YOUPAIHRGuildCenterDetailVC.m 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368
  1. #import "YOUPAIHRGuildCenterDetailVC.h"
  2. #import "YOUPAIHRGuildCenterDetailCell.h"
  3. #import "YOUPAIHRGuildCenterDetailHeaderView.h"
  4. #import "YOUPAIHRMembershipApplicationVC.h"
  5. #import "LZAlertWindow.h"
  6. #import "UIViewController+TFPresent.h"
  7. #import "UIScrollView+LZRefresh.h"
  8. #import "YOUPAIHRGuildCenterDetailModel.h"
  9. #import "YOUPAIApplyOutWindow.h"
  10. #import "YOUPAICancellationApplicationVC.h"
  11. @interface YOUPAIHRGuildCenterDetailVC ()<UITableViewDelegate,UITableViewDataSource>
  12. @property(nonatomic,strong)UITableView *youpaiptableView;
  13. @property (nonatomic, assign) NSInteger youpaippage;
  14. @property (nonatomic, strong) NSMutableArray *youpaipdataSource;
  15. @property(nonatomic,strong)YOUPAIHRGuildCenterDetailModel *youpaipmodel;
  16. @property(nonatomic,strong)YOUPAIHRGuildCenterDetailHeaderView *youpaipheaderView;
  17. @property(nonatomic,strong)UILabel *youpaipunReadView;
  18. @property(nonatomic,assign)NSInteger youpaipheaderViewHeight;
  19. @property(nonatomic,strong)UILabel *outpaipunReadView;
  20. @property(nonatomic,assign)BOOL isOut;
  21. @end
  22. @implementation YOUPAIHRGuildCenterDetailVC
  23. -(void)viewWillAppear:(BOOL)animated{
  24. [super viewWillAppear:animated];
  25. [self.youpaiptableView.mj_header beginRefreshing];
  26. }
  27. - (void)viewDidLoad {
  28. [super viewDidLoad];
  29. self.title = @"公会中心";
  30. [self youpaiptableView];
  31. if (self.youpaipguild == 2) {
  32. [self youpaifsetJoinGuildView];
  33. self.youpaipheaderViewHeight = 384;
  34. }else{
  35. [self youpaifsetRightBtn];
  36. self.youpaipheaderViewHeight = 384-70;
  37. }
  38. [self youpaifsetYoupaipheaderView];
  39. @weakify(self);
  40. [self.youpaiptableView setRefreshHeaderWithBlock:^{
  41. @strongify(self);
  42. [self youpaifrequestRankListWithStatus:kRefreshHeader];
  43. }];
  44. [self.youpaiptableView.mj_header beginRefreshing];
  45. }
  46. /// 设置加载更多
  47. - (void)youpaifrefreshFooterWithHidden:(BOOL)hidden{
  48. @weakify(self);
  49. [self.youpaiptableView setRefreshFooter:hidden withBlock:^{
  50. @strongify(self);
  51. [self youpaifrequestRankListWithStatus:kRefreshFooter];
  52. }];
  53. }
  54. - (void)youpaifrequestRankListWithStatus:(kRefreshStatus)status{
  55. if (status == kRefreshFooter) {
  56. self.youpaippage ++;
  57. }else{
  58. self.youpaippage = 1;
  59. }
  60. @weakify(self);
  61. [LCHttpHelper requestWithURLString:ChatRoom_guildCenter parameters:@{@"number":[NSString stringWithFormat:@"%d",15],@"page":@(self.youpaippage)} needToken:YES type:(HttpRequestTypePost) success:^(id responseObject) {
  62. @strongify(self);
  63. [self.youpaiptableView endRefreshing:kRefreshAll];
  64. NSDictionary* dict = (NSDictionary*)responseObject;
  65. NSInteger code = [[dict objectForKey:@"code"] integerValue];
  66. if (code == 0) {//成功
  67. if (status != kRefreshFooter) {
  68. [self.youpaipdataSource removeAllObjects];
  69. }
  70. NSDictionary *data = [dict objectForKey:@"data"];
  71. YOUPAIHRGuildCenterDetailModel *model = [YOUPAIHRGuildCenterDetailModel mj_objectWithKeyValues:data];
  72. self.youpaipmodel = model;
  73. NSArray *arr = model.list;
  74. [arr enumerateObjectsUsingBlock:^(id _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
  75. GuildMemberList *guildModel = obj;
  76. if (idx == 0&&self.youpaippage == 1) {
  77. guildModel.isHuiZ = YES;
  78. }
  79. [self.youpaipdataSource addObject:guildModel];
  80. }];
  81. self.isOut = model.quitStatus;
  82. [self.youpaipheaderView youpaifreloadHeaderViewWith:model];
  83. self.outpaipunReadView.text = [NSString stringWithFormat:@"%ld",(long)model.quitNumber];
  84. self.youpaipunReadView.text = [NSString stringWithFormat:@"%ld",(long)model.waitNumber];
  85. [self.youpaiptableView reloadData];
  86. NSInteger youpaiptotalPage = [data[@"guildMember"][@"total_page"] integerValue];
  87. [self youpaifrefreshFooterWithHidden:self.youpaippage >= youpaiptotalPage];
  88. if (self.youpaipdataSource.count != 0) {
  89. [self.youpaiptableView lz_hideEmptyView];
  90. }else{
  91. [self.youpaiptableView lz_showEmptyViewWithImage:[UIImage imageNamed:@"vqu_images_not_home_data"] content:@"暂无数据"];
  92. }
  93. }
  94. } failure:^(NSError *error) {
  95. @strongify(self);
  96. [self.youpaiptableView endRefreshing:kRefreshAll];
  97. }];
  98. }
  99. //入会申请
  100. -(void)youpaifsetJoinGuildView{
  101. UIView *JoinGuildBgView1 = [UIView new];
  102. [self.view addSubview:JoinGuildBgView1];
  103. [JoinGuildBgView1 mas_makeConstraints:^(MASConstraintMaker *make) {
  104. make.right.mas_equalTo(-20);
  105. make.bottom.mas_equalTo(-SafeHeight-20);
  106. make.size.mas_equalTo(CGSizeMake(90, 30+37.5));
  107. }];
  108. JoinGuildBgView1.backgroundColor = [UIColor clearColor];
  109. UIView *JoinGuildBgView = [UIView new];
  110. [JoinGuildBgView1 addSubview:JoinGuildBgView];
  111. [JoinGuildBgView mas_makeConstraints:^(MASConstraintMaker *make) {
  112. make.right.mas_equalTo(0);
  113. make.top.mas_equalTo(0);
  114. make.size.mas_equalTo(CGSizeMake(90, 30));
  115. }];
  116. JoinGuildBgView.backgroundColor = [UIColor clearColor];
  117. UIButton *joinGuildBtn = [UIButton new];
  118. [JoinGuildBgView addSubview:joinGuildBtn];
  119. [joinGuildBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  120. make.left.mas_equalTo(0);
  121. make.top.mas_equalTo(0);
  122. make.right.mas_equalTo(-10);
  123. make.bottom.mas_equalTo(0);
  124. }];
  125. [joinGuildBtn setTitle:@"入会申请" forState:UIControlStateNormal];
  126. [joinGuildBtn setTitleColor:HexColorFromRGB(0xFF6A1F) forState:UIControlStateNormal];
  127. joinGuildBtn.titleLabel.font = [UIFont systemFontOfSize:12];
  128. [joinGuildBtn setImage:[UIImage imageNamed:@"vqu_images_guild_ic_apply"] forState:UIControlStateNormal];
  129. joinGuildBtn.backgroundColor = [UIColor whiteColor];
  130. joinGuildBtn.layer.cornerRadius = 14.5;
  131. joinGuildBtn.layer.masksToBounds = YES;
  132. //未读数
  133. UILabel *youpaipunReadView = [UILabel new];
  134. self.youpaipunReadView = youpaipunReadView;
  135. [JoinGuildBgView addSubview:youpaipunReadView];
  136. [youpaipunReadView mas_makeConstraints:^(MASConstraintMaker *make) {
  137. make.left.mas_equalTo(joinGuildBtn.mas_right).offset(-7);
  138. make.top.mas_equalTo(joinGuildBtn);
  139. make.size.mas_equalTo(CGSizeMake(14, 14));
  140. }];
  141. youpaipunReadView.text = @"8";
  142. youpaipunReadView.font = [UIFont systemFontOfSize:10];
  143. youpaipunReadView.textColor = [UIColor whiteColor];
  144. youpaipunReadView.backgroundColor = HexColorFromRGB(0xF4003F);
  145. youpaipunReadView.layer.cornerRadius = 7;
  146. youpaipunReadView.layer.masksToBounds = YES;
  147. youpaipunReadView.textAlignment = NSTextAlignmentCenter;
  148. //事件
  149. [joinGuildBtn addTarget:self action:@selector(youpaifjoinGuildBtnClick) forControlEvents:UIControlEventTouchUpInside];
  150. //退会申请
  151. UIView *outGuildBgView = [UIView new];
  152. [JoinGuildBgView1 addSubview:outGuildBgView];
  153. [outGuildBgView mas_makeConstraints:^(MASConstraintMaker *make) {
  154. make.right.mas_equalTo(0);
  155. make.top.mas_equalTo(JoinGuildBgView.mas_bottom).offset(7.5);
  156. make.size.mas_equalTo(CGSizeMake(90, 30));
  157. }];
  158. outGuildBgView.backgroundColor = [UIColor clearColor];
  159. UIButton *outGuildBtn = [UIButton new];
  160. [outGuildBgView addSubview:outGuildBtn];
  161. [outGuildBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  162. make.left.mas_equalTo(0);
  163. make.top.mas_equalTo(0);
  164. make.right.mas_equalTo(-10);
  165. make.bottom.mas_equalTo(0);
  166. }];
  167. [outGuildBtn setTitle:@"退会申请" forState:UIControlStateNormal];
  168. [outGuildBtn setTitleColor:HexColorFromRGB(0xffffff) forState:UIControlStateNormal];
  169. outGuildBtn.titleLabel.font = [UIFont systemFontOfSize:12];
  170. [outGuildBtn setImage:[UIImage imageNamed:@"vqu_images_guild_ic_out"] forState:UIControlStateNormal];
  171. [outGuildBtn setBackgroundColor:[UIColor colorWithPatternImage:[LCTools ColorImage:CGSizeMake(80, 30) FromColors:@[HexColorFromRGB(0x75ECFF),HexColorFromRGB(0x40A1F7)] ByGradientType:1]]];
  172. outGuildBtn.layer.cornerRadius = 14.5;
  173. outGuildBtn.layer.masksToBounds = YES;
  174. //未读数
  175. UILabel *outpaipunReadView = [UILabel new];
  176. self.outpaipunReadView = outpaipunReadView;
  177. [outGuildBgView addSubview:outpaipunReadView];
  178. [outpaipunReadView mas_makeConstraints:^(MASConstraintMaker *make) {
  179. make.left.mas_equalTo(outGuildBtn.mas_right).offset(-7);
  180. make.top.mas_equalTo(outGuildBtn);
  181. make.size.mas_equalTo(CGSizeMake(14, 14));
  182. }];
  183. outpaipunReadView.text = @"8";
  184. outpaipunReadView.font = [UIFont systemFontOfSize:10];
  185. outpaipunReadView.textColor = [UIColor whiteColor];
  186. outpaipunReadView.backgroundColor = HexColorFromRGB(0xF4003F);
  187. outpaipunReadView.layer.cornerRadius = 7;
  188. outpaipunReadView.layer.masksToBounds = YES;
  189. outpaipunReadView.textAlignment = NSTextAlignmentCenter;
  190. //事件
  191. [outGuildBtn addTarget:self action:@selector(youpaifoutGuildBtnClick) forControlEvents:UIControlEventTouchUpInside];
  192. }
  193. #pragma mark 入会申请
  194. -(void)youpaifjoinGuildBtnClick{
  195. YOUPAIHRMembershipApplicationVC *vc = [YOUPAIHRMembershipApplicationVC new];
  196. [self.navigationController pushViewController:vc animated:YES];
  197. }
  198. //退会申请
  199. -(void)youpaifoutGuildBtnClick{
  200. YOUPAICancellationApplicationVC *vc = [YOUPAICancellationApplicationVC new];
  201. [self.navigationController pushViewController:vc animated:YES];
  202. }
  203. -(void)youpaifsetYoupaipheaderView{
  204. YOUPAIHRGuildCenterDetailHeaderView *headView = [[YOUPAIHRGuildCenterDetailHeaderView alloc]initWithFrame:CGRectMake(0, 0, KScreenWidth, self.youpaipheaderViewHeight)];
  205. self.youpaipheaderView = headView;
  206. headView.youpaipguild = self.youpaipguild;
  207. self.youpaiptableView.tableHeaderView = headView;
  208. }
  209. #pragma mark UITableViewDelegate&UITableViewDataSource
  210. -(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
  211. return 68;
  212. }
  213. -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
  214. return self.youpaipdataSource.count;
  215. }
  216. -(UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
  217. NSString *CellIdentifier = @"YOUPAIHRGuildCenterDetailCell";
  218. YOUPAIHRGuildCenterDetailCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];;
  219. if (cell == nil) {
  220. cell = [[YOUPAIHRGuildCenterDetailCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
  221. }
  222. [cell setSelectionStyle:UITableViewCellSelectionStyleNone];
  223. cell.backgroundColor = LCBkgColor;
  224. GuildMemberList *model = self.youpaipdataSource[indexPath.row];
  225. cell.youpaipmodel = model;
  226. return cell;
  227. }
  228. -(void)youpaifsetRightBtn{
  229. // 退出
  230. UIButton *rightBtn = [UIButton buttonWithType:(UIButtonTypeCustom)];
  231. rightBtn.frame = CGRectMake(0, 0, 44, 22);
  232. UIBarButtonItem *right = [[UIBarButtonItem alloc]initWithCustomView:rightBtn];
  233. [rightBtn setTitle:@"退出" forState:UIControlStateNormal];
  234. [rightBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
  235. [rightBtn addTarget:self action:@selector(youpaifbackAction) forControlEvents:(UIControlEventTouchUpInside)];
  236. self.navigationItem.rightBarButtonItem = right;
  237. [rightBtn setBackgroundColor:HexColorFromRGB(0x4F4B5B)];
  238. rightBtn.layer.cornerRadius = 11;
  239. rightBtn.layer.masksToBounds = YES;
  240. rightBtn.titleLabel.font = LCBoldFont(10);
  241. }
  242. -(void)youpaifbackAction{
  243. if (self.isOut) {
  244. LZAlertAction *cancelAction = [LZAlertAction actionWithTitle:@"取消" handler:^(LZAlertAction *action) {
  245. }];
  246. cancelAction.cornerRadius = 24.0f;
  247. cancelAction.color = LZ273145Color;
  248. cancelAction.bgColor = LZF5F4F7Color;
  249. // @weakify(self);
  250. LZAlertAction *confimAction = [LZAlertAction actionWithTitle:@"好的" handler:^(LZAlertAction *action) {
  251. // @strongify(self);
  252. // [self youpaifoutGuild];
  253. }];
  254. confimAction.cornerRadius = 24.0f;
  255. confimAction.color = [UIColor whiteColor];
  256. confimAction.bgColor = [UIColor colorWithPatternImage:[LCTools ColorImage:CGSizeMake((KScreenWidth - 105.0f), 48.0f) FromColors:@[LZBFB6FFColor,LZ7C69FEColor] ByGradientType:GradientLeftToRight]];
  257. LZAlertWindow *alert = [LZAlertWindow alertWithTitle:@"退会申请" content:[NSString stringWithFormat:@"已提交过申请,请等待会长处理"] action:@[confimAction]];
  258. alert.contentTextAlignment = NSTextAlignmentCenter;
  259. [self TFPresentVC:alert completion:^{}];
  260. }else{
  261. YOUPAIApplyOutWindow *applyOut = [YOUPAIApplyOutWindow new];
  262. applyOut.vWidth = KScreenWidth -68;
  263. applyOut.vHeight = ScaleHeight(247)+10;
  264. applyOut.isTouchDismiss = YES;
  265. @weakify(self);
  266. [applyOut setDidlickSureBlock:^(NSString * _Nonnull content) {
  267. @strongify(self);
  268. [LCHttpHelper requestWithURLString:ChatRoom_guildQuit parameters:@{@"content":content} needToken:YES type:(HttpRequestTypePost) success:^(id responseObject) {
  269. NSDictionary* dict = (NSDictionary*)responseObject;
  270. NSInteger code = [[dict objectForKey:@"code"] integerValue];
  271. if (code == 0) {//成功
  272. [ZCHUDHelper showTitle:@"操作成功"];
  273. [self.youpaiptableView.mj_header beginRefreshing];
  274. }
  275. } failure:^(NSError *error) {
  276. @strongify(self);
  277. [self.youpaiptableView endRefreshing:kRefreshAll];
  278. }];
  279. }];
  280. [self TFPresentVC:applyOut completion:^{
  281. }];
  282. }
  283. }
  284. //退出公会
  285. -(void)youpaifoutGuild{
  286. [LCHttpHelper requestWithURLString:ChatRoom_guildQuit parameters:nil needToken:YES type:(HttpRequestTypePost) success:^(id responseObject) {
  287. NSDictionary* dict = (NSDictionary*)responseObject;
  288. NSInteger code = [[dict objectForKey:@"code"] integerValue];
  289. if (code == 0) {//成功
  290. [self.navigationController popViewControllerAnimated:YES];
  291. }else{
  292. [ZCHUDHelper showTitle:dict[@"message"]];
  293. }
  294. } failure:^(NSError *error) {
  295. [self.youpaiptableView endRefreshing:kRefreshAll];
  296. }];
  297. }
  298. -(UITableView *)youpaiptableView{
  299. if (_youpaiptableView == nil) {
  300. _youpaiptableView = [[UITableView alloc]initWithFrame:CGRectZero style:UITableViewStylePlain];
  301. [self.view addSubview:_youpaiptableView];
  302. [_youpaiptableView mas_makeConstraints:^(MASConstraintMaker *make) {
  303. make.top.mas_equalTo(NavBarHeight);
  304. make.left.mas_equalTo(0);
  305. make.right.mas_equalTo(0);
  306. make.bottom.mas_equalTo(-SafeHeight);
  307. }];
  308. _youpaiptableView.delegate = self;
  309. _youpaiptableView.dataSource = self;
  310. _youpaiptableView.backgroundColor = [UIColor clearColor];
  311. _youpaiptableView.separatorStyle = UITableViewCellSeparatorStyleNone;
  312. _youpaiptableView.showsVerticalScrollIndicator = NO;
  313. _youpaiptableView.showsHorizontalScrollIndicator = NO;
  314. if (@available(iOS 15.0, *)) {
  315. _youpaiptableView.sectionHeaderTopPadding = 0;
  316. }
  317. }
  318. return _youpaiptableView;
  319. }
  320. -(NSMutableArray *)youpaipdataSource{
  321. if (_youpaipdataSource == nil) {
  322. _youpaipdataSource = [NSMutableArray new];
  323. }
  324. return _youpaipdataSource;
  325. }
  326. @end