#import "YOUPAIHRGuildCenterDetailVC.h" #import "YOUPAIHRGuildCenterDetailCell.h" #import "YOUPAIHRGuildCenterDetailHeaderView.h" #import "YOUPAIHRMembershipApplicationVC.h" #import "LZAlertWindow.h" #import "UIViewController+TFPresent.h" #import "UIScrollView+LZRefresh.h" #import "YOUPAIHRGuildCenterDetailModel.h" #import "YOUPAIApplyOutWindow.h" #import "YOUPAICancellationApplicationVC.h" @interface YOUPAIHRGuildCenterDetailVC () @property(nonatomic,strong)UITableView *youpaiptableView; @property (nonatomic, assign) NSInteger youpaippage; @property (nonatomic, strong) NSMutableArray *youpaipdataSource; @property(nonatomic,strong)YOUPAIHRGuildCenterDetailModel *youpaipmodel; @property(nonatomic,strong)YOUPAIHRGuildCenterDetailHeaderView *youpaipheaderView; @property(nonatomic,strong)UILabel *youpaipunReadView; @property(nonatomic,assign)NSInteger youpaipheaderViewHeight; @property(nonatomic,strong)UILabel *outpaipunReadView; @property(nonatomic,assign)BOOL isOut; @end @implementation YOUPAIHRGuildCenterDetailVC -(void)viewWillAppear:(BOOL)animated{ [super viewWillAppear:animated]; [self.youpaiptableView.mj_header beginRefreshing]; } - (void)viewDidLoad { [super viewDidLoad]; self.title = @"公会中心"; [self youpaiptableView]; if (self.youpaipguild == 2) { [self youpaifsetJoinGuildView]; self.youpaipheaderViewHeight = 384; }else{ [self youpaifsetRightBtn]; self.youpaipheaderViewHeight = 384-70; } [self youpaifsetYoupaipheaderView]; @weakify(self); [self.youpaiptableView setRefreshHeaderWithBlock:^{ @strongify(self); [self youpaifrequestRankListWithStatus:kRefreshHeader]; }]; [self.youpaiptableView.mj_header beginRefreshing]; } /// 设置加载更多 - (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); [LCHttpHelper requestWithURLString:ChatRoom_guildCenter parameters:@{@"number":[NSString stringWithFormat:@"%d",15],@"page":@(self.youpaippage)} needToken:YES type:(HttpRequestTypePost) success:^(id responseObject) { @strongify(self); [self.youpaiptableView endRefreshing:kRefreshAll]; NSDictionary* dict = (NSDictionary*)responseObject; NSInteger code = [[dict objectForKey:@"code"] integerValue]; if (code == 0) {//成功 if (status != kRefreshFooter) { [self.youpaipdataSource removeAllObjects]; } NSDictionary *data = [dict objectForKey:@"data"]; YOUPAIHRGuildCenterDetailModel *model = [YOUPAIHRGuildCenterDetailModel mj_objectWithKeyValues:data]; self.youpaipmodel = model; NSArray *arr = model.list; [arr enumerateObjectsUsingBlock:^(id _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) { GuildMemberList *guildModel = obj; if (idx == 0&&self.youpaippage == 1) { guildModel.isHuiZ = YES; } [self.youpaipdataSource addObject:guildModel]; }]; self.isOut = model.quitStatus; [self.youpaipheaderView youpaifreloadHeaderViewWith:model]; self.outpaipunReadView.text = [NSString stringWithFormat:@"%ld",(long)model.quitNumber]; self.youpaipunReadView.text = [NSString stringWithFormat:@"%ld",(long)model.waitNumber]; [self.youpaiptableView reloadData]; NSInteger youpaiptotalPage = [data[@"guildMember"][@"total_page"] integerValue]; [self youpaifrefreshFooterWithHidden:self.youpaippage >= youpaiptotalPage]; if (self.youpaipdataSource.count != 0) { [self.youpaiptableView lz_hideEmptyView]; }else{ [self.youpaiptableView lz_showEmptyViewWithImage:[UIImage imageNamed:@"vqu_images_not_home_data"] content:@"暂无数据"]; } } } failure:^(NSError *error) { @strongify(self); [self.youpaiptableView endRefreshing:kRefreshAll]; }]; } //入会申请 -(void)youpaifsetJoinGuildView{ UIView *JoinGuildBgView1 = [UIView new]; [self.view addSubview:JoinGuildBgView1]; [JoinGuildBgView1 mas_makeConstraints:^(MASConstraintMaker *make) { make.right.mas_equalTo(-20); make.bottom.mas_equalTo(-SafeHeight-20); make.size.mas_equalTo(CGSizeMake(90, 30+37.5)); }]; JoinGuildBgView1.backgroundColor = [UIColor clearColor]; UIView *JoinGuildBgView = [UIView new]; [JoinGuildBgView1 addSubview:JoinGuildBgView]; [JoinGuildBgView mas_makeConstraints:^(MASConstraintMaker *make) { make.right.mas_equalTo(0); make.top.mas_equalTo(0); make.size.mas_equalTo(CGSizeMake(90, 30)); }]; JoinGuildBgView.backgroundColor = [UIColor clearColor]; UIButton *joinGuildBtn = [UIButton new]; [JoinGuildBgView addSubview:joinGuildBtn]; [joinGuildBtn mas_makeConstraints:^(MASConstraintMaker *make) { make.left.mas_equalTo(0); make.top.mas_equalTo(0); make.right.mas_equalTo(-10); make.bottom.mas_equalTo(0); }]; [joinGuildBtn setTitle:@"入会申请" forState:UIControlStateNormal]; [joinGuildBtn setTitleColor:HexColorFromRGB(0xFF6A1F) forState:UIControlStateNormal]; joinGuildBtn.titleLabel.font = [UIFont systemFontOfSize:12]; [joinGuildBtn setImage:[UIImage imageNamed:@"vqu_images_guild_ic_apply"] forState:UIControlStateNormal]; joinGuildBtn.backgroundColor = [UIColor whiteColor]; joinGuildBtn.layer.cornerRadius = 14.5; joinGuildBtn.layer.masksToBounds = YES; //未读数 UILabel *youpaipunReadView = [UILabel new]; self.youpaipunReadView = youpaipunReadView; [JoinGuildBgView addSubview:youpaipunReadView]; [youpaipunReadView mas_makeConstraints:^(MASConstraintMaker *make) { make.left.mas_equalTo(joinGuildBtn.mas_right).offset(-7); make.top.mas_equalTo(joinGuildBtn); make.size.mas_equalTo(CGSizeMake(14, 14)); }]; youpaipunReadView.text = @"8"; youpaipunReadView.font = [UIFont systemFontOfSize:10]; youpaipunReadView.textColor = [UIColor whiteColor]; youpaipunReadView.backgroundColor = HexColorFromRGB(0xF4003F); youpaipunReadView.layer.cornerRadius = 7; youpaipunReadView.layer.masksToBounds = YES; youpaipunReadView.textAlignment = NSTextAlignmentCenter; //事件 [joinGuildBtn addTarget:self action:@selector(youpaifjoinGuildBtnClick) forControlEvents:UIControlEventTouchUpInside]; //退会申请 UIView *outGuildBgView = [UIView new]; [JoinGuildBgView1 addSubview:outGuildBgView]; [outGuildBgView mas_makeConstraints:^(MASConstraintMaker *make) { make.right.mas_equalTo(0); make.top.mas_equalTo(JoinGuildBgView.mas_bottom).offset(7.5); make.size.mas_equalTo(CGSizeMake(90, 30)); }]; outGuildBgView.backgroundColor = [UIColor clearColor]; UIButton *outGuildBtn = [UIButton new]; [outGuildBgView addSubview:outGuildBtn]; [outGuildBtn mas_makeConstraints:^(MASConstraintMaker *make) { make.left.mas_equalTo(0); make.top.mas_equalTo(0); make.right.mas_equalTo(-10); make.bottom.mas_equalTo(0); }]; [outGuildBtn setTitle:@"退会申请" forState:UIControlStateNormal]; [outGuildBtn setTitleColor:HexColorFromRGB(0xffffff) forState:UIControlStateNormal]; outGuildBtn.titleLabel.font = [UIFont systemFontOfSize:12]; [outGuildBtn setImage:[UIImage imageNamed:@"vqu_images_guild_ic_out"] forState:UIControlStateNormal]; [outGuildBtn setBackgroundColor:[UIColor colorWithPatternImage:[LCTools ColorImage:CGSizeMake(80, 30) FromColors:@[HexColorFromRGB(0x75ECFF),HexColorFromRGB(0x40A1F7)] ByGradientType:1]]]; outGuildBtn.layer.cornerRadius = 14.5; outGuildBtn.layer.masksToBounds = YES; //未读数 UILabel *outpaipunReadView = [UILabel new]; self.outpaipunReadView = outpaipunReadView; [outGuildBgView addSubview:outpaipunReadView]; [outpaipunReadView mas_makeConstraints:^(MASConstraintMaker *make) { make.left.mas_equalTo(outGuildBtn.mas_right).offset(-7); make.top.mas_equalTo(outGuildBtn); make.size.mas_equalTo(CGSizeMake(14, 14)); }]; outpaipunReadView.text = @"8"; outpaipunReadView.font = [UIFont systemFontOfSize:10]; outpaipunReadView.textColor = [UIColor whiteColor]; outpaipunReadView.backgroundColor = HexColorFromRGB(0xF4003F); outpaipunReadView.layer.cornerRadius = 7; outpaipunReadView.layer.masksToBounds = YES; outpaipunReadView.textAlignment = NSTextAlignmentCenter; //事件 [outGuildBtn addTarget:self action:@selector(youpaifoutGuildBtnClick) forControlEvents:UIControlEventTouchUpInside]; } #pragma mark 入会申请 -(void)youpaifjoinGuildBtnClick{ YOUPAIHRMembershipApplicationVC *vc = [YOUPAIHRMembershipApplicationVC new]; [self.navigationController pushViewController:vc animated:YES]; } //退会申请 -(void)youpaifoutGuildBtnClick{ YOUPAICancellationApplicationVC *vc = [YOUPAICancellationApplicationVC new]; [self.navigationController pushViewController:vc animated:YES]; } -(void)youpaifsetYoupaipheaderView{ YOUPAIHRGuildCenterDetailHeaderView *headView = [[YOUPAIHRGuildCenterDetailHeaderView alloc]initWithFrame:CGRectMake(0, 0, KScreenWidth, self.youpaipheaderViewHeight)]; self.youpaipheaderView = headView; headView.youpaipguild = self.youpaipguild; self.youpaiptableView.tableHeaderView = headView; } #pragma mark UITableViewDelegate&UITableViewDataSource -(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{ return 68; } -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{ return self.youpaipdataSource.count; } -(UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{ NSString *CellIdentifier = @"YOUPAIHRGuildCenterDetailCell"; YOUPAIHRGuildCenterDetailCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];; if (cell == nil) { cell = [[YOUPAIHRGuildCenterDetailCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier]; } [cell setSelectionStyle:UITableViewCellSelectionStyleNone]; cell.backgroundColor = LCBkgColor; GuildMemberList *model = self.youpaipdataSource[indexPath.row]; cell.youpaipmodel = model; return cell; } -(void)youpaifsetRightBtn{ // 退出 UIButton *rightBtn = [UIButton buttonWithType:(UIButtonTypeCustom)]; rightBtn.frame = CGRectMake(0, 0, 44, 22); UIBarButtonItem *right = [[UIBarButtonItem alloc]initWithCustomView:rightBtn]; [rightBtn setTitle:@"退出" forState:UIControlStateNormal]; [rightBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal]; [rightBtn addTarget:self action:@selector(youpaifbackAction) forControlEvents:(UIControlEventTouchUpInside)]; self.navigationItem.rightBarButtonItem = right; [rightBtn setBackgroundColor:HexColorFromRGB(0x4F4B5B)]; rightBtn.layer.cornerRadius = 11; rightBtn.layer.masksToBounds = YES; rightBtn.titleLabel.font = LCBoldFont(10); } -(void)youpaifbackAction{ if (self.isOut) { LZAlertAction *cancelAction = [LZAlertAction actionWithTitle:@"取消" handler:^(LZAlertAction *action) { }]; cancelAction.cornerRadius = 24.0f; cancelAction.color = LZ273145Color; cancelAction.bgColor = LZF5F4F7Color; // @weakify(self); LZAlertAction *confimAction = [LZAlertAction actionWithTitle:@"好的" handler:^(LZAlertAction *action) { // @strongify(self); // [self youpaifoutGuild]; }]; confimAction.cornerRadius = 24.0f; confimAction.color = [UIColor whiteColor]; confimAction.bgColor = [UIColor colorWithPatternImage:[LCTools ColorImage:CGSizeMake((KScreenWidth - 105.0f), 48.0f) FromColors:@[LZBFB6FFColor,LZ7C69FEColor] ByGradientType:GradientLeftToRight]]; LZAlertWindow *alert = [LZAlertWindow alertWithTitle:@"退会申请" content:[NSString stringWithFormat:@"已提交过申请,请等待会长处理"] action:@[confimAction]]; alert.contentTextAlignment = NSTextAlignmentCenter; [self TFPresentVC:alert completion:^{}]; }else{ YOUPAIApplyOutWindow *applyOut = [YOUPAIApplyOutWindow new]; applyOut.vWidth = KScreenWidth -68; applyOut.vHeight = ScaleHeight(247)+10; applyOut.isTouchDismiss = YES; @weakify(self); [applyOut setDidlickSureBlock:^(NSString * _Nonnull content) { @strongify(self); [LCHttpHelper requestWithURLString:ChatRoom_guildQuit parameters:@{@"content":content} needToken:YES type:(HttpRequestTypePost) success:^(id responseObject) { NSDictionary* dict = (NSDictionary*)responseObject; NSInteger code = [[dict objectForKey:@"code"] integerValue]; if (code == 0) {//成功 [ZCHUDHelper showTitle:@"操作成功"]; [self.youpaiptableView.mj_header beginRefreshing]; } } failure:^(NSError *error) { @strongify(self); [self.youpaiptableView endRefreshing:kRefreshAll]; }]; }]; [self TFPresentVC:applyOut completion:^{ }]; } } //退出公会 -(void)youpaifoutGuild{ [LCHttpHelper requestWithURLString:ChatRoom_guildQuit parameters:nil needToken:YES type:(HttpRequestTypePost) success:^(id responseObject) { NSDictionary* dict = (NSDictionary*)responseObject; NSInteger code = [[dict objectForKey:@"code"] integerValue]; if (code == 0) {//成功 [self.navigationController popViewControllerAnimated:YES]; }else{ [ZCHUDHelper showTitle:dict[@"message"]]; } } failure:^(NSError *error) { [self.youpaiptableView endRefreshing:kRefreshAll]; }]; } -(UITableView *)youpaiptableView{ if (_youpaiptableView == nil) { _youpaiptableView = [[UITableView alloc]initWithFrame:CGRectZero style:UITableViewStylePlain]; [self.view addSubview:_youpaiptableView]; [_youpaiptableView mas_makeConstraints:^(MASConstraintMaker *make) { make.top.mas_equalTo(NavBarHeight); make.left.mas_equalTo(0); make.right.mas_equalTo(0); make.bottom.mas_equalTo(-SafeHeight); }]; _youpaiptableView.delegate = self; _youpaiptableView.dataSource = self; _youpaiptableView.backgroundColor = [UIColor clearColor]; _youpaiptableView.separatorStyle = UITableViewCellSeparatorStyleNone; _youpaiptableView.showsVerticalScrollIndicator = NO; _youpaiptableView.showsHorizontalScrollIndicator = NO; if (@available(iOS 15.0, *)) { _youpaiptableView.sectionHeaderTopPadding = 0; } } return _youpaiptableView; } -(NSMutableArray *)youpaipdataSource{ if (_youpaipdataSource == nil) { _youpaipdataSource = [NSMutableArray new]; } return _youpaipdataSource; } @end