YBPlayCtrlView.m 56 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438
  1. //
  2. // YBPlayCtrlView.m
  3. // YBVideo
  4. //
  5. // Created by YB007 on 2019/12/4.
  6. // Copyright © 2019 cat. All rights reserved.
  7. //
  8. #import "YBPlayCtrlView.h"
  9. #import "YBLiveChatView.h"
  10. #import "YBUserListView.h"
  11. #import "YBUserEnterAnimation.h"
  12. #import "YBGiftPage.h"
  13. #import "expensiveGiftV.h"
  14. #import "continueGift.h"
  15. #import "YBShareView.h"
  16. #import "YBOnSaleView.h"
  17. #import "YBGoodsInfoVC.h"
  18. #import "YBGoodsBriefView.h"
  19. #import "RKShowPaintedView.h"
  20. #import "SDCycleScrollView.h"
  21. #import "YBDayTaskView.h"
  22. #import "turntableView.h"
  23. #import "guardShowView.h"
  24. #import "shouhuView.h"
  25. #import "YBTxLinkMicView.h"
  26. #import "YBAnchorPKView.h"
  27. #import "OutsideGoodsDetailVC.h"
  28. #import "CommodityDetailVC.h"
  29. #import "YBAnchorLinkInfo.h"
  30. @interface YBPlayCtrlView()<UIGestureRecognizerDelegate,haohuadelegate,SDCycleScrollViewDelegate,turntableViewDelegate,shouhuViewDelegate,guardShowDelegate>
  31. {
  32. NSString *_liveUid; //主播uid
  33. NSString *_liveStream; //主播留地址
  34. expensiveGiftV *haohualiwuV; //豪华礼物
  35. continueGift *continueGifts; //连送礼物
  36. UIView *liansongliwubottomview;
  37. UIImageView *starImage;
  38. CGFloat starX;
  39. CGFloat starY;
  40. guardShowView *gShowView;
  41. shouhuView *guardView;
  42. int _linkMicAskLast;
  43. NSTimer *_linkMicAskTimer; //连麦请求中倒计时
  44. YBAlertView *_disconnectAlert;
  45. }
  46. //@property(nonatomic,strong)UIScrollView *horScrollView; //水平滑动Scroll
  47. @property(nonatomic,strong)UIView *showUIView;
  48. @property(nonatomic,strong)UIView *hostInfoView; //左上角主播信息
  49. @property(nonatomic,strong)UIButton *hostAvatarBtn; //主播头像
  50. @property(nonatomic,strong)UILabel *hostNameL; //主播昵称
  51. @property(nonatomic,strong)UILabel *hostIDL; //主播id
  52. @property(nonatomic,strong)UIButton *followBtn; //关注按钮
  53. @property(nonatomic,strong)UIButton *hostVotesBtn; //主播映票
  54. @property(nonatomic,strong)UIButton *hostGuardBtn; //守护
  55. @property(nonatomic,strong)NSArray *roomGameArray;
  56. @property(nonatomic,strong)SDCycleScrollView *roomGameCycle; //幸运转盘+每日任务
  57. @property(nonatomic,strong)YBPageControl *roomGamePage;
  58. @property(nonatomic,strong)YBDayTaskView *dayTaskView; //每日任务
  59. @property(nonatomic,strong)turntableView *turntableView; //转盘
  60. @property(nonatomic,strong)YBUserListView *userListView; //用户列表
  61. @property(nonatomic,strong)YBLiveChatView *liveChatView; //公屏聊天
  62. @property(nonatomic,strong)YBGoodsBriefView *goodsBriefView; //当前展示的商品
  63. @property(nonatomic,strong)YBUserEnterAnimation *userAnimation; //进场动画
  64. @property(nonatomic,strong)YBOnSaleView *onsaleView;
  65. @property(nonatomic,strong)RKShowPaintedView *paintedShowRegion;//手绘礼物显示区域
  66. @property(nonatomic,strong)UIButton *closeLiveBtn; //↓...底部功能键
  67. @property(nonatomic,strong)UIButton *shareBtn;
  68. @property(nonatomic,strong)UIButton *msgBtn;
  69. @property(nonatomic,strong)UILabel *redPoint;
  70. @property(nonatomic,strong)UIButton *giftBtn;
  71. @property(nonatomic,strong)UIButton *cartBtn;
  72. @property(nonatomic,strong)YBTxLinkMicView *linkMicView; //连麦窗口
  73. @property(nonatomic,strong)YBAnchorPKView *pkView;
  74. @property(nonatomic,strong)YBAnchorLinkInfo *pkTohostInfoV;
  75. @property(nonatomic,strong)UIButton *pkFollowBtn;
  76. @end
  77. @implementation YBPlayCtrlView
  78. - (instancetype)initWithFrame:(CGRect)frame {
  79. self = [super initWithFrame:frame];
  80. if (self) {
  81. [self addSubview:self.avatarEffect];
  82. [self addSubview:self.horScrollView];
  83. if (@available(iOS 11.0,*)) {
  84. _horScrollView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
  85. }else {
  86. [YBBaseAppDelegate sharedAppDelegate].topViewController.automaticallyAdjustsScrollViewInsets = NO;
  87. }
  88. [_showUIView addSubview:self.hostInfoView];
  89. [_showUIView addSubview:self.hostVotesBtn];
  90. [_showUIView addSubview:self.hostGuardBtn];
  91. [_showUIView addSubview:self.userListView];
  92. [_showUIView addSubview:self.liveChatView];
  93. [_showUIView addSubview:self.goodsBriefView];
  94. [_showUIView addSubview:self.userAnimation];
  95. [_showUIView addSubview:self.botBtnFunView];
  96. [_showUIView addSubview:self.chatTool];
  97. [_showUIView addSubview:self.linkCtrBtn];
  98. self.roomGameArray = @[@"日任-房间",@"幸运大转盘"];
  99. if ([lagType isEqual:EN]) {
  100. self.roomGameArray = @[@"日任-房间_en",@"幸运大转盘_en"];
  101. }
  102. [_showUIView addSubview:self.roomGameCycle];
  103. [_showUIView addSubview:self.roomGamePage];
  104. if ([PublicObj isUp]) {
  105. self.roomGameCycle.hidden = self.roomGamePage.hidden = YES;
  106. }
  107. [_showUIView addSubview:self.turntableView];
  108. _turntableView.hidden = YES;
  109. /// 青少年
  110. int youngSwitch = [YBYoungManager shareInstance].youngSwitch;
  111. if (youngSwitch == 1) {
  112. _linkCtrBtn.hidden = YES;
  113. _roomGameCycle.hidden = YES;
  114. _roomGamePage.hidden = YES;
  115. _hostVotesBtn.hidden = YES;
  116. _hostGuardBtn.hidden = YES;
  117. }
  118. }
  119. return self;
  120. }
  121. - (void)layoutSubviews {
  122. [super layoutSubviews];
  123. [_hostInfoView mas_makeConstraints:^(MASConstraintMaker *make) {
  124. make.left.equalTo(_showUIView.mas_left).offset(11);
  125. make.top.equalTo(_showUIView.mas_top).offset(27+statusbarHeight);
  126. make.right.equalTo(_followBtn.mas_right).offset(5);
  127. make.height.mas_equalTo(34);
  128. }];
  129. [_userListView mas_makeConstraints:^(MASConstraintMaker *make) {
  130. make.height.mas_equalTo(40);
  131. make.left.equalTo(_hostInfoView.mas_right).offset(5);
  132. make.centerY.equalTo(_hostInfoView.mas_centerY).offset(-5);
  133. make.right.equalTo(_showUIView.mas_right).offset(0);
  134. }];
  135. [_hostVotesBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  136. make.left.equalTo(_hostInfoView);
  137. make.top.equalTo(_hostInfoView.mas_bottom).offset(8);
  138. make.height.mas_equalTo(22);
  139. }];
  140. [_hostGuardBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  141. make.left.equalTo(_hostVotesBtn.mas_right).offset(5);
  142. make.height.centerY.equalTo(_hostVotesBtn);
  143. }];
  144. [_roomGameCycle mas_makeConstraints:^(MASConstraintMaker *make) {
  145. make.width.mas_equalTo(70);
  146. make.height.mas_equalTo(50);
  147. make.left.equalTo(_hostVotesBtn);
  148. make.top.equalTo(_hostVotesBtn.mas_bottom).offset(30);
  149. }];
  150. [_roomGamePage mas_makeConstraints:^(MASConstraintMaker *make) {
  151. make.height.mas_equalTo(10);
  152. if (@available(iOS 14.0,*)) {
  153. make.width.mas_equalTo(200);
  154. }else {
  155. make.width.mas_equalTo(80);
  156. }
  157. make.centerX.equalTo(_roomGameCycle);
  158. make.top.equalTo(_roomGameCycle.mas_bottom).offset(0);
  159. }];
  160. [_userAnimation mas_makeConstraints:^(MASConstraintMaker *make) {
  161. make.left.equalTo(_showUIView.mas_left).offset(10);
  162. make.bottom.equalTo(_liveChatView.mas_top).offset(-20);
  163. make.width.mas_equalTo(_window_width);
  164. make.height.mas_equalTo(20);
  165. }];
  166. CGFloat blodW = 50;
  167. if ([PublicObj isBlodText]) {
  168. blodW = 60;
  169. }
  170. [_linkCtrBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  171. make.width.height.mas_equalTo(blodW);
  172. make.bottom.equalTo(_botBtnFunView.mas_top).offset(-10);
  173. make.right.equalTo(_showUIView.mas_right).offset(-15);
  174. }];
  175. [_linkCtrBtn layoutIfNeeded];
  176. _linkCtrBtn = [PublicObj setUpImgDownText:_linkCtrBtn];
  177. [_hostGuardBtn layoutIfNeeded];
  178. [_hostGuardBtn setImageEdgeInsets:UIEdgeInsetsMake(0, _hostGuardBtn.titleLabel.size.width, 0, -_hostGuardBtn.titleLabel.size.width)];
  179. [_hostGuardBtn setTitleEdgeInsets:UIEdgeInsetsMake(0, -_hostGuardBtn.imageView.size.width-1, 0, _hostGuardBtn.imageView.size.width+1)];
  180. }
  181. - (void)setPlayDic:(NSDictionary *)playDic {
  182. _playDic = playDic;
  183. _liveUid = minstr([_playDic valueForKey:@"uid"]);
  184. _liveStream = minstr([_playDic valueForKey:@"stream"]);
  185. if (_userListView) {
  186. _userListView.liveUid = minstr(_liveUid);
  187. _userListView.liveStream = minstr(_liveStream);
  188. }
  189. //主播信息
  190. [_avatarEffect sd_setImageWithURL:[NSURL URLWithString:minstr([_playDic valueForKey:@"avatar"])] placeholderImage:[PublicObj getAppIcon]];
  191. [_hostAvatarBtn sd_setImageWithURL:[NSURL URLWithString:minstr([_playDic valueForKey:@"avatar"])] forState:0 placeholderImage:[PublicObj getAppIcon]];
  192. _hostNameL.text = minstr([_playDic valueForKey:@"user_nickname"]);
  193. _hostIDL.text = [NSString stringWithFormat:@"ID:%@",[_playDic valueForKey:@"uid"]];
  194. int isShop = [minstr([playDic valueForKey:@"isshop"]) intValue];
  195. int youngSwitch = [YBYoungManager shareInstance].youngSwitch;
  196. if (youngSwitch == 1) {
  197. // 开启青少年后购物开关置为0
  198. isShop = 0;
  199. [_giftBtn mas_remakeConstraints:^(MASConstraintMaker *make) {
  200. make.height.mas_equalTo(30);
  201. make.width.mas_equalTo(0);
  202. make.centerY.equalTo(_botBtnFunView);
  203. make.right.equalTo(_cartBtn.mas_left).offset(-10);
  204. }];
  205. }
  206. _cartBtn.hidden = !isShop;
  207. CGFloat btnW = (isShop == 1 )?30:0;
  208. CGFloat leftSpace = (isShop == 1 )?(-10):0;
  209. [_cartBtn mas_remakeConstraints:^(MASConstraintMaker *make) {
  210. make.height.mas_equalTo(30);
  211. make.width.mas_equalTo(btnW);
  212. make.centerY.equalTo(_botBtnFunView);
  213. make.right.equalTo(_msgBtn.mas_left).offset(leftSpace);
  214. }];
  215. [self showGoodsBtnAnimaition];
  216. }
  217. #pragma mark - 点击事件
  218. -(void)clickHostAvatarBtn {
  219. if (self.playCtrEvent && ![PublicObj checkNull:_liveUid]) {
  220. self.playCtrEvent(@"控制-信息卡", @{@"id":_liveUid});
  221. }
  222. }
  223. -(void)clickFollowBtn {
  224. [MBProgressHUD showMessage:@""];
  225. YBWeakSelf;
  226. [YBNetworking postWithUrl:@"User.setAttent" Dic:@{@"touid":_liveUid} Suc:^(int code, id info, NSString *msg) {
  227. [MBProgressHUD hideHUD];
  228. [weakSelf updateFollowShow:NO];
  229. if (weakSelf.playCtrEvent) {
  230. weakSelf.playCtrEvent(@"控制-关注", @{});
  231. }
  232. } Fail:^(id fail) {
  233. [MBProgressHUD hideHUD];
  234. }];
  235. }
  236. -(void)updateFollowShow:(BOOL)isShow {
  237. if (isShow) {
  238. [_followBtn mas_remakeConstraints:^(MASConstraintMaker *make) {
  239. make.height.mas_equalTo(24);
  240. make.centerY.equalTo(_hostAvatarBtn);
  241. make.left.equalTo(_hostNameL.mas_right).offset(6);
  242. }];
  243. }else {
  244. [_followBtn mas_remakeConstraints:^(MASConstraintMaker *make) {
  245. make.width.mas_equalTo(0);
  246. make.height.mas_equalTo(24);
  247. make.centerY.equalTo(_hostAvatarBtn);
  248. make.left.equalTo(_hostNameL.mas_right).offset(6);
  249. }];
  250. }
  251. }
  252. -(void)clickKeyBtn {
  253. [_chatTool.chatTF becomeFirstResponder];
  254. _botBtnFunView.hidden = YES;
  255. _chatTool.hidden = NO;
  256. }
  257. -(void)clikcCloseLiveBtn {
  258. if (self.playCtrEvent) {
  259. self.playCtrEvent(@"控制-关闭", @{});
  260. }
  261. }
  262. -(void)clikcShareBtn {
  263. //分享
  264. NSDictionary *shareDic = @{@"hostName":minstr([_playDic valueForKey:@"user_nickname"]),@"thumb_s":minstr([_playDic valueForKey:@"avatar_thumb"]),@"hostId":minstr([_playDic valueForKey:@"uid"]),@"liveTitle":minstr([_playDic valueForKey:@"title"])};
  265. [YBShareView showShareWithType:RKShareType_Liveing parameter:shareDic commplete:^(int codeEvent, NSString *nums) {
  266. }];
  267. }
  268. -(void)clikcMsgBtn {
  269. //私信
  270. if (self.playCtrEvent) {
  271. self.playCtrEvent(@"控制-私信", @{});
  272. }
  273. }
  274. -(void)clikcGiftBtn {
  275. //礼物打赏
  276. YBWeakSelf;
  277. /*
  278. [MBProgressHUD showMessage:@""];
  279. [YBNetworking postWithUrl:@"Live.getGiftList" Dic:nil Suc:^(int code, id info, NSString *msg) {
  280. [MBProgressHUD hideHUD];
  281. if (code == 0) {
  282. NSArray *infoA = [NSArray arrayWithArray:info];
  283. YBGiftPage *gView = [YBGiftPage showGiftWithData:infoA complete:^(int eventCode,NSDictionary *giftDic) {
  284. if (eventCode == -1) {
  285. //关闭
  286. }else {
  287. //发送socket
  288. [weakSelf sendGiftInfo:giftDic];
  289. }
  290. }];
  291. gView.receiveID = minstr(_liveUid);;
  292. gView.receiveStream = minstr(_liveStream);
  293. gView.sendType = SendGiftType_Live;
  294. }else {
  295. [MBProgressHUD showPop:msg];
  296. }
  297. } Fail:^(id fail) {
  298. [MBProgressHUD hideHUD];
  299. }];
  300. */
  301. YBGiftPage *gView = [YBGiftPage showGiftViewComplete:^(int eventCode,NSDictionary *giftDic) {
  302. if (eventCode == -1) {
  303. //关闭
  304. }else {
  305. //发送socket
  306. [weakSelf sendGiftInfo:giftDic];
  307. }
  308. }];
  309. gView.receiveID = minstr(_liveUid);;
  310. gView.receiveStream = minstr(_liveStream);
  311. gView.sendType = SendGiftType_Live;
  312. [gView requestGiftData];
  313. }
  314. -(void)sendGiftInfo:(NSDictionary *)giftDic {
  315. if (self.playCtrEvent) {
  316. self.playCtrEvent(@"控制-礼物", giftDic);
  317. }
  318. }
  319. -(void)clikcCartBtn {
  320. _onsaleView = [YBOnSaleView showSaleWithAnchor:NO andAnchorID:minstr(_liveUid)];
  321. YBWeakSelf;
  322. _onsaleView.onSaleEvent = ^(OnSaleType saleCtrEvent,NSDictionary *goodsDic) {
  323. if (saleCtrEvent == OnSaleType_Info) {
  324. //用户端只能查看详情
  325. [weakSelf goGoodsInfo:goodsDic];
  326. }
  327. };
  328. }
  329. -(void)goGoodsInfo:(NSDictionary *)goodsDic {
  330. [PublicObj checkGoodsExistenceWithID:minstr([goodsDic valueForKey:@"id"]) Existence:^(int code, NSString *msg) {
  331. if (code ==0) {
  332. if ([minstr([goodsDic valueForKey:@"type"]) isEqual:@"1"]) {
  333. OutsideGoodsDetailVC *detail = [[OutsideGoodsDetailVC alloc]init];
  334. detail.goodsID = minstr([goodsDic valueForKey:@"id"]);
  335. detail.liveUid= _liveUid;
  336. [[YBBaseAppDelegate sharedAppDelegate] pushViewController:detail animated:YES];
  337. }else{
  338. CommodityDetailVC *detail = [[CommodityDetailVC alloc]init];
  339. detail.goodsID = minstr([goodsDic valueForKey:@"id"]);
  340. detail.backTags = @"live";
  341. detail.liveUid= _liveUid;
  342. [[YBBaseAppDelegate sharedAppDelegate] pushViewController:detail animated:YES];
  343. }
  344. }else{
  345. [MBProgressHUD showError:msg];
  346. }
  347. }];
  348. }
  349. #pragma mark - 连麦开始
  350. //用户-主播连麦
  351. -(void)clickLinkCtrBtn:(UIButton *)sender {
  352. if (_linkCtrBtn.selected) {
  353. //连麦中
  354. [self userEndLinkMic];
  355. }else {
  356. //未连麦
  357. if (_linkMicAskTimer) {
  358. [MBProgressHUD showPop:YZMsg(@"您已申请,请稍等")];
  359. return;
  360. }
  361. YBWeakSelf;
  362. [MBProgressHUD showMessage:@""];
  363. [YBNetworking postWithUrl:@"Linkmic.isMic" Dic:@{@"liveuid":_liveUid} Suc:^(int code, id info, NSString *msg) {
  364. [MBProgressHUD hideHUD];
  365. if (code == 0) {
  366. [MBProgressHUD showPop:YZMsg(@"连麦请求已发送")];
  367. [weakSelf userStartLinkMic];
  368. }else {
  369. [MBProgressHUD showPop:msg];
  370. }
  371. } Fail:^(id fail) {
  372. [MBProgressHUD hideHUD];
  373. }];
  374. }
  375. }
  376. -(void)userStartLinkMic {
  377. //发送socket
  378. if (self.playCtrEvent) {
  379. self.playCtrEvent(@"控制-用户申请连麦",@{});
  380. }
  381. if (!_linkMicAskTimer) {
  382. _linkMicAskLast = 11;
  383. _linkMicAskTimer = [NSTimer scheduledTimerWithTimeInterval:1 target:self selector:@selector(linkMicAskEvent) userInfo:nil repeats:YES];
  384. }
  385. }
  386. -(void)linkMicAskEvent {
  387. _linkMicAskLast -- ;
  388. if (_linkMicAskLast <= 0) {
  389. [self destroyLinkMicAskTimer];
  390. }
  391. }
  392. -(void)destroyLinkMicAskTimer {
  393. if (_linkMicAskTimer) {
  394. [_linkMicAskTimer invalidate];
  395. _linkMicAskTimer = nil;
  396. }
  397. }
  398. -(void)userEndLinkMic {
  399. YBWeakSelf;
  400. NSDictionary *contentDic = @{@"title":@"",@"msg":YZMsg(@"是否断开连麦"),@"left":YZMsg(@"取消"),@"right":YZMsg(@"确定"),@"richImg":@""};
  401. _disconnectAlert = [YBAlertView showAlertView:contentDic complete:^(int eventType) {
  402. if (eventType == 1) {
  403. [weakSelf userSendLinkDisconnectSocket];
  404. [weakSelf stopUserLinkView];
  405. }
  406. }];
  407. }
  408. -(void)stopUserLinkView {
  409. _linkCtrBtn.selected = NO;
  410. [self destroyLinkMicAskTimer];
  411. if (_disconnectAlert) {
  412. [_disconnectAlert removeFromSuperview];
  413. _disconnectAlert = nil;
  414. }
  415. [self destroyLinkMicView];
  416. }
  417. /** socket主播同意-拒绝连麦 */
  418. -(void)socketHostIsAgree:(BOOL)isAgree andSocDic:(NSDictionary *)socDic {
  419. [self destroyLinkMicAskTimer];
  420. if (isAgree) {
  421. //同意
  422. YBWeakSelf;
  423. NSDictionary *parDic = @{@"uid":[Config getOwnID],@"liveuid":minstr(_liveUid)};
  424. [YBNetworking postWithUrl:@"Linkmic.RequestLVBAddrForLinkMic" Dic:parDic Suc:^(int code, id info, NSString *msg) {
  425. if (code == 0) {
  426. NSDictionary *infoDic = [info firstObject];
  427. NSDictionary *subDic = @{@"userid":[Config getOwnID],
  428. @"uname":[Config getOwnNicename],
  429. @"playurl":minstr([infoDic valueForKey:@"playurl"]),
  430. @"pushurl":minstr([infoDic valueForKey:@"pushurl"]),
  431. };
  432. [weakSelf createLinkMicView:subDic];
  433. }else {
  434. [MBProgressHUD showPop:msg];
  435. }
  436. } Fail:^(id fail) {
  437. }];
  438. }else {
  439. //拒绝
  440. _linkCtrBtn.selected = NO;
  441. }
  442. }
  443. -(void)createLinkMicView:(NSDictionary *)linkDic {
  444. [self destroyLinkMicView];
  445. _linkCtrBtn.selected = YES;
  446. _linkMicView = [YBTxLinkMicView createLinkMicViewOnSuper:self andHostToHost:NO];
  447. _linkMicView.linkDic = linkDic;
  448. [_linkMicView linkMicShowViewHaveCloseBtn:NO];
  449. YBWeakSelf;
  450. _linkMicView.linkMicEvent = ^(TxLinkEventType eventType, NSDictionary *eventDic) {
  451. [weakSelf linkMicViewEvent:eventType andDic:eventDic];
  452. };
  453. }
  454. -(void)linkMicViewEvent:(TxLinkEventType)eventType andDic:(NSDictionary *)eventDic {
  455. switch (eventType) {
  456. case TxLinkEventType_StartPush:{
  457. //开始推流-发送socket
  458. YBWeakSelf;
  459. // NSDictionary *postDic = @{@"originStreamUrl":minstr([_playDic valueForKey:@"pull"])};
  460. NSDictionary *postDic = @{@"uid":[Config getOwnID],@"liveuid":minstr(_liveUid),@"stream":minstr(_liveStream)};
  461. [YBNetworking postWithUrl:@"Linkmic.RequestPlayUrlWithSignForLinkMic" Dic:postDic Suc:^(int code, id info, NSString *msg) {
  462. if (code == 0) {
  463. NSDictionary *infoDic = [info firstObject];
  464. NSString *streamUrlWithSignature = [infoDic valueForKey:@"streamUrlWithSignature"];
  465. if (weakSelf.playCtrEvent) {
  466. NSDictionary *eventDic = @{@"playurl":minstr([_linkMicView.linkDic valueForKey:@"playurl"]),
  467. @"streamUrlWithSignature":streamUrlWithSignature,
  468. };
  469. weakSelf.playCtrEvent(@"控制-用户连麦重新拉流", eventDic);
  470. }
  471. }else {
  472. [MBProgressHUD showPop:msg];
  473. }
  474. } Fail:^(id fail) {
  475. }];
  476. }break;
  477. case TxLinkEventType_StopPush:{
  478. //结束推流
  479. [self userSendLinkDisconnectSocket];
  480. }break;
  481. case TxLinkEventType_LinkDisconnect:{
  482. //断开连麦
  483. [self userSendLinkDisconnectSocket];
  484. }break;
  485. default:
  486. break;
  487. }
  488. }
  489. -(void)destroyLinkMicView {
  490. if (_linkMicView) {
  491. [_linkMicView linkMicViewDismiss];
  492. _linkMicView = nil;
  493. }
  494. }
  495. -(void)userSendLinkDisconnectSocket {
  496. if (self.playCtrEvent) {
  497. self.playCtrEvent(@"控制-用户断开连麦",@{});
  498. }
  499. }
  500. /** socket主播下麦用户 */
  501. -(void)socketHostDisconnect:(NSDictionary *)linkDic {
  502. [self stopUserLinkView];
  503. }
  504. /** socket主播忙碌 */
  505. -(void)socketHostBusy:(NSDictionary *)busyDic {
  506. [self stopUserLinkView];
  507. }
  508. /** socket主播超时 */
  509. -(void)socketHostTimeout:(NSDictionary *)timeoutDic {
  510. [self stopUserLinkView];
  511. }
  512. #pragma mark 连麦结束
  513. /** 主播-主播:对方主播id */
  514. -(void)showToHostInfoWithId:(NSString *)toHostId;{
  515. [self destroyPkTohostInfo];
  516. _pkTohostInfoV = [YBAnchorLinkInfo showHostInfoWithSuperView:self];
  517. [_pkTohostInfoV reqToHostInfo:toHostId];
  518. YBWeakSelf;
  519. _pkTohostInfoV.attentEvent = ^(int isAttent) {
  520. weakSelf.pkFollowBtn.hidden = isAttent;
  521. };
  522. //遮罩【控制层级响应点击,实际UI显示在_pkTohostInfoV里的子视图】
  523. _pkFollowBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  524. _pkFollowBtn.backgroundColor = UIColor.clearColor;
  525. [_pkFollowBtn addTarget:self action:@selector(clickPkFollow) forControlEvents:UIControlEventTouchUpInside];
  526. [self addSubview:_pkFollowBtn];
  527. [_pkFollowBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  528. make.right.equalTo(self.mas_right);
  529. make.bottom.equalTo(_pkTohostInfoV.mas_bottom);
  530. make.width.height.mas_equalTo(40);
  531. }];
  532. }
  533. -(void)clickPkFollow {
  534. _pkFollowBtn.hidden = YES;
  535. [_pkTohostInfoV updateFollow];
  536. }
  537. -(void)destroyPkTohostInfo {
  538. if (_pkTohostInfoV) {
  539. [_pkTohostInfoV removeFromSuperview];
  540. _pkTohostInfoV = nil;
  541. [_pkFollowBtn removeFromSuperview];
  542. _pkFollowBtn = nil;
  543. }
  544. }
  545. #pragma mark - PK
  546. /** PK 开始 */
  547. -(void)socketLinkPKStart:(NSDictionary *)pkDic;{
  548. [self destroyPkView];
  549. NSString *pkTime = @"300";
  550. if (pkDic) {
  551. pkTime = minstr([pkDic valueForKey:@"pk_time"]);
  552. }
  553. _pkView = [[YBAnchorPKView alloc]initWithFrame:CGRectMake(0, 130+statusbarHeight, _window_width, _window_width*2/3+20) andTime:pkTime];
  554. YBWeakSelf;
  555. _pkView.pkViewEvent = ^{
  556. [weakSelf destroyPkView];
  557. };
  558. //[_showUIView addSubview:_pkView];
  559. [self addSubview:_pkView];
  560. [self bringToFront];
  561. }
  562. ///层级关系处理
  563. -(void)bringToFront {
  564. [_showUIView bringSubviewToFront:_chatTool];
  565. [_showUIView bringSubviewToFront:_liveChatView];
  566. [_showUIView bringSubviewToFront:_goodsBriefView];
  567. [_showUIView bringSubviewToFront:haohualiwuV];
  568. [_showUIView bringSubviewToFront:_paintedShowRegion];
  569. [_showUIView bringSubviewToFront:liansongliwubottomview];
  570. [_showUIView bringSubviewToFront:_userAnimation];
  571. [_showUIView bringSubviewToFront:_turntableView];
  572. }
  573. /** PK 结果 */
  574. -(void)socketLinkPKReult:(NSDictionary *)pkDic;{
  575. int win;
  576. if ([minstr([pkDic valueForKey:@"win_uid"]) isEqual:@"0"]) {
  577. win = 0;
  578. }else if ([minstr([pkDic valueForKey:@"win_uid"]) isEqual:minstr([_playDic valueForKey:@"uid"])]) {
  579. win = 1;
  580. }else{
  581. win = 2;
  582. }
  583. [_pkView showPkResult:pkDic andWin:win];
  584. }
  585. /** PK 进度 */
  586. -(void)socketLinkPKProgress:(NSDictionary *)pkDic;{
  587. NSString *blueNum;
  588. NSString *redNum;
  589. CGFloat progress = 0.0;
  590. if ([minstr([pkDic valueForKey:@"pkuid1"]) isEqual:minstr([_playDic valueForKey:@"uid"])]) {
  591. blueNum = minstr([pkDic valueForKey:@"pktotal1"]);
  592. redNum = minstr([pkDic valueForKey:@"pktotal2"]);
  593. }else{
  594. redNum = minstr([pkDic valueForKey:@"pktotal1"]);
  595. blueNum = minstr([pkDic valueForKey:@"pktotal2"]);
  596. }
  597. if ([blueNum isEqual:@"0"] && [redNum isEqual:@"0"]) {
  598. progress = 0.5;
  599. }else{
  600. if ([blueNum isEqual:@"0"]) {
  601. progress = 0.2;
  602. }else if ([redNum isEqual:@"0"]) {
  603. progress = 0.8;
  604. }else{
  605. CGFloat ppp = [blueNum floatValue]/([blueNum floatValue] + [redNum floatValue]);
  606. if (ppp < 0.2) {
  607. progress = 0.2;
  608. }else if (ppp > 0.8){
  609. progress = 0.8;
  610. }else{
  611. progress = ppp;
  612. }
  613. }
  614. }
  615. [_pkView updateProgress:progress withBlueNum:blueNum withRedNum:redNum];
  616. }
  617. -(void)destroyPkView {
  618. if (_pkView) {
  619. [_pkView removeTimer];
  620. [_pkView removeFromSuperview];
  621. _pkView = nil;
  622. [_pkFollowBtn removeFromSuperview];
  623. _pkFollowBtn = nil;
  624. }
  625. }
  626. #pragma mark - /** 键盘弹起事件: 目前只处理 PK和连麦 的界面相对位置不变*/
  627. -(void)keyBoardNoticeIsShow:(BOOL)isShow andHeight:(CGFloat)height;{
  628. _pkView.top = 130+statusbarHeight + height;
  629. [_linkMicView keyBoardNoticeIsShow:isShow andHeight:height];
  630. }
  631. #pragma mark - 进房间更新用户列表、映票
  632. -(void)enterroomUpdateInfo:(NSDictionary *)roomDic {
  633. _guardInfo = @{};
  634. if ([[roomDic valueForKey:@"guard"] isKindOfClass:[NSDictionary class]]) {
  635. _guardInfo = [roomDic valueForKey:@"guard"];
  636. }
  637. NSArray *userListA = [NSArray arrayWithArray:[roomDic valueForKey:@"userlists"]];
  638. [_userListView updateListCount:userListA];
  639. NSString *isAttent = minstr([roomDic valueForKey:@"isattention"]);
  640. if ([isAttent isEqual:@"0"]) {
  641. [_followBtn mas_remakeConstraints:^(MASConstraintMaker *make) {
  642. make.height.mas_equalTo(24);
  643. make.centerY.equalTo(_hostAvatarBtn);
  644. make.left.equalTo(_hostNameL.mas_right).offset(6);
  645. }];
  646. }
  647. [self updateVotes:minstr([roomDic valueForKey:@"votestotal"])];
  648. [self updateGuardNums:minstr([roomDic valueForKey:@"guard_nums"])];
  649. //展示的商品
  650. NSDictionary *goodsDic = [roomDic valueForKey:@"show_goods"];
  651. NSString *goodsID = minstr([goodsDic valueForKey:@"goodsid"]);
  652. if (![PublicObj checkNull:goodsID] && ![goodsID isEqual:@"0"]) {
  653. [self goodsBriefIsShow:YES withInfo:goodsDic];
  654. }
  655. }
  656. #pragma mark - 用户点亮
  657. -(void)socketLightAnimation {
  658. [_botBtnFunView layoutIfNeeded];
  659. starX = CGRectGetMaxX(_botBtnFunView.frame)-20 ;
  660. starY = _botBtnFunView.frame.origin.y;
  661. starImage = [[UIImageView alloc]initWithFrame:CGRectMake(starX, starY, 30, 30)];
  662. starImage.contentMode = UIViewContentModeScaleAspectFit;
  663. NSMutableArray *array = [NSMutableArray arrayWithObjects:@"plane_heart_cyan.png",@"plane_heart_pink.png",@"plane_heart_red.png",@"plane_heart_yellow.png",@"plane_heart_heart.png", nil];
  664. NSInteger random = arc4random()%array.count;
  665. starImage.image = [UIImage imageNamed:[array objectAtIndex:random]];
  666. [UIView animateWithDuration:0.2 animations:^{
  667. starImage.alpha = 1.0;
  668. starImage.frame = CGRectMake(starX+random - 10, starY-random - 30, 30, 30);
  669. CGAffineTransform transfrom = CGAffineTransformMakeScale(1.3, 1.3);
  670. starImage.transform = CGAffineTransformScale(transfrom, 1, 1);
  671. }];
  672. [_showUIView addSubview:starImage];
  673. [_showUIView sendSubviewToBack:starImage];
  674. CGFloat finishX = _window_width - round(arc4random() % 200);
  675. // 动画结束点的Y值
  676. CGFloat finishY = 200;
  677. // imageView在运动过程中的缩放比例
  678. CGFloat scale = round(arc4random() % 2) + 0.7;
  679. // 生成一个作为速度参数的随机数
  680. CGFloat speed = 1 / round(arc4random() % 900) + 0.6;
  681. // 动画执行时间
  682. NSTimeInterval duration = 4 * speed;
  683. // 如果得到的时间是无穷大,就重新附一个值(这里要特别注意,请看下面的特别提醒)
  684. if (duration == INFINITY) duration = 2.412346;
  685. // 开始动画
  686. [UIView beginAnimations:nil context:(__bridge void *_Nullable)(starImage)];
  687. // 设置动画时间
  688. [UIView setAnimationDuration:duration];
  689. // 设置imageView的结束frame
  690. starImage.frame = CGRectMake( finishX, finishY, 30 * scale, 30 * scale);
  691. // 设置渐渐消失的效果,这里的时间最好和动画时间一致
  692. [UIView animateWithDuration:duration animations:^{
  693. starImage.alpha = 0;
  694. }];
  695. // 结束动画,调用onAnimationComplete:finished:context:函数
  696. [UIView setAnimationDidStopSelector:@selector(onAnimationComplete:finished:context:)];
  697. // 设置动画代理
  698. [UIView setAnimationDelegate:self];
  699. [UIView commitAnimations];
  700. }
  701. /// 动画完后销毁iamgeView
  702. - (void)onAnimationComplete:(NSString *)animationID finished:(NSNumber *)finished context:(void *)context{
  703. if ([finished isEqual:[NSNumber numberWithBool:YES]]) {
  704. UIImageView *imageViewsss = (__bridge UIImageView *)(context);
  705. [imageViewsss removeFromSuperview];
  706. imageViewsss = nil;
  707. }
  708. }
  709. #pragma mark - 清理聊天消息
  710. -(void)clearChatList;{
  711. [_liveChatView clearChatList];
  712. }
  713. #pragma mark - 发言
  714. -(void)socketChatDic:(NSDictionary *)chatDic {
  715. [_liveChatView reloadMsg:chatDic];
  716. }
  717. #pragma mark - 用户离开
  718. -(void)socketUserLeave:(NSDictionary *)leaveDic {
  719. NSLog(@"leave");
  720. [_userListView userEventOfType:UserEvent_Leave andInfo:leaveDic];
  721. }
  722. #pragma mark - 用户进入
  723. -(void)socketUserEnter:(NSDictionary *)enterDic {
  724. NSLog(@"enter");
  725. [_userListView userEventOfType:UserEvent_Enter andInfo:enterDic];
  726. NSString *vipType = [NSString stringWithFormat:@"%@",[[enterDic valueForKey:@"ct"] valueForKey:@"vip_type"]];
  727. NSString *guardType = [NSString stringWithFormat:@"%@",[[enterDic valueForKey:@"ct"] valueForKey:@"guard_type"]];
  728. //vip暂时没有动画,只有守护有
  729. if ([vipType isEqual:@"1"] || [guardType isEqual:@"1"] || [guardType isEqual:@"2"]) {
  730. //进场动画
  731. [_userAnimation addUserMove:enterDic];
  732. }
  733. NSDictionary *ctDic = [enterDic valueForKey:@"ct"];
  734. NSDictionary *chatDic = @{@"userName":minstr([ctDic valueForKey:@"user_nickname"]),
  735. @"contentChat":YZMsg(@" 进入了直播间"),
  736. @"id":minstr([ctDic valueForKey:@"id"]),
  737. @"titleColor":@"userLogin",
  738. @"usertype":minstr([ctDic valueForKey:@"usertype"]),
  739. @"guard_type":minstr([ctDic valueForKey:@"guard_type"]),
  740. };
  741. [self socketChatDic:chatDic];
  742. }
  743. #pragma mark - 送礼物
  744. -(void)socketSendGift:(NSDictionary *)giftDic {
  745. NSDictionary *ctDic = [giftDic valueForKey:@"ct"];
  746. NSMutableDictionary *showDic = @{@"avatar":minstr([giftDic valueForKey:@"uhead"]),
  747. @"nickname":minstr([giftDic valueForKey:@"uname"]),
  748. @"paintedHeight":[giftDic valueForKey:@"paintedHeight"]?[giftDic valueForKey:@"paintedHeight"]:@"",
  749. @"paintedPath":[giftDic valueForKey:@"paintedPath"]?[giftDic valueForKey:@"paintedPath"]:@[],//数组
  750. @"paintedWidth":[giftDic valueForKey:@"paintedWidth"]?[giftDic valueForKey:@"paintedWidth"]:@"",
  751. }.mutableCopy;
  752. [showDic addEntriesFromDictionary:ctDic];
  753. [self showGift:showDic];
  754. NSString *votes = minstr([ctDic valueForKey:@"votestotal"]);
  755. [self updateVotes:votes];
  756. }
  757. #pragma mark - 展示主播介绍的商品
  758. -(void)socketOnSale:(NSDictionary *)onSaleDic; {
  759. //1-展示 0-隐藏
  760. BOOL show = [minstr([onSaleDic valueForKey:@"action"]) boolValue];
  761. [self goodsBriefIsShow:show withInfo:onSaleDic];
  762. }
  763. #pragma mark - 更新映票
  764. -(void)updateVotes:(NSString *)votes {
  765. _hostVotesBtn.hidden = NO;
  766. /// 青少年
  767. int youngSwitch = [YBYoungManager shareInstance].youngSwitch;
  768. if (youngSwitch == 1) {
  769. _hostVotesBtn.hidden = YES;
  770. }
  771. NSString *votesStr = [NSString stringWithFormat:@"%@ %@",[common name_votes],votes];
  772. [_hostVotesBtn setTitle:votesStr forState:0];
  773. }
  774. #pragma mark - 更新守护数量
  775. -(void)updateGuardNums:(NSString *)nums {
  776. if ([nums intValue] <= 0) {
  777. return;
  778. }
  779. NSString *guardStr = [NSString stringWithFormat:YZMsg(@"守护 %@人"),nums];
  780. [_hostGuardBtn setTitle:guardStr forState:0];
  781. [self layoutSubviews];
  782. }
  783. #pragma mark - /** 计时器刷新列表 */
  784. -(void)timerReloadList {
  785. [_userListView timerReloadList];
  786. }
  787. #pragma mark - /** 私信未读数 */
  788. -(void)updateUnread:(int)unread {
  789. _redPoint.hidden = YES;
  790. if (unread > 0) {
  791. _redPoint.hidden = NO;
  792. }
  793. }
  794. #pragma mark - 打赏开始
  795. -(void)showGift:(NSDictionary *)giftDic {
  796. NSString *type = minstr([giftDic valueForKey:@"type"]);
  797. if (!continueGifts) {
  798. continueGifts = [[continueGift alloc]initWithFrame:CGRectMake(0, 0, liansongliwubottomview.width, liansongliwubottomview.height)];
  799. [liansongliwubottomview addSubview:continueGifts];
  800. //初始化礼物空位
  801. [continueGifts initGift];
  802. YBWeakSelf;
  803. continueGifts.rkPaintedEvent = ^(NSDictionary *giftDic) {
  804. [weakSelf showPaintedGift:giftDic];
  805. };
  806. }
  807. if ([type isEqual:@"1"]) {
  808. [self expensiveGift:giftDic];
  809. }else{
  810. //手绘以及普通礼物都进 continueGifts 由它执行队列
  811. [continueGifts GiftPopView:giftDic andLianSong:@"Y"];
  812. }
  813. }
  814. -(void)showPaintedGift:(NSDictionary *)giftDic {
  815. //手绘显示动画
  816. _paintedShowRegion.giftPathStr = minstr([giftDic valueForKey:@"gifticon"]);
  817. _paintedShowRegion.paintedWidth = [minstr([giftDic valueForKey:@"paintedWidth"]) floatValue];
  818. _paintedShowRegion.paintedHeight = [minstr([giftDic valueForKey:@"paintedHeight"]) floatValue];
  819. _paintedShowRegion.paintedPointArray = [NSArray arrayWithArray:[giftDic valueForKey:@"paintedPath"]];
  820. }
  821. /************ 礼物弹出及队列显示开始 *************/
  822. -(void)expensiveGiftdelegate:(NSDictionary *)giftData{
  823. if (!haohualiwuV) {
  824. haohualiwuV = [[expensiveGiftV alloc]init];
  825. haohualiwuV.delegate = self;
  826. [_showUIView addSubview:haohualiwuV];
  827. }
  828. if (giftData == nil) {
  829. }else {
  830. [haohualiwuV addArrayCount:giftData];
  831. }
  832. if(haohualiwuV.haohuaCount == 0){
  833. [haohualiwuV enGiftEspensive];
  834. }
  835. }
  836. -(void)expensiveGift:(NSDictionary *)giftData{
  837. if (!haohualiwuV) {
  838. haohualiwuV = [[expensiveGiftV alloc]init];
  839. haohualiwuV.delegate = self;
  840. [_showUIView addSubview:haohualiwuV];
  841. }
  842. if (giftData == nil) {
  843. }else {
  844. [haohualiwuV addArrayCount:giftData];
  845. }
  846. if(haohualiwuV.haohuaCount == 0){
  847. [haohualiwuV enGiftEspensive];
  848. }
  849. }
  850. #pragma mark - 销毁
  851. -(void)destroyCtrSubView {
  852. _avatarEffect.hidden = NO;
  853. [self goodsBriefIsShow:NO withInfo:@{}];
  854. if (continueGifts) {
  855. [continueGifts stopTimerAndArray];
  856. [continueGifts initGift];
  857. [continueGifts removeFromSuperview];
  858. continueGifts = nil;
  859. }
  860. if (haohualiwuV) {
  861. [haohualiwuV stopHaoHUaLiwu];
  862. [haohualiwuV removeFromSuperview];
  863. haohualiwuV.expensiveGiftCount = nil;
  864. haohualiwuV = nil;
  865. }
  866. [_userAnimation removeAnimation];
  867. liansongliwubottomview.top = statusbarHeight+200;
  868. if (_onsaleView) {
  869. [_onsaleView removeFromSuperview];
  870. }
  871. if (_paintedShowRegion) {
  872. [_paintedShowRegion destroyPaitend];
  873. }
  874. [self desTroyDaytaskView];
  875. _turntableView.hidden = YES;
  876. [self removeShouhuView];
  877. [self destroyLinkMicAskTimer];
  878. [self userSendLinkDisconnectSocket];
  879. [self stopUserLinkView];
  880. [self destroyPkView];
  881. }
  882. #pragma mark - 打赏结束
  883. #pragma mark - 公屏聊天处点击回调
  884. -(void)roomChatCallBack:(NSString *)eventType andEventInfo:(NSDictionary *)eventDic {
  885. if ([eventType isEqual:@"房间聊天-用户信息"] && self.playCtrEvent) {
  886. [_chatTool.chatTF resignFirstResponder];
  887. //@{@"id":model.userID,@"name":model.userName}
  888. self.playCtrEvent(@"控制-信息卡", eventDic);
  889. }
  890. }
  891. #pragma mark - 用户列表回调
  892. -(void)userListCallBack:(NSString *)eventType andEventInfo:(NSDictionary *)eventDic{
  893. if ([eventType isEqual:@"用户列表-用户信息"] && self.playCtrEvent) {
  894. [_chatTool.chatTF resignFirstResponder];
  895. //@{@"id":model.userID,@"name":model.userName}
  896. self.playCtrEvent(@"控制-信息卡", eventDic);
  897. }
  898. }
  899. #pragma mark - 聊天工具栏回调
  900. -(void)chatToolCallBack:(NSString *)eventType andContent:(NSString *)eventContent{
  901. //去发送socke;
  902. if ([eventType isEqual:@"直播聊天-发送"] && self.playCtrEvent) {
  903. self.playCtrEvent(@"控制-直播聊天", @{@"ct":eventContent});
  904. }
  905. }
  906. #pragma mark - 商品简介-展示/隐藏
  907. -(void)goodsBriefIsShow:(BOOL)showBrief withInfo:(NSDictionary *)infoDic; {
  908. int youngSwitch = [YBYoungManager shareInstance].youngSwitch;
  909. if (youngSwitch == 1 && showBrief == YES) {
  910. return;
  911. }
  912. _goodsBriefView.hidden = !showBrief;
  913. _goodsBriefView.touserID = _liveUid;
  914. _goodsBriefView.goodsDic = infoDic;
  915. [UIView animateWithDuration:0.5 animations:^{
  916. if (showBrief) {
  917. _liveChatView.y = _window_height-ChatViewHeight-60-ShowDiff-GoodsBriefHeight;
  918. }else{
  919. _liveChatView.y = _window_height-ChatViewHeight-60-ShowDiff;
  920. }
  921. }];
  922. }
  923. #pragma mark - 每日任务、转盘代理
  924. /** 点击图片回调 */
  925. - (void)cycleScrollView:(SDCycleScrollView *)cycleScrollView didSelectItemAtIndex:(NSInteger)index {
  926. NSLog(@"点击轮播----------index:%ld",index);
  927. if (index == 0) {
  928. //每日任务
  929. [self desTroyDaytaskView];
  930. _dayTaskView = [YBDayTaskView showRoomDayTask];
  931. _dayTaskView.liveuid = minstr(_liveUid);
  932. [_dayTaskView requestListData];
  933. }else {
  934. //转盘
  935. _turntableView.hidden = NO;
  936. _turntableView.zhuboMsg = _playDic;
  937. [_turntableView show];
  938. }
  939. }
  940. /** 图片滚动回调 */
  941. - (void)cycleScrollView:(SDCycleScrollView *)cycleScrollView didScrollToIndex:(NSInteger)index {
  942. self.roomGamePage.currentPage = index;
  943. }
  944. #pragma mark - 转盘
  945. - (void)turntableZhongjianla{
  946. //转盘和礼物不会同时展现,故这里可以不处理
  947. }
  948. #pragma mark - 守护
  949. -(void)clickGuardBtn {
  950. if (!gShowView) {
  951. gShowView = [[guardShowView alloc]initWithFrame:CGRectMake(0, 0, _window_width, _window_height) andUserGuardMsg:_guardInfo andLiveUid:minstr([_playDic valueForKey:@"uid"])];
  952. gShowView.delegate = self;
  953. [_showUIView addSubview:gShowView];
  954. }
  955. [gShowView show];
  956. }
  957. - (void)buyOrRenewGuard{
  958. [self removeShouhuView];
  959. if (!guardView) {
  960. guardView = [[shouhuView alloc]init];
  961. guardView.liveUid = minstr([_playDic valueForKey:@"uid"]);
  962. guardView.stream = minstr([_playDic valueForKey:@"stream"]);
  963. guardView.delegate = self;
  964. guardView.guardType = minstr([_guardInfo valueForKey:@"type"]);
  965. [_showUIView addSubview:guardView];
  966. }
  967. [guardView show];
  968. }
  969. - (void)removeShouhuView{
  970. if (guardView) {
  971. [guardView removeFromSuperview];
  972. guardView = nil;
  973. }
  974. if (gShowView) {
  975. [gShowView removeFromSuperview];
  976. gShowView = nil;
  977. }
  978. }
  979. - (void)buyShouhuSuccess:(NSDictionary *)dic{
  980. _guardInfo = dic;
  981. if (self.playCtrEvent) {
  982. self.playCtrEvent(@"控制-购买守护",dic);
  983. }
  984. }
  985. - (void)socketUpdateGuardMsg:(NSDictionary *)dic{
  986. [self updateVotes:minstr([dic valueForKey:@"votestotal"])];
  987. [self updateGuardNums:minstr([dic valueForKey:@"guard_nums"])];
  988. [self timerReloadList];
  989. }
  990. #pragma mark - set/get
  991. - (UIImageView *)avatarEffect {
  992. if (!_avatarEffect) {
  993. _avatarEffect = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, _window_width, _window_height)];
  994. _avatarEffect.contentMode = UIViewContentModeScaleAspectFill;
  995. _avatarEffect.clipsToBounds = YES;
  996. UIBlurEffect *blur = [UIBlurEffect effectWithStyle:UIBlurEffectStyleDark];
  997. UIVisualEffectView *effectview = [[UIVisualEffectView alloc] initWithEffect:blur];
  998. effectview.frame = CGRectMake(0, 0,_window_width,_window_height);
  999. [_avatarEffect addSubview:effectview];
  1000. }
  1001. return _avatarEffect;
  1002. }
  1003. - (UIScrollView *)horScrollView {
  1004. if (!_horScrollView) {
  1005. _horScrollView = [[UIScrollView alloc]initWithFrame:CGRectMake(0, 0, _window_width, _window_height)];
  1006. _horScrollView.backgroundColor = UIColor.clearColor;
  1007. _horScrollView.contentSize = CGSizeMake(_window_width*2, 0);
  1008. [_horScrollView setContentOffset:CGPointMake(_window_width, 0) animated:NO];
  1009. _horScrollView.pagingEnabled = YES;
  1010. _horScrollView.showsHorizontalScrollIndicator = NO;
  1011. _horScrollView.bounces = NO;
  1012. UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(tapGes)];
  1013. tap.delegate = self;
  1014. [_horScrollView addGestureRecognizer:tap];
  1015. _showUIView = [[UIView alloc]initWithFrame:CGRectMake(_window_width, 0, _window_width, _window_height)];
  1016. _showUIView.backgroundColor = UIColor.clearColor;
  1017. [_horScrollView addSubview:_showUIView];
  1018. //手绘礼物
  1019. [_showUIView addSubview:self.paintedShowRegion];
  1020. //连送礼物显示区域
  1021. liansongliwubottomview = [[UIView alloc]init];
  1022. liansongliwubottomview.userInteractionEnabled = NO;
  1023. liansongliwubottomview.backgroundColor = UIColor.clearColor;
  1024. [_showUIView addSubview:liansongliwubottomview];
  1025. liansongliwubottomview.frame = CGRectMake(0, statusbarHeight + 200,_window_width,140);
  1026. }
  1027. return _horScrollView;
  1028. }
  1029. - (UIView *)hostInfoView {
  1030. if (!_hostInfoView) {
  1031. _hostInfoView = [[UIView alloc]init];
  1032. _hostInfoView.layer.cornerRadius = 17;
  1033. _hostInfoView.layer.masksToBounds = YES;
  1034. _hostInfoView.backgroundColor = RGB_COLOR(@"#000000", 0.5);
  1035. _hostAvatarBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  1036. _hostAvatarBtn.layer.masksToBounds = YES;
  1037. _hostAvatarBtn.layer.cornerRadius = 15;
  1038. [_hostAvatarBtn.imageView setContentMode:UIViewContentModeScaleAspectFill];
  1039. _hostAvatarBtn.contentHorizontalAlignment = UIControlContentHorizontalAlignmentFill;
  1040. _hostAvatarBtn.contentVerticalAlignment = UIControlContentVerticalAlignmentFill;
  1041. [_hostAvatarBtn addTarget:self action:@selector(clickHostAvatarBtn) forControlEvents:UIControlEventTouchUpInside];
  1042. [_hostInfoView addSubview:_hostAvatarBtn];
  1043. [_hostAvatarBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  1044. make.centerY.equalTo(_hostInfoView);
  1045. make.left.equalTo(_hostInfoView).offset(2);
  1046. make.width.height.mas_equalTo(30);
  1047. }];
  1048. _hostNameL = [[UILabel alloc]init];
  1049. _hostNameL.font = SYS_Font(13);
  1050. _hostNameL.textColor = RGB_COLOR(@"#ffffff", 1);
  1051. [_hostInfoView addSubview:_hostNameL];
  1052. [_hostNameL mas_makeConstraints:^(MASConstraintMaker *make) {
  1053. make.centerY.equalTo(_hostAvatarBtn.mas_centerY).multipliedBy(0.65);
  1054. make.left.equalTo(_hostAvatarBtn.mas_right).offset(5);
  1055. }];
  1056. _hostIDL = [[UILabel alloc]init];
  1057. _hostIDL.font = SYS_Font(10);
  1058. _hostIDL.textColor = RGB_COLOR(@"#f0f0f0", 1);
  1059. [_hostInfoView addSubview:_hostIDL];
  1060. [_hostIDL mas_makeConstraints:^(MASConstraintMaker *make) {
  1061. make.left.right.equalTo(_hostNameL);
  1062. make.centerY.equalTo(_hostAvatarBtn.mas_centerY).multipliedBy(1.53);
  1063. }];
  1064. _followBtn = [[UIButton alloc]init];
  1065. [_followBtn setTitle:YZMsg(@"关注") forState:0];
  1066. _followBtn.titleLabel.font = SYS_Font(10);
  1067. _followBtn.layer.cornerRadius = 12;
  1068. _followBtn.layer.masksToBounds = YES;
  1069. _followBtn.backgroundColor = Pink_Cor;
  1070. _followBtn.contentEdgeInsets = UIEdgeInsetsMake(0, 8, 0, 8);
  1071. [_followBtn addTarget:self action:@selector(clickFollowBtn) forControlEvents:UIControlEventTouchUpInside];
  1072. [_hostInfoView addSubview:_followBtn];
  1073. [_followBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  1074. make.width.mas_equalTo(0);//默认宽度为0,进房间后更新
  1075. make.height.mas_equalTo(24);
  1076. make.centerY.equalTo(_hostAvatarBtn);
  1077. make.left.equalTo(_hostNameL.mas_right).offset(6);
  1078. }];
  1079. }
  1080. return _hostInfoView;
  1081. }
  1082. - (UIButton *)hostVotesBtn {
  1083. if (!_hostVotesBtn) {
  1084. _hostVotesBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  1085. //无点击事件
  1086. [_hostVotesBtn setTitleColor:RGB_COLOR(@"#ffffff", 1) forState:0];
  1087. _hostVotesBtn.titleLabel.font = SYS_Font(10);
  1088. _hostVotesBtn.contentEdgeInsets = UIEdgeInsetsMake(0, 11, 0, 11);
  1089. _hostVotesBtn.backgroundColor = RGB_COLOR(@"#000000", 0.5);
  1090. _hostVotesBtn.layer.masksToBounds = YES;
  1091. _hostVotesBtn.layer.cornerRadius = 11;
  1092. _hostVotesBtn.hidden = YES;
  1093. }
  1094. return _hostVotesBtn;
  1095. }
  1096. - (UIButton *)hostGuardBtn {
  1097. if (!_hostGuardBtn) {
  1098. _hostGuardBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  1099. _hostGuardBtn.titleLabel.font = SYS_Font(10);
  1100. _hostGuardBtn.layer.masksToBounds = YES;
  1101. _hostGuardBtn.layer.cornerRadius = 11;
  1102. [_hostGuardBtn setTitleColor:RGB_COLOR(@"#ffffff", 1) forState:0];
  1103. _hostGuardBtn.backgroundColor = RGB_COLOR(@"#000000", 0.5);
  1104. [_hostGuardBtn setTitle:YZMsg(@"守护 虚位以待") forState:0];
  1105. [_hostGuardBtn setImage:[UIImage imageNamed:@"pub_white_right"] forState:0];
  1106. [_hostGuardBtn addTarget:self action:@selector(clickGuardBtn) forControlEvents:UIControlEventTouchUpInside];
  1107. _hostGuardBtn.contentEdgeInsets = UIEdgeInsetsMake(0, 8, 0, 5);
  1108. }
  1109. return _hostGuardBtn;;
  1110. }
  1111. - (SDCycleScrollView *)roomGameCycle {
  1112. if (!_roomGameCycle) {
  1113. _roomGameCycle = [[SDCycleScrollView alloc]init];
  1114. _roomGameCycle.backgroundColor = [UIColor clearColor];
  1115. _roomGameCycle.bannerImageViewContentMode = UIViewContentModeScaleAspectFit;
  1116. _roomGameCycle.delegate = self;
  1117. _roomGameCycle.pageControlStyle = SDCycleScrollViewPageContolStyleNone;
  1118. _roomGameCycle.scrollDirection = UICollectionViewScrollDirectionHorizontal;
  1119. _roomGameCycle.autoScrollTimeInterval = 3.0;
  1120. _roomGameCycle.currentPageDotColor = [UIColor whiteColor];
  1121. _roomGameCycle.pageDotColor = [[UIColor whiteColor] colorWithAlphaComponent:0.4];
  1122. _roomGameCycle.pageControlStyle = SDCycleScrollViewPageContolStyleNone;
  1123. _roomGameCycle.imageURLStringsGroup = _roomGameArray;
  1124. }
  1125. return _roomGameCycle;
  1126. }
  1127. - (YBPageControl *)roomGamePage {
  1128. if (!_roomGamePage) {
  1129. _roomGamePage = [[YBPageControl alloc]init];
  1130. _roomGamePage.numberOfPages = _roomGameArray.count;
  1131. _roomGamePage.currentPage = 0;
  1132. _roomGamePage.pageIndicatorTintColor = [UIColor grayColor];
  1133. _roomGamePage.currentPageIndicatorTintColor = [UIColor whiteColor];
  1134. // _roomGamePage.transform = CGAffineTransformScale(CGAffineTransformIdentity, 0.7, 0.7);
  1135. _roomGamePage.userInteractionEnabled = NO;
  1136. }
  1137. return _roomGamePage;
  1138. }
  1139. - (turntableView *)turntableView {
  1140. if (!_turntableView) {
  1141. _turntableView = [[turntableView alloc]init];
  1142. _turntableView.zhuboMsg = _playDic;
  1143. _turntableView.delegate = self;
  1144. }
  1145. return _turntableView;
  1146. }
  1147. - (YBUserListView *)userListView {
  1148. if (!_userListView) {
  1149. YBWeakSelf;
  1150. _userListView = [[YBUserListView alloc]init];
  1151. _userListView.backgroundColor = UIColor.clearColor;
  1152. if (![PublicObj checkNull:_liveUid] && ![PublicObj checkNull:_liveStream]) {
  1153. _userListView.liveUid = minstr(_liveUid);
  1154. _userListView.liveStream = minstr(_liveStream);
  1155. }
  1156. _userListView.listEvent = ^(NSString *eventStr, NSDictionary *eventDic) {
  1157. [weakSelf userListCallBack:eventStr andEventInfo:eventDic];
  1158. };
  1159. }
  1160. return _userListView;
  1161. }
  1162. - (YBLiveChatView *)liveChatView {
  1163. if (!_liveChatView) {
  1164. YBWeakSelf;
  1165. _liveChatView = [[YBLiveChatView alloc]initWithFrame:CGRectMake(10,_window_height-ChatViewHeight-60-ShowDiff, ChatViewWidth, ChatViewHeight)];
  1166. _liveChatView.backgroundColor = UIColor.clearColor;
  1167. _liveChatView.liveChatEvent = ^(NSString *eventStr, NSDictionary *eventDic) {
  1168. [weakSelf roomChatCallBack:eventStr andEventInfo:eventDic];
  1169. };
  1170. }
  1171. return _liveChatView;
  1172. }
  1173. - (YBGoodsBriefView *)goodsBriefView {
  1174. if (!_goodsBriefView) {
  1175. _goodsBriefView = [[YBGoodsBriefView alloc]initWithFrame:CGRectMake(10, _window_height-GoodsBriefHeight-60-ShowDiff, GoodsBriefWidth, GoodsBriefHeight)];
  1176. _goodsBriefView.backgroundColor = UIColor.clearColor;
  1177. _goodsBriefView.hidden = YES;
  1178. }
  1179. return _goodsBriefView;
  1180. }
  1181. - (YBUserEnterAnimation *)userAnimation {
  1182. if (!_userAnimation) {
  1183. _userAnimation = [[YBUserEnterAnimation alloc]init];
  1184. }
  1185. return _userAnimation;
  1186. }
  1187. - (UIButton *)linkCtrBtn {
  1188. if (!_linkCtrBtn) {
  1189. _linkCtrBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  1190. [_linkCtrBtn addTarget:self action:@selector(clickLinkCtrBtn:) forControlEvents:UIControlEventTouchUpInside];
  1191. [_linkCtrBtn setTitleColor:RGB_COLOR(@"#dddddd", 1) forState:0];
  1192. [_linkCtrBtn setTitleColor:RGB_COLOR(@"#dddddd", 1) forState:UIControlStateSelected];
  1193. [_linkCtrBtn setTitle:YZMsg(@"连麦互动") forState:0];
  1194. [_linkCtrBtn setTitle:YZMsg(@"结束连麦") forState:UIControlStateSelected];
  1195. _linkCtrBtn.titleLabel.adjustsFontSizeToFitWidth = YES;
  1196. _linkCtrBtn.titleLabel.font = SYS_Font(8);
  1197. [_linkCtrBtn setImage:[UIImage imageNamed:@"直播-连控彩"] forState:0];
  1198. [_linkCtrBtn setImage:[UIImage imageNamed:@"直播-连控彩"] forState:UIControlStateSelected];
  1199. _linkCtrBtn.layer.cornerRadius = 8;
  1200. _linkCtrBtn.layer.masksToBounds = YES;
  1201. _linkCtrBtn.backgroundColor = RGB_COLOR(@"#000000", 0.4);
  1202. }
  1203. return _linkCtrBtn;
  1204. }
  1205. - (UIView *)botBtnFunView {
  1206. if (!_botBtnFunView) {
  1207. _botBtnFunView = [[UIView alloc]initWithFrame:CGRectMake(0, _window_height-50-ShowDiff, _window_width, 40)];
  1208. CGFloat btnW = 30;
  1209. UIButton *keyBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  1210. [keyBtn addTarget:self action:@selector(clickKeyBtn) forControlEvents:UIControlEventTouchUpInside];
  1211. [keyBtn setImage:[UIImage imageNamed:@"live_聊天"] forState:0];
  1212. [_botBtnFunView addSubview:keyBtn];
  1213. [keyBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  1214. make.width.height.mas_equalTo(btnW);
  1215. make.centerY.equalTo(_botBtnFunView);
  1216. make.left.equalTo(_botBtnFunView.mas_left).offset(10);
  1217. }];
  1218. _closeLiveBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  1219. [_closeLiveBtn addTarget:self action:@selector(clikcCloseLiveBtn) forControlEvents:UIControlEventTouchUpInside];
  1220. [_closeLiveBtn setImage:[UIImage imageNamed:@"live_关闭"] forState:0];
  1221. [_botBtnFunView addSubview:_closeLiveBtn];
  1222. [_closeLiveBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  1223. make.width.height.mas_equalTo(btnW);
  1224. make.centerY.equalTo(_botBtnFunView);
  1225. make.right.equalTo(_botBtnFunView.mas_right).offset(-10);
  1226. }];
  1227. _shareBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  1228. [_shareBtn addTarget:self action:@selector(clikcShareBtn) forControlEvents:UIControlEventTouchUpInside];
  1229. [_shareBtn setImage:[UIImage imageNamed:@"live_分享"] forState:0];
  1230. [_botBtnFunView addSubview:_shareBtn];
  1231. [_shareBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  1232. make.width.height.mas_equalTo(btnW);
  1233. make.centerY.equalTo(_botBtnFunView);
  1234. make.right.equalTo(_closeLiveBtn.mas_left).offset(-10);
  1235. }];
  1236. _msgBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  1237. [_msgBtn addTarget:self action:@selector(clikcMsgBtn) forControlEvents:UIControlEventTouchUpInside];
  1238. [_msgBtn setImage:[UIImage imageNamed:@"live_私信"] forState:0];
  1239. [_botBtnFunView addSubview:_msgBtn];
  1240. [_msgBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  1241. make.width.height.mas_equalTo(btnW);
  1242. make.centerY.equalTo(_botBtnFunView);
  1243. make.right.equalTo(_shareBtn.mas_left).offset(-10);
  1244. }];
  1245. _redPoint = [[UILabel alloc]init];
  1246. _redPoint.layer.masksToBounds = YES;
  1247. _redPoint.layer.cornerRadius = 4;
  1248. _redPoint.backgroundColor = UIColor.redColor;
  1249. [_botBtnFunView addSubview:_redPoint];
  1250. _redPoint.hidden = YES;
  1251. [_redPoint mas_makeConstraints:^(MASConstraintMaker *make) {
  1252. make.width.height.mas_equalTo(8);
  1253. make.centerY.equalTo(_msgBtn.mas_top);
  1254. make.right.equalTo(_msgBtn.mas_right).offset(-4);
  1255. }];
  1256. _cartBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  1257. [_cartBtn addTarget:self action:@selector(clikcCartBtn) forControlEvents:UIControlEventTouchUpInside];
  1258. [_cartBtn setBackgroundImage:[UIImage imageNamed:@"live_车底"] forState:0];
  1259. [_cartBtn setImage:[UIImage imageNamed:@"live_车"] forState:0];
  1260. [_botBtnFunView addSubview:_cartBtn];
  1261. _cartBtn.hidden = YES;
  1262. [_cartBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  1263. make.height.mas_equalTo(btnW);
  1264. make.width.mas_equalTo(0);
  1265. make.centerY.equalTo(_botBtnFunView);
  1266. make.right.equalTo(_msgBtn.mas_left);
  1267. }];
  1268. _giftBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  1269. [_giftBtn addTarget:self action:@selector(clikcGiftBtn) forControlEvents:UIControlEventTouchUpInside];
  1270. [_giftBtn setImage:[UIImage imageNamed:@"live_礼物"] forState:0];
  1271. [_botBtnFunView addSubview:_giftBtn];
  1272. [_giftBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  1273. make.width.height.mas_equalTo(btnW);
  1274. make.centerY.equalTo(_botBtnFunView);
  1275. make.right.equalTo(_cartBtn.mas_left).offset(-10);
  1276. }];
  1277. }
  1278. return _botBtnFunView;
  1279. }
  1280. -(void)removeGoodsBtnAnimation {
  1281. if (_cartBtn.hidden == YES) {
  1282. return;
  1283. }
  1284. [_cartBtn.layer removeAllAnimations];
  1285. }
  1286. - (void)showGoodsBtnAnimaition{
  1287. if (_cartBtn.hidden == YES) {
  1288. return;
  1289. }
  1290. CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath:@"transform.scale"];
  1291. animation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
  1292. animation.duration = 0.7;
  1293. animation.repeatCount = 99999999;
  1294. animation.autoreverses = YES;
  1295. animation.fromValue = [NSNumber numberWithFloat:0.7];
  1296. animation.toValue = [NSNumber numberWithFloat:1.1];
  1297. [_cartBtn.imageView.layer addAnimation:animation forKey:nil];
  1298. }
  1299. - (YBChatToolBar *)chatTool {
  1300. if (!_chatTool) {
  1301. YBWeakSelf;
  1302. _chatTool = [[YBChatToolBar alloc]initWithFrame:CGRectMake(0, _window_height-44, _window_width, 44)];
  1303. _chatTool.hidden = YES;
  1304. _chatTool.chatToolEvnt = ^(NSString *eventType, NSString *eventContent) {
  1305. [weakSelf chatToolCallBack:eventType andContent:eventContent];
  1306. };
  1307. }
  1308. return _chatTool;
  1309. }
  1310. -(void)tapGes {
  1311. if ([_chatTool.chatTF isFirstResponder] || _keyBoardIsShow) {
  1312. [_chatTool.chatTF resignFirstResponder];
  1313. [[YBBaseAppDelegate sharedAppDelegate].topViewController.view endEditing:YES];
  1314. }else {
  1315. //点亮
  1316. [self socketLightAnimation];
  1317. if (self.playCtrEvent) {
  1318. self.playCtrEvent(@"控制-点亮", @{});
  1319. }
  1320. }
  1321. }
  1322. - (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch;{
  1323. if ([touch.view isDescendantOfView:_botBtnFunView]
  1324. ||[touch.view isDescendantOfView:_liveChatView]
  1325. ||[touch.view isDescendantOfView:_userListView]
  1326. ||[touch.view isDescendantOfView:_hostInfoView]
  1327. ||[touch.view isDescendantOfView:_chatTool]
  1328. ||[touch.view isDescendantOfView:_roomGameCycle]) {
  1329. return NO;
  1330. }
  1331. return YES;
  1332. }
  1333. - (RKShowPaintedView *)paintedShowRegion {
  1334. if (!_paintedShowRegion) {
  1335. _paintedShowRegion = [[RKShowPaintedView alloc]init];
  1336. //_paintedShowRegion.backgroundColor = UIColor.redColor;
  1337. }
  1338. return _paintedShowRegion;
  1339. }
  1340. -(void)desTroyDaytaskView {
  1341. if (_dayTaskView) {
  1342. [_dayTaskView dismissView];
  1343. _dayTaskView = nil;
  1344. }
  1345. }
  1346. @end