Quellcode durchsuchen

1.修改iOS Apex Drivers Retrieve Password。

Pen Li vor 7 Jahren
Ursprung
Commit
4f1aba4ad3

+ 12 - 4
Redant Drivers/Apex And Drivers/Login/RetrievePasswordViewController.m

@@ -7,6 +7,7 @@
 //
 
 #import "RetrievePasswordViewController.h"
+#import "AppDelegate.h"
 
 @interface RetrievePasswordViewController ()
 
@@ -61,13 +62,15 @@
     dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
         
         
-        int ret = [RADataProvider requestRetrievePassword:user email:email];
+        NSDictionary *json = [RADataProvider requestRetrievePassword:user email:email];
         
         dispatch_async(dispatch_get_main_queue(), ^{
             self.mum.hidden=true;
             self.btnOk.enabled = true;
             self.btnCancel.enabled=true;
             
+            int ret = [[json objectForKey:@"result"] intValue];
+            
             if (ret==RESULT_TRUE)
             {
                 
@@ -81,14 +84,19 @@
                     
                     [alertVC addAction:action];
                     
-//                    AppDelegate *appDelegate = (AppDelegate *)[UIApplication sharedApplication].delegate;
-//                    [appDelegate.window.rootViewController presentViewController:alertVC animated:YES completion:nil];
+                    AppDelegate *appDelegate = (AppDelegate *)[UIApplication sharedApplication].delegate;
+                    [appDelegate.window.rootViewController presentViewController:alertVC animated:YES completion:nil];
                 }];
             }
             else
             {
+                NSString *msg = [json objectForKey:@"err_msg"];
+                if (msg.length == 0) {
+                    msg = [NSString stringWithFormat:NSLocalizedString(@"alert_msg_failed_retrieve_password", @"Failed to retrieve password code %d"),ret];
+                }
+                UIAlertController *alertVC = [UIAlertController alertControllerWithTitle:NSLocalizedString(@"alert_title_error", @"Error")
+                                                                                 message:msg preferredStyle:UIAlertControllerStyleAlert];
                 
-                UIAlertController *alertVC = [UIAlertController alertControllerWithTitle:NSLocalizedString(@"alert_title_error", @"Error") message:[NSString stringWithFormat:NSLocalizedString(@"alert_msg_failed_retrieve_password", @"Failed to retrieve password code %d"),ret] preferredStyle:UIAlertControllerStyleAlert];
                 UIAlertAction *action = [UIAlertAction actionWithTitle:NSLocalizedString(@"ok", @"Ok") style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
                     
                 }];

+ 1 - 1
Redant Drivers/Apex And Drivers/RADataProvider.h

@@ -12,7 +12,7 @@
 
 + (NSDictionary *)requestLogin:(NSString *)user password:(NSString *)pwd;
 
-+ (int)requestRetrievePassword : (NSString*)user  email:(NSString*)email;
++ (NSDictionary *)requestRetrievePassword : (NSString*)user  email:(NSString*)email;
 
 + (NSDictionary *)requestOrderList;
 

+ 27 - 27
Redant Drivers/Apex And Drivers/RADataProvider.m

@@ -135,41 +135,41 @@
     return [self handleJsonData:json];
 }
 
-+ (int)requestRetrievePassword : (NSString*)user  email:(NSString*)email
++ (NSDictionary *)requestRetrievePassword : (NSString*)user  email:(NSString*)email
 {
     
-    if(![NetworkUtils IsNetworkAvailable])
-        return RESULT_NET_NOTAVAILABLE;
+//    if(![NetworkUtils IsNetworkAvailable])
+//        return RESULT_NET_NOTAVAILABLE;
     NSMutableDictionary * params = [[NSMutableDictionary alloc] init];
-    [params setValue:user forKey:@"user"];
+    [params setValue:user forKey:@"name"];
     [params setValue:email forKey:@"email"];
     [params setValue:@"Retrieve Password" forKey:@"module_name"];
     [params setValue:@"handset_search" forKey:@"action"];
     
-    NSData* json=[self get_json:URL_HOST parameters:params  file:nil];
-    if (json==nil)
-    {
-        DebugLog(@"json is wrong");
-        return RESULT_NET_ERROR;
-    }
-    
-    NSError *error=nil;
-    NSDictionary *jsobj = [NSJSONSerialization JSONObjectWithData:json options:NSJSONReadingMutableLeaves error:&error];
-    if(jsobj)
-    {
-        int result = [[jsobj valueForKey:@"result"] intValue];
-        if(result!=AP_USER_AUTH)
-        {
-            DebugLog(@"USER NOT AUTHORIZED CODE=%d ",result);
-            return RESULT_FALSE;
-            
-        }
-        return RESULT_TRUE;
-        
-    }
-    return RESULT_NET_ERROR;
-    
+    NSData* json=[self get_json:URL_RETRIVE_PASSWORD parameters:params  file:nil];
+//    if (json==nil)
+//    {
+//        DebugLog(@"json is wrong");
+//        return RESULT_NET_ERROR;
+//    }
+//
+//    NSError *error=nil;
+//    NSDictionary *jsobj = [NSJSONSerialization JSONObjectWithData:json options:NSJSONReadingMutableLeaves error:&error];
+//    if(jsobj)
+//    {
+//        int result = [[jsobj valueForKey:@"result"] intValue];
+//        if(result!=AP_USER_AUTH)
+//        {
+//            DebugLog(@"USER NOT AUTHORIZED CODE=%d ",result);
+//            return RESULT_FALSE;
+//
+//        }
+//        return RESULT_TRUE;
+//
+//    }
+//    return RESULT_NET_ERROR;
     
+    return [self handleJsonData:json];
 }
 
 + (NSDictionary *)requestOrderList {

+ 1 - 0
Redant Drivers/Apex And Drivers/config.h

@@ -23,6 +23,7 @@
 #define URL_LOGOUT              APPENDING_STR(@"/j/mobile/loginOut.mo/")
 #define URL_REPORT_LOCATION     APPENDING_STR(@"/j/mobile/uploadDriverLocation.mo/")
 #define URL_REPORT_TOKEN        APPENDING_STR(@"/j/mobile/uploadToken.mo/")
+#define URL_RETRIVE_PASSWORD    APPENDING_STR(@"/j/mobile/resetPassword.mo/")
 
 //#define URL_HOME                @"http://192.168.0.130:8080/MyWeb/Test"
 //#define URL_LOGIN               @"http://192.168.0.130:8080/MyWeb/Test"