Forráskód Böngészése

1.修改iOS Apex Drivers Update位置上传。

Pen Li 7 éve
szülő
commit
a1149b76d8

+ 1 - 1
Redant Drivers/Apex And Drivers/AppDelegate.m

@@ -85,7 +85,7 @@ static const NSInteger OrderTypeNew = 2;
 - (void)reportLocation:(CLLocation *)location {
     
     if (location) {
-        NSString *latLon = [NSString stringWithFormat:@"location: %f,%f",[RASingleton sharedInstance].currentLocation.coordinate.latitude,[RASingleton sharedInstance].currentLocation.coordinate.longitude];
+        NSString *latLon = [NSString stringWithFormat:@"%f,%f",location.coordinate.latitude,location.coordinate.longitude];
         [RADataProvider reportCurrentLocation:latLon];
     } else {
         

+ 12 - 63
Redant Drivers/Apex And Drivers/RADataProvider.m

@@ -122,11 +122,6 @@
 
 + (NSDictionary *)requestLogin:(NSString *)user password:(NSString *)pwd {
     
-
-//    return @{
-//             @"result" : @(RESULT_TRUE)
-//             };
-    
     NSMutableDictionary *params = [NSMutableDictionary dictionary];
     
     user = [[RASingleton sharedInstance] encryptString:user];
@@ -179,11 +174,6 @@
 
 + (NSDictionary *)requestOrderList {
     
-//    sleep(3.0);
-//    return [self loadFakeData:@"fake_order_list.json"];
-//    return [self fakeError];
-    
-    
     NSMutableDictionary *params = [NSMutableDictionary dictionary];
     
     
@@ -194,11 +184,6 @@
 
 + (NSDictionary *)requestMoreOrder:(NSInteger)orderType offset:(NSInteger)offset limit:(NSInteger)limit {
     
-//    sleep(2.0);
-//    return [self loadFakeData:@"fake_more_order.json"];
-    //    return [self fakeError];
-    
-    
     NSMutableDictionary *params = [NSMutableDictionary dictionary];
     [params setObject:@(orderType) forKey:@"type"];
     [params setObject:@(offset) forKey:@"offset"];
@@ -211,10 +196,6 @@
 
 + (NSDictionary *)requestOrderDetail:(NSString *)orderID type:(NSInteger)type type2:(NSString *)type2 {
     
-//    sleep(3.0);
-//    return [self loadFakeData:@"fake_order_detail.json"];
-//    return [self fakeError];
-    
     NSMutableDictionary *params = [NSMutableDictionary dictionary];
     if (orderID) {
         [params setObject:orderID forKey:@"orderID"];
@@ -231,10 +212,6 @@
 
 + (NSDictionary *)requestUpdateOrder:(NSString *)orderID driverAction:(NSInteger)action {
     
-//    sleep(3.0);
-//    return [self loadFakeData:@"fake_order_edit.json"];
-//    return [self fakeError];
-    
     NSMutableDictionary *params = [NSMutableDictionary dictionary];
     if (orderID) {
         [params setObject:orderID forKey:@"orderID"];
@@ -249,9 +226,6 @@
 
 + (NSDictionary *)reportAcionToURL:(NSString *)url withParams:(NSMutableDictionary *)params {
     
-//    sleep(3.0);
-//    return @{@"result" : @2};
-    
     NSData* json=[self get_json:url parameters:params  file:nil];
     
     return [self handleJsonData:json];
@@ -259,21 +233,6 @@
 
 + (NSDictionary *)submitEditOrder:(NSMutableDictionary *)params {
     
-//    sleep(3);
-//
-//    return [self fakeError];
-//
-//    NSMutableDictionary *result = [NSMutableDictionary dictionary];
-//    [result setObject:@(2) forKey:@"result"];
-//    for (NSString *key in params.allKeys) {
-//        if ([key hasPrefix:@"container_photo"]) {
-//            [result setObject:[NSUUID UUID].UUIDString forKey:key];
-//        }
-//    }
-//    return result;
-    
-    // ============
-    
     if (![params isKindOfClass:[NSMutableDictionary class]]) {
         params = [params mutableCopy];
     }
@@ -295,24 +254,17 @@
 }
 
 + (NSDictionary *)uploadFile:(NSString *)filePath parameters:(NSMutableDictionary *)params {
-    
-//    sleep(3.0f);
-    
-//    int i = arc4random_uniform(100);
-//    if (i % 2 == 0) {
-//        return @{@"result" : @2};
-//    } else {
-//        return @{@"result" : @1};
-//    }
-    
     return [self upload:URL_UPLOAD parameters:params file:filePath];
 }
 
 + (NSDictionary *)reportCurrentLocation:(NSString *)location {
     
     NSMutableDictionary *params = [NSMutableDictionary dictionary];
+    if (location) {
+        [params setObject:location forKey:@"location"];
+    }
     
-    NSData* json=[self get_json:URL_HOST parameters:params  file:nil];
+    NSData* json=[self get_json:URL_REPORT_LOCATION parameters:params  file:nil];
     
     return [self handleJsonData:json];
 }
@@ -326,7 +278,7 @@
     NSMutableDictionary *params = [NSMutableDictionary dictionary];
     [params setObject:token forKey:@"token"];
     
-    NSData* json=[self get_json:URL_HOST parameters:params  file:nil];
+    NSData* json=[self get_json:URL_REPORT_TOKEN parameters:params  file:nil];
     
     return [self handleJsonData:json];
 }
@@ -347,17 +299,14 @@
     return [self handleJsonData:jsonData];
 }
 
-+ (NSDictionary *)fakeError {
+//+ (NSDictionary *)fakeError {
+//
+//
 //    return @{
-//             @"result" : @0,
-//             @"err_msg" : @"server error,please try later."
+//             @"container_photo_0": @"12346798",
+//             @"container_photo_1": @"78945612",
+//             @"result": @2
 //             };
-    
-    return @{
-             @"container_photo_0": @"12346798",
-             @"container_photo_1": @"78945612",
-             @"result": @2
-             };
-}
+//}
 
 @end

+ 8 - 3
Redant Drivers/Apex And Drivers/Update/RAOrderEditViewController.m

@@ -267,6 +267,11 @@
     if (self.orderType2) {
         [params setObject:self.orderType2 forKey:@"orderType2"];
     }
+    if (RASingleton.sharedInstance.requiredLocation) {
+        CLLocation *location = RASingleton.sharedInstance.currentLocation;
+        NSString *latLon = [NSString stringWithFormat:@"%f,%f",location.coordinate.latitude,location.coordinate.longitude];
+        [params setObject:latLon forKey:@"location"];
+    }
     NSMutableArray <RAEditPhotoModel *> *photoArr = [self prepareParams:params];
     
     __weak typeof(self) weakSelf = self;
@@ -280,10 +285,10 @@
             int result = [[json objectForKey:@"result"] intValue];
             if (result == RESULT_TRUE) {
                 
+                BOOL requiredLocation = [[json objectForKey:@"requiredLocation"] boolValue];
+                [RASingleton sharedInstance].requiredLocation = requiredLocation;
+                
                 dispatch_async(dispatch_get_main_queue(), ^{
-                    BOOL requiredLocation = [[json objectForKey:@"requiredLocation"] boolValue];
-                    [RASingleton sharedInstance].requiredLocation = requiredLocation;
-                    
                     
                     if (photoArr.count > 0) {
                         [strongSelf syncUploadPhotos:photoArr Json:json HUD:hud];

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

@@ -21,6 +21,8 @@
 #define URL_SUBMIT              APPENDING_STR(@"/j/mobile/updateContainerData.mo/")
 #define URL_UPLOAD              APPENDING_STR(@"/j/mobile/uploadContainerFiles.mo/")
 #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_HOME                @"http://192.168.0.130:8080/MyWeb/Test"
 //#define URL_LOGIN               @"http://192.168.0.130:8080/MyWeb/Test"