| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237 |
- //
- // RoomUserListViewController.m
- // yunbaolive
- //
- // Created by IOS1 on 2019/4/26.
- // Copyright © 2019 cat. All rights reserved.
- //
- #import "RoomUserListViewController.h"
- #import "adminCell.h"
- #import "fansModel.h"
- #import "OtherRoomViewController.h"
- @interface RoomUserListViewController ()<UITableViewDelegate,UITableViewDataSource,adminCellDelegate>{
- UITableView *listTable;
- NSMutableArray *listArray;
- int page;
- NSString *_noMsg;
-
- }
- @property (nonatomic,strong) NSString *addAdmins;
- @end
- @implementation RoomUserListViewController
- - (void)viewDidLoad {
- [super viewDidLoad];
- self.titleL.text = _titleStr;
- listArray = [NSMutableArray array];
- page = 1;
- listTable = [[UITableView alloc]initWithFrame:CGRectMake(0, 64+statusbarHeight, _window_width, _window_height-64-statusbarHeight-ShowDiff) style:0];
- listTable.delegate = self;
- listTable.dataSource = self;
- listTable.separatorStyle = 0;
- listTable.backgroundColor = Normal_Color;
- [self.view addSubview:listTable];
- listTable.mj_header = [MJRefreshNormalHeader headerWithRefreshingBlock:^{
- page = 1;
- [self requestData];
- }];
- listTable.mj_footer = [MJRefreshBackFooter footerWithRefreshingBlock:^{
- page ++;
- [self requestData];
- }];
- [self requestData];
- }
- - (void)requestData{
- NSString *method;
- if (_type == 0) {
- _noMsg = @"";
- method = @"Livemanage.GetManageList";
- }
- if (_type == 1) {
- _noMsg = YZMsg(@"没有被禁言用户");
- method = @"Livemanage.getShutList";
- }
- if (_type == 2) {
- _noMsg = YZMsg(@"没有被踢用户");
- method = @"Livemanage.getKickList";
- }
- NSDictionary *subdic = @{
- @"liveuid":_liveuid,
- };
- [YBNetworking postWithUrl:method Dic:subdic Suc:^(int code, id info, NSString *msg) {
- [listTable.mj_header endRefreshing];
- [listTable.mj_footer endRefreshing];
- if (code == 0) {
- if (_type == 0) {
- NSArray *array = [[info firstObject] valueForKey:@"list"];//关注信息复制给数据源
- if (page == 1) {
- [listArray removeAllObjects];
- }
- for (NSDictionary *dic in array) {
- fansModel *model = [[fansModel alloc] initWithDic:dic];
- [listArray addObject:model];
- }
- self.addAdmins = minstr([[info firstObject] valueForKey:@"total"]);//总的管理员
- }else{
- if (page == 1) {
- [listArray removeAllObjects];
- }
- for (NSDictionary *dic in info) {
- fansModel *model = [[fansModel alloc] initWithDic:dic];
- [listArray addObject:model];
- }
- if (listArray.count == 0) {
- [PublicView showTextNoData:listTable text1:@"" text2:_noMsg centerY:0.8];
- }else {
- [PublicView hiddenTextNoData:listTable];
- }
- }
- [listTable reloadData];
- }
- } Fail:^(id fail) {
- [listTable.mj_header endRefreshing];
- [listTable.mj_footer endRefreshing];
- }];
- }
- -(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
- if (_type == 0) {
- UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(0, 0, _window_width, 30)];
- label.backgroundColor = CellRow_Cor;
- label.textColor = RGB_COLOR(@"#969696", 1);
- label.font = [UIFont systemFontOfSize:15];
- label.text = [NSString stringWithFormat:@" %@(%ld/%@)",YZMsg(@"当前管理员"),listArray.count,self.addAdmins];
- return label;
- }
- return nil;
- }
- -(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
- if (_type == 0) {
- return 30;
- }
- return 0;
- }
- -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
- return listArray.count;
- }
- -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
- {
- adminCell *cell = [adminCell cellWithTableView:tableView];
- cell.delegate = self;
- fansModel *model = listArray[indexPath.row];
- cell.model = model;
- if (_type == 0) {
- [cell.rightBtn setTitle:@"" forState:0];
- [cell.rightBtn setImage:[UIImage imageNamed:@"profit_del"] forState:0];
- }else{
- if (_type == 1) {
- [cell.rightBtn setTitle:YZMsg(@"解除禁言") forState:0];
- }else{
- [cell.rightBtn setTitle:YZMsg(@"解除拉黑") forState:0];
- }
- [cell.rightBtn setImage:[UIImage new] forState:0];
- }
- cell.backgroundColor = CellRow_Cor;
- cell.selectionStyle = UITableViewCellSelectionStyleNone;
- return cell;
- }
- -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
- //弹窗
- [tableView deselectRowAtIndexPath:indexPath animated:YES];
- // fansModel *model = listArray[indexPath.row];
-
- }
- -(void)doGuanzhu:(NSString *)st{
- //关注
- NSString *url = [NSString stringWithFormat:@"User.setAttention&uid=%@&showid=%@&token=%@",[Config getOwnID],st,[Config getOwnToken]];
- [YBNetworking postWithUrl:url Dic:nil Suc:^(int code, id info, NSString *msg) {
-
- } Fail:^(id fail) {
-
- }];
-
- }
- -(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
- {
- return 60;
- }
- - (void)delateAdminUser:(fansModel *)model{
- NSString *msg;
- if (_type == 0) {
- msg = [NSString stringWithFormat:@"%@%@%@?",YZMsg(@"是否确定取消"),model.name,YZMsg(@"的管理员身份")];
- }
- if (_type == 1) {
- msg = YZMsg(@"是否解除对该用户的禁言");
- }
- if (_type == 2) {
- msg = YZMsg(@"是否解除对该用户的踢出");
- }
- NSDictionary *contentDic = @{
- @"title":YZMsg(@"提示"),
- @"msg":msg,
- @"left":YZMsg(@"取消"),
- @"right":YZMsg(@"确定")
- };
- YBWeakSelf;
- [YBAlertView showAlertView:contentDic complete:^(int eventType) {
- if (eventType == 1) {
- [weakSelf caozuo:model];
- }
- }];
- }
- - (void)caozuo:(fansModel *)model{
- NSString *method;
- if (_type == 0) {
- method = @"Livemanage.cancelManage";
- }
- if (_type == 1) {
- method = @"Livemanage.cancelShut";
- }
- if (_type == 2) {
- method = @"Livemanage.cancelKick";
- }
- NSDictionary *setadmin = @{
- @"liveuid":_liveuid,
- @"touid":model.uid,
- };
- [YBNetworking postWithUrl:method Dic:setadmin Suc:^(int code, id info, NSString *msg) {
- if (code == 0) {
- [listArray removeObject:model];
- [listTable reloadData];
- if (_type != 0) {
- if (listArray.count == 0) {
- [PublicView showTextNoData:listTable text1:@"" text2:_noMsg centerY:0.8];
- }else {
- [PublicView hiddenTextNoData:listTable];
- }
- }
- [MBProgressHUD showError:msg];
- }else{
- [MBProgressHUD showError:msg];
- }
- } Fail:^(id fail) {
-
- }];
-
- }
- /*
- #pragma mark - Navigation
- // In a storyboard-based application, you will often want to do a little preparation before navigation
- - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
- // Get the new view controller using [segue destinationViewController].
- // Pass the selected object to the new view controller.
- }
- */
- @end
|