| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656 |
- //
- // BGLivePayManager.m
- // BuguLive
- //
- // Created by 丁凯 on 2017/8/16.
- // Copyright © 2017年 xfg. All rights reserved.
- /*
- 付费直播流程
- 1主播:主播通过心跳接口判断是否加价或者提档-->进行加价或者提档-->加价或者提档成功IM发送消息给观众-->IM消息接收之后规定时间进行付费(付费成功继续观看,否则无法观看直播页面以及关闭直播声音)
- 2观众:进入直播通过get_video判断直播间是否进行收费-->收费直播就进行收费操作,且无法观看直播页面以及关闭直播声音(不需要就继续观看)
- */
- #import "BGLivePayManager.h"
- #import "LivePayLeftPromptV.h"
- @implementation BGLivePayManager
- #pragma mark =============================主播================================
- - (id)initWithLiveView:(TCShowLiveView *)liveView andRoomId:(int)roomId andhostDict:(NSDictionary *)hostDict andpayType:(NSInteger)payType
- {
- if (self = [super init])
- {
- self.roomId = roomId;
- self.httpsManager = [NetHttpsManager manager];
- self.BuguLive = [GlobalVariables sharedInstance];
- self.buttomFunctionType = payType;
- self.is_agree = NO;
- self.subLiving = liveView;
- self.hostDict = hostDict;
- self.hostLeftPView = [[LivePayLeftPromptV alloc]init];
- self.hostLeftPView.frame = CGRectMake(kDefaultMargin,CGRectGetMaxY(self.subLiving.topView.otherContainerView.frame)+kStatusBarHeight, 0, kTicketContrainerViewHeight);
- [self.subLiving addSubview:self.hostLeftPView];
- [self creatViewWithDict:self.hostDict];
- }
- return self;
- }
- #pragma mark 心跳接口判断是否付费或者提档 主播和观众同时在直播间里面开始收费的流程
- - (void)creatViewWithDict:(NSDictionary *)dict
- {
- if ([[dict objectForKey:@"live"] toInt:@"allow_mention"] == 1)
- {
- self.is_mentionType = 1;
- SUS_WINDOW.isShowMention = YES;
- [self.subLiving.bottomView addLiveFunc:self.buttomFunctionType];
- }
- else
- {
- if (self.liveType != 40)//为了防止按场付费开启后没有分享等功能(和开启按时付费开启后多一个切换付费的功能)
- {
- if ([dict toInt:@"live_pay_type"] == 0 && self.subLiving.isHost)
- {
- SUS_WINDOW.isShowLivePay = YES;
- [self.subLiving.bottomView addLiveFunc:self.buttomFunctionType];
- }
- }
- }
- }
- #pragma mark 切换付费或者提档后的代理
- - (void)creatPriceViewWithCount:(int)count
- {
- if (count == 1)//按时付费ASLocalizedString(@"1<=价格<=100")
- {
- [FanweMessage alertInput:ASLocalizedString(@"按时付费定价")message:[NSString stringWithFormat:ASLocalizedString(@"请输入价格(%@/分钟)"),self.BuguLive.appModel.diamond_name] placeholder:[NSString stringWithFormat:ASLocalizedString(@"%ld<=价格<=%ld"),(long)self.BuguLive.appModel.live_pay_min,(long)self.BuguLive.appModel.live_pay_max] keyboardType:UIKeyboardTypeNumberPad destructiveTitle:nil destructiveAction:^(NSString *text)
- {
- if ([text longLongValue] > (long)self.BuguLive.appModel.live_pay_max || [text longLongValue] < (long)self.BuguLive.appModel.live_pay_min)
- {
- [FanweMessage alert:ASLocalizedString(@"请输入正确的价格")];
- return ;
- }
- [self hostComfirmChargerWithStr:text];
- } cancelTitle:nil cancelAction:^{
-
- }];
- }else if (count == 2)//提档
- {
- [FanweMessage alert:ASLocalizedString(@"按时付费提档")message:ASLocalizedString(@"确定要提档?")destructiveAction:^{
- [self hostComfirmChargerWithStr:nil];
- } cancelAction:^{
-
- }];
- }else if (count == 3)//按场次
- {
- [FanweMessage alertInput:ASLocalizedString(@"按场付费定价")message:[NSString stringWithFormat:ASLocalizedString(@"请输入该场价格(%@/场)"),self.BuguLive.appModel.diamond_name] placeholder:[NSString stringWithFormat:ASLocalizedString(@"%ld<=价格<=%ld"),(long)self.BuguLive.appModel.live_pay_scene_min,(long)self.BuguLive.appModel.live_pay_scene_max] keyboardType:UIKeyboardTypeNumberPad destructiveTitle:nil destructiveAction:^(NSString *text)
- {
- if ([text longLongValue] > (long)self.BuguLive.appModel.live_pay_scene_max || [text longLongValue] < (long)self.BuguLive.appModel.live_pay_scene_min)
- {
- [FanweMessage alert:ASLocalizedString(@"请输入正确的价格")];
- return ;
- }
- [self hostComfirmChargerWithStr:text];
- } cancelTitle:nil cancelAction:^{
-
- }];
- }
- }
- #pragma mark 主播提档或者切换付费之后确定的接口
- - (void)hostComfirmChargerWithStr:(NSString *)textStr
- {
- NSMutableDictionary *mDict = [NSMutableDictionary dictionary];
- [mDict setObject:@"live" forKey:@"ctl"];
- [mDict setObject:@"live_pay" forKey:@"act"];
- if (self.liveType == 40)
- {
- [mDict setObject:@"1" forKey:@"live_pay_type"];
- }else
- {
- [mDict setObject:@"0" forKey:@"live_pay_type"];
- }
- [mDict setObject:[NSString stringWithFormat:@"%d",(int)self.roomId] forKey:@"room_id"];
- if (self.is_mentionType == 1)
- {
- [mDict setObject:@"1" forKey:@"is_mention"];
- }else
- {
- [mDict setObject:@"0" forKey:@"is_mention"];
- if (textStr)
- {
- [mDict setObject:textStr forKey:@"live_fee"];
- }
- }
- [self.httpsManager POSTWithParameters:mDict SuccessBlock:^(NSDictionary *responseJson)
- {
- if ([responseJson toInt:@"status"] == 1)
- {
- SUS_WINDOW.isShowLivePay = NO;
- SUS_WINDOW.isShowMention = NO;
- [self.subLiving.bottomView addLiveFunc:self.buttomFunctionType];
- if (self.liveType == 40)
- {
- [self.hostLeftPView addFirstLabWithStr:[NSString stringWithFormat:ASLocalizedString(@"该直播%d%@/场"),[responseJson toInt:@"live_fee"],self.BuguLive.appModel.diamond_name]];
- [self.hostLeftPView addSecondLabWithStr:[NSString stringWithFormat:ASLocalizedString(@"直播间付费人数:%d"),[responseJson toInt:@"live_viewer"]]];
-
-
-
- }else
- {
- self.hostTimeCount = [[responseJson toString:@"count_down"] intValue];
- if (self.hostTimeCount > 0)
- {
- self.hostTimeCount = [[responseJson toString:@"count_down"] intValue];
- [self.hostLeftPView addFirstLabWithStr:[NSString stringWithFormat:ASLocalizedString(@"%d秒后付费开始"),(int)self.hostTimeCount]];
- if (!self.hostPayLiveTime)
- {
- self.hostPayLiveTime = [NSTimer scheduledTimerWithTimeInterval:1.0 target:self selector:@selector(HostTimeGo) userInfo:nil repeats:YES];
- [[NSRunLoop currentRunLoop] addTimer:self.hostPayLiveTime forMode:NSDefaultRunLoopMode];
- }
- [self.hostLeftPView addSecondLabWithStr:[NSString stringWithFormat:ASLocalizedString(@"%d%@/分钟"),[responseJson toInt:@"live_fee"],self.BuguLive.appModel.diamond_name]];
- [self.hostLeftPView addThreeLabWithStr:[NSString stringWithFormat:ASLocalizedString(@"直播间付费人数:%d"),[responseJson toInt:@"live_viewer"]]];
- }else
- {
- [self.hostLeftPView addSecondLabWithStr:[NSString stringWithFormat:ASLocalizedString(@"%d%@/分钟"),[responseJson toInt:@"live_fee"],self.BuguLive.appModel.diamond_name]];
- [self.hostLeftPView addThreeLabWithStr:[NSString stringWithFormat:ASLocalizedString(@"直播间付费人数:%d"),[responseJson toInt:@"live_viewer"]]];
- }
-
-
- }
-
- CGRect rect = self.hostLeftPView.frame;
- rect.origin.y = CGRectGetMaxY(self.subLiving.topView.vipBtn.frame)+kStatusBarHeight;
- self.hostLeftPView.frame = rect;
- self.subLiving.livewWishView.top = rect.origin.y+rect.size.height + kDefaultMargin;
-
- __weak __typeof(self)weakSelf = self;
-
- [self.subLiving.livewWishView addObserverBlockForKeyPath:@"hidden" block:^(id _Nonnull obj, id _Nullable oldVal, id _Nullable newVal) {
- weakSelf.subLiving.livewWishView.top = rect.origin.y+rect.size.height + kDefaultMargin;
- }];
-
-
-
- }
- } FailureBlock:^(NSError *error)
- {
- NSLog(@"error===%@",error);
- }];
- }
- #pragma mark 主播付费页面显示倒计时
- - (void)HostTimeGo
- {
- self.hostTimeCount --;
- if (self.hostTimeCount == 0)
- {
- [self.hostPayLiveTime invalidate];
- self.hostPayLiveTime = nil;
- [self.hostLeftPView removeFirstLabel];
- return;
- }
- [self.hostLeftPView addFirstLabWithStr:[NSString stringWithFormat:ASLocalizedString(@"%d秒后付费开始"),(int)self.hostTimeCount]];
- }
- #pragma mark 主播异常后再次可以进入原来自己的付费直播
- - (void)hostEnterLiveAgainWithMDict:(NSDictionary *)responseJson
- {
- if ([responseJson toInt:@"live_pay_type"] == 1)//按场收费
- {
- self.liveType = 40;
- [self.hostLeftPView addFirstLabWithStr:[NSString stringWithFormat:ASLocalizedString(@"该直播%d%@/场"),[responseJson toInt:@"live_fee"],self.BuguLive.appModel.diamond_name]];
- [self.hostLeftPView addSecondLabWithStr:[NSString stringWithFormat:ASLocalizedString(@"直播间付费人数:%d"),[responseJson toInt:@"live_viewer"]]];
- }else //按时付费
- {
- self.hostTimeCount = [[responseJson toString:@"count_down"] intValue];
- if (self.hostTimeCount > 0)
- {
- self.hostTimeCount = [[responseJson toString:@"count_down"] intValue];
- [self.hostLeftPView addFirstLabWithStr:[NSString stringWithFormat:ASLocalizedString(@"%d秒后付费开始"),(int)self.hostTimeCount]];
- if (!self.hostPayLiveTime)
- {
- self.hostPayLiveTime = [NSTimer scheduledTimerWithTimeInterval:1.0 target:self selector:@selector(HostTimeGo) userInfo:nil repeats:YES];
- [[NSRunLoop currentRunLoop] addTimer:self.hostPayLiveTime forMode:NSDefaultRunLoopMode];
- }
- [self.hostLeftPView addSecondLabWithStr:[NSString stringWithFormat:ASLocalizedString(@"%d%@/分钟"),[responseJson toInt:@"live_fee"],self.BuguLive.appModel.diamond_name]];
- [self.hostLeftPView addThreeLabWithStr:[NSString stringWithFormat:ASLocalizedString(@"直播间付费人数:%d"),[responseJson toInt:@"live_viewer"]]];
- }else
- {
- [self.hostLeftPView addSecondLabWithStr:[NSString stringWithFormat:ASLocalizedString(@"%d%@/分钟"),[responseJson toInt:@"live_fee"],self.BuguLive.appModel.diamond_name]];
- [self.hostLeftPView addThreeLabWithStr:[NSString stringWithFormat:ASLocalizedString(@"直播间付费人数:%d"),[responseJson toInt:@"live_viewer"]]];
- }
- }
- }
- #pragma mark ==================================观众========================================
- - (id)initWithController:(UIViewController *)controller andLiveView:(TCShowLiveView *)liveView andRoomId:(int)roomId andAudienceDict:(NSDictionary *)audienceDict andButton:(UIButton *)closeBtn
- {
- if (self = [super init])
- {
- self.roomId = roomId;
- self.httpsManager = [NetHttpsManager manager];
- self.BuguLive = [GlobalVariables sharedInstance];
- self.closeButton = closeBtn;
- self.is_agree = NO;
- self.subLiving = liveView;
- self.livController = controller;
- self.audienceDict = audienceDict;
- self.audienceLeftPView = [[LivePayLeftPromptV alloc]init];
- self.audienceLeftPView.frame = CGRectMake(kDefaultMargin,self.subLiving.topView.vipBtn.bottom, 0, kTicketContrainerViewHeight);
- [self.subLiving addSubview:self.audienceLeftPView];
- }
- return self;
- }
- #pragma mark 观众进入直播间后是否需要付费 观众1
- - (void)creatAudienceWithDict:(NSDictionary *)dict
- {
- if (!self.payLiveTime)
- {
- self.payLiveTime = [NSTimer scheduledTimerWithTimeInterval:30.0 target:self selector:@selector(ChargeTimeGo) userInfo:nil repeats:YES];
- [[NSRunLoop currentRunLoop] addTimer:self.payLiveTime forMode:NSDefaultRunLoopMode];
- [self enterMoneyMode];//请求接口
- }
- }
- #pragma mark 按场付费直播观众在主播开启付费之后进入直播间变灰
- - (void)AudienceBecomeshadowView
- {
- self.liveType = 40;
- [self creatTwoPromptView];//切换付费
- }
- #pragma mark 观众在收费直播间IM收到收费的通知 typeTag = 40 为按场次付费
- - (void)AudienceGetVedioViewWithType:(int)typeTag
- {
- [self creatShadowView];
- self.liveType = typeTag;
- if (typeTag == 40) //按场次付费
- {
- self.shadowView.hidden = NO;
- [self enterMoneyMode];
- [self sentNotice:0];
- }else //按时间付费
- {
- [self goToCountDownTime];
- [self enterMoneyMode];
- if (!self.payLiveTime)
- {
- self.payLiveTime = [NSTimer scheduledTimerWithTimeInterval:30 target:self selector:@selector(ChargeTimeGo) userInfo:nil repeats:YES];
- [[NSRunLoop currentRunLoop] addTimer:self.payLiveTime forMode:NSDefaultRunLoopMode];
- }
- }
- }
- #pragma mark 观众倒计时方法的调用
- - (void)goToCountDownTime
- {
- self.downTimeType = 1;
- if (!self.countDownTime)
- {
- self.countDownTime = [NSTimer scheduledTimerWithTimeInterval:1.0 target:self selector:@selector(moneyCountDownTimeGo) userInfo:nil repeats:YES];
- self.timeCount = self.BuguLive.appModel.live_pay_count_down;
- [[NSRunLoop currentRunLoop] addTimer:self.countDownTime forMode:NSDefaultRunLoopMode];
- }
- }
- #pragma mark 观众倒计时
- - (void)moneyCountDownTimeGo
- {
- self.timeCount --;
- if (self.downTimeType == 1)
- {
- if (self.timeCount == 0)
- {
- [self.countDownTime invalidate];
- self.countDownTime = nil;
- [self.audienceLeftPView.threeLabel removeFromSuperview];
- if (self.is_agree)
- {
- [self enterMoneyMode];
- }else
- {
- [self closeYY];
- self.shadowView.hidden = NO;
- [self sentNotice:0];
- }
- return;
- }
- }else
- {
- if (self.timeCount == 0)
- {
- [self.countDownTime invalidate];
- self.countDownTime = nil;
-
- [self.audienceLeftPView.threeLabel removeFromSuperview];
- if (self.is_agree)
- {
- [self enterMoneyMode];
- }else
- {
- [self closeYY];
- self.shadowView.hidden = NO;
- [self sentNotice:0];
- }
- return;
- }
- }
- [self.audienceLeftPView addThreeLabWithStr:[NSString stringWithFormat:ASLocalizedString(@"%d秒后付费开始"),(int)self.timeCount]];
- }
- #pragma mark 阴影部分的创建
- - (void)creatShadowView
- {
- if (!self.shadowView)//覆盖直播间的view
- {
- self.shadowView = [[UIView alloc]initWithFrame:CGRectMake(-3*kScreenW, 0, 5*kScreenW, kScreenH)];
- self.shadowView.backgroundColor = kLightGrayColor;
- self.shadowView.hidden = YES;
- self.closeButton.hidden = NO;
- [self.livController.view addSubview:self.shadowView];
- [self.livController.view bringSubviewToFront:self.closeButton];
- }
- }
- #pragma mark 30秒循环定时器
- - (void)ChargeTimeGo
- {
- [self enterMoneyMode];
- }
- #pragma mark 观众点击确定进入收费模式
- - (void)enterMoneyMode
- {
- NSMutableDictionary *mDict = [NSMutableDictionary dictionary];
- [mDict setObject:@"live" forKey:@"ctl"];
- [mDict setObject:@"live_pay_deduct" forKey:@"act"];
- [mDict setObject:[NSString stringWithFormat:@"%d",self.is_agree] forKey:@"is_agree"];
- [mDict setObject:[NSString stringWithFormat:@"%d",(int)self.roomId] forKey:@"room_id"];
- FWWeakify(self)
- [self.httpsManager POSTWithParameters:mDict SuccessBlock:^(NSDictionary *responseJson)
- {
- FWStrongify(self)
- if ([responseJson toInt:@"status"] == 1)
- {
- self.isEnterPayLive = 1;
- [[IMAPlatform sharedInstance].host setDiamonds:[NSString stringWithFormat:@"%ld",(long)[responseJson toInt:@"diamonds"]]];
- [self.subLiving.giftView setDiamondsLabelTxt:[NSString stringWithFormat:@"%ld",(long)[responseJson toInt:@"diamonds"]]];
- self.audienceDict = responseJson;
-
- if (self.BuguLive.appModel.open_diamond_game_module == 1)
- {
- //更新游戏的余额
- [[NSNotificationCenter defaultCenter]postNotificationName:@"updateCoin" object:nil];
- }
-
- if ([responseJson toInt:@"is_live_pay"]== 1)//是否收费,1是 0 否
- {
- self.subLiving.topView.ticketNumLabel.text =[NSString stringWithFormat:@"%d",[responseJson toInt:@"ticket"]];
- [self.subLiving.topView relayoutOtherContainerViewFrame];
-
- if (self.liveType == 40)
- {
- [self.audienceLeftPView addFirstLabWithStr:[NSString stringWithFormat:ASLocalizedString(@"该直播%d%@/场"),[responseJson toInt:@"live_fee"],self.BuguLive.appModel.diamond_name]];
- if (self.is_agree == 0)
- {
- [self creatTwoPromptView];
- }else
- {
- [self getAudienceStateWithDict:self.audienceDict];
- }
- }else
- {
- [self creatAudienceWithDict:self.audienceDict];
- [self.audienceLeftPView addFirstLabWithStr:[NSString stringWithFormat:ASLocalizedString(@"%d%@/分钟"),[responseJson toInt:@"live_fee"],self.BuguLive.appModel.diamond_name]];
- [self.audienceLeftPView addSecondLabWithStr:[NSString stringWithFormat:ASLocalizedString(@"已观看:%d分钟"),[responseJson toInt:@"total_time"]/60]];
- if ([responseJson toInt:@"count_down"])
- {
- self.timeCount = [responseJson toInt:@"count_down"];
- [self.audienceLeftPView addThreeLabWithStr:[NSString stringWithFormat:ASLocalizedString(@"%d秒后付费开始"),[responseJson toInt:@"count_down"]]];
- if (!self.countDownTime)
- {
- self.countDownTime = [NSTimer scheduledTimerWithTimeInterval:1.0 target:self selector:@selector(moneyCountDownTimeGo) userInfo:nil repeats:YES];
- [[NSRunLoop currentRunLoop] addTimer:self.countDownTime forMode:NSDefaultRunLoopMode];
- }
- }
- if (self.is_agree == 1)//是否同意,1同意 0不同意
- {
- [self getAudienceStateWithDict:self.audienceDict];
- }else
- {
- if ([responseJson toInt:@"on_live_pay"] == 1)//是否收费中 1是 0否
- {
- self.shadowView.hidden = NO;
- // [self sentNotice:0];
- }
- [self creatTwoPromptView];
- }
- }
- }else
- {
- NSLog(@"not need to do");
- }
- }
- } FailureBlock:^(NSError *error)
- {
- NSLog(@"error===%@",error);
- }];
- }
- #pragma mark 判断观众现在的状态,钱为0,钱不够5分钟,钱足够 观众3
- - (void)getAudienceStateWithDict:(NSDictionary *)dict
- {
- if ([dict toInt:@"is_diamonds_low"] == 1 && [dict toInt:@"is_recharge"] == 0)//余额很少
- {
- [BGUtils closeKeyboard]; // 关闭键盘
- if (self.payDelegate)//加载直播间视频的代理
- {
- if ([self.payDelegate respondsToSelector:@selector(livePayLoadVedioIsComfirm:)])
- {
- [self.payDelegate livePayLoadVedioIsComfirm:YES];
- }
- }
- FWWeakify(self)
- if (!self.myAlertView2)
- {
- self.myAlertView2 = [FanweMessage alert:ASLocalizedString(@"温馨提示")message:[NSString stringWithFormat:ASLocalizedString(@"账户余额:%d%@"),[dict toInt:@"diamonds"],self.BuguLive.appModel.diamond_name] destructiveAction:^{
- FWStrongify(self)
- self.block(@"1");
- [self.myAlertView2 removeFromSuperview];
- self.myAlertView2 = nil;
- } cancelAction:^{
- [self.myAlertView2 removeFromSuperview];
- self.myAlertView2 = nil;
- }];
- }
-
- if (self.shadowView)
- {
- [self.shadowView removeFromSuperview];
- self.shadowView = nil;
- }
- [self sentNotice:1];
- }else if ([dict toInt:@"is_diamonds_low"] == 1 && [dict toInt:@"is_recharge"] == 1)//余额为不足
- {
- // 关闭键盘
- [BGUtils closeKeyboard];
-
- [self creatShadowView];//没钱就要加上阴影
- if (self.timeCount < 1)
- {
- [self closeYY];
- self.shadowView.hidden = NO;
- }
-
- FWWeakify(self)
- if (!self.myAlertView3)
- {
- self.myAlertView3 = [FanweMessage alert:ASLocalizedString(@"温馨提示")message:[NSString stringWithFormat:ASLocalizedString(@"账户余额:%d%@"),[dict toInt:@"diamonds"],self.BuguLive.appModel.diamond_name] destructiveAction:^{
- FWStrongify(self)
- self.block(@"1");
- [self.myAlertView3 removeFromSuperview];
- self.myAlertView3 = nil;
- } cancelAction:^{
- FWStrongify(self)
- if (self.payDelegate)//加载或者不加载直播间视频的代理
- {
- if ([self.payDelegate respondsToSelector:@selector(livePayLoadVedioIsComfirm:)])
- {
- [self.payDelegate livePayLoadVedioIsComfirm:NO];
- }
- }
- [self.myAlertView3 removeFromSuperview];
- self.myAlertView3 = nil;
- }];
- }
- [self sentNotice:0];
-
- }else
- {
- if (self.payDelegate)//加载直播间视频的代理
- {
- if ([self.payDelegate respondsToSelector:@selector(livePayLoadVedioIsComfirm:)])
- {
- [self.payDelegate livePayLoadVedioIsComfirm:YES];
- }
- }
- if (self.shadowView)
- {
- [self.shadowView removeFromSuperview];
- self.shadowView = nil;
- }
- [self sentNotice:1];
- }
- }
- #pragma mark 创建TwoPromptView
- - (void)creatTwoPromptView
- {
- if (!self.myAlertView1)
- {
- NSString *promptStr;
- if (self.liveType == 40)
- {
- promptStr = [NSString stringWithFormat:ASLocalizedString(@"主播开启了付费直播,%d%@/场,是否进入?"),[self.audienceDict toInt:@"live_fee"],self.BuguLive.appModel.diamond_name];
- }else
- {
- promptStr = [NSString stringWithFormat:ASLocalizedString(@"主播开启了付费直播,%d%@/分钟,是否进入?"),[self.audienceDict toInt:@"live_fee"],self.BuguLive.appModel.diamond_name];
- }
- self.myAlertView1 = [FanweMessage alert:ASLocalizedString(@"付费直播")message:promptStr destructiveAction:^{
- self.is_agree = YES;
- [self enterMoneyMode];
- [self.myAlertView1 removeFromSuperview];
- self.myAlertView1 = nil;
- } cancelAction:^{
- [self.myAlertView1 removeFromSuperview];
- self.myAlertView1 = nil;
- if (self.payDelegate)//加载或者不加载直播间视频的代理
- {
- if ([self.payDelegate respondsToSelector:@selector(livePayLoadVedioIsComfirm:)])
- {
- [self.payDelegate livePayLoadVedioIsComfirm:NO];
- }
- }
- }];
- }
- }
- #pragma mark 发送通知来关闭云直播间的声音
- - (void)sentNotice:(int)type
- {
- NSMutableDictionary *dict = [[NSMutableDictionary alloc]init];
- [dict setObject:[NSString stringWithFormat:@"%d",type] forKey:@"type"];
- [[NSNotificationCenter defaultCenter]postNotificationName:@"closeAndOpenVoice" object:dict];
- }
- #pragma mark 观众直播间有连麦,付费直播后不能看直播就关闭连麦
- - (void)closeYY
- {
- NSString *controlRole;
- if (![BGUtils isBlankString:_BuguLive.appModel.spear_normal])
- {
- controlRole = self.BuguLive.appModel.spear_normal;
- }
- else
- {
- controlRole = @"NormalGuest";
- }
- }
- #pragma mark ===========共用==================
- - (void)changeLeftViewFrameWithIsHost:(BOOL)isHost andAuctionView:(UIView *)auctionView andBankerView:(UIView *)bankerView
- {
- if (isHost == YES)//是主播
- {
- if (bankerView.hidden)
- {
- if (auctionView.hidden)
- {
- CGRect rect = self.hostLeftPView.frame;
- rect.origin.y = CGRectGetMaxY(self.subLiving.topView.vipBtn.frame)+kStatusBarHeight;
- self.hostLeftPView.frame = rect;
- self.subLiving.livewWishView.top = rect.origin.y+rect.size.height;
- }
- else
- {
- CGRect rect = self.hostLeftPView.frame;
- rect.origin.y = CGRectGetMaxY(self.subLiving.topView.vipBtn.frame)+auctionView.height+8+kStatusBarHeight;
- self.hostLeftPView.frame = rect;
- }
- self.hostLeftPView.right = kDefaultMargin;
- }
- else
- {
- if (auctionView.hidden)
- {
- CGRect rect = self.hostLeftPView.frame;
- rect.origin.y = CGRectGetMaxY(self.subLiving.topView.vipBtn.frame)+bankerView.height+8+kStatusBarHeight;
- // self.subLiving.livewWishView.top = rect.origin.y+rect.size.height;
-
- }
- else
- {
- CGRect rect = self.hostLeftPView.frame;
- rect.origin.y = CGRectGetMaxY(self.subLiving.topView.vipBtn.frame)+bankerView.height+auctionView.height+8+8+kStatusBarHeight;
- self.hostLeftPView.frame = rect;
- }
- }
- }else//是观众
- {
- if (bankerView.hidden)
- {
- if (auctionView.hidden)
- {
- CGRect rect = self.audienceLeftPView.frame;
- rect.origin.y = CGRectGetMaxY(self.subLiving.topView.vipBtn.frame)+kStatusBarHeight;
- self.audienceLeftPView.frame = rect;
- }
- else
- {
- CGRect rect = self.audienceLeftPView.frame;
- rect.origin.y = CGRectGetMaxY(self.subLiving.topView.vipBtn.frame)+auctionView.height+8+kStatusBarHeight;
- self.audienceLeftPView.frame = rect;
- }
- }
- else
- {
- if (auctionView.hidden)
- {
- CGRect rect = self.audienceLeftPView.frame;
- rect.origin.y = CGRectGetMaxY(self.subLiving.topView.otherContainerView.frame)+bankerView.height+8+kStatusBarHeight;
- self.audienceLeftPView.frame = rect;
- }
- else
- {
- CGRect rect = self.audienceLeftPView.frame;
- rect.origin.y = CGRectGetMaxY(self.subLiving.topView.otherContainerView.frame)+bankerView.height+auctionView.height+8+8+kStatusBarHeight;
- self.audienceLeftPView.frame = rect;
- }
- }
- }
- // self.hostLeftPView.right = kScreenW - kDefaultMargin;
- // self.audienceLeftPView.left = kScreenW / 2 - kRealValue(15);
- }
- @end
|