TDGroupRoleVC.m 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  1. //
  2. // TDGroupRoleVC.m
  3. // smartRhino
  4. //
  5. // Created by niuzhen on 2020/5/8.
  6. // Copyright © 2020 tederen. All rights reserved.
  7. //
  8. #import "TDGroupRoleVC.h"
  9. #import "TDGroupInfoDetailCell.h"
  10. #import "MOFSPickerManager.h"
  11. #import "GroupSquareModel.h"
  12. @interface TDGroupRoleVC ()<UITableViewDelegate,UITableViewDataSource>
  13. @property (weak, nonatomic) IBOutlet UITableView *tableView;
  14. @property (nonatomic, strong) NSMutableArray * dataArray;
  15. @property (nonatomic, strong) NSMutableArray * showArray;
  16. @end
  17. @implementation TDGroupRoleVC
  18. +(TDGroupRoleVC *)initTDGroupRoleVC{
  19. TDGroupRoleVC *controller = [StoryboardManager.shared.TDGroup instantiateViewControllerWithIdentifier:@"TDGroupRoleVC"];
  20. return controller;
  21. }
  22. - (void)viewDidLoad {
  23. [super viewDidLoad];
  24. self.fd_prefersNavigationBarHidden = YES;
  25. self.view.backgroundColor = UIColorHex(0xF1F1F1);
  26. self.tableView.delegate = self;
  27. self.tableView.dataSource = self;
  28. [self getData];
  29. }
  30. - (void)getData
  31. {
  32. WS(weakSelf);
  33. self.dataArray = [NSMutableArray array];
  34. self.showArray = [NSMutableArray array];
  35. SHOWLOADING
  36. NSString * url = [NSString stringWithFormat:@"%@%@",Host(API_APP_GROUP_Group_Category),@"0"];
  37. [[HttpManager sharedHttpManager] GET:url parameters:@{} success:^(NSURLSessionDataTask * _Nonnull task, id _Nullable responseObject) {
  38. NSLog(@"%@",responseObject);
  39. REMOVESHOW
  40. if ([responseObject isKindOfClass:[NSArray class]]) {
  41. for (NSDictionary * dict in responseObject) {
  42. GroupSquareModel * model = [GroupSquareModel modelWithDictionary:dict];
  43. [weakSelf.dataArray addObject:model];
  44. [weakSelf.showArray addObject:model.PiazzaName];
  45. }
  46. }
  47. } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
  48. REMOVESHOW
  49. }];
  50. }
  51. - (void)showType
  52. {
  53. WS(weakSelf);
  54. [MOFSPickerManager shareManger].pickView.toolBar.cancelBar.textColor = UIColorHex(#888888);
  55. [MOFSPickerManager shareManger].pickView.toolBar.commitBar.textColor = UIColorHex(#3979D3);
  56. MOFSPickerManager *manager = [[MOFSPickerManager alloc] init];
  57. [manager showPickerViewWithDataArray:self.showArray tag:2 title:nil cancelTitle:@"取消" commitTitle:@"确定" commitBlock:^(NSString *string) {
  58. for (GroupSquareModel * model in weakSelf.dataArray) {
  59. if ([model.PiazzaName isEqualToString:string]) {
  60. weakSelf.model.CategroyName = string;
  61. [[HttpManager sharedHttpManager] POSTUrl:Host(APP_Group_Update) parameters:@{@"GroupCategroyId":@(model.Id),@"Id":@(weakSelf.model.Id)} responseStyle:DATA success:^(id _Nonnull responseObject) {
  62. dispatch_async(dispatch_get_main_queue(), ^{
  63. [weakSelf.tableView reloadData];
  64. });
  65. } failure:^(NSError * _Nonnull error) {
  66. SHOWERROR([ZYCTool handerResultData:error]);
  67. }];
  68. }
  69. }
  70. } cancelBlock:^{
  71. }];
  72. }
  73. #pragma mark - UITableViewDelegate
  74. - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
  75. {
  76. return 1;
  77. }
  78. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
  79. {
  80. return 4;
  81. }
  82. - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
  83. {
  84. return 65.f;
  85. }
  86. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
  87. {
  88. WS(weakSelf);
  89. switch (indexPath.row) {
  90. case 0:
  91. {
  92. TDGroupInfoDetailCell *cell = [TDGroupInfoDetailCell configCell2:tableView indexPath:indexPath];
  93. cell.cell2TitleL.text = @"加入小组需要管理员同意";
  94. [cell.cell2Switch setBlockForControlEvents:UIControlEventValueChanged block:^(id _Nonnull sender) {
  95. [[HttpManager sharedHttpManager] POSTUrl:Host(APP_Group_Update) parameters:@{@"IsAdmin":cell.cell2Switch.isOn ? @(1) : @(2),@"Id":@(weakSelf.model.Id)} responseStyle:DATA success:^(id _Nonnull responseObject) {
  96. if (weakSelf.refreshBlock) {
  97. weakSelf.refreshBlock();
  98. }
  99. } failure:^(NSError * _Nonnull error) {
  100. SHOWERROR([ZYCTool handerResultData:error]);
  101. }];
  102. }];
  103. [cell.cell2Switch setOn:self.model.IsAdmin];
  104. return cell;
  105. }
  106. break;
  107. case 1:
  108. {
  109. TDGroupInfoDetailCell *cell = [TDGroupInfoDetailCell configCell2:tableView indexPath:indexPath];
  110. cell.cell2TitleL.text = @"只允许管理员发话题(禁言)";
  111. [cell.cell2Switch setBlockForControlEvents:UIControlEventValueChanged block:^(id _Nonnull sender) {
  112. [[HttpManager sharedHttpManager] POSTUrl:Host(APP_Group_Update) parameters:@{@"IsWords":cell.cell2Switch.isOn ? @"1" : @"2",@"Id":@(weakSelf.model.Id)} responseStyle:DATA success:^(id _Nonnull responseObject) {
  113. if (weakSelf.refreshBlock) {
  114. weakSelf.refreshBlock();
  115. }
  116. } failure:^(NSError * _Nonnull error) {
  117. SHOWERROR([ZYCTool handerResultData:error]);
  118. }];
  119. }];
  120. [cell.cell2Switch setOn:self.model.IsWords];
  121. return cell;
  122. }
  123. break;
  124. case 2:
  125. {
  126. TDGroupInfoDetailCell *cell = [TDGroupInfoDetailCell configCell2:tableView indexPath:indexPath];
  127. cell.cell2TitleL.text = @"小组广场可见";
  128. [cell.cell2Switch setBlockForControlEvents:UIControlEventValueChanged block:^(id _Nonnull sender) {
  129. [[HttpManager sharedHttpManager] POSTUrl:Host(APP_Group_Update) parameters:@{@"IsShow":cell.cell2Switch.isOn ? @"1" : @"2",@"Id":@(weakSelf.model.Id)} responseStyle:DATA success:^(id _Nonnull responseObject) {
  130. if (weakSelf.refreshBlock) {
  131. weakSelf.refreshBlock();
  132. }
  133. } failure:^(NSError * _Nonnull error) {
  134. SHOWERROR([ZYCTool handerResultData:error]);
  135. }];
  136. }];
  137. [cell.cell2Switch setOn:self.model.IsShow];
  138. return cell;
  139. }
  140. break;
  141. default:
  142. {
  143. TDGroupInfoDetailCell *cell = [TDGroupInfoDetailCell configCell1:tableView indexPath:indexPath];
  144. cell.cell1TitleL.text = @"小组类型";
  145. cell.subTitleL.hidden = NO;
  146. cell.subTitleL.text = self.model.CategroyName;
  147. return cell;
  148. }
  149. break;
  150. }
  151. }
  152. - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
  153. {
  154. if (indexPath.row == 3) {
  155. if (self.showArray.count > 0) {
  156. [self showType];
  157. }
  158. }
  159. }
  160. @end