TDGroupInfoDetailVC.m 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598
  1. //
  2. // TDGroupInfoDetailVC.m
  3. // smartRhino
  4. //
  5. // Created by niuzhen on 2019/12/13.
  6. // Copyright © 2019 tederen. All rights reserved.
  7. //
  8. #import "TDGroupInfoDetailVC.h"
  9. #import "TDGroupInfoDetailCell.h"
  10. #import "createSearchBarView.h"
  11. #import "TDGroupInfoListModel.h"
  12. #import "TDGroupQrcodeVC.h"
  13. #import "TDGroupInfoChangeVc.h"
  14. #import "ChatGroupAddVC.h"
  15. #import "MailListDetailVC.h"
  16. @interface TDGroupInfoDetailVC ()<UITableViewDelegate,UITableViewDataSource>
  17. @property (weak, nonatomic) IBOutlet UITableView *tableView;
  18. @property (weak, nonatomic) IBOutlet UILabel *titleL;
  19. @property (strong, nonatomic)NSMutableArray * dataArray;
  20. @property (strong, nonatomic)TDGroupInfoListModel * listModel;
  21. @end
  22. @implementation TDGroupInfoDetailVC
  23. +(TDGroupInfoDetailVC *)initTDGroupInfoDetailVC{
  24. TDGroupInfoDetailVC *controller = [StoryboardManager.shared.TDGroup instantiateViewControllerWithIdentifier:@"TDGroupInfoDetailVC"];
  25. return controller;
  26. }
  27. - (void)viewWillAppear:(BOOL)animated
  28. {
  29. [super viewWillAppear:animated];
  30. [self getData];
  31. }
  32. - (void)viewDidLoad {
  33. [super viewDidLoad];
  34. self.fd_prefersNavigationBarHidden = YES;
  35. self.tableView.delegate = self;
  36. self.tableView.dataSource = self;
  37. [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(showMessage) name:GROUPADDMESSAGE object:nil];
  38. }
  39. - (void)getData
  40. {
  41. [self.dataArray removeAllObjects];
  42. WS(weakSelf);
  43. [[HttpManager sharedHttpManager] POSTUrl:Host(APP_Group_Detail) parameters:@{@"GroupId":@(self.GroupId)} responseStyle:JOSN success:^(id _Nonnull responseObject) {
  44. NSLog(@"%@",responseObject);
  45. weakSelf.listModel = [TDGroupInfoListModel modelWithDictionary:responseObject];
  46. [weakSelf.dataArray addObjectsFromArray: weakSelf.listModel.GroupUserListResult];
  47. if (weakSelf.upDateTitleBolck) {
  48. weakSelf.upDateTitleBolck(weakSelf.listModel.Name);
  49. }
  50. dispatch_async(dispatch_get_main_queue(), ^{
  51. [weakSelf.tableView reloadData];
  52. });
  53. } failure:^(NSError * _Nonnull error) {
  54. }];
  55. }
  56. - (NSMutableArray *)dataArray
  57. {
  58. if (!_dataArray) {
  59. _dataArray = [NSMutableArray array];
  60. }
  61. return _dataArray;
  62. }
  63. #pragma mark - UITableViewDelegate
  64. - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
  65. {
  66. return 2;
  67. }
  68. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
  69. {
  70. if (section == 0) {
  71. switch (self.listModel.GroupUserRoleId) {
  72. case 1:
  73. return 6;
  74. break;
  75. case 2:
  76. return 4;
  77. break;
  78. default:
  79. return 3;
  80. break;
  81. }
  82. }else{
  83. return self.dataArray.count;
  84. }
  85. }
  86. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
  87. {
  88. WS(weakSelf);
  89. if (indexPath.section == 0) {
  90. switch (self.listModel.GroupUserRoleId) {
  91. case 1:
  92. {
  93. switch (indexPath.row) {
  94. case 0:
  95. {
  96. TDGroupInfoDetailCell *cell = [TDGroupInfoDetailCell configCell0:tableView indexPath:indexPath];
  97. [cell.cell0ImgV sd_setImageWithURL:[NSURL URLWithString:self.listModel.AvatarUrl] placeholderImage:kUserDefaultHeadImage];
  98. cell.cell0TitleL.text = self.listModel.Name;
  99. return cell;
  100. }
  101. break;
  102. case 1:
  103. {
  104. TDGroupInfoDetailCell *cell = [TDGroupInfoDetailCell configCell1:tableView indexPath:indexPath];
  105. cell.cell1TitleL.text = @"小组二维码";
  106. return cell;
  107. }
  108. break;
  109. case 2:
  110. {
  111. TDGroupInfoDetailCell *cell = [TDGroupInfoDetailCell configCell2:tableView indexPath:indexPath];
  112. cell.cell2TitleL.text = @"加入小组需要管理员同意";
  113. [cell.cell2Switch setBlockForControlEvents:UIControlEventValueChanged block:^(id _Nonnull sender) {
  114. [weakSelf NeedAgree];
  115. }];
  116. [cell.cell2Switch setOn:self.listModel.IsAdmin];
  117. return cell;
  118. }
  119. break;
  120. case 3:
  121. {
  122. TDGroupInfoDetailCell *cell = [TDGroupInfoDetailCell configCell2:tableView indexPath:indexPath];
  123. cell.cell2TitleL.text = @"只允许管理员发话题(禁言)";
  124. [cell.cell2Switch setBlockForControlEvents:UIControlEventValueChanged block:^(id _Nonnull sender) {
  125. [weakSelf AdminTalk];
  126. }];
  127. [cell.cell2Switch setOn:self.listModel.IsWords];
  128. return cell;
  129. }
  130. break;
  131. case 4:
  132. {
  133. TDGroupInfoDetailCell *cell = [TDGroupInfoDetailCell configCell2:tableView indexPath:indexPath];
  134. cell.cell2TitleL.text = @"消息免打扰";
  135. [cell.cell2Switch setBlockForControlEvents:UIControlEventValueChanged block:^(id _Nonnull sender) {
  136. [weakSelf ChatEnabelChange];
  137. }];
  138. [cell.cell2Switch setOn:self.listModel.IsUDisturb];
  139. return cell;
  140. }
  141. break;
  142. default:
  143. {
  144. ChatGroupAddVC *vc = [[ChatGroupAddVC alloc] init];
  145. TDGroupInfoDetailCell *cell = [TDGroupInfoDetailCell configCell3:tableView indexPath:indexPath];
  146. cell.cell3TitleL.text = @"添加成员";
  147. [cell.cell3AddBtn setAction:^{
  148. Department *defaltGroupSetion = [[Department alloc]init];
  149. defaltGroupSetion.Name = @"单位通讯录";
  150. defaltGroupSetion.Id = 0;
  151. Department *myGroupSetion = [[Department alloc]init];
  152. myGroupSetion.Name = @"自建通讯录";
  153. defaltGroupSetion.Id = 0;
  154. vc.departSourceDataArray = @[defaltGroupSetion,myGroupSetion].mutableCopy;
  155. vc.isDefalutPage = 1;
  156. vc.type = AddGroupUser;
  157. vc.Id = weakSelf.listModel.Id;
  158. NSMutableArray * array = [NSMutableArray array];
  159. for (TDGroupInfoModel * model in self.dataArray) {
  160. SelectModel * smodel = [[SelectModel alloc] init];
  161. smodel.UserId = model.UserId;
  162. smodel.UserName = model.Name;
  163. [array addObject:smodel];
  164. }
  165. vc.grouperArray = array;
  166. [weakSelf.navigationController pushViewController:vc animated:YES];
  167. }];
  168. return cell;
  169. }
  170. break;
  171. }
  172. }
  173. break;
  174. case 2:
  175. {
  176. switch (indexPath.row) {
  177. case 0:
  178. {
  179. TDGroupInfoDetailCell *cell = [TDGroupInfoDetailCell configCell0:tableView indexPath:indexPath];
  180. [cell.cell0ImgV sd_setImageWithURL:[NSURL URLWithString:self.listModel.AvatarUrl] placeholderImage:kUserDefaultHeadImage];
  181. cell.cell0TitleL.text = self.listModel.Name;
  182. return cell;
  183. }
  184. break;
  185. case 1:
  186. {
  187. TDGroupInfoDetailCell *cell = [TDGroupInfoDetailCell configCell1:tableView indexPath:indexPath];
  188. cell.cell1TitleL.text = @"小组二维码";
  189. return cell;
  190. }
  191. break;
  192. case 2:
  193. {
  194. TDGroupInfoDetailCell *cell = [TDGroupInfoDetailCell configCell2:tableView indexPath:indexPath];
  195. cell.cell2TitleL.text = @"消息免打扰";
  196. [cell.cell2Switch setBlockForControlEvents:UIControlEventValueChanged block:^(id _Nonnull sender) {
  197. [weakSelf ChatEnabelChange];
  198. }];
  199. [cell.cell2Switch setOn:self.listModel.IsUDisturb];
  200. return cell;
  201. }
  202. break;
  203. default:
  204. {
  205. TDGroupInfoDetailCell *cell = [TDGroupInfoDetailCell configCell3:tableView indexPath:indexPath];
  206. cell.cell3TitleL.text = @"添加成员";
  207. [cell.cell3AddBtn setAction:^{
  208. Department *defaltGroupSetion = [[Department alloc]init];
  209. defaltGroupSetion.Name = @"单位通讯录";
  210. defaltGroupSetion.Id = 0;
  211. Department *myGroupSetion = [[Department alloc]init];
  212. myGroupSetion.Name = @"自建通讯录";
  213. defaltGroupSetion.Id = 0;
  214. ChatGroupAddVC *vc = [[ChatGroupAddVC alloc] init];
  215. vc.departSourceDataArray = @[defaltGroupSetion,myGroupSetion].mutableCopy;
  216. vc.isDefalutPage = 1;
  217. vc.type = AddGroupUser;
  218. vc.Id = weakSelf.listModel.Id;
  219. NSMutableArray * array = [NSMutableArray array];
  220. for (TDGroupInfoModel * model in self.dataArray) {
  221. SelectModel * smodel = [[SelectModel alloc] init];
  222. smodel.UserId = model.UserId;
  223. smodel.UserName = model.Name;
  224. [array addObject:smodel];
  225. }
  226. vc.grouperArray = array;
  227. [weakSelf.navigationController pushViewController:vc animated:YES];
  228. }];
  229. return cell;
  230. }
  231. break;
  232. }
  233. }
  234. break;
  235. default:
  236. {
  237. switch (indexPath.row) {
  238. case 0:
  239. {
  240. TDGroupInfoDetailCell *cell = [TDGroupInfoDetailCell configCell0:tableView indexPath:indexPath];
  241. [cell.cell0ImgV sd_setImageWithURL:[NSURL URLWithString:self.listModel.AvatarUrl] placeholderImage:kUserDefaultHeadImage];
  242. cell.cell0TitleL.text = self.listModel.Name;
  243. return cell;
  244. }
  245. break;
  246. case 1:
  247. {
  248. TDGroupInfoDetailCell *cell = [TDGroupInfoDetailCell configCell1:tableView indexPath:indexPath];
  249. cell.cell1TitleL.text = @"小组二维码";
  250. return cell;
  251. }
  252. break;
  253. default:
  254. {
  255. TDGroupInfoDetailCell *cell = [TDGroupInfoDetailCell configCell2:tableView indexPath:indexPath];
  256. cell.cell2TitleL.text = @"消息免打扰";
  257. [cell.cell2Switch setBlockForControlEvents:UIControlEventValueChanged block:^(id _Nonnull sender) {
  258. [weakSelf ChatEnabelChange];
  259. }];
  260. [cell.cell2Switch setOn:self.listModel.IsUDisturb];
  261. return cell;
  262. }
  263. break;
  264. }
  265. }
  266. break;
  267. }
  268. }else{
  269. TDGroupInfoModel * model = [self.dataArray objectAtIndex:indexPath.row];
  270. TDGroupInfoDetailCell *cell = [TDGroupInfoDetailCell configCell4:tableView indexPath:indexPath];
  271. [cell.cell4imgV sd_setImageWithURL:[NSURL URLWithString:model.AvatarUrl] placeholderImage:kUserDefaultHeadImage];
  272. cell.cell4NameL.text = model.Name;
  273. switch (model.GroupUserRoleId) {
  274. case 1:
  275. {
  276. cell.cell4LevelL.hidden = NO;
  277. cell.cell4LevelL.text = @"创建者";
  278. cell.cell4LevelL.backgroundColor = UIColorHex(#3979D3);
  279. }
  280. break;
  281. case 2:
  282. {
  283. cell.cell4LevelL.hidden = NO;
  284. cell.cell4LevelL.text = @"管理员";
  285. cell.cell4LevelL.backgroundColor = UIColorHex(#FF9503);
  286. }
  287. break;
  288. default:
  289. {
  290. cell.cell4LevelL.hidden = YES;
  291. }
  292. break;
  293. }
  294. cell.cell4subL.text = model.DepartmentName;
  295. cell.cell4TimeL.text = @"2019-11-14";
  296. return cell;
  297. }
  298. }
  299. - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
  300. {
  301. return 65.f;
  302. }
  303. - (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
  304. {
  305. if (section == 0) {
  306. return 50.f;
  307. }
  308. return 35.f;
  309. }
  310. - (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
  311. {
  312. return 0.01f;
  313. }
  314. - (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
  315. {
  316. if (section == 0) {
  317. return [[createSearchBarView alloc] init];
  318. }else{
  319. UIView * view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 35)];
  320. view.backgroundColor = UIColorHex(#F0EFF4);
  321. UILabel * label = [UILabel new];
  322. NSString * str = [NSString stringWithFormat:@"成员:%ld人,话题:%ld",(long)self.listModel.GroupUserNumber,(long)self.listModel.GroupTopicNumber];
  323. NSMutableAttributedString *string = [[NSMutableAttributedString alloc] initWithString:str attributes:@{NSFontAttributeName: [UIFont fontWithName:@"PingFang SC" size: 13],NSForegroundColorAttributeName : UIColorHex(#666666)}];
  324. label.attributedText = string;
  325. [view addSubview:label];
  326. [label mas_makeConstraints:^(MASConstraintMaker *make) {
  327. make.left.mas_offset(@15);
  328. make.centerY.mas_equalTo(view);
  329. }];
  330. return view;
  331. }
  332. }
  333. - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
  334. {
  335. if (indexPath.section == 0) {
  336. switch (indexPath.row) {
  337. case 0:
  338. {
  339. if (self.listModel.GroupUserRoleId == 1) {
  340. TDGroupInfoChangeVc * vc = [TDGroupInfoChangeVc initTDGroupInfoChangeVc];
  341. vc.model = self.listModel;
  342. [self.navigationController pushViewController:vc animated:YES];
  343. }
  344. }
  345. break;
  346. case 1:
  347. {
  348. TDGroupQrcodeVC * vc= [TDGroupQrcodeVC initTDGroupQrcodeVC];
  349. vc.isCreate = NO;
  350. vc.model = self.listModel;
  351. [self.navigationController pushViewController:vc animated:YES];
  352. }
  353. break;
  354. default:
  355. break;
  356. }
  357. }else{
  358. TDGroupInfoModel * model = [self.dataArray objectAtIndex:indexPath.row];
  359. MailListDetailVC *vc = [MailListDetailVC initMailListDetailVC];
  360. vc.indexId = model.UserId;
  361. [self.navigationController pushViewController:vc animated:YES];
  362. }
  363. }
  364. #pragma mark - UISwitch - event
  365. - (void)NeedAgree
  366. {
  367. WS(weakSelf);
  368. NSString * url = [NSString stringWithFormat:@"%@%ld",Host(APP_Group_Set_Admin),(long)self.listModel.Id];
  369. [[HttpManager sharedHttpManager] PUTUrl:url parameters:@{} responseStyle:DATA success:^(id _Nonnull responseObject) {
  370. dispatch_async(dispatch_get_main_queue(), ^{
  371. [weakSelf getData];
  372. });
  373. } failure:^(NSError * _Nonnull error) {
  374. }];
  375. }
  376. - (void)AdminTalk
  377. {
  378. WS(weakSelf);
  379. NSString * url = [NSString stringWithFormat:@"%@%ld",Host(APP_Group_Set_Words),(long)self.listModel.Id];
  380. [[HttpManager sharedHttpManager] PUTUrl:url parameters:@{} responseStyle:DATA success:^(id _Nonnull responseObject) {
  381. dispatch_async(dispatch_get_main_queue(), ^{
  382. [weakSelf getData];
  383. });
  384. } failure:^(NSError * _Nonnull error) {
  385. }];
  386. }
  387. - (void)ChatEnabelChange
  388. {
  389. WS(weakSelf);
  390. NSString * url = [NSString stringWithFormat:@"%@%ld",Host(APP_Group_Set_Disturb),(long)self.listModel.Id];
  391. [[HttpManager sharedHttpManager] PUTUrl:url parameters:@{} responseStyle:DATA success:^(id _Nonnull responseObject) {
  392. dispatch_async(dispatch_get_main_queue(), ^{
  393. [weakSelf getData];
  394. });
  395. } failure:^(NSError * _Nonnull error) {
  396. }];
  397. }
  398. #pragma Mark 左滑按钮 iOS8以上
  399. #if __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_11_0
  400. - (UISwipeActionsConfiguration *)tableView:(UITableView *)tableView trailingSwipeActionsConfigurationForRowAtIndexPath:(NSIndexPath *)indexPath API_AVAILABLE(ios(11.0)) API_UNAVAILABLE(tvos){// delete action
  401. WS(weakSelf);
  402. if (indexPath.section > 0) {
  403. TDGroupInfoModel *model = [self.dataArray objectAtIndex:indexPath.row];
  404. switch (self.listModel.GroupUserRoleId) {
  405. case 1:{
  406. if (model.GroupUserRoleId != 1) {
  407. UIContextualAction *action1 = [UIContextualAction contextualActionWithStyle:UIContextualActionStyleDestructive title:@"删除" handler:^(UIContextualAction * _Nonnull action,__kindof UIView * _Nonnull sourceView,void (^ _Nonnull completionHandler)(BOOL)) {
  408. UIAlertController *alert = [UIAlertController alertControllerWithTitle:nil message:@"确认删除" preferredStyle:(UIAlertControllerStyleAlert)];
  409. UIAlertAction * sureAction = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDestructive handler:^(UIAlertAction * _Nonnull action) {
  410. [weakSelf deleteFind:model];
  411. }];
  412. UIAlertAction * cancelAction = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
  413. }];
  414. [alert addAction:sureAction];
  415. [alert addAction:cancelAction];
  416. [weakSelf presentViewController:alert animated:YES completion:^{
  417. }];
  418. }];
  419. action1.backgroundColor = UIColorHex(#F64A33);
  420. NSString * isAdmin = model.GroupUserRoleId == 2 ? @"取消管理员" : @"设为管理员";
  421. UIContextualAction *action2 = [UIContextualAction contextualActionWithStyle:UIContextualActionStyleDestructive title:isAdmin handler:^(UIContextualAction * _Nonnull action,__kindof UIView * _Nonnull sourceView,void (^ _Nonnull completionHandler)(BOOL)) {
  422. [weakSelf setRoleLevel:model];
  423. }];
  424. action2.backgroundColor = UIColorHex(#FF9503);
  425. UISwipeActionsConfiguration *actions = [UISwipeActionsConfiguration configurationWithActions:@[action1,action2]];
  426. actions.performsFirstActionWithFullSwipe = NO;
  427. return actions;
  428. }
  429. }break;
  430. case 2:{
  431. if (model.GroupUserRoleId == 3) {
  432. UIContextualAction *action1 = [UIContextualAction contextualActionWithStyle:UIContextualActionStyleDestructive title:@"删除" handler:^(UIContextualAction * _Nonnull action,__kindof UIView * _Nonnull sourceView,void (^ _Nonnull completionHandler)(BOOL)) {
  433. UIAlertController *alert = [UIAlertController alertControllerWithTitle:nil message:@"确认删除" preferredStyle:(UIAlertControllerStyleAlert)];
  434. UIAlertAction * sureAction = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDestructive handler:^(UIAlertAction * _Nonnull action) {
  435. [weakSelf deleteFind:@[model].mutableCopy];
  436. }];
  437. UIAlertAction * cancelAction = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
  438. }];
  439. [alert addAction:sureAction];
  440. [alert addAction:cancelAction];
  441. [weakSelf presentViewController:alert animated:YES completion:^{
  442. }];
  443. }];
  444. action1.backgroundColor = UIColorHex(#F64A33);
  445. UISwipeActionsConfiguration *actions = [UISwipeActionsConfiguration configurationWithActions:@[action1]];
  446. actions.performsFirstActionWithFullSwipe = NO;
  447. return actions;
  448. }
  449. }break;
  450. default:{
  451. UISwipeActionsConfiguration *actions = [UISwipeActionsConfiguration configurationWithActions:@[]];
  452. actions.performsFirstActionWithFullSwipe = NO;
  453. return actions;
  454. }
  455. }
  456. }
  457. UISwipeActionsConfiguration *actions = [UISwipeActionsConfiguration configurationWithActions:@[]];
  458. actions.performsFirstActionWithFullSwipe = NO;
  459. return actions;
  460. }
  461. #else
  462. - (NSArray<UITableViewRowAction *> *)tableView:(UITableView *)tableView editActionsForRowAtIndexPath:(NSIndexPath *)indexPath {
  463. WEAKSELF
  464. if (indexPath.section > 0) {
  465. TDGroupInfoModel *model = [self.dataArray objectAtIndex:indexPath.row];
  466. switch (self.listModel.GroupUserRoleId) {
  467. case 1:{
  468. if (model.GroupUserRoleId != 1) {
  469. UITableViewRowAction *action1 = [UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleDestructive title:@"删除" handler:^(UITableViewRowAction * _Nonnull action, NSIndexPath * _Nonnull indexPath) {
  470. [weakSelf deleteFind:model];
  471. }];
  472. action1.backgroundColor = UIColorHex(#FF3B2F);
  473. NSString * isAdmin = model.GroupUserRoleId == 2 ? @"取消管理员" : @"设为管理员";
  474. UITableViewRowAction *action2 = [UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleDestructive title:isAdmin handler:^(UITableViewRowAction * _Nonnull action, NSIndexPath * _Nonnull indexPath) {
  475. [weakSelf setRoleLevel:model];
  476. }];
  477. action2.backgroundColor = UIColorHex(#FF9503);
  478. return @[action1, action2];
  479. }else{
  480. return @[];
  481. }
  482. }break;
  483. case 2:{
  484. if (model.GroupUserRoleId == 3) {
  485. UITableViewRowAction *action1 = [UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleDestructive title:@"删除" handler:^(UITableViewRowAction * _Nonnull action, NSIndexPath * _Nonnull indexPath) {
  486. [weakSelf deleteFind:@[model].mutableCopy];
  487. }];
  488. action1.backgroundColor = UIColorHex(#FF3B2F);
  489. return @[action1];
  490. }else{
  491. return @[];
  492. }
  493. }break;
  494. default:{
  495. return @[];
  496. }
  497. }
  498. }else{
  499. return @[];
  500. }
  501. }
  502. #endif
  503. - (void)deleteFind:(TDGroupInfoModel *)model
  504. {
  505. WS(weakSelf);
  506. [[HttpManager sharedHttpManager] POSTUrl:Host(APP_Group_DELETE_User) parameters:@{@"GroupUserIds":@[@(model.UserId)],@"GroupId":@(self.listModel.Id)} responseStyle:DATA success:^(id _Nonnull responseObject) {
  507. SHOWSUCCESS(@"删除成功")
  508. dispatch_async(dispatch_get_main_queue(), ^{
  509. [weakSelf getData];
  510. });
  511. } failure:^(NSError * _Nonnull error) {
  512. }];
  513. }
  514. - (void)setRoleLevel:(TDGroupInfoModel *)model
  515. {
  516. NSInteger level = model.GroupUserRoleId == 2 ? 3 : 2;
  517. WS(weakSelf);
  518. [[HttpManager sharedHttpManager] POSTUrl:Host(APP_Group_Update_User) parameters:@{@"RoleId":@(level),@"Id":@(model.Id)} responseStyle:DATA success:^(id _Nonnull responseObject) {
  519. SHOWSUCCESS(@"设置成功")
  520. dispatch_async(dispatch_get_main_queue(), ^{
  521. [weakSelf getData];
  522. });
  523. } failure:^(NSError * _Nonnull error) {
  524. }];
  525. }
  526. /// 退出小组
  527. - (IBAction)qiutGroupAction:(id)sender {
  528. SHOWLOADING
  529. WEAKSELF
  530. NSString * url = [NSString stringWithFormat:@"%@%ld",Host(SaoYiSao3_Post),(long)self.GroupId];
  531. [[HttpManager sharedHttpManager] DeleteUrl:url parameters:@{} responseStyle:DATA success:^(id _Nonnull responseObject) {
  532. REMOVESHOW
  533. for ( int i = 0 ;i< weakSelf.navigationController.viewControllers.count;i++) {
  534. if ([weakSelf.navigationController.viewControllers[i] isKindOfClass:NSClassFromString(@"MyTDGroupViewController")]) {
  535. [weakSelf.navigationController popToViewController:weakSelf.navigationController.viewControllers[i] animated:YES];
  536. return;
  537. }
  538. }
  539. } failure:^(NSError * _Nonnull error) {
  540. SHOWERROR([ZYCTool handerResultData:error]);
  541. }];
  542. }
  543. - (IBAction)backAction:(id)sender {
  544. [super backAction:sender];
  545. }
  546. - (void)dealloc
  547. {
  548. [[NSNotificationCenter defaultCenter] removeObserver:self];
  549. }
  550. - (void)viewWillDisappear:(BOOL)animated
  551. {
  552. [super viewWillDisappear:animated];
  553. WKWebsiteDataStore *dateStore = [WKWebsiteDataStore defaultDataStore];
  554. [dateStore fetchDataRecordsOfTypes:[WKWebsiteDataStore allWebsiteDataTypes]
  555. completionHandler:^(NSArray * __nonnull records) {
  556. for (WKWebsiteDataRecord *record in records)
  557. {
  558. [[WKWebsiteDataStore defaultDataStore] removeDataOfTypes:record.dataTypes
  559. forDataRecords:@[record]
  560. completionHandler:^{
  561. NSLog(@"Cookies for %@ deleted successfully",record.displayName);
  562. }];
  563. }
  564. }];
  565. }
  566. - (void)showMessage
  567. {
  568. UIAlertController * alertController = [UIAlertController alertControllerWithTitle:@"需等待对方验证同意加入本小组" message:nil preferredStyle:UIAlertControllerStyleAlert];
  569. [alertController addAction:[UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) {
  570. }]];
  571. [self presentViewController:alertController animated:YES completion:nil];
  572. }
  573. @end