YOUPAILZLiveManageListWindow.m 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  1. //
  2. // YOUPAILZLiveManageListWindow.m
  3. // VQU
  4. //
  5. // Created by CY on 2021/8/25.
  6. // Copyright © 2021 MS. All rights reserved.
  7. //
  8. #import "YOUPAILZLiveManageListWindow.h"
  9. #import "YOUPAILZLiveManageModel.h"
  10. #import "YOUPAILZLiveManageCell.h"
  11. @interface YOUPAILZLiveManageListWindow () <UITableViewDelegate,UITableViewDataSource>
  12. @property (nonatomic,weak) UITableView *youpaiptableView;
  13. @property (nonatomic,strong) NSMutableArray <YOUPAILZLiveManageModel *>*youpaipdataSource;
  14. @end
  15. @implementation YOUPAILZLiveManageListWindow
  16. - (void)viewDidLoad {
  17. [super viewDidLoad];
  18. self.baseView.hidden = YES;
  19. [self youpaifinitUI];
  20. [self youpaifrequestListData];
  21. }
  22. - (void)youpaifinitUI{
  23. UIView *bgV = [[UIView alloc] initWithFrame:CGRectMake(0, 0, KScreenWidth, 259.0f + SafeHeight)];
  24. bgV.backgroundColor = HexColorFromRGB(0x2A2935);
  25. [LCTools clipCorner:UIRectCornerTopLeft|UIRectCornerTopRight View:bgV size:CGSizeMake(20.0f, 20.0f)];
  26. [self.view addSubview:bgV];
  27. [bgV mas_makeConstraints:^(MASConstraintMaker *make) {
  28. make.left.bottom.right.offset(0.0f);
  29. make.height.offset(259.0f + SafeHeight);
  30. }];
  31. UILabel *titleL = [[UILabel alloc] init];
  32. titleL.font = LCFont17;
  33. titleL.textColor = [UIColor whiteColor];
  34. titleL.text = self.youpaiptitleText;
  35. [bgV addSubview:titleL];
  36. [titleL mas_makeConstraints:^(MASConstraintMaker *make) {
  37. make.top.offset(0.0f);
  38. make.centerX.equalTo(bgV);
  39. make.height.offset(49.0f);
  40. }];
  41. UITableView *tableView = [[UITableView alloc] initWithFrame:CGRectZero style:UITableViewStyleGrouped];
  42. tableView.delegate = self;
  43. tableView.dataSource = self;
  44. tableView.rowHeight = 60.0f;
  45. tableView.estimatedRowHeight = 60.0f;
  46. tableView.estimatedSectionHeaderHeight = 0.0f;
  47. tableView.estimatedSectionFooterHeight = 0.0f;
  48. tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
  49. tableView.backgroundColor = [UIColor clearColor];
  50. [self.view addSubview:tableView];
  51. self.youpaiptableView = tableView;
  52. [tableView mas_makeConstraints:^(MASConstraintMaker *make) {
  53. make.left.bottom.right.offset(0.0f);
  54. make.top.equalTo(titleL.mas_bottom);
  55. }];
  56. }
  57. #pragma mark - UITableViewDataSource
  58. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
  59. return self.youpaipdataSource.count;
  60. }
  61. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
  62. NSString *cellID = @"YOUPAILZLiveManageCell";
  63. YOUPAILZLiveManageCell *cell = [tableView dequeueReusableCellWithIdentifier:cellID];
  64. if (!cell) {
  65. cell = [[YOUPAILZLiveManageCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellID];
  66. }
  67. [cell youpaifreloadWithModel:self.youpaipdataSource[indexPath.row] indexPath:indexPath];
  68. @weakify(self);
  69. [cell setYoupaiprepealBlock:^(YOUPAILZLiveManageModel * _Nonnull model, NSIndexPath * _Nonnull indexPath) {
  70. @strongify(self);
  71. [self youpaifrepealWithModel:model indexPath:indexPath];
  72. }];
  73. return cell;
  74. }
  75. #pragma mark - UITableViewDelegate
  76. - (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
  77. return CGFLOAT_MIN;
  78. }
  79. - (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
  80. return CGFLOAT_MIN;
  81. }
  82. - (void)youpaifrepealWithModel:(YOUPAILZLiveManageModel *)model indexPath:(NSIndexPath *)indexPath{
  83. @weakify(self);
  84. if (self.youpaiptype == LZLiveManageListTypeWithManage) {
  85. NIMChatroomMemberUpdateRequest *request = [[NIMChatroomMemberUpdateRequest alloc] init];
  86. request.roomId = self.youpaipliveModel.youpaiproomid;
  87. request.userId = model.youpaipid;
  88. request.enable = NO;
  89. [ZCHUDHelper showWithStatus:nil];
  90. [[[NIMSDK sharedSDK] chatroomManager] markMemberManager:request completion:^(NSError * _Nullable error) {
  91. [ZCHUDHelper dismiss];
  92. @strongify(self);
  93. if (error) {
  94. [ZCHUDHelper showTitle:@"撤销失败"];
  95. }else{
  96. [self.youpaipdataSource removeObjectAtIndex:indexPath.row];
  97. [self.youpaiptableView deleteRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationNone];
  98. }
  99. }];
  100. }else if (self.youpaiptype == LZLiveManageListTypeWithForbidden) {
  101. [ZCHUDHelper showWithStatus:nil];
  102. NSDictionary *params = @{@"live_id":self.youpaipliveModel.youpaiplive_id,@"forbidden_uid":model.youpaipid};
  103. [LCHttpHelper requestWithURLString:LiveRepealForbidden parameters:params needToken:YES type:(HttpRequestTypePost) success:^(id responseObject) {
  104. [ZCHUDHelper dismiss];
  105. @strongify(self);
  106. NSDictionary* dict = (NSDictionary*)responseObject;
  107. NSInteger code = [[dict objectForKey:@"code"] integerValue];
  108. if (code == 0) {
  109. [self.youpaipdataSource removeObjectAtIndex:indexPath.row];
  110. [self.youpaiptableView deleteRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationNone];
  111. }else{
  112. [ZCHUDHelper showTitle:[dict objectForKey:@"message"]];
  113. }
  114. } failure:^(NSError *error) {
  115. [ZCHUDHelper dismiss];
  116. [ZCHUDHelper showTitle:error.localizedDescription];
  117. }];
  118. }else if (self.youpaiptype == LZLiveManageListTypeWithDisableSendMessage) {
  119. [ZCHUDHelper showWithStatus:nil];
  120. NSDictionary *params = @{@"live_id":self.youpaipliveModel.youpaiplive_id,@"type":@"mute",@"forbidden_uid":model.youpaipid,@"time":model.youpaipis_permanent};
  121. [LCHttpHelper requestWithURLString:ForBiddenUser parameters:params needToken:YES type:(HttpRequestTypePost) success:^(id responseObject) {
  122. [ZCHUDHelper dismiss];
  123. @strongify(self);
  124. NSDictionary* dict = (NSDictionary*)responseObject;
  125. NSInteger code = [[dict objectForKey:@"code"] integerValue];
  126. if (code == 0) {
  127. [self.youpaipdataSource removeObjectAtIndex:indexPath.row];
  128. [self.youpaiptableView deleteRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationNone];
  129. }else{
  130. [ZCHUDHelper showTitle:[dict objectForKey:@"message"]];
  131. }
  132. } failure:^(NSError *error) {
  133. [ZCHUDHelper dismiss];
  134. [ZCHUDHelper showTitle:error.localizedDescription];
  135. }];
  136. }
  137. }
  138. - (void)youpaifrequestListData{
  139. NSString *type = @"";
  140. switch (self.youpaiptype) {
  141. case LZLiveManageListTypeWithManage:
  142. type = @"manager";
  143. break;
  144. case LZLiveManageListTypeWithForbidden:
  145. type = @"forbidden";
  146. break;
  147. case LZLiveManageListTypeWithDisableSendMessage:
  148. type = @"mute";
  149. break;
  150. default:
  151. break;
  152. }
  153. @weakify(self);
  154. [LCHttpHelper requestWithURLString:GetManagerList parameters:@{@"live_id":self.youpaipliveModel.youpaiplive_id,@"type":type} needToken:YES type:HttpRequestTypePost success:^(id responseObject) {
  155. @strongify(self);
  156. NSDictionary* dict = (NSDictionary*)responseObject;
  157. NSInteger code = [[dict objectForKey:@"code"] integerValue];
  158. if (code == 0) {
  159. self.youpaipdataSource = [YOUPAILZLiveManageModel mj_objectArrayWithKeyValuesArray:[dict objectForKey:@"data"]].mutableCopy;
  160. [self.youpaiptableView reloadData];
  161. }else{
  162. [ZCHUDHelper showTitle:[dict objectForKey:@"message"]];
  163. }
  164. } failure:^(NSError *error) {
  165. [ZCHUDHelper showTitle:error.localizedDescription];
  166. }];
  167. }
  168. @end