new login style

This commit is contained in:
lianxiang
2018-10-15 19:26:07 +08:00
parent 71f6176cea
commit 94ce6d3e14
30 changed files with 533 additions and 218 deletions
@@ -136,7 +136,11 @@
[MBProgressHUD hideHUDForView:self.view animated:YES];
GILog(@"短信获取%@",result.message);
if (result.success) {
[self startTimer:btn];
}else{
GIGA_ShowToast(result.message);
}
}];
+87 -49
View File
@@ -20,10 +20,12 @@
#import "GIGAMBHUDHelper.h"
#import "GiGaHelper.h"
#import "GiGaUserManager.h"
#import "NSTimer+Convenience.h"
@interface GiGaUserLoginVC ()
@property (weak, nonatomic) IBOutlet UIImageView *userImagView;
@property (weak, nonatomic) IBOutlet UITextField *acountTextField;
//0.9+ 改成code
@property (weak, nonatomic) IBOutlet UITextField *passwordTextField;
@property (weak, nonatomic) IBOutlet UIButton *loginBtn;
@@ -31,6 +33,8 @@
@property (weak, nonatomic) IBOutlet UIButton *registBtn;
@property (weak, nonatomic) IBOutlet UIButton *secretBtn;
@property(nonatomic,strong) NSTimer*timer;
@property(nonatomic) NSInteger time;
@end
@@ -38,7 +42,7 @@
- (void)viewDidLoad {
[super viewDidLoad];
_time = 60;
if (@available(iOS 11.0, *)) {
self.backScrollView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
} else {
@@ -96,8 +100,9 @@
// NSAttributedString *passholderText = [[NSAttributedString alloc] initWithString:@"密码" attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:14],NSForegroundColorAttributeName:[UIColor redColor]}];
// self.passwordTextField.attributedPlaceholder = passholderText;
UIView *passView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 40, 40)];
UIImageView *passViewIcon = [[UIImageView alloc] initWithFrame:CGRectMake(15,8, 12, 22)];
passViewIcon.image = [UIImage imageNamed:@"icon_key"];
UIImageView *passViewIcon = [[UIImageView alloc] initWithFrame:CGRectMake(12,13.5, 18, 13)];
passViewIcon.image = [UIImage imageNamed:@"ic_note"];
[passView addSubview:passViewIcon];
self.passwordTextField.leftView = passView;
self.passwordTextField.leftViewMode = UITextFieldViewModeAlways;
@@ -158,7 +163,7 @@
}
#pragma mark 手机号登录
#pragma mark 手机号登录 验证码登录
-(void)loginBtnAction:(UIButton *)btn{
if (self.acountTextField.text.length == 0) {
@@ -174,56 +179,51 @@
GIGA_ShowToast(@"密码不能为空");
return;
}
// BOOL isPass = [GiGaHelper checkPassWord:self.passwordTextField.text];
//
// if (isPass == NO) {
// GIGA_ShowToast(@"请输入6-20位数字和字母组成的密码");
// return;
// }
int leng = [GiGaHelper convertToInt: self.passwordTextField.text];
if (!(leng >= 6 && leng <= 20)) {
GIGA_ShowToast(@"请输入6-20位数字和字母组成的密码");
if (self.passwordTextField.text.length == 0) {
GIGA_ShowToast(@"请输入验证码");
return;
}
[self loginWithAction:btn];
}
-(void)loginWithAction:(UIButton *)btn{
// NSDictionary *weixinInfoDic = [GiGaUserDefault getWeiXinAccessToenDic];
// NSDictionary *weixinInfoDic = [GiGaUserDefault getWeiXinAccessToenDic];
NSString *wechatCode = [GiGaUserDefault getWeiXinCode];
NSDictionary *params = nil;
if (wechatCode) {
params = @{
@"username":self.acountTextField.text,
@"password":self.passwordTextField.text,
@"wechatCode":wechatCode,
};
}else{
params = @{
@"username":self.acountTextField.text,
@"password":self.passwordTextField.text
};
}
@"mobile":self.acountTextField.text,
@"code":self.passwordTextField.text,
@"wechatCode":wechatCode,
};
//[GIGAMBHUDHelper messageAddto:self.view title:@"登录中..."];
[self.view makeToastActivity:CSToastPositionCenter];
NSString *baseapi = [GiGaServerConfig getMainUrl];
NSString *url = [NSString stringWithFormat:@"%@%@",baseapi,kApiUserLogin];
[GiGaNetManager userbodyRequest:url params:params completionHandler:^(NSURLResponse *response, NSDictionary *resDic, NSError * _Nullable error) {
GILog(@"%@",resDic);
//NSString *baseapi = [GiGaServerConfig getMainUrl];
//NSString *url = [NSString stringWithFormat:@"%@%@",baseapi,kApiUserloginWithSMSCode];
// [GiGaNetManager userbodyRequest:url params:params completionHandler:^(NSURLResponse *response, NSDictionary *resDic, NSError * _Nullable error) {
// GILog(@"%@",resDic);
// [self.view hideToastActivity];
// GiGaAPIResult *result = [[GiGaAPIResult alloc] initWithDictionary:resDic];
// GILog(@"**登陆***\n code:%ld\n message:%@\n *******\n",result.code,result.message);
// if (result.success) {
// [self userloginSussecess:resDic];
// }else{
// GIGA_ShowToast(result.message);
// }
// }];
//[GIGAMBHUDHelper messageAddto:self.view title:@"登录中..."];
[self.view makeToastActivity:CSToastPositionCenter];
GiGaBaseAPiRequest *api = [GiGaBaseAPiRequest initWithRequestPath:kApiUserloginWithSMSCode method:RequestPostMethod parms:params];
[api requstDataWithResult:^(GiGaAPIResult *result) {
[self.view hideToastActivity];
GiGaAPIResult *result = [[GiGaAPIResult alloc] initWithDictionary:resDic];
GILog(@"**登陆***\n code:%ld\n message:%@\n *******\n",result.code,result.message);
if (result.success) {
[self userloginSussecess:resDic];
[self userloginSussecess:result.dic];
}else{
GIGA_ShowToast(result.message);
@@ -300,7 +300,7 @@
}];
}
//上传微信用户信息
// 微信登陆
-(void)gigaUploadweixinInfo:(NSDictionary *)weiXinUserinfo{
[self.view makeToastActivity:CSToastPositionCenter];
@@ -315,11 +315,10 @@
}else if([responseDict[@"code"] integerValue] == 500){
//登录流程待定
[self.view makeToast:responseDict[@"msg"] duration:2.0 position:CSToastPositionCenter];
[self jxt_showAlertWithTitle:@"温馨提示" message:@"请先绑定手机账号" appearanceProcess:^(JXTAlertController * _Nonnull alertMaker) {
//[self.view makeToast:responseDict[@"msg"] duration:2.0 position:CSToastPositionCenter];
[self jxt_showAlertWithTitle:@"温馨提示" message:responseDict[@"msg"] appearanceProcess:^(JXTAlertController * _Nonnull alertMaker) {
alertMaker.addActionCancelTitle(@"知道了");
} actionsBlock:^(NSInteger buttonIndex, UIAlertAction * _Nonnull action, JXTAlertController * _Nonnull alertSelf) {
}];
}else{
@@ -360,18 +359,57 @@
self.acountTextField.text =(NSString *)noti.object;
}
//密码加密按钮
//短信验证码按钮
-(void)secretBtnAction:(UIButton *)btn{
btn.selected = !btn.selected;
if (btn.selected) {
//秘文
self.passwordTextField.secureTextEntry = YES;
[btn setImage:[UIImage imageNamed:@"btn_tab_notselect"] forState:UIControlStateSelected];
}else{
self.passwordTextField.secureTextEntry = NO;
[btn setImage:[UIImage imageNamed:@"btn_tab_desplay"] forState:UIControlStateNormal];
if (![GiGaHelper isPhoneNumber:self.acountTextField.text]) {
GIGA_ShowToast(@"请输入正确手机号");
return;
}
[MBProgressHUD showHUDAddedTo:self.view animated:YES];
NSString *phoneNumber = self.acountTextField.text;
NSDictionary *param = @{
@"mobile":phoneNumber
};
GiGaBaseAPiRequest *api = [GiGaBaseAPiRequest initWithRequestPath:kApiIUserLoginSendCode method:RequestPostMethod parms:param];
[api requstDataWithResult:^(GiGaAPIResult *result) {
[MBProgressHUD hideHUDForView:self.view animated:YES];
GILog(@"短信获取%@",result.message);
if (result.success) {
[self startTimer:btn];
}else{
GIGA_ShowToast(result.message);
}
}];
}
//短信登录 验证码倒计时
-(void)startTimer:(UIButton *)btn{
btn.userInteractionEnabled = NO;
if (_time>0) {
_timer = [NSTimer scheduledTimerWithTimeInterval:1 count:60 callback:^{
NSString *timeStr=[NSString stringWithFormat:@"%lds",(long)self->_time];
[btn setTitle:timeStr forState:UIControlStateNormal];
self->_time--;
if (self->_time==0) {
[self.secretBtn setTitle:@"发送短信" forState:UIControlStateNormal];
self->_time =60;
btn.userInteractionEnabled = YES;
}
}];
[[NSRunLoop currentRunLoop] addTimer:self.timer forMode:NSRunLoopCommonModes];
}
}
@end
@@ -47,7 +47,7 @@
<constraint firstAttribute="height" constant="2" id="4IT-CI-Nj4"/>
</constraints>
</view>
<textField opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" placeholder="码" textAlignment="natural" minimumFontSize="17" translatesAutoresizingMaskIntoConstraints="NO" id="Y1I-OE-6t1">
<textField opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" placeholder="验证码" textAlignment="natural" minimumFontSize="17" translatesAutoresizingMaskIntoConstraints="NO" id="Y1I-OE-6t1">
<rect key="frame" x="65" y="311" width="161" height="48"/>
<constraints>
<constraint firstAttribute="height" constant="48" id="rw6-Ax-vah"/>
@@ -63,7 +63,7 @@
<constraint firstAttribute="height" constant="2" id="kqB-Hm-kqr"/>
</constraints>
</view>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="chq-bd-6sQ">
<button hidden="YES" opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="chq-bd-6sQ">
<rect key="frame" x="234" y="373" width="76" height="37"/>
<constraints>
<constraint firstAttribute="width" constant="76" id="7Tc-Zf-bbN"/>
@@ -94,7 +94,12 @@
<constraint firstAttribute="height" constant="42" id="HyY-eo-8yw"/>
<constraint firstAttribute="width" constant="76" id="pz1-th-22o"/>
</constraints>
<state key="normal" image="btn_tab_desplay"/>
<fontDescription key="fontDescription" name="TimesNewRomanPSMT" family="Times New Roman" pointSize="12"/>
<inset key="titleEdgeInsets" minX="-73" minY="0.0" maxX="0.0" maxY="0.0"/>
<inset key="imageEdgeInsets" minX="5" minY="0.0" maxX="0.0" maxY="0.0"/>
<state key="normal" title="发送验证码" image="btn_meaasag">
<color key="titleColor" red="0.91764705879999997" green="0.30196078430000001" blue="0.30196078430000001" alpha="1" colorSpace="calibratedRGB"/>
</state>
</button>
<imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="img_circle_avatar" translatesAutoresizingMaskIntoConstraints="NO" id="RIl-8E-GcR">
<rect key="frame" x="130.5" y="58" width="114" height="114"/>
@@ -122,7 +127,7 @@
</attributedString>
</state>
</button>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="F5p-cf-frr">
<button hidden="YES" opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="F5p-cf-frr">
<rect key="frame" x="80" y="373" width="55" height="36"/>
<constraints>
<constraint firstAttribute="width" constant="55" id="E7Z-DH-nia"/>
@@ -180,7 +185,7 @@
</view>
</objects>
<resources>
<image name="btn_tab_desplay" width="45" height="20"/>
<image name="btn_meaasag" width="76" height="22"/>
<image name="btn_wechat" width="126" height="25"/>
<image name="img_circle_avatar" width="114" height="114"/>
</resources>