YOUPAILZChatRoomVC.m 88 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651
  1. //
  2. // YOUPAILZChatRoomVC.m
  3. // VQU
  4. //
  5. // Created by CY on 2021/10/25.
  6. // Copyright © 2021 MS. All rights reserved.
  7. //
  8. #import "YOUPAILZChatRoomVC.h"
  9. #import "UIViewController+TFPresent.h"
  10. #import "YOUPAILZChatRoomReloadSeatAttachment.h"
  11. #import "YOUPAILZChatRoomInviactionUpSeatAttachment.h"
  12. #import "YOUPAILZChatRoomApplySeatAttachment.h"
  13. #import "LZAlertWindow.h"
  14. #import "YOUPAILCIMSessionVC.h"
  15. #import "YOUPAILZChatRoomInviationUpSeatListWindow.h"
  16. #import "YOUPAILZChatRoomSeatInlineWindow.h"
  17. #import "YOUPAILZChatRoomUpSeatApplyWindow.h"
  18. #import "YOUPAILZChatRoomSelectedSeatWindow.h"
  19. #import "YOUPAILZLiveRankAttachment.h"
  20. #import "YOUPAILZLiveVipBarrageAttachment.h"
  21. #import "YOUPAILZLiveCarAttachment.h"
  22. #import <SVGAPlayer.h>
  23. #import <SVGAParser.h>
  24. #import "UIView+YOUPAIRCDDanmaku.h"
  25. #import "YOUPAIRCDDanmaku.h"
  26. #import "YOUPAIRCDDanmakuManager.h"
  27. #import "YOUPAILZLiveBarrageTool.h"
  28. #import "NIMMessageMaker.h"
  29. #import "YOUPAILZChatRoomModeUpdateAttrchment.h"
  30. #import "YOUPAILZChatRoomEmptyChatAttachment.h"
  31. #import "YOUPAILZChatRoomCloseOpenChatAttachment.h"
  32. #import "YOUPAILZChatRoomInfoEditNoticeAttachment.h"
  33. #import "YOUPAILZChatRoomInfoEditTitleAttachment.h"
  34. #import "YOUPAILZChatRoomInfoEditPasswordAttachment.h"
  35. #import "YOUPAILZLiveManageAttachment.h"
  36. #import "YOUPAILZChatRoomEmojiAttachment.h"
  37. #import "YOUPAILZChatRoomGiftAttachment.h"
  38. #import "YOUPAILZChatRoomEndAttachment.h"
  39. #import "YOUPAILZGuardAttachment.h"
  40. #import "YOUPAILZChatRoomTransferPlayAttachment.h"
  41. #import "YOUPAILZChatRoomBlindDateProgressChangeAttachment.h"
  42. #import "YOUPAILZChatRoomBlindDateSelectedAttrchment.h"
  43. #import "YOUPAILZChatRoomBlindDateAnimationAttachment.h"
  44. #import "YOUPAILZChatRoomUpdatePowerAttachment.h"
  45. #import "YOUPAILZChatRoomGiftView.h"
  46. #import "YOUPAILZChatRoomBlindDataAnimationView.h"
  47. #import "YOUPAILZChatRoomBgImgAttachment.h"
  48. #import "YOUPAILZChatRoomCurrentMenberVC.h"
  49. //#import "LZChatRoomEmojiView.h"
  50. @interface YOUPAILZChatRoomVC ()<SVGAPlayerDelegate,LZChatRoomGiftViewDelegate>
  51. @property (nonatomic, strong) NSDate *youpaipjoinLiveMessageDate; /// 直播间加入消息时间
  52. @property (nonatomic, strong) YOUPAILZLiveCarAttachment *youpaipcarAttachment; // 直播间座驾动画
  53. @property (nonatomic, strong) SVGAPlayer *youpaipcarSvgaPlayer;
  54. @property (nonatomic, strong) SVGAParser *youpaipcarParser;
  55. @property (nonatomic, assign) BOOL youpaipisPlayCarSvga;
  56. @property (nonatomic, strong) NSMutableArray *youpaipgifts; // 礼物数据
  57. @property (nonatomic, strong) NSMutableArray <YOUPAILZChatRoomGiftView *>* youpaipgiftViews;// 礼物
  58. @property (nonatomic, strong) NSMutableArray *youpaipsvgas; /// svga礼物数据
  59. @property (nonatomic, strong) SVGAPlayer *youpaipsvgaPlayer;
  60. @property (nonatomic, strong) SVGAParser *youpaipparser;
  61. @property (nonatomic, assign) BOOL youpaipisPlaySvga;
  62. @property (nonatomic, assign) BOOL youpaipisBlindDataAnimation; /// 相亲动画
  63. @property (nonatomic, weak) YOUPAILZChatRoomBlindDataAnimationView *youpaipblindDataAnimationView;
  64. @end
  65. @implementation YOUPAILZChatRoomVC
  66. - (void)viewDidDisappear:(BOOL)animated{
  67. [super viewDidDisappear:animated];
  68. [self.view youpaifstopDanmaku];
  69. }
  70. - (void)viewDidLoad {
  71. [super viewDidLoad];
  72. self.view.clipsToBounds = YES;
  73. [self youpaifinitializeValue];
  74. [self youpaifinitSvga];
  75. [self youpaifjoinChatRoom];
  76. [self youpaifhandleAgoraEvent];
  77. [self youpaifinitBlindDataAnimationView];
  78. }
  79. /// 初始值
  80. - (void)youpaifinitializeValue{
  81. }
  82. /// svga init
  83. - (void)youpaifinitSvga{
  84. self.youpaipcarSvgaPlayer = [[SVGAPlayer alloc] initWithFrame:[UIScreen mainScreen].bounds];
  85. self.youpaipcarSvgaPlayer.contentMode = UIViewContentModeScaleAspectFit;
  86. self.youpaipcarSvgaPlayer.delegate = self;
  87. [self.view addSubview:self.youpaipcarSvgaPlayer];
  88. self.youpaipcarSvgaPlayer.hidden = YES;
  89. self.youpaipcarSvgaPlayer.loops = 1;
  90. self.youpaipcarSvgaPlayer.clearsAfterStop = true;
  91. self.youpaipcarParser = [[SVGAParser alloc] init];
  92. self.youpaipcarSvgaPlayer.userInteractionEnabled = NO;
  93. self.youpaipsvgaPlayer = [[SVGAPlayer alloc] initWithFrame:[UIScreen mainScreen].bounds];
  94. self.youpaipsvgaPlayer.contentMode = UIViewContentModeScaleAspectFit;
  95. self.youpaipsvgaPlayer.delegate = self;
  96. [self.view addSubview:self.youpaipsvgaPlayer];
  97. self.youpaipsvgaPlayer.hidden = YES;
  98. self.youpaipsvgaPlayer.loops = 1;
  99. self.youpaipsvgaPlayer.clearsAfterStop = true;
  100. self.youpaipparser = [[SVGAParser alloc] init];
  101. self.youpaipsvgaPlayer.userInteractionEnabled = NO;
  102. }
  103. - (void)youpaifinitBlindDataAnimationView{
  104. YOUPAILZChatRoomBlindDataAnimationView *youpaipblindDataAnimationView = [[YOUPAILZChatRoomBlindDataAnimationView alloc] initWithFrame:self.view.bounds];
  105. youpaipblindDataAnimationView.hidden = YES;
  106. youpaipblindDataAnimationView.userInteractionEnabled = NO;
  107. [self.view addSubview:youpaipblindDataAnimationView];
  108. self.youpaipblindDataAnimationView = youpaipblindDataAnimationView;
  109. @weakify(self);
  110. [youpaipblindDataAnimationView setAnimationFinishBlock:^{
  111. @strongify(self);
  112. self.youpaipisBlindDataAnimation = NO;
  113. self.youpaipblindDataAnimationView.hidden = YES;
  114. }];
  115. }
  116. /// 处理回调
  117. - (void)youpaifhandleAgoraEvent{
  118. @weakify(self);
  119. // 获取瞬时说话音量最高的几个用户(即说话者)的用户 ID、他们的音量及本地用户是否在说话。
  120. // speakers 为一个数组,包含说话者的用户 ID 、音量及本地用户人声状态。音量的取值范围为 [0, 255]。
  121. // totalVolume 指混音后频道内的总音量,取值范围为 [0, 255]。
  122. [[YOUPAILZChatRoomManager shareManager] setReportAudioVolumeIndicationOfSpeakersBlock:^(AgoraRtcEngineKit * _Nonnull engine, NSArray<AgoraRtcAudioVolumeInfo *> * _Nonnull speakers, NSInteger totalVolume) {
  123. @strongify(self);
  124. dispatch_async(dispatch_get_global_queue(0, 0), ^{
  125. @strongify(self);
  126. if (speakers.count == 0) {
  127. for (NSInteger i = 0; i < self.youpaipchatroomModel.youpaipnormalSeats.count + 1; i ++) {
  128. YOUPAILZChatRoomSeatModel *seatModel;
  129. if (i >= self.youpaipchatroomModel.youpaipnormalSeats.count) {
  130. seatModel = self.youpaipchatroomModel.youpaiphostSeat;
  131. }else{
  132. seatModel = self.youpaipchatroomModel.youpaipnormalSeats[i];
  133. }
  134. if (![seatModel.youpaipuserInfo.youpaipid isEqual:self.youpaipchatroomModel.youpaipuserInfo.youpaipid]) {
  135. seatModel.youpaipisTalking = NO;
  136. }
  137. }
  138. }else{
  139. for (NSInteger i = 0; i < speakers.count; i ++) {
  140. AgoraRtcAudioVolumeInfo *info = speakers[i];
  141. if (info.uid == 0) {
  142. self.youpaiplocalSeatModel.youpaipisTalking = info.vad == 1;
  143. }else{
  144. for (NSInteger i = 0; i < self.youpaipchatroomModel.youpaipnormalSeats.count + 1; i ++) {
  145. YOUPAILZChatRoomSeatModel *seatModel;
  146. if (i >= self.youpaipchatroomModel.youpaipnormalSeats.count) {
  147. seatModel = self.youpaipchatroomModel.youpaiphostSeat;
  148. }else{
  149. seatModel = self.youpaipchatroomModel.youpaipnormalSeats[i];
  150. }
  151. if ([[NSString stringWithFormat:@"%@",@(info.uid)] isEqual:seatModel.youpaipuserInfo.youpaipid]) {
  152. seatModel.youpaipisTalking = YES;
  153. }
  154. }
  155. }
  156. }
  157. }
  158. //通知主线程刷新
  159. dispatch_async(dispatch_get_main_queue(), ^{
  160. @strongify(self);
  161. [self youpaifreloadSeats];
  162. });
  163. });
  164. }];
  165. /// 收到消息回调
  166. [[YOUPAILZChatRoomManager shareManager] setOnRecvMessagesBlock:^(NSArray<NIMMessage *> * _Nonnull messages) {
  167. @strongify(self);
  168. /// 新消息处理
  169. NIMMessage *message = messages.firstObject;
  170. NIMSession *session = message.session;
  171. if (![session.sessionId isEqual:self.youpaipchatroomModel.youpaiproom_id] || !messages.count){
  172. return;
  173. }
  174. [self youpaifuiAddMessages:messages];
  175. }];
  176. /// 发送消息完成回调
  177. [[YOUPAILZChatRoomManager shareManager] setSendMessageSuccessBlock:^(NIMMessage * _Nonnull message, NSError * _Nonnull error) {
  178. @strongify(self);
  179. if (error == nil) {
  180. [self youpaifuiAddMessages:@[message]];
  181. }else if(error.code == 13004){
  182. [ZCHUDHelper showTitle:@"您已被禁言,不能发送消息"];
  183. }
  184. }];
  185. /// 房间前三点击回调
  186. [self.youpaipchatroomMemberView setYoupaipmemberAvatarBtnClickBlock:^(NSString * _Nonnull user_id) {
  187. @strongify(self);
  188. [self.youpaipkeyboardView resignFirstResponder];
  189. self.youpaipkeyboardView.hidden = YES;
  190. [self youpaifhandleUserOperationWithUserId:user_id];
  191. }];
  192. /// 房间人数点击回调
  193. [self.youpaipchatroomMemberView setYoupaipmemberCountBtnClickBlock:^{
  194. @strongify(self);
  195. [self.youpaipkeyboardView resignFirstResponder];
  196. self.youpaipkeyboardView.hidden = YES;
  197. YOUPAILZChatRoomCurrentMenberVC *window = [[YOUPAILZChatRoomCurrentMenberVC alloc] init];
  198. window.youpaipchatroomModel = self.youpaipchatroomModel;
  199. window.isTouchDismiss = YES;
  200. [window setYoupaipupseatBlock:^(YOUPAILZChatRoomMemberModel * _Nonnull model) {
  201. @strongify(self);
  202. [self youpaifshowSelectedSeatWindowWithUserId:model.youpaipid youpaipisInviation:YES];
  203. }];
  204. [window setYoupaiptouchUserBlock:^(NSString * _Nonnull userId) {
  205. @strongify(self);
  206. [self youpaifshowUserInfoWithUserId:userId];
  207. }];
  208. [self TFPresentVC:window completion:^{}];
  209. }];
  210. }
  211. /// 加入房间
  212. - (void)youpaifjoinChatRoom{
  213. @weakify(self);
  214. [[YOUPAILZChatRoomManager shareManager] youpaifjoinChannelById:self.youpaipchatroomModel.youpaiproom_id uid:[self.youpaipchatroomModel.youpaipuserInfo.youpaipid integerValue]];
  215. [[YOUPAILZChatRoomManager shareManager] youpaifjoinChatRoomById:self.youpaipchatroomModel.youpaiproom_id isComeinRoomHide:self.youpaipchatroomModel.youpaipis_comein_room_hide completion:^(NSError * _Nullable error, NIMChatroom * _Nullable chatroom, NIMChatroomMember * _Nullable me) {
  216. @strongify(self);
  217. [self youpaifreloadSeats];
  218. if (self.youpaipchatroomModel.youpaipis_fly_car == 1) {
  219. self.youpaipcarAttachment = self.youpaipchatroomModel.youpaipcar_data;
  220. [self youpaifstartPlayCarSvga];
  221. }
  222. if (self.youpaipchatroomModel.youpaipis_fly_noble == 1) {
  223. [self youpaifhandleVipBarrageAttachment:self.youpaipchatroomModel.youpaipb_box_data];
  224. }
  225. [self youpaifuiAddMessages:@[[self youpaifaddNoticeMessage]]];
  226. }];
  227. }
  228. /// 添加公告消息
  229. - (NIMMessage *)youpaifaddNoticeMessage{
  230. NIMMessage *imMessage = [NIMMessageMaker msgWithText:self.youpaipchatroomModel.youpaipnotice_text];
  231. return imMessage;
  232. }
  233. /// UI添加消息
  234. - (void)youpaifuiAddMessages:(NSArray<NIMMessage *> *)messages{
  235. NSArray *newMessages = [self youpaifdealMessage:messages];
  236. if (newMessages.count != 0) {
  237. [self.youpaipmessages insertObjects:newMessages atIndexes:[NSIndexSet indexSetWithIndexesInRange:NSMakeRange(0, newMessages.count)]];
  238. // [self.messages addObjectsFromArray:newMessages];
  239. NIMMessage *joinLiveMessage = nil;
  240. for (NSInteger i = 0; i < self.youpaipmessages.count; i ++) {
  241. NIMMessage *msg = self.youpaipmessages[i];
  242. if ([msg isKindOfClass:[NIMMessage class]]) {
  243. if (msg.session.sessionType == NIMSessionTypeChatroom
  244. && msg.messageType == NIMMessageTypeNotification){ /// 如果是聊天室并且消息类型为通知类型
  245. NIMNotificationObject *object = msg.messageObject;
  246. if (![object.content isKindOfClass:[NIMUnsupportedNotificationContent class]]) {
  247. NIMChatroomNotificationContent *content = (NIMChatroomNotificationContent *)object.content;
  248. if (content.eventType == NIMChatroomEventTypeEnter) { /// 有成员加入聊天室
  249. if (joinLiveMessage == nil) {
  250. joinLiveMessage = msg;
  251. }
  252. [self.youpaipmessages removeObject:msg];
  253. i --;
  254. }
  255. }
  256. }
  257. }
  258. }
  259. if (joinLiveMessage != nil) {
  260. [self.youpaipmessages insertObject:joinLiveMessage atIndex:0];
  261. // [self.messages addObject:joinLiveMessage];
  262. NSTimeInterval timeBetween = [[NSDate new] timeIntervalSinceDate:self.youpaipjoinLiveMessageDate];
  263. if (timeBetween >= 3.0f) {
  264. [self.youpaipmessages removeObject:joinLiveMessage];
  265. }
  266. // else{
  267. // [self performSelector:@selector(removeJoinLiveMessage:) withObject:joinLiveMessage afterDelay:3.0];
  268. // }
  269. }
  270. [self youpaifreloadTableView];
  271. }
  272. }
  273. - (void)youpaifreloadTableView{
  274. [self.youpaipmessageTableView reloadData];
  275. if (self.youpaipmessages.count != 0) {
  276. [self.youpaipmessageTableView scrollToRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:0] atScrollPosition:UITableViewScrollPositionBottom animated:YES];
  277. }
  278. }
  279. /// 聊天室消息处理
  280. - (NSArray *)youpaifdealMessage:(NSArray <NIMMessage *>*)messages{
  281. NSMutableArray *n_messages = [NSMutableArray array];
  282. /// 聊天室通知处理
  283. for (NIMMessage *message in messages) {
  284. if (message.from != nil) {
  285. [[[NIMSDK sharedSDK] userManager] fetchUserInfos:@[message.from] completion:^(NSArray<NIMUser *> * _Nullable users, NSError * _Nullable error) {
  286. // NIMUser* user = users[0];
  287. }];
  288. }
  289. if (message.session.sessionType == NIMSessionTypeChatroom
  290. && message.messageType == NIMMessageTypeNotification){ /// 如果是聊天室并且消息类型为通知类型
  291. NIMNotificationObject *object = message.messageObject;
  292. if (![object.content isKindOfClass:[NIMUnsupportedNotificationContent class]]) {
  293. NIMChatroomNotificationContent *content = (NIMChatroomNotificationContent *)object.content;
  294. NSString *fromId = nil;
  295. for (NIMChatroomNotificationMember *memebr in content.targets) {
  296. fromId = memebr.userId;
  297. }
  298. if (content.eventType == NIMChatroomEventTypeEnter) { /// 有成员加入聊天室
  299. // if (![message.from isEqual:self.youpaipchatroomModel.userInfo.id]) {
  300. NSData *jsonData = [content.notifyExt dataUsingEncoding:NSUTF8StringEncoding];
  301. if (jsonData != nil) {
  302. NSError *err;
  303. NSDictionary *dic = [NSJSONSerialization JSONObjectWithData:jsonData options:NSJSONReadingMutableContainers error:&err];
  304. if (!([dic.allKeys containsObject:@"is_comein_room_hide"] && [[dic objectForKey:@"is_comein_room_hide"] integerValue] == 1)) {
  305. [n_messages insertObject:message atIndex:0];
  306. self.youpaipjoinLiveMessageDate = [NSDate new];
  307. }
  308. }
  309. // }
  310. [self youpaifuploadChatRoomMemberCount];
  311. }else if(content.eventType == NIMChatroomEventTypeExit){ /// 有成员离开聊天室
  312. [self youpaifuploadChatRoomMemberCount];
  313. }
  314. else if(content.eventType == NIMChatroomEventTypeKicked){ /// 聊天室成员被踢
  315. [self youpaifuploadChatRoomMemberCount];
  316. }else if (content.eventType == NIMChatroomEventTypeAddMute){ // 成员被禁言
  317. if ([fromId isEqual:self.youpaipchatroomModel.youpaipuserInfo.youpaipid]) {
  318. [ZCHUDHelper showTitle:@"你被禁言"];
  319. }
  320. }else if (content.eventType == NIMChatroomEventTypeRemoveMute){ // 成员被取消禁言
  321. if ([fromId isEqual:self.youpaipchatroomModel.youpaipuserInfo.youpaipid]) {
  322. [ZCHUDHelper showTitle:@"你被取消禁言"];
  323. }
  324. }else if (content.eventType == NIMChatroomEventTypeAddMuteTemporarily){ // 聊天室成员被临时禁言
  325. if ([fromId isEqual:self.youpaipchatroomModel.youpaipuserInfo.youpaipid]) {
  326. [ZCHUDHelper showTitle:@"你被禁言"];
  327. }
  328. }else if (content.eventType == NIMChatroomEventTypeRemoveMuteTemporarily){ // 聊天室成员被解除临时禁言
  329. if ([fromId isEqual:self.youpaipchatroomModel.youpaipuserInfo.youpaipid]) {
  330. [ZCHUDHelper showTitle:@"你被取消禁言"];
  331. }
  332. }
  333. // }else if (content.eventType == NIMChatroomEventTypeAddManager){ // 设置为管理员
  334. // [n_messages insertObject:message atIndex:0];
  335. // [[YOUPAILZLiveManagerListUtils shared] youpaifreloadManagerListWithLiveId:self.liveModel.live_id];
  336. // if ([fromId isEqual:[LCSaveModel getUserModel].userinfo.user_id]) {
  337. // [ZCHUDHelper showTitle:@"你被设置为管理员"];
  338. // }
  339. // }else if (content.eventType == NIMChatroomEventTypeRemoveManager){ // 移除管理员
  340. // [n_messages insertObject:message atIndex:0];
  341. // [[YOUPAILZLiveManagerListUtils shared] youpaifreloadManagerListWithLiveId:self.liveModel.live_id];
  342. // if ([fromId isEqual:[LCSaveModel getUserModel].userinfo.user_id]) {
  343. // [ZCHUDHelper showTitle:@"你被取消设置为管理员"];
  344. // }
  345. // }
  346. }
  347. }else if (message.messageType == NIMMessageTypeText){ // 文本消息
  348. [n_messages insertObject:message atIndex:0];
  349. }else if(message.messageType == NIMMessageTypeCustom){ // 自定义消息
  350. NIMCustomObject *object = (NIMCustomObject*)message.messageObject;
  351. if ([object.attachment isKindOfClass:[YOUPAILZChatRoomReloadSeatAttachment class]]) { // 更新语聊房座位
  352. YOUPAILZChatRoomReloadSeatAttachment *attachment = (YOUPAILZChatRoomReloadSeatAttachment *)object.attachment;
  353. // 主持位
  354. YOUPAILZChatRoomSeatModel *hostSeatModel = [YOUPAILZChatRoomSeatModel mj_objectWithKeyValues:attachment.host];
  355. if ([hostSeatModel.youpaipuserInfo.youpaipid isEqual:self.youpaipchatroomModel.youpaiphostSeat.youpaipuserInfo.youpaipid]) {
  356. hostSeatModel.youpaipisEmoji = self.youpaipchatroomModel.youpaiphostSeat.youpaipisEmoji;
  357. hostSeatModel.youpaipemojiImg = self.youpaipchatroomModel.youpaiphostSeat.youpaipemojiImg;
  358. }
  359. self.youpaipchatroomModel.youpaiphostSeat = hostSeatModel;
  360. // 其他座位
  361. NSMutableArray *normalSeatModels = [YOUPAILZChatRoomSeatModel mj_objectArrayWithKeyValuesArray:attachment.normal];
  362. for (NSInteger i = 0; i < normalSeatModels.count; i ++) {
  363. YOUPAILZChatRoomSeatModel *oldSeatModel = self.youpaipchatroomModel.youpaipnormalSeats[i];
  364. YOUPAILZChatRoomSeatModel *newSeatModel = normalSeatModels[i];
  365. if ([oldSeatModel.youpaipuserInfo.youpaipid isEqual:newSeatModel.youpaipuserInfo.youpaipid]) {
  366. newSeatModel.youpaipisEmoji = oldSeatModel.youpaipisEmoji;
  367. newSeatModel.youpaipemojiImg = oldSeatModel.youpaipemojiImg;
  368. }
  369. }
  370. self.youpaipchatroomModel.youpaipnormalSeats = normalSeatModels;
  371. [self youpaifreloadSeats];
  372. }
  373. if ([object.attachment isKindOfClass:[YOUPAILZChatRoomInviactionUpSeatAttachment class]]) { // 邀请上麦
  374. YOUPAILZChatRoomInviactionUpSeatAttachment *attachment = (YOUPAILZChatRoomInviactionUpSeatAttachment *)object.attachment;
  375. [self youpaifinviactionUpSeatAlertWithAttachment:attachment];
  376. }
  377. if ([object.attachment isKindOfClass:[YOUPAILZChatRoomApplySeatAttachment class]]) { // 上麦申请 我要上麦 排麦中
  378. YOUPAILZChatRoomApplySeatAttachment *attachment = (YOUPAILZChatRoomApplySeatAttachment *)object.attachment;
  379. [self youpaifreloadApplySeatButtonWithAttachment:attachment];
  380. }
  381. if ([object.attachment isKindOfClass:[YOUPAILZChatRoomModeUpdateAttrchment class]]) { // 房间麦位模式
  382. YOUPAILZChatRoomModeUpdateAttrchment *attachment = (YOUPAILZChatRoomModeUpdateAttrchment *)object.attachment;
  383. self.youpaipchatroomModel.youpaiptalk_type = attachment.changeData[@"talk_type"];
  384. self.youpaipchatroomModel.youpaipsay_count = attachment.changeData[@"say_count"];
  385. self.youpaipapplySeatButton.youpaipmemberCount = [self.youpaipchatroomModel.youpaipsay_count integerValue];
  386. if (self.youpaipchatroomModel.youpaipuserInfo.youpaifroleType == LZUserRoleTypeWithNormal) {
  387. [self.youpaipapplySeatButton youpaifrleoadWithType:LZChatRoomApplySeatTypeWithUpSeat playType:self.youpaipchatroomModel.youpaipplayType];
  388. }
  389. if (self.youpaipchatroomModel.youpaipchatroomType == LZChatRoomTypeWithFree) {
  390. self.youpaipapplySeatButton.hidden = YES;
  391. }else{
  392. if (self.youpaipisCurrentUserUpSeat && self.youpaipchatroomModel.youpaipuserInfo.youpaifroleType == LZUserRoleTypeWithNormal) {
  393. self.youpaipapplySeatButton.hidden = YES;
  394. }else{
  395. self.youpaipapplySeatButton.hidden = NO;
  396. }
  397. }
  398. self.youpaipmoreModel.youpaipisSeatFree = self.youpaipchatroomModel.youpaipchatroomType == LZChatRoomTypeWithFree;
  399. [self.youpaipmoreWindow youpaifreloadData];
  400. }
  401. if ([object.attachment isKindOfClass:[YOUPAILZChatRoomEmptyChatAttachment class]]) { // 清空公屏
  402. YOUPAILZChatRoomEmptyChatAttachment *attachment = (YOUPAILZChatRoomEmptyChatAttachment *)object.attachment;
  403. [self.youpaipmessages removeAllObjects];
  404. [self youpaifuiAddMessages:@[[self youpaifaddEmptyChatMessage]]];
  405. }
  406. if ([object.attachment isKindOfClass:[YOUPAILZChatRoomCloseOpenChatAttachment class]]) { // 公屏开启or关闭
  407. YOUPAILZChatRoomCloseOpenChatAttachment *attachment = (YOUPAILZChatRoomCloseOpenChatAttachment *)object.attachment;
  408. self.youpaipchatroomModel.youpaiptalk_mute = [attachment.changeData[@"mute_status"] integerValue];
  409. self.youpaipmoreModel.youpaipisCloseChatMessage = self.youpaipchatroomModel.youpaiptalk_mute != 0; //是否关闭公屏
  410. [self.youpaipmoreWindow youpaifreloadData];
  411. if([attachment.change_type isEqual:@"remove_whole_forbid_words"]){
  412. [self youpaifuiAddMessages:@[[self youpaifaddOpenChatroomChat]]];
  413. }else{
  414. [self youpaifuiAddMessages:@[[self youpaifaddCloseChatroomChat]]];
  415. }
  416. }
  417. if ([object.attachment isKindOfClass:[YOUPAILZChatRoomInfoEditNoticeAttachment class]]) { // 房间信息公告修改
  418. YOUPAILZChatRoomInfoEditNoticeAttachment *attachment = (YOUPAILZChatRoomInfoEditNoticeAttachment *)object.attachment;
  419. self.youpaipchatroomModel.youpaiptalk_notice = attachment.changeData[@"notice"];
  420. }
  421. if ([object.attachment isKindOfClass:[YOUPAILZChatRoomInfoEditTitleAttachment class]]) { // 房间信息标题修改
  422. YOUPAILZChatRoomInfoEditTitleAttachment *attachment = (YOUPAILZChatRoomInfoEditTitleAttachment *)object.attachment;
  423. self.youpaipchatroomModel.youpaiproom_title = attachment.changeData[@"title"];
  424. self.youpaipchatroomInfoView.youpaiptitleL.text = self.youpaipchatroomModel.youpaiproom_title;
  425. // if (self.youpaipchatroomModel.room_title.length > 3) {
  426. // [self.youpaipchatroomInfoView.titleL marqueeOfSettingWithState:MarqueeStart_H];
  427. // }else{
  428. // [self.youpaipchatroomInfoView.titleL marqueeOfSettingWithState:MarqueeShutDown_H];
  429. // }
  430. }
  431. if ([object.attachment isKindOfClass:[YOUPAILZChatRoomInfoEditPasswordAttachment class]]) { // 房间信息密码修改
  432. YOUPAILZChatRoomInfoEditPasswordAttachment *attachment = (YOUPAILZChatRoomInfoEditPasswordAttachment *)object.attachment;
  433. self.youpaipchatroomModel.youpaiptalk_pwd = [attachment.changeData[@"is_pwd"] integerValue];
  434. self.youpaipmoreModel.youpaipisLock = self.youpaipchatroomModel.youpaiptalk_pwd == 1;
  435. [self.youpaipmoreWindow youpaifreloadData];
  436. }
  437. if ([object.attachment isKindOfClass:[YOUPAILZLiveManageAttachment class]]) { //移出房间
  438. YOUPAILZLiveManageAttachment *attachment = (YOUPAILZLiveManageAttachment*)object.attachment;
  439. if ([self.youpaipchatroomModel.youpaipuserInfo.youpaipid isEqual:attachment.forbidden_uid]) {
  440. self.youpaipisClose = YES;
  441. [ZCHUDHelper showTitle:attachment.user_des];
  442. [[YOUPAILZChatRoomManager shareManager] youpaifcloseChatRoom];
  443. }
  444. }
  445. if ([object.attachment isKindOfClass:[YOUPAILZChatRoomEndAttachment class]]) { //解散房间
  446. self.youpaipisClose = YES;
  447. [ZCHUDHelper showTitle:@"房间已被关闭"];
  448. [[YOUPAILZChatRoomManager shareManager] youpaifcloseChatRoom];
  449. }
  450. if ([object.attachment isKindOfClass:[YOUPAILZChatRoomEmojiAttachment class]]) { // 互动表情
  451. YOUPAILZChatRoomEmojiAttachment *attachment = (YOUPAILZChatRoomEmojiAttachment *)object.attachment;
  452. [self youpaifhandleEmojiWithAttachment:attachment];
  453. }
  454. if ([object.attachment isKindOfClass:[YOUPAILZChatRoomGiftAttachment class]]){ // 礼物
  455. YOUPAILZChatRoomGiftAttachment *attachment = (YOUPAILZChatRoomGiftAttachment *)object.attachment;
  456. for (NSInteger i = 0; i < attachment.receiveInfo.count; i ++) {
  457. NSDictionary *dict = attachment.receiveInfo[i];
  458. YOUPAILZLiveGIftModel *giftModel = [[YOUPAILZLiveGIftModel alloc] init];
  459. giftModel.youpaipavatar = attachment.from_avatar;
  460. giftModel.youpaipnickName = attachment.from_nickname;
  461. giftModel.youpaipgiftImage = attachment.gift_url;
  462. giftModel.youpaipgiftCount = attachment.gift_count;
  463. giftModel.youpaipuser_id = attachment.from_uid;
  464. giftModel.youpaipgift_id = attachment.gift_id;
  465. giftModel.youpaipgift_svga = attachment.gift_svga;
  466. giftModel.youpaipgift_type = attachment.gift_type;
  467. giftModel.youpaipto_uid = [[dict objectForKey:@"user_id"] integerValue];
  468. giftModel.youpaipto_nickName= [dict objectForKey:@"nickname"];
  469. if ([self.youpaipchatroomModel.youpaipuserInfo.youpaipid isEqual:message.from]) {
  470. [self.youpaipgifts insertObject:giftModel atIndex:0];
  471. }else{
  472. [self.youpaipgifts addObject:giftModel];
  473. }
  474. if (i == 0) {
  475. if (giftModel.youpaipgift_type == 1 && ![giftModel.youpaipgift_svga isEqualToString:@""]) {
  476. [self.youpaipsvgas addObject:giftModel];
  477. [self youpaifstartPlaySvga];
  478. }
  479. }
  480. YOUPAILZChatRoomGiftAttachment *gift_attachment = [[YOUPAILZChatRoomGiftAttachment alloc] init];
  481. gift_attachment.gift_id = attachment.gift_id;
  482. gift_attachment.gift_name = attachment.gift_name;
  483. gift_attachment.gift_count = attachment.gift_count;
  484. gift_attachment.gift_url = attachment.gift_url;
  485. gift_attachment.from_uid = attachment.from_uid;
  486. gift_attachment.to_uid = giftModel.youpaipto_uid;
  487. gift_attachment.to_nickname = giftModel.youpaipto_nickName;
  488. gift_attachment.roomid = attachment.roomid;
  489. gift_attachment.link_type = attachment.link_type;
  490. gift_attachment.link_url = attachment.link_url;
  491. gift_attachment.md5_string = attachment.md5_string;
  492. gift_attachment.gift_svga = attachment.gift_svga;
  493. gift_attachment.gift_type = attachment.gift_type;
  494. gift_attachment.from_nickname = attachment.from_nickname;
  495. gift_attachment.from_avatar = attachment.from_avatar;
  496. gift_attachment.send_gift_hide = attachment.send_gift_hide;
  497. gift_attachment.receiveInfo = attachment.receiveInfo;
  498. [n_messages insertObject:gift_attachment atIndex:0];
  499. }
  500. [self youpaifeditGiftView];
  501. }
  502. if ([object.attachment isKindOfClass:[YOUPAILZGuardAttachment class]]){ // 守护
  503. YOUPAILZGuardAttachment *attachment = (YOUPAILZGuardAttachment *)object.attachment;
  504. YOUPAILZChatRoomGiftAttachment *gift_attachment = [[YOUPAILZChatRoomGiftAttachment alloc] init];
  505. gift_attachment.gift_id = -1;
  506. gift_attachment.gift_name = attachment.guard_name;
  507. gift_attachment.gift_count = attachment.guard_count;
  508. gift_attachment.gift_url = attachment.guard_url;
  509. gift_attachment.from_uid = attachment.from_uid;
  510. gift_attachment.to_uid = attachment.to_uid;
  511. gift_attachment.to_nickname = attachment.to_nickname;
  512. gift_attachment.roomid = attachment.roomid;
  513. gift_attachment.link_type = attachment.link_type;
  514. gift_attachment.link_url = attachment.link_url;
  515. gift_attachment.md5_string = attachment.md5_string;
  516. gift_attachment.gift_svga = attachment.gift_svga;
  517. gift_attachment.gift_type = attachment.gift_type;
  518. gift_attachment.from_nickname = attachment.from_nickname;
  519. gift_attachment.from_avatar = attachment.from_avatar;
  520. gift_attachment.send_gift_hide = 0;
  521. [n_messages insertObject:gift_attachment atIndex:0];
  522. YOUPAILZLiveGIftModel *giftModel = [[YOUPAILZLiveGIftModel alloc] init];
  523. giftModel.youpaipavatar = attachment.from_avatar;
  524. giftModel.youpaipnickName = attachment.from_nickname;
  525. giftModel.youpaipgiftImage = attachment.guard_url;
  526. giftModel.youpaipgiftCount = attachment.guard_count;
  527. giftModel.youpaipuser_id = attachment.from_uid;
  528. giftModel.youpaipgift_id = -1;
  529. giftModel.youpaipgift_svga = attachment.gift_svga;
  530. giftModel.youpaipgift_type = attachment.gift_type;
  531. giftModel.youpaipto_uid = attachment.to_uid;
  532. giftModel.youpaipto_nickName = attachment.to_nickname;
  533. [self.youpaipsvgas addObject:giftModel];
  534. [self youpaifstartPlaySvga];
  535. }
  536. if ([object.attachment isKindOfClass:[YOUPAILZLiveRankAttachment class]]) { //排行信息
  537. YOUPAILZLiveRankAttachment *attachment = (YOUPAILZLiveRankAttachment*)object.attachment;
  538. self.youpaipchatroomModel.youpaiplive_top_three = [LZLiveTopThreeModel mj_objectArrayWithKeyValuesArray:attachment.rank];
  539. [self.youpaipchatroomMemberView youpaifreloadWithMemberList:self.youpaipchatroomModel.youpaiplive_top_three];
  540. }
  541. if ([object.attachment isKindOfClass:[YOUPAILZLiveVipBarrageAttachment class]]) { //VIP弹幕信息
  542. if (![message.from isEqual:[LCSaveModel getUserModel].youpaipuserinfo.youpaipuser_id]) {
  543. YOUPAILZLiveVipBarrageAttachment *attachment = (YOUPAILZLiveVipBarrageAttachment*)object.attachment;
  544. [self youpaifhandleVipBarrageAttachment:attachment];
  545. }
  546. }
  547. if ([object.attachment isKindOfClass:[YOUPAILZLiveCarAttachment class]]) { //座驾
  548. YOUPAILZLiveCarAttachment *attachment = (YOUPAILZLiveCarAttachment*)object.attachment;
  549. self.youpaipcarAttachment = attachment;
  550. [self youpaifstartPlayCarSvga];
  551. }
  552. if ([object.attachment isKindOfClass:[YOUPAILZChatRoomTransferPlayAttachment class]]) { /// 切换房间玩法
  553. YOUPAILZChatRoomTransferPlayAttachment *attachment = (YOUPAILZChatRoomTransferPlayAttachment*)object.attachment;
  554. self.youpaipchatroomModel.youpaiptalk_played = attachment.type;
  555. self.youpaipchatroomModel.youpaiptalk_played_status = [YOUPAILZChatRoomTalkPlayedStatusModel mj_objectArrayWithKeyValuesArray:attachment.blind_status];
  556. [self.youpaipmoreWindow youpaifreloadData];
  557. [self youpaifreloadPlayTypeUI];
  558. if (self.presentedViewController != nil) {
  559. NSArray *vcClas = @[NSClassFromString(@"YOUPAILZChatRoomSelectedSeatWindow"),NSClassFromString(@"YOUPAILZChatRoomUpSeatApplyWindow"),NSClassFromString(@"YOUPAILZBlindDateSelectWindow")];
  560. if ([vcClas containsObject:self.presentedViewController.class]) {
  561. [self.presentedViewController dismissViewControllerAnimated:YES completion:^{}];
  562. }
  563. }
  564. }
  565. if ([object.attachment isKindOfClass:[YOUPAILZChatRoomBlindDateProgressChangeAttachment class]]) { /// 相亲玩法进度更变
  566. YOUPAILZChatRoomBlindDateProgressChangeAttachment *attachment = (YOUPAILZChatRoomBlindDateProgressChangeAttachment*)object.attachment;
  567. self.youpaipchatroomModel.youpaiptalk_played_status = [YOUPAILZChatRoomTalkPlayedStatusModel mj_objectArrayWithKeyValuesArray:attachment.blind_data_change];
  568. [self youpaifsetupBlindDateProgressData];
  569. }
  570. if ([object.attachment isKindOfClass:[YOUPAILZChatRoomBlindDateSelectedAttrchment class]]) { /// 选择相亲对象
  571. if (self.youpaiplocalSeatModel != nil && ![self.youpaipchatroomModel.youpaiphostSeat.youpaipuserInfo.youpaipid isEqual:self.youpaipchatroomModel.youpaipuserInfo.youpaipid] ) {
  572. [self youpaifshowBlindDateSelectWindow];
  573. }
  574. }
  575. if ([object.attachment isKindOfClass:[YOUPAILZChatRoomBlindDateAnimationAttachment class]]) { /// 相亲动画
  576. YOUPAILZChatRoomBlindDateAnimationAttachment *attachment = (YOUPAILZChatRoomBlindDateAnimationAttachment*)object.attachment;
  577. if (attachment.select_data.count != 0) {
  578. self.youpaipsvgaPlayer.hidden = YES;
  579. self.youpaipisBlindDataAnimation = YES;
  580. self.youpaipblindDataAnimationView.hidden = NO;
  581. [self.youpaipblindDataAnimationView youpaifreloadWithModels:[YOUPAILZChatRoomBlindDataAnimationModel mj_objectArrayWithKeyValuesArray:attachment.select_data]];
  582. }
  583. }
  584. if ([object.attachment isKindOfClass:[YOUPAILZChatRoomBgImgAttachment class]]) { /// 背景
  585. YOUPAILZChatRoomBgImgAttachment *attachment = (YOUPAILZChatRoomBgImgAttachment*)object.attachment;
  586. self.youpaipchatroomModel.youpaipbg_img = attachment.bg;
  587. [self youpaifsetupBgImage];
  588. }
  589. if ([object.attachment isKindOfClass:[YOUPAILZChatRoomUpdatePowerAttachment class]]) { /// 修改权限
  590. YOUPAILZChatRoomUpdatePowerAttachment *attachment = (YOUPAILZChatRoomUpdatePowerAttachment*)object.attachment;
  591. if ([attachment.uid isEqual:self.youpaipchatroomModel.youpaipuserInfo.youpaipid]) {
  592. self.youpaipchatroomModel.youpaipuserInfo.youpaipidentity = attachment.identity;
  593. }
  594. if ([[YOUPAILZChatRoomManager shareManager].chatroomModel.youpaipmanagers.allKeys containsObject:attachment.uid]) {
  595. NSMutableDictionary *managerListDict = [YOUPAILZChatRoomManager shareManager].chatroomModel.youpaipmanagers.mutableCopy;
  596. NSMutableDictionary *managerDict = [[[YOUPAILZChatRoomManager shareManager].chatroomModel.youpaipmanagers objectForKey:attachment.uid] mutableCopy];
  597. [managerDict setObject:attachment.identity forKey:@"identity"];
  598. [managerListDict setObject:managerDict forKey:attachment.uid];
  599. [YOUPAILZChatRoomManager shareManager].chatroomModel.youpaipmanagers = managerListDict.copy;
  600. }
  601. }
  602. }
  603. }
  604. return n_messages.copy;
  605. }
  606. /// 处理互动表情
  607. - (void)youpaifhandleEmojiWithAttachment:(YOUPAILZChatRoomEmojiAttachment *)attachment{
  608. NSInteger seatIndex = -999;
  609. YOUPAILZChatRoomSeatModel *seatModel = nil;
  610. if ([self.youpaipchatroomModel.youpaiphostSeat.youpaipuserInfo.youpaipid isEqual:attachment.from_uid]) {
  611. seatModel = [YOUPAILZChatRoomSeatModel mj_objectWithKeyValues:[self.youpaipchatroomModel.youpaiphostSeat mj_keyValues]];
  612. seatIndex = -1;
  613. }
  614. for (NSInteger i = 0; i < self.youpaipchatroomModel.youpaipnormalSeats.count; i ++) {
  615. YOUPAILZChatRoomSeatModel *f_seatModel = self.youpaipchatroomModel.youpaipnormalSeats[i];
  616. if ([f_seatModel.youpaipuserInfo.youpaipid isEqual:attachment.from_uid]) {
  617. seatModel = [YOUPAILZChatRoomSeatModel mj_objectWithKeyValues:[f_seatModel mj_keyValues]];
  618. seatIndex = i;
  619. break;
  620. }
  621. }
  622. if (seatModel != nil) {
  623. seatModel.youpaipisEmoji = YES;
  624. seatModel.youpaipemojiImg = attachment.img;
  625. if ([self.youpaiplocalSeatModel.youpaipuserInfo.youpaipid isEqual:seatModel.youpaipuserInfo.youpaipid]) {
  626. self.youpaiplocalSeatModel = seatModel;
  627. }
  628. if (seatIndex == -1) {
  629. self.youpaipchatroomModel.youpaiphostSeat = seatModel;
  630. self.youpaiphostSeatView.youpaipmodel = seatModel;
  631. }else{
  632. self.youpaipchatroomModel.youpaipnormalSeats[seatIndex] = seatModel;
  633. YOUPAILZChatRoomOthearSeatCell *cell = (YOUPAILZChatRoomOthearSeatCell *)[self.youpaipotherSeatCollectionView cellForItemAtIndexPath:[NSIndexPath indexPathForItem:seatIndex inSection:0]];
  634. cell.youpaipseatView.youpaipmodel = self.youpaipchatroomModel.youpaipnormalSeats[seatIndex];
  635. }
  636. }
  637. }
  638. /// 处理礼物
  639. - (void)youpaifeditGiftView{
  640. NSInteger maxCount = 2;
  641. NSInteger count = maxCount - self.youpaipgiftViews.count;
  642. if (count > self.youpaipgifts.count) {
  643. count = self.youpaipgifts.count;
  644. }
  645. if (count <= 0) {
  646. NSMutableArray *tempGifts = [NSMutableArray array];
  647. for (NSInteger i = 0; i < self.youpaipgiftViews.count; i ++) {
  648. if (self.youpaipgifts.count <= 0) {
  649. return;
  650. }
  651. YOUPAILZLiveGIftModel *giftModel = nil;
  652. if (self.youpaipgifts.count - 1 < i) {
  653. giftModel = self.youpaipgifts[self.youpaipgifts.count - 1];
  654. }else{
  655. giftModel = self.youpaipgifts[i];
  656. }
  657. YOUPAILZChatRoomGiftView *giftView = nil;
  658. for (YOUPAILZChatRoomGiftView *f_giftView in self.youpaipgiftViews) {
  659. 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) {
  660. giftView = f_giftView;
  661. break;
  662. }
  663. }
  664. if (giftView != nil) {
  665. // i --;
  666. [giftView youpaifupdateGiftCount:giftModel.youpaipgiftCount];
  667. // [self.youpaipgifts removeObject:giftModel];
  668. [tempGifts addObject:giftModel];
  669. }
  670. }
  671. [self.youpaipgifts removeObjectsInArray:tempGifts];
  672. }else{
  673. NSMutableArray *tempGifts = [NSMutableArray array];
  674. for (NSInteger i = 0; i < count; i ++) {
  675. if (self.youpaipgifts.count <= 0) {
  676. return;
  677. }
  678. YOUPAILZLiveGIftModel *giftModel = nil;
  679. if (self.youpaipgifts.count - 1 < i) {
  680. giftModel = self.youpaipgifts[self.youpaipgifts.count - 1];
  681. }else{
  682. giftModel = self.youpaipgifts[i];
  683. }
  684. YOUPAILZChatRoomGiftView *giftView = nil;
  685. for (YOUPAILZChatRoomGiftView *f_giftView in self.youpaipgiftViews) {
  686. 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) {
  687. giftView = f_giftView;
  688. break;
  689. }
  690. }
  691. if (giftView != nil) {
  692. // i --;
  693. [giftView youpaifupdateGiftCount:giftModel.youpaipgiftCount];
  694. // [self.youpaipgifts removeObject:giftModel];
  695. [tempGifts addObject:giftModel];
  696. }else{
  697. YOUPAILZChatRoomGiftView *giftView = [[YOUPAILZChatRoomGiftView alloc] initWithModel:giftModel];
  698. [giftView addTarget:self action:@selector(youpaifgiftAnimationViewClick:) forControlEvents:UIControlEventTouchUpInside];
  699. NSInteger tag = 0;
  700. if (self.youpaipgiftViews.count == 1){
  701. if (self.youpaipgiftViews.lastObject.tag == 1) {
  702. tag = 0;
  703. }else{
  704. tag = 1;
  705. }
  706. }
  707. giftView.tag = tag;
  708. [self.view addSubview:giftView];
  709. [self.youpaipgiftViews addObject:giftView];
  710. if (giftView != nil) {
  711. UIView *view = self.youpaipgiftViews.lastObject;
  712. if (view != nil) {
  713. [giftView mas_makeConstraints:^(MASConstraintMaker *make) {
  714. make.left.offset(-200.0f);
  715. if (view.tag == 0) {
  716. make.bottom.equalTo(self.youpaipmessageTableView.mas_top).offset(-15.0f);
  717. }else{
  718. make.bottom.equalTo(self.youpaipmessageTableView.mas_top).offset(-30.0f-40.0f);
  719. }
  720. make.height.offset(40.0f);
  721. }];
  722. }
  723. }
  724. [giftView.superview layoutIfNeeded];
  725. [giftView youpaifshowAnimation];
  726. giftView.delegate = self;
  727. [tempGifts addObject:giftModel];
  728. // [self.youpaipgifts removeObject:giftModel];
  729. // i --;
  730. }
  731. }
  732. [self.youpaipgifts removeObjectsInArray:tempGifts];
  733. }
  734. }
  735. - (void)youpaifstartPlaySvga{
  736. if (self.youpaipisPlaySvga == NO && self.youpaipsvgas.count != 0) {
  737. self.youpaipisPlaySvga = YES;
  738. YOUPAILZLiveGIftModel* giftModel = self.youpaipsvgas[0];
  739. [self.youpaipsvgaPlayer stopAnimation];
  740. if (giftModel.youpaipgift_type == 1 && ![giftModel.youpaipgift_svga isEqualToString:@""] && !self.youpaipmoreModel.youpaipisCloseAnimation && !self.youpaipisBlindDataAnimation) {
  741. self.youpaipsvgaPlayer.hidden = NO;
  742. }
  743. NSString* svgaName = [[giftModel.youpaipgift_svga componentsSeparatedByString:@"/"] lastObject];
  744. NSString* svgaCanchesPath= [[NSString alloc]initWithFormat:@"%@/%@/%@",CachesPath,@"SVGA",svgaName];
  745. if (![LCTools giftSVGAWithSvgaUrlStr:giftModel.youpaipgift_svga]){
  746. NSString* urlStr = [NSString stringWithFormat:@"%@/%@",[LCSaveData getImageUrl]?[LCSaveData getImageUrl]:BaseImgUrl,giftModel.youpaipgift_svga];
  747. @weakify(self);
  748. [self.youpaipparser parseWithURLRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:urlStr]] completionBlock:^(SVGAVideoEntity * _Nullable videoItem) {
  749. @strongify(self);
  750. if (videoItem != nil) {
  751. self.youpaipsvgaPlayer.videoItem = videoItem;
  752. [self.youpaipsvgaPlayer startAnimation];
  753. }
  754. } failureBlock:^(NSError * _Nullable error) {
  755. @strongify(self);
  756. self.youpaipsvgaPlayer.hidden = YES;
  757. self.youpaipisPlaySvga = NO;
  758. [self youpaifstartPlaySvga];
  759. }];
  760. [LCTools giftSVGAWithSvgaUrlStr:giftModel.youpaipgift_svga];
  761. }else{
  762. @weakify(self);
  763. [self.youpaipparser parseWithData:[LCTools giftSVGAWithSvgaUrlStr:giftModel.youpaipgift_svga] cacheKey:svgaCanchesPath completionBlock:^(SVGAVideoEntity * _Nonnull videoItem) {
  764. @strongify(self);
  765. if (videoItem != nil) {
  766. self.youpaipsvgaPlayer.videoItem = videoItem;
  767. [self.youpaipsvgaPlayer startAnimation];
  768. }
  769. } failureBlock:^(NSError * _Nonnull error) {
  770. @strongify(self);
  771. self.youpaipsvgaPlayer.hidden = YES;
  772. self.youpaipisPlaySvga = NO;
  773. [self youpaifstartPlaySvga];
  774. }];
  775. }
  776. [self.youpaipsvgas removeObject:giftModel];
  777. }
  778. }
  779. /// 左边小礼物动画点击
  780. - (void)youpaifgiftAnimationViewClick:(YOUPAILZChatRoomGiftView *)sender{
  781. [self youpaifhandleUserOperationWithUserId:[NSString stringWithFormat:@"%@",@(sender.youpaipgiftModel.youpaipuser_id)]];
  782. }
  783. - (void)youpaifanimatiomFinishWithView:(YOUPAILZChatRoomGiftView *)liveGiftView{
  784. [self.youpaipgiftViews removeObject:liveGiftView];
  785. [liveGiftView removeFromSuperview];
  786. [self youpaifeditGiftView];
  787. }
  788. /// 添加清空公屏消息
  789. - (NIMMessage *)youpaifaddEmptyChatMessage{
  790. NIMMessage *imMessage = [NIMMessageMaker msgWithText:@"公屏消息被清空"];
  791. return imMessage;
  792. }
  793. /// 开启公屏消息
  794. - (NIMMessage *)youpaifaddOpenChatroomChat{
  795. NIMMessage *imMessage = [NIMMessageMaker msgWithText:@"公屏消息已开启"];
  796. return imMessage;
  797. }
  798. /// 关闭公屏消息
  799. - (NIMMessage *)youpaifaddCloseChatroomChat{
  800. NIMMessage *imMessage = [NIMMessageMaker msgWithText:@"公屏消息已关闭"];
  801. return imMessage;
  802. }
  803. /// 更新聊天室人员数
  804. - (void)youpaifuploadChatRoomMemberCount{
  805. @weakify(self);
  806. [[[NIMSDK sharedSDK] chatroomManager] fetchChatroomInfo:self.youpaipchatroomModel.youpaiproom_id completion:^(NSError * _Nullable error, NIMChatroom * _Nullable chatroom) {
  807. if (!error) {
  808. @strongify(self);
  809. self.youpaipchatroomMemberView.youpaipmemberL.text = [NSString stringWithFormat:@"%@",@(chatroom.onlineUserCount)];
  810. }
  811. }];
  812. }
  813. /// 处理VIP弹幕消息
  814. - (void)youpaifhandleVipBarrageAttachment:(YOUPAILZLiveVipBarrageAttachment *)barrageAttachment{
  815. YOUPAIRCDDanmaku *danmaku = [[YOUPAIRCDDanmaku alloc]init];
  816. danmaku.playView = [YOUPAILZLiveBarrageTool youpaifhandleVipBarrageAttachment:barrageAttachment];
  817. [self.view sendDanmaku:danmaku];
  818. }
  819. /// 开始座驾动画
  820. - (void)youpaifstartPlayCarSvga{
  821. if (self.youpaipisPlayCarSvga == NO && self.youpaipcarAttachment != nil) {
  822. self.youpaipisPlayCarSvga = YES;
  823. [self.youpaipcarSvgaPlayer stopAnimation];
  824. if (self.youpaipcarAttachment.car_big_preview_img_svga.length != 0 && !self.youpaipmoreModel.youpaipisCloseAnimation) {
  825. self.youpaipcarSvgaPlayer.hidden = NO;
  826. }
  827. NSString* svgaName = [[self.youpaipcarAttachment.car_big_preview_img_svga componentsSeparatedByString:@"/"] lastObject];
  828. NSString* svgaCanchesPath= [[NSString alloc]initWithFormat:@"%@/%@/%@",CachesPath,@"SVGA",svgaName];
  829. NSString *svgaPath =[svgaCanchesPath stringByAppendingPathComponent:svgaName];
  830. if (![[NSFileManager defaultManager] fileExistsAtPath:svgaPath]){
  831. NSString* urlStr = [NSString stringWithFormat:@"%@/%@",[LCSaveData getImageUrl]?[LCSaveData getImageUrl]:BaseImgUrl,self.youpaipcarAttachment.car_big_preview_img_svga];
  832. @weakify(self);
  833. [self.youpaipcarParser parseWithURLRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:urlStr]] completionBlock:^(SVGAVideoEntity * _Nullable videoItem) {
  834. @strongify(self);
  835. if (videoItem != nil) {
  836. self.youpaipcarSvgaPlayer.videoItem = videoItem;
  837. [self.youpaipcarSvgaPlayer startAnimation];
  838. }
  839. } failureBlock:^(NSError * _Nullable error) {
  840. @strongify(self);
  841. self.youpaipcarSvgaPlayer.hidden = YES;
  842. self.youpaipisPlayCarSvga = NO;
  843. [self youpaifstartPlayCarSvga];
  844. }];
  845. [LCTools giftSVGAWithSvgaUrlStr:self.youpaipcarAttachment.car_big_preview_img_svga];
  846. }else{
  847. @weakify(self);
  848. [self.youpaipcarParser parseWithData:[LCTools giftSVGAWithSvgaUrlStr:self.youpaipcarAttachment.car_big_preview_img_svga] cacheKey:svgaCanchesPath completionBlock:^(SVGAVideoEntity * _Nonnull videoItem) {
  849. @strongify(self);
  850. if (videoItem != nil) {
  851. self.youpaipcarSvgaPlayer.videoItem = videoItem;
  852. [self.youpaipcarSvgaPlayer startAnimation];
  853. }
  854. } failureBlock:^(NSError * _Nonnull error) {
  855. @strongify(self);
  856. self.youpaipcarSvgaPlayer.hidden = YES;
  857. self.youpaipisPlayCarSvga = NO;
  858. [self youpaifstartPlayCarSvga];
  859. }];
  860. }
  861. self.youpaipcarAttachment = nil;
  862. }
  863. }
  864. #pragma mark - SVGAPlayerDelegate
  865. - (void)svgaPlayerDidFinishedAnimation:(SVGAPlayer *)player{
  866. if (self.youpaipcarSvgaPlayer == player) {
  867. self.youpaipcarSvgaPlayer.hidden = YES;
  868. self.youpaipisPlayCarSvga = NO;
  869. [self youpaifstartPlayCarSvga];
  870. }else{
  871. self.youpaipsvgaPlayer.hidden = YES;
  872. self.youpaipisPlaySvga = NO;
  873. [self youpaifstartPlaySvga];
  874. }
  875. }
  876. /// 处理点击用户操作
  877. - (void)youpaifhandleUserOperationWithUserId:(NSString *)userId{
  878. YOUPAILZChatRoomSeatModel *f_seatModel = nil;
  879. NSInteger seatIndex = -999;
  880. if ([self.youpaipchatroomModel.youpaiphostSeat.youpaipuserInfo.youpaipid isEqual:userId]) {
  881. f_seatModel = self.youpaipchatroomModel.youpaiphostSeat;
  882. seatIndex = -1;
  883. }
  884. for (NSInteger i = 0; i < self.youpaipchatroomModel.youpaipnormalSeats.count; i ++) {
  885. YOUPAILZChatRoomSeatModel *seatModel = self.youpaipchatroomModel.youpaipnormalSeats[i];
  886. if ([seatModel.youpaipuserInfo.youpaipid isEqual:userId]) {
  887. f_seatModel = seatModel;
  888. seatIndex = i;
  889. break;
  890. }
  891. }
  892. if (f_seatModel != nil) {
  893. if ([userId isEqual:self.youpaipchatroomModel.youpaipuserInfo.youpaipid]) {
  894. NSMutableArray* actionArray = [NSMutableArray array];
  895. [actionArray addObject:[self youpaifuserInfoAlertActionWithUserId:userId]];
  896. [actionArray addObject:[self youpaifdownseatAlertAction]];
  897. ZCAlertSheetView* alertSheet = [[ZCAlertSheetView alloc]initWithTitle:nil andShowCancelButton:YES andAction:actionArray];
  898. alertSheet.alertWindow.hidden = NO;
  899. [alertSheet show];
  900. }else{
  901. if (self.youpaipchatroomModel.youpaipuserInfo.youpaifroleType == LZUserRoleTypeWithNormal) { // 普通用户显示用户资料
  902. [self youpaifshowUserInfoWithUserId:userId];
  903. }else{
  904. NIMChatroomMembersByIdsRequest *request = [[NIMChatroomMembersByIdsRequest alloc] init];
  905. request.roomId = self.youpaipchatroomModel.youpaiproom_id;
  906. request.userIds = @[userId];
  907. @weakify(self);
  908. [[[NIMSDK sharedSDK] chatroomManager] fetchChatroomMembersByIds:request completion:^(NSError * _Nullable error, NSArray<NIMChatroomMember *> * _Nullable members) {
  909. @strongify(self);
  910. BOOL youpaipisDisableMessage = NO;
  911. NIMChatroomMember *member = nil;
  912. if (members.count != 0) {
  913. member = members[0];
  914. if (member.isTempMuted) {
  915. youpaipisDisableMessage = YES;
  916. }
  917. }
  918. NSMutableArray *actionArray = [NSMutableArray array];
  919. if (f_seatModel == nil) {
  920. [actionArray addObject:[self youpaifuserInfoAlertActionWithUserId:userId]];
  921. [actionArray addObject:[self youpaifinvitationUpSeatAlertActionWithUserId:userId]];
  922. if (youpaipisDisableMessage) {
  923. [actionArray addObject:[self youpaifclearDisableSendMessageAlertActionWithUserID:userId nickname:member.roomNickname]];
  924. }else{
  925. [actionArray addObject:[self youpaifdisableSendMessageAlertActionWithUserID:userId]];
  926. }
  927. [actionArray addObject:[self youpaifgetOutRoomAlertActionWithUserID:userId]];
  928. }else{
  929. [actionArray addObject:[self youpaifuserInfoAlertActionWithUserId:userId]];
  930. if (self.youpaipchatroomModel.youpaipplayType == LZChatRoomPlayTypeWithCardiac) {
  931. [actionArray addObject:[self emptyLoveValueAlertActionWithUserID:userId]];
  932. }
  933. [actionArray addObject:[self youpaifforcedDownSeatAlertActionWithOperationUserId:f_seatModel.youpaipuserInfo.youpaipid]];
  934. if (f_seatModel.youpaipisDisableMicrophone) {
  935. [actionArray addObject:[self youpaifopenMisAlertActionWithSeatId:seatIndex]];
  936. }else{
  937. [actionArray addObject:[self youpaifdisableMisAlertActionWithSeatId:seatIndex]];
  938. }
  939. if (youpaipisDisableMessage) {
  940. [actionArray addObject:[self youpaifclearDisableSendMessageAlertActionWithUserID:userId nickname:member.roomNickname]];
  941. }else{
  942. [actionArray addObject:[self youpaifdisableSendMessageAlertActionWithUserID:userId]];
  943. }
  944. [actionArray addObject:[self youpaifgetOutRoomAlertActionWithUserID:userId]];
  945. }
  946. ZCAlertSheetView* alertSheet = [[ZCAlertSheetView alloc]initWithTitle:nil andShowCancelButton:YES andAction:actionArray];
  947. alertSheet.alertWindow.hidden = NO;
  948. [alertSheet show];
  949. }];
  950. }
  951. }
  952. }else{
  953. if ([userId isEqual:self.youpaipchatroomModel.youpaipuserInfo.youpaipid]) {
  954. [self youpaifshowUserInfoWithUserId:userId];
  955. }else{
  956. if (self.youpaipchatroomModel.youpaipuserInfo.youpaifroleType == LZUserRoleTypeWithNormal) { // 普通用户显示用户资料
  957. [self youpaifshowUserInfoWithUserId:userId];
  958. }else{
  959. NIMChatroomMembersByIdsRequest *request = [[NIMChatroomMembersByIdsRequest alloc] init];
  960. request.roomId = self.youpaipchatroomModel.youpaiproom_id;
  961. request.userIds = @[userId];
  962. @weakify(self);
  963. [[[NIMSDK sharedSDK] chatroomManager] fetchChatroomMembersByIds:request completion:^(NSError * _Nullable error, NSArray<NIMChatroomMember *> * _Nullable members) {
  964. @strongify(self);
  965. BOOL youpaipisDisableMessage = NO;
  966. NIMChatroomMember *member = nil;
  967. if (members.count != 0) {
  968. member = members[0];
  969. if (member.isTempMuted) {
  970. youpaipisDisableMessage = YES;
  971. }
  972. }
  973. NSMutableArray *actionArray = [NSMutableArray array];
  974. if (f_seatModel == nil) {
  975. [actionArray addObject:[self youpaifuserInfoAlertActionWithUserId:userId]];
  976. [actionArray addObject:[self youpaifinvitationUpSeatAlertActionWithUserId:userId]];
  977. if (youpaipisDisableMessage) {
  978. [actionArray addObject:[self youpaifclearDisableSendMessageAlertActionWithUserID:userId nickname:member.roomNickname]];
  979. }else{
  980. [actionArray addObject:[self youpaifdisableSendMessageAlertActionWithUserID:userId]];
  981. }
  982. [actionArray addObject:[self youpaifgetOutRoomAlertActionWithUserID:userId]];
  983. }else{
  984. [actionArray addObject:[self youpaifuserInfoAlertActionWithUserId:userId]];
  985. if (self.youpaipchatroomModel.youpaipplayType == LZChatRoomPlayTypeWithCardiac) {
  986. [actionArray addObject:[self emptyLoveValueAlertActionWithUserID:userId]];
  987. }
  988. [actionArray addObject:[self youpaifforcedDownSeatAlertActionWithOperationUserId:f_seatModel.youpaipuserInfo.youpaipid]];
  989. if (f_seatModel.youpaipisDisableMicrophone) {
  990. [actionArray addObject:[self youpaifopenMisAlertActionWithSeatId:seatIndex]];
  991. }else{
  992. [actionArray addObject:[self youpaifdisableMisAlertActionWithSeatId:seatIndex]];
  993. }
  994. if (youpaipisDisableMessage) {
  995. [actionArray addObject:[self youpaifclearDisableSendMessageAlertActionWithUserID:userId nickname:member.roomNickname]];
  996. }else{
  997. [actionArray addObject:[self youpaifdisableSendMessageAlertActionWithUserID:userId]];
  998. }
  999. [actionArray addObject:[self youpaifgetOutRoomAlertActionWithUserID:userId]];
  1000. }
  1001. ZCAlertSheetView* alertSheet = [[ZCAlertSheetView alloc]initWithTitle:nil andShowCancelButton:YES andAction:actionArray];
  1002. alertSheet.alertWindow.hidden = NO;
  1003. [alertSheet show];
  1004. }];
  1005. }
  1006. }
  1007. }
  1008. }
  1009. /// 被邀请上麦弹框
  1010. - (void)youpaifinviactionUpSeatAlertWithAttachment:(YOUPAILZChatRoomInviactionUpSeatAttachment *)attachment{
  1011. if([attachment.to_uid isEqual:self.youpaipchatroomModel.youpaipuserInfo.youpaipid]){
  1012. @weakify(self);
  1013. LZAlertAction *cancelAction = [LZAlertAction actionWithTitle:@"取消" handler:^(LZAlertAction *action) {
  1014. @strongify(self);
  1015. [self youpaifuserAgreeSeat:NO];
  1016. }];
  1017. cancelAction.cornerRadius = 24.0f;
  1018. cancelAction.bgColor = HexColorFromRGB(0x9F9DA5);
  1019. LZAlertAction *confimAction = [LZAlertAction actionWithTitle:@"上麦" handler:^(LZAlertAction *action) {
  1020. @strongify(self);
  1021. [self youpaifuserAgreeSeat:YES];
  1022. }];
  1023. confimAction.cornerRadius = 24.0f;
  1024. confimAction.bgColor = [UIColor colorWithPatternImage:[LCTools ColorImage:CGSizeMake((KScreenWidth - 105.0f) / 2.0f, 48.0f) FromColors:@[ZYGradientOneColor,ZYGradientTwoColor] ByGradientType:GradientLeftToRight]];
  1025. LZAlertWindow *alert = [LZAlertWindow alertWithTitle:@"上麦邀请" content:@"房主邀请你上麦一起聊,是否上麦?" action:@[cancelAction,confimAction]];
  1026. alert.contentTextAlignment = NSTextAlignmentCenter;
  1027. [self TFPresentVC:alert completion:^{}];
  1028. }
  1029. }
  1030. /// 用户同意&拒绝上麦
  1031. - (void)youpaifuserAgreeSeat:(BOOL)isAgree{
  1032. [LCHttpHelper requestWithURLString:UserAgreeSeat parameters:@{@"room_id":self.youpaipchatroomModel.youpaiproom_id,@"operate":isAgree ? @"1" : @"0"} needToken:YES type:(HttpRequestTypePost) success:^(id responseObject) {
  1033. } failure:^(NSError *error) {
  1034. }];
  1035. }
  1036. /// 点击主持位
  1037. - (void)youpaifhostSeatClick{
  1038. [self.youpaipkeyboardView resignFirstResponder];
  1039. self.youpaipkeyboardView.hidden = YES;
  1040. if (self.youpaipchatroomModel.youpaiphostSeat.youpaipseatState == LZChatRoomSeatStateWithFree) { // 主持位在空闲状态下
  1041. if (self.youpaipchatroomModel.youpaipuserInfo.youpaifroleType != LZUserRoleTypeWithNormal) {
  1042. [self youpaifuserUpSeatWithSeatId:-1];
  1043. }else{
  1044. [ZCHUDHelper showTitle:@"这是主持位"];
  1045. }
  1046. }else if(self.youpaipchatroomModel.youpaiphostSeat.youpaipseatState == LZChatRoomSeatStateWithBusy){ // 主持位有人状态下
  1047. if ([self.youpaipchatroomModel.youpaiphostSeat.youpaipuserInfo.youpaipid isEqual:self.youpaipchatroomModel.youpaipuserInfo.youpaipid]) { //自己操作
  1048. NSMutableArray* actionArray = [NSMutableArray array];
  1049. [actionArray addObject:[self youpaifuserInfoAlertActionWithUserId:self.youpaipchatroomModel.youpaiphostSeat.youpaipuserInfo.youpaipid]];
  1050. [actionArray addObject:[self youpaifdownseatAlertAction]];
  1051. ZCAlertSheetView* alertSheet = [[ZCAlertSheetView alloc]initWithTitle:nil andShowCancelButton:YES andAction:actionArray];
  1052. alertSheet.alertWindow.hidden = NO;
  1053. [alertSheet show];
  1054. }else{
  1055. if (self.youpaipchatroomModel.youpaipuserInfo.youpaifroleType != LZUserRoleTypeWithNormal) { // 如果当前用户角色小于等于主持位,并且自己不是普通用户
  1056. NIMChatroomMembersByIdsRequest *request = [[NIMChatroomMembersByIdsRequest alloc] init];
  1057. request.roomId = self.youpaipchatroomModel.youpaiproom_id;
  1058. request.userIds = @[self.youpaipchatroomModel.youpaiphostSeat.youpaipuserInfo.youpaipid];
  1059. @weakify(self);
  1060. [[[NIMSDK sharedSDK] chatroomManager] fetchChatroomMembersByIds:request completion:^(NSError * _Nullable error, NSArray<NIMChatroomMember *> * _Nullable members) {
  1061. @strongify(self);
  1062. BOOL youpaipisDisableMessage = NO;
  1063. NIMChatroomMember *member = nil;
  1064. if (members.count != 0) {
  1065. member = members[0];
  1066. if (member.isTempMuted) {
  1067. youpaipisDisableMessage = YES;
  1068. }
  1069. }
  1070. NSMutableArray *actionArray = [NSMutableArray array];
  1071. [actionArray addObject:[self youpaifuserInfoAlertActionWithUserId:self.youpaipchatroomModel.youpaiphostSeat.youpaipuserInfo.youpaipid]];
  1072. if (self.youpaipchatroomModel.youpaipplayType == LZChatRoomPlayTypeWithCardiac) {
  1073. [actionArray addObject:[self emptyLoveValueAlertActionWithUserID:self.youpaipchatroomModel.youpaiphostSeat.youpaipuserInfo.youpaipid]];
  1074. }
  1075. [actionArray addObject:[self youpaifforcedDownSeatAlertActionWithOperationUserId:self.youpaipchatroomModel.youpaiphostSeat.youpaipuserInfo.youpaipid]];
  1076. if (self.youpaipchatroomModel.youpaiphostSeat.youpaipisDisableMicrophone) {
  1077. [actionArray addObject:[self youpaifopenMisAlertActionWithSeatId:-1]];
  1078. }else{
  1079. [actionArray addObject:[self youpaifdisableMisAlertActionWithSeatId:-1]];
  1080. }
  1081. if (youpaipisDisableMessage) {
  1082. [actionArray addObject:[self youpaifclearDisableSendMessageAlertActionWithUserID:self.youpaipchatroomModel.youpaiphostSeat.youpaipuserInfo.youpaipid nickname:member.roomNickname]];
  1083. }else{
  1084. [actionArray addObject:[self youpaifdisableSendMessageAlertActionWithUserID:self.youpaipchatroomModel.youpaiphostSeat.youpaipuserInfo.youpaipid]];
  1085. }
  1086. [actionArray addObject:[self youpaifgetOutRoomAlertActionWithUserID:self.youpaipchatroomModel.youpaiphostSeat.youpaipuserInfo.youpaipid]];
  1087. ZCAlertSheetView* alertSheet = [[ZCAlertSheetView alloc]initWithTitle:nil andShowCancelButton:YES andAction:actionArray];
  1088. alertSheet.alertWindow.hidden = NO;
  1089. [alertSheet show];
  1090. }];
  1091. }else{ // 如果当前用户角色大于主持位 展示个人信息
  1092. [self youpaifshowUserInfoWithUserId:self.youpaipchatroomModel.youpaiphostSeat.youpaipuserInfo.youpaipid];
  1093. }
  1094. }
  1095. }
  1096. }
  1097. /// 点击其他麦位
  1098. - (void)youpaifotherSeatClickWithIndex:(NSInteger)index{
  1099. YOUPAILZChatRoomSeatModel *seatModel = self.youpaipchatroomModel.youpaipnormalSeats[index];
  1100. if (seatModel.youpaipseatState == LZChatRoomSeatStateWithFree) { // 麦位在空闲状态下
  1101. if (self.youpaipchatroomModel.youpaipuserInfo.youpaifroleType != LZUserRoleTypeWithNormal) {
  1102. NSMutableArray* actionArray = [NSMutableArray array];
  1103. [actionArray addObject:[self youpaifupseatAlertActionWithSeatId:index]];
  1104. [actionArray addObject:[self youpaifinvitationUpseatAlertActionWithSeatId:index]];
  1105. [actionArray addObject:[self youpaiflockSeatAlertActionWithSeatId:index]];
  1106. ZCAlertSheetView* alertSheet = [[ZCAlertSheetView alloc]initWithTitle:nil andShowCancelButton:YES andAction:actionArray];
  1107. alertSheet.alertWindow.hidden = NO;
  1108. [alertSheet show];
  1109. }else{
  1110. if (self.youpaipchatroomModel.youpaipchatroomType == LZChatRoomTypeWithFree) { // 自由麦序
  1111. [self youpaifuserUpSeatWithSeatId:index];
  1112. }else{ // 主持麦序
  1113. [self youpaifuserUpSeatWithSeatId:-999];
  1114. [self.youpaipapplySeatButton youpaifrleoadWithType:LZChatRoomApplySeatTypeWithInline playType:self.youpaipchatroomModel.youpaipplayType];
  1115. }
  1116. }
  1117. }else if(seatModel.youpaipseatState == LZChatRoomSeatStateWithBusy){ // 麦位有人状态下
  1118. if ([seatModel.youpaipuserInfo.youpaipid isEqual:self.youpaipchatroomModel.youpaipuserInfo.youpaipid]) { //自己操作
  1119. NSMutableArray *actionArray = [NSMutableArray array];
  1120. [actionArray addObject:[self youpaifuserInfoAlertActionWithUserId:seatModel.youpaipuserInfo.youpaipid]];
  1121. [actionArray addObject:[self youpaifdownseatAlertAction]];
  1122. ZCAlertSheetView* alertSheet = [[ZCAlertSheetView alloc]initWithTitle:nil andShowCancelButton:YES andAction:actionArray];
  1123. alertSheet.alertWindow.hidden = NO;
  1124. [alertSheet show];
  1125. }else{
  1126. if (self.youpaipchatroomModel.youpaipuserInfo.youpaifroleType != LZUserRoleTypeWithNormal) { // 如果当前用户角色小于等于麦位,并且自己不是普通用户
  1127. NIMChatroomMembersByIdsRequest *request = [[NIMChatroomMembersByIdsRequest alloc] init];
  1128. request.roomId = self.youpaipchatroomModel.youpaiproom_id;
  1129. request.userIds = @[seatModel.youpaipuserInfo.youpaipid];
  1130. @weakify(self);
  1131. [[[NIMSDK sharedSDK] chatroomManager] fetchChatroomMembersByIds:request completion:^(NSError * _Nullable error, NSArray<NIMChatroomMember *> * _Nullable members) {
  1132. @strongify(self);
  1133. BOOL youpaipisDisableMessage = NO;
  1134. NIMChatroomMember *member = nil;
  1135. if (members.count != 0) {
  1136. member = members[0];
  1137. if (member.isTempMuted) {
  1138. youpaipisDisableMessage = YES;
  1139. }
  1140. }
  1141. NSMutableArray *actionArray = [NSMutableArray array];
  1142. [actionArray addObject:[self youpaifuserInfoAlertActionWithUserId:seatModel.youpaipuserInfo.youpaipid]];
  1143. if (self.youpaipchatroomModel.youpaipplayType == LZChatRoomPlayTypeWithCardiac) {
  1144. [actionArray addObject:[self emptyLoveValueAlertActionWithUserID:seatModel.youpaipuserInfo.youpaipid]];
  1145. }
  1146. [actionArray addObject:[self youpaifforcedDownSeatAlertActionWithOperationUserId:seatModel.youpaipuserInfo.youpaipid]];
  1147. if (seatModel.youpaipisDisableMicrophone) {
  1148. [actionArray addObject:[self youpaifopenMisAlertActionWithSeatId:index]];
  1149. }else{
  1150. [actionArray addObject:[self youpaifdisableMisAlertActionWithSeatId:index]];
  1151. }
  1152. if (youpaipisDisableMessage) {
  1153. [actionArray addObject:[self youpaifclearDisableSendMessageAlertActionWithUserID:seatModel.youpaipuserInfo.youpaipid nickname:member.roomNickname]];
  1154. }else{
  1155. [actionArray addObject:[self youpaifdisableSendMessageAlertActionWithUserID:seatModel.youpaipuserInfo.youpaipid]];
  1156. }
  1157. [actionArray addObject:[self youpaifgetOutRoomAlertActionWithUserID:seatModel.youpaipuserInfo.youpaipid]];
  1158. ZCAlertSheetView* alertSheet = [[ZCAlertSheetView alloc]initWithTitle:nil andShowCancelButton:YES andAction:actionArray];
  1159. alertSheet.alertWindow.hidden = NO;
  1160. [alertSheet show];
  1161. }];
  1162. }else{ // 如果当前用户角色大于主持位 展示个人信息
  1163. [self youpaifshowUserInfoWithUserId:seatModel.youpaipuserInfo.youpaipid];
  1164. }
  1165. }
  1166. }else if(seatModel.youpaipseatState == LZChatRoomSeatStateWithLock){ // 麦位锁定状态下
  1167. if (self.youpaipchatroomModel.youpaipuserInfo.youpaifroleType != LZUserRoleTypeWithNormal) {
  1168. NSMutableArray* actionArray = [NSMutableArray array];
  1169. [actionArray addObject:[self youpaifunlockSeatAlertActionWithIndex:index]];
  1170. ZCAlertSheetView* alertSheet = [[ZCAlertSheetView alloc]initWithTitle:nil andShowCancelButton:YES andAction:actionArray];
  1171. alertSheet.alertWindow.hidden = NO;
  1172. [alertSheet show];
  1173. }else{
  1174. [ZCHUDHelper showTitle:@"该麦位已被锁定,无法申请上麦"];
  1175. }
  1176. }
  1177. }
  1178. /// 上麦处理按钮事件
  1179. - (void)youpaifapplySeatButtonClick{
  1180. switch (self.youpaipapplySeatButton.youpaiptype) {
  1181. case LZChatRoomApplySeatTypeWithUpSeat:{
  1182. [self youpaifuserUpSeatWithSeatId:-999];
  1183. [self.youpaipapplySeatButton youpaifrleoadWithType:LZChatRoomApplySeatTypeWithInline playType:self.youpaipchatroomModel.youpaipplayType];
  1184. }
  1185. break;
  1186. case LZChatRoomApplySeatTypeWithInline:{
  1187. [self youpaifshowSeatInlineWindow];
  1188. }
  1189. break;
  1190. case LZChatRoomApplySeatTypeWithApplyList:{
  1191. [self youpaifshowUpSeatApplyWindow];
  1192. }
  1193. break;
  1194. default:
  1195. break;
  1196. }
  1197. }
  1198. - (void)youpaifreloadApplySeatButtonWithAttachment:(YOUPAILZChatRoomApplySeatAttachment *)attachment{
  1199. self.youpaipchatroomModel.youpaipsay_count = attachment.num;
  1200. self.youpaipapplySeatButton.youpaipmemberCount = [self.youpaipchatroomModel.youpaipsay_count integerValue];
  1201. if ([attachment.op_uid isEqual:self.youpaipchatroomModel.youpaipuserInfo.youpaipid]) {
  1202. //0、拒绝,1、同意,2、用户申请
  1203. if ([attachment.status isEqual:@"0"]) {
  1204. [self.youpaipapplySeatButton youpaifrleoadWithType:LZChatRoomApplySeatTypeWithUpSeat playType:self.youpaipchatroomModel.youpaipplayType];
  1205. }else if ([attachment.status isEqual:@"1"]) {
  1206. self.youpaipapplySeatButton.hidden = YES;
  1207. [self.youpaipapplySeatButton youpaifrleoadWithType:LZChatRoomApplySeatTypeWithUpSeat playType:self.youpaipchatroomModel.youpaipplayType];
  1208. }
  1209. }
  1210. }
  1211. // 显示排麦中列表
  1212. - (void)youpaifshowSeatInlineWindow{
  1213. YOUPAILZChatRoomSeatInlineWindow *window = [[YOUPAILZChatRoomSeatInlineWindow alloc] init];
  1214. window.isTouchDismiss = YES;
  1215. window.youpaiproomId = self.youpaipchatroomModel.youpaiproom_id;
  1216. [self TFPresentVC:window completion:^{}];
  1217. }
  1218. // 显示上麦申请列表
  1219. - (void)youpaifshowUpSeatApplyWindow{
  1220. YOUPAILZChatRoomUpSeatApplyWindow *window = [[YOUPAILZChatRoomUpSeatApplyWindow alloc] init];
  1221. window.isTouchDismiss = YES;
  1222. window.youpaiproomId = self.youpaipchatroomModel.youpaiproom_id;
  1223. window.youpaipplayType = self.youpaipchatroomModel.youpaipplayType;
  1224. @weakify(self);
  1225. [window setYoupaipupseatBlock:^(YOUPAILZChatRoomMemberModel * _Nonnull model) {
  1226. @strongify(self);
  1227. [self youpaifshowSelectedSeatWindowWithUserId:model.youpaipid youpaipisInviation:NO];
  1228. }];
  1229. [self TFPresentVC:window completion:^{}];
  1230. }
  1231. // 显示选择座位
  1232. - (void)youpaifshowSelectedSeatWindowWithUserId:(NSString *)userId youpaipisInviation:(BOOL)youpaipisInviation{
  1233. YOUPAILZChatRoomSelectedSeatWindow *window = [[YOUPAILZChatRoomSelectedSeatWindow alloc] init];
  1234. window.youpaipoperationUserId = userId;
  1235. window.youpaiproomId = self.youpaipchatroomModel.youpaiproom_id;
  1236. window.youpaipisInviation = youpaipisInviation;
  1237. window.youpaipplayType = self.youpaipchatroomModel.youpaipplayType;
  1238. window.youpaipnormalSeatJsons = [YOUPAILZChatRoomSeatModel mj_keyValuesArrayWithObjectArray:self.youpaipchatroomModel.youpaipnormalSeats];
  1239. [self TFPresentVC:window completion:^{}];
  1240. }
  1241. /// 用户上麦
  1242. /// youpaipseatId 座位下标
  1243. /// -999 说明是申请上麦
  1244. /// -1 说明是主持麦位
  1245. /// 其他则是对应的麦位下标
  1246. - (void)youpaifuserUpSeatWithSeatId:(NSInteger)youpaipseatId{
  1247. NSString *seat = @"";
  1248. if (youpaipseatId != -999) {
  1249. seat = [NSString stringWithFormat:@"%@",@(youpaipseatId)];
  1250. }
  1251. [LCHttpHelper requestWithURLString:UserUpperWheat parameters:@{@"room_id":self.youpaipchatroomModel.youpaiproom_id,@"seat":seat} needToken:YES type:(HttpRequestTypePost) success:^(id responseObject) {
  1252. } failure:^(NSError *error) {
  1253. }];
  1254. }
  1255. /// 用户下麦
  1256. - (void)youpaifuserDownSeat{
  1257. [LCHttpHelper requestWithURLString:LowerSeats parameters:@{@"room_id":self.youpaipchatroomModel.youpaiproom_id} needToken:YES type:(HttpRequestTypePost) success:^(id responseObject) {
  1258. } failure:^(NSError *error) {
  1259. }];
  1260. }
  1261. /// 锁定座位
  1262. - (void)youpaiflockSeatWithSeatId:(NSInteger)youpaipseatId isLock:(BOOL)isLock{
  1263. NSInteger lock = isLock ? 1 : 0;
  1264. [LCHttpHelper requestWithURLString:LockSeates parameters:@{@"room_id":self.youpaipchatroomModel.youpaiproom_id,@"seat":@(youpaipseatId),@"type":@(lock)} needToken:YES type:(HttpRequestTypePost) success:^(id responseObject) {
  1265. } failure:^(NSError *error) {
  1266. }];
  1267. }
  1268. /// 抱下麦
  1269. - (void)youpaifforcedDownSeatWithOperationUserId:(NSString *)youpaipoperationUserId{
  1270. [LCHttpHelper requestWithURLString:LowerSeat parameters:@{@"room_id":self.youpaipchatroomModel.youpaiproom_id,@"op_uid":youpaipoperationUserId} needToken:YES type:(HttpRequestTypePost) success:^(id responseObject) {
  1271. } failure:^(NSError *error) {
  1272. }];
  1273. }
  1274. /// 闭麦
  1275. /// @param youpaipseatId 座位号
  1276. /// @param disable 是否禁止
  1277. - (void)youpaifdisableMisWithSeatId:(NSInteger)youpaipseatId disable:(BOOL)disable{
  1278. NSInteger type = disable ? 1 : 0;
  1279. [LCHttpHelper requestWithURLString:CloseAOpenSeatSay parameters:@{@"room_id":self.youpaipchatroomModel.youpaiproom_id,@"seat":@(youpaipseatId),@"type":@(type)} needToken:YES type:(HttpRequestTypePost) success:^(id responseObject) {
  1280. } failure:^(NSError *error) {
  1281. }];
  1282. }
  1283. // 个人资料
  1284. - (ZCAlertAction *)youpaifuserInfoAlertActionWithUserId:(NSString *)userId{
  1285. @weakify(self);
  1286. ZCAlertAction *action = [ZCAlertAction actionWithTitle:@"个人资料" andblock:^{
  1287. @strongify(self);
  1288. [self youpaifshowUserInfoWithUserId:userId];
  1289. }];
  1290. return action;
  1291. }
  1292. /// 展示邀请列表
  1293. - (void)youpaifshowInviationListWindowWithSeatId:(NSInteger)youpaipseatId{
  1294. YOUPAILZChatRoomInviationUpSeatListWindow *window = [[YOUPAILZChatRoomInviationUpSeatListWindow alloc] init];
  1295. window.isTouchDismiss = YES;
  1296. window.youpaipseatId = youpaipseatId;
  1297. window.youpaiproomId = self.youpaipchatroomModel.youpaiproom_id;
  1298. [self TFPresentVC:window completion:^{}];
  1299. }
  1300. // 上麦
  1301. - (ZCAlertAction *)youpaifupseatAlertActionWithSeatId:(NSInteger)youpaipseatId{
  1302. @weakify(self);
  1303. ZCAlertAction *action = [ZCAlertAction actionWithTitle:@"上麦" andblock:^{
  1304. @strongify(self);
  1305. [self youpaifuserUpSeatWithSeatId:youpaipseatId];
  1306. }];
  1307. return action;
  1308. }
  1309. // 下麦
  1310. - (ZCAlertAction *)youpaifdownseatAlertAction{
  1311. @weakify(self);
  1312. ZCAlertAction *action = [ZCAlertAction actionWithTitle:@"下麦" andblock:^{
  1313. @strongify(self);
  1314. [self youpaifuserDownSeat];
  1315. }];
  1316. return action;
  1317. }
  1318. // 邀请上麦
  1319. - (ZCAlertAction *)youpaifinvitationUpseatAlertActionWithSeatId:(NSInteger)youpaipseatId{
  1320. @weakify(self);
  1321. ZCAlertAction *action = [ZCAlertAction actionWithTitle:@"邀请上麦" andblock:^{
  1322. @strongify(self);
  1323. [self youpaifshowInviationListWindowWithSeatId:youpaipseatId];
  1324. }];
  1325. return action;
  1326. }
  1327. // 邀请上麦2
  1328. - (ZCAlertAction *)youpaifinvitationUpSeatAlertActionWithUserId:(NSString *)userId{
  1329. @weakify(self);
  1330. ZCAlertAction *action = [ZCAlertAction actionWithTitle:@"邀请上麦" andblock:^{
  1331. @strongify(self);
  1332. [self youpaifshowSelectedSeatWindowWithUserId:userId youpaipisInviation:YES];
  1333. }];
  1334. return action;
  1335. }
  1336. // 抱下麦
  1337. - (ZCAlertAction *)youpaifforcedDownSeatAlertActionWithOperationUserId:(NSString *)youpaipoperationUserId{
  1338. @weakify(self);
  1339. ZCAlertAction *action = [ZCAlertAction actionWithTitle:@"抱下麦" andblock:^{
  1340. @strongify(self);
  1341. [self youpaifforcedDownSeatWithOperationUserId:youpaipoperationUserId];
  1342. }];
  1343. return action;
  1344. }
  1345. // 锁定麦位
  1346. - (ZCAlertAction *)youpaiflockSeatAlertActionWithSeatId:(NSInteger)youpaipseatId{
  1347. @weakify(self);
  1348. ZCAlertAction *action = [ZCAlertAction actionWithTitle:@"锁定麦位" andblock:^{
  1349. @strongify(self);
  1350. [self youpaiflockSeatWithSeatId:youpaipseatId isLock:YES];
  1351. }];
  1352. return action;
  1353. }
  1354. // 解锁麦位
  1355. - (ZCAlertAction *)youpaifunlockSeatAlertActionWithIndex:(NSInteger)index{
  1356. @weakify(self);
  1357. ZCAlertAction *action = [ZCAlertAction actionWithTitle:@"解锁麦位" andblock:^{
  1358. @strongify(self);
  1359. [self youpaiflockSeatWithSeatId:index isLock:NO];
  1360. }];
  1361. return action;
  1362. }
  1363. // 闭麦
  1364. - (ZCAlertAction *)youpaifdisableMisAlertActionWithSeatId:(NSInteger)youpaipseatId{
  1365. @weakify(self);
  1366. ZCAlertAction *action = [ZCAlertAction actionWithTitle:@"闭麦" andblock:^{
  1367. @strongify(self);
  1368. [self youpaifdisableMisWithSeatId:youpaipseatId disable:YES];
  1369. }];
  1370. return action;
  1371. }
  1372. // 开麦
  1373. - (ZCAlertAction *)youpaifopenMisAlertActionWithSeatId:(NSInteger)youpaipseatId{
  1374. @weakify(self);
  1375. ZCAlertAction *action = [ZCAlertAction actionWithTitle:@"开麦" andblock:^{
  1376. @strongify(self);
  1377. [self youpaifdisableMisWithSeatId:youpaipseatId disable:NO];
  1378. }];
  1379. return action;
  1380. }
  1381. // 禁言
  1382. - (ZCAlertAction *)youpaifdisableSendMessageAlertActionWithUserID:(NSString *)userId{
  1383. @weakify(self);
  1384. ZCAlertAction *action = [ZCAlertAction actionWithTitle:@"禁言" andblock:^{
  1385. @strongify(self);
  1386. [self youpaifselectedDisableMessageTimerAlertUserId:userId];
  1387. }];
  1388. return action;
  1389. }
  1390. // 解除禁言
  1391. - (ZCAlertAction *)youpaifclearDisableSendMessageAlertActionWithUserID:(NSString *)userId nickname:(NSString *)nickname{
  1392. @weakify(self);
  1393. ZCAlertAction *action = [ZCAlertAction actionWithTitle:@"解除禁言" andblock:^{
  1394. @strongify(self);
  1395. ZCAlertAction *action1 = [ZCAlertAction actionWithTitle:@"确认解除" andblock:^{
  1396. @strongify(self);
  1397. [self youpaifoutRoomOrDisableMessageWithType:@"mute" userId:userId timer:@"0"];
  1398. }];
  1399. NSMutableAttributedString *str = [[NSMutableAttributedString alloc] initWithString:[NSString stringWithFormat:@"将解除 %@ 禁言状态",nickname]];
  1400. [str addAttribute:NSForegroundColorAttributeName value:HexColorFromRGB(0xFFDB80) range:NSMakeRange(4,nickname.length)];
  1401. ZCAlertSheetView* alertSheet = [[ZCAlertSheetView alloc]initWithAttrbuteTitle:str andShowCancelButton:YES andAction:@[action1]];
  1402. alertSheet.alertWindow.hidden = NO;
  1403. [alertSheet show];
  1404. }];
  1405. return action;
  1406. }
  1407. // 移出房间
  1408. - (ZCAlertAction *)youpaifgetOutRoomAlertActionWithUserID:(NSString *)userId{
  1409. @weakify(self);
  1410. ZCAlertAction *action = [ZCAlertAction actionWithTitle:@"移出房间" andblock:^{
  1411. @strongify(self);
  1412. [self youpaifselectedOutRoomTimerAlertUserID:userId];
  1413. }];
  1414. return action;
  1415. }
  1416. // 选择移出房间时间弹框
  1417. - (void)youpaifselectedOutRoomTimerAlertUserID:(NSString *)userId{
  1418. @weakify(self);
  1419. ZCAlertAction *action1 = [ZCAlertAction actionWithTitle:@"5分钟" andblock:^{
  1420. @strongify(self);
  1421. [self youpaifoutRoomOrDisableMessageWithType:@"kick" userId:userId timer:[NSString stringWithFormat:@"%@",@(5*60)]];
  1422. }];
  1423. ZCAlertAction *action2 = [ZCAlertAction actionWithTitle:@"30分钟" andblock:^{
  1424. @strongify(self);
  1425. [self youpaifoutRoomOrDisableMessageWithType:@"kick" userId:userId timer:[NSString stringWithFormat:@"%@",@(30*60)]];
  1426. }];
  1427. ZCAlertAction *action3 = [ZCAlertAction actionWithTitle:@"60分钟" andblock:^{
  1428. @strongify(self);
  1429. [self youpaifoutRoomOrDisableMessageWithType:@"kick" userId:userId timer:[NSString stringWithFormat:@"%@",@(60*60)]];
  1430. }];
  1431. ZCAlertAction *action4 = [ZCAlertAction actionWithTitle:@"永久移出" andblock:^{
  1432. @strongify(self);
  1433. LZAlertAction *cancelAction = [LZAlertAction actionWithTitle:@"取消" handler:^(LZAlertAction *action) {
  1434. }];
  1435. cancelAction.cornerRadius = 24.0f;
  1436. cancelAction.bgColor = HexColorFromRGB(0x9F9DA5);
  1437. LZAlertAction *confimAction = [LZAlertAction actionWithTitle:@"确定" handler:^(LZAlertAction *action) {
  1438. @strongify(self);
  1439. [self youpaifoutRoomOrDisableMessageWithType:@"kick" userId:userId timer:[NSString stringWithFormat:@"%@",@(-1)]];
  1440. }];
  1441. confimAction.cornerRadius = 24.0f;
  1442. confimAction.bgColor = [UIColor colorWithPatternImage:[LCTools ColorImage:CGSizeMake((KScreenWidth - 105.0f) / 2.0f, 48.0f) FromColors:@[ZYGradientOneColor,ZYGradientTwoColor] ByGradientType:GradientLeftToRight]];
  1443. LZAlertWindow *alert = [LZAlertWindow alertWithTitle:@"提示" content:@"选择【永久移出】后,用户将无法进入该房间,直至管理者解除限制" action:@[cancelAction,confimAction]];
  1444. alert.contentTextAlignment = NSTextAlignmentCenter;
  1445. [self TFPresentVC:alert completion:^{}];
  1446. }];
  1447. ZCAlertSheetView* alertSheet = [[ZCAlertSheetView alloc]initWithTitle:nil andShowCancelButton:YES andAction:@[action1,action2,action3,action4]];
  1448. alertSheet.alertWindow.hidden = NO;
  1449. [alertSheet show];
  1450. }
  1451. // 清空心动值
  1452. - (ZCAlertAction *)emptyLoveValueAlertActionWithUserID:(NSString *)userId{
  1453. @weakify(self);
  1454. ZCAlertAction *action = [ZCAlertAction actionWithTitle:@"清空心动值" andblock:^{
  1455. @strongify(self);
  1456. LZAlertAction *cancelAction = [LZAlertAction actionWithTitle:@"取消" handler:^(LZAlertAction *action) {
  1457. }];
  1458. cancelAction.cornerRadius = 24.0f;
  1459. cancelAction.bgColor = HexColorFromRGB(0x9F9DA5);
  1460. LZAlertAction *confimAction = [LZAlertAction actionWithTitle:@"确定" handler:^(LZAlertAction *action) {
  1461. @strongify(self);
  1462. [self emptyLoveValueWithUserID:userId];
  1463. }];
  1464. confimAction.cornerRadius = 24.0f;
  1465. confimAction.bgColor = [UIColor colorWithPatternImage:[LCTools ColorImage:CGSizeMake((KScreenWidth - 105.0f) / 2.0f, 48.0f) FromColors:@[ZYGradientOneColor,ZYGradientTwoColor] ByGradientType:GradientLeftToRight]];
  1466. LZAlertWindow *alert = [LZAlertWindow alertWithTitle:@"提示" content:@"是否清空该用户的心动值" action:@[cancelAction,confimAction]];
  1467. alert.contentTextAlignment = NSTextAlignmentCenter;
  1468. [self TFPresentVC:alert completion:^{}];
  1469. }];
  1470. return action;
  1471. }
  1472. // 清空心动值
  1473. - (void)emptyLoveValueWithUserID:(NSString *)userId{
  1474. [LCHttpHelper requestWithURLString:ChatRoomClearUserCardiac parameters:@{@"room_id":self.youpaipchatroomModel.youpaiproom_id,@"user_id":userId} needToken:YES type:(HttpRequestTypePost) success:^(id responseObject) {
  1475. NSDictionary* dict = (NSDictionary*)responseObject;
  1476. NSInteger code = [[dict objectForKey:@"code"] integerValue];
  1477. if (code==0) {//成功
  1478. [ZCHUDHelper showTitle:@"操作成功"];
  1479. }
  1480. } failure:^(NSError *error) {
  1481. }];
  1482. }
  1483. // 选择禁言时间弹框
  1484. - (void)youpaifselectedDisableMessageTimerAlertUserId:(NSString *)userId{
  1485. @weakify(self);
  1486. ZCAlertAction *action1 = [ZCAlertAction actionWithTitle:@"禁言1分钟" andblock:^{
  1487. @strongify(self);
  1488. [self youpaifoutRoomOrDisableMessageWithType:@"mute" userId:userId timer:[NSString stringWithFormat:@"%@",@(1*60)]];
  1489. }];
  1490. ZCAlertAction *action2 = [ZCAlertAction actionWithTitle:@"禁言5分钟" andblock:^{
  1491. @strongify(self);
  1492. [self youpaifoutRoomOrDisableMessageWithType:@"mute" userId:userId timer:[NSString stringWithFormat:@"%@",@(5*60)]];
  1493. }];
  1494. ZCAlertAction *action3 = [ZCAlertAction actionWithTitle:@"禁言10分钟" andblock:^{
  1495. @strongify(self);
  1496. [self youpaifoutRoomOrDisableMessageWithType:@"mute" userId:userId timer:[NSString stringWithFormat:@"%@",@(10*60)]];
  1497. }];
  1498. ZCAlertAction *action4 = [ZCAlertAction actionWithTitle:@"禁言30分钟" andblock:^{
  1499. @strongify(self);
  1500. [self youpaifoutRoomOrDisableMessageWithType:@"mute" userId:userId timer:[NSString stringWithFormat:@"%@",@(30*60)]];
  1501. }];
  1502. ZCAlertAction *action5 = [ZCAlertAction actionWithTitle:@"禁言60分钟" andblock:^{
  1503. @strongify(self);
  1504. [self youpaifoutRoomOrDisableMessageWithType:@"mute" userId:userId timer:[NSString stringWithFormat:@"%@",@(60*60)]];
  1505. }];
  1506. ZCAlertAction *action6 = [ZCAlertAction actionWithTitle:@"禁言90分钟" andblock:^{
  1507. @strongify(self);
  1508. [self youpaifoutRoomOrDisableMessageWithType:@"mute" userId:userId timer:[NSString stringWithFormat:@"%@",@(90*60)]];
  1509. }];
  1510. ZCAlertSheetView* alertSheet = [[ZCAlertSheetView alloc]initWithTitle:nil andShowCancelButton:NO andAction:@[action1,action2,action3,action4,action5,action6]];
  1511. alertSheet.alertWindow.hidden = NO;
  1512. [alertSheet show];
  1513. }
  1514. // 禁言&解除禁言 踢人
  1515. - (void)youpaifoutRoomOrDisableMessageWithType:(NSString *)type userId:(NSString *)userId timer:(NSString *)tiemr{
  1516. [LCHttpHelper requestWithURLString:ForbidUser parameters:@{@"room_id":self.youpaipchatroomModel.youpaiproom_id,@"time":tiemr,@"type":type,@"op_uid":userId} needToken:YES type:(HttpRequestTypePost) success:^(id responseObject) {
  1517. NSDictionary* dict = (NSDictionary*)responseObject;
  1518. NSInteger code = [[dict objectForKey:@"code"] integerValue];
  1519. if (code==0) {//成功
  1520. [ZCHUDHelper showTitle:@"操作成功"];
  1521. }
  1522. } failure:^(NSError *error) {
  1523. }];
  1524. }
  1525. - (NSMutableArray *)youpaipgifts{// 礼物数据
  1526. if (!_youpaipgifts) {
  1527. _youpaipgifts = [NSMutableArray array];
  1528. }
  1529. return _youpaipgifts;
  1530. }
  1531. - (NSMutableArray<YOUPAILZChatRoomGiftView *> *)youpaipgiftViews{// 礼物
  1532. if (!_youpaipgiftViews) {
  1533. _youpaipgiftViews = [NSMutableArray array];
  1534. }
  1535. return _youpaipgiftViews;
  1536. }
  1537. - (NSMutableArray *)youpaipsvgas{
  1538. if (!_youpaipsvgas) {
  1539. _youpaipsvgas = [NSMutableArray array];
  1540. }
  1541. return _youpaipsvgas;
  1542. }
  1543. @end