// // AddVideoMomberVC.m // watch // // Created by Apple on 2019/1/25. // Copyright © 2019年 xTT. All rights reserved. // #import "AddVideoMomberVC.h" #import "AddVideoMomberCell.h" @interface AddVideoMomberVC () @end @implementation AddVideoMomberVC - (void)viewDidLoad { [super viewDidLoad]; if(self.isUnCheck){ self.title = @"删除成员"; }else{ self.title = @"添加联系人"; } // self.view.backgroundColor = self.myTableView.backgroundColor; [self.myTableView registerNib:[UINib nibWithNibName:@"AddVideoMomberCell" bundle:[NSBundle mainBundle]] forCellReuseIdentifier:@"AddVideoMomberCell"]; //去线 // self.myTableView.separatorStyle = UITableViewCellSeparatorStyleNone; self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"确定" style:UIBarButtonItemStylePlain target:self action:@selector(saveAction:)]; NSMutableArray *arr = self.myDataSource[0]; NSMutableArray *temp = [NSMutableArray array]; for (VideoUserModel *model in arr) { // VideoUserModel *model = [VideoUserModel new]; // [model mj_setKeyValues:dic]; // model.imageid = [dic[@"image"] intValue]; [temp addObject:model]; } self.myDataSource[0] = temp; } - (void)saveAction:(UIBarButtonItem *)sender{ NSMutableArray *temp = [NSMutableArray array]; for (VideoUserModel *model in self.myDataSource[0] ) { if(model.ifSelect){ //选中的人加 [temp addObject:model.openid]; } } if(temp.count == 0){ NSString *str = @"删除"; if(!self.isUnCheck){ str = @"增加"; } [UICommon MessageErrorText:[NSString stringWithFormat:@"请选择要%@视频通话成员",str]]; return; } WEAKSELF if(self.isUnCheck){ [cUser.cDevice delectVideoUserListWithList:[temp copy] Success:^(id responseObject) { [UICommon MessageSuccessText:@"删除视频通话成员成功" isImg:YES]; AfterDispatch(1, ^{ [weakSelf.navigationController popViewControllerAnimated:YES]; }); } failure:^{ }]; }else{ [cUser.cDevice addVideoUserListWithList:[temp copy] Success:^(id responseObject) { [UICommon MessageSuccessText:@"增加视频通话成员成功" isImg:YES]; AfterDispatch(1, ^{ [weakSelf.navigationController popViewControllerAnimated:YES]; }); } failure:^{ }]; } } - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{ VideoUserModel *model = self.myDataSource[indexPath.section][indexPath.row]; AddVideoMomberCell *cell = [tableView dequeueReusableCellWithIdentifier:@"AddVideoMomberCell" forIndexPath:indexPath]; [cell setModel:model]; return cell; } -(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{ return 65; } //MARK: 设置cell 的 交互 样式 - (UITableViewCellEditingStyle)tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath{ /** UITableViewCellEditingStyleNone, UITableViewCellEditingStyleDelete, UITableViewCellEditingStyleInsert */ //设置右滑 删除的 样式 // return UITableViewCellEditingStyleDelete; return UITableViewCellEditingStyleNone; } - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{ VideoUserModel *model = self.myDataSource[indexPath.section][indexPath.row]; model.ifSelect = !model.ifSelect; [tableView reloadRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationNone]; } @end