Эх сурвалжийг харах

RedAnt Mobile

修复结果页点下载会重复下载的逻辑错误。
新增文件下载接口
修复结果页查询下载与行查看冲突的问题
Ray Zhang 8 жил өмнө
parent
commit
0dcb8c75a4

+ 4 - 0
RedAnt Mobile/RedAnt Mobile.xcodeproj/project.pbxproj

@@ -30,6 +30,7 @@
 		42DFAE7B1F9B2CE6009AFCCC /* Phone_Switch_Cell.xib in Resources */ = {isa = PBXBuildFile; fileRef = 42DFAE7A1F9B2CE6009AFCCC /* Phone_Switch_Cell.xib */; };
 		42DFAE7D1F9B2D02009AFCCC /* Phone_TextView_Cell.xib in Resources */ = {isa = PBXBuildFile; fileRef = 42DFAE7C1F9B2D02009AFCCC /* Phone_TextView_Cell.xib */; };
 		42F2EB3E1FA80EDC00BC6468 /* RAModel.m in Sources */ = {isa = PBXBuildFile; fileRef = 42F2EB3D1FA80EDC00BC6468 /* RAModel.m */; };
+		7197D4041FB438B60063EFBB /* demo_row.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 7197D4031FB4388F0063EFBB /* demo_row.pdf */; };
 		71CB70B41FA1CCDB009FDCB7 /* server.json in Resources */ = {isa = PBXBuildFile; fileRef = 71CB70B31FA1CCDB009FDCB7 /* server.json */; };
 		71E9F6C81F8C5CCB0052C78E /* NetworkUtils.m in Sources */ = {isa = PBXBuildFile; fileRef = 71E9F6C61F8C5CCA0052C78E /* NetworkUtils.m */; };
 		71F3A9A21F5F8E22001036C8 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 71F3A9A11F5F8E22001036C8 /* main.m */; };
@@ -144,6 +145,7 @@
 		42DFAE7C1F9B2D02009AFCCC /* Phone_TextView_Cell.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = Phone_TextView_Cell.xib; sourceTree = "<group>"; };
 		42F2EB3C1FA80EDC00BC6468 /* RAModel.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RAModel.h; sourceTree = "<group>"; };
 		42F2EB3D1FA80EDC00BC6468 /* RAModel.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = RAModel.m; sourceTree = "<group>"; };
+		7197D4031FB4388F0063EFBB /* demo_row.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = demo_row.pdf; sourceTree = "<group>"; };
 		71CB70B01FA1BA5E009FDCB7 /* data.json */ = {isa = PBXFileReference; lastKnownFileType = text.json; path = data.json; sourceTree = "<group>"; };
 		71CB70B11FA1BA5E009FDCB7 /* layout.json */ = {isa = PBXFileReference; lastKnownFileType = text.json; path = layout.json; sourceTree = "<group>"; };
 		71CB70B31FA1CCDB009FDCB7 /* server.json */ = {isa = PBXFileReference; lastKnownFileType = text.json; path = server.json; sourceTree = "<group>"; };
@@ -476,6 +478,7 @@
 				71FF60361FA96EEE00C5523A /* download_query.xls */,
 				71F3A9C01F5FA11F001036C8 /* login.json */,
 				71CB70B31FA1CCDB009FDCB7 /* server.json */,
+				7197D4031FB4388F0063EFBB /* demo_row.pdf */,
 				71FF602E1FA8449C00C5523A /* predef_query.json */,
 			);
 			name = "fake data";
@@ -809,6 +812,7 @@
 			isa = PBXResourcesBuildPhase;
 			buildActionMask = 2147483647;
 			files = (
+				7197D4041FB438B60063EFBB /* demo_row.pdf in Resources */,
 				71FF60371FA96F4F00C5523A /* download_query.xls in Resources */,
 				71FF60321FA871DD00C5523A /* data.json in Resources */,
 				71FF60331FA871DD00C5523A /* layout.json in Resources */,

+ 1 - 0
RedAnt Mobile/RedAnt Mobile/RANetwork.h

@@ -16,4 +16,5 @@
 +(NSDictionary*)logout;
 +(NSDictionary*)query : (NSMutableDictionary*) params;
 +(NSString*)download_query : (NSMutableDictionary*) params;
++(NSString*)download_file : (NSMutableDictionary*) params url:(NSString*) url;
 @end

+ 16 - 0
RedAnt Mobile/RedAnt Mobile/RANetwork.m

@@ -69,6 +69,22 @@
     return resultDic;
 }
 
++(NSString*)download_file : (NSMutableDictionary*) params url:(NSString*) url
+{
+    NSString *Path =nil;
+    Path=[[NSBundle mainBundle] pathForResource:@"demo_row.pdf" ofType:nil];
+    
+    return Path;
+    
+    
+    // params[@"_operate"]=@"valid_upload";
+    AppDelegate *appDelegate = (AppDelegate *)[UIApplication sharedApplication].delegate;
+    
+    NSData *data = [self get_json:url parameters:params file:nil];
+    NSDictionary *resultDic = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableLeaves error:nil];
+    return resultDic;
+}
+
 +(NSData*)get_json : (NSString*) url parameters:(NSMutableDictionary *) params file:(NSString *) file //delegate:(id < NSURLConnectionDelegate >)delegate
 {
     

+ 2 - 0
RedAnt Mobile/RedAnt Mobile/ResultViewController.h

@@ -12,8 +12,10 @@
 @property (weak, nonatomic) IBOutlet UITableView *tableview;
 @property (weak, nonatomic) IBOutlet UIScrollView *scrollview;
 @property (strong, nonatomic) NSMutableDictionary* content_layout;
+@property (strong, nonatomic) NSMutableDictionary* content_action;
 @property (strong, nonatomic) NSMutableDictionary* content_data;
 @property (strong, nonatomic) UILabel *label;
+@property (strong, nonatomic) NSString *download_query;
 
 - (void)setQueryParams:(NSDictionary *)params;
 

+ 47 - 1
RedAnt Mobile/RedAnt Mobile/ResultViewController.m

@@ -97,6 +97,36 @@ static const int delta = 25;
 -(void)cellDoubleTapAction:(UIGestureRecognizer*)gestureRecognizer
 {
     NSLog(@"cell double tap");
+    
+    //strongSelf.content_action
+    if(self.content_action!=nil)
+    {
+        NSString * module =  self.content_action[@"module"];
+        if([module isEqualToString:@"quick_look"])
+        {
+            
+//            +(NSString*)download_file : (NSMutableDictionary*) params url:(NSString*) url
+            NSMutableDictionary *params = self.content_action[@"params"];
+            NSString* URL =self.content_action[@"url"];
+            __weak typeof(self) weakSelf = self;
+            dispatch_async(dispatch_get_global_queue(0, 0), ^{
+                
+                
+                NSString *path = [RANetwork download_file:params url:URL];
+                weakSelf.documentPath = path;
+                
+                if (path) {
+                    dispatch_async(dispatch_get_main_queue(), ^{
+                        [weakSelf.navigationController pushViewController:weakSelf.quickLook animated:YES];
+                    });
+                }
+                
+            });
+        }
+    }
+    
+  
+    
 }
 -(void)labelTapAction:(UIGestureRecognizer*)gestureRecognizer
 {
@@ -405,11 +435,21 @@ static const int delta = 25;
 
 - (void)downloadItemClick:(UIBarButtonItem *)sender {
     
+    
+    
+    if(self.download_query )
+    {
+        self.documentPath = self.download_query;
+        [self.navigationController pushViewController:self.quickLook animated:YES];
+        return;
+    }
+
     __weak typeof(self) weakSelf = self;
     dispatch_async(dispatch_get_global_queue(0, 0), ^{
        
         NSMutableDictionary *params = self.params.mutableCopy;
         NSString *path = [RANetwork download_query:params];
+        weakSelf.download_query = path;
         weakSelf.documentPath = path;
         
         if (path) {
@@ -461,6 +501,7 @@ static const int delta = 25;
                     __strong typeof(weakSelf) strongSelf = weakSelf;
                     if (result == RESULT_TRUE) {
                         strongSelf.content_layout = [contentDic objectForKey:@"layout"];
+                        strongSelf.content_action = [contentDic objectForKey:@"action"];
                         strongSelf.content_data = [contentDic objectForKey:@"data"];
                         [strongSelf updateTableFrame];
                         [strongSelf.tableview reloadData];
@@ -577,11 +618,16 @@ static const int delta = 25;
 #pragma mark - Quick Look
 
 - (QLPreviewController *)quickLook {
-    if (!_quickLook) {
+    if (!_quickLook)
+    {
         _quickLook = [[QLPreviewController alloc] init];
         _quickLook.delegate = self;
         _quickLook.dataSource = self;
     }
+    else
+    {
+        [_quickLook reloadData];
+    }
     return _quickLook;
 }
 

BIN
RedAnt Mobile/RedAnt Mobile/demo_row.pdf


+ 2 - 0
RedAnt Mobile/RedAnt Mobile/predef_query.json

@@ -3,8 +3,10 @@
     "action":{
         "title":"demo title",
         "module":"quick_look",
+        "url":"http://1.1.1.1",
         "params":{
             "order#":0
+            
         }
     },
     "data": {