YOUPAILZLiveAudienceVC.m 42 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925
  1. //
  2. // YOUPAILZLiveAudienceVC.m
  3. // TIANYAN
  4. //
  5. // Created by CY on 2021/5/8.
  6. // Copyright © 2021 leo. All rights reserved.
  7. //
  8. #import "YOUPAILZLiveAudienceVC.h"
  9. #import "YOUPAILZBadgeButton.h"
  10. #import "YOUPAILZAudienceMenuView.h"
  11. #import "YOUPAILCReportVC.h"
  12. #import "YOUPAILPGuardHerVC.h"
  13. #import "UIViewController+TFPresent.h"
  14. #import "YOUPAILZLiveCloseAudienceWindow.h"
  15. #import "YOUPAILZRecommendAnchorView.h"
  16. #import "LZLiveAnimation.h"
  17. #import "YOUPAILCUserShowModel.h"
  18. #import "YOUPAILZLiveMemberListVC.h"
  19. #import "YOUPAILZUserShowVC.h"
  20. #import "SDCycleScrollView.h"
  21. #import "YOUPAILZLiveBoardCycleViewCell.h"
  22. #import "YOUPAILZLiveMemberButton.h"
  23. #import "YOUPAILZLiveAnchorHotWindow.h"
  24. #import "YOUPAILZLiveSendFestivalAlertVC.h"
  25. #import "UIViewController+TFPresent.h"
  26. #import "YOUPAILZCommonGiftView.h"
  27. @interface YOUPAILZLiveAudienceVC () <NIMConversationManagerDelegate,LPGuardHerDelegate,SDCycleScrollViewDelegate>
  28. @property (nonatomic, weak) UIButton *youpaipsendMessageBtn; // 发送消息按钮
  29. @property (nonatomic, weak) UIButton *youpaipvoiceBtn; // 喇叭按钮
  30. @property (nonatomic, weak) UIButton *youpaipbeautyBtn; // 美颜按钮
  31. @property (nonatomic, weak) UIButton *youpaipcloseCameraBtn; // 关闭相机按钮
  32. @property (nonatomic, weak) UIButton *youpaipchangeCameraBtn; // 切换摄像头
  33. //@property (nonatomic, weak) YOUPAILZBadgeButton *messageCountBtn; // 新消息
  34. @property (nonatomic, weak) UILabel *youpaipliveMemberCountL; // 直播人数
  35. @property (nonatomic, strong) NSMutableArray <YOUPAILZLiveMemberButton *> *youpaipmemberBtns; ///直播榜单人数
  36. @property (nonatomic, weak) YOUPAILZBadgeButton *youpaipmessageCountBtn; // 新消息
  37. @property (nonatomic, weak) UIView *youpaiprankBgV; // 排行背景View
  38. //@property (nonatomic, weak) UILabel *youpaipcharmValueL; // 魅力值
  39. @property (nonatomic, weak) SDCycleScrollView *youpaipboardCycleView; // 当前直播间上榜信息View
  40. @property (nonatomic, weak) UILabel *youpaipfansCountL; // 粉丝数
  41. @property (nonatomic, weak) UIButton *youpaipfollowBtn; //关注按钮
  42. @property (nonatomic, strong) YOUPAILZAudienceMenuView *youpaipmenuView;
  43. @end
  44. @implementation YOUPAILZLiveAudienceVC
  45. - (void)viewWillAppear:(BOOL)animated{
  46. [super viewWillAppear:animated];
  47. // [IQKeyboardManager sharedManager].enable = NO;
  48. // [IQKeyboardManager sharedManager].enableAutoToolbar = NO;
  49. [[NIMSDK sharedSDK].conversationManager addDelegate:self];
  50. }
  51. - (void)viewWillDisappear:(BOOL)animated{
  52. [super viewWillDisappear:animated];
  53. // [IQKeyboardManager sharedManager].enable = YES;
  54. // [IQKeyboardManager sharedManager].enableAutoToolbar = YES;
  55. [[NIMSDK sharedSDK].conversationManager removeDelegate:self];
  56. }
  57. - (void)viewDidDisappear:(BOOL)animated{
  58. [super viewDidDisappear:animated];
  59. if (!self.youpaipisNotPanClose) {
  60. [self youpaifleaveChannel];
  61. [[NSNotificationCenter defaultCenter] removeObserver:self];
  62. }
  63. }
  64. - (void)dealloc{
  65. NSString *cls = NSStringFromClass([self class]);
  66. NSLog(@"销毁:--%@ dealloc",cls);
  67. }
  68. - (void)viewDidLoad {
  69. [super viewDidLoad];
  70. self.sx_disableInteractivePop = NO;
  71. [self youpaifsetupHeaderView];
  72. [self youpaifsetupFooterView];
  73. [self youpaifupdateUnread];
  74. [self youpaifhandleBlock];
  75. [self youpaifhandlePKDataInfo];
  76. [self youpaifloadAdvertRecharge];
  77. [[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(youpaifendLive) name:@"CallVideo" object:nil];
  78. [[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(youpaifendLiveTwo) name:@"MeCallVideo" object:nil];
  79. /// 关注状态改变,接收通知
  80. [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(youpaifchangeFollowStateNotification:) name:@"ChangeFollowState" object:nil];
  81. UITapGestureRecognizer *tapGesture = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(youpaifhandleTapGesture:)];
  82. tapGesture.numberOfTapsRequired = 2;
  83. [self.view addGestureRecognizer:tapGesture];
  84. }
  85. - (void)youpaifchangeFollowStateNotification:(NSNotification *)notification{
  86. NSDictionary *dict = [notification userInfo];
  87. if ([dict[@"follow_uid"] isEqual:self.youpaipliveModel.youpaipuser_info.youpaipuser_id]) {
  88. if ([dict[@"is_follow"] integerValue] != 0) { // 加关注
  89. [self.youpaipfollowBtn setBackgroundImage:[LCTools ColorImage:CGSizeMake(34.0f, 23.0f) FromColors:@[HexColorFromRGB(0xF7AC00),HexColorFromRGB(0xFD7E00)] ByGradientType:GradientLeftToRight] forState:UIControlStateNormal];
  90. [self.youpaipfollowBtn setTitle:@"守护" forState:UIControlStateNormal];
  91. [self.youpaipfollowBtn removeTarget:self action:@selector(youpaiffollowBtnClick:) forControlEvents:UIControlEventTouchUpInside];
  92. [self.youpaipfollowBtn addTarget:self action:@selector(youpaifguardBtnClick) forControlEvents:UIControlEventTouchUpInside];
  93. [self youpaiffollow];
  94. }else{ // 取消关注
  95. [self.youpaipfollowBtn setBackgroundImage:[LCTools ColorImage:CGSizeMake(34.0f, 23.0f) FromColors:@[HexColorFromRGB(0xFF0084),HexColorFromRGB(0xFF3A00)] ByGradientType:GradientLeftToRight] forState:UIControlStateNormal];
  96. [self.youpaipfollowBtn setTitle:@"关注" forState:UIControlStateNormal];
  97. [self.youpaipfollowBtn removeTarget:self action:@selector(youpaifguardBtnClick) forControlEvents:UIControlEventTouchUpInside];
  98. [self.youpaipfollowBtn addTarget:self action:@selector(youpaiffollowBtnClick:) forControlEvents:UIControlEventTouchUpInside];
  99. }
  100. }
  101. }
  102. /// 女神直播回调
  103. - (void)youpaifhandleBlock{
  104. @weakify(self);
  105. [self setYoupaipliveCloseBlock:^{
  106. @strongify(self);
  107. [self youpaifleaveChannel];
  108. [self youpaifrequestLiveCloseData];
  109. }];
  110. [self setYoupaipaudienceRecommendMoreAnchorBlock:^{
  111. @strongify(self);
  112. [self youpaifgoRecommendAnchorPage];
  113. }];
  114. [self setYoupaipclickRemoteVideoViewBlock:^(NSString * _Nonnull uid, NSString * _Nonnull room_id) {
  115. @strongify(self);
  116. if (room_id.length != 0) {
  117. [self youpaifjoinLiveWithRoomId:room_id];
  118. }
  119. }];
  120. }
  121. // 处理pk
  122. - (void)youpaifhandlePKDataInfo{
  123. if (self.youpaipliveModel.youpaippk_info != nil) {
  124. self.youpaippkdataView.hidden = NO;
  125. [self.youpaippkdataView youpaifreloadWithAttachment:self.youpaipliveModel.youpaippk_info];
  126. }
  127. }
  128. /// 设置headerView
  129. - (void)youpaifsetupHeaderView{
  130. UIView *headerView = [[UIView alloc] init];
  131. [self.view addSubview:headerView];
  132. [headerView mas_makeConstraints:^(MASConstraintMaker *make) {
  133. make.left.offset(0.0f);
  134. make.height.offset(70.0f);
  135. make.top.offset(StatusBarHeight);
  136. }];
  137. UIButton *anchorInfoBgBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  138. anchorInfoBgBtn.layer.cornerRadius = 17.5f;
  139. anchorInfoBgBtn.clipsToBounds = YES;
  140. anchorInfoBgBtn.tag = [self.youpaipliveModel.youpaipuser_info.youpaipuser_id integerValue];
  141. [anchorInfoBgBtn addTarget:self action:@selector(youpaifshowUserInfoClick:) forControlEvents:UIControlEventTouchUpInside];
  142. anchorInfoBgBtn.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.3f];
  143. [headerView addSubview:anchorInfoBgBtn];
  144. [anchorInfoBgBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  145. make.left.offset(12.0f);
  146. make.top.offset(5.0f);
  147. make.height.offset(35.0f);
  148. make.width.lessThanOrEqualTo(160.0f);
  149. make.right.offset(0.0f);
  150. }];
  151. UIImageView *youpaipavatarImgV = [[UIImageView alloc] init];
  152. youpaipavatarImgV.contentMode = UIViewContentModeScaleAspectFill;
  153. youpaipavatarImgV.layer.cornerRadius = 16.5f;
  154. youpaipavatarImgV.clipsToBounds = YES;
  155. [youpaipavatarImgV sd_setImageWithURL:[LCTools getImageUrlWithAddress:self.youpaipliveModel.youpaipuser_info.youpaipavatar]];
  156. [anchorInfoBgBtn addSubview:youpaipavatarImgV];
  157. [youpaipavatarImgV mas_makeConstraints:^(MASConstraintMaker *make) {
  158. make.left.top.offset(1.0f);
  159. make.size.mas_offset(CGSizeMake(33.0f, 33.0f));
  160. }];
  161. UIImageView *anchorTagImgV = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"vqu_images_anchor_vlog"]];
  162. [anchorInfoBgBtn addSubview:anchorTagImgV];
  163. [anchorTagImgV mas_makeConstraints:^(MASConstraintMaker *make) {
  164. make.right.equalTo(youpaipavatarImgV.mas_right).offset(0.0f);
  165. make.bottom.equalTo(youpaipavatarImgV.mas_bottom).offset(0.0f);
  166. make.size.mas_offset(CGSizeMake(10.0f, 10.0f));
  167. }];
  168. UIButton *youpaipfollowBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  169. youpaipfollowBtn.layer.cornerRadius = 11.5f;
  170. youpaipfollowBtn.clipsToBounds = YES;
  171. youpaipfollowBtn.titleLabel.font = LCFont(12.0f);
  172. [youpaipfollowBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
  173. if(self.youpaipliveModel.youpaipuser_info.youpaipis_follow == 0){
  174. [youpaipfollowBtn setBackgroundImage:[LCTools ColorImage:CGSizeMake(34.0f, 23.0f) FromColors:@[HexColorFromRGB(0xFF0084),HexColorFromRGB(0xFF3A00)] ByGradientType:GradientLeftToRight] forState:UIControlStateNormal];
  175. [youpaipfollowBtn setTitle:@"关注" forState:UIControlStateNormal];
  176. [youpaipfollowBtn addTarget:self action:@selector(youpaiffollowBtnClick:) forControlEvents:UIControlEventTouchUpInside];
  177. }else{
  178. [youpaipfollowBtn setBackgroundImage:[LCTools ColorImage:CGSizeMake(34.0f, 23.0f) FromColors:@[HexColorFromRGB(0xF7AC00),HexColorFromRGB(0xFD7E00)] ByGradientType:GradientLeftToRight] forState:UIControlStateNormal];
  179. [youpaipfollowBtn setTitle:@"守护" forState:UIControlStateNormal];
  180. [youpaipfollowBtn addTarget:self action:@selector(youpaifguardBtnClick) forControlEvents:UIControlEventTouchUpInside];
  181. }
  182. [anchorInfoBgBtn addSubview:youpaipfollowBtn];
  183. self.youpaipfollowBtn = youpaipfollowBtn;
  184. [youpaipfollowBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  185. make.right.offset(-4.0f);
  186. make.width.offset(34.0f);
  187. make.height.offset(23.0f);
  188. make.centerY.equalTo(anchorInfoBgBtn.mas_centerY);
  189. }];
  190. UILabel *youpaipnicknameL = [[UILabel alloc] init];
  191. youpaipnicknameL.font = LCBoldFont(11.0f);
  192. youpaipnicknameL.textColor = [UIColor whiteColor];
  193. youpaipnicknameL.text = self.youpaipliveModel.youpaipuser_info.youpaipnickname;
  194. [anchorInfoBgBtn addSubview:youpaipnicknameL];
  195. [youpaipnicknameL mas_makeConstraints:^(MASConstraintMaker *make) {
  196. make.left.equalTo(youpaipavatarImgV.mas_right).offset(4.0f);
  197. make.right.equalTo(youpaipfollowBtn.mas_left).offset(-12.0f);
  198. make.top.offset(5.0f);
  199. // make.height.offset(17.5f);
  200. }];
  201. UILabel *youpaipfansCountL = [[UILabel alloc] init];
  202. youpaipfansCountL.font = LCFont(8.0f);
  203. youpaipfansCountL.textColor = [UIColor whiteColor];
  204. youpaipfansCountL.text = [NSString stringWithFormat:@"粉丝:%@",self.youpaipliveModel.youpaipfans_count];
  205. [anchorInfoBgBtn addSubview:youpaipfansCountL];
  206. self.youpaipfansCountL = youpaipfansCountL;
  207. [youpaipfansCountL mas_makeConstraints:^(MASConstraintMaker *make) {
  208. make.left.equalTo(youpaipavatarImgV.mas_right).offset(4.0f);
  209. make.right.equalTo(youpaipfollowBtn.mas_left).offset(-12.0f);
  210. make.bottom.offset(-5.0f);
  211. // make.height.offset(17.5f);
  212. }];
  213. UIButton *closeLiveBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  214. [closeLiveBtn setImage:[UIImage imageNamed:@"vqu_images_L_live_anchor_close"] forState:UIControlStateNormal];
  215. [closeLiveBtn setImage:[UIImage imageNamed:@"vqu_images_L_live_anchor_close"] forState:UIControlStateHighlighted];
  216. [closeLiveBtn addTarget:self action:@selector(youpaifendLive) forControlEvents:UIControlEventTouchUpInside];
  217. [self.view addSubview:closeLiveBtn];
  218. [closeLiveBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  219. make.right.offset(-12.0f);
  220. make.top.offset(7.0f + StatusBarHeight);
  221. make.height.offset(31.0f);
  222. make.width.offset(19.0f);
  223. }];
  224. UIButton *liveMemberCountBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  225. liveMemberCountBtn.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.3f];
  226. liveMemberCountBtn.layer.cornerRadius = 15.5f;
  227. liveMemberCountBtn.clipsToBounds = YES;
  228. [liveMemberCountBtn addTarget:self action:@selector(youpaifliveMemberCountBtnClick) forControlEvents:UIControlEventTouchUpInside];
  229. [self.youpaipchatBgView addSubview:liveMemberCountBtn];
  230. [liveMemberCountBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  231. make.right.offset(-1.0f-19.0f-12.0f);
  232. make.top.offset(7.0f + StatusBarHeight);
  233. make.height.offset(31.0f);
  234. make.width.greaterThanOrEqualTo(31.0f);
  235. }];
  236. UILabel *youpaipliveMemberCountL = [[UILabel alloc] init];
  237. youpaipliveMemberCountL.font = LCFont(12.0f);
  238. youpaipliveMemberCountL.textColor = [UIColor whiteColor];
  239. youpaipliveMemberCountL.textAlignment = NSTextAlignmentCenter;
  240. youpaipliveMemberCountL.text = @"0";
  241. [liveMemberCountBtn addSubview:youpaipliveMemberCountL];
  242. self.youpaipliveMemberCountL = youpaipliveMemberCountL;
  243. [youpaipliveMemberCountL mas_makeConstraints:^(MASConstraintMaker *make) {
  244. make.left.offset(7.0f);
  245. make.top.bottom.offset(0.0f);
  246. make.right.offset(-7.0f);
  247. }];
  248. @weakify(self);
  249. [self setYoupaipliveMemberCountChangeBlock:^(NSInteger memberCount) {
  250. @strongify(self);
  251. self.youpaipliveMemberCountL.text = [NSString stringWithFormat:@"%@",@(memberCount)];
  252. }];
  253. UIView *youpaiprankBgV = [[UIView alloc] init];
  254. [self.youpaipchatBgView addSubview:youpaiprankBgV];
  255. self.youpaiprankBgV = youpaiprankBgV;
  256. [youpaiprankBgV mas_makeConstraints:^(MASConstraintMaker *make) {
  257. make.right.equalTo(liveMemberCountBtn.mas_left).offset(-4.0f);
  258. // make.right.offset(-7.0f-31.0f-12.0f);
  259. make.top.offset(7.0f + StatusBarHeight);
  260. make.height.offset(31.0f);
  261. make.width.offset(0.0f);
  262. }];
  263. [self youpaifupdateMemberInfo];
  264. [self setYoupaipliveMemberListChangeBlock:^(NSArray * _Nonnull members) {
  265. @strongify(self);
  266. self.youpaipliveModel.youpaiplive_top_three = [LZLiveTopThreeModel mj_objectArrayWithKeyValuesArray:members];
  267. [self youpaifupdateMemberInfo];
  268. }];
  269. NSMutableArray *arr = [NSMutableArray array];
  270. if (self.youpaipliveModel.youpaipanchor_rank_info.youpaiptotalMoney.youpaipval.length != 0) {
  271. [arr addObject:@"totalMoney"];
  272. }
  273. if (self.youpaipliveModel.youpaipanchor_rank_info.youpaipgapMoney.youpaipval.length != 0) {
  274. [arr addObject:@"gapMoney"];
  275. }
  276. if (self.youpaipliveModel.youpaipanchor_rank_info.youpaipno.youpaipval.length != 0) {
  277. [arr addObject:@"no"];
  278. }
  279. SDCycleScrollView *youpaipboardCycleView = [[SDCycleScrollView alloc] init];
  280. youpaipboardCycleView.backgroundColor = [UIColor clearColor];
  281. youpaipboardCycleView.scrollDirection = UICollectionViewScrollDirectionVertical;
  282. youpaipboardCycleView.autoScrollTimeInterval = 5.0f/arr.count;
  283. youpaipboardCycleView.autoScroll = YES;
  284. youpaipboardCycleView.imageURLStringsGroup = arr.copy;
  285. youpaipboardCycleView.titleLabelTextColor = [UIColor redColor];
  286. youpaipboardCycleView.showPageControl = NO;
  287. youpaipboardCycleView.delegate = self;
  288. [headerView addSubview:youpaipboardCycleView];
  289. self.youpaipboardCycleView = youpaipboardCycleView;
  290. [youpaipboardCycleView mas_makeConstraints:^(MASConstraintMaker *make) {
  291. make.left.offset(14.0f);
  292. make.top.equalTo(anchorInfoBgBtn.mas_bottom).offset(10.0f);
  293. make.height.offset(20.0f);
  294. make.width.offset(150.0f);
  295. }];
  296. [self setYoupaipliveInfoUpdateBlock:^(NSString * _Nonnull anchor_charm, NSString * _Nonnull fans, NSDictionary * _Nonnull anchor_rank_info) {
  297. @strongify(self);
  298. self.youpaipfansCountL.text = [NSString stringWithFormat:@"粉丝:%@",fans];
  299. self.youpaipliveModel.youpaipanchor_rank_info = [LZLiveAnchorRankInfoModel mj_objectWithKeyValues:anchor_rank_info];
  300. NSMutableArray *arr = [NSMutableArray array];
  301. if (self.youpaipliveModel.youpaipanchor_rank_info.youpaiptotalMoney.youpaipval.length != 0) {
  302. [arr addObject:@"totalMoney"];
  303. }
  304. if (self.youpaipliveModel.youpaipanchor_rank_info.youpaipgapMoney.youpaipval.length != 0) {
  305. [arr addObject:@"gapMoney"];
  306. }
  307. if (self.youpaipliveModel.youpaipanchor_rank_info.youpaipno.youpaipval.length != 0) {
  308. [arr addObject:@"no"];
  309. }
  310. self.youpaipboardCycleView.imageURLStringsGroup = arr.copy;
  311. self.youpaipboardCycleView.autoScrollTimeInterval = 5.0f/arr.count;
  312. }];
  313. // UIView *userIdBgV = [[UIView alloc] init];
  314. // userIdBgV.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.2f];
  315. // userIdBgV.layer.cornerRadius = 8.5f;
  316. // userIdBgV.clipsToBounds = YES;
  317. // [self.youpaipchatBgView addSubview:userIdBgV];
  318. // [userIdBgV mas_makeConstraints:^(MASConstraintMaker *make) {
  319. // make.right.offset(-12.0f);
  320. // make.top.equalTo(youpaiprankBgV.mas_bottom).offset(8.0f);
  321. // make.height.offset(17.0f);
  322. // }];
  323. // UILabel *userIdL = [[UILabel alloc] init];
  324. // userIdL.font = LCFont(7.0f);
  325. // userIdL.textColor = HexColorFromRGB(0xDDDDDD);
  326. // userIdL.text = [NSString stringWithFormat:@"花舞号 %@",self.youpaipliveModel.user_info.usercode];
  327. // [self.youpaipchatBgView addSubview:userIdL];
  328. // [userIdL mas_makeConstraints:^(MASConstraintMaker *make) {
  329. // make.right.offset(-12.0f);
  330. // make.top.equalTo(youpaiprankBgV.mas_bottom).offset(3.0f);
  331. // }];
  332. UIButton *recommendBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  333. recommendBtn.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.2f];
  334. recommendBtn.frame = CGRectMake(0, 0, 73.0f, 20.0f);
  335. [LCTools clipCorner:UIRectCornerTopLeft|UIRectCornerBottomLeft View:recommendBtn size:CGSizeMake(10.0f, 10.0f)];
  336. [recommendBtn addTarget:self action:@selector(youpaifgoRecommendAnchorPage) forControlEvents:UIControlEventTouchUpInside];
  337. [self.youpaipchatBgView addSubview:recommendBtn];
  338. [recommendBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  339. make.right.offset(0.0f);
  340. make.top.equalTo(anchorInfoBgBtn.mas_bottom).offset(10.0f);
  341. make.size.mas_offset(CGSizeMake(73.0f, 20.0f));
  342. }];
  343. UILabel *youpaiprecommendL = [[UILabel alloc] init];
  344. youpaiprecommendL.font = LCBoldFont(11.0f);
  345. youpaiprecommendL.textColor = HexColorFromRGB(0xEEEEEE);
  346. youpaiprecommendL.text = @"更多直播";
  347. [recommendBtn addSubview:youpaiprecommendL];
  348. [youpaiprecommendL mas_makeConstraints:^(MASConstraintMaker *make) {
  349. make.left.offset(6.0f);
  350. make.top.bottom.offset(0.0f);
  351. }];
  352. UIImageView *arrowImgV = [[UIImageView alloc] init];
  353. arrowImgV.image = [UIImage imageNamed:@"vqu_images_L_live_recommend_arrow_left"];
  354. [recommendBtn addSubview:arrowImgV];
  355. [arrowImgV mas_makeConstraints:^(MASConstraintMaker *make) {
  356. make.left.equalTo(youpaiprecommendL.mas_right).offset(1.0f);
  357. make.centerY.equalTo(recommendBtn.mas_centerY);
  358. make.size.mas_offset(CGSizeMake(8.0f, 8.0f));
  359. }];
  360. }
  361. - (void)youpaifupdateMemberInfo{
  362. [self youpaifeditBtnCountWithCount:self.youpaipliveModel.youpaiplive_top_three.count > 3 ? 3 : self.youpaipliveModel.youpaiplive_top_three.count];
  363. [self.youpaiprankBgV updateConstraints:^(MASConstraintMaker *make) {
  364. make.width.offset(self.youpaipmemberBtns.count * 31.0f + (self.youpaipmemberBtns.count - 1.0f) * 4.0f);
  365. }];
  366. NSArray <UIColor *>*borderColors = @[[HexColorFromRGB(0xFF0000) colorWithAlphaComponent:0.47f],[HexColorFromRGB(0xFFD043) colorWithAlphaComponent:0.47f],[HexColorFromRGB(0x6EF467) colorWithAlphaComponent:0.47f]];
  367. NSArray <UIColor *>*titleBgColors = @[[HexColorFromRGB(0xF46767) colorWithAlphaComponent:0.41f],[HexColorFromRGB(0xFFC104) colorWithAlphaComponent:0.41f],[HexColorFromRGB(0x6EF467) colorWithAlphaComponent:0.41f]];
  368. // for (NSInteger i = 0; i < self.youpaipmemberBtns.count; i ++) {
  369. // YOUPAILZLiveMemberButton *imgBtn = self.youpaipmemberBtns[i];
  370. // imgBtn.layer.cornerRadius = 15.5f;
  371. // imgBtn.clipsToBounds = YES;
  372. // imgBtn.tag = [self.youpaipliveModel.youpaiplive_top_three[i].youpaipid integerValue];
  373. // [imgBtn addTarget:self action:@selector(youpaifshowUserInfoClick:) forControlEvents:UIControlEventTouchUpInside];
  374. // [imgBtn sd_setImageWithURL:[LCTools getImageUrlWithAddress:self.youpaipliveModel.youpaiplive_top_three[i].youpaipavatar] forState:UIControlStateNormal];
  375. // imgBtn.frame = CGRectMake(i * 31.0f + i * 4.0f, 0, 31.0f, 31.0f);
  376. // imgBtn.youpaipcountL.text = self.youpaipliveModel.youpaiplive_top_three[i].youpaipscore;
  377. // imgBtn.layer.borderColor = borderColors[i].CGColor;
  378. // imgBtn.layer.borderWidth = 1.0f;
  379. // imgBtn.youpaipcountL.mj_w = 31.0f;
  380. // imgBtn.youpaipcountL.backgroundColor = titleBgColors[i];
  381. // [LCTools clipCorner:UIRectCornerTopLeft|UIRectCornerTopRight View:imgBtn.youpaipcountL size:CGSizeMake(6.0f, 6.0f)];
  382. // }
  383. }
  384. /// 设置FooterView
  385. - (void)youpaifsetupFooterView{
  386. UIView *youpaipfooterView = [[UIView alloc] init];
  387. [self.youpaipchatBgView addSubview:youpaipfooterView];
  388. [youpaipfooterView mas_makeConstraints:^(MASConstraintMaker *make) {
  389. make.right.left.offset(0.0f);
  390. make.height.offset(40.0f);
  391. make.bottom.offset(-SafeHeight - 10.0f);
  392. }];
  393. UIButton *sendMessageBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  394. sendMessageBtn.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.2f];
  395. sendMessageBtn.layer.cornerRadius = 20.0f;
  396. sendMessageBtn.clipsToBounds = YES;
  397. [sendMessageBtn addTarget:self action:@selector(youpaifsendMessageBtnClick) forControlEvents:UIControlEventTouchUpInside];
  398. [youpaipfooterView addSubview:sendMessageBtn];
  399. self.youpaipsendMessageBtn = sendMessageBtn;
  400. [sendMessageBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  401. make.left.bottom.offset(0.0f);
  402. make.height.offset(40.0f);
  403. make.bottom.offset(0.0f);
  404. make.width.offset(155.0f);
  405. }];
  406. UILabel *youpaiptextL = [[UILabel alloc] init];
  407. youpaiptextL.font = LCFont16;
  408. youpaiptextL.textColor = HexColorFromRGB(0xDDDDDD);
  409. youpaiptextL.text = @"聊聊天…";
  410. [sendMessageBtn addSubview:youpaiptextL];
  411. [youpaiptextL mas_makeConstraints:^(MASConstraintMaker *make) {
  412. make.left.offset(16.0f);
  413. make.top.bottom.offset(0.0f);
  414. }];
  415. UIButton *moreBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  416. [moreBtn setBackgroundImage:[UIImage imageNamed:@"vqu_images_L_live_audience_more"] forState:UIControlStateNormal];
  417. [moreBtn setBackgroundImage:[UIImage imageNamed:@"vqu_images_L_live_audience_more"] forState:UIControlStateHighlighted];
  418. [moreBtn addTarget:self action:@selector(youpaifmoreBtnClick) forControlEvents:UIControlEventTouchUpInside];
  419. [youpaipfooterView addSubview:moreBtn];
  420. [moreBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  421. make.right.offset(-12.0f);
  422. make.top.offset(0.0f);
  423. make.size.mas_offset(CGSizeMake(40.0f, 40.0f));
  424. }];
  425. // // 新消息
  426. // YOUPAILZBadgeButton *messageCountBtn = [YOUPAILZBadgeButton buttonWithType:UIButtonTypeCustom];
  427. // messageCountBtn.youpaipbadgeSize = CGSizeMake(20.0f, 20.0f);
  428. // [messageCountBtn setImage:[UIImage imageNamed:@"vqu_images_L_live_new_message"] forState:(UIControlStateNormal)];
  429. // [messageCountBtn setBackgroundImage:[UIImage imageNamed:@"vqu_images_L_live_new_message"] forState:UIControlStateHighlighted];
  430. // [messageCountBtn addTarget:self action:@selector(youpaifnewMessageBtnClick) forControlEvents:(UIControlEventTouchUpInside)];
  431. // [youpaipfooterView addSubview:messageCountBtn];
  432. // self.messageCountBtn = messageCountBtn;
  433. // [messageCountBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  434. // make.right.equalTo(moreBtn.mas_left).offset(-9.0f);
  435. // make.top.offset(0.0f);
  436. // make.size.mas_offset(CGSizeMake(40.0f, 40.0f));
  437. // }];
  438. // 礼物
  439. UIButton *giftBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  440. [giftBtn setBackgroundImage:[UIImage imageNamed:@"vqu_images_L_live_gift"] forState:UIControlStateNormal];
  441. [giftBtn setBackgroundImage:[UIImage imageNamed:@"vqu_images_L_live_gift"] forState:UIControlStateHighlighted];
  442. [giftBtn addTarget:self action:@selector(youpaifgiftBtnClick) forControlEvents:UIControlEventTouchUpInside];
  443. [youpaipfooterView addSubview:giftBtn];
  444. [giftBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  445. make.right.equalTo(moreBtn.mas_left).offset(-9.0f);
  446. make.top.offset(0.0f);
  447. make.size.mas_offset(CGSizeMake(40.0f, 40.0f));
  448. }];
  449. // // 守护
  450. // UIButton *guardBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  451. // [guardBtn setBackgroundImage:[UIImage imageNamed:@"vqu_images_L_live_guard"] forState:UIControlStateNormal];
  452. // [guardBtn setBackgroundImage:[UIImage imageNamed:@"vqu_images_L_live_guard"] forState:UIControlStateHighlighted];
  453. // [guardBtn addTarget:self action:@selector(youpaifguardBtnClick) forControlEvents:UIControlEventTouchUpInside];
  454. // [youpaipfooterView addSubview:guardBtn];
  455. // [guardBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  456. // make.right.equalTo(giftBtn.mas_left).offset(-9.0f);
  457. // make.top.offset(0.0f);
  458. // make.size.mas_offset(CGSizeMake(40.0f, 40.0f));
  459. // }];
  460. if (self.youpaipliveModel.youpaiprecommend_gift.youpaipid.length != 0) { // 节日特别礼物
  461. UIButton *festivalBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  462. [festivalBtn sd_setImageWithURL:[LCTools getImageUrlWithAddress:self.youpaipliveModel.youpaiprecommend_gift.youpaipimg] forState:UIControlStateNormal];
  463. [festivalBtn addTarget:self action:@selector(youpaiffestivalBtnClick) forControlEvents:UIControlEventTouchUpInside];
  464. [youpaipfooterView addSubview:festivalBtn];
  465. [festivalBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  466. make.right.equalTo(giftBtn.mas_left).offset(-9.0f);
  467. make.top.offset(0.0f);
  468. make.size.mas_offset(CGSizeMake(40.0f, 40.0f));
  469. }];
  470. }
  471. }
  472. #pragma mark - Click
  473. - (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{
  474. [self youpaifhideKayboard];
  475. // UITouch *touch = [touches allObjects].lastObject;
  476. // CGPoint point = [touch locationInView:self.view];
  477. // [LZLiveAnimation showAnimationWithPoint:point baseView:self.view];
  478. }
  479. - (void)youpaifhandleTapGesture:(UITapGestureRecognizer *)recognizer{
  480. CGPoint point = [recognizer locationInView:self.view];
  481. [LZLiveAnimation showAnimationWithPoint:point baseView:self.view];
  482. }
  483. /// 关注
  484. - (void)youpaiffollowBtnClick:(UIButton *)sender{
  485. [LCCommonHttp followUserId:self.youpaipliveModel.youpaipuser_info.youpaipuser_id liveId:@"1"];
  486. }
  487. /// 查看在线人员列表
  488. - (void)youpaifliveMemberCountBtnClick{
  489. YOUPAILZLiveMemberListVC *memberVc = [[YOUPAILZLiveMemberListVC alloc] init];
  490. memberVc.youpaiplive_id = self.youpaipliveModel.youpaiplive_id;
  491. memberVc.isTouchDismiss = YES;
  492. memberVc.youpaipisAnchor = NO;
  493. @weakify(self);
  494. [memberVc setSelectedMemberBlock:^(YOUPAILZLiveMemberModel * _Nonnull member) {
  495. @strongify(self);
  496. [self youpaifshowUserInfoWithUserId:member.youpaipid];
  497. }];
  498. [self TFPresentVC:memberVc completion:^{}];
  499. }
  500. /// 更多按钮点击事件
  501. - (void)youpaifmoreBtnClick{
  502. [self.youpaipmenuView youpaifshowAnimation];
  503. }
  504. /// 喇叭
  505. - (void)youpaifvoice:(BOOL)isOpen{
  506. if (isOpen) {
  507. [self.youpaipagoraKit disableAudio];
  508. }else{
  509. [self.youpaipagoraKit enableAudio];
  510. }
  511. }
  512. /// 发送消息按钮点击事件
  513. - (void)youpaifsendMessageBtnClick{
  514. [self youpaifsendMessageBecomeFirstResponder];
  515. }
  516. /// 赠送礼物按钮点击事件
  517. - (void)youpaifgiftBtnClick{
  518. //
  519. YOUPAILZCommonGiftView *view = [YOUPAILZCommonGiftView new];
  520. view.isTouchDismiss = YES;
  521. view.youpaipisAnchor = YES;
  522. view.youpaipcountDown = 3;
  523. @weakify(self);
  524. [view setYoupaiplzgiftblock:^(YOUPAILCGiftModel * _Nonnull model, NSInteger count,NSString*categoryID) {
  525. @strongify(self);
  526. [LCHttpHelper requestWithURLString:SendGift_New parameters:@{@"type":@(4),@"to_uid":self.youpaipliveModel.youpaipuser_info.youpaipuser_id,@"gift_id":model.youpaipid,@"num":@(count),@"live_id":self.youpaipliveModel.youpaiplive_id,@"gift_type_id":categoryID} needToken:YES type:(HttpRequestTypePost) success:^(id responseObject) {
  527. NSDictionary* dict = (NSDictionary*)responseObject;
  528. NSInteger code = [[dict objectForKey:@"code"] integerValue];
  529. if (code==0) {//成功
  530. [ZCHUDHelper showTitle:@"礼物赠送成功"];
  531. }
  532. } failure:^(NSError *error) {
  533. }];
  534. }];
  535. [view setYoupaiptouchAdvertBlock:^(YOUPAILCBannerModel * _Nonnull bannerModel) {
  536. @strongify(self);
  537. if (bannerModel.youpaiplink_type==1) {
  538. ZCBaseWebVC* baseWeb = [[ZCBaseWebVC alloc]init];
  539. baseWeb.contentUrl = bannerModel.youpaiplink_url;
  540. self.youpaipisNotPanClose = YES;
  541. [self.navigationController pushViewController:baseWeb animated:YES];
  542. }else if (bannerModel.youpaiplink_type==2||bannerModel.youpaiplink_type==3){
  543. [self youpaifpageToStr:bannerModel.youpaiplink_url];
  544. }
  545. }];
  546. [self TFPresentVC:view completion:^{
  547. }];
  548. }
  549. /// 守护按钮点击事件
  550. - (void)youpaifguardBtnClick{
  551. @weakify(self);
  552. [LCHttpHelper requestWithURLString:UserShowPage parameters:@{@"user_id":[LCSaveModel getUserModel].youpaipuserinfo.youpaipuser_id,@"no_visitor":@"1"} needToken:YES type:(HttpRequestTypePost) success:^(id responseObject) {
  553. @strongify(self);
  554. NSDictionary* dict = (NSDictionary*)responseObject;
  555. NSInteger code = [[dict objectForKey:@"code"] integerValue];
  556. if (code==0) {//成功
  557. YOUPAILCUserShowModel *showModel = [YOUPAILCUserShowModel mj_objectWithKeyValues:[dict objectForKey:@"data"]];
  558. YOUPAILPGuardHerVC *VC= [[YOUPAILPGuardHerVC alloc]init];
  559. VC.youpaipdelegate = self;
  560. VC.youpaipuser_id = self.youpaipliveModel.youpaipuser_info.youpaipuser_id;
  561. VC.vWidth = KScreenWidth-54;
  562. VC.vHeight = ((KScreenWidth-54)*165)/321.0+261.5;
  563. VC.youpaipinfoModel = showModel.youpaipguard;
  564. VC.youpaipliveid = self.youpaipliveModel.youpaiplive_id;
  565. VC.isTouchDismiss = YES;
  566. if(VC.youpaipinfoModel!=nil)
  567. [self TFPresentVC:VC completion:^{
  568. }];
  569. }else{
  570. [ZCHUDHelper showTitle:[dict objectForKey:@"message"]];
  571. }
  572. } failure:^(NSError *error) {
  573. [ZCHUDHelper showTitle:error.localizedDescription];
  574. }];
  575. }
  576. /// 节日特别礼物点击事件
  577. - (void)youpaiffestivalBtnClick{
  578. if ([LCSaveData getLiveSendFirstRecommendGift] != YES) {
  579. YOUPAILZLiveSendFestivalAlertVC *VC= [[YOUPAILZLiveSendFestivalAlertVC alloc]init];
  580. VC.isTouchDismiss = YES;
  581. VC.youpaipgiftName = self.youpaipliveModel.youpaiprecommend_gift.youpaipname;
  582. VC.youpaippriceStr = [NSString stringWithFormat:@"%@",self.youpaipliveModel.youpaiprecommend_gift.youpaipprice];
  583. @weakify(self);
  584. [VC setYoupaipconfirmClickBlock:^(BOOL youpaipisSelect) {
  585. @strongify(self);
  586. if (youpaipisSelect) {
  587. [LCSaveData saveLiveSendFirstRecommendGift:YES];
  588. }
  589. [self youpaifsendFestivalGift];
  590. }];
  591. [self TFPresentVC:VC completion:^{
  592. }];
  593. }else{
  594. [self youpaifsendFestivalGift];
  595. }
  596. }
  597. - (void)youpaifsendFestivalGift{
  598. NSMutableDictionary *params = @{@"gift_type_id":@(1),@"to_uid":self.youpaipliveModel.youpaipuser_info.youpaipuser_id,@"gift_id":self.youpaipliveModel.youpaiprecommend_gift.youpaipid,@"num":@(1),@"live_id":self.youpaipliveModel.youpaiplive_id}.mutableCopy;
  599. [LCHttpHelper requestWithURLString:SendGift_New parameters:params.copy needToken:YES type:(HttpRequestTypePost) success:^(id responseObject) {
  600. NSDictionary* dict = (NSDictionary*)responseObject;
  601. NSInteger code = [[dict objectForKey:@"code"] integerValue];
  602. if (code==0) {//成功
  603. [ZCHUDHelper showTitle:@"礼物赠送成功"];
  604. }
  605. } failure:^(NSError *error) {
  606. }];
  607. }
  608. /// 点击新消息数
  609. - (void)youpaifnewMessageBtnClick{
  610. // YOUPAILZLiveAudienceMessageListVC *vc = [[YOUPAILZLiveAudienceMessageListVC alloc] init];
  611. // ZCBaseNavigationVC *navigationVC = [[ZCBaseNavigationVC alloc] initWithRootViewController:vc];
  612. // [self TFPresentViewController:navigationVC presentSize:CGSizeMake(KScreenWidth, KScreenHeight * 0.6f) direction:TFDirectionBottom completion:^{
  613. //
  614. // }];
  615. }
  616. /// 更新信息数
  617. - (void)youpaifupdateUnread{
  618. NSInteger badge = [[NIMSDK sharedSDK].conversationManager allUnreadCount];
  619. self.youpaipmessageCountBtn.youpaipbadgeValue = badge;
  620. }
  621. /// 获取用户信息
  622. - (void)youpaifshowUserInfoClick:(UIButton *)sender{
  623. [self youpaifshowUserInfoWithUserId:[NSString stringWithFormat:@"%@",@(sender.tag)]];
  624. }
  625. #pragma mark - SDCycleScrollViewDelegate
  626. //- (void)cycleScrollView:(SDCycleScrollView *)cycleScrollView didSelectItemAtIndex:(NSInteger)index{
  627. //
  628. //}
  629. - (Class)customCollectionViewCellClassForCycleScrollView:(SDCycleScrollView *)view{
  630. return [YOUPAILZLiveBoardCycleViewCell class];
  631. }
  632. - (void)setupCustomCell:(UICollectionViewCell *)cell forIndex:(NSInteger)index cycleScrollView:(SDCycleScrollView *)view{
  633. YOUPAILZLiveBoardCycleViewCell *boardCell = (YOUPAILZLiveBoardCycleViewCell *)cell;
  634. if (view == self.youpaipboardCycleView) {
  635. NSString *type = view.imageURLStringsGroup[index];
  636. @weakify(self);
  637. [boardCell youpaifreloadWithModel:[self.youpaipliveModel.youpaipanchor_rank_info valueForKey:type] type:type];
  638. [boardCell setYoupaipclickBlock:^{
  639. @strongify(self);
  640. YOUPAILZLiveAnchorHotWindow *memberVc = [[YOUPAILZLiveAnchorHotWindow alloc] init];
  641. memberVc.youpaiplive_id = self.youpaipliveModel.youpaiplive_id;
  642. memberVc.isTouchDismiss = YES;
  643. memberVc.youpaipisAnchor = NO;
  644. [memberVc setSelectedMemberBlock:^(YOUPAILZLiveMemberModel * _Nonnull member) {
  645. @strongify(self);
  646. [self youpaifshowUserInfoWithUserId:member.youpaipid];
  647. }];
  648. [self TFPresentVC:memberVc completion:^{}];
  649. }];
  650. }
  651. }
  652. #pragma mark - ZYGuardHerDelegate
  653. - (void)youpaifaddGuardSuccess{
  654. }
  655. #pragma mark - NIMConversationManagerDelegate
  656. - (void)didAddRecentSession:(NIMRecentSession *)recentSession
  657. totalUnreadCount:(NSInteger)totalUnreadCount{
  658. [self youpaifupdateUnread];
  659. }
  660. - (void)didUpdateRecentSession:(NIMRecentSession *)recentSession
  661. totalUnreadCount:(NSInteger)totalUnreadCount{
  662. [self youpaifupdateUnread];
  663. }
  664. - (void)didRemoveRecentSession:(NIMRecentSession *)recentSession
  665. totalUnreadCount:(NSInteger)totalUnreadCount{
  666. [self youpaifupdateUnread];
  667. }
  668. - (void)messagesDeletedInSession:(NIMSession *)session{
  669. [self youpaifupdateUnread];
  670. }
  671. - (void)allMessagesDeleted{
  672. [self youpaifupdateUnread];
  673. }
  674. /// 设置用户角色
  675. - (AgoraClientRole)youpaifclientRole{
  676. return AgoraClientRoleAudience;
  677. }
  678. /// 顶部榜单相关函数
  679. - (void)youpaifeditBtnCountWithCount:(NSInteger)count{
  680. if (count >= self.youpaipmemberBtns.count) {
  681. [self youpaifaddBtnWithCount:count - self.youpaipmemberBtns.count];
  682. }else{
  683. [self youpaifdeleteBtnWithCount:self.youpaipmemberBtns.count - count];
  684. }
  685. }
  686. - (void)youpaifdeleteBtnWithCount:(NSInteger)count{
  687. if (count != 0) {
  688. for (NSInteger i = 0; i < count; i ++) {
  689. YOUPAILZLiveMemberButton *btn = self.youpaipmemberBtns.lastObject;
  690. [self.youpaipmemberBtns removeLastObject];
  691. [btn removeFromSuperview];
  692. }
  693. }
  694. }
  695. - (void)youpaifaddBtnWithCount:(NSInteger)count{
  696. for (NSInteger i = 0; i < count; i ++) {
  697. [self youpaifcreateBtn];
  698. }
  699. }
  700. - (void)youpaifcreateBtn{
  701. YOUPAILZLiveMemberButton *btn = [[YOUPAILZLiveMemberButton alloc] init];
  702. btn.imageView.contentMode = UIViewContentModeScaleAspectFill;
  703. btn.contentHorizontalAlignment = UIControlContentHorizontalAlignmentFill;
  704. btn.contentVerticalAlignment = UIControlContentVerticalAlignmentFill;
  705. // btn.layer.cornerRadius = 3.0f;
  706. // btn.clipsToBounds = YES;
  707. [self.youpaiprankBgV addSubview:btn];
  708. [self.youpaipmemberBtns addObject:btn];
  709. }
  710. - (NSMutableArray<YOUPAILZLiveMemberButton *> *)youpaipmemberBtns{
  711. if (!_youpaipmemberBtns) {
  712. _youpaipmemberBtns = [NSMutableArray array];
  713. }
  714. return _youpaipmemberBtns;
  715. }
  716. - (YOUPAILZAudienceMenuView *)youpaipmenuView{
  717. if (!_youpaipmenuView) {
  718. _youpaipmenuView = [[YOUPAILZAudienceMenuView alloc] initWithSupView:self.view];
  719. @weakify(self);
  720. // 隐藏聊天记录
  721. [_youpaipmenuView setYoupaiphideChatMessageBlock:^{
  722. @strongify(self);
  723. [self youpaifhiddenChatList];
  724. }];
  725. // 黑名单
  726. [_youpaipmenuView setYoupaipblocklistBlock:^{
  727. @strongify(self);
  728. [LCCommonHttp blackUserId:self.youpaipliveModel.youpaipuser_info.youpaipuser_id];
  729. }];
  730. // 举报
  731. [_youpaipmenuView setYoupaipreportBlock:^{
  732. @strongify(self);
  733. YOUPAILCReportVC* report = [[YOUPAILCReportVC alloc]init];
  734. report.youpaipreport_uid = self.youpaipliveModel.youpaipuser_info.youpaipuser_id;
  735. report.youpaiptype = 5;
  736. [self.navigationController pushViewController:report animated:YES];
  737. }];
  738. // 静音
  739. [_youpaipmenuView setYoupaipcloseVoiceBlock:^(BOOL open) {
  740. @strongify(self);
  741. [self youpaifvoice:open];
  742. }];
  743. // 结束直播
  744. [_youpaipmenuView setYoupaipcloseBlock:^{
  745. @strongify(self);
  746. [self youpaifendLive];
  747. }];
  748. }
  749. return _youpaipmenuView;
  750. }
  751. /// 退出直播
  752. - (void)youpaifendLive{
  753. [self youpaifleaveChannel];
  754. [self.navigationController popViewControllerAnimated:YES];
  755. }
  756. - (void)youpaifendLiveTwo{
  757. [self youpaifleaveChannel];
  758. NSArray *vcs = self.navigationController.viewControllers;
  759. NSMutableArray *nvcs = [NSMutableArray array];
  760. for (UIViewController *vc in vcs) {
  761. if (![vc isKindOfClass:[self class]]) {
  762. [nvcs addObject:vc];
  763. }
  764. }
  765. [self.navigationController setViewControllers:nvcs.copy];
  766. }
  767. /// 请求直播结束后数据
  768. - (void)youpaifrequestLiveCloseData{
  769. @weakify(self);
  770. [LCHttpHelper requestWithURLString:GetUserCloseLive parameters:@{@"id":self.youpaipliveModel.youpaiplive_id} needToken:YES type:(HttpRequestTypePost) success:^(id responseObject) {
  771. NSDictionary* dict = (NSDictionary*)responseObject;
  772. NSInteger code = [[dict objectForKey:@"code"] integerValue];
  773. if (code==0) {//成功
  774. @strongify(self);
  775. YOUPAILZLiveCloseModel *model = [YOUPAILZLiveCloseModel mj_objectWithKeyValues:[dict objectForKey:@"data"]];
  776. YOUPAILZLiveCloseAudienceWindow *vc = [[YOUPAILZLiveCloseAudienceWindow alloc] initWithModel:model];
  777. [vc setYoupaipcloseBlock:^{
  778. [self.navigationController popViewControllerAnimated:YES];
  779. }];
  780. [vc setYoupaipitemClickBlock:^(YOUPAILZLiveListItemModel * _Nonnull itemModel) {
  781. [self youpaifjoinLiveWithRoomId:itemModel.youpaiproom_id];
  782. }];
  783. vc.isTouchDismiss = NO;
  784. [self TFPresentVC:vc completion:^{}];
  785. }else{
  786. [ZCHUDHelper showTitle:[dict objectForKey:@"message"]];
  787. }
  788. } failure:^(NSError *error) {
  789. [ZCHUDHelper showTitle:error.localizedDescription];
  790. }];
  791. }
  792. // 观众加入直播间
  793. - (void)youpaifjoinLiveWithRoomId:(NSString *)roomId{
  794. [ZCHUDHelper showWithStatus:nil];
  795. @weakify(self);
  796. [LCHttpHelper requestWithURLString:JoinLive parameters:@{@"room_id":roomId} needToken:YES type:HttpRequestTypePost success:^(id responseObject) {
  797. NSDictionary* dict = (NSDictionary*)responseObject;
  798. NSInteger code = [[dict objectForKey:@"code"] integerValue];
  799. if (code == 0) {
  800. @strongify(self);
  801. [ZCHUDHelper dismiss];
  802. [[YOUPAILZChatRoomManager shareManager] youpaifcloseChatRoom];
  803. YOUPAILZLiveModel *youpaipliveModel = [YOUPAILZLiveModel mj_objectWithKeyValues:[dict objectForKey:@"data"]];
  804. YOUPAILZLiveAudienceVC *audienceVC = [[YOUPAILZLiveAudienceVC alloc] initWithModel:youpaipliveModel];
  805. audienceVC.hidesBottomBarWhenPushed = YES;
  806. NSArray *vcs = self.navigationController.viewControllers;
  807. NSMutableArray <UIViewController *>*nVcs = [NSMutableArray array];
  808. for (UIViewController *vc in vcs) {
  809. if (![vc isKindOfClass:[YOUPAILZLiveAudienceVC class]]) {
  810. [nVcs addObject:vc];
  811. }
  812. }
  813. [nVcs addObject:audienceVC];
  814. [self.navigationController setViewControllers:nVcs.copy animated:YES];
  815. }else{
  816. [ZCHUDHelper showTitle:[dict objectForKey:@"message"]];
  817. }
  818. } failure:^(NSError *error) {
  819. [ZCHUDHelper showTitle:error.localizedDescription];
  820. }];
  821. }
  822. /// 更多推荐女神
  823. - (void)youpaifgoRecommendAnchorPage{
  824. self.sx_disableInteractivePop = YES;
  825. @weakify(self);
  826. [YOUPAILZRecommendAnchorView youpaifshowWithSuperView:self.view currentLiveId:self.youpaipliveModel.youpaiplive_id selectedBlock:^(YOUPAILZLiveListItemModel *model) {
  827. @strongify(self);
  828. [self youpaifjoinLiveWithRoomId:model.youpaiproom_id];
  829. } hiddenBlock:^{
  830. @strongify(self);
  831. self.sx_disableInteractivePop = NO;
  832. }];
  833. }
  834. @end