|
|
@@ -111,233 +111,458 @@
|
|
|
}
|
|
|
|
|
|
UIAlertView * waitalert = [RAUtils waiting_alert:@"Please wait" title:@"Switch user"];
|
|
|
- dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
|
|
|
+
|
|
|
+ [RANetwork request_logout:^(NSMutableDictionary *result) {
|
|
|
|
|
|
- [RANetwork logout];
|
|
|
|
|
|
- dispatch_async(dispatch_get_main_queue(), ^{
|
|
|
-
|
|
|
-
|
|
|
- appDelegate.cart_count = 0;
|
|
|
- appDelegate.wish_count =0;
|
|
|
- appDelegate.port_count =0;
|
|
|
-
|
|
|
- [appDelegate update_count_mark];
|
|
|
-
|
|
|
-
|
|
|
- appDelegate.can_show_price =false;
|
|
|
- appDelegate.can_see_price =false;
|
|
|
- appDelegate.can_create_portfolio =false;
|
|
|
- appDelegate.can_create_order =false;
|
|
|
-
|
|
|
-
|
|
|
- appDelegate.can_cancel_order =false;
|
|
|
- appDelegate.can_set_cart_price =false;
|
|
|
- appDelegate.can_delete_order =false;
|
|
|
- appDelegate.can_submit_order =false;
|
|
|
- appDelegate.can_set_tearsheet_price =false;
|
|
|
- appDelegate.can_update_contact_info = false;
|
|
|
-
|
|
|
- appDelegate.save_order_logout = false;
|
|
|
- appDelegate.submit_order_logout = false;
|
|
|
- appDelegate.alert_sold_in_quantities = false;
|
|
|
-
|
|
|
- appDelegate.ipad_perm =nil ;
|
|
|
- appDelegate.user_type = USER_ROLE_UNKNOWN;
|
|
|
- appDelegate.OrderFilter= nil;
|
|
|
- [appDelegate SetSo:nil];
|
|
|
- [appDelegate set_main_button_panel];
|
|
|
+
|
|
|
+ appDelegate.cart_count = 0;
|
|
|
+ appDelegate.wish_count =0;
|
|
|
+ appDelegate.port_count =0;
|
|
|
+
|
|
|
+ [appDelegate update_count_mark];
|
|
|
+
|
|
|
+
|
|
|
+ appDelegate.can_show_price =false;
|
|
|
+ appDelegate.can_see_price =false;
|
|
|
+ appDelegate.can_create_portfolio =false;
|
|
|
+ appDelegate.can_create_order =false;
|
|
|
+
|
|
|
+
|
|
|
+ appDelegate.can_cancel_order =false;
|
|
|
+ appDelegate.can_set_cart_price =false;
|
|
|
+ appDelegate.can_delete_order =false;
|
|
|
+ appDelegate.can_submit_order =false;
|
|
|
+ appDelegate.can_set_tearsheet_price =false;
|
|
|
+ appDelegate.can_update_contact_info = false;
|
|
|
+
|
|
|
+ appDelegate.save_order_logout = false;
|
|
|
+ appDelegate.submit_order_logout = false;
|
|
|
+ appDelegate.alert_sold_in_quantities = false;
|
|
|
+
|
|
|
+ appDelegate.ipad_perm =nil ;
|
|
|
+ appDelegate.user_type = USER_ROLE_UNKNOWN;
|
|
|
+ appDelegate.OrderFilter= nil;
|
|
|
+ [appDelegate SetSo:nil];
|
|
|
+ [appDelegate set_main_button_panel];
|
|
|
+
|
|
|
+ [appDelegate Logout];
|
|
|
+ [appDelegate checkLogin:NO];
|
|
|
+
|
|
|
+ // [waitalert dismissWithClickedButtonIndex:0 animated:FALSE];
|
|
|
+
|
|
|
+ [RANetwork request_login:user password:password completionHandler:^(NSMutableDictionary *result) {
|
|
|
+ int ret=[result[@"result"]intValue];
|
|
|
|
|
|
- [appDelegate Logout];
|
|
|
- [appDelegate checkLogin:NO];
|
|
|
|
|
|
-// [waitalert dismissWithClickedButtonIndex:0 animated:FALSE];
|
|
|
+ [waitalert dismissWithClickedButtonIndex:0 animated:FALSE];
|
|
|
|
|
|
- [RANetwork request_login:user password:password completionHandler:^(NSMutableDictionary *result) {
|
|
|
- int ret=[result[@"result"]intValue];
|
|
|
-
|
|
|
+ if(ret==RESULT_TRUE)
|
|
|
+ {
|
|
|
+ AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
|
|
|
|
|
|
- [waitalert dismissWithClickedButtonIndex:0 animated:FALSE];
|
|
|
-
|
|
|
- if(ret==RESULT_TRUE)
|
|
|
+ NSUserDefaults *defaults =[NSUserDefaults standardUserDefaults];
|
|
|
+ [defaults removeObjectForKey:@"user"];
|
|
|
+ [defaults removeObjectForKey:@"password"];
|
|
|
+ if(true)
|
|
|
{
|
|
|
- AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
|
|
|
-
|
|
|
- NSUserDefaults *defaults =[NSUserDefaults standardUserDefaults];
|
|
|
- [defaults removeObjectForKey:@"user"];
|
|
|
- [defaults removeObjectForKey:@"password"];
|
|
|
- if(true)
|
|
|
- {
|
|
|
- NSString* encryptu=[AESCrypt encrypt:appDelegate.user password:@"usai"];
|
|
|
- NSString* encryptp=[AESCrypt encrypt:appDelegate.password password:@"usai"] ;
|
|
|
-
|
|
|
- [defaults setValue:encryptu forKey:@"user"];
|
|
|
- [defaults setValue:encryptp forKey:@"password"];
|
|
|
-
|
|
|
- }
|
|
|
- [defaults synchronize];
|
|
|
+ NSString* encryptu=[AESCrypt encrypt:appDelegate.user password:@"usai"];
|
|
|
+ NSString* encryptp=[AESCrypt encrypt:appDelegate.password password:@"usai"] ;
|
|
|
|
|
|
- MainViewController* main_vc=(MainViewController*)appDelegate.main_vc;
|
|
|
- if(appDelegate.user_type==USER_ROLE_EMPLOYEE)
|
|
|
- {
|
|
|
- [main_vc checklogin:false];
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- [main_vc checklogin:false];
|
|
|
- }
|
|
|
-
|
|
|
- [self dismissViewControllerAnimated:true completion:^{
|
|
|
- if(self.returnValue)
|
|
|
- self.returnValue(true);
|
|
|
- }];
|
|
|
+ [defaults setValue:encryptu forKey:@"user"];
|
|
|
+ [defaults setValue:encryptp forKey:@"password"];
|
|
|
|
|
|
- } // 登陆成功
|
|
|
+ }
|
|
|
+ [defaults synchronize];
|
|
|
+
|
|
|
+ MainViewController* main_vc=(MainViewController*)appDelegate.main_vc;
|
|
|
+ if(appDelegate.user_type==USER_ROLE_EMPLOYEE)
|
|
|
+ {
|
|
|
+ [main_vc checklogin:false];
|
|
|
+ }
|
|
|
else
|
|
|
{
|
|
|
- NSString* msg=nil;
|
|
|
-
|
|
|
- switch (ret) {
|
|
|
-
|
|
|
- case RESULT_NET_NOTAVAILABLE:
|
|
|
- msg = MSG_NET_NOTAVAILABLE;
|
|
|
- break;
|
|
|
-
|
|
|
-
|
|
|
- case RESULT_NET_ERROR:
|
|
|
- msg = MSG_NET_ERROR;
|
|
|
- break;
|
|
|
-
|
|
|
-
|
|
|
- case RESULT_FALSE:
|
|
|
- msg = MSG_USERAUTH_ERROR;
|
|
|
- break;
|
|
|
-
|
|
|
- case RESULT_VER_LOW:
|
|
|
- msg = MSG_VER_LOW;
|
|
|
- break;
|
|
|
- default:
|
|
|
- break;
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- UIAlertController *alertControl = [UIAlertController alertControllerWithTitle:@"Switch User" message:msg preferredStyle:UIAlertControllerStyleAlert];
|
|
|
- //block代码块取代了delegate
|
|
|
- UIAlertAction *actionOne = [UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
|
|
|
+ [main_vc checklogin:false];
|
|
|
+ }
|
|
|
+
|
|
|
+ [self dismissViewControllerAnimated:true completion:^{
|
|
|
+ if(self.returnValue)
|
|
|
+ self.returnValue(true);
|
|
|
+ }];
|
|
|
+
|
|
|
+ } // 登陆成功
|
|
|
+ else
|
|
|
+ {
|
|
|
+ NSString* msg=nil;
|
|
|
+
|
|
|
+ switch (ret) {
|
|
|
|
|
|
- [self dismissViewControllerAnimated:true completion:^{
|
|
|
- if(self.returnValue)
|
|
|
- self.returnValue(false);
|
|
|
- }];
|
|
|
+ case RESULT_NET_NOTAVAILABLE:
|
|
|
+ msg = MSG_NET_NOTAVAILABLE;
|
|
|
+ break;
|
|
|
|
|
|
- }];
|
|
|
-
|
|
|
-
|
|
|
- [alertControl addAction:actionOne];
|
|
|
+
|
|
|
+ case RESULT_NET_ERROR:
|
|
|
+ msg = MSG_NET_ERROR;
|
|
|
+ break;
|
|
|
+
|
|
|
+
|
|
|
+ case RESULT_FALSE:
|
|
|
+ msg = MSG_USERAUTH_ERROR;
|
|
|
+ break;
|
|
|
+
|
|
|
+ case RESULT_VER_LOW:
|
|
|
+ msg = MSG_VER_LOW;
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ break;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ UIAlertController *alertControl = [UIAlertController alertControllerWithTitle:@"Switch User" message:msg preferredStyle:UIAlertControllerStyleAlert];
|
|
|
+ //block代码块取代了delegate
|
|
|
+ UIAlertAction *actionOne = [UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
|
|
|
|
|
|
- [self presentViewController:alertControl animated:YES completion:nil];
|
|
|
+ [self dismissViewControllerAnimated:true completion:^{
|
|
|
+ if(self.returnValue)
|
|
|
+ self.returnValue(false);
|
|
|
+ }];
|
|
|
|
|
|
- } // 登陆失败
|
|
|
+ }];
|
|
|
+
|
|
|
+
|
|
|
+ [alertControl addAction:actionOne];
|
|
|
|
|
|
+ [self presentViewController:alertControl animated:YES completion:nil];
|
|
|
|
|
|
- }];
|
|
|
+ } // 登陆失败
|
|
|
|
|
|
|
|
|
- dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
|
|
|
-
|
|
|
- int ret=[RANetwork Authorize:user password:password];
|
|
|
-
|
|
|
- dispatch_async(dispatch_get_main_queue(), ^{
|
|
|
-
|
|
|
- [waitalert dismissWithClickedButtonIndex:0 animated:FALSE];
|
|
|
-
|
|
|
- if(ret==RESULT_TRUE)
|
|
|
- {
|
|
|
- AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
|
|
|
-
|
|
|
- NSUserDefaults *defaults =[NSUserDefaults standardUserDefaults];
|
|
|
- [defaults removeObjectForKey:@"user"];
|
|
|
- [defaults removeObjectForKey:@"password"];
|
|
|
- if(true)
|
|
|
- {
|
|
|
- NSString* encryptu=[AESCrypt encrypt:appDelegate.user password:@"usai"];
|
|
|
- NSString* encryptp=[AESCrypt encrypt:appDelegate.password password:@"usai"] ;
|
|
|
-
|
|
|
- [defaults setValue:encryptu forKey:@"user"];
|
|
|
- [defaults setValue:encryptp forKey:@"password"];
|
|
|
-
|
|
|
- }
|
|
|
- [defaults synchronize];
|
|
|
-
|
|
|
- MainViewController* main_vc=(MainViewController*)appDelegate.main_vc;
|
|
|
- if(appDelegate.user_type==USER_ROLE_EMPLOYEE)
|
|
|
- {
|
|
|
- [main_vc checklogin:false];
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- [main_vc checklogin:false];
|
|
|
- }
|
|
|
-
|
|
|
- [self dismissViewControllerAnimated:true completion:^{
|
|
|
- if(self.returnValue)
|
|
|
- self.returnValue(true);
|
|
|
- }];
|
|
|
-
|
|
|
- } // 登陆成功
|
|
|
- else
|
|
|
- {
|
|
|
- NSString* msg=nil;
|
|
|
-
|
|
|
- switch (ret) {
|
|
|
-
|
|
|
- case RESULT_NET_NOTAVAILABLE:
|
|
|
- msg = MSG_NET_NOTAVAILABLE;
|
|
|
- break;
|
|
|
-
|
|
|
-
|
|
|
- case RESULT_NET_ERROR:
|
|
|
- msg = MSG_NET_ERROR;
|
|
|
- break;
|
|
|
-
|
|
|
-
|
|
|
- case RESULT_FALSE:
|
|
|
- msg = MSG_USERAUTH_ERROR;
|
|
|
- break;
|
|
|
-
|
|
|
- case RESULT_VER_LOW:
|
|
|
- msg = MSG_VER_LOW;
|
|
|
- break;
|
|
|
- default:
|
|
|
- break;
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- UIAlertController *alertControl = [UIAlertController alertControllerWithTitle:@"Switch User" message:msg preferredStyle:UIAlertControllerStyleAlert];
|
|
|
- //block代码块取代了delegate
|
|
|
- UIAlertAction *actionOne = [UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
|
|
|
-
|
|
|
- [self dismissViewControllerAnimated:true completion:^{
|
|
|
- if(self.returnValue)
|
|
|
- self.returnValue(false);
|
|
|
- }];
|
|
|
-
|
|
|
- }];
|
|
|
-
|
|
|
-
|
|
|
- [alertControl addAction:actionOne];
|
|
|
-
|
|
|
- [self presentViewController:alertControl animated:YES completion:nil];
|
|
|
-
|
|
|
- } // 登陆失败
|
|
|
-
|
|
|
- }); // update login ui
|
|
|
-
|
|
|
- }); // attemp login
|
|
|
-
|
|
|
- }); // update logout ui
|
|
|
+ }];
|
|
|
|
|
|
- }); // logout
|
|
|
+
|
|
|
+ // dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
|
|
|
+ //
|
|
|
+ // int ret=[RANetwork Authorize:user password:password];
|
|
|
+ //
|
|
|
+ // dispatch_async(dispatch_get_main_queue(), ^{
|
|
|
+ //
|
|
|
+ // [waitalert dismissWithClickedButtonIndex:0 animated:FALSE];
|
|
|
+ //
|
|
|
+ // if(ret==RESULT_TRUE)
|
|
|
+ // {
|
|
|
+ // AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
|
|
|
+ //
|
|
|
+ // NSUserDefaults *defaults =[NSUserDefaults standardUserDefaults];
|
|
|
+ // [defaults removeObjectForKey:@"user"];
|
|
|
+ // [defaults removeObjectForKey:@"password"];
|
|
|
+ // if(true)
|
|
|
+ // {
|
|
|
+ // NSString* encryptu=[AESCrypt encrypt:appDelegate.user password:@"usai"];
|
|
|
+ // NSString* encryptp=[AESCrypt encrypt:appDelegate.password password:@"usai"] ;
|
|
|
+ //
|
|
|
+ // [defaults setValue:encryptu forKey:@"user"];
|
|
|
+ // [defaults setValue:encryptp forKey:@"password"];
|
|
|
+ //
|
|
|
+ // }
|
|
|
+ // [defaults synchronize];
|
|
|
+ //
|
|
|
+ // MainViewController* main_vc=(MainViewController*)appDelegate.main_vc;
|
|
|
+ // if(appDelegate.user_type==USER_ROLE_EMPLOYEE)
|
|
|
+ // {
|
|
|
+ // [main_vc checklogin:false];
|
|
|
+ // }
|
|
|
+ // else
|
|
|
+ // {
|
|
|
+ // [main_vc checklogin:false];
|
|
|
+ // }
|
|
|
+ //
|
|
|
+ // [self dismissViewControllerAnimated:true completion:^{
|
|
|
+ // if(self.returnValue)
|
|
|
+ // self.returnValue(true);
|
|
|
+ // }];
|
|
|
+ //
|
|
|
+ // } // 登陆成功
|
|
|
+ // else
|
|
|
+ // {
|
|
|
+ // NSString* msg=nil;
|
|
|
+ //
|
|
|
+ // switch (ret) {
|
|
|
+ //
|
|
|
+ // case RESULT_NET_NOTAVAILABLE:
|
|
|
+ // msg = MSG_NET_NOTAVAILABLE;
|
|
|
+ // break;
|
|
|
+ //
|
|
|
+ //
|
|
|
+ // case RESULT_NET_ERROR:
|
|
|
+ // msg = MSG_NET_ERROR;
|
|
|
+ // break;
|
|
|
+ //
|
|
|
+ //
|
|
|
+ // case RESULT_FALSE:
|
|
|
+ // msg = MSG_USERAUTH_ERROR;
|
|
|
+ // break;
|
|
|
+ //
|
|
|
+ // case RESULT_VER_LOW:
|
|
|
+ // msg = MSG_VER_LOW;
|
|
|
+ // break;
|
|
|
+ // default:
|
|
|
+ // break;
|
|
|
+ // }
|
|
|
+ //
|
|
|
+ //
|
|
|
+ // UIAlertController *alertControl = [UIAlertController alertControllerWithTitle:@"Switch User" message:msg preferredStyle:UIAlertControllerStyleAlert];
|
|
|
+ // //block代码块取代了delegate
|
|
|
+ // UIAlertAction *actionOne = [UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
|
|
|
+ //
|
|
|
+ // [self dismissViewControllerAnimated:true completion:^{
|
|
|
+ // if(self.returnValue)
|
|
|
+ // self.returnValue(false);
|
|
|
+ // }];
|
|
|
+ //
|
|
|
+ // }];
|
|
|
+ //
|
|
|
+ //
|
|
|
+ // [alertControl addAction:actionOne];
|
|
|
+ //
|
|
|
+ // [self presentViewController:alertControl animated:YES completion:nil];
|
|
|
+ //
|
|
|
+ // } // 登陆失败
|
|
|
+ //
|
|
|
+ // }); // update login ui
|
|
|
+ //
|
|
|
+ // }); // attemp login
|
|
|
+
|
|
|
+
|
|
|
+ }];
|
|
|
+
|
|
|
+// dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
|
|
|
+//
|
|
|
+// [RANetwork logout];
|
|
|
+//
|
|
|
+// dispatch_async(dispatch_get_main_queue(), ^{
|
|
|
+//
|
|
|
+//
|
|
|
+// appDelegate.cart_count = 0;
|
|
|
+// appDelegate.wish_count =0;
|
|
|
+// appDelegate.port_count =0;
|
|
|
+//
|
|
|
+// [appDelegate update_count_mark];
|
|
|
+//
|
|
|
+//
|
|
|
+// appDelegate.can_show_price =false;
|
|
|
+// appDelegate.can_see_price =false;
|
|
|
+// appDelegate.can_create_portfolio =false;
|
|
|
+// appDelegate.can_create_order =false;
|
|
|
+//
|
|
|
+//
|
|
|
+// appDelegate.can_cancel_order =false;
|
|
|
+// appDelegate.can_set_cart_price =false;
|
|
|
+// appDelegate.can_delete_order =false;
|
|
|
+// appDelegate.can_submit_order =false;
|
|
|
+// appDelegate.can_set_tearsheet_price =false;
|
|
|
+// appDelegate.can_update_contact_info = false;
|
|
|
+//
|
|
|
+// appDelegate.save_order_logout = false;
|
|
|
+// appDelegate.submit_order_logout = false;
|
|
|
+// appDelegate.alert_sold_in_quantities = false;
|
|
|
+//
|
|
|
+// appDelegate.ipad_perm =nil ;
|
|
|
+// appDelegate.user_type = USER_ROLE_UNKNOWN;
|
|
|
+// appDelegate.OrderFilter= nil;
|
|
|
+// [appDelegate SetSo:nil];
|
|
|
+// [appDelegate set_main_button_panel];
|
|
|
+//
|
|
|
+// [appDelegate Logout];
|
|
|
+// [appDelegate checkLogin:NO];
|
|
|
+//
|
|
|
+//// [waitalert dismissWithClickedButtonIndex:0 animated:FALSE];
|
|
|
+//
|
|
|
+// [RANetwork request_login:user password:password completionHandler:^(NSMutableDictionary *result) {
|
|
|
+// int ret=[result[@"result"]intValue];
|
|
|
+//
|
|
|
+//
|
|
|
+// [waitalert dismissWithClickedButtonIndex:0 animated:FALSE];
|
|
|
+//
|
|
|
+// if(ret==RESULT_TRUE)
|
|
|
+// {
|
|
|
+// AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
|
|
|
+//
|
|
|
+// NSUserDefaults *defaults =[NSUserDefaults standardUserDefaults];
|
|
|
+// [defaults removeObjectForKey:@"user"];
|
|
|
+// [defaults removeObjectForKey:@"password"];
|
|
|
+// if(true)
|
|
|
+// {
|
|
|
+// NSString* encryptu=[AESCrypt encrypt:appDelegate.user password:@"usai"];
|
|
|
+// NSString* encryptp=[AESCrypt encrypt:appDelegate.password password:@"usai"] ;
|
|
|
+//
|
|
|
+// [defaults setValue:encryptu forKey:@"user"];
|
|
|
+// [defaults setValue:encryptp forKey:@"password"];
|
|
|
+//
|
|
|
+// }
|
|
|
+// [defaults synchronize];
|
|
|
+//
|
|
|
+// MainViewController* main_vc=(MainViewController*)appDelegate.main_vc;
|
|
|
+// if(appDelegate.user_type==USER_ROLE_EMPLOYEE)
|
|
|
+// {
|
|
|
+// [main_vc checklogin:false];
|
|
|
+// }
|
|
|
+// else
|
|
|
+// {
|
|
|
+// [main_vc checklogin:false];
|
|
|
+// }
|
|
|
+//
|
|
|
+// [self dismissViewControllerAnimated:true completion:^{
|
|
|
+// if(self.returnValue)
|
|
|
+// self.returnValue(true);
|
|
|
+// }];
|
|
|
+//
|
|
|
+// } // 登陆成功
|
|
|
+// else
|
|
|
+// {
|
|
|
+// NSString* msg=nil;
|
|
|
+//
|
|
|
+// switch (ret) {
|
|
|
+//
|
|
|
+// case RESULT_NET_NOTAVAILABLE:
|
|
|
+// msg = MSG_NET_NOTAVAILABLE;
|
|
|
+// break;
|
|
|
+//
|
|
|
+//
|
|
|
+// case RESULT_NET_ERROR:
|
|
|
+// msg = MSG_NET_ERROR;
|
|
|
+// break;
|
|
|
+//
|
|
|
+//
|
|
|
+// case RESULT_FALSE:
|
|
|
+// msg = MSG_USERAUTH_ERROR;
|
|
|
+// break;
|
|
|
+//
|
|
|
+// case RESULT_VER_LOW:
|
|
|
+// msg = MSG_VER_LOW;
|
|
|
+// break;
|
|
|
+// default:
|
|
|
+// break;
|
|
|
+// }
|
|
|
+//
|
|
|
+//
|
|
|
+// UIAlertController *alertControl = [UIAlertController alertControllerWithTitle:@"Switch User" message:msg preferredStyle:UIAlertControllerStyleAlert];
|
|
|
+// //block代码块取代了delegate
|
|
|
+// UIAlertAction *actionOne = [UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
|
|
|
+//
|
|
|
+// [self dismissViewControllerAnimated:true completion:^{
|
|
|
+// if(self.returnValue)
|
|
|
+// self.returnValue(false);
|
|
|
+// }];
|
|
|
+//
|
|
|
+// }];
|
|
|
+//
|
|
|
+//
|
|
|
+// [alertControl addAction:actionOne];
|
|
|
+//
|
|
|
+// [self presentViewController:alertControl animated:YES completion:nil];
|
|
|
+//
|
|
|
+// } // 登陆失败
|
|
|
+//
|
|
|
+//
|
|
|
+// }];
|
|
|
+//
|
|
|
+//
|
|
|
+//// dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
|
|
|
+////
|
|
|
+//// int ret=[RANetwork Authorize:user password:password];
|
|
|
+////
|
|
|
+//// dispatch_async(dispatch_get_main_queue(), ^{
|
|
|
+////
|
|
|
+//// [waitalert dismissWithClickedButtonIndex:0 animated:FALSE];
|
|
|
+////
|
|
|
+//// if(ret==RESULT_TRUE)
|
|
|
+//// {
|
|
|
+//// AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
|
|
|
+////
|
|
|
+//// NSUserDefaults *defaults =[NSUserDefaults standardUserDefaults];
|
|
|
+//// [defaults removeObjectForKey:@"user"];
|
|
|
+//// [defaults removeObjectForKey:@"password"];
|
|
|
+//// if(true)
|
|
|
+//// {
|
|
|
+//// NSString* encryptu=[AESCrypt encrypt:appDelegate.user password:@"usai"];
|
|
|
+//// NSString* encryptp=[AESCrypt encrypt:appDelegate.password password:@"usai"] ;
|
|
|
+////
|
|
|
+//// [defaults setValue:encryptu forKey:@"user"];
|
|
|
+//// [defaults setValue:encryptp forKey:@"password"];
|
|
|
+////
|
|
|
+//// }
|
|
|
+//// [defaults synchronize];
|
|
|
+////
|
|
|
+//// MainViewController* main_vc=(MainViewController*)appDelegate.main_vc;
|
|
|
+//// if(appDelegate.user_type==USER_ROLE_EMPLOYEE)
|
|
|
+//// {
|
|
|
+//// [main_vc checklogin:false];
|
|
|
+//// }
|
|
|
+//// else
|
|
|
+//// {
|
|
|
+//// [main_vc checklogin:false];
|
|
|
+//// }
|
|
|
+////
|
|
|
+//// [self dismissViewControllerAnimated:true completion:^{
|
|
|
+//// if(self.returnValue)
|
|
|
+//// self.returnValue(true);
|
|
|
+//// }];
|
|
|
+////
|
|
|
+//// } // 登陆成功
|
|
|
+//// else
|
|
|
+//// {
|
|
|
+//// NSString* msg=nil;
|
|
|
+////
|
|
|
+//// switch (ret) {
|
|
|
+////
|
|
|
+//// case RESULT_NET_NOTAVAILABLE:
|
|
|
+//// msg = MSG_NET_NOTAVAILABLE;
|
|
|
+//// break;
|
|
|
+////
|
|
|
+////
|
|
|
+//// case RESULT_NET_ERROR:
|
|
|
+//// msg = MSG_NET_ERROR;
|
|
|
+//// break;
|
|
|
+////
|
|
|
+////
|
|
|
+//// case RESULT_FALSE:
|
|
|
+//// msg = MSG_USERAUTH_ERROR;
|
|
|
+//// break;
|
|
|
+////
|
|
|
+//// case RESULT_VER_LOW:
|
|
|
+//// msg = MSG_VER_LOW;
|
|
|
+//// break;
|
|
|
+//// default:
|
|
|
+//// break;
|
|
|
+//// }
|
|
|
+////
|
|
|
+////
|
|
|
+//// UIAlertController *alertControl = [UIAlertController alertControllerWithTitle:@"Switch User" message:msg preferredStyle:UIAlertControllerStyleAlert];
|
|
|
+//// //block代码块取代了delegate
|
|
|
+//// UIAlertAction *actionOne = [UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
|
|
|
+////
|
|
|
+//// [self dismissViewControllerAnimated:true completion:^{
|
|
|
+//// if(self.returnValue)
|
|
|
+//// self.returnValue(false);
|
|
|
+//// }];
|
|
|
+////
|
|
|
+//// }];
|
|
|
+////
|
|
|
+////
|
|
|
+//// [alertControl addAction:actionOne];
|
|
|
+////
|
|
|
+//// [self presentViewController:alertControl animated:YES completion:nil];
|
|
|
+////
|
|
|
+//// } // 登陆失败
|
|
|
+////
|
|
|
+//// }); // update login ui
|
|
|
+////
|
|
|
+//// }); // attemp login
|
|
|
+//
|
|
|
+// }); // update logout ui
|
|
|
+//
|
|
|
+// }); // logout
|
|
|
}
|
|
|
|
|
|
|