// // QXRoomSubsidyViewController.m // IsLandVoice // // Created by 启星 on 2025/4/23. // #import "QXRoomSubsidyViewController.h" #import "QXRoomHistoryViewController.h" #import "QXRoomSubsidyCell.h" #import "QXSubsidyModel.h" #import #import "QXMineNetwork.h" @interface QXRoomSubsidyViewController () @property (nonatomic,strong)UITableView *tableView; @property (nonatomic,strong)QXSubsidyModel *model; @property (nonatomic,strong)WKWebView *webView; @end @implementation QXRoomSubsidyViewController - (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view. self.navigationItem.title = @"房间补贴"; UIButton *rightBtn = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 55, 44)]; [rightBtn setTitle:@"历史记录" forState:(UIControlStateNormal)]; rightBtn.titleLabel.font = [UIFont systemFontOfSize:13]; [rightBtn setTitleColor:[UIColor colorWithHexString:@"#FF8ACC"] forState:(UIControlStateNormal)]; [rightBtn addTarget:self action:@selector(detailAction) forControlEvents:(UIControlEventTouchUpInside)]; self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:rightBtn]; [self.view addSubview:self.tableView]; [self.view addSubview:self.webView]; [self getSubsidy]; } -(void)viewWillAppear:(BOOL)animated{ [super viewWillAppear:animated]; [self.navigationController setNavigationBarHidden:NO animated:YES]; } -(void)detailAction{ QXRoomHistoryViewController *vc = [[QXRoomHistoryViewController alloc] init]; vc.room_id = self.room_id; [self.navigationController pushViewController:vc animated:YES]; } -(void)getSubsidy{ MJWeakSelf [QXMineNetwork roomSubsidyWithRoomId:self.room_id successBlock:^(QXSubsidyModel * _Nonnull model) { weakSelf.model = model; NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@"%@",model.explain]]; NSURLRequest *request = [NSURLRequest requestWithURL:url]; [weakSelf.webView loadRequest:request]; [weakSelf.tableView reloadData]; } failBlock:^(NSError * _Nonnull error, NSString * _Nonnull msg) { showToast(msg); }]; } - (NSInteger)tableView:(nonnull UITableView *)tableView numberOfRowsInSection:(NSInteger)section { if (self.model) { return 2; } return 0; } -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{ QXRoomSubsidyCell *cell = [QXRoomSubsidyCell cellWithTableView:tableView]; if (indexPath.row == 0) { cell.titleLabel.text = @"上周补贴"; cell.model = self.model.lastweek; }else{ cell.titleLabel.text = @"本周补贴"; cell.model = self.model.thisweek; } return cell; } -(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{ return 90; } -(UITableView *)tableView{ if (!_tableView) { _tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, NavContentHeight+18, SCREEN_WIDTH, 190) style:(UITableViewStylePlain)]; [_tableView addRoundedCornersWithRadius:16 byRoundingCorners:(UIRectCornerTopLeft|UIRectCornerTopRight)]; _tableView.dataSource = self; _tableView.delegate = self; _tableView.backgroundColor = [UIColor whiteColor]; _tableView.separatorStyle = UITableViewCellSeparatorStyleNone; _tableView.scrollEnabled = NO; } return _tableView; } -(WKWebView *)webView{ if (!_webView) { _webView = [[WKWebView alloc] initWithFrame:CGRectMake(0, self.tableView.bottom, SCREEN_WIDTH, SCREEN_HEIGHT-self.tableView.bottom)]; } return _webView; } /* #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. } */ @end