|
|
@@ -32,6 +32,7 @@ static NSString *kLoginUserInfo = @"UserInfo";
|
|
|
[super viewDidLoad];
|
|
|
// Do any additional setup after loading the view.
|
|
|
|
|
|
+ [self initUserData];
|
|
|
[self loadData];
|
|
|
[self.loginTable reloadData];
|
|
|
}
|
|
|
@@ -116,6 +117,7 @@ static NSString *kLoginUserInfo = @"UserInfo";
|
|
|
} else if ([placeOrder isEqualToString:@"password"]) {
|
|
|
cell.textBox.text = self.pwd;
|
|
|
}
|
|
|
+ cell.textBox.secureTextEntry = [[itemDic objectForKey:@"security"] boolValue];
|
|
|
return cell;
|
|
|
|
|
|
} else if ([type isEqualToString:@"switch"]) {
|
|
|
@@ -145,14 +147,56 @@ static NSString *kLoginUserInfo = @"UserInfo";
|
|
|
|
|
|
- (IBAction)loginBtnClick:(UIButton *)sender {
|
|
|
[self prepareUserData];
|
|
|
- if ([self userDefaultsValue:kRememberLogin]) {
|
|
|
- [self setUserDefaultsValue:[NSString stringWithFormat:@"%@&%@&%@",self.address,self.user,self.pwd] forKey:kLoginUserInfo];
|
|
|
+ if (!self.address.length) {
|
|
|
+ [RAUtils message_alert:@"Please choose an address in setting" title:@"Warning" controller:self];
|
|
|
+ return;
|
|
|
}
|
|
|
+
|
|
|
+ if (!self.user.length) {
|
|
|
+ [RAUtils message_alert:@"User name cann't be blank" title:@"Warning" controller:self];
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!self.pwd.length) {
|
|
|
+ [RAUtils message_alert:@"Password cann't be blank" title:@"Warning" controller:self];
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ AppDelegate *appDelegate = (AppDelegate *)[UIApplication sharedApplication].delegate;
|
|
|
+ appDelegate.address = self.address;
|
|
|
+ __weak typeof(self) weakself = self;
|
|
|
+ UIAlertView *alert = [RAUtils waiting_alert:@"Please wait" title:@"Login"];
|
|
|
+ dispatch_async(dispatch_get_global_queue(0, 0), ^{
|
|
|
+ if (weakself) {
|
|
|
+ __strong typeof(weakself) strongself = weakself;
|
|
|
+ NSDictionary *loginDic = [RAINetwork Login:strongself.user password:strongself.pwd];
|
|
|
+ dispatch_async(dispatch_get_main_queue(), ^{
|
|
|
+ [alert dismissWithClickedButtonIndex:0 animated:YES];
|
|
|
+ int result = [[loginDic objectForKey:@"result"] intValue];
|
|
|
+ if (result == 1 && [strongself userDefaultsValue:kRememberLogin]) {
|
|
|
+ [strongself setUserDefaultsValue:[NSString stringWithFormat:@"%@&%@&%@",strongself.address,strongself.user,strongself.pwd] forKey:kLoginUserInfo];
|
|
|
+ appDelegate.bLogin = YES;
|
|
|
+ [appDelegate showNormalRootVC];
|
|
|
+ } else {
|
|
|
+ NSString *msg = [loginDic objectForKey:@"err_msg"];
|
|
|
+ [RAUtils message_alert:msg title:@"Warning" controller:strongself];
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ }
|
|
|
+ });
|
|
|
}
|
|
|
|
|
|
- (IBAction)settingBtnClick:(UIButton *)sender {
|
|
|
|
|
|
LoginSettingViewController *loginSettingVC = [[UIStoryboard storyboardWithName:@"Main" bundle:nil] instantiateViewControllerWithIdentifier:@"LoginSettingViewController"];
|
|
|
+ __weak typeof(self) weakself = self;
|
|
|
+ loginSettingVC.returnValue = ^(NSString *address) {
|
|
|
+ if (weakself) {
|
|
|
+ __strong typeof(weakself) strongself = weakself;
|
|
|
+ strongself.address = address;
|
|
|
+ [strongself.loginTable reloadData];
|
|
|
+ }
|
|
|
+ };
|
|
|
UINavigationController *settingRootNav = [[UINavigationController alloc] initWithRootViewController:loginSettingVC];
|
|
|
[self presentViewController:settingRootNav animated:YES completion:nil];
|
|
|
|