TDGroupInfoDetailVC.m 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619
  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 "MyTDGroupView.h"
  11. #import "TDGroupInfoListModel.h"
  12. #import "TDGroupQrcodeVC.h"
  13. #import "TDGroupInfoChangeVc.h"
  14. #import "ChatGroupAddVC.h"
  15. #import "MailListDetailVC.h"
  16. #import "TDGroupRoleVC.h"
  17. #import "TDGroupLabelVC.h"
  18. @interface TDGroupInfoDetailVC ()<UITableViewDelegate,UITableViewDataSource>
  19. @property (weak, nonatomic) IBOutlet UITableView *tableView;
  20. @property (weak, nonatomic) IBOutlet UILabel *titleL;
  21. @property (weak, nonatomic) IBOutlet UIView *HeadView;
  22. @property (strong, nonatomic)NSMutableArray *dataArray;
  23. @property (strong, nonatomic) MyTDGroupView *SearchView;
  24. @property (strong, nonatomic)TDGroupInfoListModel *listModel;
  25. @end
  26. @implementation TDGroupInfoDetailVC
  27. +(TDGroupInfoDetailVC *)initTDGroupInfoDetailVC{
  28. TDGroupInfoDetailVC *controller = [StoryboardManager.shared.TDGroup instantiateViewControllerWithIdentifier:@"TDGroupInfoDetailVC"];
  29. return controller;
  30. }
  31. - (void)viewWillAppear:(BOOL)animated
  32. {
  33. [super viewWillAppear:animated];
  34. [self getData];
  35. }
  36. - (void)viewDidLoad {
  37. [super viewDidLoad];
  38. self.fd_prefersNavigationBarHidden = YES;
  39. [self.HeadView addSubview:self.SearchView];
  40. [self.SearchView mas_makeConstraints:^(MASConstraintMaker *make) {
  41. make.top.mas_offset(6);
  42. make.left.right.mas_equalTo(self.HeadView);
  43. make.height.mas_offset(36);
  44. }];
  45. [self.SearchView.button setAction: ^{
  46. NSLog(@"SearchView");
  47. }];
  48. self.tableView.delegate = self;
  49. self.tableView.dataSource = self;
  50. [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(showMessage) name:GROUPADDMESSAGE object:nil];
  51. }
  52. - (MyTDGroupView *)SearchView
  53. {
  54. if (!_SearchView) {
  55. _SearchView = [[MyTDGroupView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 36)];
  56. }
  57. return _SearchView;
  58. }
  59. - (void)getData
  60. {
  61. [self.dataArray removeAllObjects];
  62. WS(weakSelf);
  63. [[HttpManager sharedHttpManager] POSTUrl:Host(APP_Group_Detail) parameters:@{@"GroupId":@(self.GroupId)} responseStyle:JOSN success:^(id _Nonnull responseObject) {
  64. NSLog(@"%@",responseObject);
  65. weakSelf.listModel = [TDGroupInfoListModel modelWithDictionary:responseObject];
  66. weakSelf.dataArray = [NSMutableArray arrayWithArray:weakSelf.listModel.GroupUserListResult];
  67. if (weakSelf.upDateTitleBolck) {
  68. weakSelf.upDateTitleBolck(weakSelf.listModel.Name);
  69. }
  70. dispatch_async(dispatch_get_main_queue(), ^{
  71. [weakSelf.tableView reloadData];
  72. });
  73. } failure:^(NSError * _Nonnull error) {
  74. }];
  75. }
  76. - (NSMutableArray *)dataArray
  77. {
  78. if (!_dataArray) {
  79. _dataArray = [NSMutableArray array];
  80. }
  81. return _dataArray;
  82. }
  83. #pragma mark - UITableViewDelegate
  84. - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
  85. {
  86. return 2;
  87. }
  88. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
  89. {
  90. if (section == 0) {
  91. switch (self.listModel.GroupUserRoleId) {
  92. case 1:
  93. return 5;
  94. break;
  95. case 2:
  96. return 5;
  97. break;
  98. default:
  99. return 3;
  100. break;
  101. }
  102. }else{
  103. return self.dataArray.count;
  104. }
  105. }
  106. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
  107. {
  108. WS(weakSelf);
  109. if (indexPath.section == 0) {
  110. switch (self.listModel.GroupUserRoleId) {
  111. case 1:
  112. {
  113. switch (indexPath.row) {
  114. case 0:
  115. {
  116. TDGroupInfoDetailCell *cell = [TDGroupInfoDetailCell configCell0:tableView indexPath:indexPath];
  117. [cell.cell0ImgV sd_setImageWithURL:[NSURL URLWithString:self.listModel.AvatarUrl] placeholderImage:kUserDefaultHeadImage];
  118. cell.cell0TitleL.text = self.listModel.Name;
  119. return cell;
  120. }
  121. break;
  122. case 1:
  123. {
  124. TDGroupInfoDetailCell *cell = [TDGroupInfoDetailCell configCell1:tableView indexPath:indexPath];
  125. cell.cell1TitleL.text = @"小组信息";
  126. return cell;
  127. }
  128. break;
  129. case 2:
  130. {
  131. TDGroupInfoDetailCell *cell = [TDGroupInfoDetailCell configCell1:tableView indexPath:indexPath];
  132. cell.cell1TitleL.text = @"小组标签";
  133. return cell;
  134. }
  135. break;
  136. case 3:
  137. {
  138. TDGroupInfoDetailCell *cell = [TDGroupInfoDetailCell configCell1:tableView indexPath:indexPath];
  139. cell.cell1TitleL.text = @"小组权限";
  140. return cell;
  141. }
  142. break;
  143. default:
  144. {
  145. ChatGroupAddVC *vc = [[ChatGroupAddVC alloc] init];
  146. TDGroupInfoDetailCell *cell = [TDGroupInfoDetailCell configCell3:tableView indexPath:indexPath];
  147. cell.cell3TitleL.text = @"添加成员";
  148. [cell.cell3AddBtn setAction:^{
  149. Department *defaltGroupSetion = [[Department alloc]init];
  150. defaltGroupSetion.Name = @"单位通讯录";
  151. defaltGroupSetion.Id = 0;
  152. Department *myGroupSetion = [[Department alloc]init];
  153. myGroupSetion.Name = @"自建通讯录";
  154. defaltGroupSetion.Id = 0;
  155. vc.departSourceDataArray = @[defaltGroupSetion,myGroupSetion].mutableCopy;
  156. vc.isDefalutPage = 1;
  157. vc.type = AddGroupUser;
  158. vc.Id = weakSelf.listModel.Id;
  159. NSMutableArray * array = [NSMutableArray array];
  160. for (TDGroupInfoModel * model in self.dataArray) {
  161. SelectModel * smodel = [[SelectModel alloc] init];
  162. smodel.UserId = model.UserId;
  163. smodel.UserName = model.Name;
  164. [array addObject:smodel];
  165. }
  166. vc.grouperArray = array;
  167. [weakSelf.navigationController pushViewController:vc animated:YES];
  168. }];
  169. return cell;
  170. }
  171. break;
  172. }
  173. }
  174. break;
  175. case 2:
  176. {
  177. switch (indexPath.row) {
  178. case 0:
  179. {
  180. TDGroupInfoDetailCell *cell = [TDGroupInfoDetailCell configCell0:tableView indexPath:indexPath];
  181. [cell.cell0ImgV sd_setImageWithURL:[NSURL URLWithString:self.listModel.AvatarUrl] placeholderImage:kUserDefaultHeadImage];
  182. cell.cell0TitleL.text = self.listModel.Name;
  183. return cell;
  184. }
  185. break;
  186. case 1:
  187. {
  188. TDGroupInfoDetailCell *cell = [TDGroupInfoDetailCell configCell1:tableView indexPath:indexPath];
  189. cell.cell1TitleL.text = @"小组信息";
  190. return cell;
  191. }
  192. break;
  193. case 2:
  194. {
  195. TDGroupInfoDetailCell *cell = [TDGroupInfoDetailCell configCell1:tableView indexPath:indexPath];
  196. cell.cell1TitleL.text = @"小组标签";
  197. return cell;
  198. }
  199. break;
  200. case 3:
  201. {
  202. TDGroupInfoDetailCell *cell = [TDGroupInfoDetailCell configCell1:tableView indexPath:indexPath];
  203. cell.cell1TitleL.text = @"小组权限";
  204. return cell;
  205. }
  206. break;
  207. default:
  208. {
  209. TDGroupInfoDetailCell *cell = [TDGroupInfoDetailCell configCell3:tableView indexPath:indexPath];
  210. cell.cell3TitleL.text = @"添加成员";
  211. [cell.cell3AddBtn setAction:^{
  212. Department *defaltGroupSetion = [[Department alloc]init];
  213. defaltGroupSetion.Name = @"单位通讯录";
  214. defaltGroupSetion.Id = 0;
  215. Department *myGroupSetion = [[Department alloc]init];
  216. myGroupSetion.Name = @"自建通讯录";
  217. defaltGroupSetion.Id = 0;
  218. ChatGroupAddVC *vc = [[ChatGroupAddVC alloc] init];
  219. vc.departSourceDataArray = @[defaltGroupSetion,myGroupSetion].mutableCopy;
  220. vc.isDefalutPage = 1;
  221. vc.type = AddGroupUser;
  222. vc.Id = weakSelf.listModel.Id;
  223. NSMutableArray * array = [NSMutableArray array];
  224. for (TDGroupInfoModel * model in self.dataArray) {
  225. SelectModel * smodel = [[SelectModel alloc] init];
  226. smodel.UserId = model.UserId;
  227. smodel.UserName = model.Name;
  228. [array addObject:smodel];
  229. }
  230. vc.grouperArray = array;
  231. [weakSelf.navigationController pushViewController:vc animated:YES];
  232. }];
  233. return cell;
  234. }
  235. break;
  236. }
  237. }
  238. break;
  239. default:
  240. {
  241. switch (indexPath.row) {
  242. case 0:
  243. {
  244. TDGroupInfoDetailCell *cell = [TDGroupInfoDetailCell configCell0:tableView indexPath:indexPath];
  245. [cell.cell0ImgV sd_setImageWithURL:[NSURL URLWithString:self.listModel.AvatarUrl] placeholderImage:kUserDefaultHeadImage];
  246. cell.cell0TitleL.text = self.listModel.Name;
  247. return cell;
  248. }
  249. break;
  250. case 1:
  251. {
  252. TDGroupInfoDetailCell *cell = [TDGroupInfoDetailCell configCell1:tableView indexPath:indexPath];
  253. cell.cell1TitleL.text = @"小组信息";
  254. return cell;
  255. }
  256. break;
  257. default:
  258. {
  259. TDGroupInfoDetailCell *cell = [TDGroupInfoDetailCell configCell1:tableView indexPath:indexPath];
  260. cell.cell1TitleL.text = @"小组标签";
  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 = nil;
  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 0.01f;
  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 [UIView new];
  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. WS(weakSelf);
  336. if (indexPath.section == 0) {
  337. switch (indexPath.row) {
  338. case 0:
  339. {
  340. if (self.listModel.GroupUserRoleId == 1) {
  341. TDGroupInfoChangeVc * vc = [TDGroupInfoChangeVc initTDGroupInfoChangeVc];
  342. vc.model = self.listModel;
  343. [self.navigationController pushViewController:vc animated:YES];
  344. }
  345. }
  346. break;
  347. case 1:
  348. {
  349. TDGroupQrcodeVC * vc= [TDGroupQrcodeVC initTDGroupQrcodeVC];
  350. vc.isCreate = NO;
  351. vc.model = self.listModel;
  352. [self.navigationController pushViewController:vc animated:YES];
  353. }
  354. break;
  355. case 2:
  356. {
  357. TDGroupLabelVC * vc= [TDGroupLabelVC initTDGroupLabelVC];
  358. vc.labelName = self.listModel.LabelName;
  359. vc.Id = self.listModel.Id;
  360. vc.refreshBlock = ^{
  361. [weakSelf getData];
  362. };
  363. [self.navigationController pushViewController:vc animated:YES];
  364. }
  365. break;
  366. case 3:
  367. {
  368. TDGroupRoleVC * vc= [TDGroupRoleVC initTDGroupRoleVC];
  369. vc.model = self.listModel;
  370. vc.refreshBlock = ^{
  371. [weakSelf getData];
  372. };
  373. [self.navigationController pushViewController:vc animated:YES];
  374. }
  375. break;
  376. default:
  377. break;
  378. }
  379. }else{
  380. TDGroupInfoModel * model = [self.dataArray objectAtIndex:indexPath.row];
  381. MailListDetailVC *vc = [MailListDetailVC initMailListDetailVC];
  382. vc.indexId = model.UserId;
  383. [self.navigationController pushViewController:vc animated:YES];
  384. }
  385. }
  386. #pragma mark - UISwitch - event
  387. - (void)NeedAgree
  388. {
  389. WS(weakSelf);
  390. NSString * url = [NSString stringWithFormat:@"%@%ld",Host(APP_Group_Set_Admin),(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. - (void)AdminTalk
  399. {
  400. WS(weakSelf);
  401. NSString * url = [NSString stringWithFormat:@"%@%ld",Host(APP_Group_Set_Words),(long)self.listModel.Id];
  402. [[HttpManager sharedHttpManager] PUTUrl:url parameters:@{} responseStyle:DATA success:^(id _Nonnull responseObject) {
  403. dispatch_async(dispatch_get_main_queue(), ^{
  404. [weakSelf getData];
  405. });
  406. } failure:^(NSError * _Nonnull error) {
  407. }];
  408. }
  409. - (void)ChatEnabelChange
  410. {
  411. WS(weakSelf);
  412. NSString * url = [NSString stringWithFormat:@"%@%ld",Host(APP_Group_Set_Disturb),(long)self.listModel.Id];
  413. [[HttpManager sharedHttpManager] PUTUrl:url parameters:@{} responseStyle:DATA success:^(id _Nonnull responseObject) {
  414. dispatch_async(dispatch_get_main_queue(), ^{
  415. [weakSelf getData];
  416. });
  417. } failure:^(NSError * _Nonnull error) {
  418. }];
  419. }
  420. #pragma Mark 左滑按钮 iOS8以上
  421. #if __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_11_0
  422. - (UISwipeActionsConfiguration *)tableView:(UITableView *)tableView trailingSwipeActionsConfigurationForRowAtIndexPath:(NSIndexPath *)indexPath API_AVAILABLE(ios(11.0)) API_UNAVAILABLE(tvos){// delete action
  423. WS(weakSelf);
  424. if (indexPath.section > 0) {
  425. TDGroupInfoModel *model = [self.dataArray objectAtIndex:indexPath.row];
  426. switch (self.listModel.GroupUserRoleId) {
  427. case 1:{
  428. if (model.GroupUserRoleId != 1) {
  429. UIContextualAction *action1 = [UIContextualAction contextualActionWithStyle:UIContextualActionStyleDestructive title:@"删除" handler:^(UIContextualAction * _Nonnull action,__kindof UIView * _Nonnull sourceView,void (^ _Nonnull completionHandler)(BOOL)) {
  430. UIAlertController *alert = [UIAlertController alertControllerWithTitle:nil message:@"确认删除" preferredStyle:(UIAlertControllerStyleAlert)];
  431. UIAlertAction * sureAction = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDestructive handler:^(UIAlertAction * _Nonnull action) {
  432. [weakSelf deleteFind:model];
  433. }];
  434. UIAlertAction * cancelAction = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
  435. }];
  436. [alert addAction:sureAction];
  437. [alert addAction:cancelAction];
  438. [weakSelf presentViewController:alert animated:YES completion:^{
  439. }];
  440. }];
  441. action1.backgroundColor = UIColorHex(#F64A33);
  442. NSString * isAdmin = model.GroupUserRoleId == 2 ? @"取消管理员" : @"设为管理员";
  443. UIContextualAction *action2 = [UIContextualAction contextualActionWithStyle:UIContextualActionStyleDestructive title:isAdmin handler:^(UIContextualAction * _Nonnull action,__kindof UIView * _Nonnull sourceView,void (^ _Nonnull completionHandler)(BOOL)) {
  444. [weakSelf setRoleLevel:model];
  445. }];
  446. action2.backgroundColor = UIColorHex(#FF9503);
  447. UISwipeActionsConfiguration *actions = [UISwipeActionsConfiguration configurationWithActions:@[action1,action2]];
  448. actions.performsFirstActionWithFullSwipe = NO;
  449. return actions;
  450. }
  451. }break;
  452. case 2:{
  453. if (model.GroupUserRoleId == 3) {
  454. UIContextualAction *action1 = [UIContextualAction contextualActionWithStyle:UIContextualActionStyleDestructive title:@"删除" handler:^(UIContextualAction * _Nonnull action,__kindof UIView * _Nonnull sourceView,void (^ _Nonnull completionHandler)(BOOL)) {
  455. UIAlertController *alert = [UIAlertController alertControllerWithTitle:nil message:@"确认删除" preferredStyle:(UIAlertControllerStyleAlert)];
  456. UIAlertAction * sureAction = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDestructive handler:^(UIAlertAction * _Nonnull action) {
  457. [weakSelf deleteFind:@[model].mutableCopy];
  458. }];
  459. UIAlertAction * cancelAction = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
  460. }];
  461. [alert addAction:sureAction];
  462. [alert addAction:cancelAction];
  463. [weakSelf presentViewController:alert animated:YES completion:^{
  464. }];
  465. }];
  466. action1.backgroundColor = UIColorHex(#F64A33);
  467. UISwipeActionsConfiguration *actions = [UISwipeActionsConfiguration configurationWithActions:@[action1]];
  468. actions.performsFirstActionWithFullSwipe = NO;
  469. return actions;
  470. }
  471. }break;
  472. default:{
  473. UISwipeActionsConfiguration *actions = [UISwipeActionsConfiguration configurationWithActions:@[]];
  474. actions.performsFirstActionWithFullSwipe = NO;
  475. return actions;
  476. }
  477. }
  478. }
  479. UISwipeActionsConfiguration *actions = [UISwipeActionsConfiguration configurationWithActions:@[]];
  480. actions.performsFirstActionWithFullSwipe = NO;
  481. return actions;
  482. }
  483. #else
  484. - (NSArray<UITableViewRowAction *> *)tableView:(UITableView *)tableView editActionsForRowAtIndexPath:(NSIndexPath *)indexPath {
  485. WEAKSELF
  486. if (indexPath.section > 0) {
  487. TDGroupInfoModel *model = [self.dataArray objectAtIndex:indexPath.row];
  488. switch (self.listModel.GroupUserRoleId) {
  489. case 1:{
  490. if (model.GroupUserRoleId != 1) {
  491. UITableViewRowAction *action1 = [UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleDestructive title:@"删除" handler:^(UITableViewRowAction * _Nonnull action, NSIndexPath * _Nonnull indexPath) {
  492. [weakSelf deleteFind:model];
  493. }];
  494. action1.backgroundColor = UIColorHex(#FF3B2F);
  495. NSString * isAdmin = model.GroupUserRoleId == 2 ? @"取消管理员" : @"设为管理员";
  496. UITableViewRowAction *action2 = [UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleDestructive title:isAdmin handler:^(UITableViewRowAction * _Nonnull action, NSIndexPath * _Nonnull indexPath) {
  497. [weakSelf setRoleLevel:model];
  498. }];
  499. action2.backgroundColor = UIColorHex(#FF9503);
  500. return @[action1, action2];
  501. }else{
  502. return @[];
  503. }
  504. }break;
  505. case 2:{
  506. if (model.GroupUserRoleId == 3) {
  507. UITableViewRowAction *action1 = [UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleDestructive title:@"删除" handler:^(UITableViewRowAction * _Nonnull action, NSIndexPath * _Nonnull indexPath) {
  508. [weakSelf deleteFind:@[model].mutableCopy];
  509. }];
  510. action1.backgroundColor = UIColorHex(#FF3B2F);
  511. return @[action1];
  512. }else{
  513. return @[];
  514. }
  515. }break;
  516. default:{
  517. return @[];
  518. }
  519. }
  520. }else{
  521. return @[];
  522. }
  523. }
  524. #endif
  525. - (void)deleteFind:(TDGroupInfoModel *)model
  526. {
  527. WS(weakSelf);
  528. [[HttpManager sharedHttpManager] POSTUrl:Host(APP_Group_DELETE_User) parameters:@{@"GroupUserIds":@[@(model.UserId)],@"GroupId":@(self.listModel.Id)} responseStyle:DATA success:^(id _Nonnull responseObject) {
  529. SHOWSUCCESS(@"删除成功")
  530. dispatch_async(dispatch_get_main_queue(), ^{
  531. [weakSelf getData];
  532. });
  533. } failure:^(NSError * _Nonnull error) {
  534. }];
  535. }
  536. - (void)setRoleLevel:(TDGroupInfoModel *)model
  537. {
  538. NSInteger level = model.GroupUserRoleId == 2 ? 3 : 2;
  539. WS(weakSelf);
  540. [[HttpManager sharedHttpManager] POSTUrl:Host(APP_Group_Update_User) parameters:@{@"RoleId":@(level),@"Id":@(model.Id)} responseStyle:DATA success:^(id _Nonnull responseObject) {
  541. SHOWSUCCESS(@"设置成功")
  542. dispatch_async(dispatch_get_main_queue(), ^{
  543. [weakSelf getData];
  544. });
  545. } failure:^(NSError * _Nonnull error) {
  546. }];
  547. }
  548. /// 退出小组
  549. - (IBAction)qiutGroupAction:(id)sender {
  550. SHOWLOADING
  551. WEAKSELF
  552. NSString * url = [NSString stringWithFormat:@"%@%ld",Host(SaoYiSao3_Post),(long)self.GroupId];
  553. [[HttpManager sharedHttpManager] DeleteUrl:url parameters:@{} responseStyle:DATA success:^(id _Nonnull responseObject) {
  554. REMOVESHOW
  555. for ( int i = 0 ;i< weakSelf.navigationController.viewControllers.count;i++) {
  556. if ([weakSelf.navigationController.viewControllers[i] isKindOfClass:NSClassFromString(@"MyTDGroupViewController")]) {
  557. [weakSelf.navigationController popToViewController:weakSelf.navigationController.viewControllers[i] animated:YES];
  558. return;
  559. }
  560. }
  561. } failure:^(NSError * _Nonnull error) {
  562. SHOWERROR([ZYCTool handerResultData:error]);
  563. }];
  564. }
  565. - (IBAction)backAction:(id)sender {
  566. [super backAction:sender];
  567. }
  568. - (void)dealloc
  569. {
  570. [[NSNotificationCenter defaultCenter] removeObserver:self];
  571. }
  572. - (void)viewWillDisappear:(BOOL)animated
  573. {
  574. [super viewWillDisappear:animated];
  575. WKWebsiteDataStore *dateStore = [WKWebsiteDataStore defaultDataStore];
  576. [dateStore fetchDataRecordsOfTypes:[WKWebsiteDataStore allWebsiteDataTypes]
  577. completionHandler:^(NSArray * __nonnull records) {
  578. for (WKWebsiteDataRecord *record in records)
  579. {
  580. [[WKWebsiteDataStore defaultDataStore] removeDataOfTypes:record.dataTypes
  581. forDataRecords:@[record]
  582. completionHandler:^{
  583. NSLog(@"Cookies for %@ deleted successfully",record.displayName);
  584. }];
  585. }
  586. }];
  587. }
  588. - (void)showMessage
  589. {
  590. UIAlertController * alertController = [UIAlertController alertControllerWithTitle:@"需等待对方验证同意加入本小组" message:nil preferredStyle:UIAlertControllerStyleAlert];
  591. [alertController addAction:[UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) {
  592. }]];
  593. [self presentViewController:alertController animated:YES completion:nil];
  594. }
  595. @end