YOUPAILZChatRoomBaseVC.m 90 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886
  1. //
  2. // YOUPAILZChatRoomBaseVC.m
  3. // VQU
  4. //
  5. // Created by CY on 2021/10/28.
  6. // Copyright © 2021 MS. All rights reserved.
  7. //
  8. #import "YOUPAILZChatRoomBaseVC.h"
  9. #import "NSString+YYAdd.h"
  10. #import "YBPopupMenu.h"
  11. #import "YOUPAILZChatRoomNoticeTitleCell.h"
  12. #import "YOUPAILZChatRoomNoticeContentCell.h"
  13. #import "YOUPAILZChatRoomEmojiAnimationWindow.h"
  14. #import "UIViewController+TFPresent.h"
  15. #import "YOUPAILCMessageVC.h"
  16. #import "YOUPAILZLiveUserInfoWindow.h"
  17. #import "YOUPAILZUserShowVC.h"
  18. #import "YOUPAILCReportVC.h"
  19. #import "YOUPAILZCommonGiftView.h"
  20. #import "YOUPAILPGuardHerVC.h"
  21. #import "LZAlertWindow.h"
  22. #import "YOUPAILZLiveChatMessageCell.h"
  23. #import "YOUPAILZChatRoomInfoEditWindow.h"
  24. #import "NIMMessageMaker.h"
  25. #import "YOUPAILZChatRoomUpLockWindow.h"
  26. #import "YOUPAILZChatRoomBlockListWindow.h"
  27. #import "YOUPAILZChatRoomReportWindow.h"
  28. #import "SDCycleScrollView.h"
  29. #import "YOUPAILCFirstRechargeModel.h"
  30. #import "YOUPAIHRChatRoomGiftView.h"
  31. #import "YOUPAIHRRechargePayWindow.h"
  32. #import "YOUPAILZChatRoomGiftAttachment.h"
  33. #import "YOUPAILZMusicLibraryWindow.h"
  34. #import "YOUPAILZMusicWindow.h"
  35. #import "YOUPAIZYFirstRechargeWindow.h"
  36. #import "YOUPAILCFirstRechargeModel.h"
  37. #import "YOUPAILZLiveAudienceVC.h"
  38. #import "YOUPAILZChatRoomBlindDateProgressView.h"
  39. #import "YOUPAILZBlindDateSelectWindow.h"
  40. #import "YOUPAIHRWebWindow.h"
  41. #import "YOUPAIBBMessageVC.h"
  42. #import "YOUPAILZChatRoomGameCenterWindow.h"
  43. #import "YOUPAIHRChatRoomContributeListVC.h"
  44. #import "YOUPAILZChatRoomSetterBgImgWindow.h"
  45. #import <SVGAPlayer.h>
  46. #import <SVGAParser.h>
  47. @interface YOUPAILZChatRoomBaseVC () <YBPopupMenuDelegate,LPGuardHerDelegate,UICollectionViewDelegate,UICollectionViewDataSource,UITableViewDelegate,UITableViewDataSource,ZYFirstRechargeWindowDelegate>
  48. @property (nonatomic,weak)UIImageView *bgImgV;
  49. @property (nonatomic, strong) SVGAPlayer *youpaipBgSvgaPlayer;
  50. @property (nonatomic, strong) SVGAParser *youpaipBgParser;
  51. @property (nonatomic,weak) UIView *youpaipheaderView;
  52. @property (nonatomic,weak) UIButton *youpaipcloseBtn;
  53. @property (nonatomic,weak) UIButton *youpaipnoticeBtn; /// 公告
  54. @property (nonatomic,weak) UIButton *youpaipintroduceBtn; /// 玩法介绍
  55. @property (nonatomic,weak) YOUPAILZChatRoomBlindDateProgressView *youpaipblindDateProgressView; // 相亲玩法进度
  56. @property (nonatomic,strong) YBPopupMenu *youpaipnoticePopupMenu;// 公告弹窗
  57. //广告相关
  58. @property (nonatomic,strong) SDCycleScrollView* youpaipcycleScrollView;
  59. @property (nonatomic,strong) YOUPAILCFirstRechargeModel *youpaipfirstRechargeModel;
  60. @property (nonatomic,strong) YOUPAILCFirstRechargeModel *youpaipfirstRechargeModel1;
  61. @property (nonatomic,assign) CGFloat youpaipmusicPlayerViewY;
  62. @property (nonatomic,assign) BOOL isLoadingUserInfo; // 是否正在加载用户信息
  63. @end
  64. @implementation YOUPAILZChatRoomBaseVC
  65. - (void)viewWillAppear:(BOOL)animated{
  66. [super viewWillAppear:animated];
  67. [YOUPAILZChatRoomManager shareManager].chatroomWindow.hidden = YES;
  68. [self.youpaipfooterView youpaifupdateUnread];
  69. }
  70. - (void)viewWillDisappear:(BOOL)animated{
  71. [super viewWillDisappear:animated];
  72. self.navigationController.navigationBarHidden = NO;
  73. // [self.youpaipchatroomInfoView.titleL marqueeOfSettingWithState:MarqueeShutDown_H];
  74. [self youpaifnoticePopupMenuDismiss];
  75. }
  76. - (void)viewDidAppear:(BOOL)animated {
  77. [super viewDidAppear:animated];
  78. self.navigationController.navigationBarHidden = YES;
  79. // [self.youpaipchatroomInfoView.titleL marqueeOfSettingWithState:MarqueeStart_H];
  80. }
  81. - (void)viewDidDisappear:(BOOL)animated{
  82. [super viewDidDisappear:animated];
  83. if ([YOUPAILZChatRoomManager shareManager].chatroomController != nil) {
  84. [YOUPAILZChatRoomManager shareManager].chatroomWindow.hidden = self.youpaipisClose;
  85. }
  86. }
  87. - (void)viewDidLoad {
  88. [super viewDidLoad];
  89. [self youpaifinitBgImgV];
  90. [self youpaifinitHeaderView];
  91. [self youpaifinitNoticeView];
  92. [self youpaifinitBoardView];
  93. [self youpaifinitSeatHostView];
  94. [self youpaifinitSeatOtherView];
  95. [self youpaifinitFooterView];
  96. [self youpaifinitMessageTableView];
  97. [self youpaifinitKeyboardView];
  98. [self youpaifinitApplySeatButton];
  99. [self youpaifinitializeAgoraEngine];
  100. [self youpaifinitAdvertView];
  101. [self youpaifinitMusicLyrieView];
  102. [self youpaifloadAdvert1];
  103. [self youpaifinitPlayTypeIntroduce];
  104. [self youpaifinitBlindDateProgressView];
  105. self.youpaipchatroomInfoView.youpaiptitleL.text = self.youpaipchatroomModel.youpaiproom_title;
  106. self.youpaipchatroomInfoView.youpaiphotValueL.text = self.youpaipchatroomModel.youpaiproom_score;
  107. self.youpaipchatroomInfoView.youpaipchatroomIDL.text = [NSString stringWithFormat:@"房间号:%@",self.youpaipchatroomModel.youpaiproom_number];
  108. self.youpaipchatroomInfoView.youpaipfollowBtn.selected = self.youpaipchatroomModel.youpaipis_follow;
  109. [self performSelector:@selector(youpaifnoticeBtnClick) withObject:nil afterDelay:0.5f];
  110. [self performSelector:@selector(youpaifnoticePopupMenuDismiss) withObject:nil afterDelay:3.0f];
  111. }
  112. //获取首冲弹框数据
  113. -(void)youpaifloadAdvert1{
  114. @weakify(self);
  115. [LCHttpHelper requestWithURLString:GetAdvert parameters:@{@"position":@"7"} needToken:YES type:(HttpRequestTypePost) success:^(id responseObject) {
  116. @strongify(self);
  117. NSDictionary* dict = (NSDictionary*)responseObject;
  118. NSInteger code = [[dict objectForKey:@"code"] integerValue];
  119. if (code==0) {//成功
  120. self.youpaipfirstRechargeModel1 = [YOUPAILCFirstRechargeModel mj_objectWithKeyValues:dict[@"data"]];
  121. for (int i = 0; i<self.youpaipfirstRechargeModel1.youpaiplist.count; i++) {
  122. YOUPAILCBannerModel* model = self.youpaipfirstRechargeModel1.youpaiplist[i];
  123. if([NSStringFromClass([LCTools getCurrentVC].class) isEqual:@"YOUPAILZLiveAnchorVC"]) {
  124. continue;
  125. }
  126. if([LCTools getCurrentVC].tabBarController == nil) {
  127. continue;
  128. }
  129. if (model.youpaipwindow_type == 2) {
  130. YOUPAIHRWebWindow *window = [[YOUPAIHRWebWindow alloc] init];
  131. window.isTouchDismiss = YES;
  132. window.youpaipurl = model.youpaipwindow_link;
  133. window.youpaipwidth = model.youpaipwidth;
  134. window.youpaipheight = model.youpaipheight;
  135. window.youpaipgravity = model.youpaipgravity;
  136. [self TFPresentVC:window completion:^{}];
  137. }else{
  138. YOUPAIZYFirstRechargeWindow *VC= [[YOUPAIZYFirstRechargeWindow alloc]init];
  139. VC.youpaipdelegate = self;
  140. VC.vWidth = KScreenWidth -30;
  141. VC.vHeight = KScreenWidth-30;
  142. VC.youpaipimageurl = model.youpaipimage;
  143. VC.youpaiplink_type = model.youpaiplink_type;
  144. VC.youpaiplink_url = model.youpaiplink_url;
  145. VC.isTouchDismiss = YES;
  146. [[LCTools getCurrentVC] TFPresentVC:VC completion:^{}];
  147. }
  148. }
  149. }
  150. } failure:^(NSError *error) {}];
  151. }
  152. - (void)youpaifLZFirstRechargeClickAdverImage:(NSInteger)link_type andUrl:(NSString *)link_url{
  153. if (link_type == 1) {
  154. ZCBaseWebVC* baseWeb = [[ZCBaseWebVC alloc]init];
  155. baseWeb.contentUrl = link_url;
  156. UIViewController *vc = [LCTools getContainNavigationControllerCurrentVC];
  157. if([NSStringFromClass([LCTools getContainNavigationControllerCurrentVC].class) isEqual:@"YOUPAILZLiveAudienceVC"]) {
  158. YOUPAILZLiveAudienceVC *audienceVC = (YOUPAILZLiveAudienceVC *)vc;
  159. audienceVC.youpaipisNotPanClose = YES;
  160. }
  161. [vc.navigationController pushViewController:baseWeb animated:YES];
  162. }else if (link_type==2 || link_type==3){
  163. UIViewController *vc = [LCTools getContainNavigationControllerCurrentVC];
  164. if([NSStringFromClass([LCTools getContainNavigationControllerCurrentVC].class) isEqual:@"YOUPAILZLiveAudienceVC"]) {
  165. YOUPAILZLiveAudienceVC *audienceVC = (YOUPAILZLiveAudienceVC *)vc;
  166. audienceVC.youpaipisNotPanClose = YES;
  167. }
  168. [vc youpaifpageToStr:link_url];
  169. }else{
  170. }
  171. }
  172. /// 背景设置
  173. - (void)youpaifinitBgImgV{
  174. UIImageView *bgImgV = [[UIImageView alloc] initWithFrame:self.view.bounds];
  175. bgImgV.contentMode = UIViewContentModeScaleAspectFill;
  176. bgImgV.image = [UIImage imageNamed:@"vqu_images_chatroom_bg"];
  177. [self.view addSubview:bgImgV];
  178. self.bgImgV = bgImgV;
  179. self.youpaipBgSvgaPlayer = [[SVGAPlayer alloc] initWithFrame:self.view.bounds];
  180. self.youpaipBgSvgaPlayer.contentMode = UIViewContentModeScaleAspectFill;
  181. self.youpaipBgSvgaPlayer.layer.cornerRadius = ScaleSize(10.0f);
  182. self.youpaipBgSvgaPlayer.clipsToBounds = YES;
  183. self.youpaipBgSvgaPlayer.layer.borderColor = HexColorFromRGB(0xF4003F).CGColor;
  184. self.youpaipBgSvgaPlayer.hidden = YES;
  185. self.youpaipBgSvgaPlayer.loops = 0;
  186. self.youpaipBgSvgaPlayer.clearsAfterStop = true;
  187. self.youpaipBgSvgaPlayer.userInteractionEnabled = NO;
  188. [self.view addSubview:self.youpaipBgSvgaPlayer];
  189. self.youpaipBgParser = [[SVGAParser alloc] init];
  190. [self youpaifsetupBgImage];
  191. }
  192. - (void)youpaifsetupBgImage{
  193. if (self.youpaipchatroomModel.youpaipbg_img.length == 0) {
  194. return;
  195. }
  196. self.bgImgV.hidden = YES;
  197. self.youpaipBgSvgaPlayer.hidden = YES;
  198. if ([self.youpaipchatroomModel.youpaipbg_img containsString:@".svga"]) {
  199. self.youpaipBgSvgaPlayer.hidden = NO;
  200. [self.youpaipBgSvgaPlayer stopAnimation];
  201. NSString* svgaName = [[self.youpaipchatroomModel.youpaipbg_img componentsSeparatedByString:@"/"] lastObject];
  202. NSString* svgaCanchesPath= [[NSString alloc]initWithFormat:@"%@/%@/%@",CachesPath,@"SVGA",svgaName];
  203. if (![LCTools giftSVGAWithSvgaUrlStr:self.youpaipchatroomModel.youpaipbg_img]){
  204. NSString* urlStr = [NSString stringWithFormat:@"%@/%@",[LCSaveData getImageUrl]?[LCSaveData getImageUrl]:BaseImgUrl,self.youpaipchatroomModel.youpaipbg_img];
  205. @weakify(self);
  206. [self.youpaipBgParser parseWithURLRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:urlStr]] completionBlock:^(SVGAVideoEntity * _Nullable videoItem) {
  207. @strongify(self);
  208. if (videoItem != nil) {
  209. self.youpaipBgSvgaPlayer.videoItem = videoItem;
  210. [self.youpaipBgSvgaPlayer startAnimation];
  211. }
  212. } failureBlock:^(NSError * _Nullable error) {
  213. @strongify(self);
  214. self.youpaipBgSvgaPlayer.hidden = YES;
  215. }];
  216. [LCTools giftSVGAWithSvgaUrlStr:self.youpaipchatroomModel.youpaipbg_img];
  217. }else{
  218. @weakify(self);
  219. [self.youpaipBgParser parseWithData:[LCTools giftSVGAWithSvgaUrlStr:self.youpaipchatroomModel.youpaipbg_img] cacheKey:svgaCanchesPath completionBlock:^(SVGAVideoEntity * _Nonnull videoItem) {
  220. @strongify(self);
  221. if (videoItem != nil) {
  222. self.youpaipBgSvgaPlayer.videoItem = videoItem;
  223. [self.youpaipBgSvgaPlayer startAnimation];
  224. }
  225. } failureBlock:^(NSError * _Nonnull error) {
  226. @strongify(self);
  227. self.youpaipBgSvgaPlayer.hidden = YES;
  228. }];
  229. }
  230. }else{
  231. self.bgImgV.hidden = NO;
  232. [self.bgImgV sd_setImageWithURL:[LCTools getImageUrlWithAddress:self.youpaipchatroomModel.youpaipbg_img]];
  233. }
  234. // CATransition *transition = [CATransition animation];
  235. // transition.duration = 0.25f;
  236. // transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
  237. // transition.type = kCATransitionFade;
  238. // [self.bgImgV.layer addAnimation:transition forKey:@"bgAnimation"];
  239. // switch (self.youpaipchatroomModel.youpaipplayType) {
  240. // case LZChatRoomPlayTypeWithNormal:
  241. //
  242. // break;
  243. // case LZChatRoomPlayTypeWithCardiac:
  244. // self.bgImgV.image = [UIImage imageNamed:@"vqu_chatroom_bg_cardiac"];
  245. // break;
  246. // case LZChatRoomPlayTypeWithBlindDate:
  247. // self.bgImgV.image = [UIImage imageNamed:@"vqu_image_chatroom_blinddate"];
  248. // break;
  249. //
  250. // default:
  251. // break;
  252. // }
  253. }
  254. /// 更新玩法UI
  255. - (void)youpaifreloadPlayTypeUI{
  256. // [self youpaifsetupBgImage];
  257. [self youpaifsetupIntroduceBtnShow];
  258. [self youpaifsetupBlindDateProgressData];
  259. [self.youpaipapplySeatButton youpaifrleoadWithType:self.youpaipapplySeatButton.youpaiptype playType:self.youpaipchatroomModel.youpaipplayType];
  260. }
  261. /// youpaipheaderView
  262. - (void)youpaifinitHeaderView{
  263. UIView *youpaipheaderView = [[UIView alloc] init];
  264. [self.view addSubview:youpaipheaderView];
  265. self.youpaipheaderView = youpaipheaderView;
  266. [youpaipheaderView mas_makeConstraints:^(MASConstraintMaker *make) {
  267. make.left.right.offset(0.0f);
  268. make.top.offset(StatusBarHeight);
  269. make.height.offset(44.0f);
  270. }];
  271. UIButton *youpaipcloseBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  272. [youpaipcloseBtn setImage:[UIImage imageNamed:@"vqu_images_chatroom_close"] forState:UIControlStateNormal];
  273. [youpaipcloseBtn setImage:[UIImage imageNamed:@"vqu_images_chatroom_close"] forState:UIControlStateHighlighted];
  274. [youpaipcloseBtn addTarget:self action:@selector(youpaifcloseBtnClick) forControlEvents:UIControlEventTouchUpInside];
  275. [youpaipheaderView addSubview:youpaipcloseBtn];
  276. self.youpaipcloseBtn = youpaipcloseBtn;
  277. [youpaipcloseBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  278. make.right.offset(-10.0f);
  279. make.centerY.equalTo(youpaipheaderView);
  280. make.size.mas_offset(CGSizeMake(20.0f, 44.0f));
  281. }];
  282. [self youpaifinitChatRoomInfoView];
  283. [self youpaifinitChatRoomMemberView];
  284. }
  285. /// 语聊房信息View
  286. - (void)youpaifinitChatRoomInfoView{
  287. YOUPAILZChatRoomInfoView *youpaipchatroomInfoView = [[YOUPAILZChatRoomInfoView alloc] init];
  288. [self.youpaipheaderView addSubview:youpaipchatroomInfoView];
  289. self.youpaipchatroomInfoView = youpaipchatroomInfoView;
  290. [youpaipchatroomInfoView mas_makeConstraints:^(MASConstraintMaker *make) {
  291. make.left.top.bottom.offset(0.0f);
  292. make.width.greaterThanOrEqualTo(120.0f);
  293. }];
  294. @weakify(self);
  295. [youpaipchatroomInfoView setYoupaiffollowBtnClickBlock:^(BOOL isFollow) {
  296. if (isFollow) { // 关注
  297. @strongify(self);
  298. NSMutableDictionary *params = @{@"follow_room_id":self.youpaipchatroomModel.youpaiproom_id}.mutableCopy;
  299. if (self.youpaipchatroomModel.youpaiphostSeat.youpaipuserInfo.youpaipid.length != 0) {
  300. [params setValue:self.youpaipchatroomModel.youpaiphostSeat.youpaipuserInfo.youpaipid forKey:@"follow_user"];
  301. }
  302. [LCHttpHelper requestWithURLString:FollowRooms parameters:params needToken:YES type:(HttpRequestTypePost) success:^(id responseObject) {
  303. } failure:^(NSError *error) {
  304. }];
  305. }else{ // 取消关注
  306. [LCHttpHelper requestWithURLString:FollowRoomsCancel parameters:@{@"follow_room_id":self.youpaipchatroomModel.youpaiproom_id} needToken:YES type:(HttpRequestTypePost) success:^(id responseObject) {
  307. } failure:^(NSError *error) {
  308. }];
  309. }
  310. }];
  311. }
  312. /// 语聊房成员View
  313. - (void)youpaifinitChatRoomMemberView{
  314. YOUPAILZChatRoomMemberView *youpaipchatroomMemberView = [[YOUPAILZChatRoomMemberView alloc] init];
  315. [youpaipchatroomMemberView youpaifreloadWithMemberList:self.youpaipchatroomModel.youpaiplive_top_three];
  316. [self.youpaipheaderView addSubview:youpaipchatroomMemberView];
  317. self.youpaipchatroomMemberView = youpaipchatroomMemberView;
  318. [youpaipchatroomMemberView mas_makeConstraints:^(MASConstraintMaker *make) {
  319. make.right.equalTo(self.youpaipcloseBtn.mas_left).offset(-1.0f);
  320. make.top.bottom.offset(0.0f);
  321. }];
  322. }
  323. /// 公告View
  324. - (void)youpaifinitNoticeView{
  325. UIButton *youpaipnoticeBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  326. youpaipnoticeBtn.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.3f];
  327. youpaipnoticeBtn.layer.cornerRadius = 10.5f;
  328. youpaipnoticeBtn.clipsToBounds = YES;
  329. [youpaipnoticeBtn addTarget:self action:@selector(youpaifnoticeBtnClick) forControlEvents:UIControlEventTouchUpInside];
  330. [self.view addSubview:youpaipnoticeBtn];
  331. self.youpaipnoticeBtn = youpaipnoticeBtn;
  332. [youpaipnoticeBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  333. make.left.offset(14.0f);
  334. make.top.equalTo(self.youpaipheaderView.mas_bottom).offset(10.0f);
  335. make.height.offset(21.0f);
  336. }];
  337. UIImageView *iconImgV = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"vqu_images_chatroom_notice"]];
  338. [youpaipnoticeBtn addSubview:iconImgV];
  339. [iconImgV mas_makeConstraints:^(MASConstraintMaker *make) {
  340. make.left.offset(9.0f);
  341. make.centerY.equalTo(youpaipnoticeBtn);
  342. make.size.mas_offset(CGSizeMake(11.0f, 13.0f));
  343. }];
  344. UILabel *noticeL = [[UILabel alloc] init];
  345. noticeL.font = LCFont(11.0f);
  346. noticeL.textColor = HexColorFromRGB(0xEEEEEE);
  347. noticeL.text = @"公告";
  348. [youpaipnoticeBtn addSubview:noticeL];
  349. [noticeL mas_makeConstraints:^(MASConstraintMaker *make) {
  350. make.left.equalTo(iconImgV.mas_right).offset(4.0f);
  351. make.centerY.equalTo(youpaipnoticeBtn);
  352. make.right.offset(-9.0f);
  353. }];
  354. }
  355. /// 榜单View
  356. - (void)youpaifinitBoardView{
  357. UIButton *youpaipboardBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  358. youpaipboardBtn.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.3f];
  359. youpaipboardBtn.layer.cornerRadius = 10.5f;
  360. youpaipboardBtn.clipsToBounds = YES;
  361. [youpaipboardBtn addTarget:self action:@selector(youpaifboardBtnClick) forControlEvents:UIControlEventTouchUpInside];
  362. [self.view addSubview:youpaipboardBtn];
  363. [youpaipboardBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  364. make.left.offset(14.0f);
  365. make.top.equalTo(self.youpaipnoticeBtn.mas_bottom).offset(5.0f);
  366. make.height.offset(21.0f);
  367. }];
  368. UIImageView *iconImgV = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"vqu_images_chatroom_board"]];
  369. [youpaipboardBtn addSubview:iconImgV];
  370. [iconImgV mas_makeConstraints:^(MASConstraintMaker *make) {
  371. make.left.offset(7.0f);
  372. make.centerY.equalTo(youpaipboardBtn);
  373. make.size.mas_offset(CGSizeMake(14.0f, 13.0f));
  374. }];
  375. UILabel *boardL = [[UILabel alloc] init];
  376. boardL.font = LCFont(11.0f);
  377. boardL.textColor = HexColorFromRGB(0xFFDD8D);
  378. boardL.text = @"榜单";
  379. [youpaipboardBtn addSubview:boardL];
  380. [boardL mas_makeConstraints:^(MASConstraintMaker *make) {
  381. make.left.equalTo(iconImgV.mas_right).offset(3.0f);
  382. make.centerY.equalTo(youpaipboardBtn);
  383. make.right.offset(-9.0f);
  384. }];
  385. }
  386. - (void)youpaifboardBtnClick{
  387. @weakify(self);
  388. [self.youpaipkeyboardView resignFirstResponder];
  389. self.youpaipkeyboardView.hidden = YES;
  390. YOUPAIHRChatRoomContributeListVC *window = [[YOUPAIHRChatRoomContributeListVC alloc] init];
  391. window.youpaipchatroomModel = self.youpaipchatroomModel;
  392. window.isTouchDismiss = YES;
  393. [window setYoupaipupseatBlock:^(YOUPAILZChatRoomMemberModel * _Nonnull model) {
  394. @strongify(self);
  395. [self youpaifshowSelectedSeatWindowWithUserId:model.youpaipid youpaipisInviation:YES];
  396. }];
  397. [window setYoupaiptouchUserBlock:^(NSString * _Nonnull userId) {
  398. @strongify(self);
  399. [self youpaifshowUserInfoWithUserId:userId];
  400. }];
  401. [self TFPresentVC:window completion:^{}];
  402. }
  403. /// 玩法介绍
  404. - (void)youpaifinitPlayTypeIntroduce{
  405. UIButton *youpaipintroduceBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  406. youpaipintroduceBtn.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.3f];
  407. youpaipintroduceBtn.layer.cornerRadius = 10.5f;
  408. youpaipintroduceBtn.clipsToBounds = YES;
  409. [youpaipintroduceBtn setTitle:@"玩法介绍" forState:UIControlStateNormal];
  410. [youpaipintroduceBtn setTitleColor:HexColorFromRGB(0xEEEEEE) forState:UIControlStateNormal];
  411. youpaipintroduceBtn.titleLabel.font = LCFont(11.0f);
  412. youpaipintroduceBtn.hidden = YES;
  413. [youpaipintroduceBtn addTarget:self action:@selector(youpaifintroduceBtnClick) forControlEvents:UIControlEventTouchUpInside];
  414. [self.view addSubview:youpaipintroduceBtn];
  415. self.youpaipintroduceBtn = youpaipintroduceBtn;
  416. [youpaipintroduceBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  417. make.left.equalTo(self.youpaipnoticeBtn.mas_right).offset(5.0f);
  418. make.centerY.equalTo(self.youpaipnoticeBtn);
  419. make.size.mas_offset(CGSizeMake(62.0f, 21.0f));
  420. }];
  421. [self youpaifsetupIntroduceBtnShow];
  422. }
  423. - (void)youpaifintroduceBtnClick{
  424. YOUPAIHRWebWindow *window = [[YOUPAIHRWebWindow alloc] init];
  425. window.isTouchDismiss = YES;
  426. window.youpaipurl = self.youpaipchatroomModel.youpaippalyIntroduce.youpaipurl;
  427. window.youpaipwidth = self.youpaipchatroomModel.youpaippalyIntroduce.youpaipwidth;
  428. window.youpaipheight = self.youpaipchatroomModel.youpaippalyIntroduce.youpaipheight;
  429. window.youpaipgravity = self.youpaipchatroomModel.youpaippalyIntroduce.youpaipgravity;
  430. [self TFPresentVC:window completion:^{}];
  431. }
  432. - (void)youpaifsetupIntroduceBtnShow{
  433. self.youpaipintroduceBtn.hidden = YES;
  434. if (self.youpaipchatroomModel.youpaipplayType == LZChatRoomPlayTypeWithBlindDate) {
  435. self.youpaipintroduceBtn.hidden = NO;
  436. }
  437. }
  438. /// 相亲玩法状态
  439. - (void)youpaifinitBlindDateProgressView{
  440. YOUPAILZChatRoomBlindDateProgressView *youpaipblindDateProgressView = [[YOUPAILZChatRoomBlindDateProgressView alloc] init];
  441. youpaipblindDateProgressView.hidden = YES;
  442. [self.view addSubview:youpaipblindDateProgressView];
  443. self.youpaipblindDateProgressView = youpaipblindDateProgressView;
  444. [youpaipblindDateProgressView mas_makeConstraints:^(MASConstraintMaker *make) {
  445. make.left.right.offset(0.0f);
  446. make.top.equalTo(self.youpaiphostSeatView.mas_bottom).offset(-10.0f);
  447. make.height.offset(48.5f);
  448. }];
  449. [self youpaifsetupBlindDateProgressData];
  450. @weakify(self);
  451. [youpaipblindDateProgressView setBlindDateProgressBlock:^(NSInteger index) {
  452. @strongify(self);
  453. NSInteger status = index + 1;
  454. if (index == self.youpaipchatroomModel.youpaiptalk_played_status.count - 1) {
  455. status = 0;
  456. }
  457. YOUPAIHRWebWindow *window = [[YOUPAIHRWebWindow alloc] init];
  458. window.isTouchDismiss = YES;
  459. window.youpaipurl = [NSString stringWithFormat:@"%@&room_id=%@&status=%@",self.youpaipchatroomModel.youpaipblindDateChange.youpaipurl,self.youpaipchatroomModel.youpaiproom_id,@(status)];
  460. window.youpaipwidth = self.youpaipchatroomModel.youpaipblindDateChange.youpaipwidth;
  461. window.youpaipheight = self.youpaipchatroomModel.youpaipblindDateChange.youpaipheight;
  462. window.youpaipgravity = self.youpaipchatroomModel.youpaipblindDateChange.youpaipgravity;
  463. [self TFPresentVC:window completion:^{}];
  464. }];
  465. [youpaipblindDateProgressView setBlindDateSelectedBlock:^{
  466. @strongify(self);
  467. [self youpaifshowBlindDateSelectWindow];
  468. }];
  469. }
  470. - (void)youpaifshowBlindDateSelectWindow{
  471. YOUPAILZBlindDateSelectWindow *window = [[YOUPAILZBlindDateSelectWindow alloc] init];
  472. window.youpaipnormalSeatJsons = [YOUPAILZChatRoomSeatModel mj_keyValuesArrayWithObjectArray:self.youpaipchatroomModel.youpaipnormalSeats];
  473. window.youpaipchatroomModel = self.youpaipchatroomModel;
  474. [self TFPresentVC:window completion:^{}];
  475. }
  476. - (void)youpaifsetupBlindDateProgressData{
  477. if (self.youpaipchatroomModel.youpaipplayType == LZChatRoomPlayTypeWithBlindDate) {
  478. self.youpaipblindDateProgressView.hidden = NO;
  479. [self.youpaipblindDateProgressView youpaifreloadWithModel:self.youpaipchatroomModel];
  480. [self.youpaipotherSeatCollectionView mas_remakeConstraints:^(MASConstraintMaker *make) {
  481. make.top.equalTo(self.youpaipblindDateProgressView.mas_bottom).offset(24.0f);
  482. make.left.right.offset(0.0f);
  483. make.height.offset(228.0f);
  484. }];
  485. }else{
  486. self.youpaipblindDateProgressView.hidden = YES;
  487. [self.youpaipotherSeatCollectionView mas_remakeConstraints:^(MASConstraintMaker *make) {
  488. make.top.equalTo(self.youpaiphostSeatView.mas_bottom).offset(0.0f);
  489. make.left.right.offset(0.0f);
  490. make.height.offset(228.0f);
  491. }];
  492. }
  493. }
  494. /// 主持麦位
  495. - (void)youpaifinitSeatHostView{
  496. self.youpaipchatroomModel.youpaiphostSeat.youpaipseatType = LZChatRoomSeatTypeWithHost;
  497. self.youpaipchatroomModel.youpaiphostSeat.youpaipseatName = @"主持人";
  498. self.youpaipchatroomModel.youpaiphostSeat.youpaipseatIndex = 0;
  499. self.youpaipchatroomModel.youpaiphostSeat.youpaipplayType = self.youpaipchatroomModel.youpaipplayType;
  500. YOUPAILZChatRoomSeatView *youpaiphostSeatView = [[YOUPAILZChatRoomSeatView alloc] initWithAvatarSize:CGSizeMake(60.0f, 60.0f)];
  501. youpaiphostSeatView.youpaipmodel = self.youpaipchatroomModel.youpaiphostSeat;
  502. [self.view addSubview:youpaiphostSeatView];
  503. self.youpaiphostSeatView = youpaiphostSeatView;
  504. [youpaiphostSeatView mas_makeConstraints:^(MASConstraintMaker *make) {
  505. make.centerX.equalTo(self.view);
  506. make.top.equalTo(self.youpaipheaderView.mas_bottom).offset(10.0f);
  507. make.size.mas_offset(CGSizeMake(80.0f, 114.0f));
  508. }];
  509. UITapGestureRecognizer *tapGest = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(youpaifhostSeatClick)];
  510. [youpaiphostSeatView addGestureRecognizer:tapGest];
  511. }
  512. /// 点击主持位
  513. - (void)youpaifhostSeatClick{
  514. }
  515. /// 点击其他麦位
  516. - (void)youpaifotherSeatClickWithIndex:(NSInteger)index{
  517. }
  518. - (void)youpaifinitSeatOtherView{
  519. for (NSInteger i = 0; i < self.youpaipchatroomModel.youpaipnormalSeats.count; i ++) {
  520. YOUPAILZChatRoomSeatModel *seatModel = self.youpaipchatroomModel.youpaipnormalSeats[i];
  521. seatModel.youpaipseatType = LZChatRoomSeatTypeWithOrdinary;
  522. seatModel.youpaipseatName = [NSString stringWithFormat:@"%@号位",@(i + 1)];
  523. seatModel.youpaipseatIndex = i + 1;
  524. seatModel.youpaipplayType = self.youpaipchatroomModel.youpaipplayType;
  525. }
  526. {
  527. YOUPAILZChatRoomSeatModel *seatModel = self.youpaipchatroomModel.youpaipnormalSeats.lastObject;
  528. seatModel.youpaipseatType = LZChatRoomSeatTypeWithGuest;
  529. seatModel.youpaipisSelected = YES;
  530. if (self.youpaipchatroomModel.youpaipplayType == LZChatRoomPlayTypeWithBlindDate) {
  531. seatModel.youpaipisSelected = NO;
  532. }
  533. seatModel.youpaipseatName = @"老板专座";
  534. seatModel.youpaipplayType = self.youpaipchatroomModel.youpaipplayType;
  535. }
  536. UICollectionViewFlowLayout *flowLayout = [[UICollectionViewFlowLayout alloc] init];
  537. flowLayout.scrollDirection = UICollectionViewScrollDirectionVertical;
  538. flowLayout.minimumLineSpacing = 0.0f;
  539. flowLayout.minimumInteritemSpacing = 0.0f;
  540. flowLayout.sectionInset = UIEdgeInsetsMake(0.0f, 0.0f, 0.0f, 0.0f);
  541. flowLayout.itemSize = CGSizeMake(KScreenWidth / 4.0f, 114.0f);
  542. UICollectionView *youpaipotherSeatCollectionView = [[UICollectionView alloc] initWithFrame:CGRectZero collectionViewLayout:flowLayout];
  543. youpaipotherSeatCollectionView.delegate = self;
  544. youpaipotherSeatCollectionView.dataSource = self;
  545. youpaipotherSeatCollectionView.showsVerticalScrollIndicator = NO;
  546. youpaipotherSeatCollectionView.showsHorizontalScrollIndicator = NO;
  547. youpaipotherSeatCollectionView.backgroundColor = [UIColor clearColor];
  548. youpaipotherSeatCollectionView.clipsToBounds = NO;
  549. [youpaipotherSeatCollectionView registerClass:YOUPAILZChatRoomOthearSeatCell.class forCellWithReuseIdentifier:NSStringFromClass(YOUPAILZChatRoomOthearSeatCell.class)];
  550. [self.view addSubview:youpaipotherSeatCollectionView];
  551. self.youpaipotherSeatCollectionView = youpaipotherSeatCollectionView;
  552. [youpaipotherSeatCollectionView mas_makeConstraints:^(MASConstraintMaker *make) {
  553. make.top.equalTo(self.youpaiphostSeatView.mas_bottom).offset(0.0f);
  554. make.left.right.offset(0.0f);
  555. make.height.offset(228.0f);
  556. }];
  557. }
  558. /// 刷新座位
  559. - (void)youpaifreloadSeats{
  560. self.youpaipchatroomModel.youpaiphostSeat.youpaipseatType = LZChatRoomSeatTypeWithHost;
  561. self.youpaipchatroomModel.youpaiphostSeat.youpaipseatName = @"主持人";
  562. self.youpaipchatroomModel.youpaiphostSeat.youpaipseatIndex = 0;
  563. self.youpaipchatroomModel.youpaiphostSeat.youpaipplayType = self.youpaipchatroomModel.youpaipplayType;
  564. for (NSInteger i = 0; i < self.youpaipchatroomModel.youpaipnormalSeats.count; i ++) {
  565. YOUPAILZChatRoomSeatModel *seatModel = self.youpaipchatroomModel.youpaipnormalSeats[i];
  566. seatModel.youpaipseatType = LZChatRoomSeatTypeWithOrdinary;
  567. seatModel.youpaipseatName = [NSString stringWithFormat:@"%@号位",@(i + 1)];
  568. seatModel.youpaipseatIndex = i + 1;
  569. seatModel.youpaipplayType = self.youpaipchatroomModel.youpaipplayType;
  570. }
  571. {
  572. YOUPAILZChatRoomSeatModel *seatModel = self.youpaipchatroomModel.youpaipnormalSeats.lastObject;
  573. seatModel.youpaipseatType = LZChatRoomSeatTypeWithGuest;
  574. seatModel.youpaipisSelected = YES;
  575. if (self.youpaipchatroomModel.youpaipplayType == LZChatRoomPlayTypeWithBlindDate) {
  576. seatModel.youpaipisSelected = NO;
  577. }
  578. seatModel.youpaipseatName = @"老板专座";
  579. seatModel.youpaipplayType = self.youpaipchatroomModel.youpaipplayType;
  580. }
  581. self.youpaiphostSeatView.youpaipmodel = self.youpaipchatroomModel.youpaiphostSeat;
  582. for (NSInteger i = 0; i < self.youpaipchatroomModel.youpaipnormalSeats.count; i ++) {
  583. YOUPAILZChatRoomOthearSeatCell *cell = (YOUPAILZChatRoomOthearSeatCell *)[self.youpaipotherSeatCollectionView cellForItemAtIndexPath:[NSIndexPath indexPathForItem:i inSection:0]];
  584. cell.youpaipseatView.youpaipmodel = self.youpaipchatroomModel.youpaipnormalSeats[i];
  585. }
  586. // [self.youpaipotherSeatCollectionView reloadData];
  587. YOUPAILZChatRoomSeatModel *currentSeatModel = nil;
  588. BOOL youpaipisCurrentUserUpSeat = NO;
  589. if ([self.youpaipchatroomModel.youpaiphostSeat.youpaipuserInfo.youpaipid isEqual:self.youpaipchatroomModel.youpaipuserInfo.youpaipid]) {
  590. currentSeatModel = self.youpaipchatroomModel.youpaiphostSeat;
  591. youpaipisCurrentUserUpSeat = YES;
  592. }
  593. for (YOUPAILZChatRoomSeatModel *seatModel in self.youpaipchatroomModel.youpaipnormalSeats) {
  594. if ([seatModel.youpaipuserInfo.youpaipid isEqual:self.youpaipchatroomModel.youpaipuserInfo.youpaipid]) {
  595. youpaipisCurrentUserUpSeat = YES;
  596. currentSeatModel = seatModel;
  597. }
  598. }
  599. if (self.youpaipisCurrentUserUpSeat != youpaipisCurrentUserUpSeat) {
  600. self.youpaipisCurrentUserUpSeat = youpaipisCurrentUserUpSeat;
  601. [self.youpaipfooterView youpaifshowMicBtn:youpaipisCurrentUserUpSeat];
  602. if (youpaipisCurrentUserUpSeat) {
  603. [[YOUPAILZChatRoomManager shareManager] youpaifsetClientRole:AgoraClientRoleBroadcaster];
  604. }else{
  605. [[YOUPAILZChatRoomManager shareManager] youpaifsetClientRole:AgoraClientRoleAudience];
  606. }
  607. }
  608. self.youpaipkeyboardView.isCurrentUserUpSeat = youpaipisCurrentUserUpSeat;
  609. self.youpaiplocalSeatModel = currentSeatModel;
  610. if (currentSeatModel != nil) {
  611. if (currentSeatModel.youpaipisDisableMicrophone) {
  612. [[YOUPAILZChatRoomManager shareManager] youpaifmuteLocalAudioStream:YES];
  613. self.youpaiplocalSeatModel.youpaipisTalking = NO;
  614. }else{
  615. if (self.youpaipfooterView.youpaipmicBtn.selected) {
  616. [[YOUPAILZChatRoomManager shareManager] youpaifmuteLocalAudioStream:YES];
  617. self.youpaiplocalSeatModel.youpaipisTalking = NO;
  618. }else{
  619. [[YOUPAILZChatRoomManager shareManager] youpaifmuteLocalAudioStream:NO];
  620. }
  621. }
  622. if (self.youpaipchatroomModel.youpaipuserInfo.youpaifroleType == LZUserRoleTypeWithNormal) {
  623. self.youpaipapplySeatButton.hidden = YES;
  624. }
  625. }else{
  626. if (self.youpaipchatroomModel.youpaipchatroomType == LZChatRoomTypeWithHost) {
  627. self.youpaipapplySeatButton.hidden = NO;
  628. }
  629. }
  630. /// 更新相亲玩法进度
  631. [self youpaifsetupBlindDateProgressData];
  632. NSMutableArray *seats = [YOUPAILZChatRoomSeatModel mj_keyValuesArrayWithObjectArray:self.youpaipchatroomModel.youpaipnormalSeats];
  633. NSMutableDictionary *hostSeatDict = [self.youpaipchatroomModel.youpaiphostSeat mj_keyValues];
  634. if (hostSeatDict != nil) {
  635. [seats insertObject:hostSeatDict atIndex:0];
  636. }
  637. //所有座位
  638. [[NSNotificationCenter defaultCenter]postNotificationName:@"UpdateChatRoomAllSeat" object:nil userInfo:@{@"seats":seats}];
  639. // 除主持位的其他位置
  640. [[NSNotificationCenter defaultCenter]postNotificationName:@"UpdateChatRoomSeat" object:nil userInfo:@{@"seats":[YOUPAILZChatRoomSeatModel mj_keyValuesArrayWithObjectArray:self.youpaipchatroomModel.youpaipnormalSeats]}];
  641. if (![self.youpaipchatroomModel.youpaiphostSeat.youpaipuserInfo.youpaipid isEqual:self.youpaipchatroomModel.youpaipuserInfo.youpaipid]) {
  642. [self.youpaiplyrieView youpaifclose];
  643. self.youpaiplyrieView.hidden = YES;
  644. [[YOUPAILZChatRoomManager shareManager] youpaifStopPlayMusic];
  645. [[YOUPAILZMusicManager shareManager] youpaifpause];
  646. [[YOUPAILZMusicManager shareManager] youpaifstopPlay];
  647. }
  648. }
  649. - (void)youpaifinitFooterView{
  650. YOUPAILZChatRoomFooterView *youpaipfooterView = [[YOUPAILZChatRoomFooterView alloc] init];
  651. [self.view addSubview:youpaipfooterView];
  652. self.youpaipfooterView = youpaipfooterView;
  653. [youpaipfooterView mas_makeConstraints:^(MASConstraintMaker *make) {
  654. make.left.right.offset(0.0f);
  655. make.bottom.offset(-SafeHeight-10.0f);
  656. make.height.offset(32.0f);
  657. }];
  658. @weakify(self);
  659. [youpaipfooterView setYoupaipchatBtnClickBlock:^{
  660. @strongify(self);
  661. self.youpaipkeyboardView.hidden = NO;
  662. [self.youpaipkeyboardView showKeyBoard];
  663. }];
  664. [youpaipfooterView setYoupaipemojiBtnClickBlock:^{
  665. @strongify(self);
  666. self.youpaipkeyboardView.hidden = NO;
  667. [self.youpaipkeyboardView showEmoji];
  668. }];
  669. [youpaipfooterView setYoupaipmoreBtnClickBlock:^{
  670. @strongify(self);
  671. self.youpaipmoreModel.youpaipisSeatFree = self.youpaipchatroomModel.youpaipchatroomType == LZChatRoomTypeWithFree;
  672. self.youpaipmoreModel.youpaipisCloseChatMessage = self.youpaipchatroomModel.youpaiptalk_mute != 0; //是否关闭公屏
  673. self.youpaipmoreModel.youpaipisLock = self.youpaipchatroomModel.youpaiptalk_pwd == 1; // 房间是否设置密码 1已设置 0未设置
  674. self.youpaipmoreModel.youpaipisOpenCardiac = self.youpaipchatroomModel.youpaipplayType == LZChatRoomPlayTypeWithCardiac; // 是否开启心动值玩法
  675. self.youpaipmoreModel.youpaipisOpenBlindDate = self.youpaipchatroomModel.youpaipplayType == LZChatRoomPlayTypeWithBlindDate; // 是否开启相亲玩法
  676. YOUPAIZYChatRoomMoreWindow *window = [[YOUPAIZYChatRoomMoreWindow alloc] initWithModel:self.youpaipchatroomModel youpaipmoreModel:self.youpaipmoreModel];
  677. window.isTouchDismiss = YES;
  678. [window setYoupaipitemClickBlock:^(LZChatRoomOperationType type, BOOL isOpen) {
  679. @strongify(self);
  680. [self youpaifmoreWindowItemClickWithType:type isOpen:isOpen];
  681. }];
  682. self.youpaipmoreWindow = window;
  683. [self TFPresentVC:window completion:^{}];
  684. }];
  685. [youpaipfooterView setMessageBtnClickBlock:^{
  686. @strongify(self);
  687. if ([LCSaveData getWhiteVersion]) {
  688. YOUPAIBBMessageVC *vc = [[YOUPAIBBMessageVC alloc]init];
  689. vc.title = @"消息";
  690. [self.navigationController pushViewController:vc animated:YES];
  691. }else{
  692. YOUPAILCMessageVC *vc = [[YOUPAILCMessageVC alloc]init];
  693. vc.title = @"消息";
  694. [self.navigationController pushViewController:vc animated:YES];
  695. }
  696. }];
  697. [youpaipfooterView setYoupaipmicBtnClickBlock:^{
  698. @strongify(self);
  699. if (self.youpaiplocalSeatModel.youpaipisDisableMicrophone) {
  700. [[YOUPAILZChatRoomManager shareManager] youpaifmuteLocalAudioStream:YES];
  701. self.youpaiplocalSeatModel.youpaipisTalking = NO;
  702. [ZCHUDHelper showTitle:@"已闭麦"];
  703. }else{
  704. if (self.youpaipfooterView.youpaipmicBtn.selected) {
  705. [[YOUPAILZChatRoomManager shareManager] youpaifmuteLocalAudioStream:YES];
  706. self.youpaiplocalSeatModel.youpaipisTalking = NO;
  707. [ZCHUDHelper showTitle:@"已闭麦"];
  708. }else{
  709. [[YOUPAILZChatRoomManager shareManager] youpaifmuteLocalAudioStream:NO];
  710. [ZCHUDHelper showTitle:@"已开麦"];
  711. }
  712. }
  713. }];
  714. [youpaipfooterView setYoupaipgameBtnClickBlock:^{
  715. @strongify(self);
  716. [self youpaifshowGameWindow];
  717. }];
  718. [youpaipfooterView setYoupaipgiftBtnClickBlock:^{
  719. @strongify(self);
  720. [self youpaifshowGiftWindow];
  721. }];
  722. }
  723. /// 游戏中心弹窗
  724. - (void)youpaifshowGameWindow{
  725. @weakify(self);
  726. [LCHttpHelper requestWithURLString:GetAdvert parameters:@{@"position":@(9)} needToken:YES type:(HttpRequestTypePost) success:^(id responseObject) {
  727. NSDictionary* dict = (NSDictionary*)responseObject;
  728. NSInteger code = [[dict objectForKey:@"code"] integerValue];
  729. if (code==0) {//成功
  730. @strongify(self);
  731. YOUPAILCFirstRechargeModel *firstRechargeModel = [YOUPAILCFirstRechargeModel mj_objectWithKeyValues:dict[@"data"]];
  732. if (firstRechargeModel.youpaiplist.count == 0) {
  733. [ZCHUDHelper showTitle:@"暂时没有相关活动"];
  734. return;
  735. }
  736. YOUPAILZChatRoomGameCenterWindow *window = [[YOUPAILZChatRoomGameCenterWindow alloc] init];
  737. window.youpaiplist = firstRechargeModel.youpaiplist;
  738. window.isTouchDismiss = YES;
  739. [window setYoupaipitemClickBlock:^(YOUPAILCBannerModel * _Nonnull model) {
  740. @strongify(self);
  741. if (model.youpaipwindow_type == 2) {
  742. YOUPAIHRWebWindow *window = [[YOUPAIHRWebWindow alloc] init];
  743. window.isTouchDismiss = YES;
  744. window.youpaipurl = model.youpaipwindow_link;
  745. window.youpaipwidth = model.youpaipwidth;
  746. window.youpaipheight = model.youpaipheight;
  747. window.youpaipgravity = model.youpaipgravity;
  748. [self TFPresentVC:window completion:^{}];
  749. }else{
  750. if (model.youpaiplink_type == 1) {
  751. ZCBaseWebVC* baseWeb = [[ZCBaseWebVC alloc]init];
  752. baseWeb.contentUrl = model.youpaiplink_url;
  753. [[LCTools getContainNavigationControllerCurrentVC].navigationController pushViewController:baseWeb animated:YES];
  754. }else if (model.youpaiplink_type==2 || model.youpaiplink_type==3){
  755. [[LCTools getContainNavigationControllerCurrentVC] youpaifpageToStr:model.youpaiplink_url];
  756. }else{
  757. }
  758. }
  759. }];
  760. [self TFPresentVC:window completion:^{}];
  761. }
  762. } failure:^(NSError *error) {
  763. }];
  764. }
  765. /// 礼物弹窗
  766. - (void)youpaifshowGiftWindow{
  767. @weakify(self);
  768. YOUPAIHRChatRoomGiftView *giftWindow = [[YOUPAIHRChatRoomGiftView alloc] init];
  769. giftWindow.isTouchDismiss = YES;
  770. NSMutableArray *seats = [YOUPAILZChatRoomSeatModel mj_keyValuesArrayWithObjectArray:self.youpaipchatroomModel.youpaipnormalSeats];
  771. NSMutableDictionary *hostSeatDict = [self.youpaipchatroomModel.youpaiphostSeat mj_keyValues];
  772. if (hostSeatDict != nil) {
  773. [seats insertObject:hostSeatDict atIndex:0];
  774. }
  775. giftWindow.youpaipnormalSeatJsons = seats;
  776. /// 赠送礼物
  777. [giftWindow setYoupaiplzgiftblock:^(YOUPAILCGiftModel * _Nonnull giftModel, NSString * _Nonnull userIds, NSInteger count, NSString * _Nonnull categoryID) {
  778. @strongify(self);
  779. [LCHttpHelper requestWithURLString:TalkSendGift parameters:@{@"to_uid":userIds,@"gift_id":giftModel.youpaipid,@"num":@(count),@"room_id":self.youpaipchatroomModel.youpaiproom_id,@"gift_type_id":categoryID} needToken:YES type:(HttpRequestTypePost) success:^(id responseObject) {
  780. NSDictionary* dict = (NSDictionary*)responseObject;
  781. NSInteger code = [[dict objectForKey:@"code"] integerValue];
  782. if (code==0) {//成功
  783. [ZCHUDHelper showTitle:@"礼物赠送成功"];
  784. [giftWindow youpaifreloadBalance];
  785. }
  786. } failure:^(NSError *error) {
  787. }];
  788. }];
  789. /// 跳转到钱包
  790. [giftWindow setYoupaipjumToWalletBlock1:^{
  791. @strongify(self);
  792. // YOUPAIHRRechargePayWindow *payWindow = [YOUPAIHRRechargePayWindow new];
  793. // payWindow.isTouchDismiss = NO;
  794. // [self TFPresentVC:payWindow completion:^{
  795. //
  796. // }];
  797. YMAccountBalanceViewModel *accountBalanceVM = [[YMAccountBalanceViewModel alloc]initWithParams:@{
  798. ParamsId:@([[LCSaveModel getUserModel].youpaipuserinfo.youpaipuser_id intValue])
  799. }];
  800. YMAccountBalanceRechargePopupView *customView = [[YMAccountBalanceRechargePopupView alloc]init];
  801. [customView ym_bindViewModel:accountBalanceVM];
  802. YMPopupView *popupView = [YMPopupView initWithCustomView:customView parentView:nil popStyle:YMPopupStyleSmoothFromBottom dismissStyle:YMDismissStyleSmoothToBottom];
  803. popupView.priority = 999;
  804. popupView.cornerRadius = adapt(10);
  805. popupView.rectCorners = UIRectCornerTopLeft|UIRectCornerTopRight;
  806. popupView.positionStyle = YMPositionStyleBottom;
  807. popupView.isClickBgDismiss = YES;
  808. popupView.isHideBg = NO;
  809. popupView.bgAlpha = 0.5;
  810. [popupView pop];
  811. @weakify(popupView)
  812. customView.dismissBlock = ^{
  813. @strongify(popupView)
  814. [popupView dismissWithStyle:YMDismissStyleSmoothToBottom duration:2.0];
  815. };
  816. }];
  817. /// 广告
  818. [giftWindow setYoupaiptouchAdvertBlock:^(YOUPAILCBannerModel * _Nonnull bannerModel) {
  819. @strongify(self);
  820. if (bannerModel.youpaiplink_type==1) {
  821. ZCBaseWebVC* baseWeb = [[ZCBaseWebVC alloc]init];
  822. baseWeb.contentUrl = bannerModel.youpaiplink_url;
  823. [self.navigationController pushViewController:baseWeb animated:YES];
  824. }else if (bannerModel.youpaiplink_type==2||bannerModel.youpaiplink_type==3){
  825. [self youpaifpageToStr:bannerModel.youpaiplink_url];
  826. }
  827. }];
  828. [self TFPresentVC:giftWindow completion:^{}];
  829. }
  830. ///更多item点击操作
  831. - (void)youpaifmoreWindowItemClickWithType:(LZChatRoomOperationType)type isOpen:(BOOL)isOpen{
  832. switch (type) {
  833. case LZChatRoomOperationTypeWithAnimation:{
  834. self.youpaipmoreModel.youpaipisCloseAnimation = isOpen;
  835. if (self.youpaipmoreModel.youpaipisCloseAnimation) {
  836. [ZCHUDHelper showTitle:@"动画特效已关闭"];
  837. }else{
  838. [ZCHUDHelper showTitle:@"动画特效已开启"];
  839. }
  840. }
  841. break;
  842. case LZChatRoomOperationTypeWithFreeSeat:{
  843. [self youpaifadjustSeatAlertWithIsOpen:isOpen];
  844. }
  845. break;
  846. case LZChatRoomOperationTypeWithEmptyChat:{
  847. [self youpaifemptyChatAlert];
  848. }
  849. break;
  850. case LZChatRoomOperationTypeWithCloseChat:{
  851. [self youpaifchatroomMessageAlertWithIsOpen:isOpen];
  852. }
  853. break;
  854. case LZChatRoomOperationTypeWithRoomLock:{
  855. [self youpaifchatroomLockWithIsOpen:isOpen];
  856. }
  857. break;
  858. case LZChatRoomOperationTypeWithRoomInfo:{
  859. [self youpaifchatroomEditInfo];
  860. }
  861. break;
  862. case LZChatRoomOperationTypeWithDisableMessage:{
  863. [self youpaifblackOrDisableMessageListWithType:@"mute" youpaiptitleStr:@"禁言管理" youpaipbtnTitle:@"解除禁言"];
  864. }
  865. break;
  866. case LZChatRoomOperationTypeWithRoomBlockList:{
  867. [self youpaifblackOrDisableMessageListWithType:@"kick" youpaiptitleStr:@"房间黑名单" youpaipbtnTitle:@"解除限制"];
  868. }
  869. break;
  870. case LZChatRoomOperationTypeWithBgMusic:{
  871. [self youpaifbackgoundMusic];
  872. }
  873. break;
  874. case LZChatRoomOperationTypeWithMute:{
  875. self.youpaipmoreModel.youpaipisRemoteAudio = !self.youpaipmoreModel.youpaipisRemoteAudio;
  876. if (self.youpaipmoreModel.youpaipisRemoteAudio) {
  877. [ZCHUDHelper showTitle:@"静音已打开"];
  878. }else{
  879. [ZCHUDHelper showTitle:@"静音已关闭"];
  880. }
  881. [[YOUPAILZChatRoomManager shareManager] youpaifmuteAllRemoteAudioStreams:self.youpaipmoreModel.youpaipisRemoteAudio];
  882. }
  883. break;
  884. case LZChatRoomOperationTypeWithReport:{
  885. YOUPAILZChatRoomReportWindow *window = [[YOUPAILZChatRoomReportWindow alloc] init];
  886. window.youpaipchatroomModel = self.youpaipchatroomModel;
  887. [self TFPresentVC:window completion:^{}];
  888. }
  889. break;
  890. case LZChatRoomOperationTypeWithCardiac:{
  891. NSString *title = @"开启心动值";
  892. NSString *content = @"麦位下将开启心动值的展示与统计\n(礼物价值累加)";
  893. if (!isOpen) {
  894. title = @"关闭心动值";
  895. content = @"麦位下将关闭心动值的展示与统计";
  896. }
  897. @weakify(self);
  898. LZAlertAction *cancelAction = [LZAlertAction actionWithTitle:@"取消" handler:^(LZAlertAction *action) {
  899. }];
  900. cancelAction.cornerRadius = 24.0f;
  901. cancelAction.bgColor = HexColorFromRGB(0x9F9DA5);
  902. LZAlertAction *confimAction = [LZAlertAction actionWithTitle:@"确定" handler:^(LZAlertAction *action) {
  903. @strongify(self);
  904. if (isOpen) {
  905. [self youpaiftransferPlayWithType:1];
  906. }else{
  907. [self youpaiftransferPlayWithType:0];
  908. }
  909. }];
  910. confimAction.cornerRadius = 24.0f;
  911. confimAction.bgColor = [UIColor colorWithPatternImage:[LCTools ColorImage:CGSizeMake((KScreenWidth - 105.0f) / 2.0f, 48.0f) FromColors:@[ZYGradientOneColor,ZYGradientTwoColor] ByGradientType:GradientLeftToRight]];
  912. LZAlertWindow *alert = [LZAlertWindow alertWithTitle:title content:content action:@[cancelAction,confimAction]];
  913. alert.contentTextAlignment = NSTextAlignmentCenter;
  914. [self TFPresentVC:alert completion:^{}];
  915. }
  916. break;
  917. case LZChatRoomOperationTypeWithClearCardiac:{
  918. @weakify(self);
  919. LZAlertAction *cancelAction = [LZAlertAction actionWithTitle:@"取消" handler:^(LZAlertAction *action) {
  920. }];
  921. cancelAction.cornerRadius = 24.0f;
  922. cancelAction.bgColor = HexColorFromRGB(0x9F9DA5);
  923. LZAlertAction *confimAction = [LZAlertAction actionWithTitle:@"确定" handler:^(LZAlertAction *action) {
  924. @strongify(self);
  925. [self youpaifclearCardiac];
  926. }];
  927. confimAction.cornerRadius = 24.0f;
  928. confimAction.bgColor = [UIColor colorWithPatternImage:[LCTools ColorImage:CGSizeMake((KScreenWidth - 105.0f) / 2.0f, 48.0f) FromColors:@[ZYGradientOneColor,ZYGradientTwoColor] ByGradientType:GradientLeftToRight]];
  929. LZAlertWindow *alert = [LZAlertWindow alertWithTitle:@"清空心动值" content:@"将清空所有麦上用户现有的心动值,\n重新统计" action:@[cancelAction,confimAction]];
  930. alert.contentTextAlignment = NSTextAlignmentCenter;
  931. [self TFPresentVC:alert completion:^{}];
  932. }
  933. break;
  934. case LZChatRoomOperationTypeWithBlindDate:{
  935. NSString *title = @"开启相亲";
  936. NSString *content = @"当前房间将更换为相亲玩法";
  937. if (!isOpen) {
  938. title = @"关闭相亲";
  939. content = @"当前房间将关闭相亲玩法,恢复普通语聊房";
  940. }
  941. @weakify(self);
  942. LZAlertAction *cancelAction = [LZAlertAction actionWithTitle:@"取消" handler:^(LZAlertAction *action) {
  943. }];
  944. cancelAction.cornerRadius = 24.0f;
  945. cancelAction.bgColor = HexColorFromRGB(0x9F9DA5);
  946. LZAlertAction *confimAction = [LZAlertAction actionWithTitle:@"确定" handler:^(LZAlertAction *action) {
  947. @strongify(self);
  948. if (isOpen) {
  949. [self youpaiftransferPlayWithType:3];
  950. }else{
  951. [self youpaiftransferPlayWithType:2];
  952. }
  953. }];
  954. confimAction.cornerRadius = 24.0f;
  955. confimAction.bgColor = [UIColor colorWithPatternImage:[LCTools ColorImage:CGSizeMake((KScreenWidth - 105.0f) / 2.0f, 48.0f) FromColors:@[ZYGradientOneColor,ZYGradientTwoColor] ByGradientType:GradientLeftToRight]];
  956. LZAlertWindow *alert = [LZAlertWindow alertWithTitle:title content:content action:@[cancelAction,confimAction]];
  957. alert.contentTextAlignment = NSTextAlignmentCenter;
  958. [self TFPresentVC:alert completion:^{}];
  959. }
  960. break;
  961. case LZChatRoomOperationTypeWithBackgoundImage:{
  962. YOUPAILZChatRoomSetterBgImgWindow *window = [[YOUPAILZChatRoomSetterBgImgWindow alloc] init];
  963. window.isTouchDismiss = YES;
  964. window.youpaipchatroomModel = self.youpaipchatroomModel;
  965. [self TFPresentVC:window completion:^{}];
  966. }
  967. break;
  968. default:
  969. break;
  970. }
  971. }
  972. /// 切换玩法
  973. /// type 0关闭心动 1开启心动 2关闭相亲 3开启相亲
  974. - (void)youpaiftransferPlayWithType:(NSInteger)type{
  975. [LCHttpHelper requestWithURLString:ChatroomCardiac parameters:@{@"room_id":self.youpaipchatroomModel.youpaiproom_id,@"type":@(type)} needToken:YES type:(HttpRequestTypePost) success:^(id responseObject) {
  976. NSDictionary* dict = (NSDictionary*)responseObject;
  977. NSInteger code = [[dict objectForKey:@"code"] integerValue];
  978. if (code==0) {//成功
  979. [ZCHUDHelper showTitle:@"操作成功"];
  980. }
  981. } failure:^(NSError *error) {
  982. }];
  983. }
  984. /// 清空心动值
  985. - (void)youpaifclearCardiac{
  986. [LCHttpHelper requestWithURLString:ChatroomClearCardiac parameters:@{@"room_id":self.youpaipchatroomModel.youpaiproom_id} needToken:YES type:(HttpRequestTypePost) success:^(id responseObject) {
  987. NSDictionary* dict = (NSDictionary*)responseObject;
  988. NSInteger code = [[dict objectForKey:@"code"] integerValue];
  989. if (code==0) {//成功
  990. [ZCHUDHelper showTitle:@"操作成功"];
  991. }
  992. } failure:^(NSError *error) {
  993. }];
  994. }
  995. /// 调整麦序弹框
  996. - (void)youpaifadjustSeatAlertWithIsOpen:(BOOL)isOpen{
  997. NSString *title = @"开启自由麦序";
  998. NSString *content = @"当前房间内所有用户可自由上下麦";
  999. if (!isOpen) {
  1000. title = @"关闭自由麦序";
  1001. content = @"当前房间内所有用户将无法自由上下麦";
  1002. }
  1003. @weakify(self);
  1004. LZAlertAction *cancelAction = [LZAlertAction actionWithTitle:@"取消" handler:^(LZAlertAction *action) {
  1005. }];
  1006. cancelAction.cornerRadius = 24.0f;
  1007. cancelAction.bgColor = HexColorFromRGB(0x9F9DA5);
  1008. LZAlertAction *confimAction = [LZAlertAction actionWithTitle:@"确定" handler:^(LZAlertAction *action) {
  1009. @strongify(self);
  1010. [self youpaifadjustSeatWithIsOpen:isOpen];
  1011. }];
  1012. confimAction.cornerRadius = 24.0f;
  1013. confimAction.bgColor = [UIColor colorWithPatternImage:[LCTools ColorImage:CGSizeMake((KScreenWidth - 105.0f) / 2.0f, 48.0f) FromColors:@[ZYGradientOneColor,ZYGradientTwoColor] ByGradientType:GradientLeftToRight]];
  1014. LZAlertWindow *alert = [LZAlertWindow alertWithTitle:title content:content action:@[cancelAction,confimAction]];
  1015. alert.contentTextAlignment = NSTextAlignmentCenter;
  1016. [self TFPresentVC:alert completion:^{}];
  1017. }
  1018. /// 调整麦序
  1019. - (void)youpaifadjustSeatWithIsOpen:(BOOL)isOpen{
  1020. if (isOpen) {
  1021. self.youpaipchatroomModel.youpaiptalk_type = @"free"; // 自由麦
  1022. }else{
  1023. self.youpaipchatroomModel.youpaiptalk_type = @"host"; // 主持麦
  1024. }
  1025. [LCHttpHelper requestWithURLString:SetTalkType parameters:@{@"room_id":self.youpaipchatroomModel.youpaiproom_id,@"operate":self.youpaipchatroomModel.youpaiptalk_type} needToken:YES type:(HttpRequestTypePost) success:^(id responseObject) {
  1026. NSDictionary* dict = (NSDictionary*)responseObject;
  1027. NSInteger code = [[dict objectForKey:@"code"] integerValue];
  1028. if (code==0) {//成功
  1029. [ZCHUDHelper showTitle:@"操作成功"];
  1030. }
  1031. } failure:^(NSError *error) {
  1032. }];
  1033. }
  1034. /// 清空公屏
  1035. - (void)youpaifemptyChatAlert{
  1036. @weakify(self);
  1037. LZAlertAction *cancelAction = [LZAlertAction actionWithTitle:@"取消" handler:^(LZAlertAction *action) {
  1038. }];
  1039. cancelAction.cornerRadius = 24.0f;
  1040. cancelAction.bgColor = HexColorFromRGB(0x9F9DA5);
  1041. LZAlertAction *confimAction = [LZAlertAction actionWithTitle:@"确定" handler:^(LZAlertAction *action) {
  1042. @strongify(self);
  1043. [LCHttpHelper requestWithURLString:ClearTalk parameters:@{@"room_id":self.youpaipchatroomModel.youpaiproom_id} needToken:YES type:(HttpRequestTypePost) success:^(id responseObject) {
  1044. } failure:^(NSError *error) {
  1045. }];
  1046. }];
  1047. confimAction.cornerRadius = 24.0f;
  1048. confimAction.bgColor = [UIColor colorWithPatternImage:[LCTools ColorImage:CGSizeMake((KScreenWidth - 105.0f) / 2.0f, 48.0f) FromColors:@[ZYGradientOneColor,ZYGradientTwoColor] ByGradientType:GradientLeftToRight]];
  1049. LZAlertWindow *alert = [LZAlertWindow alertWithTitle:@"清空公屏" content:@"当前房间内所有用户的公屏消息将被清空" action:@[cancelAction,confimAction]];
  1050. alert.contentTextAlignment = NSTextAlignmentCenter;
  1051. [self TFPresentVC:alert completion:^{}];
  1052. }
  1053. /// 房间上锁
  1054. - (void)youpaifchatroomLockWithIsOpen:(BOOL)isOpen{
  1055. if (isOpen) {
  1056. YOUPAILZChatRoomUpLockWindow *window = [[YOUPAILZChatRoomUpLockWindow alloc] init];
  1057. @weakify(self);
  1058. [window setYoupaipconfirmBtnClickBlock:^(NSString * _Nonnull password) {
  1059. @strongify(self);
  1060. [self youpaifchatroomLockWithPassword:password];
  1061. }];
  1062. [self TFPresentVC:window completion:^{}];
  1063. }else{
  1064. [self youpaifchatroomLockWithPassword:@""];
  1065. }
  1066. }
  1067. /// 房间上锁、解锁
  1068. - (void)youpaifchatroomLockWithPassword:(NSString *)password{
  1069. [LCHttpHelper requestWithURLString:SetTalkPwd parameters:@{@"room_id":self.youpaipchatroomModel.youpaiproom_id,@"pwd":password} needToken:YES type:(HttpRequestTypePost) success:^(id responseObject) {
  1070. NSDictionary* dict = (NSDictionary*)responseObject;
  1071. NSInteger code = [[dict objectForKey:@"code"] integerValue];
  1072. if (code==0) {//成功
  1073. if (password.length == 0) {
  1074. [ZCHUDHelper showTitle:@"房间已解锁"];
  1075. }else{
  1076. [ZCHUDHelper showTitle:@"房间已上锁"];
  1077. }
  1078. }
  1079. } failure:^(NSError *error) {
  1080. }];
  1081. }
  1082. /// 语聊房消息是否开启弹窗
  1083. - (void)youpaifchatroomMessageAlertWithIsOpen:(BOOL)isOpen{
  1084. NSString *title = @"关闭公屏";
  1085. NSString *content = @"当前房间内所有用户将无法发送公屏消息";
  1086. if (!isOpen) {
  1087. title = @"开启公屏";
  1088. content = @"当前房间内所有用户可正常发送公屏消息";
  1089. }
  1090. @weakify(self);
  1091. LZAlertAction *cancelAction = [LZAlertAction actionWithTitle:@"取消" handler:^(LZAlertAction *action) {
  1092. }];
  1093. cancelAction.cornerRadius = 24.0f;
  1094. cancelAction.bgColor = HexColorFromRGB(0x9F9DA5);
  1095. LZAlertAction *confimAction = [LZAlertAction actionWithTitle:@"确定" handler:^(LZAlertAction *action) {
  1096. @strongify(self);
  1097. [self youpaifchatroomMessageWithIsOpen:isOpen];
  1098. }];
  1099. confimAction.cornerRadius = 24.0f;
  1100. confimAction.bgColor = [UIColor colorWithPatternImage:[LCTools ColorImage:CGSizeMake((KScreenWidth - 105.0f) / 2.0f, 48.0f) FromColors:@[ZYGradientOneColor,ZYGradientTwoColor] ByGradientType:GradientLeftToRight]];
  1101. LZAlertWindow *alert = [LZAlertWindow alertWithTitle:title content:content action:@[cancelAction,confimAction]];
  1102. alert.contentTextAlignment = NSTextAlignmentCenter;
  1103. [self TFPresentVC:alert completion:^{}];
  1104. }
  1105. /// 语聊房消息是否开启
  1106. - (void)youpaifchatroomMessageWithIsOpen:(BOOL)isOpen{
  1107. NSInteger type = 0;
  1108. if (isOpen) {
  1109. type = 1;
  1110. }
  1111. [LCHttpHelper requestWithURLString:OpenACloseTalk parameters:@{@"room_id":self.youpaipchatroomModel.youpaiproom_id,@"type":@(type)} needToken:YES type:(HttpRequestTypePost) success:^(id responseObject) {
  1112. } failure:^(NSError *error) {
  1113. }];
  1114. }
  1115. /// 编辑房间资料
  1116. - (void)youpaifchatroomEditInfo{
  1117. YOUPAILZChatRoomInfoEditWindow *window = [[YOUPAILZChatRoomInfoEditWindow alloc] init];
  1118. window.youpaipchatroomModel = self.youpaipchatroomModel;
  1119. window.isTouchDismiss = NO;
  1120. [self TFPresentVC:window completion:^{}];
  1121. }
  1122. /// 背景音乐
  1123. - (void)youpaifbackgoundMusic{
  1124. self.youpaiplyrieView.hidden = NO;
  1125. YOUPAILZMusicLibraryWindow *window = [[YOUPAILZMusicLibraryWindow alloc] init];
  1126. window.isTouchDismiss = YES;
  1127. @weakify(self);
  1128. [window setMusicLibBtnClickBlock:^{
  1129. @strongify(self);
  1130. YOUPAILZMusicWindow *musicWindow = [[YOUPAILZMusicWindow alloc] init];
  1131. musicWindow.isTouchDismiss = YES;
  1132. [self TFPresentVC:musicWindow completion:^{}];
  1133. }];
  1134. [window setCloseBtnClickBlock:^{
  1135. @strongify(self);
  1136. [self.youpaiplyrieView youpaifclose];
  1137. self.youpaiplyrieView.hidden = YES;
  1138. [[YOUPAILZChatRoomManager shareManager] youpaifStopPlayMusic];
  1139. [[YOUPAILZMusicManager shareManager] youpaifpause];
  1140. [[YOUPAILZMusicManager shareManager] youpaifstopPlay];
  1141. }];
  1142. [self TFPresentVC:window completion:^{}];
  1143. }
  1144. /// 黑名单、禁言列表
  1145. - (void)youpaifblackOrDisableMessageListWithType:(NSString *)type youpaiptitleStr:(NSString *)youpaiptitleStr youpaipbtnTitle:(NSString *)youpaipbtnTitle{
  1146. YOUPAILZChatRoomBlockListWindow *window = [[YOUPAILZChatRoomBlockListWindow alloc] init];
  1147. window.youpaipchatroomModel = self.youpaipchatroomModel;
  1148. window.youpaiptype = type;
  1149. window.youpaiptitleStr = youpaiptitleStr;
  1150. window.youpaipbtnTitle = youpaipbtnTitle;
  1151. [self TFPresentVC:window completion:^{}];
  1152. }
  1153. - (void)youpaifinitKeyboardView{
  1154. @weakify(self);
  1155. LZBKeyBoardToolEmojiBar *keyboardView = [LZBKeyBoardToolEmojiBar showKeyBoardWithConfigToolBarHeight:0 sendTextCompletion:^(NSString *sendText) {
  1156. @strongify(self);
  1157. NSString *temp = [sendText stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]];
  1158. NSString *text = [temp stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
  1159. if (text.length != 0) {
  1160. @weakify(self);
  1161. [LCHttpHelper requestWithURLString:ChatRoomSendMessage parameters:@{@"room_id":self.youpaipchatroomModel.youpaiproom_id,@"content":text} needToken:YES type:HttpRequestTypePost success:^(id responseObject) {
  1162. @strongify(self);
  1163. NSDictionary* dict = (NSDictionary*)responseObject;
  1164. NSInteger code = [[dict objectForKey:@"code"] integerValue];
  1165. if (code == 0) {
  1166. NIMSession *session = [NIMSession session:self.youpaipchatroomModel.youpaiproom_id type:NIMSessionTypeChatroom];
  1167. NIMMessage *imMessage = [NIMMessageMaker msgWithText:[[dict objectForKey:@"data"] objectForKey:@"content"]];
  1168. if ([[[NIMSDK sharedSDK] chatManager] sendMessage:imMessage toSession:session error:nil]) {
  1169. [self.youpaipkeyboardView resignFirstResponder];
  1170. self.youpaipkeyboardView.hidden = YES;
  1171. }
  1172. }else{
  1173. [self.youpaipkeyboardView resignFirstResponder];
  1174. self.youpaipkeyboardView.hidden = YES;
  1175. [ZCHUDHelper showTitle:[dict objectForKey:@"message"]];
  1176. }
  1177. } failure:^(NSError *error) {
  1178. @strongify(self);
  1179. [self.youpaipkeyboardView resignFirstResponder];
  1180. self.youpaipkeyboardView.hidden = YES;
  1181. [ZCHUDHelper showTitle:error.localizedDescription];
  1182. }];
  1183. }
  1184. }];
  1185. [keyboardView setAnimationEmojiBtnClickBlock:^{
  1186. @strongify(self);
  1187. [self.youpaipkeyboardView resignFirstResponder];
  1188. self.youpaipkeyboardView.hidden = YES;
  1189. YOUPAILZChatRoomEmojiAnimationWindow *window = [[YOUPAILZChatRoomEmojiAnimationWindow alloc] init];
  1190. window.youpaipchatroomModel = self.youpaipchatroomModel;
  1191. window.isTouchDismiss = YES;
  1192. [window setYoupaipyoupaifchatEmojiBtnClickBlock:^{
  1193. @strongify(self);
  1194. self.youpaipkeyboardView.hidden = NO;
  1195. [self.youpaipkeyboardView showEmoji];
  1196. }];
  1197. [self TFPresentVC:window completion:^{}];
  1198. }];
  1199. [keyboardView setInputViewPlaceHolderText:@"说点什么…"];
  1200. keyboardView.hidden = YES;
  1201. [self.view addSubview:keyboardView];
  1202. self.youpaipkeyboardView = keyboardView;
  1203. }
  1204. - (void)youpaifinitMessageTableView{
  1205. //消息列表
  1206. UITableView *tableView = [[UITableView alloc] initWithFrame:CGRectZero style:UITableViewStyleGrouped];
  1207. tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
  1208. tableView.showsVerticalScrollIndicator = NO;
  1209. tableView.delegate = self;
  1210. tableView.dataSource = self;
  1211. tableView.backgroundColor = [UIColor clearColor];
  1212. // tableView.transform = CGAffineTransformMakeRotation(M_PI * 1.0001f);
  1213. tableView.transform = CGAffineTransformMakeScale(1, -1);
  1214. tableView.rowHeight = UITableViewAutomaticDimension;
  1215. tableView.estimatedSectionHeaderHeight = 0.0f;
  1216. tableView.estimatedSectionFooterHeight = 0.0f;
  1217. [self.view addSubview:tableView];
  1218. self.youpaipmessageTableView = tableView;
  1219. [tableView mas_makeConstraints:^(MASConstraintMaker *make) {
  1220. make.left.offset(10.0f);
  1221. make.bottom.equalTo(self.youpaipfooterView.mas_top).offset(-14.0f);
  1222. make.width.offset(276.0f);
  1223. make.top.equalTo(self.youpaipotherSeatCollectionView.mas_bottom).offset(0.0f);
  1224. }];
  1225. }
  1226. // 我要上麦、排麦中、上麦申请按钮
  1227. - (void)youpaifinitApplySeatButton{
  1228. BOOL youpaipisHide = NO;
  1229. if (self.youpaipchatroomModel.youpaipchatroomType == LZChatRoomTypeWithFree) {
  1230. youpaipisHide = YES;
  1231. }
  1232. LZChatRoomApplySeatType applySeatType = LZChatRoomApplySeatTypeWithUpSeat;
  1233. if (self.youpaipchatroomModel.youpaipuserInfo.youpaifroleType != LZUserRoleTypeWithNormal) {
  1234. applySeatType = LZChatRoomApplySeatTypeWithApplyList;
  1235. }
  1236. YOUPAILZChatRoomApplySeatButton *youpaipapplySeatButton = [[YOUPAILZChatRoomApplySeatButton alloc] initWithType:applySeatType playType:self.youpaipchatroomModel.youpaipplayType];
  1237. youpaipapplySeatButton.hidden = youpaipisHide;
  1238. youpaipapplySeatButton.youpaipmemberCount = [self.youpaipchatroomModel.youpaipsay_count integerValue];
  1239. [youpaipapplySeatButton addTarget:self action:@selector(youpaifapplySeatButtonClick) forControlEvents:UIControlEventTouchUpInside];
  1240. [self.view addSubview:youpaipapplySeatButton];
  1241. self.youpaipapplySeatButton = youpaipapplySeatButton;
  1242. [youpaipapplySeatButton mas_makeConstraints:^(MASConstraintMaker *make) {
  1243. make.right.offset(-14.0f);
  1244. make.bottom.equalTo(self.youpaipfooterView.mas_top).offset(2.0f);
  1245. make.size.mas_offset(CGSizeMake(50.0f, 50.0f));
  1246. }];
  1247. }
  1248. /// 广告banner
  1249. - (void)youpaifinitAdvertView{
  1250. SDCycleScrollView *youpaipcycleScrollView = [SDCycleScrollView cycleScrollViewWithFrame:CGRectZero delegate:nil placeholderImage:nil];
  1251. youpaipcycleScrollView.bannerImageViewContentMode = UIViewContentModeScaleAspectFit;
  1252. youpaipcycleScrollView.hidden = YES;
  1253. [self.view addSubview:youpaipcycleScrollView];
  1254. self.youpaipcycleScrollView = youpaipcycleScrollView;
  1255. [youpaipcycleScrollView mas_makeConstraints:^(MASConstraintMaker *make) {
  1256. make.right.mas_equalTo(-14.0f);
  1257. make.bottom.equalTo(self.youpaipapplySeatButton.mas_top).offset(-11.0f);
  1258. make.size.mas_equalTo(CGSizeMake(50, 50));
  1259. }];
  1260. youpaipcycleScrollView.autoScrollTimeInterval = 5.0;//2s轮播
  1261. youpaipcycleScrollView.pageControlStyle = SDCycleScrollViewPageContolStyleNone;
  1262. youpaipcycleScrollView.backgroundColor = [UIColor clearColor];
  1263. @weakify(self);
  1264. [youpaipcycleScrollView setClickItemOperationBlock:^(NSInteger currentIndex) {
  1265. @strongify(self);
  1266. YOUPAILCBannerModel* model = self.youpaipfirstRechargeModel.youpaiplist[currentIndex];
  1267. if (model.youpaipwindow_type == 2) {
  1268. YOUPAIHRWebWindow *window = [[YOUPAIHRWebWindow alloc] init];
  1269. window.isTouchDismiss = YES;
  1270. window.youpaipurl = model.youpaipwindow_link;
  1271. window.youpaipwidth = model.youpaipwidth;
  1272. window.youpaipheight = model.youpaipheight;
  1273. window.youpaipgravity = model.youpaipgravity;
  1274. [self TFPresentVC:window completion:^{}];
  1275. }else{
  1276. if (model.youpaiplink_type==1) {
  1277. ZCBaseWebVC* baseWeb = [[ZCBaseWebVC alloc]init];
  1278. baseWeb.contentUrl = model.youpaiplink_url;
  1279. [self.navigationController pushViewController:baseWeb animated:YES];
  1280. }else if (model.youpaiplink_type==2||model.youpaiplink_type==3){
  1281. [self youpaifpageToStr:model.youpaiplink_url];
  1282. }
  1283. }
  1284. }];
  1285. [self youpaifloadAdvertRecharge];
  1286. }
  1287. /// 广告位数据
  1288. -(void)youpaifloadAdvertRecharge{
  1289. @weakify(self);
  1290. [LCHttpHelper requestWithURLString:GetAdvert parameters:@{@"position":@"8"} needToken:YES type:(HttpRequestTypePost) success:^(id responseObject) {
  1291. NSDictionary* dict = (NSDictionary*)responseObject;
  1292. NSInteger code = [[dict objectForKey:@"code"] integerValue];
  1293. if (code==0) {//成功
  1294. @strongify(self);
  1295. self.youpaipfirstRechargeModel = [YOUPAILCFirstRechargeModel mj_objectWithKeyValues:dict[@"data"]];
  1296. NSMutableArray *imgUrlArray = [NSMutableArray new];
  1297. for (YOUPAILCBannerModel* model in self.youpaipfirstRechargeModel.youpaiplist) {
  1298. [imgUrlArray addObject:[LCTools getImageUrlWithAddress:model.youpaipimage]];
  1299. }
  1300. self.youpaipcycleScrollView.imageURLStringsGroup = imgUrlArray;
  1301. if (self.youpaipfirstRechargeModel.youpaipis_open == 1) {
  1302. self.youpaipcycleScrollView.hidden = NO;
  1303. }else{
  1304. self.youpaipcycleScrollView.hidden = YES;
  1305. }
  1306. }
  1307. } failure:^(NSError *error) {}];
  1308. }
  1309. /// 歌词View
  1310. - (void)youpaifinitMusicLyrieView{
  1311. YOUPAILZMusicLyrieView *youpaiplyrieView = [[YOUPAILZMusicLyrieView alloc] init];
  1312. youpaiplyrieView.frame = CGRectMake(KScreenWidth - 68.0f - 8.0f, (KScreenHeight - 68.0f) / 2.0f, 68.0f, 68.0f);
  1313. youpaiplyrieView.hidden = YES;
  1314. [self.view addSubview:youpaiplyrieView];
  1315. self.youpaiplyrieView = youpaiplyrieView;
  1316. UIPanGestureRecognizer *panGestureRecognizer = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(youpaifmusicHandlePan:)];
  1317. [youpaiplyrieView addGestureRecognizer:panGestureRecognizer];
  1318. UITapGestureRecognizer *tapGestureRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(youpaifmusicHandleTap)];
  1319. [youpaiplyrieView addGestureRecognizer:tapGestureRecognizer];
  1320. }
  1321. - (void)youpaifmusicHandlePan:(UIPanGestureRecognizer*)recognizer{
  1322. CGPoint translation = [recognizer translationInView:self.view];
  1323. if(recognizer.state == UIViewAnimatingPositionStart){
  1324. self.youpaipmusicPlayerViewY = self.youpaiplyrieView.mj_y;
  1325. }else if (recognizer.state == UIGestureRecognizerStateChanged) {
  1326. self.youpaiplyrieView.mj_y = self.youpaipmusicPlayerViewY + translation.y;
  1327. }else if(recognizer.state == UIGestureRecognizerStateEnded || recognizer.state == UIGestureRecognizerStateCancelled) {
  1328. [UIView animateWithDuration:0.25f animations:^{
  1329. if (self.youpaiplyrieView.mj_y < NavBarHeight) {
  1330. self.youpaiplyrieView.mj_y = NavBarHeight;
  1331. }else if (self.youpaiplyrieView.mj_y > KScreenHeight - TabbarHeight - self.youpaiplyrieView.mj_h){
  1332. self.youpaiplyrieView.mj_y = KScreenHeight - TabbarHeight - self.youpaiplyrieView.mj_h;
  1333. }
  1334. }];
  1335. }
  1336. }
  1337. - (void)youpaifmusicHandleTap{
  1338. [self youpaifbackgoundMusic];
  1339. }
  1340. /// 上麦处理按钮事件
  1341. - (void)youpaifapplySeatButtonClick{
  1342. }
  1343. /// 初始化声网SDK
  1344. - (void)youpaifinitializeAgoraEngine{
  1345. [[YOUPAILZChatRoomManager shareManager] youpaifinitializeAgoraEngine];
  1346. }
  1347. - (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{
  1348. [self.youpaipkeyboardView resignFirstResponder];
  1349. self.youpaipkeyboardView.hidden = YES;
  1350. }
  1351. /// 关闭按钮事件
  1352. - (void)youpaifcloseBtnClick{
  1353. [self.navigationController popViewControllerAnimated:YES];
  1354. }
  1355. /// 点击公告事件
  1356. - (void)youpaifnoticeBtnClick{
  1357. if (self.youpaipchatroomModel.youpaiptalk_notice.length == 0) {
  1358. return;
  1359. }
  1360. @weakify(self);
  1361. self.youpaipnoticePopupMenu = [YBPopupMenu showRelyOnView:self.youpaipnoticeBtn titles:@[@"",@""] icons:@[@"",@""] menuWidth:KScreenWidth - 32.0f otherSettings:^(YBPopupMenu *popupMenu) {
  1362. @strongify(self)
  1363. popupMenu.delegate = self;
  1364. popupMenu.borderWidth = 0.5f;
  1365. popupMenu.borderColor = HexColorFromRGB(0x4F4B5B);
  1366. popupMenu.backColor = HexColorFromRGB(0x2A2935);
  1367. }];
  1368. self.youpaipnoticePopupMenu.mj_h = 41.0f + [self.youpaipchatroomModel.youpaiptalk_notice heightForFont:LCFont(13.0f) width:KScreenWidth - 32.0f - 34.0f] + 40.0f + 10.0f;
  1369. }
  1370. - (void)youpaifnoticePopupMenuDismiss{
  1371. [self.youpaipnoticePopupMenu dismiss];
  1372. }
  1373. // 展示个人信息
  1374. - (void)youpaifshowUserInfoWithUserId:(NSString *)userId{
  1375. if (self.isLoadingUserInfo) {
  1376. return;
  1377. }
  1378. self.isLoadingUserInfo = YES;
  1379. @weakify(self);
  1380. [LCHttpHelper requestWithURLString:UserShowPage parameters:@{@"user_id":userId,@"no_visitor":@"1"} needToken:YES type:(HttpRequestTypePost) success:^(id responseObject) {
  1381. @strongify(self);
  1382. self.isLoadingUserInfo = NO;
  1383. NSDictionary* dict = (NSDictionary*)responseObject;
  1384. NSInteger code = [[dict objectForKey:@"code"] integerValue];
  1385. if (code==0) {//成功
  1386. YOUPAILCUserShowModel *showModel = [YOUPAILCUserShowModel mj_objectWithKeyValues:[dict objectForKey:@"data"]];
  1387. [self youpaifshowUserInfoWithModel:showModel];
  1388. }
  1389. } failure:^(NSError *error) {
  1390. @strongify(self);
  1391. self.isLoadingUserInfo = NO;
  1392. }];
  1393. }
  1394. - (void)youpaifshowUserInfoWithModel:(YOUPAILCUserShowModel *)showModel{
  1395. @weakify(self);
  1396. YOUPAILZLiveUserInfoWindow *vc = [[YOUPAILZLiveUserInfoWindow alloc] initWithModel:showModel isAnchor:NO isManage:NO];
  1397. vc.isTouchDismiss = YES;
  1398. // 个人中心
  1399. [vc setYoupaipuserShowBlock:^(YOUPAILCUserShowModel * _Nonnull model) {
  1400. @strongify(self);
  1401. YOUPAILZUserShowVC *vc = [[YOUPAILZUserShowVC alloc] init];
  1402. vc.youpaipuserId = model.youpaipinfo.youpaipuserid;
  1403. [self.navigationController pushViewController:vc animated:YES];
  1404. }];
  1405. // 举报
  1406. [vc setYoupaipreportBlock:^(YOUPAILCUserShowModel * _Nonnull model) {
  1407. @strongify(self);
  1408. ZCAlertAction *action = [ZCAlertAction actionWithTitle:@"举报" andblock:^{//举报
  1409. @strongify(self);
  1410. YOUPAILCReportVC* report = [[YOUPAILCReportVC alloc]init];
  1411. report.youpaipreport_uid = model.youpaipinfo.youpaipuserid;
  1412. report.youpaiptype = 5;
  1413. [self.navigationController pushViewController:report animated:YES];
  1414. }];
  1415. ZCAlertAction *action1 = [ZCAlertAction actionWithTitle:@"拉黑" andblock:^{//举报
  1416. @strongify(self);
  1417. [self youpaifshowAddBlackWithUserId:model.youpaipinfo.youpaipuserid];
  1418. }];
  1419. ZCAlertSheetView* alertSheet = [[ZCAlertSheetView alloc]initWithTitle:nil andShowCancelButton:YES andAction:@[action,action1]];
  1420. alertSheet.alertWindow.hidden = NO;
  1421. [alertSheet show];
  1422. }];
  1423. // 礼物
  1424. [vc setYoupaipgiftBlock:^(YOUPAILCUserShowModel * _Nonnull model) {
  1425. @strongify(self);
  1426. NSString *to_uid = model.youpaipinfo.youpaipuserid;
  1427. YOUPAILZCommonGiftView *view = [YOUPAILZCommonGiftView new];
  1428. view.isTouchDismiss = YES;
  1429. view.youpaipcountDown = 3;
  1430. view.youpaipisAnchor = NO;
  1431. [view setYoupaiplzgiftblock:^(YOUPAILCGiftModel * _Nonnull model, NSInteger count,NSString*categoryID) {
  1432. @strongify(self);
  1433. [LCHttpHelper requestWithURLString:TalkSendGift parameters:@{@"to_uid":to_uid,@"gift_id":model.youpaipid,@"num":@(count),@"room_id":self.youpaipchatroomModel.youpaiproom_id,@"gift_type_id":categoryID} needToken:YES type:(HttpRequestTypePost) success:^(id responseObject) {
  1434. NSDictionary* dict = (NSDictionary*)responseObject;
  1435. NSInteger code = [[dict objectForKey:@"code"] integerValue];
  1436. if (code==0) {//成功
  1437. [ZCHUDHelper showTitle:@"礼物赠送成功"];
  1438. }
  1439. } failure:^(NSError *error) {
  1440. }];
  1441. }];
  1442. // 广告
  1443. [view setYoupaiptouchAdvertBlock:^(YOUPAILCBannerModel * _Nonnull bannerModel) {
  1444. @strongify(self);
  1445. if (bannerModel.youpaiplink_type==1) {
  1446. ZCBaseWebVC* baseWeb = [[ZCBaseWebVC alloc]init];
  1447. baseWeb.contentUrl = bannerModel.youpaiplink_url;
  1448. [self.navigationController pushViewController:baseWeb animated:YES];
  1449. }else if (bannerModel.youpaiplink_type==2||bannerModel.youpaiplink_type==3){
  1450. [self youpaifpageToStr:bannerModel.youpaiplink_url];
  1451. }
  1452. }];
  1453. [view setJumToWalletBlock1:^{
  1454. @strongify(self);
  1455. // YOUPAIHRRechargePayWindow *payWindow = [YOUPAIHRRechargePayWindow new];
  1456. // payWindow.isTouchDismiss = NO;
  1457. // [self TFPresentVC:payWindow completion:^{
  1458. //
  1459. // }];
  1460. YMAccountBalanceViewModel *accountBalanceVM = [[YMAccountBalanceViewModel alloc]initWithParams:@{
  1461. ParamsId:@([[LCSaveModel getUserModel].youpaipuserinfo.youpaipuser_id intValue])
  1462. }];
  1463. YMAccountBalanceRechargePopupView *customView = [[YMAccountBalanceRechargePopupView alloc]init];
  1464. [customView ym_bindViewModel:accountBalanceVM];
  1465. YMPopupView *popupView = [YMPopupView initWithCustomView:customView parentView:nil popStyle:YMPopupStyleSmoothFromBottom dismissStyle:YMDismissStyleSmoothToBottom];
  1466. popupView.priority = 999;
  1467. popupView.cornerRadius = adapt(10);
  1468. popupView.rectCorners = UIRectCornerTopLeft|UIRectCornerTopRight;
  1469. popupView.positionStyle = YMPositionStyleBottom;
  1470. popupView.isClickBgDismiss = YES;
  1471. popupView.isHideBg = NO;
  1472. popupView.bgAlpha = 0.5;
  1473. [popupView pop];
  1474. @weakify(popupView)
  1475. customView.dismissBlock = ^{
  1476. @strongify(popupView)
  1477. [popupView dismissWithStyle:YMDismissStyleSmoothToBottom duration:2.0];
  1478. };
  1479. }];
  1480. [self TFPresentVC:view completion:^{
  1481. }];
  1482. }];
  1483. // 守护
  1484. [vc setYoupaipguardBlock:^(YOUPAILCUserShowModel * _Nonnull model) {
  1485. @strongify(self);
  1486. [LCHttpHelper requestWithURLString:UserShowPage parameters:@{@"user_id":[LCSaveModel getUserModel].youpaipuserinfo.youpaipuser_id,@"no_visitor":@"1"} needToken:YES type:(HttpRequestTypePost) success:^(id responseObject) {
  1487. NSDictionary* dict = (NSDictionary*)responseObject;
  1488. NSInteger code = [[dict objectForKey:@"code"] integerValue];
  1489. if (code==0) {//成功
  1490. @strongify(self);
  1491. YOUPAILCUserShowModel *showModel = [YOUPAILCUserShowModel mj_objectWithKeyValues:[dict objectForKey:@"data"]];
  1492. YOUPAILPGuardHerVC *VC= [[YOUPAILPGuardHerVC alloc]init];
  1493. VC.youpaipdelegate = self;
  1494. VC.youpaipuser_id = model.youpaipinfo.youpaipuserid;
  1495. VC.youpaiproomid = self.youpaipchatroomModel.youpaiproom_id;
  1496. VC.vWidth = KScreenWidth-54;
  1497. VC.vHeight = ((KScreenWidth-54)*165)/321.0+261.5;
  1498. VC.youpaipinfoModel = showModel.youpaipguard;
  1499. VC.youpaipisChatRoom = YES;
  1500. VC.isTouchDismiss = YES;
  1501. if(VC.youpaipinfoModel!=nil)
  1502. [self TFPresentVC:VC completion:^{
  1503. }];
  1504. }else{
  1505. [ZCHUDHelper showTitle:[dict objectForKey:@"message"]];
  1506. }
  1507. } failure:^(NSError *error) {
  1508. [ZCHUDHelper showTitle:error.localizedDescription];
  1509. }];
  1510. }];
  1511. // 私信
  1512. [vc setYoupaipsiXinBlock:^(YOUPAILCUserShowModel * _Nonnull model) {
  1513. @strongify(self);
  1514. [self goChatPageWithUserId:model.youpaipinfo.youpaipuserid];
  1515. }];
  1516. // [vc setManageBlock:^(YOUPAILCUserShowModel * _Nonnull model, BOOL isAnchor) {
  1517. //// @strongify(self);
  1518. //// [self youpaifshowliveMembersManageWithModel:model isAnchor:isAnchor];
  1519. // }];
  1520. [self TFPresentVC:vc completion:^{}];
  1521. }
  1522. - (void)goChatPageWithUserId:(NSString *)userId{
  1523. @weakify(self);
  1524. // [LCHttpHelper requestWithURLString:IsChat parameters:@{@"user_id":userId} needToken:YES type:(HttpRequestTypePost) success:^(id responseObject) {
  1525. // NSDictionary* dict = (NSDictionary*)responseObject;
  1526. // NSInteger code = [[dict objectForKey:@"code"] integerValue];
  1527. // if (code==0) {//成功
  1528. // NSInteger is_chat = [[[dict objectForKey:@"data"] objectForKey:@"is_chat"] integerValue];
  1529. // NSString *msg = [[dict objectForKey:@"data"] objectForKey:@"msg"];
  1530. // @strongify(self);
  1531. // if (is_chat == 0) { /// 0不可以 1可以私信
  1532. // LZAlertAction *cancelAction = [LZAlertAction actionWithTitle:@"再想想" handler:^(LZAlertAction *action) {
  1533. //
  1534. // }];
  1535. // cancelAction.cornerRadius = 5.0f;
  1536. // cancelAction.bgColor = HexColorFromRGB(0x9F9DA5);
  1537. // LZAlertAction *confimAction = [LZAlertAction actionWithTitle:@"去充值" handler:^(LZAlertAction *action) {
  1538. // @strongify(self);
  1539. // YOUPAIHRRechargePayWindow *payWindow = [YOUPAIHRRechargePayWindow new];
  1540. // payWindow.isTouchDismiss = NO;
  1541. // [self.navigationController TFPresentVC:payWindow completion:^{
  1542. //
  1543. // }];
  1544. // }];
  1545. // confimAction.cornerRadius = 5.0f;
  1546. // confimAction.bgColor = [UIColor colorWithPatternImage:[LCTools ColorImage:CGSizeMake((KScreenWidth - 105.0f) / 2.0f, 48.0f) FromColors:@[ZYGradientOneColor,ZYGradientTwoColor] ByGradientType:GradientLeftToRight]];
  1547. // LZAlertWindow *alert = [LZAlertWindow alertWithTitle:@"提示" content:msg action:@[cancelAction,confimAction]];
  1548. // alert.contentTextAlignment = NSTextAlignmentCenter;
  1549. // [self TFPresentVC:alert completion:^{}];
  1550. // }else{
  1551. NIMSession *session = [NIMSession session:userId type:NIMSessionTypeP2P];
  1552. if (session) {
  1553. [ZCHUDHelper show];
  1554. [[[NIMSDK sharedSDK] userManager] fetchUserInfos:@[session.sessionId] completion:^(NSArray<NIMUser *> * _Nullable users, NSError * _Nullable error) {
  1555. @strongify(self);
  1556. [ZCHUDHelper dismiss];
  1557. YOUPAILCIMSessionVC *vc = [[YOUPAILCIMSessionVC alloc] initWithSession:session];
  1558. [self.navigationController pushViewController:vc animated:YES];
  1559. }];
  1560. }
  1561. // }
  1562. // }
  1563. // } failure:^(NSError *error) {
  1564. // }];
  1565. }
  1566. /// 拉黑弹框
  1567. - (void)youpaifshowAddBlackWithUserId:(NSString *)userId{
  1568. @weakify(self);
  1569. LZAlertAction *cancelAction = [LZAlertAction actionWithTitle:@"取消" handler:^(LZAlertAction *action) {
  1570. }];
  1571. cancelAction.cornerRadius = 24.0f;
  1572. cancelAction.bgColor = HexColorFromRGB(0x9F9DA5);
  1573. LZAlertAction *confimAction = [LZAlertAction actionWithTitle:@"确定" handler:^(LZAlertAction *action) {
  1574. @strongify(self);
  1575. [LCCommonHttp blackUserId:userId];
  1576. }];
  1577. confimAction.cornerRadius = 24.0f;
  1578. confimAction.bgColor = [UIColor colorWithPatternImage:[LCTools ColorImage:CGSizeMake((KScreenWidth - 105.0f) / 2.0f, 48.0f) FromColors:@[ZYGradientOneColor,ZYGradientTwoColor] ByGradientType:GradientLeftToRight]];
  1579. LZAlertWindow *alert = [LZAlertWindow alertWithTitle:@"提示" content:@"拉黑后,你将不再收到对方的消息,并且你们互相看不到对方的动态更新。可以在“设置-黑名单”中解除。" action:@[cancelAction,confimAction]];
  1580. alert.contentTextAlignment = NSTextAlignmentCenter;
  1581. [self TFPresentVC:alert completion:^{}];
  1582. }
  1583. - (void)youpaifaddGuardSuccess{
  1584. }
  1585. // 展示选择座位
  1586. - (void)youpaifshowSelectedSeatWindowWithUserId:(NSString *)userId youpaipisInviation:(BOOL)youpaipisInviation{
  1587. }
  1588. /// 处理点击用户操作
  1589. - (void)youpaifhandleUserOperationWithUserId:(NSString *)userId{
  1590. }
  1591. #pragma mark - YBPopupMenuDelegate
  1592. - (UITableViewCell *)ybPopupMenu:(YBPopupMenu *)ybPopupMenu cellForRowAtIndex:(NSInteger)index{
  1593. if (index == 0) {
  1594. NSString *cellID = @"YOUPAILZChatRoomNoticeTitleCell";
  1595. YOUPAILZChatRoomNoticeTitleCell *cell = [ybPopupMenu.tableView dequeueReusableCellWithIdentifier:cellID];
  1596. if (cell == nil) {
  1597. cell = [[YOUPAILZChatRoomNoticeTitleCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellID];
  1598. }
  1599. cell.youpaiptitleL.text = @"房间公告";
  1600. return cell;
  1601. }else{
  1602. NSString *cellID = @"YOUPAILZChatRoomNoticeContentCell";
  1603. YOUPAILZChatRoomNoticeContentCell *cell = [ybPopupMenu.tableView dequeueReusableCellWithIdentifier:cellID];
  1604. if (cell == nil) {
  1605. cell = [[YOUPAILZChatRoomNoticeContentCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellID];
  1606. }
  1607. cell.youpaipcontentL.text = self.youpaipchatroomModel.youpaiptalk_notice;
  1608. return cell;
  1609. }
  1610. }
  1611. - (CGFloat)ybPopupMenu:(YBPopupMenu *)ybPopupMenu heightForRowAtIndex:(NSInteger)index{
  1612. if (index == 0) {
  1613. return 41.0f;
  1614. }else{
  1615. return [self.youpaipchatroomModel.youpaiptalk_notice heightForFont:LCFont(13.0f) width:KScreenWidth - 32.0f - 34.0f] + 40.0f;
  1616. }
  1617. }
  1618. #pragma mark - UICollectionViewDataSource
  1619. - (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section{
  1620. return self.youpaipchatroomModel.youpaipnormalSeats.count;
  1621. }
  1622. - (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{
  1623. YOUPAILZChatRoomOthearSeatCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:NSStringFromClass(YOUPAILZChatRoomOthearSeatCell.class) forIndexPath:indexPath];
  1624. [cell youpaifreloadWithModel:self.youpaipchatroomModel.youpaipnormalSeats[indexPath.item]];
  1625. return cell;
  1626. }
  1627. #pragma mark - UICollectionViewDelegate
  1628. - (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath{
  1629. [self youpaifotherSeatClickWithIndex:indexPath.item];
  1630. [self.youpaipkeyboardView resignFirstResponder];
  1631. self.youpaipkeyboardView.hidden = YES;
  1632. }
  1633. #pragma mark - UITableViewDataSource
  1634. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
  1635. return self.youpaipmessages.count;
  1636. }
  1637. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
  1638. NSString *cellID = @"YOUPAILZLiveChatMessageCell";
  1639. YOUPAILZLiveChatMessageCell *cell = [tableView dequeueReusableCellWithIdentifier:cellID];
  1640. if (cell == nil) {
  1641. cell = [[YOUPAILZLiveChatMessageCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellID];
  1642. cell.selectionStyle = UITableViewCellSelectionStyleNone;
  1643. }
  1644. if ([self.youpaipmessages[indexPath.row] isKindOfClass:NIMMessage.class]) {
  1645. NIMMessage *message = self.youpaipmessages[indexPath.row];
  1646. [cell youpaifreloadWithModel:message font:LCFont14 indexPath:indexPath];
  1647. }else if ([self.youpaipmessages[indexPath.row] isKindOfClass:YOUPAILZChatRoomGiftAttachment.class]){
  1648. YOUPAILZChatRoomGiftAttachment *attachment = self.youpaipmessages[indexPath.row];
  1649. [cell youpaifreloadWithAttachment:attachment font:LCFont14 indexPath:indexPath];
  1650. }
  1651. @weakify(self);
  1652. [cell setShowUserInfoBlock:^(NSIndexPath * _Nonnull indexPath1) {
  1653. @strongify(self);
  1654. if ([self.youpaipmessages[indexPath1.row] isKindOfClass:NIMMessage.class]) {
  1655. NIMMessage *message = self.youpaipmessages[indexPath1.row];
  1656. if (message.session.sessionType == NIMSessionTypeChatroom
  1657. && message.messageType == NIMMessageTypeNotification){ /// 如果是聊天室并且消息类型为通知类型
  1658. NIMNotificationObject *object = message.messageObject;
  1659. if (![object.content isKindOfClass:[NIMUnsupportedNotificationContent class]]) {
  1660. NIMChatroomNotificationContent *content = (NIMChatroomNotificationContent *)object.content;
  1661. NSString *fromId = nil;
  1662. for (NIMChatroomNotificationMember *memebr in content.targets) {
  1663. fromId = memebr.userId;
  1664. }
  1665. if (content.eventType == NIMChatroomEventTypeEnter) { /// 有成员加入聊天室
  1666. fromId = message.from;
  1667. }else if(content.eventType == NIMChatroomEventTypeExit){ /// 有成员离开聊天室
  1668. fromId = message.from;
  1669. }else if(content.eventType == NIMChatroomEventTypeKicked){ /// 聊天室成员被踢
  1670. fromId = message.from;
  1671. }
  1672. [self youpaifhandleUserOperationWithUserId:fromId];
  1673. }
  1674. }else{
  1675. [self youpaifhandleUserOperationWithUserId:message.from];
  1676. }
  1677. }else if ([self.youpaipmessages[indexPath1.row] isKindOfClass:YOUPAILZChatRoomGiftAttachment.class]){
  1678. YOUPAILZChatRoomGiftAttachment *attachment = self.youpaipmessages[indexPath1.row];
  1679. [self youpaifhandleUserOperationWithUserId:[NSString stringWithFormat:@"%@",@(attachment.from_uid)]];
  1680. }
  1681. }];
  1682. // [cell setReplyBlock:^(NSIndexPath * _Nonnull indexPath) {
  1683. // @strongify(self);
  1684. // NSString *nick = [NIMKitUtil showNick:message.from inMessage:message];
  1685. // self.sendMessageTF.text = [NSString stringWithFormat:@"@%@ ",nick];
  1686. // [self youpaifsendMessageBecomeFirstResponder];
  1687. // }];
  1688. return cell;
  1689. }
  1690. #pragma mark - UITableViewDelegate
  1691. - (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
  1692. return CGFLOAT_MIN;
  1693. }
  1694. - (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
  1695. return CGFLOAT_MIN;
  1696. }
  1697. //- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section{
  1698. // UIView *v = [[UIView alloc] initWithFrame:CGRectMake(.0f, 0.0f, 276.0f, [self.liveModel youpaifnoticeTextHeight])];
  1699. // v.transform = CGAffineTransformMakeRotation(M_PI);
  1700. // UIView *bgV = [[UIView alloc] initWithFrame:CGRectMake(5.0f, 0, 266.0f, [self.liveModel youpaifnoticeTextHeight])];
  1701. // bgV.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.3f];
  1702. // bgV.layer.cornerRadius = 10.0f;
  1703. // bgV.clipsToBounds = YES;
  1704. // UILabel *textL = [[UILabel alloc] initWithFrame:CGRectMake(15.0f, 10.0f, 236.0f, bgV.mj_h - 20.0f)];
  1705. // NSMutableAttributedString * attributedString1 = [[NSMutableAttributedString alloc] initWithString:self.liveModel.notice_text];
  1706. // NSMutableParagraphStyle * paragraphStyle1 = [[NSMutableParagraphStyle alloc] init];
  1707. // paragraphStyle1.alignment=NSTextAlignmentJustified;
  1708. // NSDictionary * dic =@{
  1709. // NSParagraphStyleAttributeName:paragraphStyle1,
  1710. // NSUnderlineStyleAttributeName:[NSNumber numberWithInteger:NSUnderlineStyleNone],
  1711. // };
  1712. // [attributedString1 setAttributes:dic range:NSMakeRange(0, attributedString1.length)];
  1713. // textL.attributedText = attributedString1;
  1714. // textL.numberOfLines = 0;
  1715. // textL.textColor = HexColorFromRGB(0xFFA68B);
  1716. // textL.font = self.liveModel.isMaxFont ? self.liveModel.maxFont : self.liveModel.minFont;
  1717. // [bgV addSubview:textL];
  1718. // [v addSubview:bgV];
  1719. // return v;
  1720. //}
  1721. - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
  1722. // NIMMessage *message = self.messages[indexPath.row];
  1723. // if ([message isKindOfClass:[YOUPAILZLiveModel class]]) {
  1724. // [self youpaifshowUserInfoWithUserId:self.liveModel.user_info.user_id];
  1725. // }else{
  1726. // [self youpaifshowUserInfoWithUserId:message.from];
  1727. // }
  1728. }
  1729. - (NSMutableArray *)youpaipmessages{
  1730. if (!_youpaipmessages) {
  1731. _youpaipmessages = [NSMutableArray array];
  1732. }
  1733. return _youpaipmessages;
  1734. }
  1735. - (YOUPAILZChatRoomMoreModel *)youpaipmoreModel{
  1736. if (!_youpaipmoreModel) {
  1737. _youpaipmoreModel = [[YOUPAILZChatRoomMoreModel alloc] init];
  1738. }
  1739. return _youpaipmoreModel;
  1740. }
  1741. @end