123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184 |
- //
- // YOUPAILZLiveManageListWindow.m
- // VQU
- //
- // Created by CY on 2021/8/25.
- // Copyright © 2021 MS. All rights reserved.
- //
- #import "YOUPAILZLiveManageListWindow.h"
- #import "YOUPAILZLiveManageModel.h"
- #import "YOUPAILZLiveManageCell.h"
- @interface YOUPAILZLiveManageListWindow () <UITableViewDelegate,UITableViewDataSource>
- @property (nonatomic,weak) UITableView *youpaiptableView;
- @property (nonatomic,strong) NSMutableArray <YOUPAILZLiveManageModel *>*youpaipdataSource;
- @end
- @implementation YOUPAILZLiveManageListWindow
- - (void)viewDidLoad {
- [super viewDidLoad];
- self.baseView.hidden = YES;
-
- [self youpaifinitUI];
- [self youpaifrequestListData];
- }
- - (void)youpaifinitUI{
- UIView *bgV = [[UIView alloc] initWithFrame:CGRectMake(0, 0, KScreenWidth, 259.0f + SafeHeight)];
- bgV.backgroundColor = HexColorFromRGB(0x2A2935);
- [LCTools clipCorner:UIRectCornerTopLeft|UIRectCornerTopRight View:bgV size:CGSizeMake(20.0f, 20.0f)];
- [self.view addSubview:bgV];
- [bgV mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.bottom.right.offset(0.0f);
- make.height.offset(259.0f + SafeHeight);
- }];
-
- UILabel *titleL = [[UILabel alloc] init];
- titleL.font = LCFont17;
- titleL.textColor = [UIColor whiteColor];
- titleL.text = self.youpaiptitleText;
- [bgV addSubview:titleL];
- [titleL mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.offset(0.0f);
- make.centerX.equalTo(bgV);
- make.height.offset(49.0f);
- }];
-
- UITableView *tableView = [[UITableView alloc] initWithFrame:CGRectZero style:UITableViewStyleGrouped];
- tableView.delegate = self;
- tableView.dataSource = self;
- tableView.rowHeight = 60.0f;
- tableView.estimatedRowHeight = 60.0f;
- tableView.estimatedSectionHeaderHeight = 0.0f;
- tableView.estimatedSectionFooterHeight = 0.0f;
- tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
- tableView.backgroundColor = [UIColor clearColor];
- [self.view addSubview:tableView];
- self.youpaiptableView = tableView;
-
- [tableView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.bottom.right.offset(0.0f);
- make.top.equalTo(titleL.mas_bottom);
- }];
- }
- #pragma mark - UITableViewDataSource
- - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
- return self.youpaipdataSource.count;
- }
- - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
- NSString *cellID = @"YOUPAILZLiveManageCell";
- YOUPAILZLiveManageCell *cell = [tableView dequeueReusableCellWithIdentifier:cellID];
- if (!cell) {
- cell = [[YOUPAILZLiveManageCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellID];
- }
- [cell youpaifreloadWithModel:self.youpaipdataSource[indexPath.row] indexPath:indexPath];
- @weakify(self);
- [cell setYoupaiprepealBlock:^(YOUPAILZLiveManageModel * _Nonnull model, NSIndexPath * _Nonnull indexPath) {
- @strongify(self);
- [self youpaifrepealWithModel:model indexPath:indexPath];
- }];
- return cell;
- }
- #pragma mark - UITableViewDelegate
- - (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
- return CGFLOAT_MIN;
- }
- - (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
- return CGFLOAT_MIN;
- }
- - (void)youpaifrepealWithModel:(YOUPAILZLiveManageModel *)model indexPath:(NSIndexPath *)indexPath{
- @weakify(self);
- if (self.youpaiptype == LZLiveManageListTypeWithManage) {
- NIMChatroomMemberUpdateRequest *request = [[NIMChatroomMemberUpdateRequest alloc] init];
- request.roomId = self.youpaipliveModel.youpaiproomid;
- request.userId = model.youpaipid;
- request.enable = NO;
- [ZCHUDHelper showWithStatus:nil];
- [[[NIMSDK sharedSDK] chatroomManager] markMemberManager:request completion:^(NSError * _Nullable error) {
- [ZCHUDHelper dismiss];
- @strongify(self);
- if (error) {
- [ZCHUDHelper showTitle:@"撤销失败"];
- }else{
- [self.youpaipdataSource removeObjectAtIndex:indexPath.row];
- [self.youpaiptableView deleteRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationNone];
- }
- }];
- }else if (self.youpaiptype == LZLiveManageListTypeWithForbidden) {
- [ZCHUDHelper showWithStatus:nil];
- NSDictionary *params = @{@"live_id":self.youpaipliveModel.youpaiplive_id,@"forbidden_uid":model.youpaipid};
- [LCHttpHelper requestWithURLString:LiveRepealForbidden parameters:params needToken:YES type:(HttpRequestTypePost) success:^(id responseObject) {
- [ZCHUDHelper dismiss];
- @strongify(self);
- NSDictionary* dict = (NSDictionary*)responseObject;
- NSInteger code = [[dict objectForKey:@"code"] integerValue];
- if (code == 0) {
- [self.youpaipdataSource removeObjectAtIndex:indexPath.row];
- [self.youpaiptableView deleteRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationNone];
- }else{
- [ZCHUDHelper showTitle:[dict objectForKey:@"message"]];
- }
- } failure:^(NSError *error) {
- [ZCHUDHelper dismiss];
- [ZCHUDHelper showTitle:error.localizedDescription];
- }];
- }else if (self.youpaiptype == LZLiveManageListTypeWithDisableSendMessage) {
- [ZCHUDHelper showWithStatus:nil];
- NSDictionary *params = @{@"live_id":self.youpaipliveModel.youpaiplive_id,@"type":@"mute",@"forbidden_uid":model.youpaipid,@"time":model.youpaipis_permanent};
- [LCHttpHelper requestWithURLString:ForBiddenUser parameters:params needToken:YES type:(HttpRequestTypePost) success:^(id responseObject) {
- [ZCHUDHelper dismiss];
- @strongify(self);
- NSDictionary* dict = (NSDictionary*)responseObject;
- NSInteger code = [[dict objectForKey:@"code"] integerValue];
- if (code == 0) {
- [self.youpaipdataSource removeObjectAtIndex:indexPath.row];
- [self.youpaiptableView deleteRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationNone];
- }else{
- [ZCHUDHelper showTitle:[dict objectForKey:@"message"]];
- }
- } failure:^(NSError *error) {
- [ZCHUDHelper dismiss];
- [ZCHUDHelper showTitle:error.localizedDescription];
- }];
- }
- }
- - (void)youpaifrequestListData{
- NSString *type = @"";
- switch (self.youpaiptype) {
- case LZLiveManageListTypeWithManage:
- type = @"manager";
- break;
- case LZLiveManageListTypeWithForbidden:
- type = @"forbidden";
- break;
- case LZLiveManageListTypeWithDisableSendMessage:
- type = @"mute";
- break;
- default:
- break;
- }
- @weakify(self);
- [LCHttpHelper requestWithURLString:GetManagerList parameters:@{@"live_id":self.youpaipliveModel.youpaiplive_id,@"type":type} needToken:YES type:HttpRequestTypePost success:^(id responseObject) {
- @strongify(self);
- NSDictionary* dict = (NSDictionary*)responseObject;
- NSInteger code = [[dict objectForKey:@"code"] integerValue];
- if (code == 0) {
- self.youpaipdataSource = [YOUPAILZLiveManageModel mj_objectArrayWithKeyValuesArray:[dict objectForKey:@"data"]].mutableCopy;
- [self.youpaiptableView reloadData];
- }else{
- [ZCHUDHelper showTitle:[dict objectForKey:@"message"]];
- }
- } failure:^(NSError *error) {
- [ZCHUDHelper showTitle:error.localizedDescription];
- }];
- }
- @end
|