// // RoomHomeViewController.m // DingDangApp // // Created by apple on 2023/5/27. // #import "RoomViewController.h" #import "RoomInfoView.h" #import "RoomToolView.h" #import "RoomPublicMessageView.h" #import "RoomMicroView.h" #import "RoomUserMicroView.h" #import "AppDelegate.h" #import "RoomPopTool.h" #import "RoomSocketMsgModel.h" #import "RoomInfoModel.h" #import "RoomMicroModel.h" #import "RoomUserInfoModel.h" #import "AgoraTool.h" #import "RoomGIftModel.h" #import "DDMInputView.h" #import "RoomPublicScreenModel.h" #import "RoomSmallView.h" #import "DDMyInfoReportViewController.h" #import "SVGATool.h" #import "InRoomSVGATool.h" #import "SVGA.h" #import "DDMyInformationDynamicViewController.h" #import "CreatRoomViewController.h" #import "RoomEditPassWordView.h" #import "RoomWarningView.h" #import "RoomBlackView.h" #import "ConversationListVC.h" #import "RoomRightOnLineUserListView.h" #import "RoomAirPlaneView.h" #import "RoomLevelPlaneView.h" #import "DDBannerModel.h" #import "DDNobleHomeViewController.h" #import "DDWebViewController.h" #import "RoomEventView.h" #import "DDMyInformationViewController.h" #import "RoomConfigModel.h" #import "DDMsgInputView.h" #import "DDEmojiInputView.h" /// Tool #import "DDRoomRequest.h" #import "DDClientConfig.h" #import "TTPopup.h" /// Model #import "UserInfoModel.h" #import "RoomInfoModel.h" #import "DDMessageCustomRemoteExtModel.h" /// Third #import static RoomViewController *roomVC = nil; static dispatch_once_t onceToken; @interface RoomViewController () /**直播间信息*/ @property (nonatomic,strong) DDAnimateImageView *bgImageView; /**直播间信息*/ @property (nonatomic,strong) RoomInfoView *infoView; /**公告按钮*/ @property (nonatomic,strong) UIButton *tipBtn; /**魅力值逻辑*/ @property (nonatomic,strong) UIButton *hostCharmBtn; /**榜单按钮*/ @property (nonatomic,strong) UIButton *rankBtn; /**底部管理*/ @property (nonatomic,strong) RoomToolView *toolView; /**自定义表情键盘**/ @property (nonatomic, strong) DDMInputView *myInputView; /**主持人麦位*/ @property (nonatomic,strong) RoomMicroView *hostMicroView; /**嘉宾*麦位*/ @property (nonatomic,strong) RoomMicroView *guestMicroView; /**用户麦位*/ @property (nonatomic,strong) RoomUserMicroView *userMicroView; /**麦序按钮*/ @property (nonatomic,strong) UIButton *microListBtn; /**活动按钮*/ @property (nonatomic,strong) RoomEventView *roomEventView; /**公屏信息*/ @property (nonatomic,strong) RoomPublicMessageView *publicMessageView; ///公屏 //@property (nonatomic,strong) XPRoomMessageContainerView *messageContainerView; @property (nonatomic, strong) NSMutableArray *timeArray; /**房间信息*/ @property (nonatomic,strong) RoomInfoModel *roomInfoModel; ///禁言计时器 @property (nonatomic, strong) dispatch_source_t wordsTimer; ///禁麦计时器 @property (nonatomic, strong) dispatch_source_t micTimer; ///在线列表 @property (nonatomic,strong) RoomRightOnLineUserListView *onlineUserListView; ///礼物 @property (nonatomic,strong) SVGATool *svgaTool; @property (nonatomic, strong) SVGAPlayer *svgaPlayer; @property (nonatomic, strong) SVGAParser *parser; ///进入房间 @property (nonatomic, strong) SVGAPlayer *inRoomSvgaPlayer; @property (nonatomic, strong) SVGAParser *inRoomParser; @property (nonatomic, strong) InRoomSVGATool *inRoomSVGATool; ///大礼物飘屏view @property (nonatomic,strong) RoomAirPlaneView *airPlaneView; ///升级飘屏view @property (nonatomic,strong) RoomLevelPlaneView *levelPlaneView; @property (nonatomic, assign) BOOL isAirPlane; @property (nonatomic, assign) BOOL isLevelUpAirPlane; /* 飞机数组 */ @property (nonatomic, strong) NSMutableArray * airplaneArray; /* 升级飘屏数组 */ @property (nonatomic, strong) NSMutableArray * levelUpAirplaneArray; @property (nonatomic, strong) UIButton * popBgButton; @property (nonatomic, strong) DDWebViewController * halfActiveWebVC; //是否出现半屏 @property (nonatomic, assign) BOOL isHalfClick; ///弹幕 /// 用户信息 @property (nonatomic, strong) UserInfoModel *userInfo; /// 房间信息 @property (nonatomic, strong) RoomInfoModel *roomInfo; @end @implementation RoomViewController #pragma mark - Dealloc - (void)dealloc{ [[NSNotificationCenter defaultCenter] removeObserver:self]; [_svgaTool destroy]; [_inRoomSVGATool destroy]; [_svgaPlayer clear]; [_inRoomSvgaPlayer clear]; if (_svgaPlayer) { _svgaPlayer.delegate = nil; [_svgaPlayer removeFromSuperview]; _svgaPlayer = nil; } if (_inRoomSvgaPlayer) { _inRoomSvgaPlayer.delegate = nil; [_inRoomSvgaPlayer removeFromSuperview]; _inRoomSvgaPlayer = nil; } [self removeNoticationNIM]; } #pragma mark - Public Method + (instancetype)shareVC{ dispatch_once(&onceToken, ^{ roomVC = [[RoomViewController alloc] init]; }); return roomVC; } + (void)destoryVC;{ [[AgoraTool shareTool] goOutRoom:^(AgoraChannelStats * _Nonnull stat) { [AgoraTool destroyShareTool]; }]; AppDelegate *delegate = (AppDelegate*)kAppDelegate; delegate.inRoom = NO; [[AppMessageManager shareManager] sendLeaveRoomMessage]; onceToken = 0; roomVC = nil; } - (void)goCreatRoomViewController{ CreatRoomViewController *vc = [[CreatRoomViewController alloc] init]; vc.adminId = [self.roomInfoModel.homeowner.user_id integerValue]; vc.roomAuth = [self.roomInfoModel.room_auth integerValue]; vc.roomInfo = self.roomInfoModel.room_info; vc.isUpDate = YES; [self.navigationController pushViewController:vc animated:YES]; } - (void)goReportRoom{ DDMyInfoReportViewController *vc = [[DDMyInfoReportViewController alloc] init]; vc.juBaoType = 1; vc.jubao_id = self.roomID; [self.navigationController pushViewController:vc animated:YES]; } #pragma mark - Life Cycle - (void)viewDidLoad { [super viewDidLoad]; AppDelegate *delegate = (AppDelegate*)kAppDelegate; delegate.inRoom = YES; [[AppMessageManager shareManager].delegate addDelegate:self delegateQueue:dispatch_get_main_queue()]; [AppMessageManager shareManager].roomID = self.roomID; [[DDMTool sharedTool] observationInform:self sel:@selector(messageUnreadNumber:) notificationName:[[DDMTool sharedTool]getinformType:(YVMessageNotice_MessageUnreadNumber)]]; //发送进入房间消息 [[AppMessageManager shareManager] sendJoinRoomMessage:self.roomID passWord:self.roomPassWord follow_user_id:[ToolsObject isBlankString:self.followUserModel.user_id]]; [DDRoomRequest DD_GetRoomUserInformationWithRoomUid:self.roomID success:^(RoomInfoModel * _Nonnull roomInfo, UserInfoModel * _Nonnull userInfo) { userInfo.fromUid = self.followUserModel.user_id; // userInfo.fromType = self.followUserModel. userInfo.fromNick = self.followUserModel.nickname; // roomInfo.hasAnimationEffect; self.roomInfo = roomInfo; self.userInfo = userInfo; if (roomInfo.valid) { [DDRoomRequest DD_EnterNIMRoom:[NSString stringWithFormat:@"%ld", self.roomInfo.roomId] User:self.userInfo]; } else { if ([self.roomID isEqualToString:[NSString stringWithFormat:@"%ld", userInfo.uid]]) { if (roomInfo.roomId > 0) { [DDRoomRequest DD_OpenRoomTitle:roomInfo.title type:roomInfo.type roomPwd:roomInfo.roomPwd roomDesc:roomInfo.roomDesc backPic:@"" mgId:@"" success:^(RoomInfoModel * _Nonnull roomInfo) { [DDRoomRequest DD_EnterNIMRoom:[NSString stringWithFormat:@"%ld",roomInfo.roomId] User:self.userInfo]; } fail:^(NSError * _Nonnull error) { }]; } } } NSLog(@"roomInfo: %@ ---- userInfo:%@", roomInfo, userInfo); } fail:^(NSError * _Nonnull error) { }]; [self creatView]; [self initBlock]; [self addNoticationNIM]; [self createPlayer]; //礼物飘屏测试 // for (NSInteger i = 0; i<100; i++) { // RoomGiftAirPlaneModel *airModel = [[RoomGiftAirPlaneModel alloc]init]; // airModel.user_name = @"1111"; // airModel.user_id = @"1"; // airModel.avatar = @""; // airModel.giftName = @"1111"; // airModel.giftNum = 1; // airModel.small_img = @"1"; // airModel.isBarrage = 3; // [self showAirPlaneViewToModel:airModel]; // } } #pragma mark - NIMChatroomManagerDelegate - (void)chatroomBeKicked:(NIMChatroomBeKickedResult *)result { } #pragma mark - NIMChatManagerDelegate /// 接收消息 - (void)onRecvMessages:(NSArray *)messages { NSLog(@"message:%@",messages); for (NIMMessage *message in messages) { if (message.messageType == NIMMessageTypeNotification) { [self.publicMessageView handleRecvMessages: message]; } } } /// 发送消息 - (void)sendMessage:(NIMMessage *)message didCompleteWithError:(NSError *)error { } #pragma mark - NIMConversationManagerDelegate - (void)didAddRecentSession:(NIMRecentSession *)recentSession totalUnreadCount:(NSInteger)totalUnreadCount { } - (void)didUpdateRecentSession:(NIMRecentSession *)recentSession totalUnreadCount:(NSInteger)totalUnreadCount { } - (void)didRemoveRecentSession:(NIMRecentSession *)recentSession totalUnreadCount:(NSInteger)totalUnreadCount { } #pragma mark - NIMLoginManagerDelegate - (void)onKickout:(NIMLoginKickoutResult *)result { } #pragma mark - Notication(监听) - (void)addNoticationNIM { [[NIMSDK sharedSDK].chatroomManager addDelegate:self]; [[NIMSDK sharedSDK].chatManager addDelegate:self]; [[NIMSDK sharedSDK].loginManager addDelegate:self]; [[NIMSDK sharedSDK].conversationManager addDelegate:self]; } - (void)removeNoticationNIM { NSLog(@"房间销毁了"); [[NIMSDK sharedSDK].chatroomManager removeDelegate:self]; [[NIMSDK sharedSDK].chatManager removeDelegate:self]; [[NIMSDK sharedSDK].loginManager removeDelegate:self]; [[NIMSDK sharedSDK].conversationManager removeDelegate:self]; } #pragma mark --关闭房间 - (void)closeRoomClosrSmoll:(BOOL)closeSmoll{ WeakSelf(ws); [self dismissViewControllerAnimated:YES completion:^{ if(closeSmoll){ [RoomViewController destoryVC]; }else{ [ws showSmollView]; } }]; } - (void)showSmollView{ WeakSelf(ws); self.roomInfoModel.showSmollView = YES; RoomSmallView *view = [RoomSmallView shareView]; view.isKeep = YES; [view reloadWithData:self.roomInfoModel.room_info]; [view showView]; view.backEnterBlock = ^{ ws.roomInfoModel.showSmollView = NO; AppDelegate *delegate = (AppDelegate*)kAppDelegate; delegate.inRoom = YES; UINavigationController * nav = [[UINavigationController alloc] initWithRootViewController:[RoomViewController shareVC]]; nav.modalPresentationStyle = UIModalPresentationOverFullScreen; nav.modalTransitionStyle = UIModalTransitionStyleCoverVertical; [[ToolsObject getCurrentViewController] presentViewController:nav animated:YES completion:^{}]; }; view.backCloseBlock = ^{ ws.roomInfoModel.showSmollView = NO; }; } ///被动离开房间 - (void)makeToGoOutRoom:(NSDictionary*)dataDic type:(NSInteger)type{ /**type 1被踢出房间 */ /**type2被拉黑 */ /**type 3被封禁*/ /**type 4房间被封禁*/ [[AppMessageManager shareManager].delegate makeGoOutRoom:dataDic type:type]; @weakify(self) dispatch_async(dispatch_get_main_queue(), ^{ [self dismissViewControllerAnimated:YES completion:^{ @strongify(self) [RoomViewController destoryVC]; if (type == 2) { NSString * blacklist_desc = dataDic[@"blacklist_desc"]; NSString * blacklist_time = dataDic[@"blacklist_time"]; if ([ToolsObject IsNullWithObject:blacklist_desc]||[ToolsObject IsNullWithObject:blacklist_time]) { return; } UIAlertController *alertVC = [UIAlertController alertControllerWithTitle:[NSString stringWithFormat:@"您已被该房间拉黑(%@),\n将无法进入该房间,原因如下",blacklist_time] message:blacklist_desc preferredStyle:UIAlertControllerStyleAlert]; UIAlertAction *cancelaction = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleDefault handler:nil]; UIAlertAction *sendaction = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) { }]; [alertVC addAction:cancelaction]; [alertVC addAction:sendaction]; [self presentViewController:alertVC animated:YES completion:nil]; return; } if (type == 1) { if (![ToolsObject IsNullWithObject:dataDic]) { if (![ToolsObject IsNullWithObject:dataDic[@"msg"]]) { [ToolsObject addPopVieToText:dataDic[@"msg"]]; } } return; } if (type == 4) { NSString * reason = dataDic[@"reason"]; NSString * owner_id = [NSString stringWithFormat:@"%ld",[dataDic[@"room_user_id"]integerValue]]; if ([owner_id isEqualToString:[ToolsObject getUserModel].user_id]) { UIAlertController *alertVC = [UIAlertController alertControllerWithTitle:@"您的房间已被封禁,请联系客服\n进行解封,封禁原因如下" message:reason?:@"违反社区规定" preferredStyle:UIAlertControllerStyleAlert]; UIAlertAction *cancelaction = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleDefault handler:nil]; UIAlertAction *sendaction = [UIAlertAction actionWithTitle:@"联系客服" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) { [ToolsObject goAppService]; }]; [alertVC addAction:cancelaction]; [alertVC addAction:sendaction]; [self presentViewController:alertVC animated:YES completion:nil]; } return; } }]; }); } - (void)creatView{ [self bgImageView]; [self infoView]; [self tipBtn]; [self hostCharmBtn]; [self rankBtn]; [self hostMicroView]; [self guestMicroView]; [self userMicroView]; [self toolView]; [self microListBtn]; [self roomEventView]; //[self myInputView]; [self publicMessageView]; [self requestBaseConfig]; [self.view addSubview:self.svgaPlayer]; [self.view addSubview:self.inRoomSvgaPlayer]; [self.view addSubview:self.airPlaneView]; [self.view addSubview:self.levelPlaneView]; [self onlineUserListView]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(popUserInfoViewToUserID:) name:K_PopUserInfoViewToUserIDKey object:nil]; UISwipeGestureRecognizer * leftSwipeGestureRecognizer = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(handleSwipes:)]; leftSwipeGestureRecognizer.delegate = self; leftSwipeGestureRecognizer.direction = UISwipeGestureRecognizerDirectionLeft; [self.view addGestureRecognizer:leftSwipeGestureRecognizer]; UISwipeGestureRecognizer * rightSwipeGestureRecognizer = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(handleSwipes:)]; rightSwipeGestureRecognizer.delegate = self; rightSwipeGestureRecognizer.direction = UISwipeGestureRecognizerDirectionRight; [self.view addGestureRecognizer:rightSwipeGestureRecognizer]; } - (void)requestBaseConfig{ WeakSelf(weakSelf) [NetworkRequest requestPOST:@"/common/base" parameters:@{} block:^(BaseResponse * _Nonnull response) { if ([ToolsObject IsNullWithObject:response.data]) { return; } RoomConfigModel * model = [RoomConfigModel mj_objectWithKeyValues:response.data]; weakSelf.roomEventView.hidden = !model.app.version.is_normal; }]; } - (void)handleSwipes:(UISwipeGestureRecognizer *)sender { if(sender.direction == UISwipeGestureRecognizerDirectionRight) { @weakify(self) //通知主线程刷新 dispatch_async(dispatch_get_main_queue(), ^{ @strongify(self); [self closeRoomClosrSmoll:NO]; }); }else if (sender.direction == UISwipeGestureRecognizerDirectionLeft){ [self showOnlineUserListView]; } } - (void)popUserInfoViewToUserID:(NSNotification *)noti { if ([noti.object isKindOfClass:[NSDictionary class]]) { NSDictionary * dataDict = noti.object; NSString *user_id = dataDict[@"user_id"]?:@""; NSString *room_id = dataDict[@"room_id"]?:@""; if (room_id == self.roomID){ [self popUserInfoViewToUserID:user_id roomID:room_id curentVC:self]; } } } - (void)messageUnreadNumber:(NSNotification*)notifciation{ NSInteger sessionUnreadNumber = [[DDFMDBMessageTool sharedManager]allSessionUnreadMessageNumber]; NSString * noticeUnreadNumber = [DDMTool sharedTool].noticeUnreadCount; if ([noticeUnreadNumber integerValue]>0) { sessionUnreadNumber = sessionUnreadNumber + [noticeUnreadNumber integerValue]; } NSString * systemUnreadNumber = [DDMTool sharedTool].systemUnreadCount; if ([systemUnreadNumber integerValue]>0) { sessionUnreadNumber = sessionUnreadNumber + [systemUnreadNumber integerValue]; } NSString * interactiveUnreadCountNumber = [DDMTool sharedTool].interactiveUnreadCount; if ([interactiveUnreadCountNumber integerValue]>0) { sessionUnreadNumber = sessionUnreadNumber + [interactiveUnreadCountNumber integerValue]; } NSString * broadcastUnreadCountNumber = [DDMTool sharedTool].broadcastUnreadCount; if ([broadcastUnreadCountNumber integerValue]>0) { sessionUnreadNumber = sessionUnreadNumber + [broadcastUnreadCountNumber integerValue]; } NSString * totalSessionUnreadNumber = [NSString stringWithFormat:@"%@",[NSNumber numberWithInteger:sessionUnreadNumber]]; if (sessionUnreadNumber>99) { totalSessionUnreadNumber = @"99+"; } if (sessionUnreadNumber<=0) { totalSessionUnreadNumber = @""; sessionUnreadNumber = 0; } dispatch_async(dispatch_get_main_queue(), ^{ [self.toolView reloadMessageNumStr:totalSessionUnreadNumber]; }); } #pragma mark --AppMessageManager #pragma mark -- 播放动画 ///播放礼物动画 - (void)sendPlaySvga:(NSDictionary *)dataDic{ if(self.roomInfoModel.isPlayGift){ _svgaTool.isPlay = YES; NSString *svgaUrl =dataDic[@"svgaUrl"]; int count =[dataDic[@"count"] intValue]; NSInteger animationType =[dataDic[@"animationType"] integerValue]; _svgaTool.playUrl = svgaUrl; [UIApplication sharedApplication].networkActivityIndicatorVisible = YES; if(animationType ==2){ self.svgaPlayer.contentMode = UIViewContentModeScaleAspectFit; }else{ self.svgaPlayer.contentMode = UIViewContentModeScaleAspectFill; } SVGAVideoEntity *cacheItem = [SVGAVideoEntity readCache:svgaUrl.MD5String]; if (cacheItem) { self.svgaPlayer.videoItem = cacheItem; self.svgaPlayer.loops = count; [self.svgaPlayer startAnimation]; }else{ WeakSelf(ws); [self.parser parseWithURL:[NSURL URLWithString:svgaUrl] completionBlock:^(SVGAVideoEntity * _Nullable videoItem) { if (videoItem != nil) { ws.svgaPlayer.videoItem = videoItem; ws.svgaPlayer.loops = count; dispatch_async(dispatch_get_main_queue(), ^{ [ws.svgaPlayer startAnimation]; }); } } failureBlock:^(NSError * _Nullable error) { ws.svgaTool.isPlay = NO; ws.svgaTool.playUrl = @""; }]; } } } ///播放进场动画 - (void)sendPlayInRoomSvga:(NSDictionary *)dataDic{ if(self.roomInfoModel.isPlayGift){ _inRoomSVGATool.isPlay = YES; NSString *svgaUrl =dataDic[@"svgaUrl"]; _inRoomSVGATool.playUrl = svgaUrl; [UIApplication sharedApplication].networkActivityIndicatorVisible = YES; self.inRoomSvgaPlayer.contentMode = UIViewContentModeScaleAspectFill; SVGAVideoEntity *cacheItem = [SVGAVideoEntity readCache:svgaUrl.MD5String]; NSString * intoRoomString = [NSString stringWithFormat:@" 进入本房间"]; NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc]init]; paragraphStyle.alignment = NSTextAlignmentLeft; paragraphStyle.lineBreakMode = NSLineBreakByCharWrapping; paragraphStyle.baseWritingDirection = NSWritingDirectionLeftToRight; NSDictionary *intoRoomAttributes = @{NSFontAttributeName:KFont(16), NSForegroundColorAttributeName:[UIColor whiteColor],NSParagraphStyleAttributeName:paragraphStyle}; NSAttributedString * intoRoomAttributedString = [[NSMutableAttributedString alloc] initWithString:intoRoomString attributes:intoRoomAttributes]; NSString * nickname = [NSString stringWithFormat:@" %@",dataDic[@"nickname"]]; NSString * level_icon = dataDic[@"level_icon"]; NSString * avatar = dataDic[@"avatar"]; NSDictionary *nicknameAttributes = @{NSFontAttributeName:KFont(16), NSForegroundColorAttributeName:[UIColor whiteColor],NSParagraphStyleAttributeName:paragraphStyle}; NSAttributedString * nicknameAttributedString = [[NSMutableAttributedString alloc] initWithString:nickname attributes:nicknameAttributes]; //昵称 [self.inRoomSvgaPlayer setAttributedText:nicknameAttributedString forKey:@"01"]; //进入房间提示 [self.inRoomSvgaPlayer setAttributedText:intoRoomAttributedString forKey:@"02"]; //头像 [self.inRoomSvgaPlayer setImageWithURL:[NSURL URLWithString:avatar] forKey:@"03"]; //等级 [self.inRoomSvgaPlayer setImageWithURL:[NSURL URLWithString:level_icon] forKey:@"04"]; if (cacheItem) { self.inRoomSvgaPlayer.videoItem = cacheItem; self.inRoomSvgaPlayer.loops = [dataDic[@"loopCount"] intValue]; [self.inRoomSvgaPlayer startAnimation]; }else{ WeakSelf(ws); [self.inRoomParser parseWithURL:[NSURL URLWithString:dataDic[@"giftSvga"]] completionBlock:^(SVGAVideoEntity * _Nullable videoItem) { if (videoItem != nil) { ws.inRoomSvgaPlayer.videoItem = videoItem; ws.inRoomSvgaPlayer.loops = [dataDic[@"loopCount"] intValue]; dispatch_async(dispatch_get_main_queue(), ^{ [ws.inRoomSvgaPlayer startAnimation]; }); } } failureBlock:^(NSError * _Nullable error) { ws.inRoomSVGATool.isPlay = NO; ws.inRoomSVGATool.playUrl = @""; }]; } } } //播放完成改变正在播放的状态,并播放队列中下一个动画 - (void)svgaPlayerDidFinishedAnimation:(SVGAPlayer *)player { if (player == self.svgaPlayer) { _svgaTool.isPlay = NO; _svgaTool.playUrl = @""; [_svgaTool addAnimation]; } if (player == self.inRoomSvgaPlayer) { _inRoomSVGATool.isPlay = NO; _inRoomSVGATool.playUrl = @""; [_inRoomSVGATool addAnimation]; } } - (void)svgaPlayerDidAnimatedToPercentage:(CGFloat)percentage{ } ///发送爵位升级 - (void)sendNobilityLevelUp:(NSDictionary*)dataDic{ if ([ToolsObject IsNullWithObject:dataDic]) { return; } NSString * nobility_name = dataDic[@"nobility_name"]; NSString * avatar = dataDic[@"avatar"]; NSString * nickname = dataDic[@"nickname"]; NSString * background = dataDic[@"background"]; if ([ToolsObject IsNullWithObject:nobility_name]||[ToolsObject IsNullWithObject:avatar]||[ToolsObject IsNullWithObject:nickname]||[ToolsObject IsNullWithObject:background]) { return; } [self.levelUpAirplaneArray addObject:dataDic]; if (!self.isLevelUpAirPlane) { [self levelUpAirPlaneViewShowAnimation]; } } #pragma mark --刷新房间ui和数据 ///刷新房间配置和数据 - (void)reloadRoomInfo{ [ToolsObject DismissSVProgressHUD]; if([ToolsObject isBlankString:self.roomInfoModel.room_info.room_pwd].length>0){ self.roomInfoModel.isLock = YES; } self.roomInfoModel.isPlayGift = YES; self.roomInfoModel.muteState = YES; self.roomInfoModel.micListCount = self.roomInfoModel.row_mic_number; } ///刷新房间所有UI - (void)reloadRoomUI{ [self reloadInfoView]; [self reloadTooView]; } ///刷新房间信息UI - (void)reloadInfoView{ //通知主线程刷新 dispatch_async(dispatch_get_main_queue(), ^{ [self.infoView.headerImageView ddSetAnimatedImageView:[NSURL URLWithString:self.roomInfoModel.adminMicModel.avatar] placeholderImage:nil]; self.infoView.nameLabel.text =self.roomInfoModel.room_info.room_name; self.infoView.idLabel.text = [NSString stringWithFormat:@"ID:%@ 人气:%@",self.roomInfoModel.room_info.room_number,self.roomInfoModel.popularityString]; self.infoView.collectionBtn.hidden = self.roomInfoModel.is_collect; [self.bgImageView ddSetAnimatedImageView:[NSURL URLWithString:self.roomInfoModel.room_info.room_image] placeholderImage:KGetImage(@"room_0")]; }); } ///刷新底部UI - (void)reloadTooView{ [self.toolView reloadData:self.roomInfoModel]; } ///刷新管理麦位 - (void)reloadManageMicroUI{ // if(self.roomInfoModel.room_info.open_type ==1){ self.hostMicroView.microModel = self.roomInfoModel.adminMicModel; // self.hostMicroView.hidden = NO; // self.guestMicroView.hidden = YES; // }else{ // self.hostMicroView.microModel = self.roomInfoModel.hostMicModel; // self.guestMicroView.hidden = YES; // self.hostMicroView.hidden = NO; // } self.guestMicroView.microModel = self.roomInfoModel.honorGuestMicModel; } ///刷新普通麦位 - (void)reloadUserMicroUI{ [self.userMicroView reloadMicroData:[NSMutableArray arrayWithArray:self.roomInfoModel.userMicroArray.mutableCopy]]; } - (void)getGiftsAndEvent{ [self requestGetShopGifts]; [self requestGetluckGifts]; [self requestGetPricileGifts]; [self requestGetpackageGifts]; [self requestGetGiftCountArray]; [self getEventList]; } #pragma mark --刷新麦序按钮 - (void)reloadMicroListBtn:(NSInteger)microListCount{ [[AppMessageManager shareManager].delegate reloadMiceoListCount:self.roomInfoModel.micListCount]; BOOL isFangzhu = ([self.roomInfoModel.room_auth integerValue] == 2 || [[ToolsObject getUserModel].user_id isEqualToString:self.roomInfoModel.homeowner.user_id]); BOOL isFangGuan = ([self.roomInfoModel.room_auth integerValue] == 5 ||[self.roomInfoModel.room_auth integerValue] == 3); BOOL isChaoGuan = [self.roomInfoModel.room_auth integerValue] == 1; WeakSelf(ws); dispatch_async(dispatch_get_main_queue(), ^{ if (isChaoGuan) { //超管隐藏按钮 ws.microListBtn.hidden = YES; return; } ws.microListBtn.hidden = NO; if (isFangzhu || isFangGuan) { [ws.microListBtn setTitle:[NSString stringWithFormat:@"麦序\n%ld",(long)microListCount] forState:UIControlStateNormal]; ws.roomInfoModel.currentUpMicType = RoomSetType_microList; }else{ if (ws.roomInfoModel.isMicUp) { if(isChaoGuan){ [ws.microListBtn setTitle:[NSString stringWithFormat:@"麦序\n%ld",(long)microListCount] forState:UIControlStateNormal]; ws.roomInfoModel.currentUpMicType = RoomSetType_microList; }else{ [ws.microListBtn setTitle:@"下麦" forState:UIControlStateNormal]; ws.roomInfoModel.currentUpMicType = RoomSetType_microDown; } }else if(ws.roomInfoModel.isInMicList){ [ws.microListBtn setTitle:[NSString stringWithFormat:@"麦序\n%ld",(long)microListCount] forState:UIControlStateNormal]; ws.roomInfoModel.currentUpMicType = RoomSetType_microList; }else{//麦下 if(isChaoGuan){ [ws.microListBtn setTitle:[NSString stringWithFormat:@"麦序\n%ld",(long)microListCount] forState:UIControlStateNormal]; ws.roomInfoModel.currentUpMicType = RoomSetType_microList; }else{ [ws.microListBtn setTitle:@"上麦\n互动" forState:UIControlStateNormal]; ws.roomInfoModel.currentUpMicType = RoomSetType_microUp; } } } }); } #pragma mark --btnClick #pragma mark --麦序按钮点击 - (void)microListBtnClick{ KRepeatClickTime(1); WeakSelf(ws); dispatch_async(dispatch_get_main_queue(), ^{ switch (ws.roomInfoModel.currentUpMicType) { case RoomSetType_microUp: { [RoomPopTool popMicroManageToRoomID:ws.roomID microModel:[RoomMicroModel new] menuArray:@[@"上麦"] curentVC:ws selectItem:^(NSString * _Nonnull itemStr) { [ws microSetToStr:itemStr microModel:nil]; }]; } break; case RoomSetType_microDown: { [RoomPopTool popMicroManageToRoomID:ws.roomID microModel:[RoomMicroModel new] menuArray:@[@"下麦"] curentVC:ws selectItem:^(NSString * _Nonnull itemStr) { [ws microSetToStr:itemStr microModel:nil]; }]; } break; case RoomSetType_microList: { [ws hugUpMicro:@""]; } break; default: break; } }); } - (void)popButtonClick { NSLog(@"销毁半屏vc"); if (self.halfActiveWebVC) { [self dismissWebVc:self.halfActiveWebVC]; } } #pragma mark --弹出麦序列表 - (void)hugUpMicro:(NSString *)microID{ NSInteger room_auth = [self.roomInfoModel.room_auth integerValue]; BOOL isManager = NO; if (room_auth == 2 || room_auth == 5|| room_auth == 3) { isManager = YES; } WeakSelf(ws); [RoomPopTool popRoomMicroListViewToRoomInfoModel:self.roomInfoModel roomID:self.roomID userID:[ToolsObject getUserModel].user_id curentVC:self isManager:isManager microID:microID selectItem:^(RoomMicroModel * _Nonnull model, BOOL isSet, NSString * _Nonnull miscroID) { if(isSet){ if(![ToolsObject IsNullWithObject:miscroID]){ //抱上麦 [[AppMessageManager shareManager] sendHugUpMicroMessage:self.roomID microID:miscroID userID:model.user_id]; }else if(![ToolsObject IsNullWithObject:model.mic_id]){ //抱上麦 [[AppMessageManager shareManager] sendHugUpMicroMessage:self.roomID microID:model.mic_id userID:model.user_id]; }else{ NSString *microid = [ws getIdleMicRo]; //抱上麦 [[AppMessageManager shareManager] sendHugUpMicroMessage:self.roomID microID:microid userID:model.user_id]; } }else{ [ws popUserInfoViewToUserID:model.user_id roomID:self.roomID curentVC:ws]; } }]; } #pragma mark --麦位表情 - (void)showMicRoEmojiMessageToUser:(NSString *)userID url:(NSString *)url{ dispatch_async(dispatch_get_main_queue(), ^{ if ([userID isEqualToString:self.roomInfoModel.hostMicModel.user_id]) { [self.hostMicroView starAnimateEmojiImage:url]; }else if ([userID isEqualToString:self.roomInfoModel.honorGuestMicModel.user_id]){ [self.guestMicroView starAnimateEmojiImage:url]; }else{ [self.userMicroView showMicRoEmojiMessageToUser:userID url:url]; } }); } #pragma mark --公告/榜单按钮点击 - (void)setRoomInfo:(RoomInfoModel *)roomInfo { _roomInfo = roomInfo; [self.publicMessageView roomInfo:roomInfo]; } - (void)tipBtnClick{ KRepeatClickTime(1); [RoomPopTool popRoomTipToText:self.roomInfo.roomDesc curentVC:self]; } /// 排行榜 - (void)rankBtnClick{ // NSString *url = @""; // if([DDClientConfig shareConfig].configInfo.h5Uris.count > 0){ // for (DDClientH5UserModel *h5Model in [DDClientConfig shareConfig].configInfo.h5Uris) { // if([h5Model.code isEqualToString:@"roomRank"]){ // url = h5Model.uri; // break;; // } // } // } // // // /// 排行榜 // DDWebViewController *controller = [DDWebViewController webControlerWithUrlStr:[NSString stringWithFormat:@"%@/modules/room_rank/index.html",API_HOST_H5_URL] isShowNavBar:NO isHalf:YES data:@{@"roomUid":self.roomID}]; // [self.navigationController pushViewController:controller animated:normal]; KRepeatClickTime(1); NSString * routing = @"http://beta.api.nnbc123.cn/yinmeng/modules/roomRank/index.html?roomUid=200343"; // [NSString stringWithFormat:@"%@/yinmeng/modules/room_rank/index.html?roomUid=%@",@"http://beta.api.nnbc123.cn",self.roomID]; DDWebViewController *webVc = [DDWebViewController webControlerWithUrlStr:routing isShowNavBar:NO isHalf:YES data:@{@"room_id":self.roomID}]; WeakSelf(ws); webVc.goUserInfoBlock = ^(NSString * _Nonnull userID) { DDMyInformationViewController * infoVC = [[DDMyInformationViewController alloc] init]; infoVC.user_id = userID; [ws.navigationController pushViewController:infoVC animated:YES]; }; // [self presentViewController:webVc animated:NO completion:nil]; // [TTPopup popupView:webVc style:TTPopupStyleActionSheet]; XPSemiModalConfiguration *config = [XPSemiModalConfiguration defaultConfiguration]; config.backgroundOpacity = 0.5; config.enableBackgroundAnimation = NO; config.enableShadow = NO; config.shouldDismissModal = YES; [self presentSemiModalViewController:webVc contentHeight:kWidth * 1.6 configuration:config completion:^{ }dismissClickBlock:^{ }]; } #pragma mark --房主魅力值按钮点击 - (void)hostCharmBtnClick{ WeakSelf(ws); // [self requestPopUserSetToMicroModel:self.roomInfoModel.adminMicModel onMic:YES]; if(self.roomInfoModel.room_auth.integerValue ==2||self.roomInfoModel.room_auth.integerValue ==3 ||self.roomInfoModel.room_auth.integerValue ==5){ NSMutableArray * totalArr = [NSMutableArray array]; [totalArr addObject:@"清空麦位值"]; [totalArr addObject:@"查看魅力值数据"]; dispatch_async(dispatch_get_main_queue(), ^{ [RoomPopTool popMicroManageToRoomID:ws.roomID microModel: self.roomInfoModel.adminMicModel menuArray:totalArr curentVC:ws selectItem:^(NSString * _Nonnull itemStr) { [ws microSetToStr:itemStr microModel:ws.roomInfoModel.adminMicModel]; }]; }); }else{ if([ToolsObject isBlankString:self.roomInfoModel.adminMicModel.user_id].length >0){ [RoomPopTool popRoomCharmViewToRoomInfoModel:self.roomInfoModel roomID:self.roomID userID:self.roomInfoModel.adminMicModel.user_id curentVC:self selectItem:^(RoomUserInfoModel * _Nonnull model) { [ws popUserInfoViewToUserID:model.user_id roomID:ws.roomID curentVC:ws]; }]; } } } ///修改房主麦位值 - (void)changeHostCharmBtnTitle:(NSString *)title{ NSString *titleStr =[NSString stringWithFormat:@"魅力值%@",title]; [_hostCharmBtn setTitle:titleStr forState:UIControlStateNormal]; float with = [titleStr getSizeWithStrFloat:10].width+14; [self.hostCharmBtn mas_updateConstraints:^(MASConstraintMaker *make) { make.width.mas_equalTo(KAdaptedWidth(with)); }]; [self.hostCharmBtn layoutIfNeeded]; [self.hostCharmBtn jk_setRoundedCorners:UIRectCornerTopRight |UIRectCornerBottomRight radius:12]; } #pragma mark --弹出卡片view - (void)popUserInfoViewToUserID:(NSString *)user_id roomID:(NSString *)roomID curentVC:(RoomViewController *)curentVC { if([ToolsObject IsNullWithObject:user_id]){ return; } WeakSelf(ws); [RoomPopTool popUserInfoViewToUserID:user_id roomID:roomID roomAuth:self.roomInfoModel.room_auth curentVC:curentVC selectItem:^(RoomCardUserModel * _Nonnull cardModel, NSInteger index) { [ws popActionModel:cardModel index:index]; }]; } #pragma mark --弹出设置密码View - (void)showPassWordViewisEdit:(BOOL)isEdit{ WeakSelf(ws); RoomEditPassWordView *view = [RoomEditPassWordView sharView]; view.isEdit = isEdit; view.backPassWordBlock = ^(NSString * _Nonnull passWordStr) { [ws requsetPassWord:passWordStr isEdit:isEdit]; }; [view show]; } - (void)popActionModel:(RoomCardUserModel *)cardModel index:(NSInteger)index { //1:设置 2:举报 3:送礼物 4:主页 5:打招呼 if(index ==1){ RoomUserInfoModel *userModel= [[RoomUserInfoModel alloc] init]; userModel.user_id = cardModel.user_info.user_id; userModel.room_auth = [NSString stringWithFormat:@"%ld",cardModel.room_auth]; [self showMicroManageView:userModel]; }else if(index ==2){ DDMyInfoReportViewController *vc = [[DDMyInfoReportViewController alloc] init]; vc.juBaoType = 2; vc.jubao_id = cardModel.user_info.user_id; [self.navigationController pushViewController:vc animated:YES]; }else if(index ==3){ if(self.roomInfoModel.shopGiftsArray.count ==0){ [ToolsObject addPopVieToText:@"获取礼物中..."]; [self getGiftsAndEvent]; return; } cardModel.user_info.is_follow = cardModel.is_follow; [RoomPopTool popRoomGiftViewSendGiftType:RoomSendGiftType_User roomInfoModel:self.roomInfoModel selectMicroModel:[RoomMicroModel new] selestUser:cardModel.user_info curentVC:self]; }else if(index ==4){ DDMyInformationViewController * infoVC = [[DDMyInformationViewController alloc] init]; infoVC.user_id = cardModel.user_info.user_id; [self.navigationController pushViewController:infoVC animated:YES]; }else if (index == 5) { DDMUserModel * userModel = [[DDMUserModel alloc]init]; userModel.uid = cardModel.user_info.user_id; userModel.avatar = cardModel.user_info.avatar; userModel.nickName = cardModel.user_info.nickname; userModel.sex = [NSString stringWithFormat:@"%@",cardModel.user_info.sex]; userModel.age = [NSString stringWithFormat:@"%@",cardModel.user_info.age]; userModel.isGroup = NO; [DDMTool pulsChat:userModel]; } } #pragma mark --弹出在线列表 - (void)showOnlineList{ WeakSelf(ws); [RoomPopTool popOnlineUserListViewToRoomID:self.roomID roomInfoModel:self.roomInfoModel curentVC:self selectItem:^(RoomUserInfoModel * _Nonnull model, BOOL isSet) { if(isSet){ //设置某个用户 [ws showMicroManageView:model]; }else{ [ws popUserInfoViewToUserID:model.user_id roomID:self.roomID curentVC:ws]; } } goBlackList:^{ [RoomPopTool popRoomBlacklistViewToRoomInfoModel:self.roomInfoModel roomID:self.roomID curentVC:self goInfo:^(RoomUserInfoModel * _Nonnull userModel) { [ws popUserInfoViewToUserID:userModel.user_id roomID:ws.roomID curentVC:ws]; }]; }]; } //弹出管理列表 - (void)showMicroManageView:(RoomUserInfoModel *)model{ WeakSelf(ws); RoomMicroModel *micModel = [[RoomMicroModel alloc] init]; micModel.user_id = model.user_id; micModel.room_auth = model.room_auth; [RoomPopTool popMicroManageToRoomID:self.roomID microModel:micModel menuArray:[self getRoomIdentitySettingArrayToRoomAut:[model.room_auth integerValue]] curentVC:self selectItem:^(NSString * _Nonnull itemStr) { [ws microSetToStr:itemStr microModel:micModel]; }]; } //弹出禁言 禁麦时间 1禁言 2禁麦 - (void)showForbiddenToType:(NSInteger)type userID:(NSString *)userID microID:(NSString *)microID { RoomMicroModel *micModel = [[RoomMicroModel alloc] init]; micModel.user_id = userID; micModel.mic_id =microID; [RoomPopTool popMicroManageToRoomID:self.roomID microModel:micModel menuArray:self.timeArray curentVC:self selectItem:^(NSString * _Nonnull itemStr) { NSString *time = @"0"; if([itemStr isEqualToString:@"3小时"]){ time =@"10800"; }else if([itemStr isEqualToString:@"1小时"]) { time =@"3600"; }else if([itemStr isEqualToString:@"10分钟"]) { time =@"600"; }else if([itemStr isEqualToString:@"5分钟"]) { time =@"300"; }else if([itemStr isEqualToString:@"1分钟"]) { time =@"60"; } if(type ==1){ [[AppMessageManager shareManager] sendNoWordMessage:self.roomID userID:userID ttl:time banType:@"1"]; }else{ [[AppMessageManager shareManager] sendNoMicroMessage:self.roomID userID:userID ttl:time banType:@"1" micID:microID]; } }]; } #pragma mark --麦位操作 - (void)microSetToStr:(NSString *)itemStr microModel:(RoomMicroModel*)microModel{ if([itemStr isEqualToString:@"抱下麦"]){ [[AppMessageManager shareManager] sendHugDownMicroMessage:self.roomID microID:microModel.mic_id userID:microModel.user_id]; }else if ([itemStr isEqualToString:@"抱上麦"]){ if([ToolsObject IsNullWithObject:microModel.user_id]){ [self hugUpMicro:microModel.mic_id]; }else{ [[AppMessageManager shareManager] sendHugUpMicroMessage:self.roomID microID:microModel.mic_id userID:microModel.user_id]; } }else if ([itemStr isEqualToString:@"下麦"]){ [[AppMessageManager shareManager] sendDownMicroMessage:self.roomID]; self.roomInfoModel.isMicUp = NO; self.roomInfoModel.isInMicList = NO; [AgoraTool shareTool].managerIsOnMicro = NO; self.roomInfoModel.micMuteState = YES; [[AgoraTool shareTool] setRoomMute:self.roomInfoModel.micMuteState]; [[AgoraTool shareTool] setRoomRole:AgoraClientRoleAudience]; [self reloadTooView]; [self reloadMicroListBtn:self.roomInfoModel.micListCount]; }else if ([itemStr isEqualToString:@"上麦"]){ if([ToolsObject isBlankString:microModel.mic_id].length>0){ [[AppMessageManager shareManager] sendUpSelectMicroMessage:self.roomID microID:microModel.mic_id]; }else{ [self randomUpMicro]; } }else if ([itemStr isEqualToString:@"锁麦"]){ [[AppMessageManager shareManager] sendLockMicroMessage:self.roomID microID:microModel.mic_id]; }else if ([itemStr isEqualToString:@"解除锁麦"]){ [[AppMessageManager shareManager] sendUnLockMicroMessage:self.roomID microID:microModel.mic_id]; }else if ([itemStr isEqualToString:@"设为普通用户"]){ [[AppMessageManager shareManager] sendSetRoomManagerMessage:self.roomID userID:microModel.user_id roomAuth:@"6"]; }else if ([itemStr isEqualToString:@"设为房管"]){ [[AppMessageManager shareManager] sendSetRoomManagerMessage:self.roomID userID:microModel.user_id roomAuth:@"5"]; }else if ([itemStr isEqualToString:@"设为主持"]){ // [[AppMessageManager shareManager] sendSetRoomManagerMessage:self.roomID userID:microModel.user_id roomAuth:@"3"]; }else if ([itemStr isEqualToString:@"设为主播"]){ // [[AppMessageManager shareManager] sendSetRoomManagerMessage:self.roomID userID:microModel.user_id roomAuth:@"4"]; }else if ([itemStr isEqualToString:@"加入黑名单"]){ RoomBlackView *view = [[RoomBlackView alloc] initWithFrame:CGRectMake(0, 0, kWidth, kHeight)]; view.backBlackText = ^(NSString * _Nonnull text, NSString * _Nonnull time) { [[AppMessageManager shareManager] sendAddUserToBlickListMessage:self.roomID userID:microModel.user_id desc:text time:time]; }; [self.view addSubview:view]; [view show]; }else if ([itemStr isEqualToString:@"踢出房间"]){ [[AppMessageManager shareManager] sendKickOutRoomMessage:self.roomID userID:microModel.user_id]; }else if ([itemStr isEqualToString:@"禁言"]){ [self showForbiddenToType:1 userID:microModel.user_id microID:microModel.mic_id]; }else if ([itemStr isEqualToString:@"解除禁言"]){ [[AppMessageManager shareManager] sendNoWordMessage:self.roomID userID:microModel.user_id ttl:@"0" banType:@"0"]; }else if ([itemStr isEqualToString:@"禁麦"]){ [self showForbiddenToType:2 userID:microModel.user_id microID:microModel.mic_id]; }else if ([itemStr isEqualToString:@"解除禁麦"]){ [[AppMessageManager shareManager] sendNoMicroMessage:self.roomID userID:microModel.user_id ttl:@"0" banType:@"0" micID:microModel.mic_id]; }else if ([itemStr isEqualToString:@"警告"]){ RoomWarningView *view = [[RoomWarningView alloc] initWithFrame:CGRectMake(0, 0, kWidth, kHeight)]; view.backWarninigText = ^(NSString * _Nonnull text) { [[AppMessageManager shareManager] sendWarningMessage:self.roomID userID:microModel.user_id desc:text]; }; [self.view addSubview:view]; [view show]; }else if ([itemStr isEqualToString:@"查看信息名片"]){ [self popUserInfoViewToUserID:microModel.user_id roomID:self.roomID curentVC:self]; }else if ([itemStr isEqualToString:@"清空麦位值"]){ [self cleaMicroValueToUserID:microModel.user_id isCleanAll:NO]; }else if ([itemStr isEqualToString:@"封号"]){ WeakSelf(ws); UIAlertController *alertVC = [UIAlertController alertControllerWithTitle:@"是否封禁用户?" message:[NSString stringWithFormat:@"ID:%@",microModel.user_number] preferredStyle:UIAlertControllerStyleAlert]; UIAlertAction *cancelaction = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleDefault handler:nil]; UIAlertAction *sendaction = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) { [ws requestBanUserToUserID:microModel.user_id]; }]; [alertVC addAction:cancelaction]; [alertVC addAction:sendaction]; [self presentViewController:alertVC animated:YES completion:nil]; }else if ([itemStr isEqualToString:@"冻结账户"]){ WeakSelf(ws); UIAlertController *alertVC = [UIAlertController alertControllerWithTitle:@"是否冻结用户?" message:[NSString stringWithFormat:@"ID:%@",microModel.user_number] preferredStyle:UIAlertControllerStyleAlert]; UIAlertAction *cancelaction = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleDefault handler:nil]; UIAlertAction *sendaction = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) { [ws requestFrozenUserToUserID:microModel.user_id]; }]; [alertVC addAction:cancelaction]; [alertVC addAction:sendaction]; [self presentViewController:alertVC animated:YES completion:nil]; }else if ([itemStr isEqualToString:@"查看魅力值数据"]){ WeakSelf(ws); if([ToolsObject isBlankString:self.roomInfoModel.adminMicModel.user_id].length >0){ [RoomPopTool popRoomCharmViewToRoomInfoModel:self.roomInfoModel roomID:self.roomID userID:self.roomInfoModel.adminMicModel.user_id curentVC:self selectItem:^(RoomUserInfoModel * _Nonnull model) { [ws popUserInfoViewToUserID:model.user_id roomID:ws.roomID curentVC:ws]; }]; } } } #pragma mark --随机上麦 ///随机上麦 - (void)randomUpMicro{ NSInteger roomAuth = [self.roomInfoModel.room_auth integerValue]; if(roomAuth ==1){ [ToolsObject addPopVieToText:@"无权限"]; }else if(roomAuth ==2){ }else if(roomAuth ==3){ //主持 if ([ToolsObject IsNullWithObject:self.hostMicroView.microModel.user_id]) { [[AppMessageManager shareManager] sendUpSelectMicroMessage:self.roomID microID:self.hostMicroView.microModel.mic_id]; return; } [self freeOnMicro]; }else if(roomAuth ==4||roomAuth ==5||roomAuth ==6){ if(self.roomInfoModel.room_info.room_free_mic){ [self freeOnMicro]; }else{ [ToolsObject addPopVieToText:@"已申请上麦"]; [self freeOnMicro]; } }else{ [ToolsObject addPopVieToText:@"无权限"]; } } - (void)freeOnMicro{ [[AppMessageManager shareManager] sendUpSelectMicroMessage:self.roomID microID:[self getIdleMicRo]]; } #pragma mark --获得空闲的麦位 ///获得空闲的麦位 - (NSString *)getIdleMicRo{ //自由上麦 __block NSString * mic_id = @""; [self.roomInfoModel.allMicroArray enumerateObjectsUsingBlock:^(id _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) { if ([obj isKindOfClass:[RoomMicroModel class]]) { RoomMicroModel * model = obj; if ([ToolsObject IsNullWithObject:model.user_id] && [model.mic_id integerValue] != 22 && [model.mic_id integerValue] != 66 && [model.mic_id integerValue] != 88 && [model.is_lock integerValue] == 0) { mic_id = model.mic_id; *stop = YES; } } }]; if([ToolsObject IsNullWithObject:mic_id]){ mic_id = @"1"; } return mic_id; } #pragma mark --判断用户是否在麦上 - (void)getUserIsOnMicro:(NSString *)userID success:(void(^)(BOOL isUpMic,NSString * mic_id))success{ __block BOOL isUpMic = NO; __block NSString * mic_id = @""; [self.roomInfoModel.allMicroArray enumerateObjectsUsingBlock:^(id _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) { if ([obj isKindOfClass:[RoomMicroModel class]]) { RoomMicroModel * model = obj; if ([model.user_id isEqualToString:userID]) { /**自己在麦上*/ mic_id = model.mic_id; isUpMic = YES; *stop = YES; } } }]; success(isUpMic,mic_id); } #pragma mark --解析麦位数据 - (void)initMicroListToArray:(NSArray *)dataArray{ [AgoraTool shareTool].managerIsOnMicro = NO; self.roomInfoModel.isMicUp = NO; WeakSelf(ws); NSMutableArray *userMicroList = [[NSMutableArray alloc] init]; [dataArray enumerateObjectsUsingBlock:^(id _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) { if([obj isKindOfClass:[RoomMicroModel class]]){ RoomMicroModel *microModel = obj; if([microModel.mic_id integerValue]== 66){ ws.roomInfoModel.hostMicModel = microModel; }else if([microModel.mic_id integerValue]== 22){ ws.roomInfoModel.honorGuestMicModel = microModel; }else if([microModel.mic_id integerValue]== 88){ ws.roomInfoModel.adminMicModel = microModel; }else{ [userMicroList addObject:microModel]; } if(microModel.user_id.integerValue == [[ToolsObject getUserModel].user_id integerValue]){ ws.roomInfoModel.isMicUp = YES; ws.roomInfoModel.isInMicList = NO; if ([ws.roomInfoModel.room_auth integerValue] == 2 || [ws.roomInfoModel.room_auth integerValue] == 3|| [ws.roomInfoModel.room_auth integerValue] == 5) { [AgoraTool shareTool].managerIsOnMicro = YES; } } } }]; if(self.roomInfoModel.isMicUp){ [[AgoraTool shareTool] setRoomRole:AgoraClientRoleBroadcaster]; [[AgoraTool shareTool] setRoomMute:self.roomInfoModel.micMuteState]; }else{ self.roomInfoModel.micMuteState = YES; [[AgoraTool shareTool] setRoomMute:self.roomInfoModel.micMuteState]; [[AgoraTool shareTool] setRoomRole:AgoraClientRoleAudience]; } [[AppMessageManager shareManager].delegate sendRoomReloadMicroList:dataArray]; self.roomInfoModel.allMicroArray = dataArray; self.roomInfoModel.userMicroArray =userMicroList; [self reloadManageMicroUI]; [self reloadUserMicroUI]; [self reloadRoomUI]; [self reloadMicroListBtn:self.roomInfoModel.micListCount]; [self changeHostCharmBtnTitle: self.roomInfoModel.adminMicModel.mic_seat_valueString]; } #pragma mark --动画 - (void)createPlayer { _svgaTool = [[SVGATool alloc]init]; self.parser = [[SVGAParser alloc] init]; _inRoomSVGATool = [[InRoomSVGATool alloc]init]; self.inRoomParser = [[SVGAParser alloc] init]; } #pragma mark 开始飘屏动画 - (void)showAirPlaneViewToModel:(RoomGiftAirPlaneModel*)model{ [self.airplaneArray addObject:model]; if (!self.isAirPlane) { [self airPlaneViewShowAnimation]; } } - (void)airPlaneViewShowAnimation { self.isAirPlane = YES; if (self.airplaneArray.count > 0) { CGFloat delayTime = 8; RoomGiftAirPlaneModel * airPlaneModel = (RoomGiftAirPlaneModel *)self.airplaneArray.firstObject; WeakSelf(ws); dispatch_async(dispatch_get_main_queue(), ^{ [ws.airPlaneView updateUIWithModel:airPlaneModel]; }); [self.airplaneArray removeObjectAtIndex:0]; //只有展示才移除 dispatch_async(dispatch_get_main_queue(), ^{ [UIView animateWithDuration:0.5 delay:0.0 options:UIViewAnimationOptionAllowUserInteraction animations:^{ ws.airPlaneView.left = 0; } completion:^(BOOL finished) { ws.airPlaneView.frame = CGRectMake(0, KSTATUSRECT.size.height + 60, kWidth, 80.0/375.0*kWidth); [ws.airPlaneView layoutIfNeeded]; dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(delayTime * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ [UIView animateWithDuration:0.5 delay:0.0 options:UIViewAnimationOptionAllowUserInteraction animations:^{ ws.airPlaneView.right = 0; } completion:^(BOOL finished) { //执行完了再调用一次,如果有可以展示多个 ws.airPlaneView.left = kWidth; [ws.airPlaneView layoutIfNeeded]; [ws performSelector:@selector(airPlaneViewShowAnimation) withObject:ws afterDelay:CGFLOAT_MIN]; }]; }); }]; }); }else{ self.isAirPlane = NO; } } //升级飘屏动画 - (void)levelUpAirPlaneViewShowAnimation { self.isLevelUpAirPlane = YES; if (self.levelUpAirplaneArray.count > 0) { CGFloat delayTime = 3; NSDictionary * airplane_dict = (NSDictionary *)self.levelUpAirplaneArray.firstObject; WeakSelf(ws); dispatch_async(dispatch_get_main_queue(), ^{ [ws.levelPlaneView updateUIWithDict:airplane_dict]; }); [self.levelUpAirplaneArray removeObjectAtIndex:0]; //只有展示才移除 dispatch_async(dispatch_get_main_queue(), ^{ [UIView animateWithDuration:0.5 delay:0.0 options:UIViewAnimationOptionAllowUserInteraction animations:^{ ws.levelPlaneView.left = 0; } completion:^(BOOL finished) { ws.levelPlaneView.frame = CGRectMake(0, KSTATUSRECT.size.height + 90, kWidth, 80.0/375.0*kWidth); [ws.levelPlaneView layoutIfNeeded]; dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(delayTime * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ [UIView animateWithDuration:0.5 delay:0.0 options:UIViewAnimationOptionAllowUserInteraction animations:^{ ws.levelPlaneView.right = 0; } completion:^(BOOL finished) { //执行完了再调用一次,如果有可以展示多个 ws.levelPlaneView.left = kWidth; [ws.levelPlaneView layoutIfNeeded]; [ws performSelector:@selector(levelUpAirPlaneViewShowAnimation) withObject:ws afterDelay:CGFLOAT_MIN]; }]; }); }]; }); }else{ self.isLevelUpAirPlane = NO; } } #pragma mark --设置声网 - (void)initAgora{ [AgoraTool shareTool].roomID = self.roomID; [[AgoraTool shareTool] login]; [[AgoraTool shareTool] loginRoomWithID:self.roomInfoModel.agora.agora_id token:self.roomInfoModel.agora.accessToken userID:[ToolsObject getUserModel].user_id success:^{ [AgoraTool shareTool].curentRole = AgoraClientRoleAudience; [[AgoraTool shareTool] setRoomRole:AgoraClientRoleAudience]; [[AgoraTool shareTool] setRoomMute:self.roomInfoModel.micMuteState]; [[AgoraTool shareTool] setMuteAllAudio:NO]; }]; } #pragma mark --声网回调 - (void)playSoundWaveToUserID:(NSString *)userID{ if([ToolsObject IsNullWithObject:userID]){ userID = [ToolsObject getUserModel].user_id; } if([userID integerValue]==[self.roomInfoModel.adminMicModel.user_id integerValue] &&![ToolsObject IsNullWithObject:self.roomInfoModel.adminMicModel.user_id] &&[self.hostMicroView.microModel.user_id integerValue] !=[userID integerValue]){ dispatch_async(dispatch_get_main_queue(), ^{ [self.infoView starMicroAnimation]; }); }else if([userID integerValue]==[self.hostMicroView.microModel.user_id integerValue] &&![ToolsObject IsNullWithObject:self.hostMicroView.microModel.user_id]){ dispatch_async(dispatch_get_main_queue(), ^{ [self.hostMicroView.headeImageView starMicroAnimation]; }); }else if([userID integerValue]==[self.guestMicroView.microModel.user_id integerValue] &&![ToolsObject IsNullWithObject:self.guestMicroView.microModel.user_id]){ dispatch_async(dispatch_get_main_queue(), ^{ [self.guestMicroView.headeImageView starMicroAnimation]; }); }else{ for (NSInteger i = 0; i0){ [[AppMessageManager shareManager] sendCleanMicroCharmMessge:self.roomID userids:userIds]; } }]; [alertVC addAction:cancelaction]; [alertVC addAction:sendaction]; [self presentViewController:alertVC animated:YES completion:nil]; } - (void)showCloseRoom{ WeakSelf(ws); UIAlertController *alertVC = [UIAlertController alertControllerWithTitle:@"关闭房间?" message:@"" preferredStyle:UIAlertControllerStyleAlert]; UIAlertAction *cancelaction = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleDefault handler:nil]; UIAlertAction *sendaction = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) { [[AppMessageManager shareManager] sendCloseRoomMessage:ws.roomID]; }]; [alertVC addAction:cancelaction]; [alertVC addAction:sendaction]; [self presentViewController:alertVC animated:YES completion:nil]; } - (void)showBannedRoom{ WeakSelf(ws); UIAlertController *alertVC = [UIAlertController alertControllerWithTitle:@"确定封禁房间?" message:@"" preferredStyle:UIAlertControllerStyleAlert]; UIAlertAction *cancelaction = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleDefault handler:nil]; UIAlertAction *sendaction = [UIAlertAction actionWithTitle:@"封禁" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) { [ws requestBannedRoom]; }]; [alertVC addAction:cancelaction]; [alertVC addAction:sendaction]; [self presentViewController:alertVC animated:YES completion:nil]; } - (void)initBlock{ #pragma mark --声网block WeakSelf(ws); [[AgoraTool shareTool] setBackSpeakBlock:^(NSArray * _Nonnull allVolumes) { for (AgoraRtcAudioVolumeInfo *info in allVolumes) { if(info.uid ==0){ if(info.volume >0){ [ws playSoundWaveToUserID:[ToolsObject getUserModel].user_id]; } }else{ if(info.volume >0){ [ws playSoundWaveToUserID:[NSString stringWithFormat:@"%lu",info.uid]]; } } } }]; #pragma mark --更多房间设置 self.toolView.backMoreBtnBlock = ^(BOOL btnSelected) { [RoomPopTool popRoomManagementToRoomInfoModel:ws.roomInfoModel curentVC:ws selectItem:^(RoomSetModel * _Nonnull model) { switch (model.type) { case RoomSetType_liwutexiao_open: ws.roomInfoModel.isPlayGift = NO; [ws.publicMessageView.dataArr addObject:[RoomPublicScreenModel initMessage:@"礼物特效已关闭" user:[RoomUserInfoModel new] other_user:[RoomUserInfoModel new] giftModel:[DDGiftWallModel new] message_type:6 handle_type:0]]; [ws.publicMessageView refreshTableView]; break; case RoomSetType_liwutexiao_close: ws.roomInfoModel.isPlayGift = YES; [ws.publicMessageView.dataArr addObject:[RoomPublicScreenModel initMessage:@"礼物特效已开启" user:[RoomUserInfoModel new] other_user:[RoomUserInfoModel new] giftModel:[DDGiftWallModel new] message_type:6 handle_type:0]]; [ws.publicMessageView refreshTableView]; break; case RoomSetType_fangjianshengyin_open: ws.roomInfoModel.muteState = NO; [[AgoraTool shareTool] setMuteAllAudio:YES]; break; case RoomSetType_fangjianshengyin_close: ws.roomInfoModel.muteState = YES; [[AgoraTool shareTool] setMuteAllAudio:NO]; break; case RoomSetType_gongpingxiaoxi_open: ws.roomInfoModel.public_screen = YES; [[AppMessageManager shareManager] sendIsOpenPublicScreenMessage:ws.roomID isOpen:0]; break; case RoomSetType_gongpingxiaoxi_close: ws.roomInfoModel.public_screen = NO; [[AppMessageManager shareManager] sendIsOpenPublicScreenMessage:ws.roomID isOpen:1]; break; case RoomSetType_ziyoushangmai_open: [[AppMessageManager shareManager] sendCloseFreeMicroMessage:ws.roomID]; break; case RoomSetType_ziyoushangmai_close: [[AppMessageManager shareManager] sendOpenFreeMicroMessage:ws.roomID]; break; case RoomSetType_maiweizhiquanqing: [ws cleaMicroValueToUserID:@"" isCleanAll:YES]; break; case RoomSetType_zaixianliebiao: [ws showOnlineList]; break; case RoomSetType_shenfenguanli: { [RoomPopTool popRoomSetManagerListViewToRoomInfoModel:ws.roomInfoModel roomID:ws.roomID curentVC:ws selectItem:^(BOOL goInfo, BOOL isSet, RoomUserInfoModel * _Nonnull userModel) { if(goInfo){ [ws popUserInfoViewToUserID:userModel.user_id roomID:ws.roomID curentVC:ws]; } if(isSet){ [ws getUserIsOnMicro:userModel.user_id success:^(BOOL isUpMic, NSString *mic_id) { RoomMicroModel * micModel = [RoomMicroModel alloc]; micModel.user_id = userModel.user_id; micModel.mic_id = mic_id; micModel.room_auth = userModel.room_auth; micModel.user_number = userModel.user_number; micModel.nickname = userModel.nickname; micModel.nobility_id = userModel.nobility_id; [ws requestPopUserSetToMicroModel:micModel onMic:isUpMic]; }]; } }]; } break; case RoomSetType_fangjianliushui: { NSString * routing = [NSString stringWithFormat:@"%@/#/roomwaterlist",KWebURL]; DDWebViewController *webVc = [DDWebViewController webControlerWithUrlStr:routing isShowNavBar:NO isHalf:NO data:@{@"room_id":ws.roomID}]; webVc.view.backgroundColor = [UIColor whiteColor]; [ws.navigationController pushViewController:webVc animated:NO]; } break; case RoomSetType_fangjianjiesuo: [ws showPassWordViewisEdit:NO]; break; case RoomSetType_fangjianshangsuo: [ws showPassWordViewisEdit:YES]; break; case RoomSetType_quanmailiwu: break; case RoomSetType_shouqifangjian: [ws closeRoomClosrSmoll:NO]; break; case RoomSetType_tuichufangjian: [ws closeRoomClosrSmoll:YES]; break; case RoomSetType_guanbifangjian: [ws closeRoomClosrSmoll:YES]; [ws showCloseRoom]; break; case RoomSetType_fengjinfangjian: [ws showBannedRoom]; break; case RoomSetType_gengduoshezhi: [ws goCreatRoomViewController]; break; case RoomSetType_jubao: [ws goReportRoom]; break; default: break; } }]; }; #pragma mark --消息按钮点击 self.toolView.backMessageBtnBlock = ^(BOOL btnSelected) { ConversationListVC *vc = [[ConversationListVC alloc]init]; XPSemiModalConfiguration *config = [XPSemiModalConfiguration defaultConfiguration]; config.backgroundOpacity = 0.5; config.enableBackgroundAnimation = NO; config.enableShadow = NO; config.shouldDismissModal = YES; [[ToolsObject getCurrentViewController] presentSemiModalViewController:vc contentHeight:kHeight-400 configuration:config completion:nil dismissClickBlock:nil]; }; #pragma mark --麦克风是否静音按钮点击 self.toolView.backMicroBtnBlock = ^(BOOL btnSelected) { if(ws.roomInfoModel.isForbiddenMic){ [ToolsObject addPopVieToText:@"禁麦中"]; }else{ ws.roomInfoModel.micMuteState = btnSelected; [[AgoraTool shareTool] setRoomMute:ws.roomInfoModel.micMuteState]; } }; #pragma mark --发送礼物按钮点击 self.toolView.backGiftBtnBlock = ^(BOOL btnSelected) { if(self.roomInfoModel.shopGiftsArray.count ==0){ [ToolsObject addPopVieToText:@"获取礼物中..."]; [ws getGiftsAndEvent]; return; } [RoomPopTool popRoomGiftViewSendGiftType:RoomSendGiftType_Micro roomInfoModel:ws.roomInfoModel selectMicroModel:[RoomMicroModel new] selestUser:[RoomCardUserInfoModel new] curentVC:ws]; }; #pragma mark --发送文字按钮点击 self.toolView.backSendBtnBlock = ^(BOOL btnSelected) { [ws showSendMessageBar:@""]; /* ws.myInputView.hidden = NO; [ws.myInputView chatBecomeFirstResponder]; */ }; #pragma mark --上下麦按钮点击 self.toolView.backOnMicBtnBlock = ^(BOOL btnSelected) { // if(ws.roomInfoModel.isMicUp){ // //下麦 // [[AppMessageManager shareManager] sendDownMicroMessage:ws.roomID]; // // }else{ // //上麦 // if([self.roomInfoModel.room_auth integerValue] ==1){ // [ToolsObject addPopVieToText:@"无上麦权限"]; // }else if([self.roomInfoModel.room_auth integerValue] ==5 ||[self.roomInfoModel.room_auth integerValue] ==6){ // if(ws.roomInfoModel.room_info.room_free_mic){ // [ws freeOnMicro]; // // }else{ // [ToolsObject addPopVieToText:@"已申请上麦"]; // [ws freeOnMicro]; // } // // }else{ // [ToolsObject addPopVieToText:@"无上麦权限"]; // } // } }; #pragma mark --表情按钮点击 self.toolView.backEmojiBtnBlock = ^(BOOL btnSelected) { [ws showEmojiBar:@"" selectIndex:0]; }; #pragma mark --收藏房间 self.infoView.backCollectionBtnBlock = ^{ [ws collectionRoomWithIsCollection:YES]; }; #pragma mark --用户信息 self.infoView.backUserInfoBlock = ^{ [ws popUserInfoViewToUserID:ws.roomInfoModel.adminMicModel.user_id roomID:ws.roomID curentVC:ws]; }; self.infoView.backDetailBlock = ^{ [RoomPopTool popRoominfoViewToRoomInfoModel:ws.roomInfoModel roomID:ws.roomID curentVC:ws collectBlock:^(BOOL isCollect) { [ws collectionRoomWithIsCollection:isCollect]; } reportBlock:^{ [ws goReportRoom]; }]; }; #pragma mark --关闭房间 self.infoView.backCloseBtnBtnBlock = ^{ [ws closeRoomClosrSmoll:NO]; }; #pragma mark --公告 self.infoView.backTipBtnBlock = ^{ [ws tipBtnClick]; }; #pragma mark --头像 收益点击 #pragma mark --用户头像 收益点击 self.userMicroView.backHeaderTapBlock = ^(RoomMicroModel * _Nonnull microModel) { NSInteger roomAuth =ws.roomInfoModel.room_auth.integerValue; if([ToolsObject isBlankString:microModel.user_id].length ==0){ if(roomAuth ==0){ [ToolsObject addPopVieToText:@"无权限"]; }else if (roomAuth ==1){ [ToolsObject addPopVieToText:@"无权限"]; }else if (roomAuth ==2){ if([microModel.is_lock integerValue] ==1){ [RoomPopTool popMicroManageToRoomID:ws.roomID microModel:microModel menuArray:@[@"抱上麦",@"解除锁麦"] curentVC:ws selectItem:^(NSString * _Nonnull itemStr) { [ws microSetToStr:itemStr microModel:microModel]; }]; }else{ [RoomPopTool popMicroManageToRoomID:ws.roomID microModel: microModel menuArray:@[@"抱上麦",@"锁麦"] curentVC:ws selectItem:^(NSString * _Nonnull itemStr) { [ws microSetToStr:itemStr microModel:microModel]; }]; } }else if(roomAuth ==5 ||roomAuth ==3){ if([AgoraTool shareTool].managerIsOnMicro){ if([microModel.is_lock integerValue] ==1){ [RoomPopTool popMicroManageToRoomID:ws.roomID microModel: microModel menuArray:@[@"抱上麦",@"解除锁麦"] curentVC:ws selectItem:^(NSString * _Nonnull itemStr) { [ws microSetToStr:itemStr microModel:microModel]; }]; }else{ [RoomPopTool popMicroManageToRoomID:ws.roomID microModel: microModel menuArray:@[@"抱上麦",@"锁麦"] curentVC:ws selectItem:^(NSString * _Nonnull itemStr) { [ws microSetToStr:itemStr microModel:microModel]; }]; } }else{ if ([microModel.is_lock integerValue] ==1) { [ToolsObject addPopVieToText:@"此麦位已上锁"]; }else{ [RoomPopTool popMicroManageToRoomID:ws.roomID microModel: microModel menuArray:@[@"上麦"] curentVC:ws selectItem:^(NSString * _Nonnull itemStr) { [ws microSetToStr:itemStr microModel:microModel]; }]; } } }else if (roomAuth ==6){ if([microModel.is_lock integerValue] ==1){ [ToolsObject addPopVieToText:@"麦位已上锁"]; }else{ [RoomPopTool popMicroManageToRoomID:ws.roomID microModel: microModel menuArray:@[@"上麦"] curentVC:ws selectItem:^(NSString * _Nonnull itemStr) { [ws microSetToStr:itemStr microModel:microModel]; }]; } } }else{ if(microModel.user_id.integerValue ==[ToolsObject getUserModel].user_id.integerValue){ if(roomAuth ==2 ||roomAuth ==3||roomAuth ==4||roomAuth ==5){ [RoomPopTool popMicroManageToRoomID:ws.roomID microModel:microModel menuArray:@[@"查看信息名片",@"清空麦位值",@"下麦"] curentVC:ws selectItem:^(NSString * _Nonnull itemStr) { [ws microSetToStr:itemStr microModel:microModel]; }]; }else{ [RoomPopTool popMicroManageToRoomID:ws.roomID microModel:microModel menuArray:@[@"查看信息名片",@"下麦"] curentVC:ws selectItem:^(NSString * _Nonnull itemStr) { [ws microSetToStr:itemStr microModel:microModel]; }]; } return; } if(roomAuth ==1 ||roomAuth ==2||roomAuth ==3 ||roomAuth ==5){ [ws requestPopUserSetToMicroModel:microModel onMic:YES]; }else{ [ws popUserInfoViewToUserID:microModel.user_id roomID:ws.roomID curentVC:ws]; } } }; self.userMicroView.backIncomeTapBlock = ^(RoomMicroModel * _Nonnull microModel) { if([ToolsObject isBlankString:microModel.user_id].length >0){ [RoomPopTool popRoomCharmViewToRoomInfoModel:ws.roomInfoModel roomID:ws.roomID userID:microModel.user_id curentVC:ws selectItem:^(RoomUserInfoModel * _Nonnull model) { [ws popUserInfoViewToUserID:model.user_id roomID:ws.roomID curentVC:ws]; }]; } }; #pragma mark -- self.hostMicroView.backHeaderTapBlock = ^(RoomMicroModel * _Nonnull microModel) { NSInteger roomType = ws.roomInfoModel.room_info.open_type; NSInteger roomAuth =ws.roomInfoModel.room_auth.integerValue; if(roomType ==0){ if([ToolsObject isBlankString:microModel.user_id].length>0){ if(microModel.user_id.integerValue ==[ToolsObject getUserModel].user_id.integerValue){ //点击自己头像时根据身份 弹出不同选项 if(roomAuth ==2 ||roomAuth ==3||roomAuth ==4||roomAuth ==5){ [RoomPopTool popMicroManageToRoomID:ws.roomID microModel:microModel menuArray:@[@"查看信息名片",@"清空麦位值",@"下麦"] curentVC:ws selectItem:^(NSString * _Nonnull itemStr) { [ws microSetToStr:itemStr microModel:microModel]; }]; }else{ [RoomPopTool popMicroManageToRoomID:ws.roomID microModel:microModel menuArray:@[@"查看信息名片",@"下麦"] curentVC:ws selectItem:^(NSString * _Nonnull itemStr) { [ws microSetToStr:itemStr microModel:microModel]; }]; } return; } if(roomAuth ==1 ||roomAuth ==2){ [ws requestPopUserSetToMicroModel:microModel onMic:YES]; return; } [ws popUserInfoViewToUserID:microModel.user_id roomID:ws.roomID curentVC:ws]; return; } if(roomAuth ==1){ [ToolsObject addPopVieToText:@"超管不能上麦"]; return;; } if(roomAuth ==2){ if([microModel.is_lock integerValue] ==1){ [RoomPopTool popMicroManageToRoomID:ws.roomID microModel: microModel menuArray:@[@"解除锁麦"] curentVC:ws selectItem:^(NSString * _Nonnull itemStr) { [ws microSetToStr:itemStr microModel:microModel]; }]; }else{ [RoomPopTool popMicroManageToRoomID:ws.roomID microModel: microModel menuArray:@[@"锁麦"] curentVC:ws selectItem:^(NSString * _Nonnull itemStr) { [ws microSetToStr:itemStr microModel:microModel]; }]; } return; } if(roomAuth ==5 ||roomAuth ==3){ ///上主持麦 [ws roomSendUpHostMicroToMicroID:microModel.mic_id]; return; } [ToolsObject addPopVieToText:@"无权限"]; }else{ if([ws.roomInfoModel.adminMicModel.user_id isEqualToString:ToolsObject.getUserModel.user_id]){ NSMutableArray * totalArr = [NSMutableArray array]; [totalArr addObject:@"清空麦位值"]; dispatch_async(dispatch_get_main_queue(), ^{ [RoomPopTool popMicroManageToRoomID:ws.roomID microModel: microModel menuArray:totalArr curentVC:ws selectItem:^(NSString * _Nonnull itemStr) { [ws microSetToStr:itemStr microModel:microModel]; }]; }); }else{ [ws popUserInfoViewToUserID:microModel.user_id roomID:ws.roomID curentVC:ws]; } } }; self.hostMicroView.backIncomeTapBlock = ^(RoomMicroModel * _Nonnull microModel) { if([ToolsObject isBlankString:microModel.user_id].length >0){ [RoomPopTool popRoomCharmViewToRoomInfoModel:ws.roomInfoModel roomID:ws.roomID userID:microModel.user_id curentVC:ws selectItem:^(RoomUserInfoModel * _Nonnull model) { [ws popUserInfoViewToUserID:model.user_id roomID:ws.roomID curentVC:ws]; }]; } }; #pragma mark -- self.guestMicroView.backHeaderTapBlock = ^(RoomMicroModel * _Nonnull microModel) { // [RoomPopTool popUserInfoViewToUserID:microModel.user_id roomID:ws.roomID curentVC:ws]; NSInteger roomAuth =ws.roomInfoModel.room_auth.integerValue; if([ToolsObject isBlankString:microModel.user_id].length >0){ if(microModel.user_id.integerValue ==[ToolsObject getUserModel].user_id.integerValue){ if(roomAuth ==2 ||roomAuth ==3||roomAuth ==4||roomAuth ==5){ [RoomPopTool popMicroManageToRoomID:ws.roomID microModel:microModel menuArray:@[@"查看信息名片",@"清空麦位值",@"下麦"] curentVC:ws selectItem:^(NSString * _Nonnull itemStr) { [ws microSetToStr:itemStr microModel:microModel]; }]; }else{ [RoomPopTool popMicroManageToRoomID:ws.roomID microModel:microModel menuArray:@[@"查看信息名片",@"下麦"] curentVC:ws selectItem:^(NSString * _Nonnull itemStr) { [ws microSetToStr:itemStr microModel:microModel]; }]; } return; } if(roomAuth ==1 ||roomAuth ==2 ||roomAuth ==3||roomAuth ==5){ [ws requestPopUserSetToMicroModel:microModel onMic:YES]; return;; } [ws popUserInfoViewToUserID:microModel.user_id roomID:ws.roomID curentVC:ws]; return; } if(roomAuth ==1){ [ToolsObject addPopVieToText:@"超管不可上麦"]; return;; } if(roomAuth ==2){ if([microModel.is_lock integerValue] ==1){ [RoomPopTool popMicroManageToRoomID:ws.roomID microModel:microModel menuArray:@[@"抱上麦",@"解除锁麦"] curentVC:ws selectItem:^(NSString * _Nonnull itemStr) { [ws microSetToStr:itemStr microModel:microModel]; }]; }else{ [RoomPopTool popMicroManageToRoomID:ws.roomID microModel: microModel menuArray:@[@"抱上麦",@"锁麦"] curentVC:ws selectItem:^(NSString * _Nonnull itemStr) { [ws microSetToStr:itemStr microModel:microModel]; }]; } return;; } if(roomAuth ==5 ||roomAuth ==3){ if([AgoraTool shareTool].managerIsOnMicro){ if([microModel.is_lock boolValue] ==1){ [RoomPopTool popMicroManageToRoomID:ws.roomID microModel:microModel menuArray:@[@"抱上麦",@"解除锁麦"] curentVC:ws selectItem:^(NSString * _Nonnull itemStr) { [ws microSetToStr:itemStr microModel:microModel]; }]; }else{ [RoomPopTool popMicroManageToRoomID:ws.roomID microModel: microModel menuArray:@[@"抱上麦",@"锁麦"] curentVC:ws selectItem:^(NSString * _Nonnull itemStr) { [ws microSetToStr:itemStr microModel:microModel]; }]; } return;; } if([microModel.is_lock integerValue] ==1){ [ToolsObject addPopVieToText:@"麦位已上锁"]; }else{ [RoomPopTool popMicroManageToRoomID:ws.roomID microModel:microModel menuArray:@[@"上麦"] curentVC:ws selectItem:^(NSString * _Nonnull itemStr) { [ws microSetToStr:itemStr microModel:microModel]; }]; } return; } if(roomAuth ==4 ||roomAuth ==6){ if([microModel.is_lock integerValue] ==1){ [ToolsObject addPopVieToText:@"麦位已上锁"]; }else{ [RoomPopTool popMicroManageToRoomID:ws.roomID microModel: microModel menuArray:@[@"上麦"] curentVC:ws selectItem:^(NSString * _Nonnull itemStr) { [ws microSetToStr:itemStr microModel:microModel ]; }]; } return; } [ToolsObject addPopVieToText:@"无权限"]; }; self.guestMicroView.backIncomeTapBlock = ^(RoomMicroModel * _Nonnull microModel) { [RoomPopTool popRoomCharmViewToRoomInfoModel:ws.roomInfoModel roomID:ws.roomID userID:microModel.user_id curentVC:ws selectItem:^(RoomUserInfoModel * _Nonnull model) { [ws popUserInfoViewToUserID:model.user_id roomID:ws.roomID curentVC:ws]; }]; }; } /**显示键盘*/ - (void)showSendMessageBar:(NSString *)currentMessage { if (self.roomInfoModel.public_screen) { [ToolsObject addPopVieToText:@"管理员已禁用公屏"]; return; } if (self.roomInfoModel.isForbiddenWords) { //[ToolsObject addPopVieToText:@"禁言倒计时:%@",[ToolsObject timeReturnSecMinuteHour:self.forbidden_ttl]]; [ToolsObject addPopVieToText:@"发送失败,您已被禁言"]; return; } DDMsgInputView *inputView = [DDMsgInputView sharedInstance]; inputView.isForbiddenWords = self.roomInfoModel.isForbiddenWords; inputView.forbidden_ttl = self.roomInfoModel.forbidden_ttl; inputView.public_screen = self.roomInfoModel.public_screen; inputView.currentMessage = currentMessage; @weakify(self); /**发送消息*/ [inputView setSendMsgBlock:^(NSString * _Nonnull message) { DDMessageCustomRemoteExtModel *model = [[DDMessageCustomRemoteExtModel alloc] initMessageRemoteExtModelWithUserModel:self.userInfo]; NIMMessage *nimMessage = [[NIMMessage alloc] init]; nimMessage.text = message; NSMutableDictionary *remoteExt = [NSMutableDictionary dictionaryWithObject:model.dd_modelDictionary forKey:[AccountInfoStorage instance].getUid]; // NIMAntiSpamOption *option = [[NIMAntiSpamOption alloc]init]; // option.yidunEnabled = YES; // option.businessId = KeyWithType(keyType_YiDunBussinessId); // message.antiSpamOption = option; NSString * sessionId = [NSString stringWithFormat:@"%ld", self.roomInfo.roomId]; //构造会话 NIMSession *session = [NIMSession session:sessionId type:NIMSessionTypeChatroom]; [[NIMSDK sharedSDK].chatManager sendMessage:nimMessage toSession:session completion:^(NSError * _Nullable error) { // NSLog(@"发送消息成功:%@",error); [self.publicMessageView.dataArr addObject:[RoomPublicScreenModel initMessage:message user:self.userInfo other_user:[RoomInfoModel new] giftModel:[DDGiftWallModel new] message_type:3 handle_type:0]]; // self.editTextFiled.text = @""; // [self.editTextFiled resignFirstResponder]; // [self.atUids removeAllObjects]; // [self.atNames removeAllObjects]; // self.inputMessage = nil; }]; }]; [inputView setSendMsgBlock:^(NSString * _Nonnull message) { @strongify(self); NSLog(@"[ToolsObject getUserModel].nobility_id -----%lu",[ToolsObject getUserModel].nobility_id); RoomUserInfoModel *userModel = [[RoomUserInfoModel alloc] init]; userModel.nickname = [ToolsObject getUserModel].nickname; userModel.room_auth = self.roomInfoModel.room_auth; userModel.user_id = [ToolsObject getUserModel].user_id;; userModel.level_icon = [ToolsObject getUserModel].level_icon; [[AppMessageManager shareManager] sendPublicTextMessage:self.roomID text:message userInfo:userModel messageType:3]; }]; [inputView setBulletBlock:^(NSString * _Nonnull message) { @strongify(self); NSMutableDictionary *parameter = @{@"room_id":self.roomID,@"content":message}.mutableCopy; [NetworkRequest requestPOST:@"/nobility/use/roomchat" parameters:parameter block:^(BaseResponse * _Nonnull response) { if (response.isSuccess) { [ToolsObject addPopVieToText:@"发送成功"]; } }]; }]; [inputView setCardBlock:^(NSString * _Nonnull message) { @strongify(self); NSMutableDictionary *parameter = @{@"room_id":self.roomID,@"content":message}.mutableCopy; [NetworkRequest requestPOST:@"/nobility/use/allshoutcard" parameters:parameter block:^(BaseResponse * _Nonnull response) { if (response.isSuccess) { [ToolsObject addPopVieToText:@"发送成功"]; } }]; }]; /**弹出表情包*/ [inputView setAlertEmojiClickBlock:^(NSString * _Nonnull currentMessage) { @strongify(self); self.roomInfoModel.isReloadUpMicAlert = YES; //弹出表情包 [self showEmojiBar:currentMessage selectIndex:0]; }]; inputView.dissmissBlock = ^(BOOL isReloadUpMicAlert) { @strongify(self); self.roomInfoModel.isReloadUpMicAlert = isReloadUpMicAlert; }; [inputView show]; } /**显示表情包*/ - (void)showEmojiBar:(NSString *)currentMessage selectIndex:(NSInteger)selectIndex { if (self.roomInfoModel.public_screen) { [ToolsObject addPopVieToText:@"管理员已禁用公屏"]; return; } if (self.roomInfoModel.isForbiddenWords) { //[ToolsObject addPopVieToText:@"禁言倒计时:%@",[ToolsObject timeReturnSecMinuteHour:self.forbidden_ttl]]; [ToolsObject addPopVieToText:@"发送失败,您已被禁言"]; return; } return; @weakify(self); NSMutableDictionary *params = [[NSMutableDictionary alloc] init]; [params setObject:@"1" forKey:@"type"]; [NetworkRequest requestPOST:@"/expression/category" parameters:params block:^(BaseResponse * _Nonnull response) { @strongify(self); if (response.isSuccess) { if ([ToolsObject IsNullWithObject:response.data]) { NSMutableArray *emojiArr = [[NSMutableArray alloc] init]; //默认emoji系统表情在第一个 DDEmojiModel * defaultModel = [[DDEmojiModel alloc] init]; defaultModel.cid = @"0"; defaultModel.icon = @"message_icon_7"; [emojiArr insertObject:defaultModel atIndex:0]; [self showEmojiBar:currentMessage selectIndex:0 emojiArr:emojiArr]; } else { NSMutableArray *emojiArr = [DDEmojiModel mj_objectArrayWithKeyValuesArray:response.data].mutableCopy; //默认emoji系统表情在第一个 DDEmojiModel * defaultModel = [[DDEmojiModel alloc] init]; defaultModel.cid = @"0"; defaultModel.icon = @"message_icon_7"; [emojiArr insertObject:defaultModel atIndex:0]; [self showEmojiBar:currentMessage selectIndex:0 emojiArr:emojiArr]; } } }]; } - (void)showEmojiBar:(NSString *)currentMessage selectIndex:(NSInteger)selectIndex emojiArr:(NSMutableArray *)emojiArr { DDEmojiInputView * emojiBar = [DDEmojiInputView sharedInstance]; emojiBar.isForbiddenWords = self.roomInfoModel.isForbiddenWords; emojiBar.forbidden_ttl = self.roomInfoModel.forbidden_ttl; emojiBar.public_screen = self.roomInfoModel.public_screen; emojiBar.currentMessage = @""; [emojiBar updateViewWithArr:emojiArr selectIndex:0]; @weakify(self); /**发送表情包*/ [emojiBar setSendEmojiClickBlock:^(DDEmojiMessageModel * _Nonnull emojiModel) { @strongify(self); if (self.roomInfoModel.public_screen) { [ToolsObject addPopVieToText:@"管理员已禁用公屏"]; return; } RoomUserInfoModel *userModel = [[RoomUserInfoModel alloc] init]; userModel.nickname = [ToolsObject getUserModel].nickname; userModel.user_id = [ToolsObject getUserModel].user_id; userModel.nobility_id = [ToolsObject getUserModel].nobility_id; userModel.nobility_avtar = [ToolsObject getUserModel].nobility_avtar; userModel.level_icon = [ToolsObject getUserModel].level_icon; userModel.medal_box = [ToolsObject getUserModel].medal_box; userModel.bubble_box = [ToolsObject getUserModel].bubble_box; userModel.room_auth = self.roomInfoModel.room_auth; [[AppMessageManager shareManager] sendPublicEmojiMessage:self.roomID userInfo:userModel cid:emojiModel.cid eid:emojiModel.eid]; }]; [emojiBar setSendMsgBlock:^(NSString * _Nonnull message) { @strongify(self); RoomUserInfoModel *userModel = [[RoomUserInfoModel alloc] init]; userModel.nickname = [ToolsObject getUserModel].nickname; userModel.room_auth = self.roomInfoModel.room_auth; userModel.user_id = [ToolsObject getUserModel].user_id;; userModel.level_icon = [ToolsObject getUserModel].level_icon; [[AppMessageManager shareManager] sendPublicTextMessage:self.roomID text:message userInfo:userModel messageType:3]; }]; /**弹出键盘*/ [emojiBar setAlertKeybordClickBlock:^(NSString * _Nonnull currentMessage) { @strongify(self); self.roomInfoModel.isReloadUpMicAlert = YES; [self showSendMessageBar:currentMessage]; }]; emojiBar.dissmissBlock = ^(BOOL isReloadUpMicAlert) { @strongify(self); self.roomInfoModel.isReloadUpMicAlert = isReloadUpMicAlert; }; [emojiBar show]; } #pragma mark --------------------房间消息接收 - (void)receiveRoomMsgWithResponseDict:(NSDictionary*)dataDic{ RoomSocketMsgModel *msgModel = [RoomSocketMsgModel yy_modelWithDictionary:dataDic]; NSLog(@"msgModel.eventValue ==%ld",msgModel.eventValue); switch (msgModel.eventValue) { #pragma mark--------------------同步消息 case 1000: { [ToolsObject DismissSVProgressHUD]; [ToolsObject addPopVieToText:msgModel.response.msg]; } break; case 1001: [ToolsObject DismissSVProgressHUD]; //进入失败关闭房间 if(msgModel.response.status ==0){ [ToolsObject addPopVieToText:msgModel.response.msg]; [self closeRoomClosrSmoll:YES]; }else{ self.roomInfoModel = [RoomInfoModel yy_modelWithDictionary:msgModel.data]; [self getGiftsAndEvent]; self.roomInfoModel.micMuteState = YES; [self reloadRoomInfo]; [self reloadMicroListBtn:self.roomInfoModel.row_mic_number]; NSDictionary *dataDic =@{@"room_id":self.roomID,@"online":@"1"}; //发送房间开关播代理消息 [[AppMessageManager shareManager].delegate sendRoomIsOpenMessage:dataDic]; [self getMicroData]; [self initAgora]; } //公告 if (self.roomInfoModel.public_screen) { return; } [self.publicMessageView.dataArr insertObject:[RoomPublicScreenModel initMessage:@"严禁未成年人直播或打赏,平台对直播内容24小时巡查,如有任何违法违规、色情低俗、诱导欺诈等行为,请及时举报。请勿轻信各类代充值、刷礼物、第三方联系等广告信息,以免上当受骗。" user:[RoomUserInfoModel new] other_user:[RoomUserInfoModel new] giftModel:[DDGiftWallModel new] message_type:6 handle_type:0] atIndex:0];; [self.publicMessageView refreshTableView]; break; case 1002: [ToolsObject DismissSVProgressHUD]; [ToolsObject addPopVieToText:msgModel.response.msg]; break; case 1003: [ToolsObject DismissSVProgressHUD]; [ToolsObject addPopVieToText:msgModel.response.msg]; break; case 1004: [ToolsObject DismissSVProgressHUD]; [ToolsObject addPopVieToText:msgModel.response.msg]; break; case 1005: [ToolsObject DismissSVProgressHUD]; [ToolsObject addPopVieToText:msgModel.response.msg]; break; case 1006: [ToolsObject DismissSVProgressHUD]; [ToolsObject addPopVieToText:msgModel.response.msg]; break; case 1008: [ToolsObject DismissSVProgressHUD]; [ToolsObject addPopVieToText:msgModel.response.msg]; break; case 1009: [ToolsObject DismissSVProgressHUD]; [ToolsObject addPopVieToText:msgModel.response.msg]; break; case 1011: [ToolsObject DismissSVProgressHUD]; if(msgModel.response.status ==0){ [ToolsObject addPopVieToText:msgModel.response.msg]; } break; case 1012: [ToolsObject DismissSVProgressHUD]; if(msgModel.response.status ==0){ [ToolsObject addPopVieToText:msgModel.response.msg]; }else{ NSDictionary *dataDic =@{@"room_id":self.roomID,@"online":@"0"}; //发送房间开关播代理消息 [[AppMessageManager shareManager].delegate sendRoomIsOpenMessage:dataDic]; [self closeRoomClosrSmoll:YES]; } break; case 1013: [ToolsObject DismissSVProgressHUD]; [ToolsObject addPopVieToText:msgModel.response.msg]; break; case 1014: [ToolsObject DismissSVProgressHUD]; [ToolsObject addPopVieToText:msgModel.response.msg]; break; case 1015: [ToolsObject DismissSVProgressHUD]; if(msgModel.response.status ==0){ [ToolsObject addPopVieToText:msgModel.response.msg]; } if(self.roomInfoModel.public_screen){ }else{ NSDictionary *userDic = msgModel.data[@"user"]; if(![ToolsObject IsNullWithObject:userDic]){ RoomUserInfoModel *model = [RoomUserInfoModel yy_modelWithDictionary:userDic]; [self.publicMessageView.dataArr addObject:[RoomPublicScreenModel initMessage:@"" user:model other_user:[RoomUserInfoModel new] giftModel:[DDGiftWallModel new] message_type:7 handle_type:0]]; [self.publicMessageView refreshTableView]; } } break; case 1016: [ToolsObject DismissSVProgressHUD]; [ToolsObject addPopVieToText:msgModel.response.msg]; break; case 1017: [ToolsObject DismissSVProgressHUD]; [ToolsObject addPopVieToText:msgModel.response.msg]; break; case 1018: [ToolsObject DismissSVProgressHUD]; [ToolsObject addPopVieToText:msgModel.response.msg]; self.roomInfoModel.isMicUp = NO; self.roomInfoModel.isInMicList = NO; [self reloadMicroListBtn:self.roomInfoModel.micListCount]; break; case 1019: [ToolsObject DismissSVProgressHUD]; [ToolsObject addPopVieToText:msgModel.response.msg]; break; case 1020: [ToolsObject DismissSVProgressHUD]; if([ToolsObject IsNullWithObject:msgModel]){ }else{ if(msgModel.response.code ==0){ if(msgModel.response.code ==4002){ UIAlertController *alertVC = [UIAlertController alertControllerWithTitle:@"余额不足" message:@"去充值" preferredStyle:UIAlertControllerStyleAlert]; UIAlertAction *cancelaction = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleDefault handler:nil]; UIAlertAction *sendaction = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) { }]; [alertVC addAction:cancelaction]; [alertVC addAction:sendaction]; [self presentViewController:alertVC animated:YES completion:nil]; }else if (msgModel.response.code ==4003){ [self showTipAleart]; }else{ [ToolsObject addPopVieToText:msgModel.response.msg]; } }else{ [ToolsObject addPopVieToText:@"赠送成功"]; NSInteger myMoney =[msgModel.data[@"diamond"] integerValue]; [[AppMessageManager shareManager].delegate sendUpDataMyDiamond:[NSString stringWithFormat:@"%ld",myMoney]]; } } break; case 1021: { [ToolsObject DismissSVProgressHUD]; [ToolsObject addPopVieToText:msgModel.response.msg]; if(msgModel.response.status ==0){ if(msgModel.response.code ==4003){ [self showTipAleart]; } }else{ if([ToolsObject IsNullWithObject:msgModel.data]){ }else{ NSArray * dataArray = [NSArray yy_modelArrayWithClass:RoomGiftModel.class json:msgModel.data[@"surplus_list"]].mutableCopy; [[AppMessageManager shareManager].delegate sendUpDataGiftsData:dataArray]; } } } break; case 1022: [ToolsObject DismissSVProgressHUD]; [ToolsObject addPopVieToText:msgModel.response.msg]; break; case 1023: [ToolsObject DismissSVProgressHUD]; [ToolsObject addPopVieToText:msgModel.response.msg]; break; case 1024: [ToolsObject DismissSVProgressHUD]; [ToolsObject addPopVieToText:msgModel.response.msg]; break; case 1025: [ToolsObject DismissSVProgressHUD]; [ToolsObject addPopVieToText:msgModel.response.msg]; break; case 1027: { [ToolsObject DismissSVProgressHUD]; [ToolsObject addPopVieToText:msgModel.response.msg]; [ToolsObject DismissSVProgressHUD]; if([ToolsObject IsNullWithObject:msgModel]){ }else{ if(msgModel.response.status ==0){ if(msgModel.response.code ==4002){ UIAlertController *alertVC = [UIAlertController alertControllerWithTitle:@"余额不足" message:@"去充值" preferredStyle:UIAlertControllerStyleAlert]; UIAlertAction *cancelaction = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleDefault handler:nil]; UIAlertAction *sendaction = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) { }]; [alertVC addAction:cancelaction]; [alertVC addAction:sendaction]; [self presentViewController:alertVC animated:YES completion:nil]; }else if (msgModel.response.code ==4003){ [self showTipAleart]; }else{ [ToolsObject addPopVieToText:msgModel.response.msg]; } }else{ [ToolsObject addPopVieToText:@"赠送成功"]; NSInteger myMoney =[msgModel.data[@"diamond"] integerValue]; [[AppMessageManager shareManager].delegate sendUpDataMyDiamond:[NSString stringWithFormat:@"%ld",myMoney]]; NSString *codeImg = msgModel.data[@"codeImg"]; NSString *desc = msgModel.data[@"desc"]; if([ToolsObject isBlankString:codeImg].length ==0 && [ToolsObject isBlankString:desc].length ==0){ }else{ UIAlertController *alertVC = [UIAlertController alertControllerWithTitle:@"desc" message:@"" preferredStyle:UIAlertControllerStyleAlert]; UIAlertAction *cancelaction = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleDefault handler:nil]; UIAlertAction *sendaction = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) { }]; [alertVC addAction:cancelaction]; [alertVC addAction:sendaction]; [self presentViewController:alertVC animated:YES completion:nil]; self.roomInfoModel.isSendAllMic = NO; } } } } break; case 1030: { [ToolsObject DismissSVProgressHUD]; [ToolsObject addPopVieToText:msgModel.response.msg]; if([ToolsObject IsNullWithObject:msgModel]){ }else{ if(msgModel.response.status ==0){ if(msgModel.response.code ==4002){ UIAlertController *alertVC = [UIAlertController alertControllerWithTitle:@"余额不足" message:@"去充值" preferredStyle:UIAlertControllerStyleAlert]; UIAlertAction *cancelaction = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleDefault handler:nil]; UIAlertAction *sendaction = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) { }]; [alertVC addAction:cancelaction]; [alertVC addAction:sendaction]; [self presentViewController:alertVC animated:YES completion:nil]; }else if (msgModel.response.code ==4003){ [self showTipAleart]; }else{ [ToolsObject addPopVieToText:msgModel.response.msg]; } }else{ [ToolsObject addPopVieToText:@"赠送成功"]; NSInteger myMoney =[msgModel.data[@"diamond"] integerValue]; [[AppMessageManager shareManager].delegate sendUpDataMyDiamond:[NSString stringWithFormat:@"%ld",myMoney]]; } } } break; case 1032: { [ToolsObject DismissSVProgressHUD]; [ToolsObject addPopVieToText:msgModel.response.msg]; if([ToolsObject IsNullWithObject:msgModel]){ }else{ if(msgModel.response.status ==0){ if (msgModel.response.code ==4003){ [self showTipAleart]; }else{ [ToolsObject addPopVieToText:msgModel.response.msg]; } }else{ [ToolsObject addPopVieToText:@"赠送成功"]; [[AppMessageManager shareManager].delegate sendCleanMyPackage:YES]; } } } break; case 2001: { if (self.roomInfoModel.public_screen) { return; } NSDictionary *dataDict = msgModel.data; if ([ToolsObject IsNullWithObject:dataDict]) { return; } NSInteger message_type = [dataDict[@"message_type"] integerValue]; NSString * msg = dataDict[@"msg"]; NSString * expression_url = dataDict[@"expression_url"]; NSDictionary * userDict = dataDict[@"user"]; RoomUserInfoModel * user = [[RoomUserInfoModel alloc] init]; if (![ToolsObject IsNullWithObject:userDict]) { user = [RoomUserInfoModel yy_modelWithDictionary:userDict]; } if (message_type == 1) { NSDictionary * follow_userDict = dataDict[@"follow_user"]; RoomUserInfoModel *follow_user = [RoomUserInfoModel yy_modelWithDictionary:follow_userDict]; if (![ToolsObject IsNullWithObject:[ToolsObject getUserModel].user_id] &&[follow_user.follow_user_id integerValue]==0) { //[ToolsObject addPopVieToText:@"该用户已离开房间"]; } //显示“我在这”并发公屏消息 if (![ToolsObject IsNullWithObject:[ToolsObject getUserModel].user_id] &&[follow_user.follow_user_id integerValue] > 0) { //操作人 RoomUserInfoModel * other_user = [[RoomUserInfoModel alloc] init]; other_user.user_id = [ToolsObject getUserModel].user_id; other_user.nickname = [ToolsObject getUserModel].nickname; //other_user.nobility_id = [ToolsObject getUserModel].nobility_id; //other_user.nobility_avtar = [YVTool getNobility_avtarWithNobility_id:[ToolsObject getUserModel].nobility_id]; if ([follow_user.user_id isEqualToString:other_user.user_id]) { //跟随进入房间消息 [self.publicMessageView.dataArr addObject:[RoomPublicScreenModel initMessage:@"" user:user other_user:follow_user giftModel:[DDGiftWallModel new] message_type:2 handle_type:4]]; [self.publicMessageView refreshTableView]; }else{ //跟随进入房间消息 [self.publicMessageView.dataArr addObject:[RoomPublicScreenModel initMessage:@"" user:follow_user other_user:user giftModel:[DDGiftWallModel new] message_type:2 handle_type:4]]; [self.publicMessageView refreshTableView]; } } else { NSString *carSvga = user.car_box; NSString *intoWeclome =user.into_welcome; if (![ToolsObject IsNullWithObject:intoWeclome]) { NSDictionary *dataDic = @{@"animationType":@"3", @"count":@"1", @"svgaUrl":intoWeclome, @"nickname":user.nickname, @"level_icon":user.level_icon, @"avatar":user.avatar, @"nobility_id":@(user.nobility_id) }; [[AppMessageManager shareManager].delegate sendInRoomAddSvga:dataDic]; } if (![ToolsObject IsNullWithObject:carSvga]) { NSDictionary *dataDic = @{@"animationType":@"2", @"count":@"1", @"svgaUrl":carSvga }; [[AppMessageManager shareManager].delegate sendAddSvga:dataDic]; } //进入房间欢迎消息 [self.publicMessageView.dataArr addObject:[RoomPublicScreenModel initMessage:msg user:user other_user:[RoomUserInfoModel new] giftModel:[DDGiftWallModel new] message_type:1 handle_type:0]]; [self.publicMessageView refreshTableView]; } } if (message_type == 3) {//公屏聊天消息 [self.publicMessageView.dataArr addObject:[RoomPublicScreenModel initMessage:msg user:user other_user:[RoomUserInfoModel new] giftModel:[DDGiftWallModel new] message_type:3 handle_type:0]]; [self.publicMessageView refreshTableView]; } if (message_type == 5) {//表情消息 DDGiftWallModel *giftModel = [[DDGiftWallModel alloc] init]; giftModel.big_img = expression_url ?: @""; [self.publicMessageView.dataArr addObject:[RoomPublicScreenModel initMessage:@"表情消息" user:user other_user:[RoomUserInfoModel new] giftModel:giftModel message_type:5 handle_type:0]]; [self.publicMessageView refreshTableView]; [self showMicRoEmojiMessageToUser:user.user_id url:expression_url]; } } break; case 2002: { //双用户操作 系统消息 NSDictionary * dataDict = msgModel.data; if ([ToolsObject IsNullWithObject:dataDict]) { return; } NSDictionary * userDict = dataDict[@"user"]; NSDictionary * other_userDict = dataDict[@"other_user"]; if ([ToolsObject IsNullWithObject:userDict]||[ToolsObject IsNullWithObject:other_userDict]) { //如果被操作人或者操作人=nil,则不展示 return; } NSInteger handle_type = [dataDict[@"handle_type"] integerValue]; //被操作人 RoomUserInfoModel* other_user = [RoomUserInfoModel yy_modelWithDictionary:other_userDict]; if (handle_type == 1) { //被踢出房间 } if (self.roomInfoModel.public_screen) { return; } NSString * msg = dataDict[@"msg"]; //操作人 RoomUserInfoModel * user = [RoomUserInfoModel yy_modelWithDictionary:userDict]; [self.publicMessageView.dataArr addObject:[RoomPublicScreenModel initMessage:msg user:user other_user:other_user giftModel:[DDGiftWallModel new] message_type:2 handle_type:handle_type]]; [self.publicMessageView refreshTableView]; } break; case 2003: { if ([ToolsObject IsNullWithObject:msgModel.data]) { return; } NSString * msg = msgModel.data[@"msg"]; if (self.roomInfoModel.public_screen) { return; } if (![ToolsObject IsNullWithObject:msg]) { [self.publicMessageView.dataArr addObject:[RoomPublicScreenModel initMessage:msg user:[RoomUserInfoModel new] other_user:[RoomUserInfoModel new] giftModel:[DDGiftWallModel new] message_type:6 handle_type:0]]; [self.publicMessageView refreshTableView]; } } break; case 2004: { if(![ToolsObject IsNullWithObject:msgModel.data]){ NSArray * dataArray = [NSArray yy_modelArrayWithClass:RoomMicroModel.class json:msgModel.data[@"mic_list"]].mutableCopy; [self initMicroListToArray:dataArray]; } } break; case 2005: { if([ToolsObject IsNullWithObject:msgModel.data]){ }else{ RoomModel *model = [RoomModel yy_modelWithDictionary:msgModel.data[@"room_info"]]; if(model){ self.roomInfoModel.room_info = model; [self reloadRoomUI]; [[AppMessageManager shareManager].delegate sendReloadRoomInfo:model]; } } } break; case 2006: { self.roomInfoModel.micListCount = 0; self.roomInfoModel.isInMicList = NO; [[AppMessageManager shareManager].delegate sendRoomReloadMicroList:@(YES)]; [self reloadMicroListBtn:self.roomInfoModel.micListCount]; } break; case 2007: { if(![ToolsObject IsNullWithObject:msgModel.data]){ BOOL isFreeMicro = [msgModel.data[@"room_free_mic"] boolValue]; self.roomInfoModel.room_info.room_free_mic =isFreeMicro; [self reloadMicroListBtn:self.roomInfoModel.micListCount]; if (self.roomInfoModel.public_screen) { return; } if (isFreeMicro) { [self.publicMessageView.dataArr addObject:[RoomPublicScreenModel initMessage:@"自由麦序已开启" user:[RoomUserInfoModel new] other_user:[RoomUserInfoModel new] giftModel:[DDGiftWallModel new] message_type:6 handle_type:0]]; [self.publicMessageView refreshTableView]; } else { [self.publicMessageView.dataArr addObject:[RoomPublicScreenModel initMessage:@"自由麦序已关闭" user:[RoomUserInfoModel new] other_user:[RoomUserInfoModel new] giftModel:[DDGiftWallModel new] message_type:6 handle_type:0]]; [self.publicMessageView refreshTableView]; } } } break; case 2008: { if(![ToolsObject IsNullWithObject:msgModel.data]){ [self makeToGoOutRoom:msgModel.data type:1]; } } break; case 2009: { if([ToolsObject isBlankString:msgModel.data[@"msg"]].length >0){ UIAlertController *alertVC = [UIAlertController alertControllerWithTitle:@"警告" message:msgModel.data[@"msg"] preferredStyle:UIAlertControllerStyleAlert]; UIAlertAction *cancelaction = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleDefault handler:nil]; UIAlertAction *sendaction = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) { }]; [alertVC addAction:cancelaction]; [alertVC addAction:sendaction]; [self presentViewController:alertVC animated:YES completion:nil]; } } break; case 2010: { if(![ToolsObject IsNullWithObject:msgModel.data]){ self.roomInfoModel.micListCount = [msgModel.data[@"mic_order"]integerValue]; NSString * userId = msgModel.data[@"user_id"]; NSString * micId = msgModel.data[@"mic_id"]; if (![ToolsObject IsNullWithObject:msgModel.data]&&![ToolsObject IsNullWithObject:msgModel.data]) { BOOL isJoin = [msgModel.data[@"is_join"]boolValue]; if ([[ToolsObject getUserModel].user_id isEqualToString:userId]) { self.roomInfoModel.isInMicList = isJoin; } [[AppMessageManager shareManager].delegate sendRoomReloadMicroList:@{@"user_id":userId,@"is_join":@(isJoin),@"mic_id":micId}]; [self reloadMicroListBtn:self.roomInfoModel.micListCount]; } } } break; case 2011: { if ([ToolsObject IsNullWithObject:msgModel.data]) { return; } //送的人 NSDictionary * userDict = msgModel.data[@"user"]; if ([ToolsObject IsNullWithObject:userDict]) { return; } //是否播放礼物特效 NSString *svgaUrl = msgModel.data[@"gift_svga"]; if(self.roomInfoModel.isPlayGift &&![ToolsObject IsNullWithObject:svgaUrl]){ NSDictionary *dataDic = @{@"animationType":@"1", @"count":@"1", @"svgaUrl":svgaUrl }; [[AppMessageManager shareManager].delegate sendAddSvga:dataDic]; } if (self.roomInfoModel.public_screen) { return; } //接收的人 NSArray * dataArr = msgModel.data[@"other_user"]; __block NSMutableArray * giftMessageArr = [NSMutableArray array]; RoomUserInfoModel * userModel = [[RoomUserInfoModel alloc] init]; userModel.user_id = [NSString stringWithFormat:@"%ld",(long)[userDict[@"user_id"] integerValue]]; userModel.nickname = userDict[@"nickname"]; userModel.nobility_id = [userDict[@"nobility_id"] integerValue]; [dataArr enumerateObjectsUsingBlock:^(id _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) { if ([obj isKindOfClass:[NSDictionary class]]) { NSDictionary * otherUserDict = obj; RoomUserInfoModel * other_userModel = [[RoomUserInfoModel alloc] init]; other_userModel.user_id = [NSString stringWithFormat:@"%ld",(long)[otherUserDict[@"user_id"] integerValue]]; other_userModel.nickname = otherUserDict[@"nickname"]; other_userModel.nobility_id = [otherUserDict[@"nobility_id"] integerValue]; other_userModel.mic_id = [NSString stringWithFormat:@"%ld",(long)[otherUserDict[@"mic_id"] integerValue]]; DDGiftWallModel * giftModel = [[DDGiftWallModel alloc] init]; giftModel.nickname = otherUserDict[@"nickname"]; giftModel.nobility_id = otherUserDict[@"nobility_id"]; giftModel.gift_num = otherUserDict[@"num"]; giftModel.gift_name = otherUserDict[@"gift_name"]; giftModel.screen_img = otherUserDict[@"screen_img"]; giftModel.charm = otherUserDict[@"charm"]; [giftMessageArr addObject:[RoomPublicScreenModel initMessage:@"礼物消息" user:userModel other_user:other_userModel giftModel:giftModel message_type:4 handle_type:0]]; } }]; [self.publicMessageView.dataArr addObjectsFromArray:giftMessageArr]; [self.publicMessageView refreshTableView]; } break; case 2012: { if ([ToolsObject IsNullWithObject:msgModel.data]) { return; } NSDictionary * giftDict = msgModel.data[@"gift"]; NSDictionary * userDict = msgModel.data[@"user"]; NSString * room_id = [NSString stringWithFormat:@"%ld",(long)[msgModel.data[@"room_id"] integerValue]]; NSString * room_name = msgModel.data[@"room_name"]; if ([ToolsObject IsNullWithObject:giftDict]||[ToolsObject IsNullWithObject:userDict]||[ToolsObject IsNullWithObject:room_id]) { return; } RoomGiftAirPlaneModel *airModel = [[RoomGiftAirPlaneModel alloc]init]; airModel.user_name = userDict[@"nickname"]; airModel.user_id = [NSString stringWithFormat:@"%ld",(long)[userDict[@"user_id"] integerValue]]; airModel.avatar = userDict[@"avatar"]; airModel.room_id = room_id; airModel.giftName = giftDict[@"title"]; airModel.giftNum = [giftDict[@"num"] integerValue]; airModel.small_img = giftDict[@"small_img"]; airModel.room_name = room_name; airModel.isBarrage = 2; [self showAirPlaneViewToModel:airModel]; } break; case 2013: { if ([ToolsObject IsNullWithObject:msgModel.data]) { return; } NSDictionary * giftDict = msgModel.data[@"gift"]; NSDictionary * userDict = msgModel.data[@"user"]; NSDictionary * other_userDict = msgModel.data[@"other_user"]; NSString * room_id = [NSString stringWithFormat:@"%ld",(long)[msgModel.data[@"room_id"] integerValue]]; NSString * room_name = msgModel.data[@"room_name"]; if ([ToolsObject IsNullWithObject:giftDict]||[ToolsObject IsNullWithObject:userDict]||[ToolsObject IsNullWithObject:other_userDict]||[ToolsObject IsNullWithObject:room_id]) { return; } RoomGiftAirPlaneModel *airModel = [[RoomGiftAirPlaneModel alloc]init]; airModel.user_name = userDict[@"nickname"]; airModel.user_id = [NSString stringWithFormat:@"%ld",(long)[userDict[@"user_id"] integerValue]]; airModel.avatar = userDict[@"avatar"]; airModel.room_id = room_id; airModel.room_name = room_name; airModel.giftName = giftDict[@"title"]; airModel.giftNum = [giftDict[@"num"] integerValue]; airModel.small_img = giftDict[@"small_img"]; airModel.other_name = other_userDict[@"nickname"]; airModel.other_avatar = other_userDict[@"avatar"]; airModel.other_id = [NSString stringWithFormat:@"%ld",(long)[other_userDict[@"user_id"] integerValue]]; airModel.isBarrage = 1; [self showAirPlaneViewToModel:airModel]; break; } case 2014: { if([ToolsObject IsNullWithObject:msgModel.data]){ return; } NSInteger ttl = [msgModel.data[@"ttl"] integerValue]; self.roomInfoModel.isForbiddenWords = [msgModel.data[@"ban_type"] boolValue]; self.roomInfoModel.forbidden_ttl = ttl; [self uploadForbiddenWordsTime]; [self reloadTooView]; } break; case 2015: { if([ToolsObject IsNullWithObject:msgModel.data]){ return; } NSInteger ttl = [msgModel.data[@"ttl"] integerValue]; self.roomInfoModel.isForbiddenMic = [msgModel.data[@"ban_type"] boolValue]; self.roomInfoModel.micMuteState =self.roomInfoModel.isForbiddenMic; [[AgoraTool shareTool] setRoomMute: self.roomInfoModel.micMuteState]; self.roomInfoModel.unmic_ttl = ttl; [self uploadForbiddenMicTime]; [self reloadTooView]; } break; case 2016: { self.roomInfoModel.public_screen = [msgModel.data[@"public_screen"] boolValue]; [self reloadTooView]; if (!self.roomInfoModel.public_screen) { [self.publicMessageView.dataArr addObject:[RoomPublicScreenModel initMessage:@"公屏已开启" user:[RoomUserInfoModel new] other_user:[RoomUserInfoModel new] giftModel:[DDGiftWallModel new] message_type:6 handle_type:0]]; [self.publicMessageView refreshTableView]; } else { [self.publicMessageView.dataArr removeAllObjects]; [self.publicMessageView refreshTableView]; } } break; case 2017: { if([ToolsObject IsNullWithObject:msgModel.data]){ return; } self.roomInfoModel.isPwdLocked = [msgModel.data[@"is_set"] boolValue]; self.roomInfoModel.room_info.is_have_pwd =self.roomInfoModel.isPwdLocked; [[AppMessageManager shareManager].delegate sendReloadRoomInfo:self.roomInfoModel.room_info]; } break; case 2018: { NSString *userID = [NSString stringWithFormat:@"%ld",[msgModel.data[@"user_id"]integerValue]]; if ([userID isEqualToString:[ToolsObject getUserModel].user_id]) { [self makeToGoOutRoom:msgModel.data type:2]; }else{ [[AppMessageManager shareManager].delegate sendRoomReloadUserMessage:@{@"user_id":userID}]; } } break; case 2019: { NSLog(@""); if([ToolsObject IsNullWithObject:msgModel.data]){ return; } NSInteger scene = [msgModel.data[@"scene"] integerValue]; if(scene ==2){ [[AppMessageManager shareManager].delegate sendRoomIsOpenMessage:@{@"room_id":self.roomID,@"online":@"0"}]; if(self.roomInfoModel.room_auth.integerValue ==1){ dispatch_async(dispatch_get_main_queue(), ^{ [self dismissViewControllerAnimated:YES completion:^{ [RoomViewController destoryVC]; }]; }); return; } [self makeToGoOutRoom:msgModel.data type:4]; }else if (scene ==3){ NSString *userID = [NSString stringWithFormat:@"%ld",[msgModel.data[@"user_id"]integerValue]]; if([userID isEqualToString:[ToolsObject getUserModel].user_id]){ [[AppMessageManager shareManager].delegate sendRoomIsOpenMessage:@{@"room_id":self.roomID,@"online":@"-1"}]; [self makeToGoOutRoom:msgModel.data type:1]; return; } WeakSelf(ws); UIAlertController *alertVC = [UIAlertController alertControllerWithTitle:@"该房间已被注销" message:@"" preferredStyle:UIAlertControllerStyleAlert]; UIAlertAction *sendaction = [UIAlertAction actionWithTitle:@"我知道了" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) { [[AppMessageManager shareManager].delegate sendRoomIsOpenMessage:@{@"room_id":self.roomID,@"online":@"-1"}]; [ws makeToGoOutRoom:msgModel.data type:1]; }]; [alertVC addAction:sendaction]; [self presentViewController:alertVC animated:YES completion:nil]; }else{ if([msgModel.data[@"room_user_id"]integerValue]==0){ return;; } NSString *userID = [NSString stringWithFormat:@"%ld",[msgModel.data[@"user_id"]integerValue]]; if([userID isEqualToString:[ToolsObject getUserModel].user_id]){ return; } [[AppMessageManager shareManager].delegate sendRoomIsOpenMessage:@{@"room_id":self.roomID,@"online":@"0"}]; [self makeToGoOutRoom:msgModel.data type:1]; } } break; case 2020: { if([ToolsObject IsNullWithObject:msgModel.data]){ return; } NSDictionary * giftDict = msgModel.data[@"gift"]; NSDictionary * userDict = msgModel.data[@"user"]; //1:初级盲盒,2:初级宝藏,3:高级宝藏 NSString *witch_type =msgModel.data[@"witch_type"]; NSString * webUrl = msgModel.data[@"url"]; NSString * screen = [NSString stringWithFormat:@"%ld",(long)[msgModel.data[@"screen"] integerValue]]; if ([ToolsObject IsNullWithObject:giftDict]||[ToolsObject IsNullWithObject:userDict]) { return; } RoomGiftAirPlaneModel *airModel = [[RoomGiftAirPlaneModel alloc]init]; airModel.user_name = userDict[@"nickname"]; airModel.user_id = [NSString stringWithFormat:@"%ld",(long)[userDict[@"user_id"] integerValue]]; airModel.witch_type =witch_type.integerValue; airModel.avatar = userDict[@"avatar"]; airModel.giftName = giftDict[@"title"]; airModel.giftNum = [giftDict[@"num"] integerValue]; airModel.small_img = giftDict[@"small_img"]; airModel.isBarrage = 3; airModel.webUrl = webUrl; airModel.screen = screen; [self showAirPlaneViewToModel:airModel]; } break; case 2021: { if([ToolsObject IsNullWithObject:msgModel.data]){ return; } NSString *msg = msgModel.data[@"msg"]; NSString *userID = msgModel.data[@"user_id"]; NSString *roomAuth = msgModel.data[@"room_auth"]; if([ToolsObject IsNullWithObject:userID]||[ToolsObject IsNullWithObject:roomAuth]){ return; } [[AppMessageManager shareManager].delegate sendRoomReloadUserMessage:@{@"user_id":userID,@"room_auth":roomAuth}]; if([userID isEqualToString:[ToolsObject getUserModel].user_id]){ self.roomInfoModel.room_auth = roomAuth; if(self.roomInfoModel.public_screen){ return; } if(![ToolsObject IsNullWithObject:msg]){ [self.publicMessageView.dataArr addObject:[RoomPublicScreenModel initMessage:msg user:[RoomUserInfoModel new] other_user:[RoomUserInfoModel new] giftModel:[DDGiftWallModel new] message_type:6 handle_type:0]]; [self.publicMessageView refreshTableView]; } } } break; case 2022: { if(![ToolsObject IsNullWithObject:msgModel.data]){ NSInteger popularity = [msgModel.data[@"popularity"] integerValue]; self.roomInfoModel.popularity = popularity; [self reloadInfoView]; } } break; case 2023: break; case 2025: { if([ToolsObject IsNullWithObject:msgModel.data]){ return; } NSDictionary * giftDict = msgModel.data[@"gift"]; NSDictionary * userDict = msgModel.data[@"user"]; NSDictionary * other_userDict = msgModel.data[@"other_user"]; NSString * room_id = [NSString stringWithFormat:@"%ld",(long)[msgModel.data[@"room_id"] integerValue]]; NSString * room_name = msgModel.data[@"room_name"]; if ([ToolsObject IsNullWithObject:giftDict]||[ToolsObject IsNullWithObject:userDict]||[ToolsObject IsNullWithObject:other_userDict]||[ToolsObject IsNullWithObject:room_id]) { return; } RoomGiftAirPlaneModel *airModel = [[RoomGiftAirPlaneModel alloc]init]; airModel.user_name = userDict[@"nickname"]; airModel.user_id = [NSString stringWithFormat:@"%ld",(long)[userDict[@"user_id"] integerValue]]; airModel.avatar = userDict[@"avatar"]; airModel.room_id = room_id; airModel.room_name = room_name; airModel.giftName = giftDict[@"title"]; airModel.giftNum = [giftDict[@"num"] integerValue]; airModel.small_img = giftDict[@"small_img"]; airModel.other_name = other_userDict[@"nickname"]; airModel.other_id = [NSString stringWithFormat:@"%ld",(long)[other_userDict[@"user_id"] integerValue]]; airModel.other_avatar = other_userDict[@"avatar"]; airModel.gift_box_img = giftDict[@"gift_box_img"]; airModel.isBarrage = 5; [self showAirPlaneViewToModel:airModel]; } break; case 2026: { if ([ToolsObject IsNullWithObject:msgModel.data]) { return; } //送的人 NSDictionary * userDict = msgModel.data[@"user"]; if ([ToolsObject IsNullWithObject:userDict]) { return; } //接收的人 NSDictionary * otherUserDict = msgModel.data[@"other_user"]; if ([ToolsObject IsNullWithObject:otherUserDict]) { return; } //是否播放礼物特效 NSString *svgaUrl = msgModel.data[@"gift_svga"]; if(self.roomInfoModel.isPlayGift &&![ToolsObject IsNullWithObject:svgaUrl]){ NSDictionary *dataDic = @{@"animationType":@"1", @"count":@"1", @"svgaUrl":svgaUrl }; [[AppMessageManager shareManager].delegate sendAddSvga:dataDic]; } if (self.roomInfoModel.public_screen) { return; } //接收的人 RoomUserInfoModel * userModel = [[RoomUserInfoModel alloc] init]; userModel.user_id = [NSString stringWithFormat:@"%ld",(long)[userDict[@"user_id"] integerValue]]; userModel.nickname = userDict[@"nickname"]; userModel.nobility_id = [userDict[@"nobility_id"] integerValue]; NSMutableArray * giftMessageArr = [NSMutableArray array]; RoomUserInfoModel * other_userModel = [[RoomUserInfoModel alloc] init]; other_userModel.user_id = [NSString stringWithFormat:@"%ld",(long)[otherUserDict[@"user_id"] integerValue]]; other_userModel.nickname = otherUserDict[@"nickname"]; other_userModel.nobility_id = [otherUserDict[@"nobility_id"] integerValue]; other_userModel.mic_id = [NSString stringWithFormat:@"%ld",(long)[otherUserDict[@"mic_id"] integerValue]]; DDGiftWallModel * giftModel = [[DDGiftWallModel alloc] init]; giftModel.nickname = otherUserDict[@"nickname"]; giftModel.nobility_id = otherUserDict[@"nobility_id"]; giftModel.gift_num = otherUserDict[@"num"]; giftModel.gift_name = otherUserDict[@"gift_name"]; giftModel.screen_img = otherUserDict[@"screen_img"]; giftModel.charm = otherUserDict[@"charm"]; giftModel.random_gift_name = otherUserDict[@"random_gift_name"]; [giftMessageArr addObject:[RoomPublicScreenModel initMessage:@"礼物消息" user:userModel other_user:other_userModel giftModel:giftModel message_type:4 handle_type:0]]; [self.publicMessageView.dataArr addObjectsFromArray:giftMessageArr]; [self.publicMessageView refreshTableView]; } break; case 2027: { if ([ToolsObject IsNullWithObject:msgModel.data]) { return; } NSDictionary * giftDict = msgModel.data[@"gift"]; NSDictionary * userDict = msgModel.data[@"user"]; if ([ToolsObject IsNullWithObject:giftDict]||[ToolsObject IsNullWithObject:userDict]) { return; } RoomGiftAirPlaneModel *airModel = [[RoomGiftAirPlaneModel alloc]init]; airModel.user_name = userDict[@"nickname"]; airModel.user_id = [NSString stringWithFormat:@"%ld",(long)[userDict[@"user_id"] integerValue]]; airModel.avatar = userDict[@"avatar"]; airModel.giftName = giftDict[@"title"]; airModel.giftNum = [giftDict[@"num"] integerValue]; airModel.small_img = giftDict[@"small_img"]; airModel.isBarrage = 4; [self showAirPlaneViewToModel:airModel]; } break; case 2048: { if ([ToolsObject IsNullWithObject:msgModel.data]) { return; } //送的人 NSDictionary * userDict = msgModel.data[@"user"]; if ([ToolsObject IsNullWithObject:userDict]) { return; } if ([ToolsObject IsNullWithObject:msgModel.data[@"gift_info"]]){return;} //是否播放礼物特效 NSString *svgaUrl = msgModel.data[@"gift_svga"]; if(self.roomInfoModel.isPlayGift &&![ToolsObject IsNullWithObject:svgaUrl]){ NSDictionary *dataDic = @{@"animationType":@"1", @"count":@"1", @"svgaUrl":svgaUrl }; [[AppMessageManager shareManager].delegate sendAddSvga:dataDic]; } if (self.roomInfoModel.public_screen) { return; } NSDictionary * otherUserDict = msgModel.data[@"other_user"]; RoomUserInfoModel * userModel = [[RoomUserInfoModel alloc] init]; userModel.user_id = [NSString stringWithFormat:@"%ld",(long)[userDict[@"user_id"] integerValue]]; userModel.nickname = userDict[@"nickname"]; userModel.nobility_id = [userDict[@"nobility_id"] integerValue]; RoomUserInfoModel * other_userModel = [[RoomUserInfoModel alloc] init]; other_userModel.user_id = [NSString stringWithFormat:@"%ld",(long)[otherUserDict[@"user_id"] integerValue]]; other_userModel.nickname = otherUserDict[@"nickname"]; other_userModel.nobility_id = [otherUserDict[@"nobility_id"] integerValue]; [self.publicMessageView.dataArr addObject:[RoomPublicScreenModel initMessage:msgModel.data[@"gift_info"] user:userModel other_user:other_userModel giftModel:[DDGiftWallModel new] message_type:2 handle_type:5]]; [self.publicMessageView refreshTableView]; } break; default: break; } } #pragma mark --------------------消息发送 #pragma mark --上主持麦 - (void)roomSendUpHostMicroToMicroID:(NSString *)microID{ UIAlertController *alertVC = [UIAlertController alertControllerWithTitle:@"确认上主持麦" message:@"" preferredStyle:UIAlertControllerStyleAlert]; UIAlertAction *cancelaction = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleDefault handler:nil]; UIAlertAction *sendaction = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) { [[AppMessageManager shareManager] sendUpSelectMicroMessage:self.roomID microID:microID]; }]; [alertVC addAction:cancelaction]; [alertVC addAction:sendaction]; [self presentViewController:alertVC animated:YES completion:nil]; } #pragma mark --request网络请求 //封禁房间 - (void)requestBannedRoom{ WeakSelf(ws); NSMutableDictionary *params = [[NSMutableDictionary alloc] init]; [params setObject:self.roomID forKey:@"room_id"]; [NetworkRequest requestPOST:@"/room/ban/room" parameters:params block:^(BaseResponse * _Nonnull response) { if(response.code ==200){ [ToolsObject addPopVieToText:@"操作成功"]; [ws dismissViewControllerAnimated:YES completion:^{ [RoomViewController destoryVC]; }]; } }]; } //设置 取消密码 - (void)requsetPassWord:(NSString *)passWordText isEdit:(BOOL)isEdit{ WeakSelf(ws); NSMutableDictionary *params = [[NSMutableDictionary alloc] init]; [params setObject:passWordText forKey:@"pwd"]; [params setObject:self.roomID forKey:@"room_id"]; if(isEdit){ [NetworkRequest requestPOST:@"/room/set/pwd" parameters:params block:^(BaseResponse * _Nonnull response) { if(response.code ==200){ [ToolsObject addPopVieToText:@"房间上锁成功"]; ws.roomInfoModel.room_info.room_pwd = passWordText; ws.roomInfoModel.isLock = YES; } }]; }else{ [NetworkRequest requestPOST:@"/room/check/password" parameters:params block:^(BaseResponse * _Nonnull response) { if(response.code ==200){ NSMutableDictionary *paramsTwo = [[NSMutableDictionary alloc] init]; [paramsTwo setObject:@"" forKey:@"pwd"]; [paramsTwo setObject:self.roomID forKey:@"room_id"]; [NetworkRequest requestPOST:@"/room/set/pwd" parameters:paramsTwo block:^(BaseResponse * _Nonnull response) { if(response.code ==200){ [ToolsObject addPopVieToText:@"房间解锁成功"]; ws.roomInfoModel.room_info.room_pwd = @""; ws.roomInfoModel.isLock = NO; } }]; }else{ [ToolsObject addPopVieToText:@"房间密码不对哦~"]; } }]; } } //获取商店礼物 - (void)requestGetShopGifts{ NSMutableDictionary *params = [[NSMutableDictionary alloc] init]; [NetworkRequest requestPOST:@"/gift/list" parameters:params block:^(BaseResponse * _Nonnull response) { if(response.code ==200){ self.roomInfoModel.shopGiftsArray = [NSMutableArray arrayWithArray:[NSArray yy_modelArrayWithClass:[RoomGiftModel class] json:response.data]]; } }]; } //获取幸运礼物 - (void)requestGetluckGifts{ NSMutableDictionary *params = [[NSMutableDictionary alloc] init]; [params setObject:@"2" forKey:@"type"]; [NetworkRequest requestPOST:@"/gift/list" parameters:params block:^(BaseResponse * _Nonnull response) { if(response.code ==200){ self.roomInfoModel.luckGiftsArray = [NSMutableArray arrayWithArray:[NSArray yy_modelArrayWithClass:[RoomGiftModel class] json:response.data]]; } }]; } //获取特权礼物 - (void)requestGetPricileGifts{ NSMutableDictionary *params = [[NSMutableDictionary alloc] init]; [params setObject:@"4" forKey:@"type"]; [NetworkRequest requestPOST:@"/gift/list" parameters:params block:^(BaseResponse * _Nonnull response) { if(response.code ==200){ self.roomInfoModel.pricileGiftsArray =[NSMutableArray arrayWithArray: [NSArray yy_modelArrayWithClass:[RoomGiftModel class] json:response.data]]; } }]; } //获取背包礼物 - (void)requestGetpackageGifts{ NSMutableDictionary *params = [[NSMutableDictionary alloc] init]; [NetworkRequest requestPOST:@"/gift/backpack" parameters:params block:^(BaseResponse * _Nonnull response) { if(response.code ==200){ NSArray *array = [NSArray yy_modelArrayWithClass:[RoomGiftModel class] json:response.data]; __block NSInteger packageGiftValue = 0; [array enumerateObjectsUsingBlock:^(id _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) { if ([obj isKindOfClass:[RoomGiftModel class]]){ RoomGiftModel * model = obj; packageGiftValue+=model.price*model.gift_num; } }]; self.roomInfoModel.packageGiftsArray = [NSMutableArray arrayWithArray:array]; self.roomInfoModel.packageGiftValue =packageGiftValue; } }]; } - (void)requestGetGiftCountArray{ NSArray * dataArr = @[ [SendGiftCountModel initWithTitle:@"一心一意" num:1], [SendGiftCountModel initWithTitle:@"五福临门" num:5], [SendGiftCountModel initWithTitle:@"十全十美" num:10], [SendGiftCountModel initWithTitle:@"爱你" num:21], [SendGiftCountModel initWithTitle:@"想你" num:30], [SendGiftCountModel initWithTitle:@"一切顺利" num:66], [SendGiftCountModel initWithTitle:@"我要抱抱" num:188], [SendGiftCountModel initWithTitle:@"我爱你" num:520], [SendGiftCountModel initWithTitle:@"一生一世" num:1314] ]; self.roomInfoModel.giftCountArray =[NSMutableArray arrayWithArray:dataArr]; } ///封禁用户 - (void)requestBanUserToUserID:(NSString *)userID{ NSMutableDictionary *paramas = [[NSMutableDictionary alloc] init]; [paramas setObject:userID forKey:@"operated_user_id"]; [NetworkRequest requestPOST:@"/room/ban/user" parameters:paramas block:^(BaseResponse * _Nonnull response) { if(response.code ==200){ [ToolsObject addPopVieToText:@"封禁成功"]; } }]; } ///冻结用户 - (void)requestFrozenUserToUserID:(NSString *)userID{ NSMutableDictionary *paramas = [[NSMutableDictionary alloc] init]; [paramas setObject:userID forKey:@"operated_user_id"]; [NetworkRequest requestPOST:@"/room/frozen/user" parameters:paramas block:^(BaseResponse * _Nonnull response) { if(response.code ==200){ [ToolsObject addPopVieToText:@"封禁成功"]; } }]; } ///获取麦位数据 - (void)getMicroData{ WeakSelf(ws); NSMutableDictionary *parmas = [[NSMutableDictionary alloc] init]; [parmas setObject:self.roomID forKey:@"room_id"]; [NetworkRequest requestPOST:@"/room/mic/list" parameters:parmas block:^(BaseResponse * _Nonnull response) { if(response.code ==200){ NSArray * dataArray = [NSArray yy_modelArrayWithClass:RoomMicroModel.class json:response.data].mutableCopy; [ws initMicroListToArray:dataArray]; } }]; } ///是否收藏房间 - (void)collectionRoomWithIsCollection:(BOOL)isCollection{ WeakSelf(ws); [DDRoomRequest DD_RoomCollectionType:isCollection ? 2 : 1 roomUid:self.roomID success:^{ ws.infoView.collectionBtn.hidden = isCollection; // ws.roomInfoModel.is_collect =isCollection; }]; // NSMutableDictionary *dataDic = [[NSMutableDictionary alloc] init]; // [dataDic setObject:self.roomID forKey:@"room_id"]; // [dataDic setObject:isCollection ?@"1":@"0" forKey:@"is_collect"]; // WeakSelf(ws); // [NetworkRequest requestPOST:@"/room/collect" parameters:dataDic block:^(BaseResponse * _Nonnull response) { // if(response.code ==200){ // ws.infoView.collectionBtn.hidden = isCollection; // ws.roomInfoModel.is_collect =isCollection; // } // }]; } ///获取活动列表 - (void)getEventList{ NSMutableDictionary *dataDic = [[NSMutableDictionary alloc] init]; [dataDic setObject:self.roomID forKey:@"room_id"]; [dataDic setObject:@"2" forKey:@"position"]; WeakSelf(ws); [NetworkRequest requestPOST:@"/home/banner/list" parameters:dataDic block:^(BaseResponse * _Nonnull response) { if(response.code ==200){ NSArray *dataArray = [DDBannerModel mj_objectArrayWithKeyValuesArray:response.data].mutableCopy; [ws.roomEventView reloadEventArray:dataArray]; } }]; } ///获取房间功能操作 - (void)requestPopUserSetToMicroModel:(RoomMicroModel *)microModel onMic:(BOOL)onMic{ NSMutableDictionary *parmas = [[NSMutableDictionary alloc] init]; [parmas setObject:microModel.user_id forKey:@"user_id"]; [parmas setObject:self.roomID forKey:@"room_id"]; WeakSelf(ws); [NetworkRequest requestPOST:@"/room/get/status" parameters:parmas block:^(BaseResponse * _Nonnull response) { if(response.code ==200){ NSDictionary *dataDict = response.data; NSInteger is_ban_talk =[dataDict[@"is_ban_talk"] integerValue]; NSInteger is_ban_mic =[dataDict[@"is_ban_mic"] integerValue]; NSInteger is_frozen =[dataDict[@"is_frozen"] integerValue]; NSInteger room_auth =[dataDict[@"room_auth"] integerValue]; if (room_auth != 0) { microModel.room_auth = [NSString stringWithFormat:@"%lu",room_auth]; }else{ microModel.room_auth = @"6"; } if ([microModel.room_auth integerValue]== 1||([microModel.room_auth integerValue] < [ws.roomInfoModel.room_auth integerValue] && [self.roomInfoModel.room_auth integerValue]!=1)) { [ToolsObject addPopVieToText:@"无权限"]; return; } if ([ws.roomInfoModel.room_auth integerValue] == 1) { NSMutableArray * totalArr = [NSMutableArray array]; [totalArr addObject:@"查看信息名片"]; if (onMic&&[microModel.mic_id integerValue] != 88) { [totalArr addObject:@"抱下麦"]; } [totalArr addObject:@"禁言"]; if (onMic) { [totalArr addObject:@"禁麦"]; } if ([microModel.mic_id integerValue] != 88) { [totalArr addObject:@"踢出房间"]; } [totalArr addObject:@"警告"]; [totalArr addObject:@"封号"]; if (is_frozen == 0) { [totalArr addObject:@"冻结账户"]; } dispatch_async(dispatch_get_main_queue(), ^{ [RoomPopTool popMicroManageToRoomID:ws.roomID microModel: microModel menuArray:totalArr curentVC:ws selectItem:^(NSString * _Nonnull itemStr) { [ws microSetToStr:itemStr microModel:microModel]; }]; }); }else{ NSMutableArray * totalArr = [NSMutableArray array]; [totalArr addObject:@"查看信息名片"]; if ([ws.roomInfoModel.room_auth integerValue] == 2||[self.roomInfoModel.room_auth integerValue] == 3||([self.roomInfoModel.room_auth integerValue] == 5)) { if (onMic) { [totalArr addObject:@"抱下麦"]; [totalArr addObject:@"清空麦位值"]; }else{ [totalArr addObject:@"抱上麦"]; } } if ([ws.roomInfoModel.room_auth integerValue] == 5&&[microModel.room_auth integerValue] == 5) { }else{ [totalArr addObjectsFromArray:[ws getRoomIdentitySettingArrayToRoomAut:[microModel.room_auth integerValue]]]; } if (is_ban_talk==1) { [totalArr addObject:@"解除禁言"]; }else{ [totalArr addObject:@"禁言"]; } if (onMic) { if (is_ban_mic==1) { [totalArr addObject:@"解除禁麦"]; }else{ [totalArr addObject:@"禁麦"]; } } [totalArr addObject:@"踢出房间"]; if ([ws.roomInfoModel.room_auth integerValue] == 5||[ws.roomInfoModel.room_auth integerValue] == 3||[ws.roomInfoModel.room_auth integerValue] == 2) { [totalArr addObject:@"加入黑名单"]; } [RoomPopTool popMicroManageToRoomID:ws.roomID microModel:microModel menuArray:totalArr curentVC:ws selectItem:^(NSString * _Nonnull itemStr) { [ws microSetToStr:itemStr microModel:microModel]; }]; } } }]; } - (NSMutableArray *)getRoomIdentitySettingArrayToRoomAut:(NSInteger)roomAuth{ NSMutableArray *itemArray = [[NSMutableArray alloc] init]; if(self.roomInfoModel.room_auth.integerValue ==2){ switch (roomAuth) { case 3: // [itemArray addObject:@"设为主播"]; [itemArray addObject:@"设为房管"]; [itemArray addObject:@"设为普通用户"]; break; case 4: // [itemArray addObject:@"设为主持"]; [itemArray addObject:@"设为房管"]; [itemArray addObject:@"设为普通用户"]; break; case 5: // [itemArray addObject:@"设为主持"]; // [itemArray addObject:@"设为主播"]; [itemArray addObject:@"设为普通用户"]; break; case 6: // [itemArray addObject:@"设为主持"]; // [itemArray addObject:@"设为主播"]; [itemArray addObject:@"设为房管"]; break; default: break; } }else if(self.roomInfoModel.room_auth.integerValue ==5 ||self.roomInfoModel.room_auth.integerValue ==3){ switch (roomAuth) { case 3: [itemArray addObject:@"设为房管"]; [itemArray addObject:@"设为普通用户"]; break; case 4: [itemArray addObject:@"设为房管"]; [itemArray addObject:@"设为普通用户"]; break; case 5: // [itemArray addObject:@"设为主播"]; [itemArray addObject:@"设为普通用户"]; break; case 6: // [itemArray addObject:@"设为主播"]; [itemArray addObject:@"设为房管"]; break; default: break; } }else if(self.roomInfoModel.room_auth.integerValue ==4){ switch (roomAuth) { case 5: [itemArray addObject:@"设为普通用户"]; break; default: break; } } return itemArray; } - (void)inputView:(DDMInputView *)inputView sendMessage:(NSString *)message { RoomUserInfoModel *userModel = [[RoomUserInfoModel alloc] init]; userModel.nickname = [ToolsObject getUserModel].nickname; userModel.room_auth = self.roomInfoModel.room_auth; userModel.user_id = [ToolsObject getUserModel].user_id;; userModel.level_icon = [ToolsObject getUserModel].level_icon; [[AppMessageManager shareManager] sendPublicTextMessage:self.roomID text:message userInfo:userModel messageType:3]; [self.myInputView chatResignFirstResponder]; self.myInputView.hidden = YES; } #pragma mark --禁言禁麦 倒计时 - (void)uploadForbiddenMicTime{ dispatch_queue_t queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0); if (self.roomInfoModel.unmic_ttl <= 0) { [self cancelMicTimer]; return; } self.micTimer = dispatch_source_create(DISPATCH_SOURCE_TYPE_TIMER, 0, 0, queue); dispatch_source_set_timer(self.micTimer,dispatch_walltime(NULL, 0),1.0*NSEC_PER_SEC, 0); WeakSelf(ws); dispatch_source_set_event_handler(self.micTimer, ^{ if(ws.roomInfoModel.unmic_ttl <= 0){ [ws cancelMicTimer]; ws.roomInfoModel.isForbiddenMic = 0; ws.roomInfoModel.micMuteState = 0; [[AgoraTool shareTool] setRoomMute:ws.roomInfoModel.micMuteState]; dispatch_async(dispatch_get_main_queue(), ^{ [ws reloadTooView]; }); }else{ self.roomInfoModel.unmic_ttl--; } }); dispatch_resume(self.micTimer); } - (void)uploadForbiddenWordsTime{ dispatch_queue_t queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0); if (self.roomInfoModel.forbidden_ttl <= 0) { [self cancelWordsTimer]; return; } self.wordsTimer = dispatch_source_create(DISPATCH_SOURCE_TYPE_TIMER, 0, 0, queue); dispatch_source_set_timer(self.wordsTimer,dispatch_walltime(NULL, 0),1.0*NSEC_PER_SEC, 0); WeakSelf(ws); dispatch_source_set_event_handler(self.wordsTimer, ^{ if(self.roomInfoModel.forbidden_ttl <= 0){ [self cancelWordsTimer]; self.roomInfoModel.isForbiddenWords = 0; dispatch_async(dispatch_get_main_queue(), ^{ [ws reloadTooView]; }); }else{ self.roomInfoModel.forbidden_ttl--; } }); dispatch_resume(self.wordsTimer); } - (void)cancelMicTimer { if (self.micTimer) { dispatch_source_cancel(self.micTimer); self.micTimer = nil; } } - (void)cancelWordsTimer { if (self.wordsTimer) { dispatch_source_cancel(self.wordsTimer); self.wordsTimer = nil; } } //键盘状态变化 - (void)inputView:(DDMInputView *)inputView willChangeFrameWithDuration:(CGFloat)duration { NSLog(@"%f",self.myInputView.keyboardH); if (self.myInputView.keyboardH == 0) { self.myInputView.hidden = YES; } } - (void)reloadGiftSource{ [self.roomInfoModel.shopGiftsArray enumerateObjectsUsingBlock:^(id _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) { if([obj isKindOfClass:[RoomGiftModel class]]){ RoomGiftModel *model = obj; model.isSelect = NO; } }]; [self.roomInfoModel.luckGiftsArray enumerateObjectsUsingBlock:^(id _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) { if([obj isKindOfClass:[RoomGiftModel class]]){ RoomGiftModel *model = obj; model.isSelect = NO; } }]; [self.roomInfoModel.pricileGiftsArray enumerateObjectsUsingBlock:^(id _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) { if([obj isKindOfClass:[RoomGiftModel class]]){ RoomGiftModel *model = obj; model.isSelect = NO; } }]; [self.roomInfoModel.packageGiftsArray enumerateObjectsUsingBlock:^(id _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) { if([obj isKindOfClass:[RoomGiftModel class]]){ RoomGiftModel *model = obj; model.isSelect = NO; } }]; [self.roomInfoModel.allMicroArray enumerateObjectsUsingBlock:^(id _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) { if([obj isKindOfClass:[RoomMicroModel class]]){ RoomMicroModel *model = obj; model.isSelect = NO; } }]; } #pragma mark vc 上添加 webview - (void)addWebVcViewWithModel:(DDBannerModel*)model data:(NSDictionary *)dict { if ([ToolsObject IsNullWithObject:model.param]) { [ToolsObject addPopVieToText:@"没有获取到链接"]; return; } if (self.isHalfClick) { return; } if (!self.popBgButton.hidden) { return; } self.isHalfClick = YES; self.halfActiveWebVC = [DDWebViewController webControlerWithUrlStr:model.param isShowNavBar:NO isHalf:YES data:dict]; self.halfActiveWebVC.view.frame = CGRectMake(0, kHeight, kWidth, kWidth * 1.47 + KSAFEAREA_BOTTOM_HEIHGHT); WeakSelf(ws); self.halfActiveWebVC.failLoadBlock = ^{ ws.isHalfClick = NO; }; self.halfActiveWebVC.view.backgroundColor = [UIColor clearColor]; self.halfActiveWebVC.finishLoadBlock = ^{ [UIView animateWithDuration:0.1 animations:^{ ws.halfActiveWebVC.view.top = kHeight - kWidth * 1.47 - KSAFEAREA_BOTTOM_HEIHGHT ; ws.popBgButton.hidden = NO; ws.isShowHalfWebVC = YES; ws.isHalfClick = NO; }]; }; self.halfActiveWebVC.backDismissBlock = ^{ [ws dismissWebVc:ws.halfActiveWebVC]; }; [self addChildViewController:self.halfActiveWebVC]; [self.view addSubview:self.halfActiveWebVC.view]; [self.view bringSubviewToFront:self.halfActiveWebVC.view]; } - (void)dismissWebVc:(UIViewController *)vc { WeakSelf(ws); [UIView animateWithDuration:0.1 animations:^{ vc.view.top = kHeight; } completion:^(BOOL finished) { [vc.view removeFromSuperview]; [vc willMoveToParentViewController:nil]; [vc removeFromParentViewController]; ws.popBgButton.hidden = YES; ws.isShowHalfWebVC = NO; ws.isHalfClick = NO; if (ws.halfActiveWebVC) { ws.halfActiveWebVC = nil; } }]; } #pragma mark --lazy - (DDAnimateImageView *)bgImageView{ if (!_bgImageView) { _bgImageView = [[DDAnimateImageView alloc] init]; _bgImageView.backgroundColor = Kblack_color; _bgImageView.contentMode = UIViewContentModeScaleAspectFill; _bgImageView.image = KGetImage(@"roombg"); [self.view addSubview:_bgImageView]; [_bgImageView mas_makeConstraints:^(MASConstraintMaker *make) { make.edges.equalTo(self.view).with.insets(UIEdgeInsetsMake(0, 0, 0, 0)); }]; } return _bgImageView; } - (RoomInfoView *)infoView{ if (!_infoView) { _infoView = [[RoomInfoView alloc] init]; _infoView.backgroundColor = [UIColor clearColor]; [self.view addSubview:_infoView]; [_infoView mas_makeConstraints:^(MASConstraintMaker *make) { make.left.right.mas_equalTo(self.view).mas_offset(0); make.top.mas_equalTo(self.view.mas_top).mas_offset(KSTATUSRECT.size.height+KAdaptedHeight(0)); make.height.mas_equalTo(KAdaptedHeight(44)); }]; } return _infoView; } - (UIButton *)hostCharmBtn{ if (!_hostCharmBtn) { _hostCharmBtn = [UIButton buttonWithType:UIButtonTypeCustom]; [_hostCharmBtn setBackgroundColor:[UIColor jk_colorWithHex:0xffffff andAlpha:.2]]; [_hostCharmBtn addTarget:self action:@selector(hostCharmBtnClick) forControlEvents:UIControlEventTouchUpInside]; [_hostCharmBtn setTitleColor:[UIColor jk_colorWithHex:0xFFFFFF] forState:UIControlStateNormal]; _hostCharmBtn.titleLabel.font = KFont(10); [_hostCharmBtn setTitle:@"魅力值0" forState:UIControlStateNormal]; [self.view addSubview:_hostCharmBtn]; [_hostCharmBtn mas_makeConstraints:^(MASConstraintMaker *make) { make.height.mas_equalTo(KAdaptedHeight(24)); make.width.mas_equalTo(KAdaptedWidth(68)); make.left.mas_equalTo(self.view.mas_left).mas_offset(KAdaptedWidth(0)); make.top.mas_equalTo(self.infoView.mas_bottom).mas_offset(KAdaptedHeight(5)); }]; } return _hostCharmBtn; } - (UIButton *)rankBtn{ if (!_rankBtn) { _rankBtn = [UIButton buttonWithType:UIButtonTypeCustom]; [_rankBtn setBackgroundImage:KGetImage(@"room76") forState:UIControlStateNormal]; [_rankBtn addTarget:self action:@selector(rankBtnClick) forControlEvents:UIControlEventTouchUpInside]; [self.view addSubview:_rankBtn]; [_rankBtn mas_makeConstraints:^(MASConstraintMaker *make) { make.size.mas_equalTo(CGSizeMake(KAdaptedWidth(68), KAdaptedHeight(24))); make.left.mas_equalTo(self.hostCharmBtn.mas_right).mas_offset(KAdaptedWidth(8)); make.centerY.mas_equalTo(self.hostCharmBtn).mas_offset(0); }]; } return _rankBtn; } - (UIButton *)tipBtn{ if (!_tipBtn) { _tipBtn = [UIButton buttonWithType:UIButtonTypeCustom]; _tipBtn.hidden = YES; [_tipBtn setBackgroundImage:KGetImage(@"room_6") forState:UIControlStateNormal]; [_tipBtn addTarget:self action:@selector(tipBtnClick) forControlEvents:UIControlEventTouchUpInside]; [self.view addSubview:_tipBtn]; [_tipBtn mas_makeConstraints:^(MASConstraintMaker *make) { make.size.mas_equalTo(CGSizeMake(KAdaptedWidth(66), KAdaptedHeight(24))); make.left.mas_equalTo(self.view.mas_left).mas_offset(15); make.top.mas_equalTo(self.infoView.mas_bottom).mas_offset(KAdaptedHeight(5)); }]; } return _tipBtn; } - (RoomMicroView *)hostMicroView{ if (!_hostMicroView) { _hostMicroView = [[RoomMicroView alloc] init]; _hostMicroView.backgroundColor = [UIColor clearColor]; // _hostMicroView.hidden = YES; [self.view addSubview:_hostMicroView]; [_hostMicroView mas_makeConstraints:^(MASConstraintMaker *make) { make.size.mas_equalTo(CGSizeMake(KAdaptedWidth(100), KAdaptedHeight(107))); make.centerX.mas_equalTo(self.view).mas_offset(0); make.top.mas_equalTo(self.tipBtn.mas_bottom).mas_offset(0); }]; } return _hostMicroView; } - (RoomMicroView *)guestMicroView{ if (!_guestMicroView) { _guestMicroView = [[RoomMicroView alloc] init]; _guestMicroView.backgroundColor = [UIColor clearColor]; _guestMicroView.hidden = YES; [self.view addSubview:_guestMicroView]; [_guestMicroView mas_makeConstraints:^(MASConstraintMaker *make) { make.size.mas_equalTo(self.hostMicroView); make.centerY.mas_equalTo(self.hostMicroView); make.right.mas_equalTo(self.view.mas_right).mas_offset(KAdaptedWidth(-40)); }]; } return _guestMicroView; } - (RoomUserMicroView *)userMicroView{ if (!_userMicroView) { _userMicroView = [[RoomUserMicroView alloc] init]; _userMicroView.backgroundColor = [UIColor clearColor]; [self.view addSubview:_userMicroView]; [_userMicroView mas_makeConstraints:^(MASConstraintMaker *make) { make.left.right.mas_equalTo(self.view).mas_offset(0); make.top.mas_equalTo(self.hostMicroView.mas_bottom).mas_offset(10); make.height.mas_equalTo(117*2); }]; } return _userMicroView; } - (RoomToolView *)toolView{ if (!_toolView) { _toolView = [[RoomToolView alloc] init]; _toolView.backgroundColor = [UIColor clearColor]; [self.view addSubview:_toolView]; [_toolView mas_makeConstraints:^(MASConstraintMaker *make) { make.left.right.bottom.mas_equalTo(self.view).mas_offset(0); make.height.mas_equalTo(KAdaptedHeight(65)+KSAFEAREA_BOTTOM_HEIHGHT); }]; } return _toolView; } - (UIButton *)microListBtn{ if (!_microListBtn) { _microListBtn = [UIButton buttonWithType:UIButtonTypeCustom]; [_microListBtn setTitleColor:UIColor.whiteColor forState:UIControlStateNormal]; [_microListBtn setTitle:@"上麦\n互动" forState:UIControlStateNormal]; _microListBtn.titleLabel.font = KFontMedium(11); _microListBtn.titleLabel.numberOfLines = 2; _microListBtn.titleLabel.textAlignment = NSTextAlignmentCenter; [_microListBtn setBackgroundImage:[UIImage imageNamed:@"room_64"] forState:UIControlStateNormal]; [_microListBtn addTarget:self action:@selector(microListBtnClick) forControlEvents:UIControlEventTouchUpInside]; [self.view addSubview:_microListBtn]; [_microListBtn mas_makeConstraints:^(MASConstraintMaker *make) { make.size.mas_equalTo(CGSizeMake(KAdaptedWidth(48), KAdaptedWidth(48))); make.right.mas_equalTo(self.view.mas_right).mas_offset(-KAdaptedWidth(15)); make.bottom.mas_equalTo(self.toolView.mas_top).mas_offset(-KAdaptedHeight(30)); }]; } return _microListBtn; } - (RoomEventView *)roomEventView{ if (!_roomEventView) { _roomEventView = [[RoomEventView alloc] init]; _roomEventView.backgroundColor = [UIColor clearColor]; _roomEventView.hidden = YES; WeakSelf(ws); _roomEventView.selectBlock = ^(DDBannerModel * _Nonnull model) { [ws addWebVcViewWithModel:model data:@{@"room_id":ws.roomID}]; }; [self.view addSubview:_roomEventView]; [_roomEventView mas_makeConstraints:^(MASConstraintMaker *make) { make.height.mas_equalTo(85); make.width.mas_equalTo(75); make.right.equalTo(self.view).inset(10); make.top.equalTo(self.publicMessageView); }]; } return _roomEventView; } - (DDMInputView *)myInputView { if (!_myInputView) { _myInputView = [DDMInputView new]; _myInputView.delegate = self; _myInputView.hidden = YES; [self.view addSubview:_myInputView]; [_myInputView mas_makeConstraints:^(MASConstraintMaker *make) { make.left.right.bottom.mas_equalTo(self.view).mas_offset(0); make.height.mas_equalTo(KAdaptedHeight(40)+KSAFEAREA_BOTTOM_HEIHGHT); }]; } return _myInputView; } - (RoomPublicMessageView *)publicMessageView{ if (!_publicMessageView) { _publicMessageView = [[RoomPublicMessageView alloc] init]; _publicMessageView.backgroundColor = [UIColor clearColor]; _publicMessageView.dataArr = [[NSMutableArray alloc] init]; [self.view addSubview:_publicMessageView]; [_publicMessageView mas_makeConstraints:^(MASConstraintMaker *make) { make.left.mas_equalTo(self.view).mas_offset(0); make.right.mas_equalTo(self.view).mas_offset(-100); make.top.mas_equalTo(self.userMicroView.mas_bottom).mas_offset(20); make.bottom.mas_equalTo(self.toolView.mas_top).mas_offset(0); }]; WeakSelf(ws); _publicMessageView.cellTapGesActionBlock = ^(RoomUserInfoModel * _Nonnull userModel) { [ws popUserInfoViewToUserID:userModel.user_id roomID:ws.roomID curentVC:ws]; }; } return _publicMessageView; } - (void)showOnlineUserListView{ self.onlineUserListView.roomInfoModel =self.roomInfoModel; WeakSelf(ws); [UIView animateWithDuration:0.5 animations:^{ ws.onlineUserListView.frame = CGRectMake(0, 0, kWidth, kHeight); } completion:^(BOOL finished) { }]; } - (RoomRightOnLineUserListView *)onlineUserListView{ if (!_onlineUserListView) { _onlineUserListView = [[RoomRightOnLineUserListView alloc] initWithFrame:CGRectMake(kWidth, 0, kWidth, kHeight)]; _onlineUserListView.backgroundColor = [UIColor clearColor]; _onlineUserListView.roomID = self.roomID; [self.view addSubview:_onlineUserListView]; WeakSelf(ws); _onlineUserListView.disMissBlock = ^{ [UIView animateWithDuration:0.5 animations:^{ ws.onlineUserListView.frame = CGRectMake(kWidth, 0, kWidth, kHeight); } completion:^(BOOL finished) { }]; }; _onlineUserListView.backSetUserBlock = ^(RoomUserInfoModel * _Nonnull model, BOOL isSet) { if(isSet){ //设置某个用户 [ws showMicroManageView:model]; }else{ [ws popUserInfoViewToUserID:model.user_id roomID:ws.roomID curentVC:ws]; } }; _onlineUserListView.backGoBlackBlock = ^{ [RoomPopTool popRoomBlacklistViewToRoomInfoModel:ws.roomInfoModel roomID:ws.roomID curentVC:ws goInfo:^(RoomUserInfoModel * _Nonnull userModel) { [ws popUserInfoViewToUserID:userModel.user_id roomID:ws.roomID curentVC:ws]; }]; }; } return _onlineUserListView; } - (RoomAirPlaneView *)airPlaneView { if (!_airPlaneView) { _airPlaneView = [[RoomAirPlaneView alloc]initWithFrame:CGRectMake(kWidth, KSTATUSRECT.size.height + 60, kWidth, 80.0/375.0*kWidth)]; _airPlaneView.room_id = self.roomID; _airPlaneView.userInteractionEnabled = YES; WeakSelf(ws); _airPlaneView.jumpRoomBlock = ^(NSString * _Nonnull room_id) { if ([room_id isEqualToString:ws.roomID]) { return; } [[ToolsObject shareTools] jumpToRoomVC:room_id followUser:[RoomUserInfoModel new]]; }; _airPlaneView.backPushUserInfoVBlock = ^(NSString * _Nonnull user_id) { dispatch_async(dispatch_get_main_queue(), ^{ [ws popUserInfoViewToUserID:user_id roomID:ws.roomID curentVC:ws]; }); }; _airPlaneView.backPushWebBlock = ^(DDBannerModel * _Nonnull model) { ws.roomInfoModel.isReloadUpMicAlert = YES; dispatch_async(dispatch_get_main_queue(), ^{ if ([model.title isEqualToString:@"怦然星动"]) { }else if ([model.screen integerValue] == 0) { [ws addWebVcViewWithModel:model data:@{@"room_id":ws.roomID}]; }else{ DDWebViewController*webVC =[DDWebViewController webControlerWithUrlStr:model.param isShowNavBar:YES isHalf:NO data:@{@"room_id":ws.roomID}]; [ws.navigationController pushViewController:webVC animated:NO]; } }); }; } return _airPlaneView; } - (RoomLevelPlaneView *)levelPlaneView{ if (!_levelPlaneView) { _levelPlaneView = [[RoomLevelPlaneView alloc] initWithFrame:CGRectMake(kWidth, KSTATUSRECT.size.height + 90, kWidth, 80.0/375.0*kWidth)]; WeakSelf(ws); _levelPlaneView.understandNobleClickBlock = ^(NSString * _Nonnull nobility_name) { DDNobleHomeViewController *vc = [[DDNobleHomeViewController alloc]init]; vc.hidesBottomBarWhenPushed = YES; [ws.navigationController pushViewController:vc animated:YES]; }; }return _levelPlaneView; } - (RoomInfoModel *)roomInfoModel{ if (!_roomInfoModel) { _roomInfoModel = [[RoomInfoModel alloc] init]; }return _roomInfoModel; } - (SVGAPlayer *)svgaPlayer { if (!_svgaPlayer) { _svgaPlayer = [[SVGAPlayer alloc] init]; _svgaPlayer.delegate = self; _svgaPlayer.frame = CGRectMake(0, 0 , kWidth, kHeight); _svgaPlayer.loops = 1; _svgaPlayer.clearsAfterStop = YES; _svgaPlayer.userInteractionEnabled = NO; _svgaPlayer.contentMode = UIViewContentModeScaleAspectFill; } return _svgaPlayer; } - (SVGAPlayer *)inRoomSvgaPlayer { if (!_inRoomSvgaPlayer) { _inRoomSvgaPlayer = [[SVGAPlayer alloc] init]; _inRoomSvgaPlayer.delegate = self; _inRoomSvgaPlayer.frame = CGRectMake(0, 0 , kWidth, kHeight); _inRoomSvgaPlayer.loops = 1; _inRoomSvgaPlayer.clearsAfterStop = YES; _inRoomSvgaPlayer.userInteractionEnabled = NO; _inRoomSvgaPlayer.contentMode = UIViewContentModeScaleAspectFill; } return _inRoomSvgaPlayer; } - (NSMutableArray*)timeArray{ if (!_timeArray) { _timeArray = [[NSMutableArray alloc] init]; [_timeArray addObject:@"1分钟"]; [_timeArray addObject:@"5分钟"]; [_timeArray addObject:@"10分钟"]; [_timeArray addObject:@"1小时"]; [_timeArray addObject:@"3小时"]; } return _timeArray; } - (NSMutableArray *)airplaneArray { if (!_airplaneArray) { _airplaneArray = [NSMutableArray array]; } return _airplaneArray; } - (NSMutableArray *)levelUpAirplaneArray { if (!_levelUpAirplaneArray) { _levelUpAirplaneArray = [NSMutableArray array]; } return _levelUpAirplaneArray; } - (UIButton *)popBgButton { if(!_popBgButton){ _popBgButton = [UIButton buttonWithType:UIButtonTypeCustom]; _popBgButton.frame = self.view.frame; _popBgButton.hidden = YES; _popBgButton.backgroundColor = [[UIColor blackColor]colorWithAlphaComponent:0.3]; [_popBgButton addTarget:self action:@selector(popButtonClick) forControlEvents:UIControlEventTouchUpInside]; [self.view addSubview:_popBgButton]; } return _popBgButton; } @end