// // YOUPAILZChatRoomVC.m // VQU // // Created by CY on 2021/10/25. // Copyright © 2021 MS. All rights reserved. // #import "YOUPAILZChatRoomVC.h" #import "UIViewController+TFPresent.h" #import "YOUPAILZChatRoomReloadSeatAttachment.h" #import "YOUPAILZChatRoomInviactionUpSeatAttachment.h" #import "YOUPAILZChatRoomApplySeatAttachment.h" #import "LZAlertWindow.h" #import "YOUPAILCIMSessionVC.h" #import "YOUPAILZChatRoomInviationUpSeatListWindow.h" #import "YOUPAILZChatRoomSeatInlineWindow.h" #import "YOUPAILZChatRoomUpSeatApplyWindow.h" #import "YOUPAILZChatRoomSelectedSeatWindow.h" #import "YOUPAILZLiveRankAttachment.h" #import "YOUPAILZLiveVipBarrageAttachment.h" #import "YOUPAILZLiveCarAttachment.h" #import #import #import "UIView+YOUPAIRCDDanmaku.h" #import "YOUPAIRCDDanmaku.h" #import "YOUPAIRCDDanmakuManager.h" #import "YOUPAILZLiveBarrageTool.h" #import "NIMMessageMaker.h" #import "YOUPAILZChatRoomModeUpdateAttrchment.h" #import "YOUPAILZChatRoomEmptyChatAttachment.h" #import "YOUPAILZChatRoomCloseOpenChatAttachment.h" #import "YOUPAILZChatRoomInfoEditNoticeAttachment.h" #import "YOUPAILZChatRoomInfoEditTitleAttachment.h" #import "YOUPAILZChatRoomInfoEditPasswordAttachment.h" #import "YOUPAILZLiveManageAttachment.h" #import "YOUPAILZChatRoomEmojiAttachment.h" #import "YOUPAILZChatRoomGiftAttachment.h" #import "YOUPAILZChatRoomEndAttachment.h" #import "YOUPAILZGuardAttachment.h" #import "YOUPAILZChatRoomTransferPlayAttachment.h" #import "YOUPAILZChatRoomBlindDateProgressChangeAttachment.h" #import "YOUPAILZChatRoomBlindDateSelectedAttrchment.h" #import "YOUPAILZChatRoomBlindDateAnimationAttachment.h" #import "YOUPAILZChatRoomUpdatePowerAttachment.h" #import "YOUPAILZChatRoomGiftView.h" #import "YOUPAILZChatRoomBlindDataAnimationView.h" #import "YOUPAILZChatRoomBgImgAttachment.h" #import "YOUPAILZChatRoomCurrentMenberVC.h" //#import "LZChatRoomEmojiView.h" @interface YOUPAILZChatRoomVC () @property (nonatomic, strong) NSDate *youpaipjoinLiveMessageDate; /// 直播间加入消息时间 @property (nonatomic, strong) YOUPAILZLiveCarAttachment *youpaipcarAttachment; // 直播间座驾动画 @property (nonatomic, strong) SVGAPlayer *youpaipcarSvgaPlayer; @property (nonatomic, strong) SVGAParser *youpaipcarParser; @property (nonatomic, assign) BOOL youpaipisPlayCarSvga; @property (nonatomic, strong) NSMutableArray *youpaipgifts; // 礼物数据 @property (nonatomic, strong) NSMutableArray * youpaipgiftViews;// 礼物 @property (nonatomic, strong) NSMutableArray *youpaipsvgas; /// svga礼物数据 @property (nonatomic, strong) SVGAPlayer *youpaipsvgaPlayer; @property (nonatomic, strong) SVGAParser *youpaipparser; @property (nonatomic, assign) BOOL youpaipisPlaySvga; @property (nonatomic, assign) BOOL youpaipisBlindDataAnimation; /// 相亲动画 @property (nonatomic, weak) YOUPAILZChatRoomBlindDataAnimationView *youpaipblindDataAnimationView; @end @implementation YOUPAILZChatRoomVC - (void)viewDidDisappear:(BOOL)animated{ [super viewDidDisappear:animated]; [self.view youpaifstopDanmaku]; } - (void)viewDidLoad { [super viewDidLoad]; self.view.clipsToBounds = YES; [self youpaifinitializeValue]; [self youpaifinitSvga]; [self youpaifjoinChatRoom]; [self youpaifhandleAgoraEvent]; [self youpaifinitBlindDataAnimationView]; } /// 初始值 - (void)youpaifinitializeValue{ } /// svga init - (void)youpaifinitSvga{ self.youpaipcarSvgaPlayer = [[SVGAPlayer alloc] initWithFrame:[UIScreen mainScreen].bounds]; self.youpaipcarSvgaPlayer.contentMode = UIViewContentModeScaleAspectFit; self.youpaipcarSvgaPlayer.delegate = self; [self.view addSubview:self.youpaipcarSvgaPlayer]; self.youpaipcarSvgaPlayer.hidden = YES; self.youpaipcarSvgaPlayer.loops = 1; self.youpaipcarSvgaPlayer.clearsAfterStop = true; self.youpaipcarParser = [[SVGAParser alloc] init]; self.youpaipcarSvgaPlayer.userInteractionEnabled = NO; self.youpaipsvgaPlayer = [[SVGAPlayer alloc] initWithFrame:[UIScreen mainScreen].bounds]; self.youpaipsvgaPlayer.contentMode = UIViewContentModeScaleAspectFit; self.youpaipsvgaPlayer.delegate = self; [self.view addSubview:self.youpaipsvgaPlayer]; self.youpaipsvgaPlayer.hidden = YES; self.youpaipsvgaPlayer.loops = 1; self.youpaipsvgaPlayer.clearsAfterStop = true; self.youpaipparser = [[SVGAParser alloc] init]; self.youpaipsvgaPlayer.userInteractionEnabled = NO; } - (void)youpaifinitBlindDataAnimationView{ YOUPAILZChatRoomBlindDataAnimationView *youpaipblindDataAnimationView = [[YOUPAILZChatRoomBlindDataAnimationView alloc] initWithFrame:self.view.bounds]; youpaipblindDataAnimationView.hidden = YES; youpaipblindDataAnimationView.userInteractionEnabled = NO; [self.view addSubview:youpaipblindDataAnimationView]; self.youpaipblindDataAnimationView = youpaipblindDataAnimationView; @weakify(self); [youpaipblindDataAnimationView setAnimationFinishBlock:^{ @strongify(self); self.youpaipisBlindDataAnimation = NO; self.youpaipblindDataAnimationView.hidden = YES; }]; } /// 处理回调 - (void)youpaifhandleAgoraEvent{ @weakify(self); // 获取瞬时说话音量最高的几个用户(即说话者)的用户 ID、他们的音量及本地用户是否在说话。 // speakers 为一个数组,包含说话者的用户 ID 、音量及本地用户人声状态。音量的取值范围为 [0, 255]。 // totalVolume 指混音后频道内的总音量,取值范围为 [0, 255]。 [[YOUPAILZChatRoomManager shareManager] setReportAudioVolumeIndicationOfSpeakersBlock:^(AgoraRtcEngineKit * _Nonnull engine, NSArray * _Nonnull speakers, NSInteger totalVolume) { @strongify(self); dispatch_async(dispatch_get_global_queue(0, 0), ^{ @strongify(self); if (speakers.count == 0) { for (NSInteger i = 0; i < self.youpaipchatroomModel.youpaipnormalSeats.count + 1; i ++) { YOUPAILZChatRoomSeatModel *seatModel; if (i >= self.youpaipchatroomModel.youpaipnormalSeats.count) { seatModel = self.youpaipchatroomModel.youpaiphostSeat; }else{ seatModel = self.youpaipchatroomModel.youpaipnormalSeats[i]; } if (![seatModel.youpaipuserInfo.youpaipid isEqual:self.youpaipchatroomModel.youpaipuserInfo.youpaipid]) { seatModel.youpaipisTalking = NO; } } }else{ for (NSInteger i = 0; i < speakers.count; i ++) { AgoraRtcAudioVolumeInfo *info = speakers[i]; if (info.uid == 0) { self.youpaiplocalSeatModel.youpaipisTalking = info.vad == 1; }else{ for (NSInteger i = 0; i < self.youpaipchatroomModel.youpaipnormalSeats.count + 1; i ++) { YOUPAILZChatRoomSeatModel *seatModel; if (i >= self.youpaipchatroomModel.youpaipnormalSeats.count) { seatModel = self.youpaipchatroomModel.youpaiphostSeat; }else{ seatModel = self.youpaipchatroomModel.youpaipnormalSeats[i]; } if ([[NSString stringWithFormat:@"%@",@(info.uid)] isEqual:seatModel.youpaipuserInfo.youpaipid]) { seatModel.youpaipisTalking = YES; } } } } } //通知主线程刷新 dispatch_async(dispatch_get_main_queue(), ^{ @strongify(self); [self youpaifreloadSeats]; }); }); }]; /// 收到消息回调 [[YOUPAILZChatRoomManager shareManager] setOnRecvMessagesBlock:^(NSArray * _Nonnull messages) { @strongify(self); /// 新消息处理 NIMMessage *message = messages.firstObject; NIMSession *session = message.session; if (![session.sessionId isEqual:self.youpaipchatroomModel.youpaiproom_id] || !messages.count){ return; } [self youpaifuiAddMessages:messages]; }]; /// 发送消息完成回调 [[YOUPAILZChatRoomManager shareManager] setSendMessageSuccessBlock:^(NIMMessage * _Nonnull message, NSError * _Nonnull error) { @strongify(self); if (error == nil) { [self youpaifuiAddMessages:@[message]]; }else if(error.code == 13004){ [ZCHUDHelper showTitle:@"您已被禁言,不能发送消息"]; } }]; /// 房间前三点击回调 [self.youpaipchatroomMemberView setYoupaipmemberAvatarBtnClickBlock:^(NSString * _Nonnull user_id) { @strongify(self); [self.youpaipkeyboardView resignFirstResponder]; self.youpaipkeyboardView.hidden = YES; [self youpaifhandleUserOperationWithUserId:user_id]; }]; /// 房间人数点击回调 [self.youpaipchatroomMemberView setYoupaipmemberCountBtnClickBlock:^{ @strongify(self); [self.youpaipkeyboardView resignFirstResponder]; self.youpaipkeyboardView.hidden = YES; YOUPAILZChatRoomCurrentMenberVC *window = [[YOUPAILZChatRoomCurrentMenberVC alloc] init]; window.youpaipchatroomModel = self.youpaipchatroomModel; window.isTouchDismiss = YES; [window setYoupaipupseatBlock:^(YOUPAILZChatRoomMemberModel * _Nonnull model) { @strongify(self); [self youpaifshowSelectedSeatWindowWithUserId:model.youpaipid youpaipisInviation:YES]; }]; [window setYoupaiptouchUserBlock:^(NSString * _Nonnull userId) { @strongify(self); [self youpaifshowUserInfoWithUserId:userId]; }]; [self TFPresentVC:window completion:^{}]; }]; } /// 加入房间 - (void)youpaifjoinChatRoom{ @weakify(self); [[YOUPAILZChatRoomManager shareManager] youpaifjoinChannelById:self.youpaipchatroomModel.youpaiproom_id uid:[self.youpaipchatroomModel.youpaipuserInfo.youpaipid integerValue]]; [[YOUPAILZChatRoomManager shareManager] youpaifjoinChatRoomById:self.youpaipchatroomModel.youpaiproom_id isComeinRoomHide:self.youpaipchatroomModel.youpaipis_comein_room_hide completion:^(NSError * _Nullable error, NIMChatroom * _Nullable chatroom, NIMChatroomMember * _Nullable me) { @strongify(self); [self youpaifreloadSeats]; if (self.youpaipchatroomModel.youpaipis_fly_car == 1) { self.youpaipcarAttachment = self.youpaipchatroomModel.youpaipcar_data; [self youpaifstartPlayCarSvga]; } if (self.youpaipchatroomModel.youpaipis_fly_noble == 1) { [self youpaifhandleVipBarrageAttachment:self.youpaipchatroomModel.youpaipb_box_data]; } [self youpaifuiAddMessages:@[[self youpaifaddNoticeMessage]]]; }]; } /// 添加公告消息 - (NIMMessage *)youpaifaddNoticeMessage{ NIMMessage *imMessage = [NIMMessageMaker msgWithText:self.youpaipchatroomModel.youpaipnotice_text]; return imMessage; } /// UI添加消息 - (void)youpaifuiAddMessages:(NSArray *)messages{ NSArray *newMessages = [self youpaifdealMessage:messages]; if (newMessages.count != 0) { [self.youpaipmessages insertObjects:newMessages atIndexes:[NSIndexSet indexSetWithIndexesInRange:NSMakeRange(0, newMessages.count)]]; // [self.messages addObjectsFromArray:newMessages]; NIMMessage *joinLiveMessage = nil; for (NSInteger i = 0; i < self.youpaipmessages.count; i ++) { NIMMessage *msg = self.youpaipmessages[i]; if ([msg isKindOfClass:[NIMMessage class]]) { if (msg.session.sessionType == NIMSessionTypeChatroom && msg.messageType == NIMMessageTypeNotification){ /// 如果是聊天室并且消息类型为通知类型 NIMNotificationObject *object = msg.messageObject; if (![object.content isKindOfClass:[NIMUnsupportedNotificationContent class]]) { NIMChatroomNotificationContent *content = (NIMChatroomNotificationContent *)object.content; if (content.eventType == NIMChatroomEventTypeEnter) { /// 有成员加入聊天室 if (joinLiveMessage == nil) { joinLiveMessage = msg; } [self.youpaipmessages removeObject:msg]; i --; } } } } } if (joinLiveMessage != nil) { [self.youpaipmessages insertObject:joinLiveMessage atIndex:0]; // [self.messages addObject:joinLiveMessage]; NSTimeInterval timeBetween = [[NSDate new] timeIntervalSinceDate:self.youpaipjoinLiveMessageDate]; if (timeBetween >= 3.0f) { [self.youpaipmessages removeObject:joinLiveMessage]; } // else{ // [self performSelector:@selector(removeJoinLiveMessage:) withObject:joinLiveMessage afterDelay:3.0]; // } } [self youpaifreloadTableView]; } } - (void)youpaifreloadTableView{ [self.youpaipmessageTableView reloadData]; if (self.youpaipmessages.count != 0) { [self.youpaipmessageTableView scrollToRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:0] atScrollPosition:UITableViewScrollPositionBottom animated:YES]; } } /// 聊天室消息处理 - (NSArray *)youpaifdealMessage:(NSArray *)messages{ NSMutableArray *n_messages = [NSMutableArray array]; /// 聊天室通知处理 for (NIMMessage *message in messages) { if (message.from != nil) { [[[NIMSDK sharedSDK] userManager] fetchUserInfos:@[message.from] completion:^(NSArray * _Nullable users, NSError * _Nullable error) { // NIMUser* user = users[0]; }]; } if (message.session.sessionType == NIMSessionTypeChatroom && message.messageType == NIMMessageTypeNotification){ /// 如果是聊天室并且消息类型为通知类型 NIMNotificationObject *object = message.messageObject; if (![object.content isKindOfClass:[NIMUnsupportedNotificationContent class]]) { NIMChatroomNotificationContent *content = (NIMChatroomNotificationContent *)object.content; NSString *fromId = nil; for (NIMChatroomNotificationMember *memebr in content.targets) { fromId = memebr.userId; } if (content.eventType == NIMChatroomEventTypeEnter) { /// 有成员加入聊天室 // if (![message.from isEqual:self.youpaipchatroomModel.userInfo.id]) { NSData *jsonData = [content.notifyExt dataUsingEncoding:NSUTF8StringEncoding]; if (jsonData != nil) { NSError *err; NSDictionary *dic = [NSJSONSerialization JSONObjectWithData:jsonData options:NSJSONReadingMutableContainers error:&err]; if (!([dic.allKeys containsObject:@"is_comein_room_hide"] && [[dic objectForKey:@"is_comein_room_hide"] integerValue] == 1)) { [n_messages insertObject:message atIndex:0]; self.youpaipjoinLiveMessageDate = [NSDate new]; } } // } [self youpaifuploadChatRoomMemberCount]; }else if(content.eventType == NIMChatroomEventTypeExit){ /// 有成员离开聊天室 [self youpaifuploadChatRoomMemberCount]; } else if(content.eventType == NIMChatroomEventTypeKicked){ /// 聊天室成员被踢 [self youpaifuploadChatRoomMemberCount]; }else if (content.eventType == NIMChatroomEventTypeAddMute){ // 成员被禁言 if ([fromId isEqual:self.youpaipchatroomModel.youpaipuserInfo.youpaipid]) { [ZCHUDHelper showTitle:@"你被禁言"]; } }else if (content.eventType == NIMChatroomEventTypeRemoveMute){ // 成员被取消禁言 if ([fromId isEqual:self.youpaipchatroomModel.youpaipuserInfo.youpaipid]) { [ZCHUDHelper showTitle:@"你被取消禁言"]; } }else if (content.eventType == NIMChatroomEventTypeAddMuteTemporarily){ // 聊天室成员被临时禁言 if ([fromId isEqual:self.youpaipchatroomModel.youpaipuserInfo.youpaipid]) { [ZCHUDHelper showTitle:@"你被禁言"]; } }else if (content.eventType == NIMChatroomEventTypeRemoveMuteTemporarily){ // 聊天室成员被解除临时禁言 if ([fromId isEqual:self.youpaipchatroomModel.youpaipuserInfo.youpaipid]) { [ZCHUDHelper showTitle:@"你被取消禁言"]; } } // }else if (content.eventType == NIMChatroomEventTypeAddManager){ // 设置为管理员 // [n_messages insertObject:message atIndex:0]; // [[YOUPAILZLiveManagerListUtils shared] youpaifreloadManagerListWithLiveId:self.liveModel.live_id]; // if ([fromId isEqual:[LCSaveModel getUserModel].userinfo.user_id]) { // [ZCHUDHelper showTitle:@"你被设置为管理员"]; // } // }else if (content.eventType == NIMChatroomEventTypeRemoveManager){ // 移除管理员 // [n_messages insertObject:message atIndex:0]; // [[YOUPAILZLiveManagerListUtils shared] youpaifreloadManagerListWithLiveId:self.liveModel.live_id]; // if ([fromId isEqual:[LCSaveModel getUserModel].userinfo.user_id]) { // [ZCHUDHelper showTitle:@"你被取消设置为管理员"]; // } // } } }else if (message.messageType == NIMMessageTypeText){ // 文本消息 [n_messages insertObject:message atIndex:0]; }else if(message.messageType == NIMMessageTypeCustom){ // 自定义消息 NIMCustomObject *object = (NIMCustomObject*)message.messageObject; if ([object.attachment isKindOfClass:[YOUPAILZChatRoomReloadSeatAttachment class]]) { // 更新语聊房座位 YOUPAILZChatRoomReloadSeatAttachment *attachment = (YOUPAILZChatRoomReloadSeatAttachment *)object.attachment; // 主持位 YOUPAILZChatRoomSeatModel *hostSeatModel = [YOUPAILZChatRoomSeatModel mj_objectWithKeyValues:attachment.host]; if ([hostSeatModel.youpaipuserInfo.youpaipid isEqual:self.youpaipchatroomModel.youpaiphostSeat.youpaipuserInfo.youpaipid]) { hostSeatModel.youpaipisEmoji = self.youpaipchatroomModel.youpaiphostSeat.youpaipisEmoji; hostSeatModel.youpaipemojiImg = self.youpaipchatroomModel.youpaiphostSeat.youpaipemojiImg; } self.youpaipchatroomModel.youpaiphostSeat = hostSeatModel; // 其他座位 NSMutableArray *normalSeatModels = [YOUPAILZChatRoomSeatModel mj_objectArrayWithKeyValuesArray:attachment.normal]; for (NSInteger i = 0; i < normalSeatModels.count; i ++) { YOUPAILZChatRoomSeatModel *oldSeatModel = self.youpaipchatroomModel.youpaipnormalSeats[i]; YOUPAILZChatRoomSeatModel *newSeatModel = normalSeatModels[i]; if ([oldSeatModel.youpaipuserInfo.youpaipid isEqual:newSeatModel.youpaipuserInfo.youpaipid]) { newSeatModel.youpaipisEmoji = oldSeatModel.youpaipisEmoji; newSeatModel.youpaipemojiImg = oldSeatModel.youpaipemojiImg; } } self.youpaipchatroomModel.youpaipnormalSeats = normalSeatModels; [self youpaifreloadSeats]; } if ([object.attachment isKindOfClass:[YOUPAILZChatRoomInviactionUpSeatAttachment class]]) { // 邀请上麦 YOUPAILZChatRoomInviactionUpSeatAttachment *attachment = (YOUPAILZChatRoomInviactionUpSeatAttachment *)object.attachment; [self youpaifinviactionUpSeatAlertWithAttachment:attachment]; } if ([object.attachment isKindOfClass:[YOUPAILZChatRoomApplySeatAttachment class]]) { // 上麦申请 我要上麦 排麦中 YOUPAILZChatRoomApplySeatAttachment *attachment = (YOUPAILZChatRoomApplySeatAttachment *)object.attachment; [self youpaifreloadApplySeatButtonWithAttachment:attachment]; } if ([object.attachment isKindOfClass:[YOUPAILZChatRoomModeUpdateAttrchment class]]) { // 房间麦位模式 YOUPAILZChatRoomModeUpdateAttrchment *attachment = (YOUPAILZChatRoomModeUpdateAttrchment *)object.attachment; self.youpaipchatroomModel.youpaiptalk_type = attachment.changeData[@"talk_type"]; self.youpaipchatroomModel.youpaipsay_count = attachment.changeData[@"say_count"]; self.youpaipapplySeatButton.youpaipmemberCount = [self.youpaipchatroomModel.youpaipsay_count integerValue]; if (self.youpaipchatroomModel.youpaipuserInfo.youpaifroleType == LZUserRoleTypeWithNormal) { [self.youpaipapplySeatButton youpaifrleoadWithType:LZChatRoomApplySeatTypeWithUpSeat playType:self.youpaipchatroomModel.youpaipplayType]; } if (self.youpaipchatroomModel.youpaipchatroomType == LZChatRoomTypeWithFree) { self.youpaipapplySeatButton.hidden = YES; }else{ if (self.youpaipisCurrentUserUpSeat && self.youpaipchatroomModel.youpaipuserInfo.youpaifroleType == LZUserRoleTypeWithNormal) { self.youpaipapplySeatButton.hidden = YES; }else{ self.youpaipapplySeatButton.hidden = NO; } } self.youpaipmoreModel.youpaipisSeatFree = self.youpaipchatroomModel.youpaipchatroomType == LZChatRoomTypeWithFree; [self.youpaipmoreWindow youpaifreloadData]; } if ([object.attachment isKindOfClass:[YOUPAILZChatRoomEmptyChatAttachment class]]) { // 清空公屏 YOUPAILZChatRoomEmptyChatAttachment *attachment = (YOUPAILZChatRoomEmptyChatAttachment *)object.attachment; [self.youpaipmessages removeAllObjects]; [self youpaifuiAddMessages:@[[self youpaifaddEmptyChatMessage]]]; } if ([object.attachment isKindOfClass:[YOUPAILZChatRoomCloseOpenChatAttachment class]]) { // 公屏开启or关闭 YOUPAILZChatRoomCloseOpenChatAttachment *attachment = (YOUPAILZChatRoomCloseOpenChatAttachment *)object.attachment; self.youpaipchatroomModel.youpaiptalk_mute = [attachment.changeData[@"mute_status"] integerValue]; self.youpaipmoreModel.youpaipisCloseChatMessage = self.youpaipchatroomModel.youpaiptalk_mute != 0; //是否关闭公屏 [self.youpaipmoreWindow youpaifreloadData]; if([attachment.change_type isEqual:@"remove_whole_forbid_words"]){ [self youpaifuiAddMessages:@[[self youpaifaddOpenChatroomChat]]]; }else{ [self youpaifuiAddMessages:@[[self youpaifaddCloseChatroomChat]]]; } } if ([object.attachment isKindOfClass:[YOUPAILZChatRoomInfoEditNoticeAttachment class]]) { // 房间信息公告修改 YOUPAILZChatRoomInfoEditNoticeAttachment *attachment = (YOUPAILZChatRoomInfoEditNoticeAttachment *)object.attachment; self.youpaipchatroomModel.youpaiptalk_notice = attachment.changeData[@"notice"]; } if ([object.attachment isKindOfClass:[YOUPAILZChatRoomInfoEditTitleAttachment class]]) { // 房间信息标题修改 YOUPAILZChatRoomInfoEditTitleAttachment *attachment = (YOUPAILZChatRoomInfoEditTitleAttachment *)object.attachment; self.youpaipchatroomModel.youpaiproom_title = attachment.changeData[@"title"]; self.youpaipchatroomInfoView.youpaiptitleL.text = self.youpaipchatroomModel.youpaiproom_title; // if (self.youpaipchatroomModel.room_title.length > 3) { // [self.youpaipchatroomInfoView.titleL marqueeOfSettingWithState:MarqueeStart_H]; // }else{ // [self.youpaipchatroomInfoView.titleL marqueeOfSettingWithState:MarqueeShutDown_H]; // } } if ([object.attachment isKindOfClass:[YOUPAILZChatRoomInfoEditPasswordAttachment class]]) { // 房间信息密码修改 YOUPAILZChatRoomInfoEditPasswordAttachment *attachment = (YOUPAILZChatRoomInfoEditPasswordAttachment *)object.attachment; self.youpaipchatroomModel.youpaiptalk_pwd = [attachment.changeData[@"is_pwd"] integerValue]; self.youpaipmoreModel.youpaipisLock = self.youpaipchatroomModel.youpaiptalk_pwd == 1; [self.youpaipmoreWindow youpaifreloadData]; } if ([object.attachment isKindOfClass:[YOUPAILZLiveManageAttachment class]]) { //移出房间 YOUPAILZLiveManageAttachment *attachment = (YOUPAILZLiveManageAttachment*)object.attachment; if ([self.youpaipchatroomModel.youpaipuserInfo.youpaipid isEqual:attachment.forbidden_uid]) { self.youpaipisClose = YES; [ZCHUDHelper showTitle:attachment.user_des]; [[YOUPAILZChatRoomManager shareManager] youpaifcloseChatRoom]; } } if ([object.attachment isKindOfClass:[YOUPAILZChatRoomEndAttachment class]]) { //解散房间 self.youpaipisClose = YES; [ZCHUDHelper showTitle:@"房间已被关闭"]; [[YOUPAILZChatRoomManager shareManager] youpaifcloseChatRoom]; } if ([object.attachment isKindOfClass:[YOUPAILZChatRoomEmojiAttachment class]]) { // 互动表情 YOUPAILZChatRoomEmojiAttachment *attachment = (YOUPAILZChatRoomEmojiAttachment *)object.attachment; [self youpaifhandleEmojiWithAttachment:attachment]; } if ([object.attachment isKindOfClass:[YOUPAILZChatRoomGiftAttachment class]]){ // 礼物 YOUPAILZChatRoomGiftAttachment *attachment = (YOUPAILZChatRoomGiftAttachment *)object.attachment; for (NSInteger i = 0; i < attachment.receiveInfo.count; i ++) { NSDictionary *dict = attachment.receiveInfo[i]; YOUPAILZLiveGIftModel *giftModel = [[YOUPAILZLiveGIftModel alloc] init]; giftModel.youpaipavatar = attachment.from_avatar; giftModel.youpaipnickName = attachment.from_nickname; giftModel.youpaipgiftImage = attachment.gift_url; giftModel.youpaipgiftCount = attachment.gift_count; giftModel.youpaipuser_id = attachment.from_uid; giftModel.youpaipgift_id = attachment.gift_id; giftModel.youpaipgift_svga = attachment.gift_svga; giftModel.youpaipgift_type = attachment.gift_type; giftModel.youpaipto_uid = [[dict objectForKey:@"user_id"] integerValue]; giftModel.youpaipto_nickName= [dict objectForKey:@"nickname"]; if ([self.youpaipchatroomModel.youpaipuserInfo.youpaipid isEqual:message.from]) { [self.youpaipgifts insertObject:giftModel atIndex:0]; }else{ [self.youpaipgifts addObject:giftModel]; } if (i == 0) { if (giftModel.youpaipgift_type == 1 && ![giftModel.youpaipgift_svga isEqualToString:@""]) { [self.youpaipsvgas addObject:giftModel]; [self youpaifstartPlaySvga]; } } YOUPAILZChatRoomGiftAttachment *gift_attachment = [[YOUPAILZChatRoomGiftAttachment alloc] init]; gift_attachment.gift_id = attachment.gift_id; gift_attachment.gift_name = attachment.gift_name; gift_attachment.gift_count = attachment.gift_count; gift_attachment.gift_url = attachment.gift_url; gift_attachment.from_uid = attachment.from_uid; gift_attachment.to_uid = giftModel.youpaipto_uid; gift_attachment.to_nickname = giftModel.youpaipto_nickName; gift_attachment.roomid = attachment.roomid; gift_attachment.link_type = attachment.link_type; gift_attachment.link_url = attachment.link_url; gift_attachment.md5_string = attachment.md5_string; gift_attachment.gift_svga = attachment.gift_svga; gift_attachment.gift_type = attachment.gift_type; gift_attachment.from_nickname = attachment.from_nickname; gift_attachment.from_avatar = attachment.from_avatar; gift_attachment.send_gift_hide = attachment.send_gift_hide; gift_attachment.receiveInfo = attachment.receiveInfo; [n_messages insertObject:gift_attachment atIndex:0]; } [self youpaifeditGiftView]; } if ([object.attachment isKindOfClass:[YOUPAILZGuardAttachment class]]){ // 守护 YOUPAILZGuardAttachment *attachment = (YOUPAILZGuardAttachment *)object.attachment; YOUPAILZChatRoomGiftAttachment *gift_attachment = [[YOUPAILZChatRoomGiftAttachment alloc] init]; gift_attachment.gift_id = -1; gift_attachment.gift_name = attachment.guard_name; gift_attachment.gift_count = attachment.guard_count; gift_attachment.gift_url = attachment.guard_url; gift_attachment.from_uid = attachment.from_uid; gift_attachment.to_uid = attachment.to_uid; gift_attachment.to_nickname = attachment.to_nickname; gift_attachment.roomid = attachment.roomid; gift_attachment.link_type = attachment.link_type; gift_attachment.link_url = attachment.link_url; gift_attachment.md5_string = attachment.md5_string; gift_attachment.gift_svga = attachment.gift_svga; gift_attachment.gift_type = attachment.gift_type; gift_attachment.from_nickname = attachment.from_nickname; gift_attachment.from_avatar = attachment.from_avatar; gift_attachment.send_gift_hide = 0; [n_messages insertObject:gift_attachment atIndex:0]; YOUPAILZLiveGIftModel *giftModel = [[YOUPAILZLiveGIftModel alloc] init]; giftModel.youpaipavatar = attachment.from_avatar; giftModel.youpaipnickName = attachment.from_nickname; giftModel.youpaipgiftImage = attachment.guard_url; giftModel.youpaipgiftCount = attachment.guard_count; giftModel.youpaipuser_id = attachment.from_uid; giftModel.youpaipgift_id = -1; giftModel.youpaipgift_svga = attachment.gift_svga; giftModel.youpaipgift_type = attachment.gift_type; giftModel.youpaipto_uid = attachment.to_uid; giftModel.youpaipto_nickName = attachment.to_nickname; [self.youpaipsvgas addObject:giftModel]; [self youpaifstartPlaySvga]; } if ([object.attachment isKindOfClass:[YOUPAILZLiveRankAttachment class]]) { //排行信息 YOUPAILZLiveRankAttachment *attachment = (YOUPAILZLiveRankAttachment*)object.attachment; self.youpaipchatroomModel.youpaiplive_top_three = [LZLiveTopThreeModel mj_objectArrayWithKeyValuesArray:attachment.rank]; [self.youpaipchatroomMemberView youpaifreloadWithMemberList:self.youpaipchatroomModel.youpaiplive_top_three]; } if ([object.attachment isKindOfClass:[YOUPAILZLiveVipBarrageAttachment class]]) { //VIP弹幕信息 if (![message.from isEqual:[LCSaveModel getUserModel].youpaipuserinfo.youpaipuser_id]) { YOUPAILZLiveVipBarrageAttachment *attachment = (YOUPAILZLiveVipBarrageAttachment*)object.attachment; [self youpaifhandleVipBarrageAttachment:attachment]; } } if ([object.attachment isKindOfClass:[YOUPAILZLiveCarAttachment class]]) { //座驾 YOUPAILZLiveCarAttachment *attachment = (YOUPAILZLiveCarAttachment*)object.attachment; self.youpaipcarAttachment = attachment; [self youpaifstartPlayCarSvga]; } if ([object.attachment isKindOfClass:[YOUPAILZChatRoomTransferPlayAttachment class]]) { /// 切换房间玩法 YOUPAILZChatRoomTransferPlayAttachment *attachment = (YOUPAILZChatRoomTransferPlayAttachment*)object.attachment; self.youpaipchatroomModel.youpaiptalk_played = attachment.type; self.youpaipchatroomModel.youpaiptalk_played_status = [YOUPAILZChatRoomTalkPlayedStatusModel mj_objectArrayWithKeyValuesArray:attachment.blind_status]; [self.youpaipmoreWindow youpaifreloadData]; [self youpaifreloadPlayTypeUI]; if (self.presentedViewController != nil) { NSArray *vcClas = @[NSClassFromString(@"YOUPAILZChatRoomSelectedSeatWindow"),NSClassFromString(@"YOUPAILZChatRoomUpSeatApplyWindow"),NSClassFromString(@"YOUPAILZBlindDateSelectWindow")]; if ([vcClas containsObject:self.presentedViewController.class]) { [self.presentedViewController dismissViewControllerAnimated:YES completion:^{}]; } } } if ([object.attachment isKindOfClass:[YOUPAILZChatRoomBlindDateProgressChangeAttachment class]]) { /// 相亲玩法进度更变 YOUPAILZChatRoomBlindDateProgressChangeAttachment *attachment = (YOUPAILZChatRoomBlindDateProgressChangeAttachment*)object.attachment; self.youpaipchatroomModel.youpaiptalk_played_status = [YOUPAILZChatRoomTalkPlayedStatusModel mj_objectArrayWithKeyValuesArray:attachment.blind_data_change]; [self youpaifsetupBlindDateProgressData]; } if ([object.attachment isKindOfClass:[YOUPAILZChatRoomBlindDateSelectedAttrchment class]]) { /// 选择相亲对象 if (self.youpaiplocalSeatModel != nil && ![self.youpaipchatroomModel.youpaiphostSeat.youpaipuserInfo.youpaipid isEqual:self.youpaipchatroomModel.youpaipuserInfo.youpaipid] ) { [self youpaifshowBlindDateSelectWindow]; } } if ([object.attachment isKindOfClass:[YOUPAILZChatRoomBlindDateAnimationAttachment class]]) { /// 相亲动画 YOUPAILZChatRoomBlindDateAnimationAttachment *attachment = (YOUPAILZChatRoomBlindDateAnimationAttachment*)object.attachment; if (attachment.select_data.count != 0) { self.youpaipsvgaPlayer.hidden = YES; self.youpaipisBlindDataAnimation = YES; self.youpaipblindDataAnimationView.hidden = NO; [self.youpaipblindDataAnimationView youpaifreloadWithModels:[YOUPAILZChatRoomBlindDataAnimationModel mj_objectArrayWithKeyValuesArray:attachment.select_data]]; } } if ([object.attachment isKindOfClass:[YOUPAILZChatRoomBgImgAttachment class]]) { /// 背景 YOUPAILZChatRoomBgImgAttachment *attachment = (YOUPAILZChatRoomBgImgAttachment*)object.attachment; self.youpaipchatroomModel.youpaipbg_img = attachment.bg; [self youpaifsetupBgImage]; } if ([object.attachment isKindOfClass:[YOUPAILZChatRoomUpdatePowerAttachment class]]) { /// 修改权限 YOUPAILZChatRoomUpdatePowerAttachment *attachment = (YOUPAILZChatRoomUpdatePowerAttachment*)object.attachment; if ([attachment.uid isEqual:self.youpaipchatroomModel.youpaipuserInfo.youpaipid]) { self.youpaipchatroomModel.youpaipuserInfo.youpaipidentity = attachment.identity; } if ([[YOUPAILZChatRoomManager shareManager].chatroomModel.youpaipmanagers.allKeys containsObject:attachment.uid]) { NSMutableDictionary *managerListDict = [YOUPAILZChatRoomManager shareManager].chatroomModel.youpaipmanagers.mutableCopy; NSMutableDictionary *managerDict = [[[YOUPAILZChatRoomManager shareManager].chatroomModel.youpaipmanagers objectForKey:attachment.uid] mutableCopy]; [managerDict setObject:attachment.identity forKey:@"identity"]; [managerListDict setObject:managerDict forKey:attachment.uid]; [YOUPAILZChatRoomManager shareManager].chatroomModel.youpaipmanagers = managerListDict.copy; } } } } return n_messages.copy; } /// 处理互动表情 - (void)youpaifhandleEmojiWithAttachment:(YOUPAILZChatRoomEmojiAttachment *)attachment{ NSInteger seatIndex = -999; YOUPAILZChatRoomSeatModel *seatModel = nil; if ([self.youpaipchatroomModel.youpaiphostSeat.youpaipuserInfo.youpaipid isEqual:attachment.from_uid]) { seatModel = [YOUPAILZChatRoomSeatModel mj_objectWithKeyValues:[self.youpaipchatroomModel.youpaiphostSeat mj_keyValues]]; seatIndex = -1; } for (NSInteger i = 0; i < self.youpaipchatroomModel.youpaipnormalSeats.count; i ++) { YOUPAILZChatRoomSeatModel *f_seatModel = self.youpaipchatroomModel.youpaipnormalSeats[i]; if ([f_seatModel.youpaipuserInfo.youpaipid isEqual:attachment.from_uid]) { seatModel = [YOUPAILZChatRoomSeatModel mj_objectWithKeyValues:[f_seatModel mj_keyValues]]; seatIndex = i; break; } } if (seatModel != nil) { seatModel.youpaipisEmoji = YES; seatModel.youpaipemojiImg = attachment.img; if ([self.youpaiplocalSeatModel.youpaipuserInfo.youpaipid isEqual:seatModel.youpaipuserInfo.youpaipid]) { self.youpaiplocalSeatModel = seatModel; } if (seatIndex == -1) { self.youpaipchatroomModel.youpaiphostSeat = seatModel; self.youpaiphostSeatView.youpaipmodel = seatModel; }else{ self.youpaipchatroomModel.youpaipnormalSeats[seatIndex] = seatModel; YOUPAILZChatRoomOthearSeatCell *cell = (YOUPAILZChatRoomOthearSeatCell *)[self.youpaipotherSeatCollectionView cellForItemAtIndexPath:[NSIndexPath indexPathForItem:seatIndex inSection:0]]; cell.youpaipseatView.youpaipmodel = self.youpaipchatroomModel.youpaipnormalSeats[seatIndex]; } } } /// 处理礼物 - (void)youpaifeditGiftView{ NSInteger maxCount = 2; NSInteger count = maxCount - self.youpaipgiftViews.count; if (count > self.youpaipgifts.count) { count = self.youpaipgifts.count; } if (count <= 0) { NSMutableArray *tempGifts = [NSMutableArray array]; for (NSInteger i = 0; i < self.youpaipgiftViews.count; i ++) { if (self.youpaipgifts.count <= 0) { return; } YOUPAILZLiveGIftModel *giftModel = nil; if (self.youpaipgifts.count - 1 < i) { giftModel = self.youpaipgifts[self.youpaipgifts.count - 1]; }else{ giftModel = self.youpaipgifts[i]; } YOUPAILZChatRoomGiftView *giftView = nil; for (YOUPAILZChatRoomGiftView *f_giftView in self.youpaipgiftViews) { if (f_giftView.youpaipgiftModel.youpaipuser_id == giftModel.youpaipuser_id && f_giftView.youpaipgiftModel.youpaipto_uid == giftModel.youpaipto_uid && f_giftView.youpaipgiftModel.youpaipgift_id == giftModel.youpaipgift_id && giftModel.youpaipgift_id != -1) { giftView = f_giftView; break; } } if (giftView != nil) { // i --; [giftView youpaifupdateGiftCount:giftModel.youpaipgiftCount]; // [self.youpaipgifts removeObject:giftModel]; [tempGifts addObject:giftModel]; } } [self.youpaipgifts removeObjectsInArray:tempGifts]; }else{ NSMutableArray *tempGifts = [NSMutableArray array]; for (NSInteger i = 0; i < count; i ++) { if (self.youpaipgifts.count <= 0) { return; } YOUPAILZLiveGIftModel *giftModel = nil; if (self.youpaipgifts.count - 1 < i) { giftModel = self.youpaipgifts[self.youpaipgifts.count - 1]; }else{ giftModel = self.youpaipgifts[i]; } YOUPAILZChatRoomGiftView *giftView = nil; for (YOUPAILZChatRoomGiftView *f_giftView in self.youpaipgiftViews) { if (f_giftView.youpaipgiftModel.youpaipuser_id == giftModel.youpaipuser_id && f_giftView.youpaipgiftModel.youpaipto_uid == giftModel.youpaipto_uid && f_giftView.youpaipgiftModel.youpaipgift_id == giftModel.youpaipgift_id && giftModel.youpaipgift_id != -1) { giftView = f_giftView; break; } } if (giftView != nil) { // i --; [giftView youpaifupdateGiftCount:giftModel.youpaipgiftCount]; // [self.youpaipgifts removeObject:giftModel]; [tempGifts addObject:giftModel]; }else{ YOUPAILZChatRoomGiftView *giftView = [[YOUPAILZChatRoomGiftView alloc] initWithModel:giftModel]; [giftView addTarget:self action:@selector(youpaifgiftAnimationViewClick:) forControlEvents:UIControlEventTouchUpInside]; NSInteger tag = 0; if (self.youpaipgiftViews.count == 1){ if (self.youpaipgiftViews.lastObject.tag == 1) { tag = 0; }else{ tag = 1; } } giftView.tag = tag; [self.view addSubview:giftView]; [self.youpaipgiftViews addObject:giftView]; if (giftView != nil) { UIView *view = self.youpaipgiftViews.lastObject; if (view != nil) { [giftView mas_makeConstraints:^(MASConstraintMaker *make) { make.left.offset(-200.0f); if (view.tag == 0) { make.bottom.equalTo(self.youpaipmessageTableView.mas_top).offset(-15.0f); }else{ make.bottom.equalTo(self.youpaipmessageTableView.mas_top).offset(-30.0f-40.0f); } make.height.offset(40.0f); }]; } } [giftView.superview layoutIfNeeded]; [giftView youpaifshowAnimation]; giftView.delegate = self; [tempGifts addObject:giftModel]; // [self.youpaipgifts removeObject:giftModel]; // i --; } } [self.youpaipgifts removeObjectsInArray:tempGifts]; } } - (void)youpaifstartPlaySvga{ if (self.youpaipisPlaySvga == NO && self.youpaipsvgas.count != 0) { self.youpaipisPlaySvga = YES; YOUPAILZLiveGIftModel* giftModel = self.youpaipsvgas[0]; [self.youpaipsvgaPlayer stopAnimation]; if (giftModel.youpaipgift_type == 1 && ![giftModel.youpaipgift_svga isEqualToString:@""] && !self.youpaipmoreModel.youpaipisCloseAnimation && !self.youpaipisBlindDataAnimation) { self.youpaipsvgaPlayer.hidden = NO; } NSString* svgaName = [[giftModel.youpaipgift_svga componentsSeparatedByString:@"/"] lastObject]; NSString* svgaCanchesPath= [[NSString alloc]initWithFormat:@"%@/%@/%@",CachesPath,@"SVGA",svgaName]; if (![LCTools giftSVGAWithSvgaUrlStr:giftModel.youpaipgift_svga]){ NSString* urlStr = [NSString stringWithFormat:@"%@/%@",[LCSaveData getImageUrl]?[LCSaveData getImageUrl]:BaseImgUrl,giftModel.youpaipgift_svga]; @weakify(self); [self.youpaipparser parseWithURLRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:urlStr]] completionBlock:^(SVGAVideoEntity * _Nullable videoItem) { @strongify(self); if (videoItem != nil) { self.youpaipsvgaPlayer.videoItem = videoItem; [self.youpaipsvgaPlayer startAnimation]; } } failureBlock:^(NSError * _Nullable error) { @strongify(self); self.youpaipsvgaPlayer.hidden = YES; self.youpaipisPlaySvga = NO; [self youpaifstartPlaySvga]; }]; [LCTools giftSVGAWithSvgaUrlStr:giftModel.youpaipgift_svga]; }else{ @weakify(self); [self.youpaipparser parseWithData:[LCTools giftSVGAWithSvgaUrlStr:giftModel.youpaipgift_svga] cacheKey:svgaCanchesPath completionBlock:^(SVGAVideoEntity * _Nonnull videoItem) { @strongify(self); if (videoItem != nil) { self.youpaipsvgaPlayer.videoItem = videoItem; [self.youpaipsvgaPlayer startAnimation]; } } failureBlock:^(NSError * _Nonnull error) { @strongify(self); self.youpaipsvgaPlayer.hidden = YES; self.youpaipisPlaySvga = NO; [self youpaifstartPlaySvga]; }]; } [self.youpaipsvgas removeObject:giftModel]; } } /// 左边小礼物动画点击 - (void)youpaifgiftAnimationViewClick:(YOUPAILZChatRoomGiftView *)sender{ [self youpaifhandleUserOperationWithUserId:[NSString stringWithFormat:@"%@",@(sender.youpaipgiftModel.youpaipuser_id)]]; } - (void)youpaifanimatiomFinishWithView:(YOUPAILZChatRoomGiftView *)liveGiftView{ [self.youpaipgiftViews removeObject:liveGiftView]; [liveGiftView removeFromSuperview]; [self youpaifeditGiftView]; } /// 添加清空公屏消息 - (NIMMessage *)youpaifaddEmptyChatMessage{ NIMMessage *imMessage = [NIMMessageMaker msgWithText:@"公屏消息被清空"]; return imMessage; } /// 开启公屏消息 - (NIMMessage *)youpaifaddOpenChatroomChat{ NIMMessage *imMessage = [NIMMessageMaker msgWithText:@"公屏消息已开启"]; return imMessage; } /// 关闭公屏消息 - (NIMMessage *)youpaifaddCloseChatroomChat{ NIMMessage *imMessage = [NIMMessageMaker msgWithText:@"公屏消息已关闭"]; return imMessage; } /// 更新聊天室人员数 - (void)youpaifuploadChatRoomMemberCount{ @weakify(self); [[[NIMSDK sharedSDK] chatroomManager] fetchChatroomInfo:self.youpaipchatroomModel.youpaiproom_id completion:^(NSError * _Nullable error, NIMChatroom * _Nullable chatroom) { if (!error) { @strongify(self); self.youpaipchatroomMemberView.youpaipmemberL.text = [NSString stringWithFormat:@"%@",@(chatroom.onlineUserCount)]; } }]; } /// 处理VIP弹幕消息 - (void)youpaifhandleVipBarrageAttachment:(YOUPAILZLiveVipBarrageAttachment *)barrageAttachment{ YOUPAIRCDDanmaku *danmaku = [[YOUPAIRCDDanmaku alloc]init]; danmaku.playView = [YOUPAILZLiveBarrageTool youpaifhandleVipBarrageAttachment:barrageAttachment]; [self.view sendDanmaku:danmaku]; } /// 开始座驾动画 - (void)youpaifstartPlayCarSvga{ if (self.youpaipisPlayCarSvga == NO && self.youpaipcarAttachment != nil) { self.youpaipisPlayCarSvga = YES; [self.youpaipcarSvgaPlayer stopAnimation]; if (self.youpaipcarAttachment.car_big_preview_img_svga.length != 0 && !self.youpaipmoreModel.youpaipisCloseAnimation) { self.youpaipcarSvgaPlayer.hidden = NO; } NSString* svgaName = [[self.youpaipcarAttachment.car_big_preview_img_svga componentsSeparatedByString:@"/"] lastObject]; NSString* svgaCanchesPath= [[NSString alloc]initWithFormat:@"%@/%@/%@",CachesPath,@"SVGA",svgaName]; NSString *svgaPath =[svgaCanchesPath stringByAppendingPathComponent:svgaName]; if (![[NSFileManager defaultManager] fileExistsAtPath:svgaPath]){ NSString* urlStr = [NSString stringWithFormat:@"%@/%@",[LCSaveData getImageUrl]?[LCSaveData getImageUrl]:BaseImgUrl,self.youpaipcarAttachment.car_big_preview_img_svga]; @weakify(self); [self.youpaipcarParser parseWithURLRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:urlStr]] completionBlock:^(SVGAVideoEntity * _Nullable videoItem) { @strongify(self); if (videoItem != nil) { self.youpaipcarSvgaPlayer.videoItem = videoItem; [self.youpaipcarSvgaPlayer startAnimation]; } } failureBlock:^(NSError * _Nullable error) { @strongify(self); self.youpaipcarSvgaPlayer.hidden = YES; self.youpaipisPlayCarSvga = NO; [self youpaifstartPlayCarSvga]; }]; [LCTools giftSVGAWithSvgaUrlStr:self.youpaipcarAttachment.car_big_preview_img_svga]; }else{ @weakify(self); [self.youpaipcarParser parseWithData:[LCTools giftSVGAWithSvgaUrlStr:self.youpaipcarAttachment.car_big_preview_img_svga] cacheKey:svgaCanchesPath completionBlock:^(SVGAVideoEntity * _Nonnull videoItem) { @strongify(self); if (videoItem != nil) { self.youpaipcarSvgaPlayer.videoItem = videoItem; [self.youpaipcarSvgaPlayer startAnimation]; } } failureBlock:^(NSError * _Nonnull error) { @strongify(self); self.youpaipcarSvgaPlayer.hidden = YES; self.youpaipisPlayCarSvga = NO; [self youpaifstartPlayCarSvga]; }]; } self.youpaipcarAttachment = nil; } } #pragma mark - SVGAPlayerDelegate - (void)svgaPlayerDidFinishedAnimation:(SVGAPlayer *)player{ if (self.youpaipcarSvgaPlayer == player) { self.youpaipcarSvgaPlayer.hidden = YES; self.youpaipisPlayCarSvga = NO; [self youpaifstartPlayCarSvga]; }else{ self.youpaipsvgaPlayer.hidden = YES; self.youpaipisPlaySvga = NO; [self youpaifstartPlaySvga]; } } /// 处理点击用户操作 - (void)youpaifhandleUserOperationWithUserId:(NSString *)userId{ YOUPAILZChatRoomSeatModel *f_seatModel = nil; NSInteger seatIndex = -999; if ([self.youpaipchatroomModel.youpaiphostSeat.youpaipuserInfo.youpaipid isEqual:userId]) { f_seatModel = self.youpaipchatroomModel.youpaiphostSeat; seatIndex = -1; } for (NSInteger i = 0; i < self.youpaipchatroomModel.youpaipnormalSeats.count; i ++) { YOUPAILZChatRoomSeatModel *seatModel = self.youpaipchatroomModel.youpaipnormalSeats[i]; if ([seatModel.youpaipuserInfo.youpaipid isEqual:userId]) { f_seatModel = seatModel; seatIndex = i; break; } } if (f_seatModel != nil) { if ([userId isEqual:self.youpaipchatroomModel.youpaipuserInfo.youpaipid]) { NSMutableArray* actionArray = [NSMutableArray array]; [actionArray addObject:[self youpaifuserInfoAlertActionWithUserId:userId]]; [actionArray addObject:[self youpaifdownseatAlertAction]]; ZCAlertSheetView* alertSheet = [[ZCAlertSheetView alloc]initWithTitle:nil andShowCancelButton:YES andAction:actionArray]; alertSheet.alertWindow.hidden = NO; [alertSheet show]; }else{ if (self.youpaipchatroomModel.youpaipuserInfo.youpaifroleType == LZUserRoleTypeWithNormal) { // 普通用户显示用户资料 [self youpaifshowUserInfoWithUserId:userId]; }else{ NIMChatroomMembersByIdsRequest *request = [[NIMChatroomMembersByIdsRequest alloc] init]; request.roomId = self.youpaipchatroomModel.youpaiproom_id; request.userIds = @[userId]; @weakify(self); [[[NIMSDK sharedSDK] chatroomManager] fetchChatroomMembersByIds:request completion:^(NSError * _Nullable error, NSArray * _Nullable members) { @strongify(self); BOOL youpaipisDisableMessage = NO; NIMChatroomMember *member = nil; if (members.count != 0) { member = members[0]; if (member.isTempMuted) { youpaipisDisableMessage = YES; } } NSMutableArray *actionArray = [NSMutableArray array]; if (f_seatModel == nil) { [actionArray addObject:[self youpaifuserInfoAlertActionWithUserId:userId]]; [actionArray addObject:[self youpaifinvitationUpSeatAlertActionWithUserId:userId]]; if (youpaipisDisableMessage) { [actionArray addObject:[self youpaifclearDisableSendMessageAlertActionWithUserID:userId nickname:member.roomNickname]]; }else{ [actionArray addObject:[self youpaifdisableSendMessageAlertActionWithUserID:userId]]; } [actionArray addObject:[self youpaifgetOutRoomAlertActionWithUserID:userId]]; }else{ [actionArray addObject:[self youpaifuserInfoAlertActionWithUserId:userId]]; if (self.youpaipchatroomModel.youpaipplayType == LZChatRoomPlayTypeWithCardiac) { [actionArray addObject:[self emptyLoveValueAlertActionWithUserID:userId]]; } [actionArray addObject:[self youpaifforcedDownSeatAlertActionWithOperationUserId:f_seatModel.youpaipuserInfo.youpaipid]]; if (f_seatModel.youpaipisDisableMicrophone) { [actionArray addObject:[self youpaifopenMisAlertActionWithSeatId:seatIndex]]; }else{ [actionArray addObject:[self youpaifdisableMisAlertActionWithSeatId:seatIndex]]; } if (youpaipisDisableMessage) { [actionArray addObject:[self youpaifclearDisableSendMessageAlertActionWithUserID:userId nickname:member.roomNickname]]; }else{ [actionArray addObject:[self youpaifdisableSendMessageAlertActionWithUserID:userId]]; } [actionArray addObject:[self youpaifgetOutRoomAlertActionWithUserID:userId]]; } ZCAlertSheetView* alertSheet = [[ZCAlertSheetView alloc]initWithTitle:nil andShowCancelButton:YES andAction:actionArray]; alertSheet.alertWindow.hidden = NO; [alertSheet show]; }]; } } }else{ if ([userId isEqual:self.youpaipchatroomModel.youpaipuserInfo.youpaipid]) { [self youpaifshowUserInfoWithUserId:userId]; }else{ if (self.youpaipchatroomModel.youpaipuserInfo.youpaifroleType == LZUserRoleTypeWithNormal) { // 普通用户显示用户资料 [self youpaifshowUserInfoWithUserId:userId]; }else{ NIMChatroomMembersByIdsRequest *request = [[NIMChatroomMembersByIdsRequest alloc] init]; request.roomId = self.youpaipchatroomModel.youpaiproom_id; request.userIds = @[userId]; @weakify(self); [[[NIMSDK sharedSDK] chatroomManager] fetchChatroomMembersByIds:request completion:^(NSError * _Nullable error, NSArray * _Nullable members) { @strongify(self); BOOL youpaipisDisableMessage = NO; NIMChatroomMember *member = nil; if (members.count != 0) { member = members[0]; if (member.isTempMuted) { youpaipisDisableMessage = YES; } } NSMutableArray *actionArray = [NSMutableArray array]; if (f_seatModel == nil) { [actionArray addObject:[self youpaifuserInfoAlertActionWithUserId:userId]]; [actionArray addObject:[self youpaifinvitationUpSeatAlertActionWithUserId:userId]]; if (youpaipisDisableMessage) { [actionArray addObject:[self youpaifclearDisableSendMessageAlertActionWithUserID:userId nickname:member.roomNickname]]; }else{ [actionArray addObject:[self youpaifdisableSendMessageAlertActionWithUserID:userId]]; } [actionArray addObject:[self youpaifgetOutRoomAlertActionWithUserID:userId]]; }else{ [actionArray addObject:[self youpaifuserInfoAlertActionWithUserId:userId]]; if (self.youpaipchatroomModel.youpaipplayType == LZChatRoomPlayTypeWithCardiac) { [actionArray addObject:[self emptyLoveValueAlertActionWithUserID:userId]]; } [actionArray addObject:[self youpaifforcedDownSeatAlertActionWithOperationUserId:f_seatModel.youpaipuserInfo.youpaipid]]; if (f_seatModel.youpaipisDisableMicrophone) { [actionArray addObject:[self youpaifopenMisAlertActionWithSeatId:seatIndex]]; }else{ [actionArray addObject:[self youpaifdisableMisAlertActionWithSeatId:seatIndex]]; } if (youpaipisDisableMessage) { [actionArray addObject:[self youpaifclearDisableSendMessageAlertActionWithUserID:userId nickname:member.roomNickname]]; }else{ [actionArray addObject:[self youpaifdisableSendMessageAlertActionWithUserID:userId]]; } [actionArray addObject:[self youpaifgetOutRoomAlertActionWithUserID:userId]]; } ZCAlertSheetView* alertSheet = [[ZCAlertSheetView alloc]initWithTitle:nil andShowCancelButton:YES andAction:actionArray]; alertSheet.alertWindow.hidden = NO; [alertSheet show]; }]; } } } } /// 被邀请上麦弹框 - (void)youpaifinviactionUpSeatAlertWithAttachment:(YOUPAILZChatRoomInviactionUpSeatAttachment *)attachment{ if([attachment.to_uid isEqual:self.youpaipchatroomModel.youpaipuserInfo.youpaipid]){ @weakify(self); LZAlertAction *cancelAction = [LZAlertAction actionWithTitle:@"取消" handler:^(LZAlertAction *action) { @strongify(self); [self youpaifuserAgreeSeat:NO]; }]; cancelAction.cornerRadius = 24.0f; cancelAction.bgColor = HexColorFromRGB(0x9F9DA5); LZAlertAction *confimAction = [LZAlertAction actionWithTitle:@"上麦" handler:^(LZAlertAction *action) { @strongify(self); [self youpaifuserAgreeSeat:YES]; }]; confimAction.cornerRadius = 24.0f; confimAction.bgColor = [UIColor colorWithPatternImage:[LCTools ColorImage:CGSizeMake((KScreenWidth - 105.0f) / 2.0f, 48.0f) FromColors:@[ZYGradientOneColor,ZYGradientTwoColor] ByGradientType:GradientLeftToRight]]; LZAlertWindow *alert = [LZAlertWindow alertWithTitle:@"上麦邀请" content:@"房主邀请你上麦一起聊,是否上麦?" action:@[cancelAction,confimAction]]; alert.contentTextAlignment = NSTextAlignmentCenter; [self TFPresentVC:alert completion:^{}]; } } /// 用户同意&拒绝上麦 - (void)youpaifuserAgreeSeat:(BOOL)isAgree{ [LCHttpHelper requestWithURLString:UserAgreeSeat parameters:@{@"room_id":self.youpaipchatroomModel.youpaiproom_id,@"operate":isAgree ? @"1" : @"0"} needToken:YES type:(HttpRequestTypePost) success:^(id responseObject) { } failure:^(NSError *error) { }]; } /// 点击主持位 - (void)youpaifhostSeatClick{ [self.youpaipkeyboardView resignFirstResponder]; self.youpaipkeyboardView.hidden = YES; if (self.youpaipchatroomModel.youpaiphostSeat.youpaipseatState == LZChatRoomSeatStateWithFree) { // 主持位在空闲状态下 if (self.youpaipchatroomModel.youpaipuserInfo.youpaifroleType != LZUserRoleTypeWithNormal) { [self youpaifuserUpSeatWithSeatId:-1]; }else{ [ZCHUDHelper showTitle:@"这是主持位"]; } }else if(self.youpaipchatroomModel.youpaiphostSeat.youpaipseatState == LZChatRoomSeatStateWithBusy){ // 主持位有人状态下 if ([self.youpaipchatroomModel.youpaiphostSeat.youpaipuserInfo.youpaipid isEqual:self.youpaipchatroomModel.youpaipuserInfo.youpaipid]) { //自己操作 NSMutableArray* actionArray = [NSMutableArray array]; [actionArray addObject:[self youpaifuserInfoAlertActionWithUserId:self.youpaipchatroomModel.youpaiphostSeat.youpaipuserInfo.youpaipid]]; [actionArray addObject:[self youpaifdownseatAlertAction]]; ZCAlertSheetView* alertSheet = [[ZCAlertSheetView alloc]initWithTitle:nil andShowCancelButton:YES andAction:actionArray]; alertSheet.alertWindow.hidden = NO; [alertSheet show]; }else{ if (self.youpaipchatroomModel.youpaipuserInfo.youpaifroleType != LZUserRoleTypeWithNormal) { // 如果当前用户角色小于等于主持位,并且自己不是普通用户 NIMChatroomMembersByIdsRequest *request = [[NIMChatroomMembersByIdsRequest alloc] init]; request.roomId = self.youpaipchatroomModel.youpaiproom_id; request.userIds = @[self.youpaipchatroomModel.youpaiphostSeat.youpaipuserInfo.youpaipid]; @weakify(self); [[[NIMSDK sharedSDK] chatroomManager] fetchChatroomMembersByIds:request completion:^(NSError * _Nullable error, NSArray * _Nullable members) { @strongify(self); BOOL youpaipisDisableMessage = NO; NIMChatroomMember *member = nil; if (members.count != 0) { member = members[0]; if (member.isTempMuted) { youpaipisDisableMessage = YES; } } NSMutableArray *actionArray = [NSMutableArray array]; [actionArray addObject:[self youpaifuserInfoAlertActionWithUserId:self.youpaipchatroomModel.youpaiphostSeat.youpaipuserInfo.youpaipid]]; if (self.youpaipchatroomModel.youpaipplayType == LZChatRoomPlayTypeWithCardiac) { [actionArray addObject:[self emptyLoveValueAlertActionWithUserID:self.youpaipchatroomModel.youpaiphostSeat.youpaipuserInfo.youpaipid]]; } [actionArray addObject:[self youpaifforcedDownSeatAlertActionWithOperationUserId:self.youpaipchatroomModel.youpaiphostSeat.youpaipuserInfo.youpaipid]]; if (self.youpaipchatroomModel.youpaiphostSeat.youpaipisDisableMicrophone) { [actionArray addObject:[self youpaifopenMisAlertActionWithSeatId:-1]]; }else{ [actionArray addObject:[self youpaifdisableMisAlertActionWithSeatId:-1]]; } if (youpaipisDisableMessage) { [actionArray addObject:[self youpaifclearDisableSendMessageAlertActionWithUserID:self.youpaipchatroomModel.youpaiphostSeat.youpaipuserInfo.youpaipid nickname:member.roomNickname]]; }else{ [actionArray addObject:[self youpaifdisableSendMessageAlertActionWithUserID:self.youpaipchatroomModel.youpaiphostSeat.youpaipuserInfo.youpaipid]]; } [actionArray addObject:[self youpaifgetOutRoomAlertActionWithUserID:self.youpaipchatroomModel.youpaiphostSeat.youpaipuserInfo.youpaipid]]; ZCAlertSheetView* alertSheet = [[ZCAlertSheetView alloc]initWithTitle:nil andShowCancelButton:YES andAction:actionArray]; alertSheet.alertWindow.hidden = NO; [alertSheet show]; }]; }else{ // 如果当前用户角色大于主持位 展示个人信息 [self youpaifshowUserInfoWithUserId:self.youpaipchatroomModel.youpaiphostSeat.youpaipuserInfo.youpaipid]; } } } } /// 点击其他麦位 - (void)youpaifotherSeatClickWithIndex:(NSInteger)index{ YOUPAILZChatRoomSeatModel *seatModel = self.youpaipchatroomModel.youpaipnormalSeats[index]; if (seatModel.youpaipseatState == LZChatRoomSeatStateWithFree) { // 麦位在空闲状态下 if (self.youpaipchatroomModel.youpaipuserInfo.youpaifroleType != LZUserRoleTypeWithNormal) { NSMutableArray* actionArray = [NSMutableArray array]; [actionArray addObject:[self youpaifupseatAlertActionWithSeatId:index]]; [actionArray addObject:[self youpaifinvitationUpseatAlertActionWithSeatId:index]]; [actionArray addObject:[self youpaiflockSeatAlertActionWithSeatId:index]]; ZCAlertSheetView* alertSheet = [[ZCAlertSheetView alloc]initWithTitle:nil andShowCancelButton:YES andAction:actionArray]; alertSheet.alertWindow.hidden = NO; [alertSheet show]; }else{ if (self.youpaipchatroomModel.youpaipchatroomType == LZChatRoomTypeWithFree) { // 自由麦序 [self youpaifuserUpSeatWithSeatId:index]; }else{ // 主持麦序 [self youpaifuserUpSeatWithSeatId:-999]; [self.youpaipapplySeatButton youpaifrleoadWithType:LZChatRoomApplySeatTypeWithInline playType:self.youpaipchatroomModel.youpaipplayType]; } } }else if(seatModel.youpaipseatState == LZChatRoomSeatStateWithBusy){ // 麦位有人状态下 if ([seatModel.youpaipuserInfo.youpaipid isEqual:self.youpaipchatroomModel.youpaipuserInfo.youpaipid]) { //自己操作 NSMutableArray *actionArray = [NSMutableArray array]; [actionArray addObject:[self youpaifuserInfoAlertActionWithUserId:seatModel.youpaipuserInfo.youpaipid]]; [actionArray addObject:[self youpaifdownseatAlertAction]]; ZCAlertSheetView* alertSheet = [[ZCAlertSheetView alloc]initWithTitle:nil andShowCancelButton:YES andAction:actionArray]; alertSheet.alertWindow.hidden = NO; [alertSheet show]; }else{ if (self.youpaipchatroomModel.youpaipuserInfo.youpaifroleType != LZUserRoleTypeWithNormal) { // 如果当前用户角色小于等于麦位,并且自己不是普通用户 NIMChatroomMembersByIdsRequest *request = [[NIMChatroomMembersByIdsRequest alloc] init]; request.roomId = self.youpaipchatroomModel.youpaiproom_id; request.userIds = @[seatModel.youpaipuserInfo.youpaipid]; @weakify(self); [[[NIMSDK sharedSDK] chatroomManager] fetchChatroomMembersByIds:request completion:^(NSError * _Nullable error, NSArray * _Nullable members) { @strongify(self); BOOL youpaipisDisableMessage = NO; NIMChatroomMember *member = nil; if (members.count != 0) { member = members[0]; if (member.isTempMuted) { youpaipisDisableMessage = YES; } } NSMutableArray *actionArray = [NSMutableArray array]; [actionArray addObject:[self youpaifuserInfoAlertActionWithUserId:seatModel.youpaipuserInfo.youpaipid]]; if (self.youpaipchatroomModel.youpaipplayType == LZChatRoomPlayTypeWithCardiac) { [actionArray addObject:[self emptyLoveValueAlertActionWithUserID:seatModel.youpaipuserInfo.youpaipid]]; } [actionArray addObject:[self youpaifforcedDownSeatAlertActionWithOperationUserId:seatModel.youpaipuserInfo.youpaipid]]; if (seatModel.youpaipisDisableMicrophone) { [actionArray addObject:[self youpaifopenMisAlertActionWithSeatId:index]]; }else{ [actionArray addObject:[self youpaifdisableMisAlertActionWithSeatId:index]]; } if (youpaipisDisableMessage) { [actionArray addObject:[self youpaifclearDisableSendMessageAlertActionWithUserID:seatModel.youpaipuserInfo.youpaipid nickname:member.roomNickname]]; }else{ [actionArray addObject:[self youpaifdisableSendMessageAlertActionWithUserID:seatModel.youpaipuserInfo.youpaipid]]; } [actionArray addObject:[self youpaifgetOutRoomAlertActionWithUserID:seatModel.youpaipuserInfo.youpaipid]]; ZCAlertSheetView* alertSheet = [[ZCAlertSheetView alloc]initWithTitle:nil andShowCancelButton:YES andAction:actionArray]; alertSheet.alertWindow.hidden = NO; [alertSheet show]; }]; }else{ // 如果当前用户角色大于主持位 展示个人信息 [self youpaifshowUserInfoWithUserId:seatModel.youpaipuserInfo.youpaipid]; } } }else if(seatModel.youpaipseatState == LZChatRoomSeatStateWithLock){ // 麦位锁定状态下 if (self.youpaipchatroomModel.youpaipuserInfo.youpaifroleType != LZUserRoleTypeWithNormal) { NSMutableArray* actionArray = [NSMutableArray array]; [actionArray addObject:[self youpaifunlockSeatAlertActionWithIndex:index]]; ZCAlertSheetView* alertSheet = [[ZCAlertSheetView alloc]initWithTitle:nil andShowCancelButton:YES andAction:actionArray]; alertSheet.alertWindow.hidden = NO; [alertSheet show]; }else{ [ZCHUDHelper showTitle:@"该麦位已被锁定,无法申请上麦"]; } } } /// 上麦处理按钮事件 - (void)youpaifapplySeatButtonClick{ switch (self.youpaipapplySeatButton.youpaiptype) { case LZChatRoomApplySeatTypeWithUpSeat:{ [self youpaifuserUpSeatWithSeatId:-999]; [self.youpaipapplySeatButton youpaifrleoadWithType:LZChatRoomApplySeatTypeWithInline playType:self.youpaipchatroomModel.youpaipplayType]; } break; case LZChatRoomApplySeatTypeWithInline:{ [self youpaifshowSeatInlineWindow]; } break; case LZChatRoomApplySeatTypeWithApplyList:{ [self youpaifshowUpSeatApplyWindow]; } break; default: break; } } - (void)youpaifreloadApplySeatButtonWithAttachment:(YOUPAILZChatRoomApplySeatAttachment *)attachment{ self.youpaipchatroomModel.youpaipsay_count = attachment.num; self.youpaipapplySeatButton.youpaipmemberCount = [self.youpaipchatroomModel.youpaipsay_count integerValue]; if ([attachment.op_uid isEqual:self.youpaipchatroomModel.youpaipuserInfo.youpaipid]) { //0、拒绝,1、同意,2、用户申请 if ([attachment.status isEqual:@"0"]) { [self.youpaipapplySeatButton youpaifrleoadWithType:LZChatRoomApplySeatTypeWithUpSeat playType:self.youpaipchatroomModel.youpaipplayType]; }else if ([attachment.status isEqual:@"1"]) { self.youpaipapplySeatButton.hidden = YES; [self.youpaipapplySeatButton youpaifrleoadWithType:LZChatRoomApplySeatTypeWithUpSeat playType:self.youpaipchatroomModel.youpaipplayType]; } } } // 显示排麦中列表 - (void)youpaifshowSeatInlineWindow{ YOUPAILZChatRoomSeatInlineWindow *window = [[YOUPAILZChatRoomSeatInlineWindow alloc] init]; window.isTouchDismiss = YES; window.youpaiproomId = self.youpaipchatroomModel.youpaiproom_id; [self TFPresentVC:window completion:^{}]; } // 显示上麦申请列表 - (void)youpaifshowUpSeatApplyWindow{ YOUPAILZChatRoomUpSeatApplyWindow *window = [[YOUPAILZChatRoomUpSeatApplyWindow alloc] init]; window.isTouchDismiss = YES; window.youpaiproomId = self.youpaipchatroomModel.youpaiproom_id; window.youpaipplayType = self.youpaipchatroomModel.youpaipplayType; @weakify(self); [window setYoupaipupseatBlock:^(YOUPAILZChatRoomMemberModel * _Nonnull model) { @strongify(self); [self youpaifshowSelectedSeatWindowWithUserId:model.youpaipid youpaipisInviation:NO]; }]; [self TFPresentVC:window completion:^{}]; } // 显示选择座位 - (void)youpaifshowSelectedSeatWindowWithUserId:(NSString *)userId youpaipisInviation:(BOOL)youpaipisInviation{ YOUPAILZChatRoomSelectedSeatWindow *window = [[YOUPAILZChatRoomSelectedSeatWindow alloc] init]; window.youpaipoperationUserId = userId; window.youpaiproomId = self.youpaipchatroomModel.youpaiproom_id; window.youpaipisInviation = youpaipisInviation; window.youpaipplayType = self.youpaipchatroomModel.youpaipplayType; window.youpaipnormalSeatJsons = [YOUPAILZChatRoomSeatModel mj_keyValuesArrayWithObjectArray:self.youpaipchatroomModel.youpaipnormalSeats]; [self TFPresentVC:window completion:^{}]; } /// 用户上麦 /// youpaipseatId 座位下标 /// -999 说明是申请上麦 /// -1 说明是主持麦位 /// 其他则是对应的麦位下标 - (void)youpaifuserUpSeatWithSeatId:(NSInteger)youpaipseatId{ NSString *seat = @""; if (youpaipseatId != -999) { seat = [NSString stringWithFormat:@"%@",@(youpaipseatId)]; } [LCHttpHelper requestWithURLString:UserUpperWheat parameters:@{@"room_id":self.youpaipchatroomModel.youpaiproom_id,@"seat":seat} needToken:YES type:(HttpRequestTypePost) success:^(id responseObject) { } failure:^(NSError *error) { }]; } /// 用户下麦 - (void)youpaifuserDownSeat{ [LCHttpHelper requestWithURLString:LowerSeats parameters:@{@"room_id":self.youpaipchatroomModel.youpaiproom_id} needToken:YES type:(HttpRequestTypePost) success:^(id responseObject) { } failure:^(NSError *error) { }]; } /// 锁定座位 - (void)youpaiflockSeatWithSeatId:(NSInteger)youpaipseatId isLock:(BOOL)isLock{ NSInteger lock = isLock ? 1 : 0; [LCHttpHelper requestWithURLString:LockSeates parameters:@{@"room_id":self.youpaipchatroomModel.youpaiproom_id,@"seat":@(youpaipseatId),@"type":@(lock)} needToken:YES type:(HttpRequestTypePost) success:^(id responseObject) { } failure:^(NSError *error) { }]; } /// 抱下麦 - (void)youpaifforcedDownSeatWithOperationUserId:(NSString *)youpaipoperationUserId{ [LCHttpHelper requestWithURLString:LowerSeat parameters:@{@"room_id":self.youpaipchatroomModel.youpaiproom_id,@"op_uid":youpaipoperationUserId} needToken:YES type:(HttpRequestTypePost) success:^(id responseObject) { } failure:^(NSError *error) { }]; } /// 闭麦 /// @param youpaipseatId 座位号 /// @param disable 是否禁止 - (void)youpaifdisableMisWithSeatId:(NSInteger)youpaipseatId disable:(BOOL)disable{ NSInteger type = disable ? 1 : 0; [LCHttpHelper requestWithURLString:CloseAOpenSeatSay parameters:@{@"room_id":self.youpaipchatroomModel.youpaiproom_id,@"seat":@(youpaipseatId),@"type":@(type)} needToken:YES type:(HttpRequestTypePost) success:^(id responseObject) { } failure:^(NSError *error) { }]; } // 个人资料 - (ZCAlertAction *)youpaifuserInfoAlertActionWithUserId:(NSString *)userId{ @weakify(self); ZCAlertAction *action = [ZCAlertAction actionWithTitle:@"个人资料" andblock:^{ @strongify(self); [self youpaifshowUserInfoWithUserId:userId]; }]; return action; } /// 展示邀请列表 - (void)youpaifshowInviationListWindowWithSeatId:(NSInteger)youpaipseatId{ YOUPAILZChatRoomInviationUpSeatListWindow *window = [[YOUPAILZChatRoomInviationUpSeatListWindow alloc] init]; window.isTouchDismiss = YES; window.youpaipseatId = youpaipseatId; window.youpaiproomId = self.youpaipchatroomModel.youpaiproom_id; [self TFPresentVC:window completion:^{}]; } // 上麦 - (ZCAlertAction *)youpaifupseatAlertActionWithSeatId:(NSInteger)youpaipseatId{ @weakify(self); ZCAlertAction *action = [ZCAlertAction actionWithTitle:@"上麦" andblock:^{ @strongify(self); [self youpaifuserUpSeatWithSeatId:youpaipseatId]; }]; return action; } // 下麦 - (ZCAlertAction *)youpaifdownseatAlertAction{ @weakify(self); ZCAlertAction *action = [ZCAlertAction actionWithTitle:@"下麦" andblock:^{ @strongify(self); [self youpaifuserDownSeat]; }]; return action; } // 邀请上麦 - (ZCAlertAction *)youpaifinvitationUpseatAlertActionWithSeatId:(NSInteger)youpaipseatId{ @weakify(self); ZCAlertAction *action = [ZCAlertAction actionWithTitle:@"邀请上麦" andblock:^{ @strongify(self); [self youpaifshowInviationListWindowWithSeatId:youpaipseatId]; }]; return action; } // 邀请上麦2 - (ZCAlertAction *)youpaifinvitationUpSeatAlertActionWithUserId:(NSString *)userId{ @weakify(self); ZCAlertAction *action = [ZCAlertAction actionWithTitle:@"邀请上麦" andblock:^{ @strongify(self); [self youpaifshowSelectedSeatWindowWithUserId:userId youpaipisInviation:YES]; }]; return action; } // 抱下麦 - (ZCAlertAction *)youpaifforcedDownSeatAlertActionWithOperationUserId:(NSString *)youpaipoperationUserId{ @weakify(self); ZCAlertAction *action = [ZCAlertAction actionWithTitle:@"抱下麦" andblock:^{ @strongify(self); [self youpaifforcedDownSeatWithOperationUserId:youpaipoperationUserId]; }]; return action; } // 锁定麦位 - (ZCAlertAction *)youpaiflockSeatAlertActionWithSeatId:(NSInteger)youpaipseatId{ @weakify(self); ZCAlertAction *action = [ZCAlertAction actionWithTitle:@"锁定麦位" andblock:^{ @strongify(self); [self youpaiflockSeatWithSeatId:youpaipseatId isLock:YES]; }]; return action; } // 解锁麦位 - (ZCAlertAction *)youpaifunlockSeatAlertActionWithIndex:(NSInteger)index{ @weakify(self); ZCAlertAction *action = [ZCAlertAction actionWithTitle:@"解锁麦位" andblock:^{ @strongify(self); [self youpaiflockSeatWithSeatId:index isLock:NO]; }]; return action; } // 闭麦 - (ZCAlertAction *)youpaifdisableMisAlertActionWithSeatId:(NSInteger)youpaipseatId{ @weakify(self); ZCAlertAction *action = [ZCAlertAction actionWithTitle:@"闭麦" andblock:^{ @strongify(self); [self youpaifdisableMisWithSeatId:youpaipseatId disable:YES]; }]; return action; } // 开麦 - (ZCAlertAction *)youpaifopenMisAlertActionWithSeatId:(NSInteger)youpaipseatId{ @weakify(self); ZCAlertAction *action = [ZCAlertAction actionWithTitle:@"开麦" andblock:^{ @strongify(self); [self youpaifdisableMisWithSeatId:youpaipseatId disable:NO]; }]; return action; } // 禁言 - (ZCAlertAction *)youpaifdisableSendMessageAlertActionWithUserID:(NSString *)userId{ @weakify(self); ZCAlertAction *action = [ZCAlertAction actionWithTitle:@"禁言" andblock:^{ @strongify(self); [self youpaifselectedDisableMessageTimerAlertUserId:userId]; }]; return action; } // 解除禁言 - (ZCAlertAction *)youpaifclearDisableSendMessageAlertActionWithUserID:(NSString *)userId nickname:(NSString *)nickname{ @weakify(self); ZCAlertAction *action = [ZCAlertAction actionWithTitle:@"解除禁言" andblock:^{ @strongify(self); ZCAlertAction *action1 = [ZCAlertAction actionWithTitle:@"确认解除" andblock:^{ @strongify(self); [self youpaifoutRoomOrDisableMessageWithType:@"mute" userId:userId timer:@"0"]; }]; NSMutableAttributedString *str = [[NSMutableAttributedString alloc] initWithString:[NSString stringWithFormat:@"将解除 %@ 禁言状态",nickname]]; [str addAttribute:NSForegroundColorAttributeName value:HexColorFromRGB(0xFFDB80) range:NSMakeRange(4,nickname.length)]; ZCAlertSheetView* alertSheet = [[ZCAlertSheetView alloc]initWithAttrbuteTitle:str andShowCancelButton:YES andAction:@[action1]]; alertSheet.alertWindow.hidden = NO; [alertSheet show]; }]; return action; } // 移出房间 - (ZCAlertAction *)youpaifgetOutRoomAlertActionWithUserID:(NSString *)userId{ @weakify(self); ZCAlertAction *action = [ZCAlertAction actionWithTitle:@"移出房间" andblock:^{ @strongify(self); [self youpaifselectedOutRoomTimerAlertUserID:userId]; }]; return action; } // 选择移出房间时间弹框 - (void)youpaifselectedOutRoomTimerAlertUserID:(NSString *)userId{ @weakify(self); ZCAlertAction *action1 = [ZCAlertAction actionWithTitle:@"5分钟" andblock:^{ @strongify(self); [self youpaifoutRoomOrDisableMessageWithType:@"kick" userId:userId timer:[NSString stringWithFormat:@"%@",@(5*60)]]; }]; ZCAlertAction *action2 = [ZCAlertAction actionWithTitle:@"30分钟" andblock:^{ @strongify(self); [self youpaifoutRoomOrDisableMessageWithType:@"kick" userId:userId timer:[NSString stringWithFormat:@"%@",@(30*60)]]; }]; ZCAlertAction *action3 = [ZCAlertAction actionWithTitle:@"60分钟" andblock:^{ @strongify(self); [self youpaifoutRoomOrDisableMessageWithType:@"kick" userId:userId timer:[NSString stringWithFormat:@"%@",@(60*60)]]; }]; ZCAlertAction *action4 = [ZCAlertAction actionWithTitle:@"永久移出" andblock:^{ @strongify(self); LZAlertAction *cancelAction = [LZAlertAction actionWithTitle:@"取消" handler:^(LZAlertAction *action) { }]; cancelAction.cornerRadius = 24.0f; cancelAction.bgColor = HexColorFromRGB(0x9F9DA5); LZAlertAction *confimAction = [LZAlertAction actionWithTitle:@"确定" handler:^(LZAlertAction *action) { @strongify(self); [self youpaifoutRoomOrDisableMessageWithType:@"kick" userId:userId timer:[NSString stringWithFormat:@"%@",@(-1)]]; }]; confimAction.cornerRadius = 24.0f; confimAction.bgColor = [UIColor colorWithPatternImage:[LCTools ColorImage:CGSizeMake((KScreenWidth - 105.0f) / 2.0f, 48.0f) FromColors:@[ZYGradientOneColor,ZYGradientTwoColor] ByGradientType:GradientLeftToRight]]; LZAlertWindow *alert = [LZAlertWindow alertWithTitle:@"提示" content:@"选择【永久移出】后,用户将无法进入该房间,直至管理者解除限制" action:@[cancelAction,confimAction]]; alert.contentTextAlignment = NSTextAlignmentCenter; [self TFPresentVC:alert completion:^{}]; }]; ZCAlertSheetView* alertSheet = [[ZCAlertSheetView alloc]initWithTitle:nil andShowCancelButton:YES andAction:@[action1,action2,action3,action4]]; alertSheet.alertWindow.hidden = NO; [alertSheet show]; } // 清空心动值 - (ZCAlertAction *)emptyLoveValueAlertActionWithUserID:(NSString *)userId{ @weakify(self); ZCAlertAction *action = [ZCAlertAction actionWithTitle:@"清空心动值" andblock:^{ @strongify(self); LZAlertAction *cancelAction = [LZAlertAction actionWithTitle:@"取消" handler:^(LZAlertAction *action) { }]; cancelAction.cornerRadius = 24.0f; cancelAction.bgColor = HexColorFromRGB(0x9F9DA5); LZAlertAction *confimAction = [LZAlertAction actionWithTitle:@"确定" handler:^(LZAlertAction *action) { @strongify(self); [self emptyLoveValueWithUserID:userId]; }]; confimAction.cornerRadius = 24.0f; confimAction.bgColor = [UIColor colorWithPatternImage:[LCTools ColorImage:CGSizeMake((KScreenWidth - 105.0f) / 2.0f, 48.0f) FromColors:@[ZYGradientOneColor,ZYGradientTwoColor] ByGradientType:GradientLeftToRight]]; LZAlertWindow *alert = [LZAlertWindow alertWithTitle:@"提示" content:@"是否清空该用户的心动值" action:@[cancelAction,confimAction]]; alert.contentTextAlignment = NSTextAlignmentCenter; [self TFPresentVC:alert completion:^{}]; }]; return action; } // 清空心动值 - (void)emptyLoveValueWithUserID:(NSString *)userId{ [LCHttpHelper requestWithURLString:ChatRoomClearUserCardiac parameters:@{@"room_id":self.youpaipchatroomModel.youpaiproom_id,@"user_id":userId} needToken:YES type:(HttpRequestTypePost) success:^(id responseObject) { NSDictionary* dict = (NSDictionary*)responseObject; NSInteger code = [[dict objectForKey:@"code"] integerValue]; if (code==0) {//成功 [ZCHUDHelper showTitle:@"操作成功"]; } } failure:^(NSError *error) { }]; } // 选择禁言时间弹框 - (void)youpaifselectedDisableMessageTimerAlertUserId:(NSString *)userId{ @weakify(self); ZCAlertAction *action1 = [ZCAlertAction actionWithTitle:@"禁言1分钟" andblock:^{ @strongify(self); [self youpaifoutRoomOrDisableMessageWithType:@"mute" userId:userId timer:[NSString stringWithFormat:@"%@",@(1*60)]]; }]; ZCAlertAction *action2 = [ZCAlertAction actionWithTitle:@"禁言5分钟" andblock:^{ @strongify(self); [self youpaifoutRoomOrDisableMessageWithType:@"mute" userId:userId timer:[NSString stringWithFormat:@"%@",@(5*60)]]; }]; ZCAlertAction *action3 = [ZCAlertAction actionWithTitle:@"禁言10分钟" andblock:^{ @strongify(self); [self youpaifoutRoomOrDisableMessageWithType:@"mute" userId:userId timer:[NSString stringWithFormat:@"%@",@(10*60)]]; }]; ZCAlertAction *action4 = [ZCAlertAction actionWithTitle:@"禁言30分钟" andblock:^{ @strongify(self); [self youpaifoutRoomOrDisableMessageWithType:@"mute" userId:userId timer:[NSString stringWithFormat:@"%@",@(30*60)]]; }]; ZCAlertAction *action5 = [ZCAlertAction actionWithTitle:@"禁言60分钟" andblock:^{ @strongify(self); [self youpaifoutRoomOrDisableMessageWithType:@"mute" userId:userId timer:[NSString stringWithFormat:@"%@",@(60*60)]]; }]; ZCAlertAction *action6 = [ZCAlertAction actionWithTitle:@"禁言90分钟" andblock:^{ @strongify(self); [self youpaifoutRoomOrDisableMessageWithType:@"mute" userId:userId timer:[NSString stringWithFormat:@"%@",@(90*60)]]; }]; ZCAlertSheetView* alertSheet = [[ZCAlertSheetView alloc]initWithTitle:nil andShowCancelButton:NO andAction:@[action1,action2,action3,action4,action5,action6]]; alertSheet.alertWindow.hidden = NO; [alertSheet show]; } // 禁言&解除禁言 踢人 - (void)youpaifoutRoomOrDisableMessageWithType:(NSString *)type userId:(NSString *)userId timer:(NSString *)tiemr{ [LCHttpHelper requestWithURLString:ForbidUser parameters:@{@"room_id":self.youpaipchatroomModel.youpaiproom_id,@"time":tiemr,@"type":type,@"op_uid":userId} needToken:YES type:(HttpRequestTypePost) success:^(id responseObject) { NSDictionary* dict = (NSDictionary*)responseObject; NSInteger code = [[dict objectForKey:@"code"] integerValue]; if (code==0) {//成功 [ZCHUDHelper showTitle:@"操作成功"]; } } failure:^(NSError *error) { }]; } - (NSMutableArray *)youpaipgifts{// 礼物数据 if (!_youpaipgifts) { _youpaipgifts = [NSMutableArray array]; } return _youpaipgifts; } - (NSMutableArray *)youpaipgiftViews{// 礼物 if (!_youpaipgiftViews) { _youpaipgiftViews = [NSMutableArray array]; } return _youpaipgiftViews; } - (NSMutableArray *)youpaipsvgas{ if (!_youpaipsvgas) { _youpaipsvgas = [NSMutableArray array]; } return _youpaipsvgas; } @end