Эх сурвалжийг харах

登录账号密码保存沙盒

huangyp 6 жил өмнө
parent
commit
bfd8ac5d97

+ 13 - 4
UU_Ent/UU_Ent/Modules/Login/Main/Controllers/YRLoginVC.m

@@ -28,6 +28,14 @@
    
 }
 
+#pragma mark --- 保存账号密码进沙盒
+-(void)saveUserDataToNSUserDefaults
+{
+    [[NSUserDefaults standardUserDefaults] setObject:FORMAT(@"%@",_phoneTF.text) forKey:@"userAccount"];
+    
+    [[NSUserDefaults standardUserDefaults] setObject:FORMAT(@"%@",_passwordTF.text) forKey:@"userPassword"];
+}
+
 #pragma mark --- 登录操作
 -(void)loginAction
 {
@@ -63,6 +71,8 @@
             
             [YRUserInfo shareManager].userInfo = resDic;
             
+            [self saveUserDataToNSUserDefaults];
+            
             /*用户绑定的企业大于1个时,提供选择公司登陆*/
             if (response.companyArray.count > 1) {
                 
@@ -331,7 +341,7 @@
     [_phoneTF setValue:HexColor(@"#FFFFFF") forKeyPath:@"_placeholderLabel.textColor"];
     [firstView addSubview:_phoneTF];
     [_phoneTF addTarget:self action:@selector(passConTextChange:) forControlEvents:UIControlEventEditingChanged];
-    _phoneTF.text = @"15018524229";
+    _phoneTF.text = u_account;
     
     _passwordTF = [[UITextField alloc] initWithFrame:CGRectMake(CGRectGetMaxX(password.frame)+14, 0, self_width-90, 50)];
     _passwordTF.delegate = self;
@@ -351,7 +361,7 @@
     [_passwordTF setValue:HexColor(@"#FFFFFF") forKeyPath:@"_placeholderLabel.textColor"];
     [secondView addSubview:_passwordTF];
     [_passwordTF addTarget:self action:@selector(pwdTextChanged:) forControlEvents:UIControlEventAllEditingEvents|UIControlEventValueChanged];
-    _passwordTF.text = @"111111";
+    _passwordTF.text = u_password;
     
     self.loginBtn = [[YRButton alloc]initWithTitle:@"登录" titleColor:nil titleFont:18 buttonNormalColor:nil buttonSelectColor:nil buttonDiabledColor:nil];
     self.loginBtn.frame = CGRectMake(20, CGRectGetMaxY(secondView.frame)+25, self_width-40, 40);
@@ -364,8 +374,7 @@
     [self.scrollView addSubview:registerBtn];
     [registerBtn addTarget:self action:@selector(registerAction) forControlEvents:UIControlEventTouchUpInside];
     
-    [self loginAction];
-    
+//    [self loginAction];
 }
 
 #pragma mark --- lazy

+ 4 - 0
UU_Ent/UU_Ent/Supporting Files/defines/macro.h

@@ -9,6 +9,10 @@
 #ifndef macro_h
 #define macro_h
 
+//账号&密码
+#define u_account [[NSUserDefaults standardUserDefaults] objectForKey:@"userAccount"];
+#define u_password [[NSUserDefaults standardUserDefaults] objectForKey:@"userPassword"];
+
 //日志输出
 #ifdef DEBUG