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