TDGroupInfoDetailVC.m 28 KB

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