RoomUserListViewController.m 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237
  1. //
  2. // RoomUserListViewController.m
  3. // yunbaolive
  4. //
  5. // Created by IOS1 on 2019/4/26.
  6. // Copyright © 2019 cat. All rights reserved.
  7. //
  8. #import "RoomUserListViewController.h"
  9. #import "adminCell.h"
  10. #import "fansModel.h"
  11. #import "OtherRoomViewController.h"
  12. @interface RoomUserListViewController ()<UITableViewDelegate,UITableViewDataSource,adminCellDelegate>{
  13. UITableView *listTable;
  14. NSMutableArray *listArray;
  15. int page;
  16. NSString *_noMsg;
  17. }
  18. @property (nonatomic,strong) NSString *addAdmins;
  19. @end
  20. @implementation RoomUserListViewController
  21. - (void)viewDidLoad {
  22. [super viewDidLoad];
  23. self.titleL.text = _titleStr;
  24. listArray = [NSMutableArray array];
  25. page = 1;
  26. listTable = [[UITableView alloc]initWithFrame:CGRectMake(0, 64+statusbarHeight, _window_width, _window_height-64-statusbarHeight-ShowDiff) style:0];
  27. listTable.delegate = self;
  28. listTable.dataSource = self;
  29. listTable.separatorStyle = 0;
  30. listTable.backgroundColor = Normal_Color;
  31. [self.view addSubview:listTable];
  32. listTable.mj_header = [MJRefreshNormalHeader headerWithRefreshingBlock:^{
  33. page = 1;
  34. [self requestData];
  35. }];
  36. listTable.mj_footer = [MJRefreshBackFooter footerWithRefreshingBlock:^{
  37. page ++;
  38. [self requestData];
  39. }];
  40. [self requestData];
  41. }
  42. - (void)requestData{
  43. NSString *method;
  44. if (_type == 0) {
  45. _noMsg = @"";
  46. method = @"Livemanage.GetManageList";
  47. }
  48. if (_type == 1) {
  49. _noMsg = YZMsg(@"没有被禁言用户");
  50. method = @"Livemanage.getShutList";
  51. }
  52. if (_type == 2) {
  53. _noMsg = YZMsg(@"没有被踢用户");
  54. method = @"Livemanage.getKickList";
  55. }
  56. NSDictionary *subdic = @{
  57. @"liveuid":_liveuid,
  58. };
  59. [YBNetworking postWithUrl:method Dic:subdic Suc:^(int code, id info, NSString *msg) {
  60. [listTable.mj_header endRefreshing];
  61. [listTable.mj_footer endRefreshing];
  62. if (code == 0) {
  63. if (_type == 0) {
  64. NSArray *array = [[info firstObject] valueForKey:@"list"];//关注信息复制给数据源
  65. if (page == 1) {
  66. [listArray removeAllObjects];
  67. }
  68. for (NSDictionary *dic in array) {
  69. fansModel *model = [[fansModel alloc] initWithDic:dic];
  70. [listArray addObject:model];
  71. }
  72. self.addAdmins = minstr([[info firstObject] valueForKey:@"total"]);//总的管理员
  73. }else{
  74. if (page == 1) {
  75. [listArray removeAllObjects];
  76. }
  77. for (NSDictionary *dic in info) {
  78. fansModel *model = [[fansModel alloc] initWithDic:dic];
  79. [listArray addObject:model];
  80. }
  81. if (listArray.count == 0) {
  82. [PublicView showTextNoData:listTable text1:@"" text2:_noMsg centerY:0.8];
  83. }else {
  84. [PublicView hiddenTextNoData:listTable];
  85. }
  86. }
  87. [listTable reloadData];
  88. }
  89. } Fail:^(id fail) {
  90. [listTable.mj_header endRefreshing];
  91. [listTable.mj_footer endRefreshing];
  92. }];
  93. }
  94. -(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
  95. if (_type == 0) {
  96. UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(0, 0, _window_width, 30)];
  97. label.backgroundColor = CellRow_Cor;
  98. label.textColor = RGB_COLOR(@"#969696", 1);
  99. label.font = [UIFont systemFontOfSize:15];
  100. label.text = [NSString stringWithFormat:@" %@(%ld/%@)",YZMsg(@"当前管理员"),listArray.count,self.addAdmins];
  101. return label;
  102. }
  103. return nil;
  104. }
  105. -(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
  106. if (_type == 0) {
  107. return 30;
  108. }
  109. return 0;
  110. }
  111. -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
  112. return listArray.count;
  113. }
  114. -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
  115. {
  116. adminCell *cell = [adminCell cellWithTableView:tableView];
  117. cell.delegate = self;
  118. fansModel *model = listArray[indexPath.row];
  119. cell.model = model;
  120. if (_type == 0) {
  121. [cell.rightBtn setTitle:@"" forState:0];
  122. [cell.rightBtn setImage:[UIImage imageNamed:@"profit_del"] forState:0];
  123. }else{
  124. if (_type == 1) {
  125. [cell.rightBtn setTitle:YZMsg(@"解除禁言") forState:0];
  126. }else{
  127. [cell.rightBtn setTitle:YZMsg(@"解除拉黑") forState:0];
  128. }
  129. [cell.rightBtn setImage:[UIImage new] forState:0];
  130. }
  131. cell.backgroundColor = CellRow_Cor;
  132. cell.selectionStyle = UITableViewCellSelectionStyleNone;
  133. return cell;
  134. }
  135. -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
  136. //弹窗
  137. [tableView deselectRowAtIndexPath:indexPath animated:YES];
  138. // fansModel *model = listArray[indexPath.row];
  139. }
  140. -(void)doGuanzhu:(NSString *)st{
  141. //关注
  142. NSString *url = [NSString stringWithFormat:@"User.setAttention&uid=%@&showid=%@&token=%@",[Config getOwnID],st,[Config getOwnToken]];
  143. [YBNetworking postWithUrl:url Dic:nil Suc:^(int code, id info, NSString *msg) {
  144. } Fail:^(id fail) {
  145. }];
  146. }
  147. -(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
  148. {
  149. return 60;
  150. }
  151. - (void)delateAdminUser:(fansModel *)model{
  152. NSString *msg;
  153. if (_type == 0) {
  154. msg = [NSString stringWithFormat:@"%@%@%@?",YZMsg(@"是否确定取消"),model.name,YZMsg(@"的管理员身份")];
  155. }
  156. if (_type == 1) {
  157. msg = YZMsg(@"是否解除对该用户的禁言");
  158. }
  159. if (_type == 2) {
  160. msg = YZMsg(@"是否解除对该用户的踢出");
  161. }
  162. NSDictionary *contentDic = @{
  163. @"title":YZMsg(@"提示"),
  164. @"msg":msg,
  165. @"left":YZMsg(@"取消"),
  166. @"right":YZMsg(@"确定")
  167. };
  168. YBWeakSelf;
  169. [YBAlertView showAlertView:contentDic complete:^(int eventType) {
  170. if (eventType == 1) {
  171. [weakSelf caozuo:model];
  172. }
  173. }];
  174. }
  175. - (void)caozuo:(fansModel *)model{
  176. NSString *method;
  177. if (_type == 0) {
  178. method = @"Livemanage.cancelManage";
  179. }
  180. if (_type == 1) {
  181. method = @"Livemanage.cancelShut";
  182. }
  183. if (_type == 2) {
  184. method = @"Livemanage.cancelKick";
  185. }
  186. NSDictionary *setadmin = @{
  187. @"liveuid":_liveuid,
  188. @"touid":model.uid,
  189. };
  190. [YBNetworking postWithUrl:method Dic:setadmin Suc:^(int code, id info, NSString *msg) {
  191. if (code == 0) {
  192. [listArray removeObject:model];
  193. [listTable reloadData];
  194. if (_type != 0) {
  195. if (listArray.count == 0) {
  196. [PublicView showTextNoData:listTable text1:@"" text2:_noMsg centerY:0.8];
  197. }else {
  198. [PublicView hiddenTextNoData:listTable];
  199. }
  200. }
  201. [MBProgressHUD showError:msg];
  202. }else{
  203. [MBProgressHUD showError:msg];
  204. }
  205. } Fail:^(id fail) {
  206. }];
  207. }
  208. /*
  209. #pragma mark - Navigation
  210. // In a storyboard-based application, you will often want to do a little preparation before navigation
  211. - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
  212. // Get the new view controller using [segue destinationViewController].
  213. // Pass the selected object to the new view controller.
  214. }
  215. */
  216. @end