GroupSynopsisVC.m 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227
  1. //
  2. // GroupSynopsisVC.m
  3. // smartRhino
  4. //
  5. // Created by niuzhen on 2020/6/15.
  6. // Copyright © 2020 tederen. All rights reserved.
  7. //
  8. #import "GroupSynopsisVC.h"
  9. #import "GroupSynopsisCell.h"
  10. #import "TDGroupInfoListModel.h"
  11. #import "GroupVerifyVC.h"
  12. #import "TDGroupInfoListVC.h"
  13. #import "GroupSynopsisUserVC.h"
  14. #import "GroupInfoVC.h"
  15. @interface GroupSynopsisVC ()<UITableViewDelegate,UITableViewDataSource>
  16. @property (weak, nonatomic) IBOutlet UITableView *tableView;
  17. @property (weak, nonatomic) IBOutlet UIButton *joinBtn;
  18. @property (weak, nonatomic) IBOutlet NSLayoutConstraint *bottomContant;
  19. @property (strong,nonatomic) NSMutableArray *dataArray;
  20. @property (strong,nonatomic) TDGroupInfoListModel *model;
  21. @property (assign,nonatomic) BOOL show;
  22. @end
  23. @implementation GroupSynopsisVC
  24. +(GroupSynopsisVC *)initGroupSynopsisVC{
  25. GroupSynopsisVC *controller = [StoryboardManager.shared.Source instantiateViewControllerWithIdentifier:@"GroupSynopsisVC"];
  26. return controller;
  27. }
  28. - (NSMutableArray *)dataArray
  29. {
  30. if (!_dataArray) {
  31. _dataArray = [NSMutableArray array];
  32. }
  33. return _dataArray;
  34. }
  35. - (void)viewDidLoad {
  36. [super viewDidLoad];
  37. self.fd_prefersNavigationBarHidden = YES;
  38. self.tableView.delegate = self;
  39. self.tableView.dataSource = self;
  40. [self getData];
  41. if (self.GroupModel.IsApply) {
  42. [self setJoinStatus:1];
  43. }else{
  44. if (self.GroupModel.IsAdmin) {
  45. [self setJoinStatus:2];
  46. }else{
  47. [self setJoinStatus:3];
  48. }
  49. }
  50. [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(getData) name:GROUPINFOUPDATE object:nil];
  51. }
  52. - (void)dealloc
  53. {
  54. [[NSNotificationCenter defaultCenter] removeObserver:self];
  55. }
  56. - (void)setJoinStatus:(NSInteger)index
  57. {
  58. switch (index) {
  59. case 1:
  60. {
  61. [self.joinBtn setTitle:@"申请加入已提交,请等候小组管理员批准…" forState:UIControlStateNormal];
  62. [self.joinBtn setTitleColor:UIColorHex(0x878787) forState:UIControlStateNormal];
  63. self.joinBtn.backgroundColor = UIColorHex(0xE5E5E5);
  64. self.joinBtn.enabled = NO;
  65. }
  66. break;
  67. case 2:
  68. {
  69. [self.joinBtn setTitle:@"加入" forState:UIControlStateNormal];
  70. WS(weakSelf);
  71. [self.joinBtn setAction:^{
  72. GroupVerifyVC * vc = [GroupVerifyVC initGroupVerifyVC];
  73. vc.Id = weakSelf.GroupModel.Id;
  74. vc.SendBlock = ^{
  75. dispatch_async(dispatch_get_main_queue(), ^{
  76. [weakSelf showMessage];
  77. });
  78. if (weakSelf.SendBlock) {
  79. weakSelf.SendBlock();
  80. }
  81. [weakSelf setJoinStatus:1];
  82. };
  83. [weakSelf.navigationController pushViewController:vc animated:YES];
  84. }];
  85. }
  86. break;
  87. default:
  88. {
  89. [self.joinBtn setTitle:@"加入" forState:UIControlStateNormal];
  90. WS(weakSelf);
  91. [self.joinBtn setAction:^{
  92. NSDictionary * paraDict = @{@"GroupId":@(self.GroupModel.Id),
  93. @"UserIds":@[@([AppUserModel sharedAppUserModel].Id)],
  94. @"UserId":@([AppUserModel sharedAppUserModel].Id),
  95. @"SourceType":@(1),///申请
  96. };
  97. [[HttpManager sharedHttpManager] POSTUrl:Host(APP_Group_Insert_User) parameters:paraDict responseStyle:JOSN success:^(id _Nonnull responseObject) {
  98. weakSelf.joinBtn.hidden = YES;
  99. if (weakSelf.JoinBlock) {
  100. weakSelf.JoinBlock();
  101. }
  102. TDGroupInfoListVC * vc = [TDGroupInfoListVC initTDGroupInfoListVC];
  103. vc.GroupId = weakSelf.GroupModel.Id;
  104. vc.titleStr = weakSelf.GroupModel.Name;
  105. [weakSelf.navigationController pushViewController:vc animated:YES];
  106. } failure:^(NSError * _Nonnull error) {
  107. SHOWERROR([ZYCTool handerResultData:error]);
  108. }];
  109. }];
  110. }
  111. break;
  112. }
  113. }
  114. - (void)showMessage
  115. {
  116. WS(weakSelf);
  117. UIAlertController *alertVC = [UIAlertController alertControllerWithTitle:@"提示" message:@"您的申请已提交,请耐心等候!" preferredStyle:UIAlertControllerStyleAlert];
  118. UIAlertAction *noOk = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
  119. }];
  120. [noOk setValue:UIColorHex(0x0F7FD9) forKey:@"_titleTextColor"];
  121. [alertVC addAction:noOk];
  122. [weakSelf presentViewController:alertVC animated:YES completion:nil];
  123. }
  124. - (void)getData
  125. {
  126. WS(weakSelf);
  127. [[HttpManager sharedHttpManager] POSTUrl:Host(APP_Group_Detail) parameters:@{@"GroupId":@(self.GroupModel.Id)} responseStyle:JOSN success:^(id _Nonnull responseObject) {
  128. NSLog(@"%@",responseObject);
  129. weakSelf.model = [TDGroupInfoListModel modelWithDictionary:responseObject];
  130. [weakSelf.dataArray addObjectsFromArray:weakSelf.model.GroupUserListResult];
  131. dispatch_async(dispatch_get_main_queue(), ^{
  132. if (weakSelf.model.IsUser) {
  133. weakSelf.bottomContant.constant = 0.f;
  134. weakSelf.joinBtn.hidden = YES;
  135. }
  136. [weakSelf.tableView reloadData];
  137. });
  138. } failure:^(NSError * _Nonnull error) {
  139. }];
  140. }
  141. - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
  142. {
  143. return UITableViewAutomaticDimension;
  144. }
  145. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
  146. {
  147. return 4;
  148. }
  149. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
  150. {
  151. WS(weakSelf);
  152. switch (indexPath.row) {
  153. case 0:
  154. {
  155. GroupSynopsisCell * cell = [GroupSynopsisCell configCell3:tableView indexPath:indexPath];
  156. [cell setDataModel:self.model isShow:self.show];
  157. UITapGestureRecognizer * tap = [[UITapGestureRecognizer alloc] initWithActionBlock:^(id _Nonnull sender) {
  158. GroupInfoVC * vc = [GroupInfoVC initGroupInfoVC];
  159. vc.Id = weakSelf.GroupModel.Id;
  160. vc.GroupName = weakSelf.GroupModel.Name;
  161. vc.IsOwner = weakSelf.model.IsCreator;
  162. [weakSelf.navigationController pushViewController:vc animated:YES];
  163. }];
  164. [cell.contentL addGestureRecognizer:tap];
  165. cell.contentL.userInteractionEnabled = YES;
  166. cell.ShowBlcok = ^(BOOL show) {
  167. weakSelf.show = show;
  168. dispatch_async(dispatch_get_main_queue(), ^{
  169. [tableView reloadRowAtIndexPath:indexPath withRowAnimation:UITableViewRowAnimationAutomatic];
  170. });
  171. };
  172. return cell;
  173. }
  174. break;
  175. case 1:
  176. {
  177. GroupSynopsisCell * cell = [GroupSynopsisCell configCell0:tableView indexPath:indexPath];
  178. [cell setData:self.model];
  179. cell.ClickMoreBlcok = ^{
  180. NSLog(@"11111");
  181. };
  182. return cell;
  183. }
  184. break;
  185. case 2:
  186. {
  187. GroupSynopsisCell * cell = [GroupSynopsisCell configCell1:tableView indexPath:indexPath];
  188. [cell setUserCount:self.model.MainMemberCount];
  189. return cell;
  190. }
  191. break;
  192. default:
  193. {
  194. GroupSynopsisCell * cell = [GroupSynopsisCell configCell2:tableView indexPath:indexPath];
  195. [cell setGroupLabel:self.model.LabelName];
  196. return cell;
  197. }
  198. break;
  199. }
  200. }
  201. - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
  202. {
  203. [tableView deselectRowAtIndexPath:indexPath animated:YES];
  204. switch (indexPath.row) {
  205. case 2:
  206. {
  207. if (self.model.MainMemberListResult.count > 0) {
  208. GroupSynopsisUserVC * vc = [GroupSynopsisUserVC initGroupSynopsisUserVC];
  209. vc.dataArray = self.model.MainMemberListResult;
  210. [self.navigationController pushViewController:vc animated:YES];
  211. }
  212. }
  213. break;
  214. default:
  215. {
  216. }
  217. break;
  218. }
  219. }
  220. @end