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

121 lines
4.2 KiB
Objective-C

//
// QXWithDrawRecordVC.m
// QXLive
//
// Created by 启星 on 2025/7/12.
//
#import "QXWithDrawRecordVC.h"
#import "QXWalletDateView.h"
#import "QXWithDrawRecordCell.h"
#import "QXMineNetwork.h"
@interface QXWithDrawRecordVC ()<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 QXWithDrawRecordVC
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view.
}
-(void)setNavgationItems{
[super setNavgationItems];
self.navigationItem.title = @"提现记录";
}
-(void)viewWillAppear:(BOOL)animated{
[super viewWillAppear:animated];
[self.navigationController setNavigationBarHidden:NO animated:YES];
}
-(void)initSubViews{
UIView *dateBg = [[UIView alloc] initWithFrame:CGRectMake(0, NavContentHeight+8, SCREEN_WIDTH, 48)];
dateBg.backgroundColor = [UIColor clearColor];
[dateBg addSubview:self.dateView];
[self.view addSubview:dateBg];
[self.view addSubview:self.tableView];
self.page = 1;
}
-(void)getData{
__weak typeof(self) weakSelf = self;
[QXMineNetwork walletWithDrawRecordWithPage:self.page start_time:self.startTime end_time:self.endTime SuccessBlock:^(NSArray<QXWithDrawRecordModel *> * _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{
QXWithDrawRecordCell *cell = [QXWithDrawRecordCell cellWithTableView:tableView];
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, NavContentHeight+48, SCREEN_WIDTH, SCREEN_HEIGHT -NavContentHeight-48) style:(UITableViewStylePlain)];
_tableView.dataSource = self;
_tableView.delegate = self;
_tableView.backgroundColor = [UIColor clearColor];
_tableView.tableFooterView = [UIView new];
_tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
_tableView.rowHeight = 180;
MJWeakSelf
_tableView.mj_header = [MJRefreshNormalHeader headerWithRefreshingBlock:^{
weakSelf.page = 1;
[weakSelf getData];
}];
_tableView.mj_footer = [MJRefreshBackNormalFooter footerWithRefreshingBlock:^{
weakSelf.page++;
[weakSelf getData];
}];
}
return _tableView;
}
@end