Files
featherVoice/QXLive/Mine(音域)/Controller/钱包/QXCornRecordSubViewController.m
2025-11-28 22:43:06 +08:00

122 lines
4.5 KiB
Objective-C

//
// QXCornRecordSubViewController.m
// QXLive
//
// Created by 启星 on 2025/5/26.
//
#import "QXCornRecordSubViewController.h"
#import "QXCornRecordCell.h"
#import "QXWalletDateView.h"
#import "QXMineNetwork.h"
@interface QXCornRecordSubViewController ()<UITableViewDelegate,UITableViewDataSource,QXWalletDateViewDelegate>
@property (nonatomic,strong)UITableView *tableView;
@property (nonatomic,strong)QXWalletDateView *dateView;
@property (nonatomic,strong)NSString* startTime;
@property (nonatomic,strong)NSString* endTime;
@end
@implementation QXCornRecordSubViewController
-(UIView *)listView{
return self.view;
}
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view.
}
-(void)initSubViews{
UIView *dateBg = [[UIView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 48)];
dateBg.backgroundColor = [UIColor whiteColor];
[dateBg addSubview:self.dateView];
[self.view addSubview:dateBg];
[self.view addSubview:self.tableView];
self.page = 1;
}
-(void)getData{
// [self.dataArray addObject:@""];
// [self.dataArray addObject:@""];
// [self.dataArray addObject:@""];
// [self.tableView reloadData];
//
__weak typeof(self) weakSelf = self;
[QXMineNetwork roomCoinOrDiamondDetailWithPage:self.page in_out_type:[NSString stringWithFormat:@"%ld",self.type+1] start_time:self.startTime end_time:self.endTime gift_type:[NSString stringWithFormat:@"%ld",self.waterType+1] successBlock:^(NSArray<QXCoinDetailModel *> * _Nonnull list) {
__strong typeof(weakSelf) strongSelf = weakSelf;
if (!strongSelf) {
NSLog(@"⚠️ self has been deallocated, skipping hide operation");
return;
}
if (strongSelf.page == 1) {
[strongSelf.dataArray removeAllObjects];
}
[strongSelf.dataArray addObjectsFromArray:list];
[strongSelf.tableView reloadData];
if (list.count == 0) {
strongSelf.tableView.mj_footer.state = MJRefreshStateNoMoreData;
}else{
[strongSelf.tableView.mj_footer endRefreshing];
}
[strongSelf.tableView.mj_header endRefreshing];
} failBlock:^(NSError * _Nonnull error, NSString * _Nonnull msg) {
dispatch_async(dispatch_get_main_queue(), ^{
__strong typeof(weakSelf) strongSelf = weakSelf;
if (strongSelf) {
[strongSelf.tableView.mj_header endRefreshing];
[strongSelf.tableView.mj_footer endRefreshing];
}
});
}];
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
return self.dataArray.count;
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
QXCornRecordCell *cell = [QXCornRecordCell cellWithTableView:tableView];
cell.isCoin = self.waterType==0;
cell.model = self.dataArray[indexPath.row];
return cell;
}
#pragma mark - QXWalletDateViewDelegate
-(void)didSelectedStartDate:(NSString *)startDateString startDate:(NSDate *)startDate endDateString:(NSString *)endDateString endDate:(NSDate *)endDate{
QXLOG(@"开始时间-%@ 结束时间-%@",startDateString,endDateString);
self.startTime = startDateString;
self.endTime = endDateString;
self.page = 1;
[self getData];
}
-(QXWalletDateView *)dateView{
if (!_dateView) {
_dateView = [[QXWalletDateView alloc] initWithFrame:CGRectMake(16, 0, SCREEN_WIDTH-32, 38)];
_dateView.delegate = self;
}
return _dateView;
}
-(UITableView *)tableView{
if (!_tableView) {
_tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, self.dateView.bottom+10, SCREEN_WIDTH, SCREEN_HEIGHT - self.dateView.bottom-NavContentHeight-44) style:(UITableViewStylePlain)];
_tableView.dataSource = self;
_tableView.delegate = self;
_tableView.backgroundColor = [UIColor whiteColor];
_tableView.tableFooterView = [UIView new];
_tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
_tableView.estimatedRowHeight = 66;
_tableView.rowHeight = UITableViewAutomaticDimension;
MJWeakSelf
_tableView.mj_header = [MJRefreshNormalHeader headerWithRefreshingBlock:^{
weakSelf.page = 1;
[weakSelf getData];
}];
_tableView.mj_footer = [MJRefreshBackNormalFooter footerWithRefreshingBlock:^{
weakSelf.page++;
[weakSelf getData];
}];
}
return _tableView;
}
@end