|
@@ -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,
|