Files
featherVoice/QXLive/Mine(音域)/Controller/每日任务/QXTaskGiftRecordVC.m
2025-12-04 14:11:00 +08:00

132 lines
5.2 KiB
Objective-C

//
// QXTaskGiftRecordVC.m
// QXLive
//
// Created by 启星 on 2025/7/11.
//
#import "QXTaskGiftRecordVC.h"
#import "QXMineNetwork.h"
#import "QXTaskGiftRecordCell.h"
@interface QXTaskGiftRecordVC ()<UITableViewDataSource,UITableViewDelegate>
@property (nonatomic,strong)UITableView *tableView;
@property (nonatomic,strong)UIView *headerView;
@end
@implementation QXTaskGiftRecordVC
- (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)viewWillAppear:(BOOL)animated{
[super viewWillAppear:animated];
[self.navigationController setNavigationBarHidden:NO animated:YES];
}
-(void)getHistorySubsidy{
MJWeakSelf
[QXMineNetwork dayTaskGiftBoxRecordSuccessBlock:^(NSArray<QXTaskGiftBoxRecordModel *> * _Nonnull list) {
if (weakSelf.page == 1) {
[weakSelf.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{
QXTaskGiftRecordCell *cell = [QXTaskGiftRecordCell 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(16, 0, 145, 44)];
timeLabel.text = @"时间";
timeLabel.textColor = [UIColor colorWithHexString:@"#333333"];
timeLabel.font = [UIFont boldSystemFontOfSize:16];
timeLabel.textAlignment = NSTextAlignmentLeft;
[_headerView addSubview:timeLabel];
UILabel *statusLabel = [[UILabel alloc] initWithFrame:CGRectMake(timeLabel.right+15, 0, 75, 44)];
statusLabel.text = @"礼盒名称";
statusLabel.textColor = [UIColor colorWithHexString:@"#333333"];
statusLabel.font = [UIFont boldSystemFontOfSize:16];
statusLabel.textAlignment = NSTextAlignmentLeft;
[_headerView addSubview:statusLabel];
UILabel *subsidyLabel = [[UILabel alloc] initWithFrame:CGRectMake(statusLabel.right+15, 0, SCREEN_WIDTH-statusLabel.right-15-16, 44)];
subsidyLabel.text = @"获取";
subsidyLabel.textColor = [UIColor colorWithHexString:@"#333333"];
subsidyLabel.font = [UIFont boldSystemFontOfSize:16];
subsidyLabel.textAlignment = NSTextAlignmentLeft;
[_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