123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224 |
- //
- // YOUPAIHRMembershipApplicationVC.m
- // VQU
- //
- // Created by xiaohaoran on 2021/11/5.
- // Copyright © 2021 MS. All rights reserved.
- //
- #import "YOUPAIHRMembershipApplicationVC.h"
- #import "YOUPAIHRMembershipApplicationCell.h"
- #import "UIScrollView+LZRefresh.h"
- #import "YOUPAIHRMembershipApplicationModel.h"
- #import "LZAlertWindow.h"
- #import "UIViewController+TFPresent.h"
- @interface YOUPAIHRMembershipApplicationVC ()<UITableViewDelegate,UITableViewDataSource>
- @property(nonatomic,strong)UITableView *youpaiptableView;
- @property (nonatomic, assign) NSInteger youpaippage;
- @property (nonatomic, strong) NSMutableArray *youpaipdataSource;
- @end
- @implementation YOUPAIHRMembershipApplicationVC
- - (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_guildMemberList 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 68;
- }
- -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
-
- return self.youpaipdataSource.count;
- }
- -(UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
-
-
- YOUPAIHRMembershipApplicationCell *cell = [tableView dequeueReusableCellWithIdentifier:@"HRMembershipApplicationID" forIndexPath:indexPath];;
- if (cell == nil) {
- cell = [[YOUPAIHRMembershipApplicationCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"HRMembershipApplicationID"];
- }
- [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_guildMember 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_guildMember 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:[YOUPAIHRMembershipApplicationCell class] forCellReuseIdentifier:@"HRMembershipApplicationID"];
- }
-
- return _youpaiptableView;
- }
- -(NSMutableArray *)youpaipdataSource{
-
- if (_youpaipdataSource == nil) {
- _youpaipdataSource = [NSMutableArray new];
- }
- return _youpaipdataSource;
- }
- @end
|