// // LMTixianRecordViewController.m // SweetParty // // Created by Xmac on 2024/9/25. // #import "LMTixianRecordViewController.h" #import "LMTixianRecordTableViewCell.h" #import "NSString+category.h" #import "BRPickerView.h" #import "LMTixianRecordDetailViewController.h" @interface LMTixianRecordViewController () @property (weak, nonatomic) IBOutlet UITableView *recordTabelView; @property (weak, nonatomic) IBOutlet UIButton *startTimeButton; @property (weak, nonatomic) IBOutlet UIButton *endTimeButton; @property (weak, nonatomic) IBOutlet UIButton *queryButton; @property (weak, nonatomic) IBOutlet UILabel *allMoneyLabel; @property (weak, nonatomic) IBOutlet NSLayoutConstraint *TopLayout; @property (nonatomic, strong) NSMutableArray *dataArr; @property (nonatomic, assign) NSInteger page; @property (nonatomic, strong) NSString *startTime; @property (nonatomic, strong) NSString *endTime; @end @implementation LMTixianRecordViewController - (void)viewDidLoad { [super viewDidLoad]; [self showNaviBarWithTitle:@"提现记录"]; self.TopLayout.constant = yb_NavigationBar_H+10; [self.recordTabelView registerNib:[UINib nibWithNibName:@"LMTixianRecordTableViewCell" bundle:nil] forCellReuseIdentifier:LMTixianRecordTableViewCellID]; self.page = 1; NSString *currentTime = [NSString getCurrentTime:@"YYYY-MM-dd"]; self.startTime = @"2024-1-1"; self.endTime = currentTime; [self.endTimeButton setTitle:currentTime forState:(UIControlStateNormal)]; [self requestRecordListWithStartTime:self.startTime endTime:self.endTime]; self.queryButton.backgroundColor = [UIColor bm_colorGradientChangeWithSize:CGSizeMake(APPW-115*2-15*2-20-14*2, 40) direction:(FXGradientChangeDirectionHorizontal) startColor:mainLightColor endColor:mainDeepColor]; } - (IBAction)queryButtonClick:(UIButton *)sender { [self requestRecordListWithStartTime:self.startTime endTime:self.endTime]; } - (IBAction)startTimeButtonClick:(UIButton *)sender { BRDatePickerView *datePickerView = [[BRDatePickerView alloc] init]; datePickerView.pickerMode = BRDatePickerModeYMD; datePickerView.minDate = [NSDate br_setYear:2024 month:1 day:1]; datePickerView.maxDate = [NSDate date]; datePickerView.selectDate = [NSDate date]; datePickerView.showUnitType = BRShowUnitTypeNone; WEAK_SELF; datePickerView.resultBlock = ^(NSDate *selectDate, NSString *selectValue) { weakSelf.startTime = selectValue; [sender setTitle:selectValue forState:(UIControlStateNormal)]; }; datePickerView.pickerStyle = [self customPickerViewUI]; [datePickerView show]; } - (IBAction)endTimeButtonClick:(UIButton *)sender { BRDatePickerView *datePickerView = [[BRDatePickerView alloc] init]; datePickerView.pickerMode = BRDatePickerModeYMD; datePickerView.minDate = [NSDate br_setYear:2024 month:1 day:1]; datePickerView.maxDate = [NSDate date]; datePickerView.selectDate = [NSDate date]; datePickerView.showUnitType = BRShowUnitTypeNone; WEAK_SELF; datePickerView.resultBlock = ^(NSDate *selectDate, NSString *selectValue) { weakSelf.endTime = selectValue; [sender setTitle:selectValue forState:(UIControlStateNormal)]; }; datePickerView.pickerStyle = [self customPickerViewUI]; [datePickerView show]; } - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { return self.dataArr.count; } - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { LMTixianRecordTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:LMTixianRecordTableViewCellID forIndexPath:indexPath]; cell.model = self.dataArr[indexPath.row]; return cell; } - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { LMTixianRecordDetailViewController *vc = [[LMTixianRecordDetailViewController alloc] init]; LMTixianRecordListModel *model = self.dataArr[indexPath.row]; vc.wid = model.wid; [vc pushSelf]; } - (void)requestRecordListWithStartTime:(NSString *)startTime endTime:(NSString *)endTime { NSDictionary *params = @{@"start":C_string(startTime), @"end":endTime, @"page":@(self.page),@"page_limit":@"20"}; [[AFNetworkRequset shared] postRequestWithParams:params Path:@"api/user/get_user_withdrawal_detail" Loading:YES Hud:YES Success:^(id _Nonnull responseDic) { if (self.page == 1){ [self.dataArr removeAllObjects]; } NSDictionary *data = [responseDic safeDictionaryForKey:@"data"]; NSArray *array = [LMTixianRecordListModel mj_objectArrayWithKeyValuesArray:[data safeArrayForKey:@"detail"]]; self.allMoneyLabel.text = [NSString stringWithFormat:@"%@",[data safeStringForKey:@"all"]]; [self.dataArr addObjectsFromArray:array]; [self.recordTabelView reloadData]; } Failure:^(id _Nonnull errorData) { }]; } - (NSMutableArray *)dataArr { if (!_dataArr){ _dataArr = [NSMutableArray array]; } return _dataArr; } - (BRPickerStyle *)customPickerViewUI { BRPickerStyle *style = [[BRPickerStyle alloc] init]; style.selectedColor = [UIColor whiteColor]; style.topCornerRadius = 10; style.hiddenShadowLine = YES; style.hiddenTitleLine = YES; style.hiddenTitleLabel = YES; style.titleBarColor = HEXCOLOR(0xF5F7F7); style.cancelTextColor = HEXCOLOR(0x999999); style.cancelTextFont = [UIFont boldSystemFontOfSize:16]; style.cancelBtnFrame = CGRectMake(0, 0, 60, 50); style.cancelBtnTitle = @"取消"; style.doneTextColor = mainDeepColor; style.doneTextFont = [UIFont boldSystemFontOfSize:16]; style.doneBtnFrame = CGRectMake(SCREEN_WIDTH-60, 0, 60, 50); style.doneBtnTitle = @"确定"; style.separatorColor = [UIColor clearColor]; style.pickerTextColor = HEXCOLOR(0x333333); style.pickerTextFont = [UIFont systemFontOfSize:16]; style.pickerColor = HEXCOLOR(0xF5F7F7);; style.rowHeight = 44; return style; } @end