فهرست منبع

1.修改iOS Apex & Drivers上传处理,将照片由打包上传改为单独上传。

Pen Li 8 سال پیش
والد
کامیت
ddf1fd68ad

+ 12 - 9
Redant Drivers/Apex And Drivers/AppDelegate.m

@@ -13,9 +13,7 @@
 
 
 @interface AppDelegate ()<UNUserNotificationCenterDelegate,CLLocationManagerDelegate>
 @interface AppDelegate ()<UNUserNotificationCenterDelegate,CLLocationManagerDelegate>
 
 
-@property (nonatomic,weak) UINavigationController *rootVC;
 @property (nonatomic,strong) CLLocationManager *locationManager;
 @property (nonatomic,strong) CLLocationManager *locationManager;
-@property (nonatomic,strong) CLLocation *currentLocation;
 
 
 @end
 @end
 
 
@@ -50,7 +48,7 @@
     self.locationManager.allowsBackgroundLocationUpdates = YES;
     self.locationManager.allowsBackgroundLocationUpdates = YES;
     self.locationManager.pausesLocationUpdatesAutomatically = NO; // 是否允许系统自动暂停定位
     self.locationManager.pausesLocationUpdatesAutomatically = NO; // 是否允许系统自动暂停定位
     self.locationManager.desiredAccuracy = kCLLocationAccuracyBestForNavigation;//设置定位精度
     self.locationManager.desiredAccuracy = kCLLocationAccuracyBestForNavigation;//设置定位精度
-    self.locationManager.distanceFilter = kCLDistanceFilterNone; //不需要移动都可以刷新,不然不移动就不会执行定位,不定位的话,那么后台进程也就挂起了
+    self.locationManager.distanceFilter = 10; //不需要移动都可以刷新,不然不移动就不会执行定位,不定位的话,那么后台进程也就挂起了
     [self.locationManager requestAlwaysAuthorization];
     [self.locationManager requestAlwaysAuthorization];
     [self.locationManager startUpdatingLocation];
     [self.locationManager startUpdatingLocation];
 }
 }
@@ -66,7 +64,8 @@
 - (void)reportLocation:(CLLocation *)location {
 - (void)reportLocation:(CLLocation *)location {
     
     
     if (location) {
     if (location) {
-        
+        NSString *latLon = [NSString stringWithFormat:@"location: %f,%f",[RASingleton sharedInstance].currentLocation.coordinate.latitude,[RASingleton sharedInstance].currentLocation.coordinate.longitude];
+        [RADataProvider reportCurrentLocation:latLon];
     } else {
     } else {
         
         
     }
     }
@@ -87,7 +86,11 @@
     self.window.rootViewController = nav;
     self.window.rootViewController = nav;
     
     
     __weak typeof(self) weakSelf = self;
     __weak typeof(self) weakSelf = self;
-    rootVC.loginSuccessful = ^{
+    rootVC.loginSuccessful = ^(NSString *user,NSString *password){
+        
+        RASingleton.sharedInstance.user = user;
+        RASingleton.sharedInstance.password = password;
+        [RASingleton.sharedInstance saveUserInfo];
         
         
         [weakSelf showHomeVC];
         [weakSelf showHomeVC];
     };
     };
@@ -182,7 +185,7 @@
         NSInteger report_location = [[aps objectForKey:@"report-location"] integerValue];
         NSInteger report_location = [[aps objectForKey:@"report-location"] integerValue];
         if (report_location == 1) {
         if (report_location == 1) {
             
             
-            [self reportLocation:self.currentLocation];
+            [self reportLocation:[RASingleton sharedInstance].currentLocation];
             completionHandler(UIBackgroundFetchResultNewData);
             completionHandler(UIBackgroundFetchResultNewData);
         } else {
         } else {
             /**
             /**
@@ -215,9 +218,9 @@
 
 
 - (void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray<CLLocation *> *)locations {
 - (void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray<CLLocation *> *)locations {
     if (locations.count) {
     if (locations.count) {
-        self.currentLocation = [locations lastObject];
+        [RASingleton sharedInstance].currentLocation = [locations lastObject];
         
         
-        NSLog(@"location: %f, %f",self.currentLocation.coordinate.latitude,self.currentLocation.coordinate.longitude);
+        NSLog(@"location: %f, %f",[RASingleton sharedInstance].currentLocation.coordinate.latitude,[RASingleton sharedInstance].currentLocation.coordinate.longitude);
         
         
         // 省电,停止不能超过三分钟
         // 省电,停止不能超过三分钟
 //        [self performSelector:@selector(stopLocation) withObject:nil afterDelay:10]; // 获取到位置10s后关闭位置服务
 //        [self performSelector:@selector(stopLocation) withObject:nil afterDelay:10]; // 获取到位置10s后关闭位置服务
@@ -231,7 +234,7 @@
 - (void)locationManager:(CLLocationManager *)manager didChangeAuthorizationStatus:(CLAuthorizationStatus)status {
 - (void)locationManager:(CLLocationManager *)manager didChangeAuthorizationStatus:(CLAuthorizationStatus)status {
     
     
     if (status == kCLAuthorizationStatusDenied) {
     if (status == kCLAuthorizationStatusDenied) {
-        self.currentLocation = nil;
+        [RASingleton sharedInstance].currentLocation = nil;
     }
     }
 }
 }
 
 

+ 2 - 0
Redant Drivers/Apex And Drivers/BaseViewController/RABaseViewController.h

@@ -14,4 +14,6 @@
 
 
 + (instancetype)viewControllerFromStoryboard;
 + (instancetype)viewControllerFromStoryboard;
 
 
+- (void)showAlertTilte:(NSString *)title message:(NSString *)msg;
+
 @end
 @end

+ 15 - 0
Redant Drivers/Apex And Drivers/BaseViewController/RABaseViewController.m

@@ -32,5 +32,20 @@
     // Dispose of any resources that can be recreated.
     // Dispose of any resources that can be recreated.
 }
 }
 
 
+- (void)showAlertTilte:(NSString *)title message:(NSString *)msg {
+    
+    if (title.length == 0 && msg.length == 0) {
+        return;
+    }
+    
+    UIAlertController *alertVC = [UIAlertController alertControllerWithTitle:title message:msg preferredStyle:UIAlertControllerStyleAlert];
+    UIAlertAction *okAction = [UIAlertAction actionWithTitle:@"Ok" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
+        
+    }];
+    
+    [alertVC addAction:okAction];
+    
+    [self presentViewController:alertVC animated:YES completion:nil];
+}
 
 
 @end
 @end

+ 3 - 3
Redant Drivers/Apex And Drivers/Camera/RATakePhotoPreviewController.m

@@ -39,9 +39,9 @@
     _preImage = [preImage fixOrientation];
     _preImage = [preImage fixOrientation];
 }
 }
 
 
-- (BOOL)prefersStatusBarHidden {
-    return YES;
-}
+//- (BOOL)prefersStatusBarHidden {
+//    return YES;
+//}
 
 
 - (void)didReceiveMemoryWarning {
 - (void)didReceiveMemoryWarning {
     [super didReceiveMemoryWarning];
     [super didReceiveMemoryWarning];

+ 17 - 1
Redant Drivers/Apex And Drivers/Detail/RAOrderDetailViewController.m

@@ -97,6 +97,7 @@
 
 
 @property (strong, nonatomic) IBOutlet UITableView *detailTableView;
 @property (strong, nonatomic) IBOutlet UITableView *detailTableView;
 @property (nonatomic,strong) NSMutableArray <RAOrderDetailSectionModel *> *sectionArray;
 @property (nonatomic,strong) NSMutableArray <RAOrderDetailSectionModel *> *sectionArray;
+@property (nonatomic,strong) UIRefreshControl *refreshControl;
 
 
 @end
 @end
 
 
@@ -124,6 +125,17 @@
     
     
     self.detailTableView.tableFooterView = [UIView new];
     self.detailTableView.tableFooterView = [UIView new];
     self.detailTableView.separatorInset = UIEdgeInsetsMake(0, 0, 0, 0);
     self.detailTableView.separatorInset = UIEdgeInsetsMake(0, 0, 0, 0);
+    
+    UIRefreshControl *refresh = [[UIRefreshControl alloc] init];
+    [refresh addTarget:self action:@selector(refreshControlValueChanged:) forControlEvents:UIControlEventValueChanged];
+    [self.detailTableView addSubview:refresh];
+    self.refreshControl = refresh;
+}
+
+#pragma mark - Action
+
+- (void)refreshControlValueChanged:(UIRefreshControl *)refresh {
+    [self loadData];
 }
 }
 
 
 #pragma mark - Data
 #pragma mark - Data
@@ -143,6 +155,9 @@
             
             
             // dismiss progress
             // dismiss progress
             [hud dismiss];
             [hud dismiss];
+            if (weakSelf.refreshControl.isRefreshing) {
+                [weakSelf.refreshControl endRefreshing];
+            }
             
             
             if (weakSelf) {
             if (weakSelf) {
                 __strong typeof(weakSelf) strongSelf = weakSelf;
                 __strong typeof(weakSelf) strongSelf = weakSelf;
@@ -164,7 +179,8 @@
                     
                     
                 } else {
                 } else {
                     // process error
                     // process error
-                    
+                    NSString *msg = [json objectForKey:@"err_msg"];
+                    [strongSelf showAlertTilte:@"Warning" message:msg];
                 }
                 }
             }
             }
             
             

+ 22 - 2
Redant Drivers/Apex And Drivers/Home/RAHomeViewController.m

@@ -63,6 +63,7 @@
 
 
 @property (nonatomic,strong) NSMutableArray <RAHomeSectionModel *> *sectionArray;
 @property (nonatomic,strong) NSMutableArray <RAHomeSectionModel *> *sectionArray;
 @property (nonatomic,strong) NSIndexPath *currentIndexPath;
 @property (nonatomic,strong) NSIndexPath *currentIndexPath;
+@property (nonatomic,strong) UIRefreshControl *refreshControl;
 
 
 @end
 @end
 
 
@@ -85,6 +86,7 @@
 
 
 - (void)viewWillAppear:(BOOL)animated {
 - (void)viewWillAppear:(BOOL)animated {
     [super viewWillAppear:animated];
     [super viewWillAppear:animated];
+    
 }
 }
 
 
 - (void)dealloc {
 - (void)dealloc {
@@ -102,6 +104,11 @@
     
     
     self.homeOrderTableView.tableFooterView = [UIView new];
     self.homeOrderTableView.tableFooterView = [UIView new];
     self.homeOrderTableView.separatorInset = UIEdgeInsetsMake(0, 0, 0, 0);
     self.homeOrderTableView.separatorInset = UIEdgeInsetsMake(0, 0, 0, 0);
+    
+    UIRefreshControl *refresh = [[UIRefreshControl alloc] init];
+    [refresh addTarget:self action:@selector(refreshControlValueChanged:) forControlEvents:UIControlEventValueChanged];
+    [self.homeOrderTableView addSubview:refresh];
+    self.refreshControl = refresh;
 }
 }
 
 
 - (void)configureNavigationBar {
 - (void)configureNavigationBar {
@@ -122,6 +129,10 @@
     [self.navigationController pushViewController:vc animated:YES];
     [self.navigationController pushViewController:vc animated:YES];
 }
 }
 
 
+- (void)refreshControlValueChanged:(UIRefreshControl *)refresh {
+    [self loadData];
+}
+
 #pragma mark - Getter
 #pragma mark - Getter
 
 
 - (NSMutableArray *)sectionArray {
 - (NSMutableArray *)sectionArray {
@@ -168,6 +179,9 @@
             
             
             // dismiss progress
             // dismiss progress
             [hud dismiss];
             [hud dismiss];
+            if (weakSelf.refreshControl.isRefreshing) {
+                [weakSelf.refreshControl endRefreshing];
+            }
             
             
             if (weakSelf) {
             if (weakSelf) {
                 __strong typeof(weakSelf) strongSelf = weakSelf;
                 __strong typeof(weakSelf) strongSelf = weakSelf;
@@ -191,10 +205,16 @@
                     }
                     }
 
 
                     [strongSelf.homeOrderTableView reloadData];
                     [strongSelf.homeOrderTableView reloadData];
-                    
+                    if (self.currentIndexPath) {
+//                        [strongSelf.homeOrderTableView scrollToRowAtIndexPath:self.currentIndexPath atScrollPosition:UITableViewScrollPositionMiddle animated:NO];
+                        [strongSelf.homeOrderTableView selectRowAtIndexPath:self.currentIndexPath animated:NO scrollPosition:UITableViewScrollPositionMiddle];
+                    } else {
+                        
+                    }
                 } else {
                 } else {
                     // process error
                     // process error
-                    
+                    NSString *msg = [json objectForKey:@"err_msg"];
+                    [strongSelf showAlertTilte:@"Warning" message:msg];
                 }
                 }
             }
             }
             
             

+ 1 - 1
Redant Drivers/Apex And Drivers/Login/LoginViewController.h

@@ -11,7 +11,7 @@
 
 
 @interface LoginViewController : RABaseViewController<UITextFieldDelegate>
 @interface LoginViewController : RABaseViewController<UITextFieldDelegate>
 
 
-@property (nonatomic , copy) void (^loginSuccessful)(void);
+@property (nonatomic , copy) void (^loginSuccessful)(NSString *user,NSString *password);
 @property (strong, nonatomic) IBOutlet UIButton *checkSavePassword;
 @property (strong, nonatomic) IBOutlet UIButton *checkSavePassword;
 @property (strong, nonatomic) IBOutlet UITextField *editUser;
 @property (strong, nonatomic) IBOutlet UITextField *editUser;
 @property (strong, nonatomic) IBOutlet UITextField *editPassword;
 @property (strong, nonatomic) IBOutlet UITextField *editPassword;

+ 3 - 17
Redant Drivers/Apex And Drivers/Login/LoginViewController.m

@@ -78,20 +78,8 @@
             
             
             if (ret==RESULT_TRUE)
             if (ret==RESULT_TRUE)
             {
             {
-                
-                NSUserDefaults *defaults =[NSUserDefaults standardUserDefaults];
-                [defaults removeObjectForKey:@"user"];
-                [defaults removeObjectForKey:@"password"];
-               
-                [defaults setValue:[AESCrypt encrypt:self.editUser.text.lowercaseString password:@"usai"] forKey:@"user"];
-                [defaults setValue:[AESCrypt encrypt:self.editPassword.text password:@"usai"] forKey:@"password"];
-                [defaults setBool:TRUE forKey:@"autologin"];
-                
-                [defaults synchronize];
-                
                 if(self.loginSuccessful)
                 if(self.loginSuccessful)
-                    self.loginSuccessful();
-                
+                    self.loginSuccessful(self.editUser.text.lowercaseString,self.editPassword.text);
             }
             }
             else
             else
             {
             {
@@ -179,10 +167,8 @@
 - (void)viewWillAppear:(BOOL)animated {
 - (void)viewWillAppear:(BOOL)animated {
     [super viewWillAppear:animated];
     [super viewWillAppear:animated];
     
     
-    
-    NSUserDefaults *defaults =[NSUserDefaults standardUserDefaults];
-    NSString * user = [AESCrypt decrypt:[defaults stringForKey:@"user"] password:@"usai"];
-    NSString * password = [AESCrypt decrypt:[defaults stringForKey:@"password"] password:@"usai"];
+    NSString * user = RASingleton.sharedInstance.savedUser;
+    NSString *password = RASingleton.sharedInstance.savedPassword;
     
     
     if(user.length>0&&password.length>0)
     if(user.length>0&&password.length>0)
     {
     {

+ 10 - 1
Redant Drivers/Apex And Drivers/QRCode/QRCode.storyboard

@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <?xml version="1.0" encoding="UTF-8"?>
-<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="14109" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
+<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="14113" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
     <device id="retina4_7" orientation="portrait">
     <device id="retina4_7" orientation="portrait">
         <adaptation id="fullscreen"/>
         <adaptation id="fullscreen"/>
     </device>
     </device>
@@ -23,6 +23,10 @@
                                 <rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
                                 <rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
                                 <color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
                                 <color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
                             </view>
                             </view>
+                            <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="4DJ-GK-9l9">
+                                <rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
+                                <color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
+                            </view>
                             <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="vCI-Zm-N7X">
                             <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="vCI-Zm-N7X">
                                 <rect key="frame" x="70" y="146" width="235" height="235"/>
                                 <rect key="frame" x="70" y="146" width="235" height="235"/>
                                 <color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
                                 <color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
@@ -45,20 +49,25 @@
                         <color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
                         <color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
                         <constraints>
                         <constraints>
                             <constraint firstItem="0ig-dn-iSa" firstAttribute="top" relation="greaterThanOrEqual" secondItem="vCI-Zm-N7X" secondAttribute="bottom" constant="10" id="3gR-v0-uuY"/>
                             <constraint firstItem="0ig-dn-iSa" firstAttribute="top" relation="greaterThanOrEqual" secondItem="vCI-Zm-N7X" secondAttribute="bottom" constant="10" id="3gR-v0-uuY"/>
+                            <constraint firstItem="4DJ-GK-9l9" firstAttribute="height" secondItem="D8z-rA-Qpf" secondAttribute="height" id="4QJ-Tu-9cj"/>
                             <constraint firstItem="vCI-Zm-N7X" firstAttribute="centerX" secondItem="TEW-wV-M4S" secondAttribute="centerX" id="8dy-2H-2iw"/>
                             <constraint firstItem="vCI-Zm-N7X" firstAttribute="centerX" secondItem="TEW-wV-M4S" secondAttribute="centerX" id="8dy-2H-2iw"/>
                             <constraint firstItem="D8z-rA-Qpf" firstAttribute="width" secondItem="aiT-qZ-M5f" secondAttribute="width" id="BuV-2a-gda"/>
                             <constraint firstItem="D8z-rA-Qpf" firstAttribute="width" secondItem="aiT-qZ-M5f" secondAttribute="width" id="BuV-2a-gda"/>
+                            <constraint firstItem="4DJ-GK-9l9" firstAttribute="leading" secondItem="D8z-rA-Qpf" secondAttribute="leading" id="OtU-1g-dHc"/>
                             <constraint firstItem="D8z-rA-Qpf" firstAttribute="leading" secondItem="aiT-qZ-M5f" secondAttribute="leading" id="RYY-iZ-sc1"/>
                             <constraint firstItem="D8z-rA-Qpf" firstAttribute="leading" secondItem="aiT-qZ-M5f" secondAttribute="leading" id="RYY-iZ-sc1"/>
+                            <constraint firstItem="4DJ-GK-9l9" firstAttribute="width" secondItem="D8z-rA-Qpf" secondAttribute="width" id="S8U-sb-mvg"/>
                             <constraint firstItem="0ig-dn-iSa" firstAttribute="centerX" secondItem="TEW-wV-M4S" secondAttribute="centerX" id="bkm-1o-EpZ"/>
                             <constraint firstItem="0ig-dn-iSa" firstAttribute="centerX" secondItem="TEW-wV-M4S" secondAttribute="centerX" id="bkm-1o-EpZ"/>
                             <constraint firstItem="TEW-wV-M4S" firstAttribute="trailing" secondItem="vCI-Zm-N7X" secondAttribute="trailing" constant="70" id="cSr-ne-Xxd"/>
                             <constraint firstItem="TEW-wV-M4S" firstAttribute="trailing" secondItem="vCI-Zm-N7X" secondAttribute="trailing" constant="70" id="cSr-ne-Xxd"/>
                             <constraint firstItem="vCI-Zm-N7X" firstAttribute="centerY" secondItem="TEW-wV-M4S" secondAttribute="centerY" constant="-80" id="fNO-9Q-eMD"/>
                             <constraint firstItem="vCI-Zm-N7X" firstAttribute="centerY" secondItem="TEW-wV-M4S" secondAttribute="centerY" constant="-80" id="fNO-9Q-eMD"/>
                             <constraint firstItem="vCI-Zm-N7X" firstAttribute="leading" secondItem="TEW-wV-M4S" secondAttribute="leading" constant="70" id="ncF-ii-QJ5"/>
                             <constraint firstItem="vCI-Zm-N7X" firstAttribute="leading" secondItem="TEW-wV-M4S" secondAttribute="leading" constant="70" id="ncF-ii-QJ5"/>
                             <constraint firstItem="TEW-wV-M4S" firstAttribute="bottom" secondItem="0ig-dn-iSa" secondAttribute="bottom" constant="70" id="qin-xY-VOb"/>
                             <constraint firstItem="TEW-wV-M4S" firstAttribute="bottom" secondItem="0ig-dn-iSa" secondAttribute="bottom" constant="70" id="qin-xY-VOb"/>
                             <constraint firstItem="D8z-rA-Qpf" firstAttribute="top" secondItem="aiT-qZ-M5f" secondAttribute="top" id="rVq-z9-u0f"/>
                             <constraint firstItem="D8z-rA-Qpf" firstAttribute="top" secondItem="aiT-qZ-M5f" secondAttribute="top" id="rVq-z9-u0f"/>
+                            <constraint firstItem="4DJ-GK-9l9" firstAttribute="top" secondItem="D8z-rA-Qpf" secondAttribute="top" id="sbV-jE-FcH"/>
                             <constraint firstItem="D8z-rA-Qpf" firstAttribute="height" secondItem="aiT-qZ-M5f" secondAttribute="height" id="swA-T5-xSR"/>
                             <constraint firstItem="D8z-rA-Qpf" firstAttribute="height" secondItem="aiT-qZ-M5f" secondAttribute="height" id="swA-T5-xSR"/>
                         </constraints>
                         </constraints>
                         <viewLayoutGuide key="safeArea" id="TEW-wV-M4S"/>
                         <viewLayoutGuide key="safeArea" id="TEW-wV-M4S"/>
                     </view>
                     </view>
                     <connections>
                     <connections>
+                        <outlet property="maskView" destination="4DJ-GK-9l9" id="naM-uL-H99"/>
                         <outlet property="previewContainer" destination="D8z-rA-Qpf" id="XCg-1T-zSa"/>
                         <outlet property="previewContainer" destination="D8z-rA-Qpf" id="XCg-1T-zSa"/>
                         <outlet property="scanerView" destination="vCI-Zm-N7X" id="09n-Fn-vIF"/>
                         <outlet property="scanerView" destination="vCI-Zm-N7X" id="09n-Fn-vIF"/>
                     </connections>
                     </connections>

+ 26 - 2
Redant Drivers/Apex And Drivers/QRCode/RAQRCodeScannerViewController.m

@@ -13,6 +13,7 @@
 
 
 @property (strong, nonatomic) IBOutlet UIView *scanerView;
 @property (strong, nonatomic) IBOutlet UIView *scanerView;
 @property (nonatomic,strong) IBOutlet UIView *previewContainer;
 @property (nonatomic,strong) IBOutlet UIView *previewContainer;
+@property (strong, nonatomic) IBOutlet UIView *maskView;
 
 
 @property (nonatomic,strong) AVCaptureDevice *device;
 @property (nonatomic,strong) AVCaptureDevice *device;
 @property (nonatomic,strong) AVCaptureDeviceInput *input;
 @property (nonatomic,strong) AVCaptureDeviceInput *input;
@@ -24,6 +25,7 @@
 @property (nonatomic,assign) BOOL scannerInitial;
 @property (nonatomic,assign) BOOL scannerInitial;
 
 
 @property (nonatomic,strong) CAGradientLayer *scanLineLayer;
 @property (nonatomic,strong) CAGradientLayer *scanLineLayer;
+@property (nonatomic,strong) CAShapeLayer *maskLayer;
 
 
 @end
 @end
 
 
@@ -65,10 +67,32 @@
     CGRect scanlineFrame = CGRectMake(0, CGRectGetMidY(self.scanerView.bounds) - 0.5, CGRectGetWidth(self.scanerView.bounds), 1);
     CGRect scanlineFrame = CGRectMake(0, CGRectGetMidY(self.scanerView.bounds) - 0.5, CGRectGetWidth(self.scanerView.bounds), 1);
     self.scanLineLayer.frame = scanlineFrame;
     self.scanLineLayer.frame = scanlineFrame;
     [self.scanerView.layer insertSublayer:self.scanLineLayer atIndex:0];
     [self.scanerView.layer insertSublayer:self.scanLineLayer atIndex:0];
+    
+    if (!self.maskLayer) {
+        self.maskLayer = [CAShapeLayer layer];
+    }
+    UIBezierPath *path = [UIBezierPath bezierPathWithRect:self.maskView.bounds];
+    UIBezierPath *subPath = [UIBezierPath bezierPathWithRect:self.scanerView.frame];
+    [path appendPath:subPath];
+    
+    self.maskLayer.fillColor = [UIColor colorWithRed:0.2 green:0.2 blue:0.2 alpha:0.5].CGColor;
+    self.maskLayer.path = path.CGPath;
+    
+    self.maskLayer.fillRule = kCAFillRuleEvenOdd;
+    
+    CAShapeLayer *shapeLayer = [CAShapeLayer layer];
+    shapeLayer.path = subPath.CGPath;
+    shapeLayer.fillColor = [UIColor clearColor].CGColor;
+    shapeLayer.strokeColor = [UIColor whiteColor].CGColor;
+    shapeLayer.lineWidth = 0.5f;
+    
+    [self.maskLayer addSublayer:shapeLayer];
+    
+    [self.maskView.layer addSublayer:self.maskLayer];
 }
 }
 
 
-- (void)viewDidAppear:(BOOL)animated {
-    [super viewDidAppear:animated];
+- (void)viewWillAppear:(BOOL)animated {
+    [super viewWillAppear:animated];
     
     
     if (self.scannerInitial) {
     if (self.scannerInitial) {
         [self.session startRunning];
         [self.session startRunning];

+ 6 - 0
Redant Drivers/Apex And Drivers/RADataProvider.h

@@ -22,4 +22,10 @@
 
 
 + (NSDictionary *)reportAcionToURL:(NSString *)url withParams:(NSMutableDictionary *)params;
 + (NSDictionary *)reportAcionToURL:(NSString *)url withParams:(NSMutableDictionary *)params;
 
 
++ (NSDictionary *)submitEditOrder:(NSMutableDictionary *)params;
+
++ (NSDictionary *)uploadFile:(NSString *)filePath parameters:(NSMutableDictionary *)params;///<同步上传文件
+
++ (NSDictionary *)reportCurrentLocation:(NSString *)location;
+
 @end
 @end

+ 78 - 14
Redant Drivers/Apex And Drivers/RADataProvider.m

@@ -21,15 +21,15 @@
         params = [NSMutableDictionary dictionary];
         params = [NSMutableDictionary dictionary];
     }
     }
     
     
-//    AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
-//
-//
-//    if(appDelegate.user!=nil && params[@"user"] == nil)
-//        [params setValue:appDelegate.user  forKey:@"user"];
-//    if(appDelegate.password!=nil&& params[@"pwd"] == nil)
-//        [params setValue:appDelegate.password  forKey:@"pwd"];
+    NSString *user = RASingleton.sharedInstance.encryptUser;
+    NSString *password = RASingleton.sharedInstance.encryptPassword;
+    
+    if (user.length && password.length) {
+        [params setObject:user forKey:@"user"];
+        [params setObject:password forKey:@"password"];
+    }
     
     
-//    [params setValue:appDelegate.build forKey:@"app_ver"];
+    [params setObject:@"iOS" forKey:@"platform"];
     
     
     NSDictionary* infoDict =[[NSBundle mainBundle] infoDictionary];
     NSDictionary* infoDict =[[NSBundle mainBundle] infoDictionary];
     NSString* short_version =[infoDict objectForKey:@"CFBundleShortVersionString"];
     NSString* short_version =[infoDict objectForKey:@"CFBundleShortVersionString"];
@@ -171,12 +171,11 @@
     
     
     sleep(3.0);
     sleep(3.0);
     return [self loadFakeData:@"fake_order_list.json"];
     return [self loadFakeData:@"fake_order_list.json"];
+//    return [self fakeError];
     
     
     
     
     NSMutableDictionary *params = [NSMutableDictionary dictionary];
     NSMutableDictionary *params = [NSMutableDictionary dictionary];
     
     
-//    [params setObject:user forKey:@"user"];
-//    [params setObject:pwd forKey:@"password"];
     
     
     NSData* json=[self get_json:URL_HOST parameters:params  file:nil];
     NSData* json=[self get_json:URL_HOST parameters:params  file:nil];
     
     
@@ -187,11 +186,10 @@
     
     
     sleep(3.0);
     sleep(3.0);
     return [self loadFakeData:@"fake_order_detail.json"];
     return [self loadFakeData:@"fake_order_detail.json"];
+//    return [self fakeError];
     
     
     NSMutableDictionary *params = [NSMutableDictionary dictionary];
     NSMutableDictionary *params = [NSMutableDictionary dictionary];
     
     
-//    [params setObject:user forKey:@"user"];
-//    [params setObject:pwd forKey:@"password"];
     
     
     NSData* json=[self get_json:URL_HOST parameters:params  file:nil];
     NSData* json=[self get_json:URL_HOST parameters:params  file:nil];
     
     
@@ -202,11 +200,10 @@
     
     
     sleep(3.0);
     sleep(3.0);
     return [self loadFakeData:@"fake_order_edit.json"];
     return [self loadFakeData:@"fake_order_edit.json"];
+//    return [self fakeError];
     
     
     NSMutableDictionary *params = [NSMutableDictionary dictionary];
     NSMutableDictionary *params = [NSMutableDictionary dictionary];
     
     
-    //    [params setObject:user forKey:@"user"];
-    //    [params setObject:pwd forKey:@"password"];
     
     
     NSData* json=[self get_json:URL_HOST parameters:params  file:nil];
     NSData* json=[self get_json:URL_HOST parameters:params  file:nil];
     
     
@@ -223,6 +220,66 @@
     return [self handleJsonData:json];
     return [self handleJsonData:json];
 }
 }
 
 
++ (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];
+    }
+    
+    NSData* json=[self get_json:URL_HOST parameters:params  file:nil];
+    
+    return [self handleJsonData:json];
+}
+
++ (NSDictionary *)upload:(NSString*)url parameters:(NSMutableDictionary *)params file:(NSString*)file_path {
+
+    
+    if (![params isKindOfClass:[NSMutableDictionary class]]) {
+        params = [params mutableCopy];
+    }
+    NSData* json=[self get_json:url parameters:params  file:file_path];
+    
+    return [self handleJsonData:json];
+}
+
++ (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_HOST parameters:params file:filePath];
+}
+
++ (NSDictionary *)reportCurrentLocation:(NSString *)location {
+    
+    NSMutableDictionary *params = [NSMutableDictionary dictionary];
+    
+    NSData* json=[self get_json:URL_HOST parameters:params  file:nil];
+    
+    return [self handleJsonData:json];
+}
+
 + (NSDictionary *)loadFakeData:(NSString *)fileName {
 + (NSDictionary *)loadFakeData:(NSString *)fileName {
     
     
     NSString *path = [[NSBundle mainBundle] pathForResource:fileName ofType:nil];
     NSString *path = [[NSBundle mainBundle] pathForResource:fileName ofType:nil];
@@ -230,4 +287,11 @@
     return [self handleJsonData:jsonData];
     return [self handleJsonData:jsonData];
 }
 }
 
 
++ (NSDictionary *)fakeError {
+    return @{
+             @"result" : @0,
+             @"err_msg" : @"server error,please try later."
+             };
+}
+
 @end
 @end

+ 12 - 0
Redant Drivers/Apex And Drivers/RASingleton.h

@@ -8,11 +8,23 @@
 
 
 #import <Foundation/Foundation.h>
 #import <Foundation/Foundation.h>
 
 
+@class CLLocation;
 @interface RASingleton : NSObject
 @interface RASingleton : NSObject
 
 
 + (instancetype)sharedInstance;
 + (instancetype)sharedInstance;
 
 
 @property (nonatomic,copy) NSString *user;
 @property (nonatomic,copy) NSString *user;
 @property (nonatomic,copy) NSString *password;
 @property (nonatomic,copy) NSString *password;
+@property (nonatomic,strong) CLLocation *currentLocation;
+
+@property (nonatomic,copy,readonly) NSString *secretKey;
+@property (nonatomic,readonly) NSString *encryptUser;
+@property (nonatomic,readonly) NSString *encryptPassword;
+
+- (void)saveUserInfo;
+
+- (NSString *)savedUser;
+
+- (NSString *)savedPassword;
 
 
 @end
 @end

+ 48 - 1
Redant Drivers/Apex And Drivers/RASingleton.m

@@ -10,15 +10,62 @@
 
 
 static RASingleton *singleton;
 static RASingleton *singleton;
 
 
-@implementation RASingleton
+@implementation RASingleton {
+    NSString *_secretKey;
+}
 
 
 + (instancetype)sharedInstance {
 + (instancetype)sharedInstance {
     
     
     static dispatch_once_t tocken;
     static dispatch_once_t tocken;
     dispatch_once(&tocken, ^{
     dispatch_once(&tocken, ^{
         singleton = [[RASingleton alloc] init];
         singleton = [[RASingleton alloc] init];
+        singleton->_secretKey = @"usai";
     });
     });
     return singleton;
     return singleton;
 }
 }
 
 
+- (NSString *)secretKey {
+    return _secretKey;
+}
+
+- (NSString *)encryptUser {
+    
+    if (!self.user) {
+        return nil;
+    }
+    return [AESCrypt encrypt:self.user password:self.secretKey];
+}
+
+- (NSString *)encryptPassword {
+    
+    if (!self.password) {
+        return nil;
+    }
+    return [AESCrypt encrypt:self.password password:self.secretKey];
+}
+
+- (void)saveUserInfo {
+    if (self.user && self.password) {
+        
+        NSUserDefaults *defaults =[NSUserDefaults standardUserDefaults];
+        [defaults removeObjectForKey:@"user"];
+        [defaults removeObjectForKey:@"password"];
+        
+        [defaults setValue:self.encryptUser forKey:@"user"];
+        [defaults setValue:self.encryptPassword forKey:@"password"];
+        [defaults setBool:TRUE forKey:@"autologin"];
+        [defaults synchronize];
+    }
+}
+
+- (NSString *)savedUser {
+    NSString * user = [AESCrypt decrypt:[[NSUserDefaults standardUserDefaults] stringForKey:@"user"] password:self.secretKey];
+    return user;
+}
+
+- (NSString *)savedPassword {
+    NSString * password = [AESCrypt decrypt:[[NSUserDefaults standardUserDefaults] stringForKey:@"password"] password:self.secretKey];
+    return password;
+}
+
 @end
 @end

+ 212 - 91
Redant Drivers/Apex And Drivers/Update/RAOrderEditViewController.m

@@ -89,14 +89,12 @@
 
 
 #pragma mark - View Controller
 #pragma mark - View Controller
 
 
-@interface RAOrderEditViewController () <CLLocationManagerDelegate>
+@interface RAOrderEditViewController ()
 
 
 @property (nonatomic,strong) IBOutlet UITableView *orderEditTableView;
 @property (nonatomic,strong) IBOutlet UITableView *orderEditTableView;
 @property (nonatomic,strong) NSMutableArray *sectionArray;
 @property (nonatomic,strong) NSMutableArray *sectionArray;
-
-@property (nonatomic,strong) CLLocationManager *locationManager;
-@property (nonatomic,strong) CLLocation *currentLocation;
-
+@property (nonatomic,copy) NSString *photoDir;
+@property (nonatomic,strong) UIRefreshControl *refreshControl;
 
 
 @end
 @end
 
 
@@ -119,14 +117,12 @@
 - (void)viewWillAppear:(BOOL)animated {
 - (void)viewWillAppear:(BOOL)animated {
     [super viewWillAppear:animated];
     [super viewWillAppear:animated];
     
     
-    [self startLocation];
     [self registKeyboardListener];
     [self registKeyboardListener];
 }
 }
 
 
 - (void)viewWillDisappear:(BOOL)animated {
 - (void)viewWillDisappear:(BOOL)animated {
     [super viewWillDisappear:animated];
     [super viewWillDisappear:animated];
     
     
-    [self stopLocation];
     [self unregistKeyboardListener];
     [self unregistKeyboardListener];
 }
 }
 
 
@@ -137,22 +133,15 @@
 
 
 #pragma mark - Configure
 #pragma mark - Configure
 
 
-- (void)startLocation {
-    self.locationManager = [[CLLocationManager alloc] init];
-    self.locationManager.delegate = self;
-    self.locationManager.desiredAccuracy = kCLLocationAccuracyBestForNavigation;//设置定位精度
-    [self.locationManager requestWhenInUseAuthorization];
-    [self.locationManager startUpdatingLocation];
-}
-
-- (void)stopLocation {
-    [self.locationManager stopUpdatingLocation];
-}
-
 - (void)configureTable {
 - (void)configureTable {
     
     
     self.orderEditTableView.tableFooterView = [UIView new];
     self.orderEditTableView.tableFooterView = [UIView new];
     self.orderEditTableView.separatorInset = UIEdgeInsetsMake(0, 0, 0, 0);
     self.orderEditTableView.separatorInset = UIEdgeInsetsMake(0, 0, 0, 0);
+    
+    UIRefreshControl *refresh = [[UIRefreshControl alloc] init];
+    [refresh addTarget:self action:@selector(refreshControlValueChanged:) forControlEvents:UIControlEventValueChanged];
+    [self.orderEditTableView addSubview:refresh];
+    self.refreshControl = refresh;
 }
 }
 
 
 - (void)configureNavigationBar {
 - (void)configureNavigationBar {
@@ -169,7 +158,13 @@
     [[NSNotificationCenter defaultCenter] removeObserver:self];
     [[NSNotificationCenter defaultCenter] removeObserver:self];
 }
 }
 
 
-#pragma mark Getter
+#pragma mark - Action
+
+- (void)refreshControlValueChanged:(UIRefreshControl *)refresh {
+    [self loadData];
+}
+
+#pragma mark - Getter
 
 
 - (NSMutableArray *)sectionArray {
 - (NSMutableArray *)sectionArray {
     if (!_sectionArray) {
     if (!_sectionArray) {
@@ -217,6 +212,9 @@
             
             
             // dismiss progress
             // dismiss progress
             [hud dismiss];
             [hud dismiss];
+            if (weakSelf.refreshControl.isRefreshing) {
+                [weakSelf.refreshControl endRefreshing];
+            }
             
             
             if (weakSelf) {
             if (weakSelf) {
                 __strong typeof(weakSelf) strongSelf = weakSelf;
                 __strong typeof(weakSelf) strongSelf = weakSelf;
@@ -237,7 +235,8 @@
                     
                     
                 } else {
                 } else {
                     // process error
                     // process error
-                    
+                    NSString *msg = [json objectForKey:@"err_msg"];
+                    [strongSelf showAlertTilte:@"Warning" message:msg];
                 }
                 }
             }
             }
             
             
@@ -255,31 +254,163 @@
 
 
 - (void)updateBtnClick:(UIBarButtonItem *)sender {
 - (void)updateBtnClick:(UIBarButtonItem *)sender {
     
     
+    // show progress
     RAProgressHUD *hud = [RAProgressHUD showHUDOnView:self.view];
     RAProgressHUD *hud = [RAProgressHUD showHUDOnView:self.view];
     
     
-    NSMutableDictionary *task = [self preparePackage];
-    
-    AppDelegate *appDelegate = (AppDelegate *)[UIApplication sharedApplication].delegate;
-    [appDelegate.uploadManager addTask:task];
+    NSMutableDictionary *params = [NSMutableDictionary dictionary];
+    NSMutableArray <RAEditPhotoModel *> *photoArr = [self prepareParams:params];
     
     
     __weak typeof(self) weakSelf = self;
     __weak typeof(self) weakSelf = self;
-    [hud dismiss:^{
+    dispatch_async(dispatch_get_global_queue(0, 0), ^{
         
         
-        UIAlertController *alertVC = [UIAlertController alertControllerWithTitle:@"Message" message:@"you can find the update progress in upload list" preferredStyle:UIAlertControllerStyleAlert];
+        NSDictionary *json = [RADataProvider submitEditOrder:params];
         
         
-        UIAlertAction *okAction = [UIAlertAction actionWithTitle:@"Ok" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
+        if (weakSelf) {
+            __strong typeof(weakSelf) strongSelf = weakSelf;
             
             
-            [[NSNotificationCenter defaultCenter] postNotificationName:RANotificationReloadHome object:nil];
-            [weakSelf.navigationController popToRootViewControllerAnimated:YES];
-        }];
+            int result = [[json objectForKey:@"result"] intValue];
+            if (result == RESULT_TRUE) {
+                
+                [strongSelf syncUploadPhotos:photoArr Json:json HUD:nil];
+                
+            } else {
+                // process error
+                dispatch_async(dispatch_get_main_queue(), ^{
+                    
+                    // dismiss progress
+                    [hud dismiss:^{
+                        
+                        NSString *msg = [json objectForKey:@"err_msg"];
+                        [strongSelf showAlertTilte:@"Warning" message:msg];
+                    }];
+
+                });
+
+            }
+        }
+        
+        
+    });
+}
+
+- (void)backgroundUploadPhoto:(NSArray *)photos Json:(NSDictionary *)json {
+    
+    AppDelegate *appDelegate = (AppDelegate *)[UIApplication sharedApplication].delegate;
+    
+    for (RAEditPhotoModel *model in photos) {
+        
+        NSString *serial = [json objectForKey:model.key];
+        if (serial.length) {
+            
+            NSMutableDictionary *params = [NSMutableDictionary dictionary];
+            [params setObject:serial forKey:@"serial"];
+            [params setObject:@"iOS" forKey:@"platform"];
+            NSString *photoPath = [self.photoDir.lastPathComponent stringByAppendingPathComponent:model.photoName];
+            
+            NSMutableDictionary *task = [@{
+                                           @"order" : self.orderID,
+                                           @"action" : self.actionTitle,
+                                           @"url" : URL_HOST,
+                                           @"file" : photoPath
+                                           } mutableCopy];
+            [appDelegate.uploadManager addTask:task];
+        }
+    }
+}
+
+- (void)syncUploadPhotos:(NSMutableArray *)photoArr Json:(NSDictionary *)json HUD:(RAProgressHUD *)hud {
+    
+    dispatch_async(dispatch_get_main_queue(), ^{
+        
+        RAProgressHUD *innerHUD = hud;
+        if (!innerHUD) {
+            innerHUD = [RAProgressHUD showHUDOnView:self.view]; // main queue
+        }
+        
         
         
-        [alertVC addAction:okAction];
+        dispatch_async(dispatch_get_global_queue(0, 0), ^{ // network
+           
+            int retryCount = 0;
+            NSMutableArray *completArr = [NSMutableArray array];
+            // 同步上传照片
+            for (int i = 0; i < photoArr.count; i++) {
+                RAEditPhotoModel *model = [photoArr objectAtIndex:i];
+                NSString *serial = [json objectForKey:model.key];
+                if (serial.length) {
+                    
+                    NSMutableDictionary *fileParams = [NSMutableDictionary dictionary];
+                    [fileParams setObject:serial forKey:@"serial"];
+                    NSString *photoPath = [self.photoDir stringByAppendingPathComponent:model.photoName];
+                    NSDictionary *uploadJson = [RADataProvider uploadFile:photoPath parameters:fileParams];
+                    int uploadResult = [[uploadJson objectForKey:@"result"] intValue];
+                    
+                    if (uploadResult != RESULT_TRUE) { // 失败重试
+                        
+                        i--;
+                        retryCount++;
+                        if (retryCount >= 3) {
+                            break;
+                        }
+                    } else {
+                        
+                        [completArr addObject:model];
+                        retryCount = 0;
+                    }
+                } // serial
+            } // for
+            
+            // 将完成的model移除
+            [photoArr removeObjectsInArray:completArr];
+            
+            __weak typeof(self) weakSelf = self;
+            dispatch_async(dispatch_get_main_queue(), ^{
+                
+                [innerHUD dismiss:^{
+                    
+                    if (photoArr.count > 0) {
+                        // 上传失败,询问是否丢到后台线程上传,否则重启上传
+                        
+                        UIAlertController *alertVC = [UIAlertController alertControllerWithTitle:@"Warning" message:@"upload the photos failed,would you like to retry or do it background?" preferredStyle:UIAlertControllerStyleAlert];
+                        UIAlertAction *backgroundAction = [UIAlertAction actionWithTitle:@"Background" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
+                            
+                            // 开启后台上传
+                            [weakSelf backgroundUploadPhoto:photoArr Json:json];
+                            // 返回首页
+                            [weakSelf gobackHome];
+                        }];
+                        UIAlertAction *retryAction = [UIAlertAction actionWithTitle:@"Retry" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
+                            
+                            dispatch_async(dispatch_get_global_queue(0, 0), ^{
+                                [weakSelf syncUploadPhotos:photoArr Json:json HUD:nil];
+                            });
+                        }];
+                        
+                        [alertVC addAction:backgroundAction];
+                        [alertVC addAction:retryAction];
+                        
+                        [weakSelf presentViewController:alertVC animated:YES completion:nil];
+                        
+                        
+                    } else {
+                        // 上传完成,返回到首页
+                        [weakSelf gobackHome];
+                    }
+                    
+                }];
+            });
+            
+        });
         
         
-        [weakSelf presentViewController:alertVC animated:YES completion:nil];
-    }];
+    });
+    
     
     
     
     
+}
+
+- (void)gobackHome {
     
     
+    [[NSNotificationCenter defaultCenter] postNotificationName:RANotificationReloadHome object:nil];
+    [self.navigationController popToRootViewControllerAnimated:YES];
 }
 }
 
 
 #pragma mark - Keyboard Listener
 #pragma mark - Keyboard Listener
@@ -298,84 +429,60 @@
     }
     }
 }
 }
 
 
-#pragma mark - LocationManager Delegate
-
-- (void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray<CLLocation *> *)locations {
-    if (locations.count) {
-        self.currentLocation = [locations lastObject];
-    }
-}
+#pragma mark - Package Update Data
 
 
-- (void)locationManager:(CLLocationManager *)manager didChangeAuthorizationStatus:(CLAuthorizationStatus)status {
+- (NSString *)photoDir {
     
     
-    if (status == kCLAuthorizationStatusDenied) {
+    if (!_photoDir) {
         
         
-        UIAlertController *alertVC = [UIAlertController alertControllerWithTitle:@"Warning" message:@"app need location,would you like to open it" preferredStyle:UIAlertControllerStyleAlert];
-        UIAlertAction *okAction = [UIAlertAction actionWithTitle:@"Ok" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
-            NSURL *url = [NSURL URLWithString:UIApplicationOpenSettingsURLString];
-            if ([[UIApplication sharedApplication]canOpenURL:url]) {
-                [[UIApplication sharedApplication]openURL:url options:@{} completionHandler:nil];
-            }
-            [self.navigationController popViewControllerAnimated:NO];
-        }];
-        UIAlertAction *noAction = [UIAlertAction actionWithTitle:@"No" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
-            
-        }];
+        NSString *cacheDir = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) firstObject];
+        NSString *photoDir = [cacheDir stringByAppendingPathComponent:[NSString stringWithFormat:@"%@_%ld_%@",self.orderID,(long)self.actionID,[NSUUID UUID].UUIDString]];
         
         
-        [alertVC addAction:noAction];
-        [alertVC addAction:okAction];
+        NSError *error;
+        //    BOOL dirExist = YES;
+        //    for (int i = 0; i < INT_MAX; i++) {
+        //        if (i != 0) {
+        //            photoDir = [photoDir stringByAppendingString:[NSString stringWithFormat:@"(%d)",i]];
+        //        }
+        //        if (![[NSFileManager defaultManager] fileExistsAtPath:photoDir]) {
+        //            dirExist = NO;
+        //            break;
+        //        }
+        //    }
         
         
-        [self presentViewController:alertVC animated:YES completion:nil];
+        [[NSFileManager defaultManager] createDirectoryAtPath:photoDir withIntermediateDirectories:YES attributes:nil error:&error];
+        if (error) {
+            NSLog(@"create dir %@ failed %@",photoDir,error.localizedDescription);
+            return nil;
+        }
+        _photoDir = photoDir;
     }
     }
+    return _photoDir;
 }
 }
 
 
-#pragma mark - Package Update Data
-
-- (NSString *)createPhotoDir {
-    
-    NSString *cacheDir = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) firstObject];
-    NSString *photoDir = [cacheDir stringByAppendingPathComponent:[NSString stringWithFormat:@"%@_%ld_%@",self.orderID,self.actionID,[NSUUID UUID].UUIDString]];
-    
-    NSError *error;
-//    BOOL dirExist = YES;
-//    for (int i = 0; i < INT_MAX; i++) {
-//        if (i != 0) {
-//            photoDir = [photoDir stringByAppendingString:[NSString stringWithFormat:@"(%d)",i]];
-//        }
-//        if (![[NSFileManager defaultManager] fileExistsAtPath:photoDir]) {
-//            dirExist = NO;
-//            break;
-//        }
-//    }
-
-    [[NSFileManager defaultManager] createDirectoryAtPath:photoDir withIntermediateDirectories:YES attributes:nil error:&error];
-    if (error) {
-        NSLog(@"create dir %@ failed %@",photoDir,error.localizedDescription);
+- (NSMutableArray <RAEditPhotoModel *> *)prepareParams:(NSMutableDictionary *)params {
+    
+    if (params == nil) {
         return nil;
         return nil;
     }
     }
     
     
-    return photoDir;
-}
-
-- (NSMutableDictionary *)preparePackage {
+    NSMutableArray <RAEditPhotoModel *> *photoArr = [NSMutableArray array];
     
     
-    NSMutableDictionary *params = [NSMutableDictionary dictionary];
-    NSString *photoDir = [self createPhotoDir];
+    NSString *photoDir = [self photoDir];
     
     
     [params setObject:self.orderID forKey:@"orderID"];
     [params setObject:self.orderID forKey:@"orderID"];
     [params setObject:@(self.actionID) forKey:@"actionID"];
     [params setObject:@(self.actionID) forKey:@"actionID"];
     
     
-    NSString* encryptu=[AESCrypt AES128Encrypt:[RASingleton sharedInstance].user key:@"usai"];
-    NSString* encryptp=[AESCrypt AES128Encrypt:[RASingleton sharedInstance].password key:@"usai"];
+    NSString* encryptu = [RASingleton sharedInstance].encryptUser;
+    NSString* encryptp = [RASingleton sharedInstance].encryptPassword;
     [params setObject:encryptu forKey:@"user"];
     [params setObject:encryptu forKey:@"user"];
     [params setObject:encryptp forKey:@"password"];
     [params setObject:encryptp forKey:@"password"];
     [params setObject:@"iOS" forKey:@"platform"];
     [params setObject:@"iOS" forKey:@"platform"];
     
     
-    if (self.currentLocation) {
-        [params setObject:[NSString stringWithFormat:@"%f,%f",self.currentLocation.coordinate.latitude,self.currentLocation.coordinate.longitude] forKey:@"location"];
+    if ([RASingleton sharedInstance].currentLocation) {
+        [params setObject:[NSString stringWithFormat:@"%f,%f",[RASingleton sharedInstance].currentLocation.coordinate.latitude,[RASingleton sharedInstance].currentLocation.coordinate.longitude] forKey:@"location"];
     }
     }
     
     
-    NSInteger photoCount = 0;
     for (RAEditSectionModel *section in self.sectionArray) {
     for (RAEditSectionModel *section in self.sectionArray) {
         for (int i = 0; i < [section itemCount]; i++) {
         for (int i = 0; i < [section itemCount]; i++) {
             RAEditBaseModel *model = [section itemModelForIndex:i];
             RAEditBaseModel *model = [section itemModelForIndex:i];
@@ -401,15 +508,20 @@
                 }
                 }
                     break;
                     break;
                 case RAEditTypePhoto: {
                 case RAEditTypePhoto: {
+                    
                     if (photoDir) {
                     if (photoDir) {
+                    
                         RAEditPhotoModel *photoModel = (RAEditPhotoModel *)model;
                         RAEditPhotoModel *photoModel = (RAEditPhotoModel *)model;
                         if (photoModel.photo) {
                         if (photoModel.photo) {
+                            
                             NSString *photoPath = [photoDir stringByAppendingPathComponent:photoModel.photoName];
                             NSString *photoPath = [photoDir stringByAppendingPathComponent:photoModel.photoName];
                             NSData *imgData = UIImageJPEGRepresentation(photoModel.photo, 1.0f);
                             NSData *imgData = UIImageJPEGRepresentation(photoModel.photo, 1.0f);
                             if (imgData) {
                             if (imgData) {
+                                
                                 [imgData writeToFile:photoPath atomically:NO];
                                 [imgData writeToFile:photoPath atomically:NO];
                                 [params setObject:photoModel.photoName forKey:photoModel.key];
                                 [params setObject:photoModel.photoName forKey:photoModel.key];
-                                photoCount++;
+                                
+                                [photoArr addObject:photoModel];
                             }
                             }
                         }
                         }
                         
                         
@@ -425,6 +537,15 @@
         }
         }
     }
     }
     
     
+    return photoArr;
+}
+
+- (NSMutableDictionary *)preparePackage {
+    
+    NSMutableDictionary *params = [NSMutableDictionary dictionary];
+    NSInteger photoCount = [self prepareParams:params].count;
+    NSString *photoDir = [self photoDir];
+    
     NSMutableDictionary *task = [@{
     NSMutableDictionary *task = [@{
                                    @"order" : self.orderID,
                                    @"order" : self.orderID,
                                    @"action" : self.actionTitle,
                                    @"action" : self.actionTitle,