Files
my_yuyin/QXLive/Mine(音域)/Controller/我的房间/QXRoomHistoryViewController.m
2025-09-22 18:48:29 +08:00

129 lines
5.2 KiB
Objective-C

//
// QXRoomHistoryViewController.m
// IsLandVoice
//
// Created by 启星 on 2025/4/23.
//
#import "QXRoomHistoryViewController.h"
#import "QXSubsidyModel.h"
#import "QXRoomSubsidyHistoryCell.h"
#import "QXMineNetwork.h"
@interface QXRoomHistoryViewController ()<UITableViewDelegate,UITableViewDataSource>
@property (nonatomic,strong)UITableView *tableView;
@property (nonatomic,strong)UIView *headerView;
@end
@implementation QXRoomHistoryViewController
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view.
self.navigationItem.title = @"历史记录";
[self.view addSubview:self.tableView];
[self.view addSubview:self.headerView];
self.page = 1;
[self getHistorySubsidy];
}
-(void)getHistorySubsidy{
MJWeakSelf
[QXMineNetwork roomSubsidyHisoryWithWithRoomId:self.room_id page:self.page successBlock:^(NSArray<QXSubsidyHistoryModel *> * _Nonnull list) {
if (self.page == 1) {
[self.dataArray removeAllObjects];
}
if (list.count == 0) {
weakSelf.tableView.mj_footer.state = MJRefreshStateNoMoreData;
}else{
[weakSelf.tableView.mj_footer endRefreshing];
}
[weakSelf.dataArray addObjectsFromArray:list];
[weakSelf.tableView reloadData];
[weakSelf.tableView.mj_header endRefreshing];
} failBlock:^(NSError * _Nonnull error, NSString * _Nonnull msg) {
[weakSelf.tableView.mj_footer endRefreshing];
[weakSelf.tableView.mj_header endRefreshing];
showToast(msg)
}];
}
- (NSInteger)tableView:(nonnull UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return self.dataArray.count;
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
QXRoomSubsidyHistoryCell *cell = [QXRoomSubsidyHistoryCell cellWithTableView:tableView];
cell.model = self.dataArray[indexPath.row];
return cell;
}
//-(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
// return self.headerView;
//}
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
return 44;
}
//-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
// return 44;
//}
-(UITableView *)tableView{
if (!_tableView) {
_tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, self.headerView.bottom, SCREEN_WIDTH, SCREEN_HEIGHT-self.headerView.bottom) style:(UITableViewStylePlain)];
_tableView.dataSource = self;
_tableView.delegate = self;
_tableView.backgroundColor = [UIColor whiteColor];
_tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
if (@available(iOS 15.0, *)) {
_tableView.sectionHeaderTopPadding = 0;
} else {
// Fallback on earlier versions
}
MJWeakSelf
_tableView.mj_header = [MJRefreshNormalHeader headerWithRefreshingBlock:^{
weakSelf.page = 1;
[weakSelf getHistorySubsidy];
}];
_tableView.mj_footer = [MJRefreshBackNormalFooter footerWithRefreshingBlock:^{
weakSelf.page++;
[weakSelf getHistorySubsidy];
}];
}
return _tableView;
}
-(UIView *)headerView{
if (!_headerView) {
_headerView = [[UIView alloc] initWithFrame:CGRectMake(0,NavContentHeight+18 , SCREEN_WIDTH, 44)];
[_headerView addRoundedCornersWithRadius:16 byRoundingCorners:(UIRectCornerTopLeft|UIRectCornerTopRight)];
_headerView.backgroundColor = [UIColor whiteColor];
UILabel *timeLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 145, 44)];
timeLabel.text = @"时间";
timeLabel.textColor = [UIColor colorWithHexString:@"#333333"];
timeLabel.font = [UIFont boldSystemFontOfSize:16];
timeLabel.textAlignment = NSTextAlignmentCenter;
[_headerView addSubview:timeLabel];
UILabel *statusLabel = [[UILabel alloc] initWithFrame:CGRectMake(SCREEN_WIDTH-16-50, 0, 50, 44)];
statusLabel.text = @"状态";
statusLabel.textColor = [UIColor colorWithHexString:@"#333333"];
statusLabel.font = [UIFont boldSystemFontOfSize:16];
statusLabel.textAlignment = NSTextAlignmentCenter;
[_headerView addSubview:statusLabel];
UILabel *subsidyLabel = [[UILabel alloc] initWithFrame:CGRectMake(statusLabel.left-75, 0, 65, 44)];
subsidyLabel.text = @"获得补贴";
subsidyLabel.textColor = [UIColor colorWithHexString:@"#333333"];
subsidyLabel.font = [UIFont boldSystemFontOfSize:16];
subsidyLabel.textAlignment = NSTextAlignmentCenter;
[_headerView addSubview:subsidyLabel];
UILabel *allWaterLabel = [[UILabel alloc] initWithFrame:CGRectMake(timeLabel.right+10, 0, subsidyLabel.left-20-timeLabel.right, 44)];
allWaterLabel.text = @"累计流水";
allWaterLabel.textColor = [UIColor colorWithHexString:@"#333333"];
allWaterLabel.font = [UIFont boldSystemFontOfSize:16];
allWaterLabel.textAlignment = NSTextAlignmentCenter;
[_headerView addSubview:allWaterLabel];
}
return _headerView;
}
@end