| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194 |
- //
- // ScanHomeViewController.m
- // HMLG Scan Order
- //
- // Created by Rui Zhang on 5/12/22.
- // Copyright © 2022 United Software Applications, Inc. All rights reserved.
- //
- #import "ScanHomeViewController.h"
- #import "ScanHomeCell.h"
- #import "AppDelegate.h"
- #import "MainViewController.h"
- #import "WebViewController.h"
- @interface ScanHomeViewController ()
- @end
- @implementation ScanHomeViewController
- - (void)viewDidLoad {
- [super viewDidLoad];
-
- self.table.layer.borderColor = [UIColor darkGrayColor].CGColor;
- self.table.layer.borderWidth = 1.0;
- [self loadNewsList];
- // Do any additional setup after loading the view.
- }
- /*
- #pragma mark - Navigation
- // In a storyboard-based application, you will often want to do a little preparation before navigation
- - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
- // Get the new view controller using [segue destinationViewController].
- // Pass the selected object to the new view controller.
- }
- */
- - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
-
- return self.newslist.count;
-
- }
- - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
- return 44;
- }
- - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
- {
-
-
-
- ScanHomeCell *cell = [tableView dequeueReusableCellWithIdentifier:@"ScanHomeCell"];
- if (!cell) {
- cell = [[ScanHomeCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"ScanHomeCell"];
- }
- // NSArray* arr = self.newslist;
-
- cell.labeltitle.text = self.newslist[indexPath.row][@"title"];
- cell.labeldate.text = self.newslist[indexPath.row][@"date"];
-
- [cell.btnview addTarget:self action:@selector(onview:) forControlEvents:UIControlEventTouchUpInside];
-
- // [cell setModelJson:arr[indexPath.row]];
-
-
- return cell;
-
- }
- -(void) onview:(id)sender
- {
- UIButton* b = sender;
- ScanHomeCell *cell = b.superview.superview;
-
- NSIndexPath* indexPath=[self.table indexPathForCell:cell];
-
- NSString* url = self.newslist[indexPath.row][@"url"];
- NSString* title = self.newslist[indexPath.row][@"title"];
-
- WebViewController *ViewController = [[UIStoryboard storyboardWithName:@"wkweb" bundle:nil] instantiateViewControllerWithIdentifier:@"WebViewController"];
- ViewController.url = url;
- ViewController.title = title;
-
-
- [self.navigationController pushViewController:ViewController animated:YES];
-
- }
- - (IBAction)onCreateOrder:(id)sender {
- AppDelegate* appDelegate = (AppDelegate*)UIApplication.sharedApplication.delegate;
- MainViewController * mainvc = (MainViewController*)appDelegate.main_vc;
-
- [ActiveViewController Notify:@"ScanOrderListViewController" Message:@"NewOrder"];
- [mainvc switchToOrder];
- }
- - (IBAction)onSubmit:(id)sender {
- AppDelegate* appDelegate = (AppDelegate*)UIApplication.sharedApplication.delegate;
- MainViewController * mainvc = (MainViewController*)appDelegate.main_vc;
-
- [ActiveViewController Notify:@"ScanOrderListViewController" Message:@"ShowSubmit"];
- [mainvc switchToOrder];
- }
- - (IBAction)onUnsubmit:(id)sender {
- AppDelegate* appDelegate = (AppDelegate*)UIApplication.sharedApplication.delegate;
- MainViewController * mainvc = (MainViewController*)appDelegate.main_vc;
- [ActiveViewController Notify:@"ScanOrderListViewController" Message:@"ShowUnSubmit"];
- [mainvc switchToOrder];
- }
- -(void) loadNewsList
- {
- {
- [RADataProvider request_scan_news:^(NSMutableDictionary *result) {
-
- NSMutableDictionary* return_json = result;
-
- // [waitalert dismissViewControllerAnimated:YES completion:^{
- // if([[return_json valueForKey:@"result"] intValue]==2)
- // {
- //
- //
- // self.newslist = return_json[@"newslist"];
- //
- // [self.table reloadData];
- //// if(self.newslist.count>0)
- //// {
- ////
- //// }
- //
- // }
- // else
- // {
- // [RAUtils message_alert:[return_json valueForKey:@"err_msg"] title:@"Load Site News" controller:self] ;
- // }
- // }];
- {
- if([[return_json valueForKey:@"result"] intValue]==2)
- {
-
- self.newslist = return_json[@"newslist"];
-
- [self.table reloadData];
- // if(self.newslist.count>0)
- // {
- //
- // }
- }
- else
- {
- // [RAUtils message_alert:[return_json valueForKey:@"err_msg"] title:@"Load Site News" controller:self] ;
- }
- }
-
- }];
- }
-
-
- // __block UIAlertController * waitalert =[RAUtils waiting_alert:self title:@"Loading Site News" completion:^{
- // [RADataProvider request_scan_news:^(NSMutableDictionary *result) {
- //
- // NSMutableDictionary* return_json = result;
- //
- // [waitalert dismissViewControllerAnimated:YES completion:^{
- // if([[return_json valueForKey:@"result"] intValue]==2)
- // {
- //
- //
- // self.newslist = return_json[@"newslist"];
- //
- // [self.table reloadData];
- //// if(self.newslist.count>0)
- //// {
- ////
- //// }
- //
- // }
- // else
- // {
- // [RAUtils message_alert:[return_json valueForKey:@"err_msg"] title:@"Load Site News" controller:self] ;
- // }
- // }];
- //
- // }];
- // }];
-
- }
- @end
|