ScanHomeViewController.m 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  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. DebugLog(@"ScanHomeViewController RELOAD");
  25. [self loadNewsList];
  26. }
  27. /*
  28. #pragma mark - Navigation
  29. // In a storyboard-based application, you will often want to do a little preparation before navigation
  30. - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
  31. // Get the new view controller using [segue destinationViewController].
  32. // Pass the selected object to the new view controller.
  33. }
  34. */
  35. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
  36. return self.newslist.count;
  37. }
  38. - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
  39. return 44;
  40. }
  41. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
  42. {
  43. ScanHomeCell *cell = [tableView dequeueReusableCellWithIdentifier:@"ScanHomeCell"];
  44. if (!cell) {
  45. cell = [[ScanHomeCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"ScanHomeCell"];
  46. }
  47. // NSArray* arr = self.newslist;
  48. cell.labeltitle.text = self.newslist[indexPath.row][@"title"];
  49. cell.labeldate.text = self.newslist[indexPath.row][@"date"];
  50. [cell.btnview addTarget:self action:@selector(onview:) forControlEvents:UIControlEventTouchUpInside];
  51. // [cell setModelJson:arr[indexPath.row]];
  52. return cell;
  53. }
  54. -(void) onview:(id)sender
  55. {
  56. UIButton* b = sender;
  57. ScanHomeCell *cell = (ScanHomeCell*)b.superview.superview;
  58. NSIndexPath* indexPath=[self.table indexPathForCell:cell];
  59. NSString* url = self.newslist[indexPath.row][@"url"];
  60. NSString* title = self.newslist[indexPath.row][@"title"];
  61. WebViewController *ViewController = [[UIStoryboard storyboardWithName:@"wkweb" bundle:nil] instantiateViewControllerWithIdentifier:@"WebViewController"];
  62. ViewController.url = url;
  63. ViewController.title = title;
  64. [self.navigationController pushViewController:ViewController animated:YES];
  65. }
  66. - (IBAction)onCreateOrder:(id)sender {
  67. AppDelegate* appDelegate = (AppDelegate*)UIApplication.sharedApplication.delegate;
  68. MainViewController * mainvc = (MainViewController*)appDelegate.main_vc;
  69. [ActiveViewController Notify:@"ScanOrderListViewController" Message:@"NewOrder"];
  70. [mainvc switchToCart];
  71. }
  72. - (IBAction)onSubmit:(id)sender {
  73. AppDelegate* appDelegate = (AppDelegate*)UIApplication.sharedApplication.delegate;
  74. MainViewController * mainvc = (MainViewController*)appDelegate.main_vc;
  75. [ActiveViewController Notify:@"ScanOrderListViewController" Message:@"ShowSubmit"];
  76. [mainvc switchToOrder];
  77. }
  78. - (IBAction)onUnsubmit:(id)sender {
  79. AppDelegate* appDelegate = (AppDelegate*)UIApplication.sharedApplication.delegate;
  80. MainViewController * mainvc = (MainViewController*)appDelegate.main_vc;
  81. [ActiveViewController Notify:@"ScanOrderListViewController" Message:@"ShowUnSubmit"];
  82. [mainvc switchToOrder];
  83. }
  84. -(void) loadNewsList
  85. {
  86. {
  87. [RADataProvider request_scan_news:^(NSMutableDictionary *result) {
  88. NSMutableDictionary* return_json = result;
  89. {
  90. if([[return_json valueForKey:@"result"] intValue]==2)
  91. {
  92. self.newslist = return_json[@"newslist"];
  93. [self.table reloadData];
  94. // if(self.newslist.count>0)
  95. // {
  96. //
  97. // }
  98. }
  99. else
  100. {
  101. self.newslist = [NSArray new];
  102. [self.table reloadData];
  103. }
  104. }
  105. }];
  106. }
  107. }
  108. @end