|
@@ -53,12 +53,14 @@ static NSString *kLoginUserInfo = @"UserInfo";
|
|
|
|
|
|
|
|
- (void)initUserData {
|
|
- (void)initUserData {
|
|
|
NSString *userData = [self userDefaultsValue:kLoginUserInfo];
|
|
NSString *userData = [self userDefaultsValue:kLoginUserInfo];
|
|
|
- NSArray *arr = [userData componentsSeparatedByString:@"&"];
|
|
|
|
|
- [arr enumerateObjectsUsingBlock:^(id _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
|
|
|
|
|
- if (idx == 0) self.address = obj;
|
|
|
|
|
- if (idx == 1) self.user = obj;
|
|
|
|
|
- if (idx == 2) self.pwd = obj;
|
|
|
|
|
- }];
|
|
|
|
|
|
|
+ if (userData) {
|
|
|
|
|
+ NSArray *arr = [userData componentsSeparatedByString:@"&"];
|
|
|
|
|
+ [arr enumerateObjectsUsingBlock:^(id _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
|
|
|
|
|
+ if (idx == 0) self.address = obj;
|
|
|
|
|
+ if (idx == 1) self.user = obj;
|
|
|
|
|
+ if (idx == 2) self.pwd = obj;
|
|
|
|
|
+ }];
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- (void)prepareUserData {
|
|
- (void)prepareUserData {
|
|
@@ -139,7 +141,7 @@ static NSString *kLoginUserInfo = @"UserInfo";
|
|
|
#pragma mark - Delegate
|
|
#pragma mark - Delegate
|
|
|
|
|
|
|
|
- (void)switchButton:(UISwitch *)switchBtn valueChange:(BOOL)value {
|
|
- (void)switchButton:(UISwitch *)switchBtn valueChange:(BOOL)value {
|
|
|
- if (!value) [self setUserDefaultsValue:nil forKey:kLoginUserInfo];
|
|
|
|
|
|
|
+
|
|
|
[self setUserDefaultsValue:@(value) forKey:kRememberLogin];
|
|
[self setUserDefaultsValue:@(value) forKey:kRememberLogin];
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -172,9 +174,17 @@ static NSString *kLoginUserInfo = @"UserInfo";
|
|
|
dispatch_async(dispatch_get_main_queue(), ^{
|
|
dispatch_async(dispatch_get_main_queue(), ^{
|
|
|
[alert dismissWithClickedButtonIndex:0 animated:YES];
|
|
[alert dismissWithClickedButtonIndex:0 animated:YES];
|
|
|
int result = [[loginDic objectForKey:@"result"] intValue];
|
|
int result = [[loginDic objectForKey:@"result"] intValue];
|
|
|
- if (result == 1 && [strongself userDefaultsValue:kRememberLogin]) {
|
|
|
|
|
- [strongself setUserDefaultsValue:[NSString stringWithFormat:@"%@&%@&%@",strongself.address,strongself.user,strongself.pwd] forKey:kLoginUserInfo];
|
|
|
|
|
|
|
+ BOOL rememberLogin = [[strongself userDefaultsValue:kRememberLogin] boolValue];
|
|
|
|
|
+ if (result == 1) {
|
|
|
|
|
+ if (!rememberLogin) {
|
|
|
|
|
+ [self setUserDefaultsValue:nil forKey:kLoginUserInfo];
|
|
|
|
|
+ } else {
|
|
|
|
|
+ [strongself setUserDefaultsValue:[NSString stringWithFormat:@"%@&%@&%@",strongself.address,strongself.user,strongself.pwd] forKey:kLoginUserInfo];
|
|
|
|
|
+ }
|
|
|
appDelegate.bLogin = YES;
|
|
appDelegate.bLogin = YES;
|
|
|
|
|
+ appDelegate.user = strongself.user;
|
|
|
|
|
+ appDelegate.password = strongself.pwd;
|
|
|
|
|
+
|
|
|
[appDelegate showNormalRootVC];
|
|
[appDelegate showNormalRootVC];
|
|
|
} else {
|
|
} else {
|
|
|
NSString *msg = [loginDic objectForKey:@"err_msg"];
|
|
NSString *msg = [loginDic objectForKey:@"err_msg"];
|
|
@@ -191,7 +201,7 @@ static NSString *kLoginUserInfo = @"UserInfo";
|
|
|
LoginSettingViewController *loginSettingVC = [[UIStoryboard storyboardWithName:@"Main" bundle:nil] instantiateViewControllerWithIdentifier:@"LoginSettingViewController"];
|
|
LoginSettingViewController *loginSettingVC = [[UIStoryboard storyboardWithName:@"Main" bundle:nil] instantiateViewControllerWithIdentifier:@"LoginSettingViewController"];
|
|
|
__weak typeof(self) weakself = self;
|
|
__weak typeof(self) weakself = self;
|
|
|
loginSettingVC.returnValue = ^(NSString *address) {
|
|
loginSettingVC.returnValue = ^(NSString *address) {
|
|
|
- if (weakself) {
|
|
|
|
|
|
|
+ if (weakself && address.length) {
|
|
|
__strong typeof(weakself) strongself = weakself;
|
|
__strong typeof(weakself) strongself = weakself;
|
|
|
strongself.address = address;
|
|
strongself.address = address;
|
|
|
[strongself.loginTable reloadData];
|
|
[strongself.loginTable reloadData];
|