// // YOUPAIHRMembershipApplicationVC.m // VQU // // Created by xiaohaoran on 2021/11/5. // Copyright © 2021 MS. All rights reserved. // #import "YOUPAICancellationApplicationVC.h" #import "YOUPAICancellationApplicationCell.h" #import "UIScrollView+LZRefresh.h" #import "YOUPAIHRMembershipApplicationModel.h" #import "LZAlertWindow.h" #import "UIViewController+TFPresent.h" @interface YOUPAICancellationApplicationVC () @property(nonatomic,strong)UITableView *youpaiptableView; @property (nonatomic, assign) NSInteger youpaippage; @property (nonatomic, strong) NSMutableArray *youpaipdataSource; @end @implementation YOUPAICancellationApplicationVC - (void)viewDidLoad { [super viewDidLoad]; self.title = @"退会申请"; [self youpaiptableView]; @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_guildQuitList 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"]; NSArray* array = [[dict objectForKey:@"data"]objectForKey:@"list"]; NSMutableArray* modelArray = [YOUPAIHRMembershipApplicationModel mj_objectArrayWithKeyValuesArray:array]; NSMutableArray* tempArray = [NSMutableArray arrayWithArray:(NSArray*)modelArray]; [self.youpaipdataSource addObjectsFromArray:tempArray]; [self.youpaiptableView reloadData]; NSInteger youpaiptotalPage = [data[@"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]; }]; } #pragma mark UITableViewDelegate&UITableViewDataSource -(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{ return 129; } -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{ return self.youpaipdataSource.count; } -(UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{ YOUPAICancellationApplicationCell *cell = [tableView dequeueReusableCellWithIdentifier:@"YOUPAIHRMembershipApplicationCell" forIndexPath:indexPath];; if (cell == nil) { cell = [[YOUPAICancellationApplicationCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"YOUPAIHRMembershipApplicationCell"]; } [cell setSelectionStyle:UITableViewCellSelectionStyleNone]; cell.backgroundColor = LCBkgColor; YOUPAIHRMembershipApplicationModel *model = self.youpaipdataSource[indexPath.row]; cell.youpaipmodel = model; @weakify(self); [cell setYoupaipagreeBlock:^(YOUPAIHRMembershipApplicationModel * _Nonnull model) { @strongify(self); [self youpaifagreeSelector:model]; }]; [cell setYoupaiprefuseBlock:^(YOUPAIHRMembershipApplicationModel * _Nonnull model) { [self youpaifrefuseSelector:model]; }]; return cell; } //拒绝|同意 -(void)youpaifagreeSelector:(YOUPAIHRMembershipApplicationModel*)model{ 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); [LCHttpHelper requestWithURLString:ChatRoom_guildQuitUp parameters:@{@"id":[NSString stringWithFormat:@"%ld",(long)model.youpaipid],@"status":@"1"} needToken:YES type:(HttpRequestTypePost) success:^(id responseObject) { [self.youpaiptableView endRefreshing:kRefreshAll]; NSDictionary* dict = (NSDictionary*)responseObject; NSInteger code = [[dict objectForKey:@"code"] integerValue]; if (code == 0) {//成功 [self.youpaiptableView.mj_header beginRefreshing]; if (self.youpaipdataSource.count != 0) { [self.youpaiptableView lz_hideEmptyView]; }else{ [self.youpaiptableView lz_showEmptyViewWithImage:[UIImage imageNamed:@"vqu_images_not_home_data"] content:@"暂无数据"]; } }else{ [ZCHUDHelper showTitle:dict[@"message"]]; } } failure:^(NSError *error) { [self.youpaiptableView endRefreshing:kRefreshAll]; }]; }]; confimAction.cornerRadius = 24.0f; confimAction.color = [UIColor whiteColor]; confimAction.bgColor = [UIColor colorWithPatternImage:[LCTools ColorImage:CGSizeMake((KScreenWidth - 105.0f) / 2.0f, 48.0f) FromColors:@[LZBFB6FFColor,LZ7C69FEColor] ByGradientType:GradientLeftToRight]]; LZAlertWindow *alert = [LZAlertWindow alertWithTitle:@"" content:@"是否同意退会申请?" action:@[cancelAction,confimAction]]; alert.contentTextAlignment = NSTextAlignmentCenter; [self TFPresentVC:alert completion:^{}]; } -(void)youpaifrefuseSelector:(YOUPAIHRMembershipApplicationModel*)model{ 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); [LCHttpHelper requestWithURLString:ChatRoom_guildQuitUp parameters:@{@"id":[NSString stringWithFormat:@"%ld",(long)model.youpaipid],@"status":@"0"} needToken:YES type:(HttpRequestTypePost) success:^(id responseObject) { [self.youpaiptableView endRefreshing:kRefreshAll]; NSDictionary* dict = (NSDictionary*)responseObject; NSInteger code = [[dict objectForKey:@"code"] integerValue]; if (code == 0) {//成功 [ZCHUDHelper showTitle:dict[@"message"]]; [self.youpaiptableView.mj_header beginRefreshing]; if (self.youpaipdataSource.count != 0) { [self.youpaiptableView lz_hideEmptyView]; }else{ [self.youpaiptableView lz_showEmptyViewWithImage:[UIImage imageNamed:@"vqu_images_not_home_data"] content:@"暂无数据"]; } }else{ [ZCHUDHelper showTitle:dict[@"message"]]; } } failure:^(NSError *error) { [self.youpaiptableView endRefreshing:kRefreshAll]; }]; }]; confimAction.cornerRadius = 24.0f; confimAction.color = [UIColor whiteColor]; confimAction.bgColor = [UIColor colorWithPatternImage:[LCTools ColorImage:CGSizeMake((KScreenWidth - 105.0f) / 2.0f, 48.0f) FromColors:@[LZBFB6FFColor,LZ7C69FEColor] ByGradientType:GradientLeftToRight]]; LZAlertWindow *alert = [LZAlertWindow alertWithTitle:@"" content:@"是否拒绝退会申请?" action:@[cancelAction,confimAction]]; alert.contentTextAlignment = NSTextAlignmentCenter; [self TFPresentVC:alert completion:^{}]; } -(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; } [_youpaiptableView registerClass:[YOUPAICancellationApplicationCell class] forCellReuseIdentifier:@"YOUPAIHRMembershipApplicationCell"]; } return _youpaiptableView; } -(NSMutableArray *)youpaipdataSource{ if (_youpaipdataSource == nil) { _youpaipdataSource = [NSMutableArray new]; } return _youpaipdataSource; } @end