ResultViewController.m 47 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252
  1. //
  2. // ViewController.m
  3. // phoneTest
  4. //
  5. // Created by Ray on 01/09/2017.
  6. //
  7. //
  8. #define UIColorFromRGB(rgbValue) [UIColor colorWithRed:((float)((rgbValue & 0xFF0000) >> 16))/255.0 green:((float)((rgbValue & 0xFF00) >> 8))/255.0 blue:((float)(rgbValue & 0xFF))/255.0 alpha:1.0]
  9. #import "ResultViewController.h"
  10. #import "FullyShowViewController.h"
  11. #import "RANetwork.h"
  12. #import "RAUtils.h"
  13. #import "JLRefreshHeader.h"
  14. #import "JLRefreshFooter.h"
  15. //#import "OrderDetailViewController.h"
  16. //#import "KVViewController.h"
  17. #import <QuickLook/QuickLook.h>
  18. #import "config.h"
  19. #import "RAConvertor.h"
  20. #import "RAUtils.h"
  21. //#import "RTLabel.h"
  22. #import "ResultCell.h"
  23. #import <AudioToolbox/AudioToolbox.h>
  24. const int delta = 25;
  25. @interface ResultViewController () <JLRefreshDelegate,QLPreviewControllerDataSource,QLPreviewControllerDelegate,UIViewControllerPreviewingDelegate,ResultCellTouchDelegate,UITableViewDelegate,UITableViewDataSource>
  26. @property (weak, nonatomic) IBOutlet NSLayoutConstraint *w_constraint;
  27. @property (weak, nonatomic) IBOutlet NSLayoutConstraint *h_constraint;
  28. @property (weak, nonatomic) IBOutlet NSLayoutConstraint *trail_constraint;
  29. @property (weak, nonatomic) IBOutlet NSLayoutConstraint *lead_constraint;
  30. @end
  31. @implementation ResultViewController
  32. + (instancetype)buildInstanceWithParams:(NSMutableDictionary *)params {
  33. id resultVC = [[self alloc] initWithNibName:@"Result" bundle:nil];
  34. ((ResultViewController *)resultVC).params = params;
  35. return resultVC;
  36. }
  37. - (void)labelClick {
  38. NSLog(@"underlineLabel被点击了");
  39. }
  40. - (void)resetContraint {
  41. for (NSLayoutConstraint *constraint in self.view.constraints) {
  42. if ([constraint.identifier isEqualToString:@"title_top"] ) {
  43. [self.view removeConstraint:constraint];
  44. }
  45. if ([constraint.identifier isEqualToString:@"scroll_bottom"]) {
  46. [self.view removeConstraint:constraint];
  47. }
  48. }
  49. NSLayoutConstraint *scroll_top = [NSLayoutConstraint constraintWithItem:self.titleBar
  50. attribute:NSLayoutAttributeTop
  51. relatedBy:NSLayoutRelationEqual
  52. toItem:self.topLayoutGuide
  53. attribute:NSLayoutAttributeBottom
  54. multiplier:1.0
  55. constant:0];
  56. NSLayoutConstraint *scroll_bottom = [NSLayoutConstraint constraintWithItem:self.scrollview
  57. attribute:NSLayoutAttributeBottom
  58. relatedBy:NSLayoutRelationEqual
  59. toItem:self.bottomLayoutGuide
  60. attribute:NSLayoutAttributeTop
  61. multiplier:1.0
  62. constant:0];
  63. [self.view addConstraint:scroll_top];
  64. [self.view addConstraint:scroll_bottom];
  65. CGFloat height = self.bottomLayoutGuide.length;
  66. self.bottom_mask_constraint.constant = height;
  67. }
  68. - (void)viewDidLayoutSubviews {
  69. [super viewDidLayoutSubviews];
  70. [self resetContraint];
  71. }
  72. - (void)viewDidLoad {
  73. [super viewDidLoad];
  74. self.default_row_text_size=14;
  75. self.default_title_text_size=17;
  76. self.default_line_color = 0x000000;
  77. self.titleLabel.text = nil;
  78. // self.labelTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(labelTapAction:)];
  79. //
  80. // self.labelTap.numberOfTouchesRequired = 1; //手指数
  81. // self.labelTap.numberOfTapsRequired = 2; //tap次数
  82. //
  83. //
  84. //
  85. //
  86. // self.cellDoubleTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(cellDoubleTapAction:)];
  87. //
  88. // self.cellDoubleTap.numberOfTouchesRequired = 1; //手指数
  89. // self.cellDoubleTap.numberOfTapsRequired = 2; //tap次数
  90. // UITapGestureRecognizer *singleFingerOne = [[UITapGestureRecognizer alloc] initWithTarget:self
  91. // action:nil];
  92. // singleFingerOne.numberOfTouchesRequired = 1; //手指数
  93. // singleFingerOne.numberOfTapsRequired = 1; //tap次数
  94. //
  95. //
  96. // singleFingerTwo.delegate = self;
  97. self.label = [MDHTMLLabel new];
  98. self.label.font = [UIFont systemFontOfSize:self.default_row_text_size];
  99. self.label.textInsets = UIEdgeInsetsMake(0.f, 8.f, 0.f, 8.f);
  100. // NSString* Path = [[NSBundle mainBundle] pathForResource:@"layout.json" ofType:nil];
  101. //
  102. // NSData *data = [NSData dataWithContentsOfFile:Path];
  103. // self.content_layout = [[NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableContainers error:nil] mutableCopy];
  104. //
  105. //
  106. // Path = [[NSBundle mainBundle] pathForResource:@"data.json" ofType:nil];
  107. //
  108. // data = [NSData dataWithContentsOfFile:Path];
  109. // self.content_data = [[NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableContainers error:nil] mutableCopy];
  110. // int width=[self.content_layout[@"header"][@"width"] intValue];
  111. // if(width<self.tableview.frame.size.width)
  112. // width=self.tableview.frame.size.width;
  113. //
  114. // CGRect frame = CGRectMake(self.tableview.frame.origin.x, self.tableview.frame.origin.y, width, self.tableview.frame.size.height);
  115. // self.tableview.frame=frame;
  116. // self.scrollview.contentSize=self.tableview.frame.size;
  117. // Do any additional setup after loading the view, typically from a nib.
  118. self.automaticallyAdjustsScrollViewInsets = NO;
  119. self.tableview.tableFooterView = [UIView new];
  120. [self setupNavigationBar];
  121. [self configureTableView];
  122. [self setupTableRefreshView];
  123. [self loadContent];
  124. // self.tableview.tableHeaderView = [self get_tableHeader];
  125. }
  126. - (void)viewWillAppear:(BOOL)animated {
  127. [super viewWillAppear:animated];
  128. }
  129. -(void)labelTapAction:(UIGestureRecognizer*)gestureRecognizer
  130. {
  131. NSLog(@"label touched");
  132. MDHTMLLabel* label = (MDHTMLLabel*)[gestureRecognizer view];
  133. self.label.htmlText = label.htmlText;
  134. [self.label sizeToFit];
  135. if(self.label.frame.size.width>label.frame.size.width||self.label.frame.size.height>label.frame.size.height)
  136. {
  137. FullyShowViewController *fullVC = [[UIStoryboard storyboardWithName:@"Result" bundle:nil] instantiateViewControllerWithIdentifier:@"fullyShowViewController"];
  138. fullVC.htmlText = label.htmlText;
  139. fullVC.preferredContentSize = CGSizeMake(200, 240);
  140. fullVC.modalPresentationStyle=UIModalPresentationPopover;
  141. UIPopoverPresentationController* popPc = fullVC.popoverPresentationController;
  142. popPc.permittedArrowDirections = UIPopoverArrowDirectionAny;
  143. CGRect rectl = [RAUtils relativeFrameForScreenWithView:label];
  144. CGRect rectv =[RAUtils relativeFrameForScreenWithView:self.view];
  145. CGRect intersection_rect=CGRectIntersection(rectl, rectv);
  146. UIWindow * window=[[[UIApplication sharedApplication] delegate] window];
  147. CGRect source_rect=[RAUtils relativeFrame:intersection_rect FromView:window toView:label];
  148. // CGRect rect=[v convertRect: v.bounds toView:window];
  149. popPc.sourceRect = source_rect;
  150. popPc.sourceView = label;
  151. // popPc.barButtonItem = label;
  152. popPc.delegate = self;
  153. [self presentViewController:fullVC animated:true completion:nil];
  154. }
  155. }
  156. - (void)didReceiveMemoryWarning {
  157. [super didReceiveMemoryWarning];
  158. // Dispose of any resources that can be recreated.
  159. }
  160. - (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration {
  161. }
  162. -(void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation
  163. {
  164. // auto resizing
  165. // self.scrollview.contentSize=self.tableview.frame.size;
  166. // auto layout
  167. // int width=[self.content_layout[@"header"][@"width"] intValue];
  168. // if(width<self.view.frame.size.width)
  169. // width=self.view.frame.size.width;
  170. // self.w_constraint.constant = width - CGRectGetWidth(self.view.bounds);
  171. // self.h_constraint.constant = 0;
  172. [self updateTableFrame];
  173. }
  174. #pragma mark - TableView DataSource
  175. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
  176. return [self.content_data[@"count"] intValue];
  177. // return 0;
  178. }
  179. //- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
  180. //{
  181. // return 1;
  182. //}
  183. - (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
  184. {
  185. int height=[self.content_layout[@"header"][@"height"] intValue];
  186. if(height==0)
  187. height=44;
  188. return height;
  189. }
  190. - (UIView *) tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
  191. {
  192. NSArray* arr_col=self.content_layout[@"header"][@"col"];
  193. NSString* value =self.content_layout[@"header"][@"f_color"];//[DefaultAppearance get_noneappearance_value:@"DefaultTableHeaderView" valuename:@"title_text_color"];
  194. if(value==nil)
  195. value=@"";
  196. unsigned long fcolor = strtoul([value UTF8String],0,16);
  197. value =self.content_layout[@"header"][@"bg_color"];//[DefaultAppearance get_noneappearance_value:@"DefaultTableHeaderView" valuename:@"title_text_color"];
  198. if(value==nil)
  199. value=@"0xFFFFFF";
  200. unsigned long bgcolor = strtoul([value UTF8String],0,16);
  201. UIView* myView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, tableView.bounds.size.width, 0.0001)];
  202. myView.backgroundColor = UIColorFromRGB(bgcolor);
  203. myView.layer.shadowPath =[UIBezierPath bezierPathWithRect:myView.bounds].CGPath;
  204. myView.layer.shadowColor = [UIColor blackColor].CGColor;
  205. myView.layer.shadowOffset = CGSizeMake(0, 0);
  206. myView.layer.shadowOpacity = 0.5;
  207. myView.layer.shadowRadius = 2.0;
  208. int x=0;//[self.content_layout[@"header"][@"margin_l"] intValue];
  209. int y=0;//[self.content_layout[@"header"][@"margin_t"] intValue];;
  210. int height = [self.content_layout[@"header"][@"height"] intValue];
  211. for(int i=0;i<arr_col.count;i++)
  212. {
  213. int width = [arr_col[i][@"width"] intValue];
  214. UILabel *headerlabel = [[UILabel alloc] initWithFrame:CGRectMake(x, y, width, height)];
  215. headerlabel.font = [UIFont boldSystemFontOfSize:self.default_title_text_size];
  216. headerlabel.textColor=UIColorFromRGB(fcolor);//UIColor.blackColor;
  217. headerlabel.backgroundColor = [UIColor clearColor];
  218. headerlabel.text=arr_col[i][@"name"];
  219. headerlabel.textAlignment= [self get_TextHAlign:arr_col[i][@"h_align"] ];
  220. // headerlabel.font = [UIFont boldSystemFontOfSize:20];
  221. // [headerlabel sizeToFit];
  222. headerlabel.layer.borderWidth=0.5;
  223. headerlabel.layer.borderColor = UIColorFromRGB(self.default_line_color).CGColor;
  224. [myView addSubview:headerlabel];
  225. x+=width;
  226. }
  227. myView.autoresizesSubviews=true;
  228. // [myView setAutoresizingMask:UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleLeftMargin];
  229. // modellabel.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin;
  230. // pricelabel.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin;
  231. // timelabel.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin;
  232. myView.autoresizingMask = UIViewAutoresizingFlexibleWidth;
  233. //
  234. return myView;
  235. }
  236. - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
  237. {
  238. int height=[self.content_layout[@"row"][@"height"] intValue];
  239. if(height==0)
  240. height=44;
  241. return height;
  242. }
  243. -(NSTextAlignment) get_TextHAlign:(NSString*)textHAlign
  244. {
  245. if([textHAlign.lowercaseString isEqualToString:@"center"])
  246. return NSTextAlignmentCenter;
  247. else if([textHAlign.lowercaseString isEqualToString:@"left"])
  248. return NSTextAlignmentLeft;
  249. else if([textHAlign.lowercaseString isEqualToString:@"right"])
  250. return NSTextAlignmentRight;
  251. return NSTextAlignmentLeft;
  252. }
  253. //-(RTTextAlignment) get_RTTextHAlign:(NSString*)textHAlign
  254. //{
  255. //
  256. //
  257. //
  258. //
  259. // if([textHAlign.lowercaseString isEqualToString:@"center"])
  260. // return RTTextAlignmentCenter;
  261. // else if([textHAlign.lowercaseString isEqualToString:@"left"])
  262. // return RTTextAlignmentLeft;
  263. // else if([textHAlign.lowercaseString isEqualToString:@"right"])
  264. // return RTTextAlignmentRight;
  265. //
  266. // return RTTextAlignmentLeft;
  267. //}
  268. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
  269. {
  270. {
  271. NSString *CellIdentifier = @"tCell";
  272. ResultCell * cell= [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
  273. cell.touchDelegate = self;
  274. for(UIGestureRecognizer* g in cell.gestureRecognizers)
  275. [ cell removeGestureRecognizer:g];
  276. // cell gesture
  277. // [cell removeGestureRecognizer:self.cellDoubleTap];
  278. for(UIView* v in cell.subviews)
  279. {
  280. for(UIGestureRecognizer* g in v.gestureRecognizers)
  281. [ v removeGestureRecognizer:g];
  282. [v removeFromSuperview];
  283. }
  284. // cell.detailTextLabel.text=@"detail";
  285. // cell.textLabel.text=[NSString stringWithFormat:@"%ld",indexPath.row];
  286. UITapGestureRecognizer *cellDoubleTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(cellDoubleTapAction:)];
  287. cellDoubleTap.numberOfTouchesRequired = 1; //手指数
  288. cellDoubleTap.numberOfTapsRequired = 2; //tap次数
  289. [cell addGestureRecognizer:cellDoubleTap];
  290. // 3D Touch
  291. // if (self.traitCollection.forceTouchCapability == UIForceTouchCapabilityAvailable) {
  292. // DebugLog(@"3D Touch 可用!");
  293. // //给cell注册3DTouch的peek(预览)和pop功能
  294. // [self registerForPreviewingWithDelegate:self sourceView:cell];
  295. // } else {
  296. // DebugLog(@"3D Touch 无效");
  297. // }
  298. NSArray* arr_col=self.content_layout[@"header"][@"col"];
  299. NSArray* item =self.content_data[[NSString stringWithFormat:@"item_%ld",indexPath.row]];
  300. NSString* value =self.content_layout[@"row"][@"f_color"];//[DefaultAppearance get_noneappearance_value:@"DefaultTableHeaderView" valuename:@"title_text_color"];
  301. if(value==nil)
  302. value=@"";
  303. unsigned long fcolor = strtoul([value UTF8String],0,16);
  304. value =self.content_layout[@"row"][@"color_0"];//[DefaultAppearance get_noneappearance_value:@"DefaultTableHeaderView" valuename:@"title_text_color"];
  305. if(value==nil)
  306. value=@"";
  307. unsigned long color0 = strtoul([value UTF8String],0,16);
  308. value =self.content_layout[@"row"][@"color_1"];//[DefaultAppearance get_noneappearance_value:@"DefaultTableHeaderView" valuename:@"title_text_color"];
  309. if(value==nil)
  310. value=@"";
  311. unsigned long color1 = strtoul([value UTF8String],0,16);
  312. int x=0;//[self.content_layout[@"header"][@"margin_l"] intValue];
  313. int y=0;//[self.content_layout[@"header"][@"margin_t"] intValue];;
  314. int height = [self.content_layout[@"row"][@"height"] intValue];
  315. for(int i=0;i<arr_col.count;i++)
  316. {
  317. int width = [arr_col[i][@"width"] intValue];;
  318. MDHTMLLabel *vallabel = [[MDHTMLLabel alloc] initWithFrame:CGRectMake(x, y, width, height)];
  319. vallabel.textInsets = UIEdgeInsetsMake(0.f, 8.f, 0.f, 8.f);
  320. vallabel.font = [UIFont systemFontOfSize:self.default_row_text_size];
  321. vallabel.textColor=UIColorFromRGB(fcolor);//UIColor.blackColor;
  322. vallabel.backgroundColor = [UIColor clearColor];
  323. NSString* text=@"";
  324. if(i>item.count-1)
  325. text=@"row data missing";
  326. else
  327. text=item[i];
  328. // RTTextLineBreakModeWordWrapping = kCTLineBreakByWordWrapping,
  329. // RTTextLineBreakModeCharWrapping = kCTLineBreakByCharWrapping,
  330. // RTTextLineBreakModeClip = kCTLineBreakByClipping,
  331. // NSMutableAttributedString *attrStr = [[NSMutableAttributedString alloc] initWithString:text];
  332. // vallabel.attributedText = attrStr;
  333. vallabel.htmlText = text;
  334. vallabel.textAlignment= [self get_TextHAlign:arr_col[i][@"h_align"] ];
  335. vallabel.layer.borderWidth=0.3;
  336. vallabel.layer.borderColor = UIColorFromRGB(self.default_line_color).CGColor;
  337. // UITapGestureRecognizer *gestureRecognizer = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(labelTapAction:)];
  338. UITapGestureRecognizer* labelTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(labelTapAction:)];
  339. labelTap.numberOfTouchesRequired = 1; //手指数
  340. labelTap.numberOfTapsRequired = 1; //tap次数
  341. [vallabel addGestureRecognizer:labelTap];
  342. [labelTap requireGestureRecognizerToFail:cellDoubleTap];
  343. // [vallabel addGestureRecognizer:self.cellDoubleTap];
  344. vallabel.userInteractionEnabled = YES;
  345. // [vallabel becomeFirstResponder];
  346. // vallabel.delegate = self;
  347. // [statuslabel sizeToFit];
  348. [cell addSubview:vallabel];
  349. x+=width;
  350. }
  351. cell.touchColor = [UIColor colorWithRed:0.3 green:0.3 blue:0.3 alpha:0.4];
  352. if(indexPath.row%2==0)
  353. cell.backgroundColor=UIColorFromRGB(color0);//[UIColor whiteColor];
  354. else
  355. cell.backgroundColor=UIColorFromRGB(color1);//[UIColor lightGrayColor];
  356. return cell;
  357. }
  358. }
  359. - (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath {
  360. cell.backgroundColor = [UIColor whiteColor];
  361. }
  362. //#pragma mark - TouchLabel Delegate
  363. //- (void)touchLabel:(TouchLabel *)touchLabel touchesWtihTag:(NSInteger)tag
  364. //{
  365. //
  366. //}
  367. //-(void) empty
  368. //{
  369. //
  370. //}
  371. #pragma mark - UIPopoverPresentationControllerDelegate Delegate
  372. //实现该代理方法,返回UIModalPresentationNone值,可以在iPhone设备实现popover效果
  373. -(UIModalPresentationStyle)adaptivePresentationStyleForPresentationController:(UIPresentationController *)controller{
  374. return UIModalPresentationNone;//不适配(不区分ipad或iPhone)
  375. }
  376. #pragma mark - TableView Delegate
  377. - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
  378. {
  379. NSLog(@"cell selected");
  380. }
  381. - (UITableViewCellEditingStyle)tableView:(UITableView *)tv editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath {
  382. return UITableViewCellEditingStyleDelete;
  383. }
  384. #pragma mark - Public
  385. - (void)setQueryParams:(NSMutableDictionary *)params {
  386. self.params = params;
  387. }
  388. #pragma mark - Private
  389. - (void)setupTableRefreshView {
  390. __weak typeof(self) weakSelf = self;
  391. self.tableview.jl_header = [[JLRefreshHeader alloc] init];
  392. self.tableview.jl_header.refreshDelegate = self;
  393. self.tableview.jl_header.clear = YES;
  394. self.tableview.jl_header.offsetBlock = ^(CGFloat offset) {
  395. if (offset <= 0) {
  396. weakSelf.header_top_constraint.constant = -offset;
  397. }
  398. };
  399. self.tableview.jl_header.stateChangeBlock = ^(JLRefreshState state) {
  400. NSString *title = [weakSelf.tableview.jl_header refreshTitleForState:state];
  401. weakSelf.refreshHeaderTitleLb.text = title;
  402. };
  403. self.tableview.jl_footer = [[JLRefreshFooter alloc] init];
  404. self.tableview.jl_footer.refreshDelegate = self;
  405. self.tableview.jl_footer.clear = YES;
  406. self.tableview.jl_footer.offsetBlock = ^(CGFloat offset) {
  407. if (offset <= 0) {
  408. weakSelf.footer_top_constraint.constant = offset;
  409. }
  410. };
  411. self.tableview.jl_footer.stateChangeBlock = ^(JLRefreshState state) {
  412. NSString *title = [weakSelf.tableview.jl_footer refreshTitleForState:state];
  413. weakSelf.refreshFooterTitleLb.text = title;
  414. };
  415. }
  416. - (void)configureTableView {
  417. [self.tableview registerNib:[UINib nibWithNibName:@"ResultCell" bundle:nil] forCellReuseIdentifier:@"tCell"];
  418. }
  419. - (void)setupNavigationBar {
  420. if(self.content_menu==nil)
  421. {
  422. self.navigationItem.rightBarButtonItem=nil;
  423. return;
  424. }
  425. UIBarButtonItem *menuItem = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"ic_menu"] style:UIBarButtonItemStylePlain target:self action:@selector(MenuClick:)];
  426. self.navigationItem.rightBarButtonItem = menuItem;
  427. UIBarButtonItem *backItem = [[UIBarButtonItem alloc] init];
  428. backItem.title = @"Back";
  429. self.navigationItem.backBarButtonItem = backItem;
  430. }
  431. - (NSInteger)resultItemCount {
  432. return [[self.content_data objectForKey:@"count"] integerValue];
  433. }
  434. - (void)loadContent {
  435. [self loadContentWithOption:0 Complete:nil];
  436. }
  437. - (void)updateTableFrame {
  438. // auto resizing
  439. // int width=[self.content_layout[@"header"][@"width"] intValue];
  440. // if(width<self.tableview.frame.size.width)
  441. // width=self.tableview.frame.size.width;
  442. //
  443. // CGRect frame = CGRectMake(self.tableview.frame.origin.x, self.tableview.frame.origin.y, width, self.tableview.frame.size.height);
  444. // self.tableview.frame=frame;
  445. // self.scrollview.contentSize=self.tableview.frame.size;
  446. // auto layout
  447. int width=[self.content_layout[@"header"][@"width"] intValue];
  448. if(width<self.view.frame.size.width)
  449. width=self.view.frame.size.width;
  450. self.w_constraint.constant = width - CGRectGetWidth(self.view.bounds);
  451. self.h_constraint.constant = 0;
  452. // 约束修改后立即重新布局
  453. [self.view layoutIfNeeded];
  454. if (@available(iOS 11.0,*)) {
  455. UIEdgeInsets edgeInsets = [self.view safeAreaInsets];
  456. CGFloat left = edgeInsets.left;
  457. CGFloat right = edgeInsets.right;
  458. self.lead_constraint.constant = left;
  459. self.trail_constraint.constant = right;
  460. /*
  461. * lead 和 trail改变之前
  462. * scrollview.size.width = self.view.size.width;
  463. * 改变后
  464. * scrollview.size.width = self.view.size.width - left - right;
  465. * 由于w_contraint本质上是根据scrolliew.size.width决定,实际上使用self.view.size.width计算得到
  466. * 所以w_contraint需要 +left +right补偿偏差。
  467. */
  468. self.w_constraint.constant += left + right;
  469. // 约束修改后立即重新布局
  470. [self.view layoutIfNeeded];
  471. }
  472. }
  473. #pragma mark - RefreshDelegate
  474. - (void)jl_pullRefresh:(JLRefreshBasis *)refresh state:(JLRefreshState)state percentage:(float)percentage {
  475. // NSString *title = [refresh refreshTitleForState:state];
  476. // CGFloat offset = refresh.jl_height * percentage;
  477. if ([refresh isEqual:self.tableview.jl_header]) {
  478. // self.refreshHeaderTitleLb.text = title;
  479. // self.header_top_constraint.constant = offset;
  480. }
  481. if (refresh == self.tableview.jl_footer) {
  482. // self.refreshFooterTitleLb.text = title;
  483. // self.footer_top_constraint.constant = -offset;
  484. }
  485. }
  486. - (void)jl_endRefresh:(JLRefreshBasis *)refresh {
  487. // state == idle
  488. // refresh UI
  489. [self.tableview reloadData];
  490. if (refresh == self.tableview.jl_footer && refresh.state == JLRefreshStateNoMore) {
  491. }
  492. }
  493. - (void)jl_beginRefresh:(JLRefreshBasis *)refresh {
  494. // state == refreshing
  495. // load data
  496. // finish loading data
  497. int option = 0;
  498. if ([refresh isEqual:self.tableview.jl_header]) {
  499. option = 1;
  500. }
  501. if (refresh == self.tableview.jl_footer) {
  502. if(refresh.state==JLRefreshStateNoMore) //数据取完不再加载
  503. return;
  504. option = 2;
  505. }
  506. self.tableview.userInteractionEnabled = NO;
  507. __weak typeof(self) weakSelf = self;
  508. [self loadContentWithOption:option Complete:^(int result, int count) {
  509. weakSelf.tableview.userInteractionEnabled = YES;
  510. if ([refresh isEqual:weakSelf.tableview.jl_header]) {
  511. [weakSelf.tableview.jl_header performSelector:@selector(endRefresh)];
  512. }
  513. if (refresh == weakSelf.tableview.jl_footer) {
  514. [weakSelf.tableview.jl_footer performSelector:@selector(endRefresh)];
  515. if (result == 2 && count < delta) {
  516. [weakSelf.tableview.jl_footer performSelector:@selector(noMoreData)];
  517. }
  518. }
  519. }];
  520. }
  521. #pragma mark - Quick Look
  522. - (MyQLPreviewController *)quickLook {
  523. if (!_quickLook)
  524. {
  525. _quickLook = [[MyQLPreviewController alloc] init];
  526. _quickLook.delegate = self;
  527. _quickLook.dataSource = self;
  528. }
  529. else
  530. {
  531. [_quickLook reloadData];
  532. }
  533. return _quickLook;
  534. }
  535. #pragma mark - QuickLook Data Source
  536. - (NSInteger)numberOfPreviewItemsInPreviewController:(QLPreviewController *)controller {
  537. return 1;
  538. }
  539. - (id <QLPreviewItem>) previewController:(QLPreviewController *)controller previewItemAtIndex:(NSInteger)index {
  540. if(self.documentPath==nil)
  541. return nil;
  542. return [NSURL fileURLWithPath:self.documentPath];
  543. }
  544. #pragma mark - QuickLook Delegate
  545. - (void) previewControllerDidDismiss:(QLPreviewController *)controller {
  546. }
  547. /**
  548. * 文件内部链接点击不进行外部跳转
  549. */
  550. - (BOOL) previewController:(QLPreviewController *)controller shouldOpenURL:(NSURL *)url forPreviewItem:(id<QLPreviewItem>)item {
  551. return NO;
  552. }
  553. #pragma mark - customize editor
  554. - (UIView*)get_tableHeader
  555. {
  556. UILabel * headerview = [UILabel new];
  557. headerview.frame = CGRectMake(0, 0, self.tableview.frame.size.width, 44);
  558. headerview.numberOfLines = 0;
  559. headerview.textAlignment = NSTextAlignmentCenter;
  560. headerview.text = @"";
  561. return headerview;
  562. }
  563. -(void) resize_tableHeader
  564. {
  565. //利用systemLayoutSizeFittingSize:计算出真实高度
  566. CGFloat height = [self.tableview.tableHeaderView systemLayoutSizeFittingSize:UILayoutFittingCompressedSize].height;
  567. CGRect headerFrame = self.tableview.tableHeaderView.frame;
  568. headerFrame.size.height = height+20;//20是留的上下边距
  569. //修改tableHeaderView的frame
  570. self.tableview.tableHeaderView.frame = headerFrame;
  571. }
  572. #pragma mark - 3D Touch Delegate (PreviewingDelegate)
  573. // peek (预览)
  574. - (UIViewController *)previewingContext:(id<UIViewControllerPreviewing>)previewingContext viewControllerForLocation:(CGPoint)location {
  575. // [previewingContext sourceView]即为所按压的视图
  576. // UITableViewCell *view = (UITableViewCell *)[previewingContext sourceView];
  577. //
  578. // // 设置不被虚化的范围
  579. // CGRect rect = view.bounds;
  580. // [previewingContext setSourceRect:rect];
  581. //
  582. // NSIndexPath *indexPath = [self.tableview indexPathForCell:view];
  583. // // peek (预览界面)
  584. // UIViewController *tvc = [self viewControllerFor3DTouch:indexPath];
  585. //
  586. // tvc.preferredContentSize = CGSizeMake(0, 480); // 预览图的大小
  587. //
  588. // return tvc;
  589. // NSIndexPath *indexPath = [self.tableview indexPathForCell:view];
  590. // [self presses3DTouchForIndexPath:indexPath];
  591. return nil;
  592. }
  593. // pop (在预览基础上更用力按压)
  594. - (void)previewingContext:(id<UIViewControllerPreviewing>)previewingContext commitViewController:(UIViewController *)viewControllerToCommit {
  595. // [self showViewController:viewControllerToCommit sender:self];
  596. }
  597. #pragma mark - Cell Touch Delegate
  598. - (void)touchedCell:(ResultCell *)cell withForce:(float)force {
  599. if (force > 4.0f) {
  600. // 1519: 普通短震,3D Touch 中 Peek 震动反馈
  601. // 1520: 普通短震,3D Touch 中 Pop 震动反馈
  602. // 1521: 连续三次短震
  603. // kSystemSoundID_Vibrate: 震动很暴力,不适合震动反馈
  604. AudioServicesPlaySystemSound(1519); // 支持震动的设备上会震动,不支持就什么都不做 kSystemSoundID_Vibrate
  605. NSIndexPath *indexPath = [self.tableview indexPathForCell:cell];
  606. [self presses3DTouchForIndexPath:indexPath];
  607. }
  608. NSLog(@"force %f",force);
  609. }
  610. #pragma mark - Child View Controller Override
  611. /**
  612. * 0: init load
  613. * 1: refresh
  614. * 2: load more
  615. */
  616. - (void)loadContentWithOption:(int)option Complete:(void (^)(int result,int count))finish {
  617. NSAssert(true, ([NSString stringWithFormat:@"%s loadContentWithOption not impl",object_getClassName([self class])]));
  618. // if (self.params) {
  619. //
  620. // NSMutableDictionary *dic = self.params.mutableCopy;
  621. // switch (option) {
  622. // case 0:
  623. // case 1: {
  624. // self.offset = 0;
  625. // self.content_layout =nil;
  626. // self.content_action = nil;
  627. // self.content_menu = nil;
  628. // self.content_data = nil;
  629. // }
  630. // break;
  631. // case 2: {
  632. // self.offset = [self resultItemCount];
  633. // }
  634. // break;
  635. // }
  636. //
  637. //// dic[@"criteria"] = self.params;
  638. //
  639. // [dic setObject:@(self.offset) forKey:@"offset"];
  640. // [dic setObject:@(delta) forKey:@"limit"];
  641. //// dic[@"criteria"] = [NSArray arrayWithObjects:@"aaa",@"bbb", nil];
  642. //
  643. // __weak typeof(self) weakSelf = self;
  644. // dispatch_async(dispatch_get_global_queue(0, 0), ^{
  645. // NSDictionary *contentDic = [RANetwork query:dic];
  646. // NSInteger result = [[contentDic objectForKey:@"result"] integerValue];
  647. // dispatch_async(dispatch_get_main_queue(), ^{
  648. // if (weakSelf) {
  649. // __strong typeof(weakSelf) strongSelf = weakSelf;
  650. // if (result == RESULT_TRUE) {
  651. // strongSelf.content_layout = [contentDic objectForKey:@"layout"];
  652. // strongSelf.content_action = [contentDic objectForKey:@"row_action"];
  653. // strongSelf.content_menu = [[contentDic objectForKey:@"menu"] mutableCopy];
  654. // [strongSelf setupNavigationBar];
  655. //
  656. // UILabel * headerview=(UILabel *)self.tableview.tableHeaderView;
  657. // headerview.text = contentDic[@"table_title"];
  658. // [self resize_tableHeader];
  659. //
  660. // if(strongSelf.content_data==nil)
  661. // strongSelf.content_data = [NSMutableDictionary new];
  662. // NSMutableDictionary* newdata = [[contentDic objectForKey:@"data"] mutableCopy];
  663. // for(int dc = 0;dc<[newdata[@"count"] intValue];dc++)
  664. // {
  665. // NSMutableDictionary * newdata_item = newdata[[NSString stringWithFormat:@"item_%d",dc]];
  666. //
  667. // strongSelf.content_data[[NSString stringWithFormat:@"item_%d",[strongSelf.content_data[@"count"] intValue] ]] = newdata_item;
  668. // strongSelf.content_data[@"count"] = @([strongSelf.content_data[@"count"] intValue]+1);
  669. // }
  670. //
  671. //// strongSelf.content_data = [contentDic objectForKey:@"data"];
  672. // [strongSelf updateTableFrame];
  673. // [strongSelf.tableview reloadData];
  674. // } else {
  675. // [RAUtils message_alert:[contentDic objectForKey:@"err_msg"] title:@"Warning" controller:strongSelf];
  676. // }
  677. //
  678. // if (finish) {
  679. // finish((int)result,(int)[self resultItemCount]);
  680. // }
  681. //
  682. // }
  683. //
  684. // });
  685. // });
  686. // }
  687. }
  688. - (void)MenuClick:(UIBarButtonItem *)sender {
  689. // UIAlertController *alertControl = [UIAlertController alertControllerWithTitle:nil message:nil preferredStyle:UIAlertControllerStyleActionSheet];
  690. // //block代码块取代了delegate
  691. //
  692. // __weak typeof(self) weakSelf = self;
  693. // for(int i=0;i<self.content_menu.count;i++)
  694. // {
  695. // NSMutableDictionary* json = self.content_menu[i];
  696. // NSString* title =json[@"title"];
  697. // NSString* actiontype = json[@"action"];
  698. // NSString* url = json[@"url"];
  699. //// NSMutableDictionary* add_params = json[@"params"];
  700. // UIAlertAction *actioni = [UIAlertAction actionWithTitle:title style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
  701. // // DebugLog(@"Cancel");
  702. // if([actiontype isEqualToString:@"download"])
  703. // {
  704. // [weakSelf Export:url];
  705. // }
  706. // else if([actiontype isEqualToString:@"save"])
  707. // {
  708. // [weakSelf save];
  709. // }
  710. // }];
  711. // [alertControl addAction:actioni];
  712. // }
  713. //
  714. // UIAlertAction *actionCancel = [UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) {
  715. // // DebugLog(@"Cancel");
  716. //
  717. // }];
  718. // [alertControl addAction:actionCancel];
  719. //
  720. //
  721. //
  722. //
  723. //
  724. // [self presentViewController:alertControl animated:NO completion:nil];
  725. }
  726. //- (void)save {
  727. //
  728. //}
  729. //
  730. //-(void)Export:(NSString*) url
  731. //{
  732. //
  733. // NSAssert(true, ([NSString stringWithFormat:@"%s Export not impl",object_getClassName([self class])]));
  734. //// if(self.download_query )
  735. //// {
  736. //// self.documentPath = self.download_query;
  737. //// [self.navigationController pushViewController:self.quickLook animated:NO];
  738. //// return;
  739. //// }
  740. ////
  741. //// __weak typeof(self) weakSelf = self;
  742. //// dispatch_async(dispatch_get_global_queue(0, 0), ^{
  743. ////
  744. ////// NSMutableDictionary *params = self.params.mutableCopy;
  745. ////// if(add_params!=nil)
  746. ////// [params addEntriesFromDictionary:add_params];
  747. //// NSString *path = [RANetwork download_query:url];
  748. //// weakSelf.download_query = path;
  749. //// weakSelf.documentPath = path;
  750. ////
  751. //// if (path) {
  752. //// dispatch_async(dispatch_get_main_queue(), ^{
  753. //// [weakSelf.navigationController pushViewController:weakSelf.quickLook animated:NO];
  754. //// });
  755. //// }
  756. ////
  757. //// });
  758. //}
  759. //- (void)downloadItemClick:(UIBarButtonItem *)sender {
  760. // NSAssert(true, ([NSString stringWithFormat:@"%s downloadItemClick not impl",object_getClassName([self class])]));
  761. ////
  762. ////
  763. //// if(self.download_query )
  764. //// {
  765. //// self.documentPath = self.download_query;
  766. //// [self.navigationController pushViewController:self.quickLook animated:NO];
  767. //// return;
  768. //// }
  769. ////
  770. //// __weak typeof(self) weakSelf = self;
  771. //// dispatch_async(dispatch_get_global_queue(0, 0), ^{
  772. ////
  773. //// NSMutableDictionary *params = self.params.mutableCopy;
  774. //// NSString *path = [RANetwork download_query:params];
  775. //// weakSelf.download_query = path;
  776. //// weakSelf.documentPath = path;
  777. ////
  778. //// if (path) {
  779. //// dispatch_async(dispatch_get_main_queue(), ^{
  780. //// [weakSelf.navigationController pushViewController:weakSelf.quickLook animated:NO];
  781. //// });
  782. //// }
  783. ////
  784. //// });
  785. ////
  786. //}
  787. - (void)presses3DTouchForIndexPath:(NSIndexPath *)indexPath {
  788. }
  789. -(void)cellDoubleTapAction:(UIGestureRecognizer*)gestureRecognizer
  790. {
  791. NSAssert(true, ([NSString stringWithFormat:@"%s cellDoubleTapAction not impl",object_getClassName([self class])]));
  792. }
  793. //{
  794. // NSLog(@"cell double tap");
  795. // UITableViewCell* cell = (UITableViewCell*)[gestureRecognizer view];
  796. // NSIndexPath* indexPath=[self.tableview indexPathForCell:cell];
  797. // //strongSelf.content_action
  798. // if(self.content_action!=nil)
  799. // {
  800. //
  801. // if(self.content_action.count==1)
  802. // {
  803. // NSDictionary* action =self.content_action.firstObject;
  804. // NSString * module = action[@"module"];
  805. // if([module isEqualToString:@"quick_look"])
  806. // {
  807. //
  808. // // +(NSString*)download_file : (NSMutableDictionary*) params url:(NSString*) url
  809. // NSMutableDictionary *params = action[@"params"];
  810. // NSString* URL =action[@"url"];
  811. // __weak typeof(self) weakSelf = self;
  812. // dispatch_async(dispatch_get_global_queue(0, 0), ^{
  813. //
  814. //
  815. // NSString *path = [RANetwork download_file:params url:URL];
  816. // weakSelf.documentPath = path;
  817. //
  818. // if (path) {
  819. // dispatch_async(dispatch_get_main_queue(), ^{
  820. // [weakSelf.navigationController pushViewController:weakSelf.quickLook animated:NO];
  821. // });
  822. // }
  823. //
  824. // });
  825. // }
  826. // else if([module isEqualToString:@"kv_detail"])
  827. // {
  828. // NSMutableDictionary *params = [NSMutableDictionary new];
  829. // params[@"query_id"] = self.params[@"query_id"];
  830. //
  831. // NSMutableDictionary *criteria =[NSMutableDictionary new];
  832. // for(NSString* key in [action[@"params"] allKeys] )
  833. // {
  834. // NSArray* item =self.content_data[[NSString stringWithFormat:@"item_%ld",indexPath.row]];
  835. // int idx =[action[@"params"][key] intValue];
  836. // criteria[key]=item[ idx];
  837. // }
  838. //
  839. //
  840. // params[@"criteria"]=[RAConvertor dict2string:criteria] ;
  841. //
  842. //
  843. //
  844. // UIAlertView * waitalert = [RAUtils waiting_alert:@"Loading..." title:@"Please wait"];
  845. //
  846. //
  847. // __weak typeof(self) weakself = self;
  848. // dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
  849. //
  850. //
  851. //
  852. // NSDictionary* json =[RANetwork kv_detail:params];
  853. //
  854. // dispatch_async(dispatch_get_main_queue(), ^{
  855. // [waitalert dismissWithClickedButtonIndex:0 animated:FALSE];
  856. //
  857. //
  858. // if([[json valueForKey:@"result"] intValue]==2)
  859. // {
  860. // KVViewController *vc = [[UIStoryboard storyboardWithName:@"Detail" bundle:nil] instantiateViewControllerWithIdentifier:@"KVViewController"];
  861. // vc.content = [json mutableCopy];
  862. // [weakself.navigationController pushViewController:vc animated:NO];
  863. //
  864. // // weakself.content_data_download = [weakself CopyDirty:weakself.content_data_download to:[editor_json mutableCopy]];//[editor_json mutableCopy];
  865. // //
  866. // // weakself.content_data_control = [weakself translate_json:weakself.content_data_download changed: weakself.changed_data];
  867. // //
  868. // //
  869. // // [weakself download_success];
  870. // // [weakself.editorTable reloadData];
  871. //
  872. // }
  873. // else
  874. // {
  875. // [RAUtils message_alert:json[@"msg"] title:nil controller:weakself] ;
  876. // }
  877. //
  878. //
  879. //
  880. //
  881. // });
  882. // });
  883. // }
  884. // else if([module isEqualToString:@"order_detail"])
  885. // {
  886. //
  887. // OrderDetailViewController *vc = [[UIStoryboard storyboardWithName:@"Detail" bundle:nil] instantiateViewControllerWithIdentifier:@"OrderDetailViewController"];
  888. //
  889. //
  890. // vc.url_type = URL_REMOTE;
  891. // vc.request_url=URL_ORDER_DETAIL;
  892. //
  893. //
  894. // vc.params = [NSMutableDictionary dictionary];
  895. // // NSString *path = [[NSBundle mainBundle] pathForResource:@"search_ui.json" ofType:nil];
  896. // // NSData *data = [NSData dataWithContentsOfFile:path];
  897. // // vc.content_data_download = [[NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableLeaves error:nil] mutableCopy];
  898. // [self.navigationController pushViewController:vc animated:NO];
  899. // return;
  900. // }
  901. // }
  902. // else
  903. // {
  904. //
  905. // UIAlertController *alertControl = [UIAlertController alertControllerWithTitle:@"" message:nil preferredStyle:UIAlertControllerStyleAlert];
  906. // //block代码块取代了delegate
  907. //
  908. // __weak typeof(self) weakSelf = self;
  909. // for(int i=0;i<self.content_action.count;i++)
  910. // {
  911. // NSMutableDictionary* json = self.content_action[i];
  912. // NSString* title =json[@"title"];
  913. // NSString* module = json[@"module"];
  914. // NSMutableDictionary* add_params = json[@"params"];
  915. // UIAlertAction *actioni = [UIAlertAction actionWithTitle:title style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
  916. //
  917. //
  918. // if([module isEqualToString:@"quick_look"])
  919. // {
  920. //
  921. // // +(NSString*)download_file : (NSMutableDictionary*) params url:(NSString*) url
  922. // NSMutableDictionary *params = json[@"params"];
  923. // NSString* URL =json[@"url"];
  924. // __weak typeof(self) weakSelf = self;
  925. // dispatch_async(dispatch_get_global_queue(0, 0), ^{
  926. //
  927. //
  928. // NSString *path = [RANetwork download_file:params url:URL];
  929. // weakSelf.documentPath = path;
  930. //
  931. // if (path) {
  932. // dispatch_async(dispatch_get_main_queue(), ^{
  933. // [weakSelf.navigationController pushViewController:weakSelf.quickLook animated:NO];
  934. // });
  935. // }
  936. //
  937. // });
  938. // }
  939. // else if([module isEqualToString:@"kv_detail"])
  940. // {
  941. // NSMutableDictionary *params = json[@"params"];
  942. //
  943. //
  944. // UIAlertView * waitalert = [RAUtils waiting_alert:@"Loading..." title:@"Please wait"];
  945. //
  946. //
  947. // __weak typeof(self) weakself = self;
  948. // dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
  949. //
  950. //
  951. //
  952. // NSDictionary* json =[RANetwork kv_detail:params];
  953. //
  954. // dispatch_async(dispatch_get_main_queue(), ^{
  955. // [waitalert dismissWithClickedButtonIndex:0 animated:FALSE];
  956. //
  957. //
  958. // if([[json valueForKey:@"result"] intValue]==2)
  959. // {
  960. // KVViewController *vc = [[UIStoryboard storyboardWithName:@"Detail" bundle:nil] instantiateViewControllerWithIdentifier:@"KVViewController"];
  961. // vc.content = [json mutableCopy];
  962. // [weakself.navigationController pushViewController:vc animated:NO];
  963. //
  964. // // weakself.content_data_download = [weakself CopyDirty:weakself.content_data_download to:[editor_json mutableCopy]];//[editor_json mutableCopy];
  965. // //
  966. // // weakself.content_data_control = [weakself translate_json:weakself.content_data_download changed: weakself.changed_data];
  967. // //
  968. // //
  969. // // [weakself download_success];
  970. // // [weakself.editorTable reloadData];
  971. //
  972. // }
  973. // else
  974. // {
  975. // [RAUtils message_alert:json[@"msg"] title:nil controller:weakself] ;
  976. // }
  977. //
  978. //
  979. //
  980. //
  981. // });
  982. // });
  983. // }
  984. // else if([module isEqualToString:@"order_detail"])
  985. // {
  986. //
  987. // OrderDetailViewController *vc = [[UIStoryboard storyboardWithName:@"Detail" bundle:nil] instantiateViewControllerWithIdentifier:@"OrderDetailViewController"];
  988. //
  989. //
  990. // vc.url_type = URL_REMOTE;
  991. // vc.request_url=URL_ORDER_DETAIL;
  992. //
  993. //
  994. // vc.params = [NSMutableDictionary dictionary];
  995. // // NSString *path = [[NSBundle mainBundle] pathForResource:@"search_ui.json" ofType:nil];
  996. // // NSData *data = [NSData dataWithContentsOfFile:path];
  997. // // vc.content_data_download = [[NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableLeaves error:nil] mutableCopy];
  998. // [self.navigationController pushViewController:vc animated:NO];
  999. // return;
  1000. // }
  1001. // // DebugLog(@"Cancel");
  1002. //// if([actiontype isEqualToString:@"download"])
  1003. //// {
  1004. //// [weakSelf Export:add_params];
  1005. //// }
  1006. //// else if([actiontype isEqualToString:@"save"])
  1007. //// {
  1008. //// }
  1009. // }];
  1010. // [alertControl addAction:actioni];
  1011. // }
  1012. //
  1013. // UIAlertAction *actionCancel = [UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) {
  1014. // // DebugLog(@"Cancel");
  1015. //
  1016. // }];
  1017. // [alertControl addAction:actionCancel];
  1018. //
  1019. //
  1020. //
  1021. //
  1022. //
  1023. // [self presentViewController:alertControl animated:NO completion:nil];
  1024. //
  1025. // }
  1026. //
  1027. // }
  1028. //
  1029. //
  1030. //
  1031. //}
  1032. @end