123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279 |
- //
- // YOUPAILCBillDetailVC.m
- // LiveChat
- //
- // Created by 张灿 on 2018/9/17.
- // Copyright © 2018年 caicai. All rights reserved.
- //
- #import "YOUPAILCBillDetailVC.h"
- #import "YOUPAILCBillDetailCell.h"
- #import "PGDatePickManager.h"
- #import "UIViewController+TFPresent.h"
- @interface YOUPAILCBillDetailVC ()<UITableViewDelegate,UITableViewDataSource,PGDatePickerDelegate>
- @property(nonatomic,assign)NSInteger youpaipcurrentPage;
- @property(nonatomic,assign)NSInteger youpaiptotalPage;
- @property(nonatomic,strong)NSMutableArray* youpaipbillArray;
- @property(nonatomic,strong)UIButton *youpaipdateBtn;
- @property(nonatomic,assign)NSInteger youpaipyear;
- @property(nonatomic,assign) NSInteger youpaipmonth;
- @property(nonatomic,strong)NSString *youpaipdate;
- @end
- @implementation YOUPAILCBillDetailVC
- - (void)youpaifsetupTableView{
- self.tableView.frame = CGRectMake(0, NavBarHeight, KScreenWidth, KScreenHeight-NavBarHeight);
- self.tableView.showsVerticalScrollIndicator = NO;
- self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
- self.tableView.estimatedRowHeight = 56;
- self.tableView.delegate = self;
- self.tableView.dataSource= self;
- self.tableView.backgroundColor = LCBkgColor;
- self.isAllowScroll = YES;
- [self.view addSubview:self.tableView];
-
-
- self.tableView.mj_header = [MJRefreshNormalHeader headerWithRefreshingTarget:self refreshingAction:@selector(youpaifloadNewData)];
- MJRefreshAutoNormalFooter* normalFooter = [MJRefreshAutoNormalFooter footerWithRefreshingTarget:self refreshingAction:@selector(youpaifloadMoreData)];
- [normalFooter setTitle:@"正在加载..." forState:(MJRefreshStateRefreshing)];
- [normalFooter setTitle:@"" forState:(MJRefreshStateNoMoreData)];
- self.tableView.mj_footer = normalFooter;
- self.tableView.mj_footer.automaticallyHidden = YES;
- // self.tableView.tableHeaderView = [self tableHeaderView];
-
- }
- -(UIView *)youpaiftableHeaderView
- {
- UIView *tableHeaderView = [[UIView alloc] initWithFrame:CGRectMake(0,0,KScreenWidth, 44)];
- tableHeaderView.backgroundColor = [UIColor whiteColor];
- UIButton *dateBtn = [UIButton buttonWithType:UIButtonTypeCustom];
- dateBtn.frame = CGRectMake(16, 12,85, 20);
- [dateBtn setTitle:[NSString stringWithFormat:@"%ld年%ld月",_youpaipyear,_youpaipmonth] forState:0];
- dateBtn.titleLabel.font = LCFont(14);
- [dateBtn setTitleColor:LCWhiteColor forState:0];
- [dateBtn setBackgroundColor:HexColorFromRGB(0xA7A9FD)];
- [dateBtn setImage:[UIImage imageNamed:@""] forState:0];
- dateBtn.layer.cornerRadius = 10;
- dateBtn.layer.masksToBounds = YES;
- [dateBtn setImage:[UIImage imageNamed:@"vqu_images_down"] forState:0];
- dateBtn.titleEdgeInsets = UIEdgeInsetsMake(0, -dateBtn.imageView.frame.size.width - dateBtn.frame.size.width + dateBtn.titleLabel.frame.size.width+15, 0, 0);
- dateBtn.imageEdgeInsets = UIEdgeInsetsMake(0, 0, 0, -dateBtn.titleLabel.frame.size.width - dateBtn.frame.size.width + dateBtn.imageView.frame.size.width+15);
- [dateBtn addTarget:self action:@selector(youpaifselectDateAction) forControlEvents:UIControlEventTouchUpInside];
- self.youpaipdateBtn = dateBtn;
-
- [tableHeaderView addSubview:dateBtn];
-
-
-
-
- UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(KScreenWidth/2.0, 16,KScreenWidth/2.0-16, 12)];
- label.text = @"仅展示当月账单";
- label.textColor = HexColorFromRGB(0x999999);
- label.textAlignment = NSTextAlignmentRight;
- label.font = LCFont(10);
- [tableHeaderView addSubview:label];
- return tableHeaderView;
-
- }
- -(void)youpaifselectDateAction{
-
- PGDatePickManager *datePickManager = [[PGDatePickManager alloc]init];
- datePickManager.isShadeBackground = true;
- datePickManager.cancelButtonFont = LCFont(15);
- datePickManager.confirmButtonFont = LCFont(15);
- datePickManager.cancelButtonTextColor = HexColorFromRGB(0x9F9DA5);
- datePickManager.confirmButtonTextColor = [UIColor whiteColor];
- datePickManager.headerViewBackgroundColor = LCBkgColor;
- datePickManager.headerHeight = 50;
-
- PGDatePicker *datePicker = datePickManager.datePicker;
- datePicker.backgroundColor = LCBkgColor;
- datePicker.rowHeight = 35;
- datePicker.middleTextColor = [UIColor whiteColor];
- datePicker.textColorOfSelectedRow = [UIColor whiteColor];
- datePicker.textColorOfOtherRow = [[UIColor whiteColor] colorWithAlphaComponent:0.2f];
- datePicker.textFontOfSelectedRow = LCFont(17);
- datePicker.textFontOfOtherRow = LCFont(17);
- datePicker.lineBackgroundColor = [UIColor clearColor];
-
-
- NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
- NSDate* currentDate = [NSDate date];
- [dateFormatter setDateFormat:@"yyyy"];
- NSString* currentYear=[dateFormatter stringFromDate:currentDate] ;
- [dateFormatter setDateFormat:@"MM"];
- NSString* currentMonth=[dateFormatter stringFromDate:currentDate];
-
- NSString* maxDateStr = [NSString stringWithFormat:@"%zd-%@",[currentYear integerValue],currentMonth];
- NSString* minDateStr = [NSString stringWithFormat:@"%zd-%@",[currentYear integerValue]-50,currentMonth];
- [dateFormatter setDateFormat:@"yyyy-MM"];
- NSString* defaultDateStr;
- NSDate *date = [dateFormatter dateFromString:defaultDateStr];//上次设置的日期
-
- [datePicker setDate:date];
- datePicker.maximumDate = [dateFormatter dateFromString:maxDateStr];
- datePicker.minimumDate = [dateFormatter dateFromString:minDateStr];
- datePicker.delegate = self;
- datePicker.datePickerType = PGDatePickerTypeLine;
- datePicker.isHiddenMiddleText = false;
- datePicker.datePickerMode = PGDatePickerModeYearAndMonth;
- [self presentViewController:datePickManager animated:false completion:nil];
-
-
- }
- - (void)datePicker:(PGDatePicker *)datePicker didSelectDate:(NSDateComponents *)dateComponents{
- NSLog(@"dateComponents = %@", dateComponents);
- NSInteger year=[dateComponents year];
- NSInteger month=[dateComponents month];
- NSString* date = [NSString stringWithFormat:@"%ld年%ld月",year,month];
- [self.youpaipdateBtn setTitle:date forState:0];
- self.youpaipdate = [NSString stringWithFormat:@"%ld-%ld",year,month];
- [self.tableView.mj_header beginRefreshing];
-
- }
-
- - (void)youpaifloadNewData{
- self.tableView.mj_footer.hidden = YES;
- [self.tableView.mj_footer endRefreshing];//先结束上拉,假如有的话
- self.youpaipcurrentPage = 1;
- [LCHttpHelper requestWithURLString:WalletBill parameters:@{@"type":@(self.youpaiptype),@"cate_id":@(self.youpaipcate_id),@"page":@(self.youpaipcurrentPage),@"date":self.youpaipdate} needToken:YES type:(HttpRequestTypePost) success:^(id responseObject) {
- NSDictionary* dict = (NSDictionary*)responseObject;
- NSInteger code = [[dict objectForKey:@"code"] integerValue];
- if (code==0) {//成功
- [self.youpaipbillArray removeAllObjects];
- NSArray* array = [[dict objectForKey:@"data"]objectForKey:@"list"];
- NSMutableArray* modelArray = [YOUPAILCBillDetailModel mj_objectArrayWithKeyValuesArray:array];
- [self.youpaipbillArray addObjectsFromArray:modelArray];
- self.youpaiptotalPage = [[[dict objectForKey:@"data"]objectForKey:@"total_page"]integerValue];
- self.youpaipcurrentPage = [[[dict objectForKey:@"data"]objectForKey:@"page"]integerValue];
- [self.tableView reloadData];
- if (self.youpaipcurrentPage>=self.youpaiptotalPage) {
- [self.tableView.mj_footer endRefreshingWithNoMoreData];
- self.tableView.mj_footer.hidden = YES;
- }
- if (self.youpaipbillArray.count != 0) {
- [self.tableView lz_hideEmptyView];
- }else{
- [self.tableView lz_showEmptyViewWithImage:[UIImage imageNamed:@"vqu_images_not_recharge_data"] content:@"暂无充值记录"];
- }
- [self.tableView.mj_header endRefreshing];
- }else{
- [self.tableView.mj_header endRefreshing];
- }
- } failure:^(NSError *error) {
- [self.tableView.mj_header endRefreshing];
- }];
- }
- - (void)youpaifloadMoreData{
- [self.tableView.mj_header endRefreshing];
- self.tableView.mj_footer.hidden = YES;
- [self.tableView.mj_footer endRefreshing];
- self.youpaipcurrentPage+=1;
- [LCHttpHelper requestWithURLString:WalletBill parameters:@{@"type":@(self.youpaiptype),@"cate_id":@(self.youpaipcate_id),@"page":@(self.youpaipcurrentPage),@"date":self.youpaipdate} needToken:YES type:(HttpRequestTypePost) success:^(id responseObject) {
- NSDictionary* dict = (NSDictionary*)responseObject;
- NSInteger code = [[dict objectForKey:@"code"] integerValue];
- if (code==0) {//成功
- NSArray* array = [[dict objectForKey:@"data"]objectForKey:@"list"];
- NSMutableArray* modelArray = [YOUPAILCBillDetailModel mj_objectArrayWithKeyValuesArray:array];
- [self.youpaipbillArray addObjectsFromArray:modelArray];
- self.youpaiptotalPage = [[[dict objectForKey:@"data"]objectForKey:@"total_page"]integerValue];
- self.youpaipcurrentPage = [[[dict objectForKey:@"data"]objectForKey:@"page"]integerValue];
- [self.tableView reloadData];
- if (self.youpaipcurrentPage>=self.youpaiptotalPage) {
- [self.tableView.mj_footer endRefreshingWithNoMoreData];
- self.tableView.mj_footer.hidden = YES;
- }
- [self.tableView.mj_header endRefreshing];
- }else{
- [self.tableView.mj_header endRefreshing];
- }
- } failure:^(NSError *error) {
- [self.tableView.mj_header endRefreshing];
- }];
- }
- - (void)viewDidLoad {
- [super viewDidLoad];
- NSDate *date = [NSDate date];
- NSCalendar *calendar = [[NSCalendar alloc] initWithCalendarIdentifier:NSCalendarIdentifierGregorian];
- NSDateComponents *comps = [[NSDateComponents alloc] init];
- NSInteger unitFlags = NSCalendarUnitYear |NSCalendarUnitMonth;
- comps = [calendar components:unitFlags fromDate:date];
- //星期 注意星期是从周日开始计算
- //年
- self.youpaipyear=[comps year];
- //月
- self.youpaipmonth = [comps month];
- NSLog(@"%ld----%ld",_youpaipyear,_youpaipmonth);
- self.youpaipdate = [NSString stringWithFormat:@"%ld-%ld",self.youpaipyear,self.youpaipmonth];
- if (![LCSaveData getIsspecial]&& self.youpaipnomore==NO) {
- // self.navigationItem.rightBarButtonItem = [UIBarButtonItem itemWithTarget:self action:@selector(youpaifmoreSelect) image:[UIImage imageNamed:@"vqu_images_nav_more_black"]];
-
- self.navigationItem.rightBarButtonItem = [UIBarButtonItem itemWithTarget:self action:@selector(youpaifmoreSelect) title:@"筛选" font:[UIFont systemFontOfSize:16] titleColor:DecColorFromRGB(51,51,51) highlightedColor:DecColorFromRGB(51,51,51) titleEdgeInsets:UIEdgeInsetsZero];
- }else{
- self.navigationItem.rightBarButtonItem = [UIBarButtonItem itemWithTarget:self action:@selector(selectDateAction) title:@"筛选" font:LCFont14 titleColor:HexColorFromRGB(0xffffff) highlightedColor:HexColorFromRGB(0xffffff) titleEdgeInsets:UIEdgeInsetsZero];
- }
- self.youpaipbillArray = [NSMutableArray array];
- [self youpaifsetupTableView];
- [self youpaifupdateCate];
- }
- #pragma mark - tableView代理
- - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
- return 99;
- }
- - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
- return self.youpaipbillArray.count;
- }
- - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
- YOUPAILCBillDetailCell* cell = [[YOUPAILCBillDetailCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"YOUPAILCBillDetailCell"];
- YOUPAILCBillDetailModel* model = self.youpaipbillArray[indexPath.row];
- cell.youpaipbillModel = model;
- // [cell bottomLineforViewHeight:68];
- return cell;
- }
- - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
-
- }
- - (void)youpaifupdateCate{
- [self.tableView.mj_header beginRefreshing];
- NSArray* titleArray = @[@"全部",@"充值",LCStr(word20),@"视频",@"礼物",@"系统",@"兑换",@"私信",LCStr(word21),@"守护",@"公会"];//提现 系统调账
- if (self.youpaipcate_id==0) {
- self.title = LCStr(word22);//我的账单
- }else if (self.youpaipcate_id==1) {
- if (self.youpaiptype==1) {
- self.title = LCStr(word23);//充值余额明细
- }else if (self.youpaiptype==3){
- self.title =LCStr(word5);// @"收支明细";
- }else{
- self.title = LCStr(word24);//支付明细
- }
- }else{
- self.title = [NSString stringWithFormat:@"%@明细",titleArray[self.youpaipcate_id]];
- }
- }
- - (void)youpaifmoreSelect{
- NSArray* titleArray =@[@"全部",@"充值",LCStr(word20),@"视频",@"礼物",@"系统",@"兑换",@"私信",LCStr(word21),@"守护",@"公会"];//提现 系统调账
- NSArray* typeArray = @[@0,@1,@2,@3,@4,@5,@6,@7,@8,@9,@10];
- NSMutableArray* actionArray = [NSMutableArray array];
- for (int i =0; i<titleArray.count; i++) {
- ZCAlertActionBtn* actionBtn = [ZCAlertActionBtn actionWithTitle:titleArray[i] type:[typeArray[i] integerValue] andblock:^(NSInteger type) {
- self.youpaipcate_id = type;
- [self youpaifupdateCate];
- }];
- [actionArray addObject:actionBtn];
- }
- ZCAlertSheetBtnView* alertSheet = [[ZCAlertSheetBtnView alloc]initWithTitle:LCStr(word25) andShowCancelButton:YES andAction:actionArray selectIndex:self.youpaipcate_id column:3];//选择账单类型
- //modify by leo --fix bug ios13 20191009
- //alertSheet.alertWindow.rootViewController = self;
- alertSheet.alertWindow.hidden = NO;
- [alertSheet show];
- }
- @end
|