// // BGLiveUIViewController.m // FanweLive // // Created by xfg on 16/11/23. // Copyright © 2016年 xfg. All rights reserved. // #import "BGLiveUIViewController.h" #import "BGConversationListController.h" #import "BGTPlayControllerForPK.h" #import "BGKSYPlayerControllerForPk.h" #import "FPKProgress.h" #import "PKPopView.h" #import "WMDragView.h" #import "MGAddWishViewController.h" #import "BogoPkProgressModel.h" #import "BogoShopKit.h" #import "WMDragView.h" #import "WMDragView.h" #import "RoomFaceView.h" #import "RoomFaceModel.h" #import "choseMuiscVC.h" #define BEGIN_SLIDE_RATE 0.15 // 当从左往右滑动时,滑动超过了屏幕宽度的BEGIN_SLIDE_RATE时候就向左滑动 #define BEGIN_SLIDE_RATE2 0.3 // 当从上往下滑动时,滑动超过了屏幕高度的BEGIN_SLIDE_RATE时候就切换直播频道 #define DURING_TIME 10 @interface BGLiveUIViewController () { PKUserListViewController *pkList; // BGTPlayControllerForPK *pkView; // BGTPlayControllerForPK *pkView; MMAlertView *alert1; MMAlertView *alert2; MMAlertView *alert3; NSString *otherId; CurrentLiveInfo *_liveInfo; } @property(nonatomic, strong) NSString *pkID; @property(nonatomic, strong) BogoPkProgressModel *model; @property(nonatomic, strong) RoomFaceView *faceView; @end @implementation BGLiveUIViewController #pragma mark - ----------------------- 直播生命周期 ----------------------- - (void)releaseAll { [self removePanGestureRec]; [[NSNotificationCenter defaultCenter] removeObserver:self]; [_imChatVCBgView removeFromSuperview]; _liveController = nil; _liveItem = nil; if (self.livePayTimer) { [self.livePayTimer invalidate]; self.livePayTimer = nil; } if (self.livePayLeftTimer) { [self.livePayLeftTimer invalidate]; self.livePayLeftTimer = nil; } // 关闭付费的定时器 if (self.livePay.payLiveTime) { [self.livePay.payLiveTime invalidate]; self.livePay.payLiveTime = nil; } if (self.livePay.payLiveTime) { [self.livePay.hostPayLiveTime invalidate]; self.livePay.hostPayLiveTime = nil; } if (self.livePay.countDownTime) { [self.livePay.countDownTime invalidate]; self.livePay.countDownTime = nil; } self.livePay.livController = nil; } - (void)dealloc { [self releaseAll]; NSLog(ASLocalizedString(@"%s释放"),__func__); if (_fpkProgress) { [_pkCountDownView stopTimer]; } } #pragma mark 开始直播 - (void)startLive { [self.liveView startLive]; } #pragma mark 暂停直播 - (void)pauseLive { [self.liveView pauseLive]; } #pragma mark 重新开始直播 - (void)resumeLive { [self.liveView resumeLive]; } #pragma mark 结束直播 - (void)endLive { [self releaseAll]; [self.liveView endLive]; for (UIView *tmpView in self.liveView.subviews) { [tmpView removeFromSuperview]; } [self.liveView removeFromSuperview]; //2020-1-2 结束-关闭音乐 if (_soundSetView) { [_soundSetView.player pause]; _soundSetView.player=nil; } } #pragma mark 初始化房间信息等 - (instancetype)initWith:(id)liveItem liveController:(id)liveController { if (self = [super init]) { _liveItem = liveItem; _isHost = [liveItem isHost]; _liveController = liveController; self.liveView = [[TCShowLiveView alloc] initWith:liveItem liveController:liveController]; self.liveView.uiDelegate = self; [self.liveView setFrameAndLayout:self.view.bounds]; [self.view addSubview:self.liveView]; self.liveScrollView = [BGTLiveScrollView new]; self.liveScrollView.roomID = [NSString stringWithFormat:@"%d",_liveItem.liveAVRoomId]; self.liveScrollView.contentSize = CGSizeMake(0, kScreenH * 3); self.liveScrollView.frame = CGRectMake(0, 0, kScreenW, kScreenH); // self.liveScrollView.frame = CGRectMake(0, self.liveView.topView.height, kScreenW, kScreenH - self.liveView.topView.height - self.liveView.bottomView.height); self.liveScrollView.pagingEnabled = YES; self.liveScrollView.delegate = self; self.liveScrollView.userInteractionEnabled = NO; [self.liveView addSubview:self.liveScrollView]; // [self.liveScrollView addSubview:self.shopExplainView]; self.pkID = @""; } return self; } #pragma mark 请求完接口后,刷新直播间相关信息 - (void)refreshLiveItem:(id)liveItem liveInfo:(CurrentLiveInfo *)liveInfo { _liveItem = liveItem; _liveInfo = liveInfo; [self.liveView refreshLiveItem:liveItem liveInfo:liveInfo]; [self setUpLocalizationStringForView:self.liveView.topView]; } //6-19 修改-endpkview -(void)viewWillAppear:(BOOL)animated{ [super viewWillAppear:animated]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(endpkview:) name:@"endpkview" object:nil]; } - (void)viewDidLoad { [super viewDidLoad]; [self registerKeyBoardNotification]; _panGestureRec = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(moveViewWithGesture:)]; _panGestureRec.delegate = self; [self.view addGestureRecognizer:_panGestureRec]; [GlobalVariables sharedInstance].tliveView = self.view; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(showGiftView:) name:@"showGiftView" object:nil]; //2020-1-4 pk结束 // [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(endpkview:) name:@"endpkview" object:nil]; //5-7 滑动问题 // _panGestureRec.enabled=NO; // //延迟两秒模拟pk // dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(10 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ // //[self addPKView]; // _panGestureRec.enabled=YES; // }); // //禁止侧滑 // id traget = self.navigationController.interactivePopGestureRecognizer.delegate; // UIPanGestureRecognizer * pan = [[UIPanGestureRecognizer alloc]initWithTarget:traget action:nil]; // [self.view addGestureRecognizer:pan]; } -(void)PKUserClickItem:(UserModel *)user pk_id:(NSString *)pk_id { alert3 = [FanweMessage alert:ASLocalizedString(@"提示")message:ASLocalizedString(@"是否发起pk请求?")destructiveAction:^{ self.pkID = pk_id; [self requetPkWithUser:user pk_id:pk_id]; // [FanweMessage alert:ASLocalizedString(@"申请pk中,等待对方应答..")]; } cancelAction:^{ }]; [self hiddenPKlist]; } -(void)requetPkWithUser:(UserModel *)user pk_id:(NSString *)pk_id{ // UserModel *user = self.userlist[index]; NSMutableDictionary *mDict = [NSMutableDictionary dictionary]; if(![GlobalVariables sharedInstance].openAgora) { [mDict setObject:@"pk_tencent" forKey:@"ctl"]; } else { [mDict setObject:@"pk_agora" forKey:@"ctl"]; } [mDict setObject:@"request_pk" forKey:@"act"]; [mDict setObject:user.user_id forKey:@"pk_emcee_id"]; [mDict setObject:pk_id forKey:@"pk_list_id"]; __weak __typeof(self)weakSelf = self; [self.httpsManager POSTWithParameters:mDict SuccessBlock:^(NSDictionary *responseJson) { if ([responseJson toInt:@"status"] == 1) { NSNumber *pk_id = [responseJson objectForKey:@"pk_id"]; user.pk_id = pk_id.stringValue; if([self.serviceDelegate respondsToSelector:@selector(pkController:WidthData:)]) { [self.serviceDelegate pkController:0 WidthData:user]; } alert1 = [FanweMessage alert:ASLocalizedString(@"提示")message:ASLocalizedString(@"申请pk中,等待对方应答..")isHideTitle:NO destructiveTitle:ASLocalizedString(@"取消pk")destructiveAction:^{ if([self.serviceDelegate respondsToSelector:@selector(pkController:WidthData:)]) { [self.serviceDelegate pkController:3 WidthData:user]; } }]; // [self PKUserClickItem:user]; // if([self.pDelegate respondsToSelector:@selector(PKUserClickItem:)]) // { // [weakSelf.pDelegate PKUserClickItem:user]; // } } else { [FanweMessage alert:responseJson[@"msg"]]; // [[BGHUDHelper sharedInstance] tipMessage:responseJson[@"msg"]]; } } FailureBlock:^(NSError *error) { }]; } -(void)receiveRejectPkWithMsg:(NSString *)msg{ [FanweMessage alertController:msg viewController:self destructiveAction:^{ } cancelAction:nil]; [alert1 hide]; alert1 = nil; } -(void)receiveCanclePk{ [FanweMessage alert:ASLocalizedString(@"提示")message:ASLocalizedString(@"对方取消PK")isHideTitle:NO destructiveTitle:ASLocalizedString(@"确定")destructiveAction:nil]; [alert1 hide]; alert1 = nil; [self hiddenPKlist]; } -(void)pkViewWith:(NSString *)uid { [self hiddenPKlist]; [alert1 hide]; alert1 = nil; self.pkID = uid; NSMutableDictionary *mDict = [NSMutableDictionary dictionary]; if(![GlobalVariables sharedInstance].openAgora) { [mDict setObject:@"pk_tencent" forKey:@"ctl"]; } else { [mDict setObject:@"pk_agora" forKey:@"ctl"]; } [mDict setObject:@"request_get_pk_info2" forKey:@"act"]; [mDict setObject:uid.length ? uid : @"" forKey:@"pk_id"]; [self.httpsManager POSTWithParameters:mDict SuccessBlock:^(NSDictionary *responseJson){ if ([responseJson toInt:@"status"] == 1 || [responseJson toInt:@"status"] == 2) { //NSString *play_url2 = [responseJson valueForKey:@"play_url2"]; self.model = [BogoPkProgressModel mj_objectWithKeyValues:responseJson]; if ([self.model.group_id2 isEqualToString:[NSString stringWithFormat:@"%d",[_liveItem liveAVRoomId]]]) { NSArray *gift_list2 = self.model.gift_list2; self.model.gift_list2 = self.model.gift_list1; self.model.gift_list1 = gift_list2; } _fpkProgress.model = self.model; int timer = [responseJson toInt:@"pk_time"]; NSLog(@"189responseJson:%@",responseJson); [_fpkProgress setLeftIsMe:YES]; BOOL leftIsMe = NO; BOOL wodezhubois1; timer = [responseJson toInt:@"pk_time"]; //这里要判断几种情况 先判断 第一 进入是观众的话 NSString *pk_status = [responseJson valueForKey:@"pk_status"]; // 1PK中,2是惩罚 if (pk_status.integerValue == 0){ //非PK状态,不显示PK相关View return; } if(!_isHost) { //去除当前主播id NSString *live1id = [NSString stringWithFormat:@"%@",[responseJson valueForKey:@"emcee_user_id1"]]; if([[_liveItem liveHost].imUserId isEqualToString:live1id]) { //如果当前等于主播1的话就去主播2 NSString *play_url2 = [responseJson valueForKey:@"play_url2"]; [self addPKViewWithURL:play_url2 WithViewType:1 widthTime:timer WithDic:responseJson AndIsNO1:NO status:[responseJson toInt:@"status"] pkStatus:pk_status.intValue]; //此时 uid2 在左面 [self swapPlayer]; leftIsMe = YES; wodezhubois1 = YES; } else { //同上 NSString *play_url2 = [responseJson valueForKey:@"play_url1"]; [self addPKViewWithURL:play_url2 WithViewType:1 widthTime:timer WithDic:responseJson AndIsNO1:YES status:[responseJson toInt:@"status"] pkStatus:pk_status.intValue]; wodezhubois1 = NO; //此时 uid2 在右面 } } else { //始终去主播1的 NSDictionary * userInfo = @{@"roomid":[NSString stringWithFormat:@"PK%@",[responseJson valueForKey:@"emcee_user_id1"]]}; [[NSNotificationCenter defaultCenter] postNotificationName:@"KPKWithRoomID" object:self userInfo:userInfo]; //如果我是主播的话,判断下我是属于2还是1 //去除当前主播id NSString *live1id = [NSString stringWithFormat:@"%@",[responseJson valueForKey:@"emcee_user_id1"]]; if([[IMAPlatform sharedInstance].host.userId isEqualToString:live1id]) { //如果当前等于主播1的话就去主播2 NSString *play_url2 = [responseJson valueForKey:@"play_url2"]; [self addPKViewWithURL:play_url2 WithViewType:1 widthTime:timer WithDic:responseJson AndIsNO1:NO status:[responseJson toInt:@"status"] pkStatus:pk_status.intValue]; //此时 uid2 在左面,也是是我在右面 leftIsMe = YES; wodezhubois1 = YES; } else { //同上 NSString *play_url2 = [responseJson valueForKey:@"play_url1"]; [self addPKViewWithURL:play_url2 WithViewType:1 widthTime:timer WithDic:responseJson AndIsNO1:YES status:[responseJson toInt:@"status"] pkStatus:pk_status.intValue]; //此时 uid2 在右面,也就是我在右面 [self swapPlayer]; wodezhubois1 = NO; } } _fpkProgress.leftIsMe = leftIsMe; } else { [[BGHUDHelper sharedInstance] tipMessage:[responseJson valueForKey:@"error"]]; } } FailureBlock:^(NSError *error) { }]; } //把uid2 在左面的搞的右面去 - (void)swapPlayer { } -(void)clickChangeRoom:(UIButton *)sender{ // if (_serviceDelegate && [_serviceDelegate respondsToSelector:@selector(protocolGetVideoWithRoomID:)]) // { // [_serviceDelegate protocolGetVideoWithRoomID:group_id]; // } } #pragma mark - 设置pk页面播放 -(void)addPKViewWithURL:(NSString *)url WithViewType:(int )type widthTime:(int )time WithDic:(NSDictionary *)dic AndIsNO1:(BOOL)isOne status:(int)status pkStatus:(int)pkStatus { //2020-1-3 修改pk开始样式 UIImageView *pkcenterImgv=[[UIImageView alloc]initWithFrame:CGRectMake(kScreenW/2-50, 67 + kStatusBarHeight + kScreenW * 2 / 3/2 +20-50, 100, 100)]; pkcenterImgv.image=[UIImage imageNamed:@"pkcenter"]; [self.view addSubview:pkcenterImgv]; UIImageView *pkleftImgv, *pkrightImgv; for (int i=0; i<2; i++) { UIImageView *pkbackImgv=[[UIImageView alloc]init]; [self.view addSubview:pkbackImgv]; UIImageView *pkavatarImgv=[[UIImageView alloc]init]; [pkbackImgv addSubview:pkavatarImgv]; pkavatarImgv.layer.cornerRadius=42/2; pkavatarImgv.layer.masksToBounds=YES; UILabel *namelab=[[UILabel alloc]init]; namelab.textColor=kWhiteColor; namelab.font=[UIFont systemFontOfSize:12]; [pkbackImgv addSubview:namelab]; UILabel *namedelab=[[UILabel alloc]init]; namedelab.textColor=kWhiteColor; namedelab.font=[UIFont systemFontOfSize:12]; [pkbackImgv addSubview:namedelab]; if (i==0) { pkbackImgv.frame=CGRectMake(0, 67 + kStatusBarHeight + kScreenW * 2 / 3 +20+20, 145, 58); pkbackImgv.image=[UIImage imageNamed:@"我方"]; pkleftImgv=pkbackImgv; pkavatarImgv.frame=CGRectMake(15, (58-42)/2, 42, 42); [pkavatarImgv sd_setImageWithURL:[NSURL URLWithString:isOne?[dic valueForKey:@"head_image2"]:[dic valueForKey:@"head_image1"]] placeholderImage:[UIImage imageNamed:@"DefaultImg"]]; namelab.frame=CGRectMake(15+42+5, 58/2-20, 65, 25); // namelab.numberOfLines = 2; // namelab.lineBreakMode = NSLineBreakByCharWrapping; namelab.text=isOne?[dic valueForKey:@"name2"]:[dic valueForKey:@"name1"]; namelab.left = pkavatarImgv.right + 5; namedelab.frame=CGRectMake(15+42+5, 58/2 + 5, 145-15-42-5, 20); namedelab.text= ASLocalizedString(@"我方"); // isOne?ASLocalizedString(@"对方"):ASLocalizedString(@"我方"); }else{ pkbackImgv.frame=CGRectMake(kScreenW-145, 67 + kStatusBarHeight + kScreenW * 2 / 3 +20+20, 145, 58); pkbackImgv.image=[UIImage imageNamed:@"对方"]; pkrightImgv=pkbackImgv; pkavatarImgv.frame=CGRectMake(145-15-42, (58-42)/2, 42, 42); [pkavatarImgv sd_setImageWithURL:[NSURL URLWithString:isOne?[dic valueForKey:@"head_image1"]:[dic valueForKey:@"head_image2"]] placeholderImage:[UIImage imageNamed:@"DefaultImg"]]; namelab.frame=CGRectMake(0, 58/2-20, 65, 25); namelab.text=isOne?[dic valueForKey:@"name1"]:[dic valueForKey:@"name2"]; // namelab.numberOfLines = 2; // namelab.lineBreakMode = NSLineBreakByCharWrapping; namelab.textAlignment=NSTextAlignmentRight; namelab.right = pkbackImgv.width - pkavatarImgv.left - 5; namelab.left = 10; namedelab.frame=CGRectMake(0, 58/2 + 5, 145-15-42-5, 20); namedelab.text = ASLocalizedString(@"对方"); // isOne?ASLocalizedString(@"我方"):ASLocalizedString(@"对方"); namedelab.textAlignment=NSTextAlignmentRight; } } otherId = dic[@"emcee_user_id1"]; if ([otherId isEqualToString:[IMAPlatform sharedInstance].host.imUserId]) { otherId = dic[@"emcee_user_id2"]; } NSMutableDictionary *postObj = [NSMutableDictionary dictionaryWithDictionary:@{@"isFull":@0,@"playUrl":url.length ? url : @""}]; if(type == 1) { //type == 3代表要置换页面 postObj = [NSMutableDictionary dictionaryWithDictionary:@{@"isFull":@3,@"playUrl":url.length ? url : @"",@"touid":otherId}]; } if(self.model) { [postObj setObject:self.model forKey:@"model"]; } [[NSNotificationCenter defaultCenter]postNotificationName:@"onPKViewChange" object:nil userInfo:postObj]; //2020-1-3 修改pk倒计时 if (!_pkCountDownView) { _pkCountDownView = [[FPKCountDownView alloc]initWithFrame:CGRectMake(0, 67 + kStatusBarHeight +10+20, kScreenW, 20) liveItem:_liveItem]; _pkCountDownView.pkid = [NSString stringWithFormat:@"%@",dic[@"id"]]; _pkCountDownView.pktype=@"pk"; [self.view addSubview:_pkCountDownView]; // [self.view bringSubviewToFront:_pkCountDownView]; } if (pkStatus == 2) { [_fpkProgress switchToPunish:(120+time)]; //2020-1-3 修改惩罚倒计时 _pkCountDownView.frame=CGRectMake(0, 67 + kStatusBarHeight + kScreenW * 2 / 3 +20-38, kScreenW, 38); _pkCountDownView.pktype=@"cf"; [_pkCountDownView switchToPunish:(120+time)]; }else{ _pkCountDownView.countDown = time; } //2020-1-4 修改pk int64_t delayInSeconds = 3.0; // 延迟的时间 __weak typeof(self)weakSelf = self; if (_fpkProgress) { _fpkProgress.room_id = _liveInfo.room_id; } dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(delayInSeconds * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ pkcenterImgv.hidden=YES; pkleftImgv.hidden=YES; pkrightImgv.hidden=YES; if(!_fpkProgress) { //2020-1-3 修改pk进度 // BGKSYLiveController *liveVC = (BGKSYLiveController *)_liveController; _fpkProgress = [[FPKProgress alloc] initWithFrame:CGRectMake(0, kStatusBarHeight + 53 + kScreenW * 2.4 / 3, kScreenW, kRealValue(20 + 36))]; [weakSelf.view addSubview:_fpkProgress]; [weakSelf.view insertSubview:_fpkProgress belowSubview:_liveView]; } //进度条 _fpkProgress.leftValue = 0; _fpkProgress.rightValue = 0; _fpkProgress.avatar = isOne?[dic valueForKey:@"head_image1"]:[dic valueForKey:@"head_image2"]; _fpkProgress.otherId = isOne?[dic valueForKey:@"group_id1"]:[dic valueForKey:@"group_id2"]; //2020-1-4 修改pk结束后 _myavatar = isOne?[dic valueForKey:@"head_image2"]:[dic valueForKey:@"head_image1"]; _myId = isOne?[dic valueForKey:@"name2"]:[dic valueForKey:@"name1"]; _avatar=isOne?[dic valueForKey:@"head_image1"]:[dic valueForKey:@"head_image2"]; _otherId = isOne?[dic valueForKey:@"name1"]:[dic valueForKey:@"name2"]; if([[dic allKeys] containsObject:@"pk_ticket1"]) { if ([dic[@"emcee_user_id1"] isEqualToString:[IMAPlatform sharedInstance].host.imUserId] || [_liveInfo.user_id isEqualToString:dic[@"emcee_user_id1"]]) { _fpkProgress.leftValue = [[dic valueForKey:@"pk_ticket1"] intValue]; _fpkProgress.rightValue = [[dic valueForKey:@"pk_ticket2"] intValue]; }else{ _fpkProgress.leftValue = [[dic valueForKey:@"pk_ticket2"] intValue]; _fpkProgress.rightValue = [[dic valueForKey:@"pk_ticket1"] intValue]; } if ([dic[@"pk_status"] integerValue] == 2) { [_fpkProgress showPublishView]; } } if ([self.model.group_id2 isEqualToString:[NSString stringWithFormat:@"%d",[_liveItem liveAVRoomId]]]) { NSArray *gift_list2 = self.model.gift_list2; self.model.gift_list2 = self.model.gift_list1; self.model.gift_list1 = gift_list2; } _fpkProgress.room_id = _liveInfo.room_id; _fpkProgress.model = self.model; }); } -(void)pkViewUpdateData:(NSDictionary *)dic { if ([dic[@"emcee_user_id1"] isEqualToString:[IMAPlatform sharedInstance].host.imUserId] || [_liveInfo.user_id isEqualToString:dic[@"emcee_user_id1"]]) { _fpkProgress.leftValue = [[dic valueForKey:@"pk_ticket1"] intValue]; _fpkProgress.rightValue = [[dic valueForKey:@"pk_ticket2"] intValue]; }else{ _fpkProgress.leftValue = [[dic valueForKey:@"pk_ticket2"] intValue]; _fpkProgress.rightValue = [[dic valueForKey:@"pk_ticket1"] intValue]; } [self getPKInfoWithPKID:self.pkID]; } -(void)getPKInfoWithPKID:(NSString *)pk_ID{ NSMutableDictionary *mDict = [NSMutableDictionary dictionary]; if(![GlobalVariables sharedInstance].openAgora) { [mDict setObject:@"pk_tencent" forKey:@"ctl"]; } else { [mDict setObject:@"pk_agora" forKey:@"ctl"]; } [mDict setObject:@"request_get_pk_info2" forKey:@"act"]; [mDict setObject:pk_ID.length ? pk_ID : @"" forKey:@"pk_id"]; [self.httpsManager POSTWithParameters:mDict SuccessBlock:^(NSDictionary *responseJson) { if ([responseJson toInt:@"status"] == 1 || [responseJson toInt:@"status"] == 2) { //NSString *play_url2 = [responseJson valueForKey:@"play_url2"]; self.model = [BogoPkProgressModel mj_objectWithKeyValues:responseJson]; // if ([self.model.group_id2 isEqualToString:[NSString stringWithFormat:@"%d",[_liveItem liveAVRoomId]]]) { // NSArray *gift_list2 = self.model.gift_list2; // // self.model.gift_list2 = self.model.gift_list1; // self.model.gift_list1 = gift_list2; // } _fpkProgress.room_id = _liveInfo.room_id; _fpkProgress.model = self.model; } } FailureBlock:^(NSError *error) { }]; } //2020-1-4 pk结束 -(void)endpkview:(NSNotification *)noti{ } //2020-1-4 pk结束 -(void)showGiftView:(NSNotification *)noti{ NSLog(@"点击的用户ID %@",noti.userInfo[@"uid"]) [_liveView showGiftView:noti.userInfo[@"uid"]]; } -(void)pkVivewEnd:(NSString *)win_user_id anddic:(NSDictionary *)dic{ // [_showView removeFromSuperview]; // [_showView removeAllSubViews]; // _showView=nil; NSString * _leftValue=@"0"; NSString * _rightValue=@"0"; if (dic.count!=0) { NSLog(@"%@",win_user_id); NSLog(@"%@",[IMAPlatform sharedInstance].host.imUserId); if ([dic[@"emcee_user_id1"] isEqualToString:[IMAPlatform sharedInstance].host.imUserId] || [_liveInfo.user_id isEqualToString:dic[@"emcee_user_id1"]]) { // == [dic[@"emcee_user_id1"] intValue] && win_user_id.intValue == [[IMAPlatform sharedInstance].host.imUserId intValue]) { _leftValue = [dic valueForKey:@"pk_ticket1"]; _rightValue = [dic valueForKey:@"pk_ticket2"]; }else{ _leftValue = [dic valueForKey:@"pk_ticket2"]; _rightValue = [dic valueForKey:@"pk_ticket1"]; } // if (win_user_id.intValue // == [dic[@"emcee_user_id1"] intValue] && win_user_id.intValue == [[IMAPlatform sharedInstance].host.imUserId intValue]) { // _leftValue = [dic valueForKey:@"pk_ticket1"]; // _rightValue = [dic valueForKey:@"pk_ticket2"]; // }else{ // _leftValue = [dic valueForKey:@"pk_ticket2"]; // _rightValue = [dic valueForKey:@"pk_ticket1"]; // } } UIView *showView=[[UIView alloc]initWithFrame:CGRectMake(0, 0, kScreenW, kScreenHeight)]; showView.backgroundColor=[kBlackColor colorWithAlphaComponent:0.6]; [self.view addSubview:showView]; self.showView=showView; [self.view bringSubviewToFront:showView]; UIImageView *backImgv=[[UIImageView alloc]initWithFrame:CGRectMake(kScreenW/2-276/2, kScreenHeight/2-122, 276, 244)]; backImgv.image=[UIImage imageNamed:@"弹窗背景"]; [showView addSubview:backImgv]; UIImageView *topImgv=[[UIImageView alloc]initWithFrame:CGRectMake(kScreenW/2-179/2, kScreenHeight/2-244/2-52/2, 179, 52)]; topImgv.image=[UIImage imageNamed:@"PK结束"]; [showView addSubview:topImgv]; showView.userInteractionEnabled=YES; backImgv.userInteractionEnabled=YES; UIButton *btn=[[UIButton alloc]initWithFrame:CGRectMake(backImgv.width-30, 10, 20, 20)]; [btn setImage:[UIImage imageNamed:@"pk关闭"] forState:UIControlStateNormal]; [btn addTarget:self action:@selector(pushToCancleClick) forControlEvents:UIControlEventTouchUpInside]; [backImgv addSubview:btn]; UIImageView *centerImgv=[[UIImageView alloc]initWithFrame:CGRectMake(backImgv.width/2-30/2, 52/2+15+30-17/2, 30, 17)]; centerImgv.image=[UIImage imageNamed:@"PK后"]; [backImgv addSubview:centerImgv]; for (int i=0; i<2; i++) { UIImageView *pkavatarImgv=[[UIImageView alloc]init]; [backImgv addSubview:pkavatarImgv]; pkavatarImgv.layer.cornerRadius=60/2; pkavatarImgv.layer.masksToBounds=YES; UILabel *namelab=[[UILabel alloc]init]; namelab.textColor=RGB(102, 102, 102); namelab.textAlignment=NSTextAlignmentCenter; namelab.font=[UIFont systemFontOfSize:13]; [backImgv addSubview:namelab]; UIImageView *footImgv=[[UIImageView alloc]init]; [backImgv addSubview:footImgv]; UILabel *numlab=[[UILabel alloc]init]; numlab.backgroundColor=RGB(245, 245, 245); numlab.textColor=RGB(148, 143, 255); numlab.textAlignment=NSTextAlignmentCenter; numlab.font=[UIFont systemFontOfSize:13]; [backImgv addSubview:numlab]; numlab.layer.cornerRadius=3; numlab.layer.masksToBounds=YES; if (i==0) { pkavatarImgv.frame=CGRectMake(backImgv.width/2/2-30, 52/2+15, 60, 60); [pkavatarImgv sd_setImageWithURL:[NSURL URLWithString:_myavatar] placeholderImage:[UIImage imageNamed:@"com_preload_head_img"]]; namelab.frame=CGRectMake(0, 52/2+15+65, backImgv.width/2, 15); namelab.text=_myId; if (_leftValue.intValue > _rightValue.intValue) { //左边胜利,右边失败 footImgv.frame=CGRectMake(backImgv.width/2/2-91/2, 52/2+15+65+20, 91, 48); footImgv.image=[UIImage imageNamed:@"胜利"]; }else if (_leftValue.intValue < _rightValue.intValue){ //左边失败,右边胜利 footImgv.frame=CGRectMake(backImgv.width/2/2-78/2, 52/2+15+65+20+2.5, 78, 43); footImgv.image=[UIImage imageNamed:@"成功"]; }else{ footImgv.frame=CGRectMake(backImgv.width/2/2-56/2, 52/2+15+65+20-(56-48)/2, 56, 56); footImgv.image=[UIImage imageNamed:@"平局"]; //2020-1-7 平局 UILabel *lab=[[UILabel alloc]initWithFrame:CGRectMake(0, 0, 56, 56)]; lab.font=[UIFont boldSystemFontOfSize:12]; lab.text=ASLocalizedString(@"平局"); lab.textColor=kWhiteColor; lab.textAlignment=NSTextAlignmentCenter; [footImgv addSubview:lab]; } numlab.frame=CGRectMake(backImgv.width/2/2-83/2, 52/2+15+65+20+50, 83, 25); numlab.text=[NSString stringWithFormat:@"%@",_leftValue]; }else{ pkavatarImgv.frame=CGRectMake(backImgv.width/2+backImgv.width/2/2-30, 52/2+15, 60, 60); [pkavatarImgv sd_setImageWithURL:[NSURL URLWithString:_avatar] placeholderImage:[UIImage imageNamed:@"com_preload_head_img"]]; namelab.frame=CGRectMake(backImgv.width/2, 52/2+15+65, backImgv.width/2, 15); namelab.text=_otherId; if (_leftValue.intValue > _rightValue.intValue) { //左边胜利,右边失败 footImgv.frame=CGRectMake(backImgv.width/2+backImgv.width/2/2-78/2, 52/2+15+65+20+2.5, 78, 43); footImgv.image=[UIImage imageNamed:@"成功"]; }else if (_leftValue.intValue < _rightValue.intValue){ //左边失败,右边胜利 footImgv.frame=CGRectMake(backImgv.width/2+backImgv.width/2/2-91/2, 52/2+15+65+20, 91, 48); footImgv.image=[UIImage imageNamed:@"胜利"]; }else{ footImgv.frame=CGRectMake(backImgv.width/2+backImgv.width/2/2-56/2, 52/2+15+65+20-(56-48)/2, 56, 56); footImgv.image=[UIImage imageNamed:@"平局"]; //2020-1-7 平局 UILabel *lab=[[UILabel alloc]initWithFrame:CGRectMake(0, 0, 56, 56)]; lab.font=[UIFont boldSystemFontOfSize:12]; lab.text=ASLocalizedString(@"平局"); lab.textColor=kWhiteColor; lab.textAlignment=NSTextAlignmentCenter; [footImgv addSubview:lab]; } numlab.frame=CGRectMake(backImgv.width/2+backImgv.width/2/2-83/2, 52/2+15+65+20+50, 83, 25); numlab.text=[NSString stringWithFormat:@"%@",_rightValue]; } } } -(void)pushToCancleClick{ [_showView removeFromSuperview]; [_showView removeAllSubViews]; _showView=nil; } - (void)switchToPunish:(int)time{ //切换pk视图到惩罚视图 [_fpkProgress switchToPunish:time]; //2020-1-3 修改惩罚倒计时 _pkCountDownView.frame=CGRectMake(0, 67 + kStatusBarHeight + kScreenW * 2 / 3 +20-38, kScreenW, 38); _pkCountDownView.pktype=@"cf"; [_pkCountDownView switchToPunish:time]; } //self.layer.transform = CATransform3DMakeScale(1.2f, 1.2f, 1.0f); //self.alpha = 0.0f; // //[UIView animateWithDuration:self.animationDuration // delay:0.0 options:UIViewAnimationOptionCurveEaseOut | UIViewAnimationOptionBeginFromCurrentState // animations:^{ // // self.layer.transform = CATransform3DIdentity; // self.alpha = 1.0f; // // } completion:^(BOOL finished) { // // if ( self.showCompletionBlock ) // { // self.showCompletionBlock(self, finished); // } // }]; -(void)pkVivewHidden { NSMutableDictionary *dict = [[NSMutableDictionary alloc]init]; if(![GlobalVariables sharedInstance].openAgora) { [dict setObject:@"pk_tencent" forKey:@"ctl"]; } else { [dict setObject:@"pk_agora" forKey:@"ctl"]; } [dict setValue:@"request_end_pk" forKey:@"act"]; [[NetHttpsManager manager] POSTWithParameters:dict SuccessBlock:^(NSDictionary *responseJson) { if ([responseJson toInt:@"status"] == 1) { NSLog(ASLocalizedString(@"结束PK请求成功responseJson:%@"),responseJson); }else{ NSLog(ASLocalizedString(@"结束PK请求失败responseJson:%@"),responseJson); } } FailureBlock:^(NSError *error) { NSLog(ASLocalizedString(@"结束PK请求失败error:%@"),error); }]; [_pkView stopPlay]; [_pkView.view removeFromSuperview]; [_pkView removeFromParentViewController]; _pkView = nil; [_pkCountDownView stopTimer]; [_pkCountDownView removeFromSuperview]; _pkCountDownView = nil; NSDictionary *postObj = @{@"isFull":@1}; [[NSNotificationCenter defaultCenter]postNotificationName:@"onPKViewChange" object:nil userInfo:postObj]; //通知主线程刷新 // dispatch_async(dispatch_get_main_queue(), ^{ NSArray * views = [_fpkProgress subviews]; for (UIView * v in views){ [v removeFromSuperview]; } [_fpkProgress setLeftValue:0]; [_fpkProgress setRightValue:0]; [_fpkProgress removeFromSuperview]; _fpkProgress = nil; // }); } -(void)hiddenPKlist { pkList.view.hidden = YES; pkList = nil; } -(void)showPKlist { if (_fpkProgress) { PKPopView *popView = [[PKPopView alloc]initWithType:PKPopViewTypeDetail]; popView.frame = CGRectMake(0, kScreenH, kScreenW, 250); [popView setOtherId:otherId]; [popView setClickEndPkBtnBlock:^{ //点击了结束PK按钮 NSMutableDictionary *dict = [[NSMutableDictionary alloc]init]; if(![GlobalVariables sharedInstance].openAgora) { [dict setObject:@"pk_tencent" forKey:@"ctl"]; } else { [dict setObject:@"pk_agora" forKey:@"ctl"]; } [dict setValue:@"request_end_pk" forKey:@"act"]; [self.httpsManager POSTWithParameters:dict SuccessBlock:^(NSDictionary *responseJson) { if ([responseJson toInt:@"status"] == 1) { NSLog(ASLocalizedString(@"结束PK请求成功responseJson:%@"),responseJson); [[NSNotificationCenter defaultCenter] postNotificationName:@"endPunish" object:nil]; }else{ NSLog(ASLocalizedString(@"结束PK请求失败responseJson:%@"),responseJson); [[NSNotificationCenter defaultCenter] postNotificationName:@"endPunish" object:nil]; } } FailureBlock:^(NSError *error) { NSLog(ASLocalizedString(@"结束PK请求失败error:%@"),error); [[NSNotificationCenter defaultCenter] postNotificationName:@"endPunish" object:nil]; }]; }]; [popView show:self.view]; //[popView show:[UIApplication sharedApplication].keyWindow]; //2020-1-4 最上方 //[[UIApplication sharedApplication].keyWindow.viewController.view bringSubviewToFront:popView]; }else{ // NSMutableDictionary *dict = [[NSMutableDictionary alloc]init]; // [dict setValue:@"pk_tencent" forKey:@"ctl"]; // [dict setValue:@"request_end_pk" forKey:@"act"]; // [[NetHttpsManager manager] POSTWithParameters:dict SuccessBlock:^(NSDictionary *responseJson) { // if ([responseJson toInt:@"status"] == 1) { // NSLog(ASLocalizedString(@"结束PK请求成功responseJson:%@"),responseJson); // }else{ // NSLog(ASLocalizedString(@"结束PK请求失败responseJson:%@"),responseJson); // } // } FailureBlock:^(NSError *error) { // NSLog(ASLocalizedString(@"结束PK请求失败error:%@"),error); // }]; if(pkList == nil) { pkList = [[PKUserListViewController alloc] init]; pkList.pDelegate = self; [self addChildViewController:pkList]; pkList.view.frame = CGRectMake(0, kScreenH/2, kScreenW, kScreenH/2); [self.view addSubview:pkList.view]; } pkList.view.hidden = NO; [pkList reloadData]; } } -(void)closeUserListView{ [self hiddenPKlist]; } -(void)showWishView{ if (!_wishView) { _wishView = [[MGLiveWishView alloc]initWithFrame:CGRectMake(0, kScreenH / 2, kScreenW, kScreenH / 2)]; _wishView.roomId=[NSString stringWithFormat:@"%d",[_liveItem liveAVRoomId]]; __weak __typeof(self)weakSelf = self; _wishView.clickLiveWishBlock = ^(MGADD_WISH wishType) { // [weakSelf.wishView hide]; MGAddWishViewController *vc = [[MGAddWishViewController alloc]initWithWishType:wishType]; vc.roomId=[NSString stringWithFormat:@"%d",[_liveItem liveAVRoomId]]; vc.clickGiftCellBlcok = ^(MGLiveWishModel * _Nonnull wishModel) { wishModel.id = @""; [weakSelf.wishView.listArr addObject:wishModel]; [weakSelf.wishView.tableView reloadData]; NSLog(@"%@",weakSelf.wishView.listArr); }; [weakSelf.navigationController pushViewController:vc animated:YES]; }; //触发隐藏心愿的block _wishView.clickHideLiveWishBlock = ^{ [weakSelf.liveView.livewWishView requestModel:[NSString stringWithFormat:@"%d",[_liveItem liveAVRoomId]]]; //[weakSelf.liveView.livewWishView requestModel]; }; } [_wishView show:self.view]; } -(void)showSoundView{ __weak __typeof(self)weakSelf = self; if (!_soundSetView) { _soundSetView = [[BGSoundEffectsView alloc]initWithFrame:CGRectMake(0, kScreenH / 2, kScreenW, kScreenH / 2)]; _soundSetView.playUrl = ^(BGSoundEffectModel * model) { if(weakSelf.playUrlBlock) { weakSelf.playUrlBlock(model); } }; } [_soundSetView show:self.view]; } -(void)showSoundSetView:(TCShowLiveView *)showLiveView{ [self showSoundView]; } -(void)showVipView:(TCShowLiveView *)showLiveView{ if (!_vipView) { _vipView = [[MGShowVIPListView alloc]initWithFrame:CGRectMake(0, kScreenH / 2, kScreenW, kScreenH *0.6)]; } [_vipView show:self.view withRoomID:[NSString stringWithFormat:@"%d",[_liveItem liveAVRoomId]]]; } -(void)addValue { //模拟增加 dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ _fpkProgress.leftValue += 5; [self addValue]; }); } #pragma mark - ----------------------- 付费相关UI ----------------------- #pragma mark 付费直播 - (void)beginEnterPayLive:(NSDictionary *)responseJson closeBtn:(UIButton *)closeBtn { if (!_isHost && ![[[IMAPlatform sharedInstance].host imUserId] isEqualToString:[[_liveItem liveHost] imUserId]]) { if (!self.livePay) { self.livePay = [[BGLivePayManager alloc]initWithController:self andLiveView:self.liveView andRoomId:[_liveItem liveAVRoomId] andAudienceDict:responseJson andButton:closeBtn]; if ([responseJson toInt:@"is_live_pay"] == 1) { if ([_liveItem liveType] == FW_LIVE_TYPE_AUDIENCE)//回播或者云直播的观众 { if ([responseJson toString:@"preview_play_url"] && ![[responseJson toString:@"preview_play_url"] isEqualToString:@""]) { [_liveController startLiveRtmp:[responseJson toString:@"preview_play_url"]]; self.livePay.shadowView.backgroundColor = kClearColor; [_liveController setSDKMute:NO]; if ([responseJson toInt:@"is_only_play_voice"] == 1)//只有声音没有视频画面 { [self.livePayTimer invalidate]; self.livePayTimer = nil; [self.livePayLabel removeFromSuperview]; self.livePayLabel = nil; [self.livePay creatShadowView]; self.livePay.shadowView.hidden = NO; [self.view bringSubviewToFront:self.livePay.shadowView]; } } else { self.livePay.shadowView.backgroundColor = kLightGrayColor; self.livePay.shadowView.hidden = NO; } self.livePayCount = [responseJson toInt:@"countdown"]; if (self.livePayCount) { self.livePayTimer = [NSTimer scheduledTimerWithTimeInterval:1.0 target:self selector:@selector(livePayTimeGo) userInfo:nil repeats:YES]; [[NSRunLoop currentRunLoop] addTimer:self.livePayTimer forMode:NSRunLoopCommonModes]; } if ([responseJson toInt:@"is_pay_over"] == 0)//开启付费且 { self.livePayLabel = [[UILabel alloc]initWithFrame:CGRectMake(10, 80, kScreenW-20, 90)]; self.livePayLabel.textAlignment = NSTextAlignmentCenter; self.livePayLabel.font = [UIFont systemFontOfSize:16]; self.livePayLabel.textColor = kWhiteColor; self.livePayLabel.numberOfLines = 0; self.livePayLabel.backgroundColor = kClearColor; if ([responseJson toInt:@"live_pay_type"] == 1)//按场收费 { self.payLiveType = 1; self.livePayLabel.text =[NSString stringWithFormat:ASLocalizedString(@"该直播按场收费,您还能预览倒计时%d秒"),self.livePayCount]; } else { self.payLiveType = 0; self.livePayLabel.text =[NSString stringWithFormat:ASLocalizedString(@"1分钟内重复进入,不重复扣费,请能正常预览视频后,点击进入,以免扣费后不能正常进入,您还能预览倒计时%d秒"),self.livePayCount]; } [self.view addSubview:self.livePayLabel]; } [self.view bringSubviewToFront:closeBtn]; } if ([responseJson toInt:@"live_pay_type"] == 1)//按场收费 { self.livePay.liveType = 40; } if ([responseJson toInt:@"is_pay_over"] == 0)//该参数是否付费过 1付费过 0未付费 { self.livePay.audienceLeftPView.hidden = YES;//为了预览倒计时和观众左边重叠 self.livePay.is_agree = NO; } else { self.livePay.is_agree = YES; } [self.livePay enterMoneyMode]; [self changePayView:self.liveView]; } FWWeakify(self) [self.livePay setBlock:^(NSString *string){ FWStrongify(self) if ([string isEqualToString:@"1"]) { [self chargerMoney]; } else if ([string isEqualToString:@"2"]) { [self closeLiveController]; } }]; } [self changePayViewFrame:self.liveView]; }else { if ([responseJson toInt:@"is_live_pay"] == 1 && ([_liveItem liveType] == FW_LIVE_TYPE_HOST || [_liveItem liveType] == FW_LIVE_TYPE_RECORD || [_liveItem liveType] == FW_LIVE_TYPE_AUDIENCE)) { if (!self.livePay) { self.livePay = [[BGLivePayManager alloc]initWithLiveView:self.liveView andRoomId:[_liveItem liveAVRoomId] andhostDict:responseJson andpayType:[_liveItem liveType]]; } [self.livePay hostEnterLiveAgainWithMDict:responseJson]; } } } #pragma mark 心跳唤起付费界面 - (void)createPayLiveView:(NSDictionary *)responseJson { self.currentMonitorDict = responseJson; [self.livePay creatViewWithDict:responseJson]; } #pragma mark IM消息的通知 - (void)getVedioViewWithType:(int)type closeBtn:(UIButton *)closeBtn { if (!self.livePay) { self.livePay = [[BGLivePayManager alloc]initWithController:self andLiveView:self.liveView andRoomId:[_liveItem liveAVRoomId] andAudienceDict:self.currentMonitorDict andButton:closeBtn]; FWWeakify(self) [self.livePay setBlock:^(NSString *string) { FWStrongify(self) if ([string isEqualToString:@"1"]) { [self chargerMoney]; } else if ([string isEqualToString:@"2"]) { [self closeLiveController]; } }]; } [self.livePay AudienceGetVedioViewWithType:type]; [self changePayViewFrame:self.liveView]; } #pragma mark 插件中心点击付费 - (void)clickPluginPayItem:(GameModel *)model closeBtn:(UIButton *)closeBtn { if ([model.class_name isEqualToString:@"live_pay"]) // 按时付费 { if ([model.is_active isEqualToString:@"0"]) { SUS_WINDOW.isShowLivePay = YES; if (!self.livePay) { self.livePay = [[BGLivePayManager alloc]initWithLiveView:self.liveView andRoomId:[_liveItem liveAVRoomId] andhostDict:self.currentMonitorDict andpayType:[_liveItem liveType]]; if ([[self.currentMonitorDict objectForKey:@"live"] toInt:@"allow_live_pay"] != 1) { [FanweMessage alert:ASLocalizedString(@"直播间人数未达到收费人数")]; } else { self.livePay.buttomFunctionType = self.livePay.liveType = [_liveItem liveType];//通过这个判断来显示付费页面左边的提示 [self.livePay creatPriceViewWithCount:1]; } } else { self.livePay.buttomFunctionType = self.livePay.liveType = [_liveItem liveType]; [self.livePay creatViewWithDict:self.currentMonitorDict]; if ([[self.currentMonitorDict objectForKey:@"live"] toInt:@"allow_live_pay"] != 1) { [FanweMessage alert:ASLocalizedString(@"直播间人数未达到收费人数")]; } else { [self.livePay creatPriceViewWithCount:1]; } } } else { [FanweMessage alert:ASLocalizedString(@"直播间已处于收费模式中")]; } [self changePayView:self.liveView]; [self changePayViewFrame:self.liveView]; } else if ([model.class_name isEqualToString:@"live_pay_scene"]) // 按场付费 { if ([model.is_active isEqualToString:@"0"]) { if (!self.livePay) { self.livePay = [[BGLivePayManager alloc]initWithLiveView:self.liveView andRoomId:[_liveItem liveAVRoomId] andhostDict:self.currentMonitorDict andpayType:[_liveItem liveType]]; self.livePay.liveType = 40; [self.livePay creatPriceViewWithCount:3]; } else { self.livePay.liveType = 40; [self.livePay creatPriceViewWithCount:3]; } } else { [FanweMessage alert:ASLocalizedString(@"直播间已处于收费模式中")]; } [self changePayViewFrame:self.liveView]; } } #pragma mark 付费列表倒计时 - (void)livePayTimeGo { self.livePayCount --; if (self.livePayCount == 0) { [self.livePayLabel removeFromSuperview]; self.livePayLabel = nil; [self.livePayTimer invalidate]; self.livePayTimer = nil; [_liveController stopLiveRtmp]; [_liveController setSDKMute:YES]; } self.livePayLabel.text =[NSString stringWithFormat:ASLocalizedString(@"1分钟内重复进入,不重复扣费,请能正常预览视频后,点击进入,以免扣费后不能正常进入,您还能预览倒计时%d秒"),self.livePayCount]; } #pragma mark 付费直播充钱的操作 - (void)chargerMoney { // if (!self.rechargeView) { // [self.rechargeView show:self.view]; // } if (_serviceDelegate && [_serviceDelegate respondsToSelector:@selector(showRechargeView:)]) { [_serviceDelegate showRechargeView:self]; } } #pragma mark 付费直播关闭直播间的操作 - (void)closeLiveController { BOOL isDirectCloseLive; if (_isHost) { isDirectCloseLive = NO; } else { isDirectCloseLive = YES; } DebugLog(@"=================:付费直播关闭直播间的操作"); if (_serviceDelegate && [_serviceDelegate respondsToSelector:@selector(closeCurrentLive:isHostShowAlert:)]) { [_serviceDelegate closeCurrentLive:isDirectCloseLive isHostShowAlert:NO]; } } #pragma mark 切换付费 - (void)clickChangePay:(TCShowLiveView *)showLiveView { if ([[self.currentMonitorDict objectForKey:@"live"] toInt:@"allow_live_pay"] == 1) { [self.livePay creatPriceViewWithCount:1]; } else { [FanweMessage alert:ASLocalizedString(@"直播间人数未达到收费人数")]; } } #pragma mark 提档 - (void)clickMention:(TCShowLiveView *)showLiveView { if ([[self.currentMonitorDict objectForKey:@"live"] toInt:@"allow_mention"] == 1) { [self.livePay creatPriceViewWithCount:2]; } } - (void)changePayView:(TCShowLiveView *)showLiveView { [self.livePay changeLeftViewFrameWithIsHost:_isHost andAuctionView:showLiveView.topView.priceView andBankerView:showLiveView.gameBankerView]; } - (void)changePayViewFrame:(TCShowLiveView *)showLiveView { [self.livePay changeLeftViewFrameWithIsHost:_isHost andAuctionView:showLiveView.topView.priceView andBankerView:showLiveView.gameBankerView]; } - (void)dealLivepayTComfirm { self.livePay.audienceLeftPView.hidden = NO;//观众进入直播间要把左边的付费信息显示出来(一开始为了避免预览倒计时和左边重叠就将其隐藏) [self.livePayTimer invalidate]; self.livePayTimer = nil; [self.livePayLabel removeFromSuperview]; self.livePayLabel = nil; } #pragma mark - ----------------------- 键盘事件 ----------------------- #pragma mark 键盘监听 - (void)registerKeyBoardNotification { //添加键盘监听 [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onKeyboardWillShow:) name:UIKeyboardWillShowNotification object:nil]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onKeyboardWillHide:) name:UIKeyboardWillHideNotification object:nil]; FWWeakify(self) // 1.监听键盘 地球 切换 [Noti_Default addObserverForName:UIKeyboardDidChangeFrameNotification object:nil queue:[NSOperationQueue mainQueue] usingBlock:^(NSNotification *_Nonnull note) { FWStrongify(self) // 取出键盘高度 CGRect keyboardF = [note.userInfo[UIKeyboardFrameEndUserInfoKey] CGRectValue]; CGFloat keyboardH = keyboardF.size.height; if (self.isKeyboardTypeNum == 1 && self.isHaveHalfIMMsgVC) { for (UIViewController *one_VC in self.childViewControllers) { if ([one_VC isKindOfClass:[BGConversationServiceController class]]) { BGConversationServiceController *im_Msg_VC = (BGConversationServiceController *) one_VC; [UIView animateWithDuration:0.25 animations:^{ im_Msg_VC.view.y = kScreenH / 2 - keyboardH; } completion:^(BOOL finished){ }]; } } } }]; } - (void)onKeyboardWillShow:(NSNotification *)notification { // 1.键盘弹出需要的时间 CGFloat animationDuration = [notification.userInfo[UIKeyboardAnimationDurationUserInfoKey] doubleValue]; // 取出键盘高度 CGRect keyboardF = [notification.userInfo[UIKeyboardFrameEndUserInfoKey] CGRectValue]; CGFloat keyboardH = keyboardF.size.height; FWWeakify(self) [UIView animateWithDuration:animationDuration animations:^{ FWStrongify(self) if (_isHaveHalfIMMsgVC == YES && _isKeyboardTypeNum != 1) { // 弹出 文本 键盘 //[self textKeyboardUp:keyboardH]; } if (self.isHaveHalfIMChatVC == NO ) { if (self.liveView.goldFlowerView && self.liveView.goldViewCanNotSee == NO && self.liveView.bankerViewCanSee == NO) { self.liveView.liveInputView.transform = CGAffineTransformMakeTranslation(0, -keyboardH+self.liveView.goldFlowerViewHeiht); self.liveView.msgView.transform = CGAffineTransformMakeTranslation(0, -keyboardH+self.liveView.goldFlowerViewHeiht); // [self textKeyboardUp:keyboardH]; } else if (self.liveView.guessSizeView && self.liveView.guessSizeViewCanNotSee == NO && self.liveView.bankerViewCanSee == NO) { self.liveView.liveInputView.transform = CGAffineTransformMakeTranslation(0, -keyboardH+kGuessSizeViewHeight); self.liveView.msgView.transform = CGAffineTransformMakeTranslation(0, -keyboardH+kGuessSizeViewHeight); //[self textKeyboardUp:keyboardH]; } else if ((self.liveView.goldFlowerView || self.liveView.guessSizeView) && self.liveView.bankerViewCanSee == YES) { // _liveView.bankerView.y = _liveView.height - keyboardF.size.height - _liveView.bankerView.height - 50; } else { // self.liveView.transform = CGAffineTransformMakeTranslation(0, - keyboardH); [UIView animateWithDuration:animationDuration animations:^{ self.liveView.liveInputView.top = kScreenH - keyboardH - self.liveView.liveInputView.height; }]; } } }]; } #pragma mark 弹起文本键盘 - (void)textKeyboardUp:(CGFloat)move_high { for (UIViewController *vc in self.childViewControllers) { if ([vc isKindOfClass:[BGConversationServiceController class]]) { BGConversationServiceController *im_Msg_VC = (BGConversationServiceController *) vc; FWWeakify(self) __weak BGConversationServiceController *imMsgVC = im_Msg_VC; _isKeyboardTypeNum = 1; //关闭 CGFloat time = 0.0; dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(time * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ // 保证表情 if(move_high <100) { return ; } [UIView animateWithDuration:0.4 animations:^{ //im_Msg_VC.view.height = kScreenH/2; imMsgVC.view.y = kScreenH/2-move_high; } completion:^(BOOL finished) { FWStrongify(self) //必须写在这里 if (finished) { imMsgVC.view.height = kScreenH/2; imMsgVC.view.y = kScreenH/2-move_high; imMsgVC.inputView.hidden = YES; self.isKeyboardTypeNum = 1;//是否加载半屏幕 VC 键盘类型 1文本 2表情 3更多 } }]; }); } } } - (void)onKeyboardDidShow:(NSNotification *)notification { } - (void)onKeyboardWillHide:(NSNotification *)notification { self.liveView.bottomView.hidden = NO; [self.liveView hideInputView]; // 1.键盘弹出需要的时间 CGFloat duration = [notification.userInfo[UIKeyboardAnimationDurationUserInfoKey] doubleValue]; // 取出键盘高度 CGRect keyboardF = [notification.userInfo[UIKeyboardFrameEndUserInfoKey] CGRectValue]; CGFloat keyboardH = keyboardF.size.height; FWWeakify(self) // 2.动画 [UIView animateWithDuration:duration animations:^{ FWStrongify(self) if (_isHaveHalfIMMsgVC == YES) { [[NSNotificationCenter defaultCenter] postNotificationName:@"HalfIMMsgChaVC" object:nil userInfo:@{@"keyboardH":[NSString stringWithFormat:@"%f",keyboardH]}]; return ; } if (self.isHaveHalfIMChatVC == NO) { if (self.liveView.goldFlowerView && self.liveView.goldViewCanNotSee == NO && self.liveView.bankerViewCanSee == NO) { self.liveView.liveInputView.transform = CGAffineTransformIdentity;//恢复之前的位置 self.liveView.msgView.transform = CGAffineTransformIdentity;//恢复之前的位置 self.liveView.transform = CGAffineTransformIdentity;//恢复之前的位置 } else if (self.liveView.guessSizeView && self.liveView.guessSizeViewCanNotSee == NO && self.liveView.bankerViewCanSee == NO) { self.liveView.liveInputView.transform = CGAffineTransformIdentity;//恢复之前的位置 self.liveView.msgView.transform = CGAffineTransformIdentity;//恢复之前的位置 self.liveView.transform = CGAffineTransformIdentity;//恢复之前的位置 } else if ((self.liveView.goldFlowerView || self.liveView.guessSizeView) && self.liveView.bankerViewCanSee == YES) { // self.liveView.bankerView.frame = CGRectMake((kScreenW - 255)/2, (kScreenH - 195)/2, 255, 195); } else { // self.liveView.transform = CGAffineTransformIdentity;//恢复之前的位置 [UIView animateWithDuration:duration animations:^{ self.liveView.liveInputView.top = kScreenH; }]; } [self.liveView relayoutFrameOfSubViews]; } }]; } #pragma mark -表情/更多 键盘弹起 /*! * @author Yue * * @brief ykk825 代理实现 表情/更多按钮控制 键盘弹起 * * @param isFace 表情 * @param isHave 键盘是否已经存在 * * @step 1: 表情键盘 * * */ - (void)faceAndMoreKeyboardBtnClickWith:(BOOL)isFace isNotHaveBothKeyboard:(BOOL)isHave keyBoardHeight:(CGFloat)height { for (UIViewController *vc in self.childViewControllers) { if ([vc isKindOfClass:[BGConversationServiceController class]]) { BGConversationServiceController *imMsg_VC = (BGConversationServiceController *) vc; [UIView animateWithDuration:0.2 animations:^{ if(isHave == YES) { imMsg_VC.view.y = kScreenH/2-300; imMsg_VC.view.height = kScreenH-(kScreenH*0.5-300)-height; } else if (isFace == YES) { imMsg_VC.view.y = kScreenH/2-300; imMsg_VC.view.height = kScreenH-(kScreenH*0.5-300); } else if (isHave == NO && isFace == NO) { imMsg_VC.view.y = kScreenH/2; imMsg_VC.view.height =kScreenH/2; } else { imMsg_VC.view.y = kScreenH/2; } } completion:^(BOOL finished) { }]; } } } #pragma mark - ----------------------- 弹出 半屏幕VC 部分 ----------------------- /** 直播VC 加2个子 半屏幕的子VC 不能直接的push/模态。。弹出半VC,直播VC 还要能点击--加载/退出分2部分: 导航上按钮控制 & 其他控件控制 1: 添加chatVC 列表Vc 2: chatVC 返回键 3: chatVC 点击cell 加载 到 IMMsgVC 4: IMMsgVC 返回按键 返回到 chatVC 5: homePageVC IMMsgVC push homePageVC 6: clickBlank 实现代理方法,是TCShowLieView 的方法(手势里 7: returnChatVC 找到子VC-chatVC 8: returnIMMsgVC 找到子VC -IMMsgVC */ - (void)addTwoSubVC { if (!_imChatVCBgView) { _imChatVCBgView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, kScreenW, kScreenH)]; _imChatVCBgView.backgroundColor = [UIColor clearColor]; [self.liveView addSubview:_imChatVCBgView]; UITapGestureRecognizer *IMChatVCTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(ChatVCBgViewTap)]; [_imChatVCBgView addGestureRecognizer:IMChatVCTap]; } else { _imChatVCBgView.hidden = NO; } //1. if (self.isHaveHalfIMChatVC == YES) { return; } //2. //ConversationListController *imChat_VC = [ConversationListController createIMChatVCWithHalf:self isRelive:NO]; BGConversationSegmentController *imChat_VC = [BGConversationSegmentController createIMChatVCWithHalf:self isRelive:NO]; //3. _isKeyboardTypeNum = 0; self.isHaveHalfIMChatVC = YES; //4. __weak __typeof(self) weak_Self = self; __weak BGConversationSegmentController *weak_chat_VC = imChat_VC; //5. weak_chat_VC.goNextVCBlock = ^(int tag, SFriendObj *friend_Obj) { //6. if (tag == 1) { [weak_Self chatVCBackToLiveVC:weak_chat_VC]; } else { //7.去聊天界面 if (weak_Self.isHaveHalfIMMsgVC == YES) { return; } //8.Go [weak_Self chatVCGoIMMsgVC:weak_chat_VC withFrinend:friend_Obj]; } }; } #pragma mark -chatVC -返回 //@step 2: - (void)chatVCBackToLiveVC:(BGConversationSegmentController *)chat_VC { // A --返回 chatVC -- 直接移到下面 并删除 [UIView animateWithDuration:kHalfVCViewanimation animations:^{ //当前chatVc 半VC 显示,要下去 chat_VC.view.y = kScreenH; } completion:^(BOOL finished) { //移除 chatVc [chat_VC.view removeFromSuperview]; [self removeChild:chat_VC]; self.isHaveHalfIMChatVC = NO; self.isHaveHalfIMMsgVC = NO; }]; } #pragma mark - Goto 聊天 half VC //@step 3: - (void)chatVCGoIMMsgVC:(BGConversationSegmentController *)chat_VC withFrinend:(SFriendObj *)friend_Obj { BGConversationServiceController *imMsgChat_VC = [[BGConversationServiceController alloc] initWithNibName:@"BGBaseChatController" bundle:nil]; //1.2 imMsgChat_VC.mbhalf = NO; imMsgChat_VC.mChatFriend = friend_Obj; //1.1 // imMsgChat_VC.view.frame = CGRectMake(kScreenW, kScreenH / 2, kScreenW, kScreenH / 2 ); [[AppDelegate sharedAppDelegate] pushViewController:imMsgChat_VC animated:NO]; return; // BGConversationServiceController *imMsgChat_VC = [BGConversationServiceController createIMMsgVCWithHalfWith:friend_Obj form:self isRelive:NO]; // imMsgChat_VC.delegate = self; // self.isHaveHalfIMMsgVC = YES; // // 传一个参数 // __weak BGConversationServiceController *weak_iMsg_VC = imMsgChat_VC; // weak_iMsg_VC.backOrGoNextVCBlock = ^(int tag) { // // 返回到chatVC // if (tag == 1) // { // [self imMsgVcGoBackToChatVC:weak_iMsg_VC]; // } // else // { // //去 push // [self imMsgVCPushHomePageVC:weak_iMsg_VC]; // } // }; } #pragma - imMsgVC - 聊天返回列表ChatVC //@step 4: - (void)imMsgVcGoBackToChatVC:(BGConversationServiceController *)weak_iMsg_VC { //先下来 表情/更多 CGFloat time; CGFloat height = weak_iMsg_VC.view.frame.size.height; if (height > kScreenH/2) { time = 0.2; weak_iMsg_VC.inputView.hidden = YES; [UIView animateWithDuration:time animations:^{ weak_iMsg_VC.view.y =kScreenH/2; } completion:^(BOOL finished) { weak_iMsg_VC.view.height = kScreenH/2; weak_iMsg_VC.inputView.hidden = NO; self.isKeyboardTypeNum = 0; }]; } dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(time * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ [UIView animateWithDuration:kHalfVCViewanimation animations:^{ weak_iMsg_VC.view.x = kScreenW; } completion:^(BOOL finished) { weak_iMsg_VC.view.height = kScreenH/2; [weak_iMsg_VC.view removeFromSuperview]; [self removeChild:weak_iMsg_VC animation:nil]; self.isHaveHalfIMMsgVC = NO; }]; }); } #pragma - imMsgVC - push 到个人中心 // @step 5: - (void)imMsgVCPushHomePageVC:(BGConversationServiceController *)imMsgChatVC { SHomePageVC *tmpController = [[SHomePageVC alloc] init]; tmpController.user_id = [NSString stringWithFormat:@"%d", imMsgChatVC.mChatFriend.mUser_id]; tmpController.type = 0; [imMsgChatVC.navigationController pushViewController:tmpController animated:YES]; } #pragma mark 点击空白部分(半VC出现时) - (void)ChatVCBgViewTap { //后期 通知要废掉 [[NSNotificationCenter defaultCenter] postNotificationName:@"imRemoveNeedUpdate" object:nil]; _imChatVCBgView.hidden = YES; self.panGestureRec.enabled = YES; for (UIViewController *one_VC in self.childViewControllers) { //chatVC 存在 if ([one_VC isKindOfClass:[BGConversationSegmentController class]]) { BGConversationSegmentController *imChat_VC = (BGConversationSegmentController *) one_VC; [UIView animateWithDuration:kHalfVCViewanimation animations:^{ imChat_VC.view.y = kScreenH; } completion:^(BOOL finished) { if (finished) { [imChat_VC.view removeFromSuperview]; [self removeChild:imChat_VC]; self.isHaveHalfIMChatVC = NO; _isKeyboardTypeNum = 0; } }]; } //聊天 退出 if ([one_VC isKindOfClass:[BGConversationServiceController class]]) { BGConversationSegmentController *imMsgChat_VC = (BGConversationSegmentController *) one_VC; [UIView animateWithDuration:kHalfVCViewanimation animations:^{ imMsgChat_VC.view.y = kScreenH; } completion:^(BOOL finished) { [imMsgChat_VC.view removeFromSuperview]; [self removeChild:imMsgChat_VC]; self.isHaveHalfIMMsgVC = NO; _isKeyboardTypeNum = 0; }]; } } } #pragma mark - ----------------------- 滑动手势 ----------------------- #pragma mark - pan手势冲突 #pragma mark移除滑动手势 ? ? ? #pragma mark pan手势冲突 - (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch { if ([touch.view isKindOfClass:[BGTLiveScrollView class]]) { return NO; } if ([touch.view isDescendantOfView:self.shopExplainView]) { return NO; } if (SUS_WINDOW.isSmallSusWindow ) { return NO; } else { return YES; } } #pragma mark移除滑动手势 - (void)removePanGestureRec { if (_panGestureRec) { [_panGestureRec removeTarget:self action:@selector(moveViewWithGesture:)]; } } #pragma mark 设置当前是否能够使用滑动手势 - (void)setPanGesture:(BOOL)isEnabled { _panGestureRec.enabled = isEnabled; } #pragma mark 滑动手势 - (void)moveViewWithGesture:(UIPanGestureRecognizer *)panGes { if (_fpkProgress) { // [FanweMessage alertHUD:ASLocalizedString(@"pk中不能滑动直播间!")]; return; } if ([GlobalVariables sharedInstance].isBeingLinkMic) { // [FanweMessage alertHUD:ASLocalizedString(@"连麦中不能滑动直播间!")]; return; } // 关闭键盘 [BGUtils closeKeyboard]; //ykk 半VC 出现 禁止滑动live—View if (self.isHaveHalfIMChatVC == YES || self.isHaveHalfIMMsgVC == YES) { panGes.enabled = NO; return; } else { panGes.enabled = YES; } if (!_isHost) { static CGFloat startX; static CGFloat lastX; static CGFloat startY; static CGFloat lastY; static CGFloat durationX; static CGFloat durationY; CGPoint touchPoint = [panGes locationInView:[[UIApplication sharedApplication] keyWindow]]; if (panGes.state == UIGestureRecognizerStateBegan) { startX = touchPoint.x; lastX = touchPoint.x; startY = touchPoint.y; lastY = touchPoint.y; } if (panGes.state == UIGestureRecognizerStateChanged) { CGFloat currentX = touchPoint.x; durationX = currentX - lastX; lastX = currentX; CGFloat currentY = touchPoint.y; durationY = currentY - lastY; lastY = currentY; NSLog(@"durationX%f",durationX); NSLog(@"durationY%f",durationY); //验证滑动手势朝左右方向大还是朝上下方向大 //朝左右方向滑动 if (fabs(durationX) > fabs(durationY)) { //如果正在上下滑动就不能左右滑动 if (self.view.frame.origin.y > 0 || CGRectGetMaxY(self.view.frame) < self.view.frame.size.height) { return; } _isLeftOrRightPan = YES; if (durationX > 0) { _isFromeLeft = YES; } else if (durationX < 0) { _isFromeLeft = NO; } if (self.liveView.frame.origin.x <= 0 && !_isFromeLeft) { return; } if (!_showingRight) { _showingRight = YES; } float x = durationX + self.liveView.frame.origin.x; NSLog(@"left right%f",x); [self.liveView setFrame:CGRectMake(x, self.liveView.frame.origin.y, self.liveView.frame.size.width, self.liveView.frame.size.height)]; } else{//朝上下方向滑动 return;; if (_fpkProgress) { // [FanweMessage alertHUD:ASLocalizedString(@"pk中不能滑动直播间!")]; return; } if (durationY>0) { _isFromeTop = YES; } else if(durationY<0) { _isFromeTop = NO; } _isLeftOrRightPan = NO; self.liveScrollView.top = durationY + self.liveScrollView.top; NSLog(@"durationY%f",self.liveScrollView.top); self.liveScrollView.isFromeTop = _isFromeTop; float scrollDuration = fabs(durationY); // self.liveScrollView.top - kScreenH); BOOL isRefresh = scrollDuration > kScreenH * BEGIN_SLIDE_RATE2; NSLog(@"%f",scrollDuration); NSLog(@"kScreenH * BEGIN_SLIDE_RATE2 %f",kScreenH * BEGIN_SLIDE_RATE2); NSLog(@"%d",isRefresh); if (self.serviceDelegate && [self.serviceDelegate respondsToSelector:@selector(protocolDidScrollView:isRefreshLive:)]) { [self.serviceDelegate protocolDidScrollView:self.liveScrollView isRefreshLive:isRefresh]; } } } else if (panGes.state == UIGestureRecognizerStateEnded) { // if (self.liveScrollView.top != 0 || self.liveScrollView.top != kScreenH || self.liveScrollView.top != kScreenH * 2) { // _isLeftOrRightPan = NO; // } if (_isLeftOrRightPan) { //朝左右方向滑动 if (_showingRight) { if (_isFromeLeft) { if (self.liveView.frame.origin.x < self.view.frame.size.width * BEGIN_SLIDE_RATE) { float durationTime = (self.liveView.frame.origin.x) / (self.view.frame.size.width) / DURING_TIME; [UIView animateWithDuration:durationTime animations:^{ [self.liveView setFrame:CGRectMake(0, self.liveView.frame.origin.y, self.liveView.frame.size.width, self.liveView.frame.size.height)]; } completion:^(BOOL finished) { self.liveView.userInteractionEnabled = YES; }]; } else { float durationTime = (1 - (self.liveView.frame.origin.x) / (self.view.frame.size.width)) / DURING_TIME; [UIView animateWithDuration:durationTime animations:^{ [self.liveView setFrame:CGRectMake(self.view.frame.size.width, self.liveView.frame.origin.y, self.liveView.frame.size.width, self.liveView.frame.size.height)]; } completion:^(BOOL finished) { [self.view sendSubviewToBack:self.liveView]; _showingRight = NO; }]; } } else { if (self.liveView.frame.origin.x < self.view.frame.size.width * (1 - BEGIN_SLIDE_RATE)) { float durationTime = (self.liveView.frame.origin.x) / (self.view.frame.size.width) / DURING_TIME; [UIView animateWithDuration:durationTime animations:^{ [self.liveView setFrame:CGRectMake(0, self.liveView.frame.origin.y, self.liveView.frame.size.width, self.liveView.frame.size.height)]; } completion:^(BOOL finished) { self.liveView.userInteractionEnabled = YES; }]; } else { float durationTime = (1 - (self.liveView.frame.origin.x) / (self.view.frame.size.width)) / DURING_TIME; [UIView animateWithDuration:durationTime animations:^{ [self.liveView setFrame:CGRectMake(self.view.frame.size.width, self.liveView.frame.origin.y, self.liveView.frame.size.width, self.liveView.frame.size.height)]; } completion:^(BOOL finished) { [self.view sendSubviewToBack:self.liveView]; _showingRight = NO; }]; } } } } else //朝上下方向滑动 { return; self.liveScrollView.isFromeTop = _isFromeTop; BOOL isRefresh = YES; self.liveScrollView.y = self.liveScrollView.isFromeTop ? 0 : kScreenH; if (self.serviceDelegate && [self.serviceDelegate respondsToSelector:@selector(protocolDidScrollView:isRefreshLive:)]) { [self.serviceDelegate protocolDidScrollView:self.liveScrollView isRefreshLive:isRefresh]; } // return; // // if (self.liveScrollView.y < kScreenH) // { // self.liveScrollView.y = self.liveScrollView.y < kScreenH * BEGIN_SLIDE_RATE2 ? 0 : kScreenH; // // if (self.serviceDelegate && [self.serviceDelegate respondsToSelector:@selector(protocolDidScrollView:isRefreshLive:)]) { // [self.serviceDelegate protocolDidScrollView:self.liveScrollView isRefreshLive:isRefresh]; // } // return; // } // if (self.liveScrollView.y < (kScreenH * 2)) { // self.liveScrollView.y = self.liveScrollView.y < kScreenH * BEGIN_SLIDE_RATE2 ? kScreenH : kScreenH * 2; // if (self.serviceDelegate && [self.serviceDelegate respondsToSelector:@selector(protocolDidScrollView:isRefreshLive:)]) { // [self.serviceDelegate protocolDidScrollView:self.liveScrollView isRefreshLive:isRefresh]; // } // return; // } // if (self.liveScrollView.y < (kScreenH * 3)) { // self.liveScrollView.y = self.liveScrollView.y < kScreenH * BEGIN_SLIDE_RATE2 ? kScreenH * 2 : kScreenH * 3; // if (self.serviceDelegate && [self.serviceDelegate respondsToSelector:@selector(protocolDidScrollView:isRefreshLive:)]) { // [self.serviceDelegate protocolDidScrollView:self.liveScrollView isRefreshLive:isRefresh]; // } // return; // } } } } } #pragma mark - scrollview的代理方法 -(void)scrollViewDidScroll:(BGTLiveScrollView *)scrollView{ if (self.serviceDelegate && [self.serviceDelegate respondsToSelector:@selector(protocolDidScrollView:isRefreshLive:)]) { [self.serviceDelegate protocolDidScrollView:self.liveScrollView isRefreshLive:NO]; } } -(BogoShopExplainView *)shopExplainView{ if (!_shopExplainView) { _shopExplainView = [kShopKitBundle loadNibNamed:@"BogoShopExplainView" owner:nil options:nil].lastObject; // _shopExplainView.delegate = self; _shopExplainView.frame = CGRectMake(kScreenW - kRealValue(12) - kRealValue(130), kScreenHeight - MG_BOTTOM_MARGIN - kRealValue(50) - kRealValue(174), kRealValue(130), kRealValue(174)); _shopExplainView.clickBuyBlock = ^(BogoCommodityDetailShopModel * _Nonnull model) { //送出 没有,没有点击事件 if (model.model_id.integerValue == 1) { [[UIApplication sharedApplication] openURL:[NSURL URLWithString:model.link_url]]; }else{ BogoGoodDetailViewController *detailVC = [[BogoGoodDetailViewController alloc]init]; detailVC.gid = model.gid; // detailVC.distribution_id = model.distribution_uid; detailVC.uid = model.uid; detailVC.source = BogoShopBuySourceLive; [self.navigationController pushViewController:detailVC animated:YES]; } // _shopExplainView.duringDragBlock = ^(WMDragView *dragView) { // _shopExplainView.frame = dragView.frame; // }; // _shopExplainView.endDragBlock = ^(WMDragView *dragView) { // // CGContextRef context = UIGraphicsGetCurrentContext(); // [UIView beginAnimations:@"rightMove" context:context]; // [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut]; // [UIView setAnimationDuration:0.5]; // // _shopExplainView.frame = dragView.frame; // // [UIView commitAnimations]; // }; }; // _shopExplainView.hidden = YES; } _shopExplainView.backgroundColor = kWhiteColor; return _shopExplainView; } - (void)showFace { NSLog(@"点击了表情"); [self.faceView show:self.view]; } - (void)showMusic { if(_musicVC == nil) { NSLog(@"点击了音乐"); _musicVC = [[choseMuiscVC alloc] init]; // _musicVC.delegate = self; [self addChild:_musicVC inRect:CGRectMake(0, 227, SCREEN_WIDTH, SCREEN_HEIGHT-227)]; } else { _musicVC.view.hidden = NO; } _musicVC.mitblock = ^(musiceModel *chosemusic) { // [self removeChild:_musicVC]; _musicVC.view.hidden = YES; }; // [choseMuiscVC showMuisChoseVCOnSuperVC:self inSuperView:self.view frame:CGRectMake(0, 227, SCREEN_WIDTH, SCREEN_HEIGHT-227) completion:^(BOOL finished) { // // }]; } - (RoomFaceView *)faceView{ if (!_faceView) { _faceView = [[RoomFaceView alloc]initWithFrame:CGRectMake(0, kScreenH, kScreenW, 320 + (IPHONE_X ? 34 : 0))]; _faceView.delegate = self; } return _faceView; } - (void)faceView:(RoomFaceView *)faceView didSelectFace:(RoomFaceModel *)model { [faceView hide]; if (self.serviceDelegate && [self.serviceDelegate respondsToSelector:@selector(protocolDidClickEmoji:)]) { [self.serviceDelegate protocolDidClickEmoji:model.img]; } // - (void)protocolDidClickEmoji:(NSString *)emoji; } //-(void)playMusicClicked:(musiceModel *)model //{ // //} // //- (void)stopMusic //{ // //} //#pragma mark - RoomFaceViewDelegate //- (void)faceView:(RoomFaceView *)faceView didSelectFace:(RoomFaceModel *)model{ // if (self.delegate && [self.delegate respondsToSelector:@selector(uicontroller:faceView:didSelectFace:)]) { // [self.delegate uicontroller:self faceView:faceView didSelectFace:model]; // } //} @end