123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166 |
- //
- // TDGroupRoleVC.m
- // smartRhino
- //
- // Created by niuzhen on 2020/5/8.
- // Copyright © 2020 tederen. All rights reserved.
- //
- #import "TDGroupRoleVC.h"
- #import "TDGroupInfoDetailCell.h"
- #import "MOFSPickerManager.h"
- #import "GroupSquareModel.h"
- @interface TDGroupRoleVC ()<UITableViewDelegate,UITableViewDataSource>
- @property (weak, nonatomic) IBOutlet UITableView *tableView;
- @property (nonatomic, strong) NSMutableArray * dataArray;
- @property (nonatomic, strong) NSMutableArray * showArray;
- @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;
- [self getData];
- }
- - (void)getData
- {
- WS(weakSelf);
- self.dataArray = [NSMutableArray array];
- self.showArray = [NSMutableArray array];
- SHOWLOADING
- NSString * url = [NSString stringWithFormat:@"%@%@",Host(API_APP_GROUP_Group_Category),@"0"];
- [[HttpManager sharedHttpManager] GET:url parameters:@{} success:^(NSURLSessionDataTask * _Nonnull task, id _Nullable responseObject) {
- NSLog(@"%@",responseObject);
- REMOVESHOW
- if ([responseObject isKindOfClass:[NSArray class]]) {
- for (NSDictionary * dict in responseObject) {
- GroupSquareModel * model = [GroupSquareModel modelWithDictionary:dict];
- [weakSelf.dataArray addObject:model];
- [weakSelf.showArray addObject:model.PiazzaName];
- }
- }
- } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
- REMOVESHOW
- }];
- }
- - (void)showType
- {
- WS(weakSelf);
- [MOFSPickerManager shareManger].pickView.toolBar.cancelBar.textColor = UIColorHex(#888888);
- [MOFSPickerManager shareManger].pickView.toolBar.commitBar.textColor = UIColorHex(#3979D3);
- MOFSPickerManager *manager = [[MOFSPickerManager alloc] init];
- [manager showPickerViewWithDataArray:self.showArray tag:2 title:nil cancelTitle:@"取消" commitTitle:@"确定" commitBlock:^(NSString *string) {
- for (GroupSquareModel * model in weakSelf.dataArray) {
- if ([model.PiazzaName isEqualToString:string]) {
- weakSelf.model.CategroyName = string;
- [[HttpManager sharedHttpManager] POSTUrl:Host(APP_Group_Update) parameters:@{@"GroupCategroyId":@(model.Id),@"Id":@(weakSelf.model.Id)} responseStyle:DATA success:^(id _Nonnull responseObject) {
- dispatch_async(dispatch_get_main_queue(), ^{
- [weakSelf.tableView reloadData];
- });
- } failure:^(NSError * _Nonnull error) {
- SHOWERROR([ZYCTool handerResultData:error]);
- }];
- }
- }
- } cancelBlock:^{
-
- }];
- }
- #pragma mark - UITableViewDelegate
- - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
- {
- return 1;
- }
- - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
- {
- return 4;
- }
- - (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;
- case 2:
- {
- 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;
- default:
- {
- TDGroupInfoDetailCell *cell = [TDGroupInfoDetailCell configCell1:tableView indexPath:indexPath];
- cell.cell1TitleL.text = @"小组类型";
- cell.subTitleL.hidden = NO;
- cell.subTitleL.text = self.model.CategroyName;
- return cell;
- }
- break;
- }
- }
- - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
- {
- if (indexPath.row == 3) {
- if (self.showArray.count > 0) {
- [self showType];
- }
- }
- }
- @end
|