|
|
@@ -11,6 +11,7 @@
|
|
|
#import "RANetwork.h"
|
|
|
#import "RAUtils.h"
|
|
|
#import "DetailTabBarController.h"
|
|
|
+#import <QuickLook/QuickLook.h>
|
|
|
|
|
|
#pragma clang diagnostic push
|
|
|
#pragma clang diagnostic ignored"-Wdeprecated-declarations"
|
|
|
@@ -231,15 +232,117 @@
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+- (void)showQuickLookAtIndexPath:(NSIndexPath *)indexPath Action:(NSDictionary *)action {
|
|
|
+
|
|
|
+
|
|
|
+ NSMutableDictionary *params = [NSMutableDictionary new];
|
|
|
+
|
|
|
+ NSMutableDictionary *criteria =[NSMutableDictionary new];
|
|
|
+ for(NSString* key in [action[@"params"] allKeys] )
|
|
|
+ {
|
|
|
+ NSArray* item =self.content_data[[NSString stringWithFormat:@"item_%ld",indexPath.row]];
|
|
|
+ int idx =[action[@"params"][key] intValue];
|
|
|
+ criteria[key]=item[ idx];
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ params[@"criteria"]=[RAConvertor dict2string:criteria] ;
|
|
|
+
|
|
|
+ NSString* URL =action[@"url"];
|
|
|
+ __weak typeof(self) weakSelf = self;
|
|
|
+ dispatch_async(dispatch_get_global_queue(0, 0), ^{
|
|
|
+
|
|
|
+ NSArray *paths = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES);
|
|
|
+ NSString *documents = [paths objectAtIndex:0];
|
|
|
+ NSString *path = [documents stringByAppendingPathComponent:[NSUUID UUID].UUIDString];
|
|
|
+
|
|
|
+ [RANetwork download_file:params url:URL toCachePath:path progressHandler:^(NSURLSessionTask *task, double progress) {
|
|
|
+
|
|
|
+ } completionHandler:^(NSMutableDictionary *result) {
|
|
|
+
|
|
|
+ weakSelf.documentPath = path;
|
|
|
+
|
|
|
+ if (path) {
|
|
|
+ dispatch_async(dispatch_get_main_queue(), ^{
|
|
|
+ [weakSelf.navigationController pushViewController:weakSelf.quickLook animated:NO];
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ }];
|
|
|
+
|
|
|
+
|
|
|
+ });
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+- (void)handleRowAction:(NSIndexPath *)indexPath {
|
|
|
+
|
|
|
+ if(self.content_action!=nil)
|
|
|
+ {
|
|
|
+
|
|
|
+ if(self.content_action.count==1)
|
|
|
+ {
|
|
|
+ NSDictionary* action =self.content_action.firstObject;
|
|
|
+ NSString * module = action[@"module"];
|
|
|
+ if([module isEqualToString:@"quick_look"])
|
|
|
+ {
|
|
|
+ [self showQuickLookAtIndexPath:indexPath Action:action];
|
|
|
+ }
|
|
|
+ else if([module isEqualToString:@"detail"])
|
|
|
+ {
|
|
|
+ [self showDetailForIndexPath:indexPath];
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+
|
|
|
+ UIAlertController *alertControl = [UIAlertController alertControllerWithTitle:@"" message:nil preferredStyle:UIAlertControllerStyleAlert];
|
|
|
+
|
|
|
+ __weak typeof(self) weakSelf = self;
|
|
|
+ for(int i=0;i<self.content_action.count;i++)
|
|
|
+ {
|
|
|
+ NSMutableDictionary* json = self.content_action[i];
|
|
|
+ NSString* title =json[@"title"];
|
|
|
+ NSString* module = json[@"module"];
|
|
|
+ UIAlertAction *actioni = [UIAlertAction actionWithTitle:title style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
|
|
|
+
|
|
|
+
|
|
|
+ if([module isEqualToString:@"quick_look"])
|
|
|
+ {
|
|
|
+ [weakSelf showQuickLookAtIndexPath:indexPath Action:json];
|
|
|
+ }
|
|
|
+ else if([module isEqualToString:@"order_detail"])
|
|
|
+ {
|
|
|
+ [weakSelf showDetailForIndexPath:indexPath];
|
|
|
+ }
|
|
|
+
|
|
|
+ }];
|
|
|
+ [alertControl addAction:actioni];
|
|
|
+ }
|
|
|
+
|
|
|
+ UIAlertAction *actionCancel = [UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) {
|
|
|
+
|
|
|
+ }];
|
|
|
+ [alertControl addAction:actionCancel];
|
|
|
+
|
|
|
+ [self presentViewController:alertControl animated:NO completion:nil];
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
-(void)cellDoubleTapAction:(UIGestureRecognizer*)gestureRecognizer
|
|
|
{
|
|
|
UITableViewCell *cell = (UITableViewCell *)[gestureRecognizer view];
|
|
|
NSIndexPath *indexPath = [self.tableview indexPathForCell:cell];
|
|
|
- [self showDetailForIndexPath:indexPath];
|
|
|
+// [self showDetailForIndexPath:indexPath];
|
|
|
+ [self handleRowAction:indexPath];
|
|
|
}
|
|
|
|
|
|
- (void)presses3DTouchForIndexPath:(NSIndexPath *)indexPath {
|
|
|
- [self showDetailForIndexPath:indexPath];
|
|
|
+// [self showDetailForIndexPath:indexPath];
|
|
|
+ [self handleRowAction:indexPath];
|
|
|
}
|
|
|
|
|
|
/*
|