ScanHomeViewController.m 5.7 KB

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