Преглед на файлове

1.修改RedAnt Mobile查询加载。

Pen Li преди 8 години
родител
ревизия
0df620486f

BIN
RedAnt Mobile/RedAnt Mobile.xcodeproj/project.xcworkspace/xcuserdata/macmini1.xcuserdatad/UserInterfaceState.xcuserstate


+ 1 - 1
RedAnt Mobile/RedAnt Mobile/Base.lproj/Main.storyboard

@@ -324,7 +324,7 @@
         <!--Result View Controller-->
         <scene sceneID="spM-H5-A1H">
             <objects>
-                <viewController id="Ekb-S8-yfK" customClass="ResultViewController" sceneMemberID="viewController">
+                <viewController storyboardIdentifier="ResultViewController" useStoryboardIdentifierAsRestorationIdentifier="YES" id="Ekb-S8-yfK" customClass="ResultViewController" sceneMemberID="viewController">
                     <layoutGuides>
                         <viewControllerLayoutGuide type="top" id="QN9-la-fqb"/>
                         <viewControllerLayoutGuide type="bottom" id="ifv-Jz-opQ"/>

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

@@ -14,4 +14,5 @@
 +(NSDictionary*)commoneditor_partialrefresh: (NSMutableDictionary*)params url:(NSString*)url;
 +(NSDictionary*)Login : (NSString*) user password:(NSString*) password;
 +(NSDictionary*)logout;
++(NSDictionary*)query : (NSMutableDictionary*) params;
 @end

+ 10 - 3
RedAnt Mobile/RedAnt Mobile/RARootViewController.m

@@ -11,6 +11,7 @@
 #import "RAModel.h"
 #import "RAPredefQueryViewController.h"
 #import "RAQueryViewController.h"
+#import "ResultViewController.h"
 
 @interface RARootViewController () <UITableViewDelegate,UITableViewDataSource>
 
@@ -99,9 +100,15 @@
 #pragma mark - Private
 
 - (void) processPredefQueryModel:(RAModel *)model {
-    RAPredefQueryViewController *preQueryVC = [[UIStoryboard storyboardWithName:@"RAPredefQuery" bundle:nil] instantiateInitialViewController];
-    preQueryVC.query_id = [model.query_id integerValue];
-    preQueryVC.title = model.name;
+//    RAPredefQueryViewController *preQueryVC = [[UIStoryboard storyboardWithName:@"RAPredefQuery" bundle:nil] instantiateInitialViewController];
+//    preQueryVC.query_id = [model.query_id integerValue];
+//    preQueryVC.title = model.name;
+    
+    ResultViewController *preQueryVC = [[UIStoryboard storyboardWithName:@"Main" bundle:nil] instantiateViewControllerWithIdentifier:@"ResultViewController"];
+    [preQueryVC setQueryParams: @{
+                                  @"query_id" : model.query_id
+                                  }];
+    
     [self.navigationController pushViewController:preQueryVC animated:YES];
 }
 

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

@@ -15,6 +15,8 @@
 @property (strong, nonatomic) NSMutableDictionary* content_data;
 @property (strong, nonatomic) UILabel *label;
 
+- (void)setQueryParams:(NSDictionary *)params;
+
 //@property (strong, nonatomic)UITapGestureRecognizer* labelTap;
 //
 //@property (strong, nonatomic)UITapGestureRecognizer* cellDoubleTap;

+ 51 - 10
RedAnt Mobile/RedAnt Mobile/ResultViewController.m

@@ -9,9 +9,16 @@
 
 #import "ResultViewController.h"
 #import "FullyShowViewController.h"
+#import "RANetwork.h"
+#import "RAUtils.h"
+
+static const int delta = 25;
 
 @interface ResultViewController ()
 
+@property (nonatomic,assign) NSInteger offset;
+@property (nonatomic,strong) NSDictionary *params;
+
 @end
 
 @implementation ResultViewController
@@ -49,16 +56,16 @@
 //    singleFingerTwo.delegate = self;
     
     self.label = [UILabel new];
-    NSString* Path = [[NSBundle mainBundle] pathForResource:@"layout.json" ofType:nil];
-    
-    NSData *data = [NSData dataWithContentsOfFile:Path];
-    self.content_layout = [[NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableContainers error:nil] mutableCopy];
-    
-    
-    Path = [[NSBundle mainBundle] pathForResource:@"data.json" ofType:nil];
-    
-    data = [NSData dataWithContentsOfFile:Path];
-    self.content_data = [[NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableContainers error:nil] mutableCopy];
+//    NSString* Path = [[NSBundle mainBundle] pathForResource:@"layout.json" ofType:nil];
+//
+//    NSData *data = [NSData dataWithContentsOfFile:Path];
+//    self.content_layout = [[NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableContainers error:nil] mutableCopy];
+//
+//
+//    Path = [[NSBundle mainBundle] pathForResource:@"data.json" ofType:nil];
+//
+//    data = [NSData dataWithContentsOfFile:Path];
+//    self.content_data = [[NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableContainers error:nil] mutableCopy];
     
     
     int width=[self.content_layout[@"header"][@"width"] intValue];
@@ -69,6 +76,8 @@
     self.tableview.frame=frame;
     self.scrollview.contentSize=self.tableview.frame.size;
     // Do any additional setup after loading the view, typically from a nib.
+    
+    [self loadContent];
 }
 
 -(void)cellDoubleTapAction:(UIGestureRecognizer*)gestureRecognizer
@@ -349,5 +358,37 @@
     
 }
 
+#pragma mark - Public
+
+- (NSInteger)resultItemCount {
+    return [[self.content_data objectForKey:@"count"] integerValue];
+}
+
+- (void)setQueryParams:(NSDictionary *)params {
+    self.params = params;
+}
+
+- (void)loadContent {
+    if (self.params) {
+        __weak typeof(self) weakSelf = self;
+        dispatch_async(dispatch_get_global_queue(0, 0), ^{
+            NSDictionary *contentDic = [RANetwork query:self.params.mutableCopy];
+            NSInteger result = [[contentDic objectForKey:@"result"] integerValue];
+            dispatch_async(dispatch_get_main_queue(), ^{
+                if (weakSelf) {
+                    __strong typeof(weakSelf) strongSelf = weakSelf;
+                    if (result == RESULT_TRUE) {
+                        strongSelf.content_layout = [contentDic objectForKey:@"layout"];
+                        strongSelf.content_data = [contentDic objectForKey:@"data"];
+                        [strongSelf.tableview reloadData];
+                    } else {
+                        [RAUtils message_alert:[contentDic objectForKey:@"err_msg"] title:@"Warning" controller:strongSelf];
+                    }
+                }
+                
+            });
+        });
+    }
+}
 
 @end