YOUPAIHRMembershipApplicationVC.m 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224
  1. //
  2. // YOUPAIHRMembershipApplicationVC.m
  3. // VQU
  4. //
  5. // Created by xiaohaoran on 2021/11/5.
  6. // Copyright © 2021 MS. All rights reserved.
  7. //
  8. #import "YOUPAIHRMembershipApplicationVC.h"
  9. #import "YOUPAIHRMembershipApplicationCell.h"
  10. #import "UIScrollView+LZRefresh.h"
  11. #import "YOUPAIHRMembershipApplicationModel.h"
  12. #import "LZAlertWindow.h"
  13. #import "UIViewController+TFPresent.h"
  14. @interface YOUPAIHRMembershipApplicationVC ()<UITableViewDelegate,UITableViewDataSource>
  15. @property(nonatomic,strong)UITableView *youpaiptableView;
  16. @property (nonatomic, assign) NSInteger youpaippage;
  17. @property (nonatomic, strong) NSMutableArray *youpaipdataSource;
  18. @end
  19. @implementation YOUPAIHRMembershipApplicationVC
  20. - (void)viewDidLoad {
  21. [super viewDidLoad];
  22. self.title = @"入会申请";
  23. [self youpaiptableView];
  24. @weakify(self);
  25. [self.youpaiptableView setRefreshHeaderWithBlock:^{
  26. @strongify(self);
  27. [self youpaifrequestRankListWithStatus:kRefreshHeader];
  28. }];
  29. [self.youpaiptableView.mj_header beginRefreshing];
  30. }
  31. /// 设置加载更多
  32. - (void)youpaifrefreshFooterWithHidden:(BOOL)hidden{
  33. @weakify(self);
  34. [self.youpaiptableView setRefreshFooter:hidden withBlock:^{
  35. @strongify(self);
  36. [self youpaifrequestRankListWithStatus:kRefreshFooter];
  37. }];
  38. }
  39. - (void)youpaifrequestRankListWithStatus:(kRefreshStatus)status{
  40. if (status == kRefreshFooter) {
  41. self.youpaippage ++;
  42. }else{
  43. self.youpaippage = 1;
  44. }
  45. @weakify(self);
  46. [LCHttpHelper requestWithURLString:ChatRoom_guildMemberList parameters:@{@"number":[NSString stringWithFormat:@"%d",15],@"page":@(self.youpaippage)} needToken:YES type:(HttpRequestTypePost) success:^(id responseObject) {
  47. @strongify(self);
  48. [self.youpaiptableView endRefreshing:kRefreshAll];
  49. NSDictionary* dict = (NSDictionary*)responseObject;
  50. NSInteger code = [[dict objectForKey:@"code"] integerValue];
  51. if (code == 0) {//成功
  52. if (status != kRefreshFooter) {
  53. [self.youpaipdataSource removeAllObjects];
  54. }
  55. NSDictionary *data = [dict objectForKey:@"data"];
  56. NSArray* array = [[dict objectForKey:@"data"]objectForKey:@"list"];
  57. NSMutableArray* modelArray = [YOUPAIHRMembershipApplicationModel mj_objectArrayWithKeyValuesArray:array];
  58. NSMutableArray* tempArray = [NSMutableArray arrayWithArray:(NSArray*)modelArray];
  59. [self.youpaipdataSource addObjectsFromArray:tempArray];
  60. [self.youpaiptableView reloadData];
  61. NSInteger youpaiptotalPage = [data[@"total_page"] integerValue];
  62. [self youpaifrefreshFooterWithHidden:self.youpaippage >= youpaiptotalPage];
  63. if (self.youpaipdataSource.count != 0) {
  64. [self.youpaiptableView lz_hideEmptyView];
  65. }else{
  66. [self.youpaiptableView lz_showEmptyViewWithImage:[UIImage imageNamed:@"vqu_images_not_home_data"] content:@"暂无数据"];
  67. }
  68. }
  69. } failure:^(NSError *error) {
  70. @strongify(self);
  71. [self.youpaiptableView endRefreshing:kRefreshAll];
  72. }];
  73. }
  74. #pragma mark UITableViewDelegate&UITableViewDataSource
  75. -(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
  76. return 68;
  77. }
  78. -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
  79. return self.youpaipdataSource.count;
  80. }
  81. -(UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
  82. YOUPAIHRMembershipApplicationCell *cell = [tableView dequeueReusableCellWithIdentifier:@"HRMembershipApplicationID" forIndexPath:indexPath];;
  83. if (cell == nil) {
  84. cell = [[YOUPAIHRMembershipApplicationCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"HRMembershipApplicationID"];
  85. }
  86. [cell setSelectionStyle:UITableViewCellSelectionStyleNone];
  87. cell.backgroundColor = LCBkgColor;
  88. YOUPAIHRMembershipApplicationModel *model = self.youpaipdataSource[indexPath.row];
  89. cell.youpaipmodel = model;
  90. @weakify(self);
  91. [cell setYoupaipagreeBlock:^(YOUPAIHRMembershipApplicationModel * _Nonnull model) {
  92. @strongify(self);
  93. [self youpaifagreeSelector:model];
  94. }];
  95. [cell setYoupaiprefuseBlock:^(YOUPAIHRMembershipApplicationModel * _Nonnull model) {
  96. [self youpaifrefuseSelector:model];
  97. }];
  98. return cell;
  99. }
  100. //拒绝|同意
  101. -(void)youpaifagreeSelector:(YOUPAIHRMembershipApplicationModel*)model{
  102. LZAlertAction *cancelAction = [LZAlertAction actionWithTitle:@"取消" handler:^(LZAlertAction *action) {
  103. }];
  104. cancelAction.cornerRadius = 24.0f;
  105. cancelAction.color = LZ273145Color;
  106. cancelAction.bgColor = LZF5F4F7Color;
  107. @weakify(self);
  108. LZAlertAction *confimAction = [LZAlertAction actionWithTitle:@"确定" handler:^(LZAlertAction *action) {
  109. @strongify(self);
  110. [LCHttpHelper requestWithURLString:ChatRoom_guildMember parameters:@{@"id":[NSString stringWithFormat:@"%ld",(long)model.youpaipid],@"status":@"1"} needToken:YES type:(HttpRequestTypePost) success:^(id responseObject) {
  111. [self.youpaiptableView endRefreshing:kRefreshAll];
  112. NSDictionary* dict = (NSDictionary*)responseObject;
  113. NSInteger code = [[dict objectForKey:@"code"] integerValue];
  114. if (code == 0) {//成功
  115. [self.youpaiptableView.mj_header beginRefreshing];
  116. if (self.youpaipdataSource.count != 0) {
  117. [self.youpaiptableView lz_hideEmptyView];
  118. }else{
  119. [self.youpaiptableView lz_showEmptyViewWithImage:[UIImage imageNamed:@"vqu_images_not_home_data"] content:@"暂无数据"];
  120. }
  121. }else{
  122. [ZCHUDHelper showTitle:dict[@"message"]];
  123. }
  124. } failure:^(NSError *error) {
  125. [self.youpaiptableView endRefreshing:kRefreshAll];
  126. }];
  127. }];
  128. confimAction.cornerRadius = 24.0f;
  129. confimAction.color = [UIColor whiteColor];
  130. confimAction.bgColor = [UIColor colorWithPatternImage:[LCTools ColorImage:CGSizeMake((KScreenWidth - 105.0f) / 2.0f, 48.0f) FromColors:@[LZBFB6FFColor,LZ7C69FEColor] ByGradientType:GradientLeftToRight]];
  131. LZAlertWindow *alert = [LZAlertWindow alertWithTitle:@"" content:@"是否同意入会申请?" action:@[cancelAction,confimAction]];
  132. alert.contentTextAlignment = NSTextAlignmentCenter;
  133. [self TFPresentVC:alert completion:^{}];
  134. }
  135. -(void)youpaifrefuseSelector:(YOUPAIHRMembershipApplicationModel*)model{
  136. LZAlertAction *cancelAction = [LZAlertAction actionWithTitle:@"取消" handler:^(LZAlertAction *action) {
  137. }];
  138. cancelAction.cornerRadius = 24.0f;
  139. cancelAction.color = LZ273145Color;
  140. cancelAction.bgColor = LZF5F4F7Color;
  141. @weakify(self);
  142. LZAlertAction *confimAction = [LZAlertAction actionWithTitle:@"确定" handler:^(LZAlertAction *action) {
  143. @strongify(self);
  144. [LCHttpHelper requestWithURLString:ChatRoom_guildMember parameters:@{@"id":[NSString stringWithFormat:@"%ld",(long)model.youpaipid],@"status":@"0"} needToken:YES type:(HttpRequestTypePost) success:^(id responseObject) {
  145. [self.youpaiptableView endRefreshing:kRefreshAll];
  146. NSDictionary* dict = (NSDictionary*)responseObject;
  147. NSInteger code = [[dict objectForKey:@"code"] integerValue];
  148. if (code == 0) {//成功
  149. [ZCHUDHelper showTitle:dict[@"message"]];
  150. [self.youpaiptableView.mj_header beginRefreshing];
  151. if (self.youpaipdataSource.count != 0) {
  152. [self.youpaiptableView lz_hideEmptyView];
  153. }else{
  154. [self.youpaiptableView lz_showEmptyViewWithImage:[UIImage imageNamed:@"vqu_images_not_home_data"] content:@"暂无数据"];
  155. }
  156. }else{
  157. [ZCHUDHelper showTitle:dict[@"message"]];
  158. }
  159. } failure:^(NSError *error) {
  160. [self.youpaiptableView endRefreshing:kRefreshAll];
  161. }];
  162. }];
  163. confimAction.cornerRadius = 24.0f;
  164. confimAction.color = [UIColor whiteColor];
  165. confimAction.bgColor = [UIColor colorWithPatternImage:[LCTools ColorImage:CGSizeMake((KScreenWidth - 105.0f) / 2.0f, 48.0f) FromColors:@[LZBFB6FFColor,LZ7C69FEColor] ByGradientType:GradientLeftToRight]];
  166. LZAlertWindow *alert = [LZAlertWindow alertWithTitle:@"" content:@"是否拒绝入会申请?" action:@[cancelAction,confimAction]];
  167. alert.contentTextAlignment = NSTextAlignmentCenter;
  168. [self TFPresentVC:alert completion:^{}];
  169. }
  170. -(UITableView *)youpaiptableView{
  171. if (_youpaiptableView == nil) {
  172. _youpaiptableView = [[UITableView alloc]initWithFrame:CGRectZero style:UITableViewStylePlain];
  173. [self.view addSubview:_youpaiptableView];
  174. [_youpaiptableView mas_makeConstraints:^(MASConstraintMaker *make) {
  175. make.top.mas_equalTo(NavBarHeight);
  176. make.left.mas_equalTo(0);
  177. make.right.mas_equalTo(0);
  178. make.bottom.mas_equalTo(-SafeHeight);
  179. }];
  180. _youpaiptableView.delegate = self;
  181. _youpaiptableView.dataSource = self;
  182. _youpaiptableView.backgroundColor = [UIColor clearColor];
  183. _youpaiptableView.separatorStyle = UITableViewCellSeparatorStyleNone;
  184. _youpaiptableView.showsVerticalScrollIndicator = NO;
  185. _youpaiptableView.showsHorizontalScrollIndicator = NO;
  186. if (@available(iOS 15.0, *)) {
  187. _youpaiptableView.sectionHeaderTopPadding = 0;
  188. }
  189. [_youpaiptableView registerClass:[YOUPAIHRMembershipApplicationCell class] forCellReuseIdentifier:@"HRMembershipApplicationID"];
  190. }
  191. return _youpaiptableView;
  192. }
  193. -(NSMutableArray *)youpaipdataSource{
  194. if (_youpaipdataSource == nil) {
  195. _youpaipdataSource = [NSMutableArray new];
  196. }
  197. return _youpaipdataSource;
  198. }
  199. @end