// // YOUPAIHRSubGuildDetailVC.m // VQU // // Created by xiaohaoran on 2021/11/5. // Copyright © 2021 MS. All rights reserved. // #import "YOUPAIHRSubGuildDetailVC.h" #import "YOUPAIHRSubGuildDetailCell.h" #import "PGDatePickManager.h" #import "UIViewController+TFPresent.h" #import "YOUPAILZBillSectionModel.h" #import "YOUPAIHRDatePickerView.h" #import "BRPickerView.h" #import "YOUPAIHRChatRoomWindow.h" #import "YOUPAIHRSubGuildDetailModel.h" #import "UIScrollView+LZRefresh.h" @interface YOUPAIHRSubGuildDetailVC () @property(nonatomic,assign)NSInteger youpaippage; @property(nonatomic,assign)NSInteger youpaiptotalPage; @property(nonatomic,strong)NSMutableArray* youpaipbillArray; @property (nonatomic,strong)UITableView *youpaiptableView; @property(nonatomic,strong)NSString *youpaipdate; @property (nonatomic, assign) NSInteger youpaipselectIndex; @property(nonatomic,copy)NSString *youpaipstarDate; @property(nonatomic,copy)NSString *youpaipendDate; @property(nonatomic,strong)YOUPAIHRSubGuildDetailModel *youpaipmodel; @property(nonatomic,assign)NSInteger youpaiproomId; @property(nonatomic,copy)NSString *youpaiptimeType; @property(nonatomic,strong)UIView *youpaipbgView; @end @implementation YOUPAIHRSubGuildDetailVC -(void)viewWillAppear:(BOOL)animated{ [super viewWillAppear:animated]; self.youpaiptimeType = @"2"; self.youpaipstarDate =nil; self.youpaipendDate =nil; [self.youpaiptableView.mj_header beginRefreshing]; } -(void)dealloc{ [[NSNotificationCenter defaultCenter]removeObserver:self]; } - (void)viewDidLoad { [super viewDidLoad]; self.youpaipdate = @""; self.youpaipbillArray = [NSMutableArray array]; self.youpaiptimeType = @"2"; [[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(youpaifchangSelectDate:) name:@"changSelectDate" object:nil]; [self youpaifinitUI]; [self youpaifloadRoomFilterView]; @weakify(self); [self.youpaiptableView setRefreshHeaderWithBlock:^{ @strongify(self); [self youpaifrequestRankListWithStatus:kRefreshHeader]; }]; [self.youpaiptableView.mj_header beginRefreshing]; } -(void)youpaifchangSelectDate:(NSNotification*)notic{ NSDictionary *dict = notic.userInfo; self.youpaipstarDate =dict[@"starDate"]; self.youpaipendDate =dict[@"endDate"]; self.youpaiptimeType = dict[@"timeType"]; [self.youpaiptableView.mj_header beginRefreshing]; } -(void)youpaifloadRoomFilterView{ UIView *youpaipbgView = [UIView new]; self.youpaipbgView =youpaipbgView; [self.view addSubview:youpaipbgView]; [youpaipbgView mas_makeConstraints:^(MASConstraintMaker *make) { make.left.mas_equalTo(0); make.top.mas_equalTo(-44); make.height.mas_equalTo(44); make.right.mas_equalTo(0); }]; youpaipbgView.backgroundColor = LCBkgColor; //title UILabel *enterL = [[UILabel alloc] init]; enterL.font = [UIFont systemFontOfSize:11]; enterL.textColor = [UIColor whiteColor]; [youpaipbgView addSubview:enterL]; [enterL mas_makeConstraints:^(MASConstraintMaker *make) { make.left.offset(14.0f); make.centerY.offset(0.0f); }]; UIButton *roomFilterBtn = [UIButton new]; [youpaipbgView addSubview:roomFilterBtn]; [roomFilterBtn mas_makeConstraints:^(MASConstraintMaker *make) { make.right.mas_equalTo(-14); make.centerY.mas_equalTo(0); }]; [roomFilterBtn setTitle:@"房间筛选" forState:UIControlStateNormal]; [roomFilterBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal]; roomFilterBtn.titleLabel.font = [UIFont systemFontOfSize:11]; [roomFilterBtn setImage:[UIImage imageNamed:@"vqu_images_commen_ic_up"] forState:UIControlStateNormal]; [roomFilterBtn setSemanticContentAttribute:UISemanticContentAttributeForceRightToLeft]; [roomFilterBtn addTarget:self action:@selector(youpaifroomFilterBtnClick) forControlEvents:UIControlEventTouchUpInside]; enterL.text = [NSString stringWithFormat:@"房间收入0钻石"]; } //房间筛选 -(void)youpaifroomFilterBtnClick{ YOUPAIHRChatRoomWindow *vc = [YOUPAIHRChatRoomWindow new]; vc.isTouchDismiss = YES; [self TFPresentVC:vc completion:^{ }]; @weakify(self); [vc setYoupaipdidResetBlock:^{ @strongify(self); self.youpaiproomId = 0; [self.youpaiptableView.mj_header beginRefreshing]; }]; [vc setYoupaipdidSelectCellUserBlock:^(NSInteger room_ID) { @strongify(self); self.youpaiproomId = room_ID; [self.youpaiptableView.mj_header beginRefreshing]; }]; } - (void)youpaifinitUI{ self.youpaiptableView = [[UITableView alloc] initWithFrame:CGRectZero style:UITableViewStylePlain]; [self.view addSubview:self.youpaiptableView]; [self.youpaiptableView mas_makeConstraints:^(MASConstraintMaker *make) { make.top.mas_equalTo(0); make.left.mas_equalTo(0); make.right.mas_equalTo(0); make.bottom.mas_equalTo(0); }]; self.youpaiptableView.backgroundColor = [UIColor clearColor]; self.youpaiptableView.showsVerticalScrollIndicator = NO; self.youpaiptableView.separatorStyle = UITableViewCellSeparatorStyleNone; self.youpaiptableView.estimatedRowHeight = 78.0f; self.youpaiptableView.rowHeight = 78.0f; self.youpaiptableView.delegate = self; self.youpaiptableView.dataSource= self; if (@available(iOS 15.0, *)) { self.youpaiptableView.sectionHeaderTopPadding = 0; } } /// 设置加载更多 - (void)youpaifrefreshFooterWithHidden:(BOOL)hidden{ @weakify(self); [self.youpaiptableView setRefreshFooter:hidden withBlock:^{ @strongify(self); [self youpaifrequestRankListWithStatus:kRefreshFooter]; }]; } - (void)youpaifrequestRankListWithStatus:(kRefreshStatus)status{ if (status == kRefreshFooter) { self.youpaippage ++; }else{ self.youpaippage = 1; } @weakify(self); NSMutableDictionary *dict = [NSMutableDictionary new]; [dict setObject:@(self.youpaippage) forKey:@"page"]; [dict setObject:@(15) forKey:@"number"]; [dict setValue:@(self.youpaiptype) forKey:@"type"]; [dict setValue:self.youpaipstarDate forKey:@"beginTime"]; [dict setValue:self.youpaipendDate forKey:@"endTime"]; [dict setValue:[NSString stringWithFormat:@"%@",self.youpaiptimeType] forKey:@"timeType"]; [dict setValue:@(self.youpaiproomId) forKey:@"roomId"]; [LCHttpHelper requestWithURLString:ChatRoom_guildIncome parameters:dict needToken:YES type:(HttpRequestTypePost) success:^(id responseObject) { NSDictionary* dict = (NSDictionary*)responseObject; NSInteger code = [[dict objectForKey:@"code"] integerValue]; if (code==0) {//成功 @strongify(self); [self.youpaipbillArray removeAllObjects]; YOUPAIHRSubGuildDetailModel *Detailmodel = [YOUPAIHRSubGuildDetailModel mj_objectWithKeyValues:dict[@"data"]]; self.youpaipmodel = Detailmodel; NSArray *array1 = Detailmodel.youpaiplist; NSMutableArray *array = [NSMutableArray arrayWithArray:array1]; NSMutableArray *dateMutablearray = [NSMutableArray new]; for (int i = 0; i < array.count; i ++) { listModel *model =array[i]; NSMutableArray *tempArray = [NSMutableArray new]; [tempArray addObject:model]; for (int j = i+1; j < array.count; j ++) { listModel *model1 = array[j]; if([model.youpaipdate isEqualToString:model1.youpaipdate]){ [tempArray addObject:model1]; [array removeObjectAtIndex:j]; j -= 1; } } [dateMutablearray addObject:tempArray]; } [self.youpaipbillArray addObjectsFromArray:dateMutablearray]; self.youpaiptotalPage = [[[dict objectForKey:@"data"]objectForKey:@"total_page"]integerValue]; self.youpaippage = [[[dict objectForKey:@"data"]objectForKey:@"page"]integerValue]; [self.youpaiptableView reloadData]; if (self.youpaippage>=self.youpaiptotalPage) { [self.youpaiptableView.mj_footer endRefreshingWithNoMoreData]; self.youpaiptableView.mj_footer.hidden = YES; } [self.youpaiptableView lz_hideEmptyView]; if (self.youpaipbillArray.count == 0) { [UIView animateWithDuration:0.01 animations:^{ [self.youpaipbgView mas_remakeConstraints:^(MASConstraintMaker *make) { make.left.mas_equalTo(0); make.top.mas_equalTo(0); make.height.mas_equalTo(44); make.right.mas_equalTo(0); }]; } completion:^(BOOL finished) { }]; [self.youpaiptableView lz_showEmptyViewWithImage:[UIImage imageNamed:@"vqu_images_not_home_data"] content:@"暂无记录"]; }else{ [UIView animateWithDuration:0.01 animations:^{ [self.youpaipbgView mas_remakeConstraints:^(MASConstraintMaker *make) { make.left.mas_equalTo(0); make.top.mas_equalTo(-44); make.height.mas_equalTo(44); make.right.mas_equalTo(0); }]; } completion:^(BOOL finished) { }]; } [self.youpaiptableView.mj_header endRefreshing]; }else{ [self.youpaiptableView.mj_header endRefreshing]; } } failure:^(NSError *error) { [self.youpaiptableView.mj_header endRefreshing]; }]; } #pragma mark - tableView代理 - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{ return self.youpaipbillArray.count; } - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{ NSArray *arr = self.youpaipbillArray[section]; return arr.count; } - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{ NSArray *arr = self.youpaipbillArray[indexPath.section]; YOUPAIHRSubGuildDetailCell* cell = [tableView dequeueReusableCellWithIdentifier:@"YOUPAIHRSubGuildDetailCell"]; if (cell == nil) { cell = [[YOUPAIHRSubGuildDetailCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"YOUPAIHRSubGuildDetailCell"]; } listModel *model = arr[indexPath.row]; cell.youpaipbillModel = model; return cell; } - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{ } - (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{ if (section == 0) { return 68; }else{ return 46.0f; } } - (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{ listModel *sectionModel = self.youpaipbillArray[section][0]; CGFloat height; if (section == 0) { height = 68; }else{ height = 46; } UIView *bgV = [[UIView alloc] initWithFrame:CGRectMake(0, 0, KScreenWidth, height)]; bgV.backgroundColor = LCBkgColor; UILabel *enterL = [[UILabel alloc] init]; enterL.font = [UIFont systemFontOfSize:11]; enterL.textColor = [UIColor whiteColor]; [bgV addSubview:enterL]; [enterL mas_makeConstraints:^(MASConstraintMaker *make) { make.left.offset(14.0f); make.top.offset(16.0f); }]; UILabel *dayL = [[UILabel alloc] init]; dayL.text = sectionModel.youpaipdate;//@"2020年12月"; dayL.font = [UIFont systemFontOfSize:11]; dayL.textColor = HexColorFromRGB(0x9F9DA5); [bgV addSubview:dayL]; [dayL mas_makeConstraints:^(MASConstraintMaker *make) { make.left.offset(14.0f); make.top.mas_equalTo(enterL.mas_bottom).offset(20); }]; if (section != 0) { [dayL mas_remakeConstraints:^(MASConstraintMaker *make) { make.left.offset(14.0f); make.centerY.mas_equalTo(0); }]; } if (self.youpaiptype ==1 &§ion == 0) { //房间筛选 UIButton *roomFilterBtn = [UIButton new]; [bgV addSubview:roomFilterBtn]; [roomFilterBtn mas_makeConstraints:^(MASConstraintMaker *make) { make.right.mas_equalTo(-14); make.centerY.mas_equalTo(0); }]; [roomFilterBtn setTitle:@"房间筛选" forState:UIControlStateNormal]; [roomFilterBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal]; roomFilterBtn.titleLabel.font = [UIFont systemFontOfSize:11]; [roomFilterBtn setImage:[UIImage imageNamed:@"vqu_images_commen_ic_up"] forState:UIControlStateNormal]; [roomFilterBtn setSemanticContentAttribute:UISemanticContentAttributeForceRightToLeft]; [roomFilterBtn addTarget:self action:@selector(youpaifroomFilterBtnClick) forControlEvents:UIControlEventTouchUpInside]; enterL.text = [NSString stringWithFormat:@"房间收入 %@钻石",self.youpaipmodel.youpaipincome]; } else if ( self.youpaiptype ==0&§ion == 0){ enterL.text = [NSString stringWithFormat:@"总收入 %@钻石",self.youpaipmodel.youpaipincome]; }else if (self.youpaiptype ==2&§ion == 0){ enterL.text = [NSString stringWithFormat:@"公会收入 %@钻石",self.youpaipmodel.youpaipincome]; } return bgV; } #pragma mark - JXCategoryListContainerView - (UIView *)listView{ return self.view; } @end