ScanHomeViewController.m 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196
  1. //
  2. // ScanHomeViewController.m
  3. // HMLG Scan Order
  4. //
  5. // Created by Rui Zhang on 5/12/22.
  6. // Copyright © 2022 United Software Applications, Inc. All rights reserved.
  7. //
  8. #import "ScanHomeViewController.h"
  9. #import "ScanHomeCell.h"
  10. #import "AppDelegate.h"
  11. #import "MainViewController.h"
  12. #import "WebViewController.h"
  13. @interface ScanHomeViewController ()
  14. @end
  15. @implementation ScanHomeViewController
  16. - (void)viewDidLoad {
  17. [super viewDidLoad];
  18. self.table.layer.borderColor = [UIColor darkGrayColor].CGColor;
  19. self.table.layer.borderWidth = 1.0;
  20. // [self loadNewsList];
  21. // Do any additional setup after loading the view.
  22. }
  23. - (void) reload_data {
  24. [self loadNewsList];
  25. }
  26. /*
  27. #pragma mark - Navigation
  28. // In a storyboard-based application, you will often want to do a little preparation before navigation
  29. - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
  30. // Get the new view controller using [segue destinationViewController].
  31. // Pass the selected object to the new view controller.
  32. }
  33. */
  34. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
  35. return self.newslist.count;
  36. }
  37. - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
  38. return 44;
  39. }
  40. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
  41. {
  42. ScanHomeCell *cell = [tableView dequeueReusableCellWithIdentifier:@"ScanHomeCell"];
  43. if (!cell) {
  44. cell = [[ScanHomeCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"ScanHomeCell"];
  45. }
  46. // NSArray* arr = self.newslist;
  47. cell.labeltitle.text = self.newslist[indexPath.row][@"title"];
  48. cell.labeldate.text = self.newslist[indexPath.row][@"date"];
  49. [cell.btnview addTarget:self action:@selector(onview:) forControlEvents:UIControlEventTouchUpInside];
  50. // [cell setModelJson:arr[indexPath.row]];
  51. return cell;
  52. }
  53. -(void) onview:(id)sender
  54. {
  55. UIButton* b = sender;
  56. ScanHomeCell *cell = b.superview.superview;
  57. NSIndexPath* indexPath=[self.table indexPathForCell:cell];
  58. NSString* url = self.newslist[indexPath.row][@"url"];
  59. NSString* title = self.newslist[indexPath.row][@"title"];
  60. WebViewController *ViewController = [[UIStoryboard storyboardWithName:@"wkweb" bundle:nil] instantiateViewControllerWithIdentifier:@"WebViewController"];
  61. ViewController.url = url;
  62. ViewController.title = title;
  63. [self.navigationController pushViewController:ViewController animated:YES];
  64. }
  65. - (IBAction)onCreateOrder:(id)sender {
  66. AppDelegate* appDelegate = (AppDelegate*)UIApplication.sharedApplication.delegate;
  67. MainViewController * mainvc = (MainViewController*)appDelegate.main_vc;
  68. [ActiveViewController Notify:@"ScanOrderListViewController" Message:@"NewOrder"];
  69. [mainvc switchToCart];
  70. }
  71. - (IBAction)onSubmit:(id)sender {
  72. AppDelegate* appDelegate = (AppDelegate*)UIApplication.sharedApplication.delegate;
  73. MainViewController * mainvc = (MainViewController*)appDelegate.main_vc;
  74. [ActiveViewController Notify:@"ScanOrderListViewController" Message:@"ShowSubmit"];
  75. [mainvc switchToOrder];
  76. }
  77. - (IBAction)onUnsubmit:(id)sender {
  78. AppDelegate* appDelegate = (AppDelegate*)UIApplication.sharedApplication.delegate;
  79. MainViewController * mainvc = (MainViewController*)appDelegate.main_vc;
  80. [ActiveViewController Notify:@"ScanOrderListViewController" Message:@"ShowUnSubmit"];
  81. [mainvc switchToOrder];
  82. }
  83. -(void) loadNewsList
  84. {
  85. {
  86. [RADataProvider request_scan_news:^(NSMutableDictionary *result) {
  87. NSMutableDictionary* return_json = result;
  88. // [waitalert dismissViewControllerAnimated:YES completion:^{
  89. // if([[return_json valueForKey:@"result"] intValue]==2)
  90. // {
  91. //
  92. //
  93. // self.newslist = return_json[@"newslist"];
  94. //
  95. // [self.table reloadData];
  96. //// if(self.newslist.count>0)
  97. //// {
  98. ////
  99. //// }
  100. //
  101. // }
  102. // else
  103. // {
  104. // [RAUtils message_alert:[return_json valueForKey:@"err_msg"] title:@"Load Site News" controller:self] ;
  105. // }
  106. // }];
  107. {
  108. if([[return_json valueForKey:@"result"] intValue]==2)
  109. {
  110. self.newslist = return_json[@"newslist"];
  111. [self.table reloadData];
  112. // if(self.newslist.count>0)
  113. // {
  114. //
  115. // }
  116. }
  117. else
  118. {
  119. // [RAUtils message_alert:[return_json valueForKey:@"err_msg"] title:@"Load Site News" controller:self] ;
  120. }
  121. }
  122. }];
  123. }
  124. // __block UIAlertController * waitalert =[RAUtils waiting_alert:self title:@"Loading Site News" completion:^{
  125. // [RADataProvider request_scan_news:^(NSMutableDictionary *result) {
  126. //
  127. // NSMutableDictionary* return_json = result;
  128. //
  129. // [waitalert dismissViewControllerAnimated:YES completion:^{
  130. // if([[return_json valueForKey:@"result"] intValue]==2)
  131. // {
  132. //
  133. //
  134. // self.newslist = return_json[@"newslist"];
  135. //
  136. // [self.table reloadData];
  137. //// if(self.newslist.count>0)
  138. //// {
  139. ////
  140. //// }
  141. //
  142. // }
  143. // else
  144. // {
  145. // [RAUtils message_alert:[return_json valueForKey:@"err_msg"] title:@"Load Site News" controller:self] ;
  146. // }
  147. // }];
  148. //
  149. // }];
  150. // }];
  151. }
  152. @end