From e03d804dd8d3ff1cda2e0420e17da861662a3a42 Mon Sep 17 00:00:00 2001 From: fengshuo <963787902@qq.com> Date: Wed, 1 Dec 2021 20:57:23 +0800 Subject: [PATCH] =?UTF-8?q?s4=E7=9B=B8=E4=BA=B2=E6=A8=A1=E5=BC=8F=E5=92=8C?= =?UTF-8?q?=E6=8E=92=E9=BA=A6=E6=A8=A1=E5=BC=8F=E7=9A=84=E6=93=8D=E4=BD=9C?= =?UTF-8?q?=E9=99=90=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../View/Cell/XPGiftUserCollectionViewCell.m | 2 +- xplan-ios/Main/Room/Model/RoomInfoModel.h | 22 ++++- .../Room/View/RoomHeaderView/RoomHeaderView.m | 3 +- .../Room/View/StageView/MicroView/MicroView.m | 31 +++++++ .../StageView/MicroView/MicroViewProtocol.h | 3 +- .../Main/Room/View/StageView/StageView.m | 80 ++++++++++++++++--- 6 files changed, 125 insertions(+), 16 deletions(-) diff --git a/xplan-ios/Main/ModuleKit/SendGiftView/View/Cell/XPGiftUserCollectionViewCell.m b/xplan-ios/Main/ModuleKit/SendGiftView/View/Cell/XPGiftUserCollectionViewCell.m index 57b949e6..738e4e50 100644 --- a/xplan-ios/Main/ModuleKit/SendGiftView/View/Cell/XPGiftUserCollectionViewCell.m +++ b/xplan-ios/Main/ModuleKit/SendGiftView/View/Cell/XPGiftUserCollectionViewCell.m @@ -73,7 +73,7 @@ if (_userInfo.position.integerValue == -1) { self.positionLabel.text = @"房主位"; [self.positionLabel mas_updateConstraints:^(MASConstraintMaker *make) { - make.width.mas_equalTo(23); + make.width.mas_equalTo(28); }]; } else { self.positionLabel.text = [NSString stringWithFormat:@"%ld", _userInfo.position.integerValue + 1]; diff --git a/xplan-ios/Main/Room/Model/RoomInfoModel.h b/xplan-ios/Main/Room/Model/RoomInfoModel.h index c61dd2f7..7c37e3c9 100644 --- a/xplan-ios/Main/Room/Model/RoomInfoModel.h +++ b/xplan-ios/Main/Room/Model/RoomInfoModel.h @@ -13,13 +13,28 @@ typedef NS_ENUM(NSInteger, RoomType) { RoomType_Game = 3, }; +typedef NS_ENUM(NSInteger, RoomModeType){ + ///普通模式 + RoomModeType_Normal_Mode = 0, + ///排麦模式 + RoomModeType_Open_Micro_Mode = 1, + ///关闭排麦模式 + RoomModeType_Close_Micro_Mode = 2, + ///开启PK + RoomModeType_Open_PK_Mode = 3, + ///关闭PK + RoomModeType_Close_PK_Mode = 4, + ///相亲 + RoomModeType_Open_Blind = 5, + ///开启跨房PK + RoomModeType_Open_AcrossRoomPK_mode = 7, +}; @interface RoomInfoModel : NSObject @property (nonatomic , copy) NSString * nick; @property (nonatomic , assign) NSInteger uid; @property (nonatomic , assign) NSInteger isRecom; @property (nonatomic , assign) NSInteger calcSumDataIndex; -@property (nonatomic , assign) NSInteger roomModeType; @property (nonatomic , copy) NSString * roomTag; @property (nonatomic , copy) NSString * audioSdkType; @property (nonatomic , assign) NSInteger hideFlag; @@ -50,7 +65,6 @@ typedef NS_ENUM(NSInteger, RoomType) { @property (nonatomic , assign) BOOL serverRedEnvelopeSwitch; @property (nonatomic , assign) BOOL isOpenGame; @property (nonatomic , copy) NSString * roomDesc; -@property (nonatomic , assign) BOOL leaveMode; @property (nonatomic , assign) NSInteger officeUser; @property (nonatomic , assign) NSInteger erbanNo; @property (nonatomic , assign) NSInteger audioQuality; @@ -60,6 +74,10 @@ typedef NS_ENUM(NSInteger, RoomType) { @property (nonatomic , assign) BOOL isRoomFans; ///房间密码 @property(nonatomic, copy) NSString *roomPwd; +///是否打开离开模式 +@property (nonatomic, assign) BOOL leaveMode; +///房间的模式 +@property (nonatomic, assign) RoomModeType roomModeType;//房间模式 @end NS_ASSUME_NONNULL_END diff --git a/xplan-ios/Main/Room/View/RoomHeaderView/RoomHeaderView.m b/xplan-ios/Main/Room/View/RoomHeaderView/RoomHeaderView.m index 393c2ee5..f170c441 100644 --- a/xplan-ios/Main/Room/View/RoomHeaderView/RoomHeaderView.m +++ b/xplan-ios/Main/Room/View/RoomHeaderView/RoomHeaderView.m @@ -91,7 +91,8 @@ TTActionSheetConfig *reportRoom = [TTActionSheetConfig normalTitle:@"举报房间" clickAction:^{ XPWebViewController * webVC = [[XPWebViewController alloc] init]; - webVC.url = URLWithType(kReportRoomURL); + NSString *urlstr = [NSString stringWithFormat:@"%@?reportUid=%ld&source=ROOM", URLWithType(kReportRoomURL),self.hostDelegate.getRoomInfo.uid]; + webVC.url = urlstr; [[self.hostDelegate getCurrentNav] pushViewController:webVC animated:YES]; }]; diff --git a/xplan-ios/Main/Room/View/StageView/MicroView/MicroView.m b/xplan-ios/Main/Room/View/StageView/MicroView/MicroView.m index 30bf9f6a..44dea6d2 100644 --- a/xplan-ios/Main/Room/View/StageView/MicroView/MicroView.m +++ b/xplan-ios/Main/Room/View/StageView/MicroView/MicroView.m @@ -31,6 +31,8 @@ @property (nonatomic,strong) UILabel *nickLabel; ///声波动画 @property (nonatomic,strong) MicroWaveView *animationView; +///离开模式 +@property (nonatomic,strong) UILabel *leaveLabel; @end @implementation MicroView @@ -95,6 +97,19 @@ [self configUser:userInfo]; } +- (void)showLeaveMode:(BOOL)isLeaveMode { + if (isLeaveMode) { + [self addSubview:self.leaveLabel]; + [self.leaveLabel mas_makeConstraints:^(MASConstraintMaker *make) { + make.edges.mas_equalTo(self.avatarImageView); + }]; + } else { + if ([self.subviews containsObject:self.leaveLabel]) { + [self.leaveLabel removeFromSuperview]; + } + } +} + - (void)configMicroState:(MicroStateModel *)micState { self.micStateImageView.hidden = micState.micState == MicroMicStateType_Open; UIImage *image; @@ -193,4 +208,20 @@ return _postionLabel; } +- (UILabel *)leaveLabel { + if (!_leaveLabel) { + _leaveLabel = [[UILabel alloc] init]; + _leaveLabel .text = @"离开"; + _leaveLabel .font = [UIFont systemFontOfSize:16]; + _leaveLabel .textColor = UIColor.whiteColor; + _leaveLabel.textAlignment = NSTextAlignmentCenter; + _leaveLabel.backgroundColor = [UIColor colorWithWhite:0 alpha:0.45]; + _leaveLabel.layer.cornerRadius = 65 / 2; + _leaveLabel.layer.masksToBounds = YES; + _leaveLabel.userInteractionEnabled = YES; + } + return _leaveLabel ; +} + + @end diff --git a/xplan-ios/Main/Room/View/StageView/MicroView/MicroViewProtocol.h b/xplan-ios/Main/Room/View/StageView/MicroView/MicroViewProtocol.h index 82b9c8f3..83f35a51 100644 --- a/xplan-ios/Main/Room/View/StageView/MicroView/MicroViewProtocol.h +++ b/xplan-ios/Main/Room/View/StageView/MicroView/MicroViewProtocol.h @@ -12,7 +12,8 @@ NS_ASSUME_NONNULL_BEGIN @class MicroQueueModel; @protocol MicroViewProtocol - +///是否显示离开模式 +- (void)showLeaveMode:(BOOL)isLeaveMode; ///赋值给item - (void)configMicroView:(MicroQueueModel *)model; ///坑位用户正在说话 diff --git a/xplan-ios/Main/Room/View/StageView/StageView.m b/xplan-ios/Main/Room/View/StageView/StageView.m index 5c9cdd84..0d21afe9 100644 --- a/xplan-ios/Main/Room/View/StageView/StageView.m +++ b/xplan-ios/Main/Room/View/StageView/StageView.m @@ -55,7 +55,11 @@ ///可见池 @property (nonatomic,strong) NSMutableSet * giftVisibleArray; - +//TODO 根据自定义消息 更新房间信息 目前就先先放这里 +///离开模式 +@property (nonatomic,assign) BOOL leaveMode; +///正在上麦 防止快速点击的时候 一次操作还未完成 就进行下此操作 +@property (nonatomic,assign) BOOL isUpingMic; @end @implementation StageView @@ -92,7 +96,7 @@ - (void)initRtcRoom { RoomInfoModel* roomInfo = self.hostDelegate.getRoomInfo; - + self.leaveMode = roomInfo.leaveMode; // 1. 加入语音房间。 RtcEngineType type = [roomInfo.audioSdkType isEqualToString:@"wujie"] ? RtcEngineType_WJ : ([roomInfo.audioSdkType isEqualToString:@"zego"] ? RtcEngineType_Zego : RtcEngineType_Agora); [RtcManager initEngineWithType:type delegate:self]; @@ -124,7 +128,7 @@ NSString *position = item.allKeys.firstObject; MicroQueueModel *sequence = [self.micQueue objectForKey:position]; sequence.userInfo = userInfo; - } + } [self microQueueUpdated]; }]; } @@ -136,11 +140,24 @@ * **Note:** 也即意味着其他的方法(回调),仅更新 self.micQueue 数据。 */ - (void)microQueueUpdated { + ///房主开启了 离开模式的话 把他加入到队列中 + if (self.leaveMode) { + RoomInfoModel * roomInfo = self.hostDelegate.getRoomInfo; + UserInfoModel * owner = [[UserInfoModel alloc] init]; + owner.avatar = roomInfo.avatar; + owner.nick = roomInfo.nick; + owner.uid = roomInfo.uid; + owner.gender = roomInfo.gender; + MicroQueueModel * microModel = [self.micQueue objectForKey:@"-1"]; + microModel.userInfo = owner; + } + bool selfNeedBroadcast = NO; for (int i = 0; i < self.countOfMircoView; i++) { UIView * view = [self findMicroViewByIndex:i]; MicroQueueModel * model = [self.micQueue objectForKey:[self indexToPosition:i]]; [view configMicroView:model]; + [view showLeaveMode:i == 0 && self.leaveMode]; if (self.hostDelegate.getUserInfo.uid && model.userInfo.uid == self.hostDelegate.getUserInfo.uid) { // 当前用户在麦上,且该麦位未锁麦 selfNeedBroadcast = model.microState.micState == MicroMicStateType_Open; @@ -198,11 +215,32 @@ int type = [data[@"type"] intValue]; NSArray* microStates; switch (type) { + case 1: + { + // TODO 房间信息更新 需要通知到 更新host中的roominfo 目前s4只影响了离开模式 讨论一下 怎么更新吧 + RoomInfoModel * roomInfo =[RoomInfoModel modelWithJSON:data[@"roomInfo"]]; + self.leaveMode = roomInfo.leaveMode; + if (!roomInfo.leaveMode) { + MicroQueueModel * microModel = [self.micQueue objectForKey:@"-1"]; + microModel.userInfo = nil; + } + + } + break; case 2: microStates = @[[MicroStateModel modelWithJSON:data[@"micInfo"]]]; break; case 3: ///更新了某一个麦序信息 + { microStates = [MicroStateModel modelsWithArray:data[@"micInfo"]]; + // TODO 房间信息更新 需要通知到 更新host中的roominfo 目前s4只影响了离开模式 讨论一下 怎么更新吧 + RoomInfoModel * roomInfo =[RoomInfoModel modelWithJSON:data[@"roomInfo"]]; + self.leaveMode = roomInfo.leaveMode; + if (!roomInfo.leaveMode) { + MicroQueueModel * microModel = [self.micQueue objectForKey:@"-1"]; + microModel.userInfo = nil; + } + } break; } if (microStates && microStates.count > 0) { @@ -326,13 +364,16 @@ NSString * uid = [NSString stringWithFormat:@"%ld", userInfo.uid]; NSString* roomId = [NSString stringWithFormat:@"%ld", roomInfo.roomId]; - void(^nimUpQueue)(NSString*) = ^ (NSString* up){ + void(^nimUpQueue)(NSString*, BOOL) = ^ (NSString* up, BOOL isFromDownMic){ NIMChatroomQueueUpdateRequest *request = [[NIMChatroomQueueUpdateRequest alloc]init]; request.key = up; request.value = [userInfo toJSONString]; request.roomId = roomId; request.transient = YES; [[NIMSDK sharedSDK].chatroomManager updateChatroomQueueObject:request completion:^(NSError * _Nullable error) { + if (isFromDownMic) { + self.isUpingMic = NO; + } if (error) { } @@ -347,10 +388,12 @@ NIMChatroomQueueRemoveRequest *request = [[NIMChatroomQueueRemoveRequest alloc]init]; request.key = firstDown; request.roomId = roomId; - [[NIMSDK sharedSDK].chatroomManager removeChatroomQueueObject:request completion:^(NSError * _Nullable error, NSDictionary * _Nullable element) { + [[NIMSDK sharedSDK].chatroomManager removeChatroomQueueObject:request completion:^(NSError * _Nullable error, NSDictionary * _Nullable element) { if (!error && nextUp) { - nimUpQueue(nextUp); - } + nimUpQueue(nextUp, YES); + } else { + self.isUpingMic = NO; + } }]; }; @@ -358,9 +401,9 @@ NSString* selfUid = [NSString stringWithFormat:@"%ld", (long)self.hostDelegate.getUserInfo.uid]; UIView* microView = [self findMicroViewByUid:selfUid]; if (microView) { - nimDownQueue([self indexToPosition:microView.tag], position); + nimDownQueue([self indexToPosition:microView.tag], position); } else { - nimUpQueue(position); + nimUpQueue(position, NO); } }]; @@ -396,6 +439,10 @@ XPUserCardViewController * userCardVC = [[XPUserCardViewController alloc] initWithUser:model delegate:self.hostDelegate]; [self.hostDelegate.getCurrentNav presentViewController:userCardVC animated:YES completion:nil]; } else { + if (roomInfo.roomModeType == RoomModeType_Open_Micro_Mode || roomInfo.roomModeType == RoomModeType_Open_Blind) { + [XCHUDTool showErrorWithMessage:@"当前上麦需要主持操作,无法自主上麦"]; + return; + } NIMChatroomMembersByIdsRequest *request = [[NIMChatroomMembersByIdsRequest alloc]init]; request.roomId = roomId; request.userIds = @[uid]; @@ -403,10 +450,21 @@ NIMChatroomMember * member = members.firstObject; if (member == nil) {return;} if (member.type == NIMTeamMemberTypeOwner || member.type == NIMTeamMemberTypeManager) {///管理员的话 - [TTPopup actionSheetWithItems:@[upMic, lockMic, muteMic]]; + [TTPopup actionSheetWithItems:@[upMic, lockMic, muteMic]]; } else { if (micModel.microState.posState == MicroPosStateType_Lock) return; - nimUpQueue(position); + NSString* selfUid = [NSString stringWithFormat:@"%ld", (long)self.hostDelegate.getUserInfo.uid]; + UIView* microView = [self findMicroViewByUid:selfUid]; + if (microView) { + if (self.isUpingMic) { + [XCHUDTool showErrorWithMessage:@"正在上麦"]; + } else { + self.isUpingMic = YES; + nimDownQueue([self indexToPosition:microView.tag], position); + } + } else { + nimUpQueue(position, NO); + } } }]; }