// // TDGroupRoleVC.m // smartRhino // // Created by niuzhen on 2020/5/8. // Copyright © 2020 tederen. All rights reserved. // #import "TDGroupRoleVC.h" #import "TDGroupInfoDetailCell.h" @interface TDGroupRoleVC () @property (weak, nonatomic) IBOutlet UITableView *tableView; @end @implementation TDGroupRoleVC +(TDGroupRoleVC *)initTDGroupRoleVC{ TDGroupRoleVC *controller = [StoryboardManager.shared.TDGroup instantiateViewControllerWithIdentifier:@"TDGroupRoleVC"]; return controller; } - (void)viewDidLoad { [super viewDidLoad]; self.fd_prefersNavigationBarHidden = YES; self.view.backgroundColor = UIColorHex(0xF1F1F1); self.tableView.delegate = self; self.tableView.dataSource = self; } #pragma mark - UITableViewDelegate - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { return 1; } - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { return 3; } - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath { return 65.f; } - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { WS(weakSelf); switch (indexPath.row) { case 0: { TDGroupInfoDetailCell *cell = [TDGroupInfoDetailCell configCell2:tableView indexPath:indexPath]; cell.cell2TitleL.text = @"加入小组需要管理员同意"; [cell.cell2Switch setBlockForControlEvents:UIControlEventValueChanged block:^(id _Nonnull sender) { [[HttpManager sharedHttpManager] POSTUrl:Host(APP_Group_Update) parameters:@{@"IsAdmin":cell.cell2Switch.isOn ? @"1" : @"2",@"Id":@(weakSelf.model.Id)} responseStyle:DATA success:^(id _Nonnull responseObject) { if (weakSelf.refreshBlock) { weakSelf.refreshBlock(); } } failure:^(NSError * _Nonnull error) { SHOWERROR([ZYCTool handerResultData:error]); }]; }]; [cell.cell2Switch setOn:self.model.IsAdmin]; return cell; } break; case 1: { TDGroupInfoDetailCell *cell = [TDGroupInfoDetailCell configCell2:tableView indexPath:indexPath]; cell.cell2TitleL.text = @"只允许管理员发话题(禁言)"; [cell.cell2Switch setBlockForControlEvents:UIControlEventValueChanged block:^(id _Nonnull sender) { [[HttpManager sharedHttpManager] POSTUrl:Host(APP_Group_Update) parameters:@{@"IsWords":cell.cell2Switch.isOn ? @"1" : @"2",@"Id":@(weakSelf.model.Id)} responseStyle:DATA success:^(id _Nonnull responseObject) { if (weakSelf.refreshBlock) { weakSelf.refreshBlock(); } } failure:^(NSError * _Nonnull error) { SHOWERROR([ZYCTool handerResultData:error]); }]; }]; [cell.cell2Switch setOn:self.model.IsWords]; return cell; } break; default: { TDGroupInfoDetailCell *cell = [TDGroupInfoDetailCell configCell2:tableView indexPath:indexPath]; cell.cell2TitleL.text = @"小组广场可见"; [cell.cell2Switch setBlockForControlEvents:UIControlEventValueChanged block:^(id _Nonnull sender) { [[HttpManager sharedHttpManager] POSTUrl:Host(APP_Group_Update) parameters:@{@"IsShow":cell.cell2Switch.isOn ? @"1" : @"2",@"Id":@(weakSelf.model.Id)} responseStyle:DATA success:^(id _Nonnull responseObject) { if (weakSelf.refreshBlock) { weakSelf.refreshBlock(); } } failure:^(NSError * _Nonnull error) { SHOWERROR([ZYCTool handerResultData:error]); }]; }]; [cell.cell2Switch setOn:self.model.IsShow]; return cell; } break; } } @end