Files
mier_ios/SweetParty/主类/RCMic/Room/RCMicRoomViewController.m

3161 lines
125 KiB
Mathematica
Raw Normal View History

2025-08-11 10:43:19 +08:00
//
// RCMicRoomViewController.m
// SealMic
//
// Created by lichenfeng on 2020/5/26.
// Copyright © 2020 rongcloud. All rights reserved.
//
#import "RCMicRoomViewController.h"
#import "RCMicRoomNavigationView.h"
#import "RCMicUtil.h"
#import "RCMicMacro.h"
#import "RCMicParticipantsArea.h"
#import "RCMicChatView.h"
#import "RCMicInputBar.h"
#import "RCMicRoomToolBar.h"
#import "RCMicBlinkExcelView.h"
#import "RCMicActiveWheel.h"
#import "BJMicRoomOperationAlert.h"
#import "BJRoomGiftAlert.h"
#import "BJRoomGiftModel.h"
#import "BJRoomBaomaiAlert.h"
#import "BJRoomBaomaiModel.h"
#import "BJRoomSetAdminiCtrl.h"
#import "BJRoomEmojiAlert.h"
#import "BJFlyWordManager.h"
#import "BJFloatRoomManager.h"
#import "RoomBotMoreView.h"
#import <HWPopController/HWPop.h>
#import "MH_ZhuanZengView.h"
#import "WebSocketManager.h"
//
#import "RoomPublicSelectView.h"
#import "BJRoomSetChaoguanCtrl.h"
#import "KNActionSheet.h"
#import "RoomNoticeAlertView.h"
#import "AmPKVC.h"
#import "PklineView.h"
#import "SPRoomPeopleAlert.h"
#import "SPRoomTop3View.h"
#import "TXMessageVC.h"
#import "YYRoomSettingVC.h"
#import "YYRoomRankVC.h"
#import "YYJYApplyUpView.h"
#import "YYRoomCPRankView.h"
#import "YYKTVChujiaInfoView.h"
#import "YYKTVCenterView.h"
#import "RoomSongSettingView.h"
#import "RoomSongView.h"
#import "UIButton+BAKit.h"
#import "YYRoomInviteAlert.h"
#import "YYQianyueSelfAlert.h"
#import "YYQianyueSuccessAlert.h"
#import "YYJYRelationView.h"
#import "YYJYSimiRoomView.h"
#import "YYJYPendantGiftView.h"
#import "UIView+VAP.h"
#import "QGVAPWrapView.h"
#import "QGVAPWrapView+download.h"
#import "RoomMusicView.h"
#import "YYPMSelfAlert.h"
#import "YYPMSuccessAlert.h"
#import "YYRoomChujiaAlert.h"
#import "YYKTVTipsAlert.h"
#import "YYXinrenTop3View.h"
#import "YYPMPickRelationView.h"
#import "SweetParty-Bridging-Header.h"
#import "Yinyue-Swift.h"
#import "GiftTableView.h"
#import "SEARoomHeadlineShowView.h"
#import "SEARoomHeadlinesPublishView.h"
#import <IQKeyboardManager/IQKeyboardManager.h>
#import "LMLoveSkyWheelViewController.h"
#import "LMCPInRoomVapView.h"
#import "RCMicRoomViewController+Game.h"
#import "YYRoomGamePickView.h"
#import "YYXQInviteAlert.h"
#import "LMRoomBlackListViewController.h"
#import "BlindXunlehuiShowView.h"
#import "ZWTimer.h"
#define InputBarHeight 50
#define ToolBarHeight 40
#define ResponseWaiting 15
@interface RCMicRoomViewController ()<RCMicRoomNavigationViewDelegate, RCMicRoomToolBarDelegate, RCMicParticipantsAreaDelegate, RCMicInputBarControlDelegate, RCMicChatViewDelegate, UIGestureRecognizerDelegate, BJMicRoomOperationAlertDelegate, HWDMP4PlayDelegate, VAPWrapViewDelegate, AgoraLrcViewDelegate, AgoraLogDelegate, AgoraLrcDownloadDelegate,ZWTimerDelegate>
@property (nonatomic, strong) RCMicRoomViewModel *viewModel;
@property (nonatomic, strong) UIImageView *backgroundView;
@property (nonatomic, strong) UITapGestureRecognizer *tapGesture;
@property (nonatomic, strong) RCMicRoomNavigationView *customNavigationView;//
@property (nonatomic, strong) RCMicRoomToolBar *customToolBar;//
@property (nonatomic, strong) RoomPublicSelectView *publicSelectView;//
@property (nonatomic, strong) RCMicParticipantsArea *participantsArea;//
@property (nonatomic, strong) RCMicChatView *chatView;//
@property (nonatomic, strong) RCMicInputBar *inputBar;//
@property (nonatomic, strong) RCMicBlinkExcelView *blinkExcelView;//debug
@property (nonatomic, strong) PklineView *pkView;
@property (nonatomic, strong) UIButton *stopPkBtn;
@property (nonatomic, strong) SPRoomTop3View *top3View;
@property (nonatomic, strong) UIButton *rankBtn;
@property (nonatomic, strong) UIImageView *meiliImgView;
@property (nonatomic, strong) UIButton *room_noticeBtn;
@property (nonatomic, strong) UIButton *descBtn; //
@property (nonatomic, strong) NSIndexPath *currentBgSoundIndexPath;//
@property (nonatomic, strong) NSTimer *wheelDismissTimer;//
@property (nonatomic, assign) BOOL joinRoomSuccess;//
@property (nonatomic, assign) BOOL kvSyncSuccess;// IM KV
@property (nonatomic, strong) BJMicRoomOperationAlert *operationAlert; //
@property (nonatomic, strong) BJRoomGiftAlert *roomGiftView; //
@property (nonatomic, strong) BJRoomBaomaiAlert *userAlert; //
@property (nonatomic, strong) BJRoomEmojiAlert *emojiAlert; //
//@property(nonatomic, strong) RoomBotMoreView *botMoreView;//
@property (nonatomic, assign) BOOL isTotalQuitRoom;
@property (nonatomic,strong) YYRoomRankVC *bangdanVC;
@property (nonatomic,strong) UIView *bangdanBgView;
@property (nonatomic, strong) UIButton *applyUpBtn;
@property (nonatomic, strong) UILabel *applyUpNumLab;
@property (nonatomic, strong) YYJYApplyUpView *jyApplyUpV;
@property (nonatomic, strong) YYXinrenTop3View *xrTop3View;
@property (nonatomic, strong) YYJYRelationView *jyRelationV;
@property (nonatomic, strong) YYJYSimiRoomView *simiRoomV;
@property (nonatomic, strong) YYJYPendantGiftView *pendantGiftV;
@property (nonatomic, strong) BlindXunlehuiShowView *blindShowV;
@property (nonatomic, strong) QGVAPWrapView *jySimiVapView;
@property (nonatomic, assign) NSInteger leftSecond;
@property (nonatomic, strong) ZWTimer *timer;
@property (nonatomic, strong) UIButton *ktvStartBtn;
@property (nonatomic, strong) UIButton *ktvNextBtn;
@property (nonatomic, strong) UIButton *ktvDiangeBtn;
@property (nonatomic, strong) YYKTVChujiaInfoView *ktvChujiaInfoV;
@property (nonatomic, strong) YYKTVCenterView *ktvCenterV;
@property (nonatomic, strong) UIButton *ktvTiaoyinBtn;
@property (nonatomic, strong) RoomSongView *songListV;
@property (nonatomic, strong) RoomSongSettingView *songSettingV;
@property (nonatomic, strong) AgoraLrcScoreView *lrcView;
//ID
@property (nonatomic, copy) NSString *ktvCurrentUid;
@property (nonatomic, copy) NSString *ktvZhizuoUid;
@property(nonatomic, assign) CGFloat startX;
@property(nonatomic, assign) BOOL bMove;
@property (nonatomic, strong) RoomMusicView *musicView;
//ID
@property (nonatomic, copy) NSString *siliaoId;
@property (nonatomic, strong) GiftTableView *lianjiView;
@property (nonatomic, strong) QGVAPWrapView *luckyVapView;
@property (nonatomic, strong) SEARoomHeadlineShowView *headlineShowView;
@property (nonatomic, strong) ZWTimer *GBTimer;
@property (nonatomic, assign) NSInteger endTime;
@property (nonatomic, strong) LMCPInRoomVapView *cpvapView;
/// view
@property (nonatomic, strong) UIView *gameView;
/// SudMGP SDK
@property (nonatomic, strong) SudMGPLoadConfigModel *sudMGPLoadConfigModel;
@property (nonatomic, strong) YYRoomGamePickView *gamePickView;
@end
@implementation RCMicRoomViewController
#pragma mark - Life cycle
- (instancetype)initWithRoomInfo:(id)roomInfo Role:(RCMicRoleType)role {
self = [super init];
if (self) {
_joinRoomSuccess = NO;
_kvSyncSuccess = NO;
//
// [self checkCalculatorStatusWithModelInfo:roomInfo Role:role];
[self initViewModelWithRoomInfo:roomInfo role:role];
}
return self;
}
//
//- (void)checkCalculatorStatusWithModelInfo:(id)roomInfo Role:(RCMicRoleType)role {
// [RCMicHTTP postWithURLString:@"/api/api/calculator" parameters:@{} response:^(RCMicHTTPResult *result) {
// [SVProgressHUD dismiss];
// if (result.success) {
// if (result.errorCode == 200 && [result.content isKindOfClass:NSDictionary.class]) {
// NSString *is_calculator = [result.content safeStringForKey:@"is_calculator"];
// GVUSER.is_calculator = is_calculator;
// }else{
// GVUSER.is_calculator = @"0";
// }
// [self initViewModelWithRoomInfo:roomInfo role:role];
// [self addSubviews];
// [self addConstraints];
// [self joinMicRoom];
// }else {
// GVUSER.is_calculator = @"0";
// [self initViewModelWithRoomInfo:roomInfo role:role];
// [self addSubviews];
// [self addConstraints];
// [self joinMicRoom];
// }
// }];
//}
- (void)viewDidLoad {
[super viewDidLoad];
[UIApplication sharedApplication].idleTimerDisabled = YES;
[self addSubviews];
[self addConstraints];
[self joinMicRoom];
//退
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(kickedOffLineAction) name:TXIMDinghaoNoti object:nil];
[NSNotificationCenter.defaultCenter addObserver:self selector:@selector(bjkeyboardDidHide) name:UIKeyboardWillHideNotification object:nil];
[NSNotificationCenter.defaultCenter addObserver:self selector:@selector(onUpdateMsgDot) name:TXIMUnreadMessageNoti object:nil];
//312
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(BlindStartAction:) name:@"BlindxunlehuiStart" object:nil];
//313
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(BlindUpdateTime:) name:@"BlindxunlehuiGetLockGift" object:nil];
//316
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(BlindEndAction) name:@"BlindxunlehuiEnd" object:nil];
[self onCreateXinrenViews];
[self onJuageJiaoyouRoom];
[self onCreatePaimaiViews];
[self onCreateKTVViews];
[self onRequestCurrentLaba];
[self onSudJuageGameRoom];
[self onJuageXiangqinRoomView];
[self onJuageXiangqinJiubaRoom];
//
if (self.viewModel.roomInfo.is_Game != 1) {
id traget = self.navigationController.interactivePopGestureRecognizer.delegate;
UIPanGestureRecognizer * pan = [[UIPanGestureRecognizer alloc]initWithTarget:traget action:nil];
[self.view addGestureRecognizer:pan];
}
}
- (void)kickedOffLineAction {
// [self doThingsBeforeQuitRoom];
self.isTotalQuitRoom = YES;
[self backAction];
}
- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
_isTotalQuitRoom = NO;
[self onUpdateMsgDot];
//mp4
[self.pendantGiftV onPlayGiftVap];
IQKeyboardManager *manager = IQKeyboardManager.sharedManager;
manager.enable = YES;
}
-(void)onUpdateMsgDot {
[self.customToolBar updateUnreadDot];
}
- (void)viewDidAppear:(BOOL)animated {
[super viewDidAppear:animated];
if (@available(iOS 13.0, *)) {
[UIApplication sharedApplication].statusBarStyle = UIStatusBarStyleLightContent;
}else {
[UIApplication sharedApplication].statusBarStyle = UIStatusBarStyleLightContent;
}
//
if (self.viewModel.roomInfo.is_dating == 1) {
self.participantsArea.userInteractionEnabled = NO;
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
self.participantsArea.userInteractionEnabled = YES;
});
}
}
- (void)viewWillDisappear:(BOOL)animated {
[super viewWillDisappear:animated];
if (@available(iOS 13.0, *)) {
[UIApplication sharedApplication].statusBarStyle = UIStatusBarStyleDarkContent;
}else {
[UIApplication sharedApplication].statusBarStyle = UIStatusBarStyleDefault;
}
}
- (void)viewDidDisappear:(BOOL)animated {
[super viewDidDisappear:animated];
BOOL havePop = YES;
for (UIViewController *vc in self.navigationController.viewControllers) {
if ([vc isKindOfClass:RCMicRoomViewController.class]) {
havePop = NO;
break;
}
}
if (havePop) {
if(_isTotalQuitRoom) {
[self doThingsBeforeQuitRoom];
[BJFloatRoomManager.sharedBJFloatRoomManager closeFloatWindow];
}else {
//
[BJFloatRoomManager.sharedBJFloatRoomManager showFloatWindowWithModel:_viewModel WithRoomCtrl:self];
}
}
}
- (void)doThingsBeforeQuitRoom {
//
// [[RCMicRTCService sharedService] stopMixingMusic];
[BJSvgaManager.sharedBJSvgaManager stopAllSvga];
[WebSocketManager.shared webSocketClose];
[[BJAgoraRtmManager shared] logoutAndLeaveChannel];
[BJFlyWordManager.sharedBJFlyWordManager stopAllFlyWord];
//退
[_viewModel quitMicRoom:^{
RCMicLog(@"quit mic room success!");
} error:^{
RCMicLog(@"quit mic room error!");
//
}];
}
- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{
// NSLog(@"开始了");
UITouch *touch = [touches anyObject];
CGPoint pointone = [touch locationInView:self.view];//
//
_startX = pointone.x;
NSLog(@"触摸点的坐标:%f",_startX);
}
- (void)touchesMoved:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{
UITouch *touch = [touches anyObject];
//imgViewTopView
CGPoint pointtwo = [touch locationInView:self.view]; //
NSLog(@"移动点的坐标:%f,%f",pointtwo.x,_startX);
int position = (pointtwo.x-_startX);
NSLog(@"position is %d",position);
if(fabs(pointtwo.x-_startX)>100)
{ //
NSLog(@"移动了");
_bMove = YES;
//100
// [UIViewController goRankPageWithRid:self.viewModel.roomInfo.roomId];
}
}
- (void)touchesEnded:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{
UITouch *touch = [touches anyObject];
CGPoint pointtwo = [touch locationInView:self.view]; //
if((fabs(pointtwo.x-_startX)>100)&&(_bMove))
{
//
if(pointtwo.x-_startX>0)
{ //
NSLog(@"左向右移动");
}
//
else
{ //
NSLog(@"右移动");
//100
[UIViewController goRankPageWithRid:self.viewModel.roomInfo.roomId];
}
}
}
- (void)dealloc {
[UIApplication sharedApplication].idleTimerDisabled = NO;
//
[_viewModel descory];
[[NSNotificationCenter defaultCenter] removeObserver:self];
NSLog(@"销毁%@", NSStringFromClass(self.class));
}
#pragma mark - Private method
- (void)initViewModelWithRoomInfo:(RCMicRoomInfo *)roomInfo role:(RCMicRoleType)role {
//cate_id 26 27K 28 29 19 36-37
if ([roomInfo.cate_id integerValue] == 26) {
roomInfo.is_xinren = 1;
}else if ([roomInfo.cate_id integerValue] == 27) {
roomInfo.is_song = 1;
}else if ([roomInfo.cate_id integerValue] == 28) {
roomInfo.is_paimai = 1;
}else if ([roomInfo.cate_id integerValue] == 29) {
roomInfo.is_dating = 1;
}else if ([roomInfo.cate_id integerValue] == 35) {
roomInfo.is_Game = 1;
}else if ([roomInfo.cate_id integerValue] == 36 || [roomInfo.cate_id integerValue] == 37) {
roomInfo.is_xiangqin = 1;
}else if ([roomInfo.cate_id integerValue] == 19) {
roomInfo.is_blind_date = 1;
}
__weak typeof(self) weakSelf = self;
_yb_rid = roomInfo.roomId;
_viewModel = [[RCMicRoomViewModel alloc] initWithRoomInfo:roomInfo role:role];
// KV
[_viewModel setKvSyncCompleted:^{
weakSelf.kvSyncSuccess = YES;
[weakSelf checkRoomStatus];
}];
//
[_viewModel setMessageChanged:^(RCMicMessageChangedType type, NSArray * _Nonnull indexs) {
[weakSelf.chatView updateTableViewWithType:type indexs:indexs];
}];
//
[_viewModel setParticipantChanged:^(NSArray<NSString *> * _Nonnull keys) {
[weakSelf.participantsArea updateCollectionViewWithKeys:keys];
}];
//
[_viewModel setGuangquanChanged:^(NSArray<NSString *> * _Nonnull keys) {
[weakSelf.participantsArea updateGuangquanWithKeys:keys];
}];
//
[_viewModel setDidHoldOrGiveUpMic:^(RCMicRoleType role) {
// toolbar
// RCMicRoleType role = isHold ? RCMicRoleType_Participant : RCMicRoleType_Audience;
BOOL haveAuth = weakSelf.viewModel.isRoomOwner || weakSelf.viewModel.isRoomAdministrator;
[weakSelf.customToolBar updateWithRoleType:role auth:haveAuth];
// RTC
RCMicSpeakerState speakerState = weakSelf.viewModel.useSpeaker ? RCMicSpeakerStateOpen : RCMicSpeakerStateClose;
[weakSelf setSpeakerState:speakerState];
if (role==RCMicRoleType_Host || role==RCMicRoleType_Participant) {
// RTC RTC
// RCMicMicrophoneState micState = weakSelf.viewModel.useMicrophone ? RCMicMicrophoneStateNormal : RCMicMicrophoneStateSilent;
//
RCMicMicrophoneState micState = RCMicMicrophoneStateSilent;
[weakSelf setMicrophoneState:micState];
//
if (weakSelf.viewModel.roomInfo.is_paimai == 1) {
[weakSelf onPMAutoChooseAlert];
}
} else {
//
weakSelf.currentBgSoundIndexPath = [NSIndexPath indexPathForRow:0 inSection:0];
// [[RCMicRTCService sharedService] stopMixingMusic];
}
}];
//
[_viewModel setDelayInfoChanged:^(NSInteger delay) {
[weakSelf.customNavigationView updateDelay:delay];
}];
//debug
[_viewModel setDebugInfoChanged:^(NSArray * _Nonnull array) {
weakSelf.blinkExcelView.array = array;
}];
//线
[_viewModel setOnlineCountChanged:^(NSInteger onlineCount) {
[weakSelf.customNavigationView updateOnlineCount:onlineCount];
}];
//
[_viewModel setWaitingStateChanged:^(BOOL waiting) {
[weakSelf.customNavigationView showTipLabel:waiting];
}];
//
[_viewModel setReceivedSvgaGift:^(NSString * _Nonnull svgaUrl, NSDictionary * _Nonnull cpDict) {
//
dispatch_async(dispatch_get_main_queue(), ^{
if (!GVUSER.closeGiftEffect) {
[BJSvgaManager.sharedBJSvgaManager showSvgaUrl:svgaUrl onView:weakSelf.view cpDict:cpDict];
}
});
}];
//
[_viewModel setReceivedNormGift:^(NSString * _Nonnull uid, NSString * _Nonnull imgUrl) {
RCMicMainThread(^{
[weakSelf showNorGiftPathAnimate:imgUrl uid:uid];
})
}];
//
[_viewModel setMicroPhoneStateChanged:^(BOOL enable) {
RCMicMicrophoneState state = enable ? RCMicMicrophoneStateNormal : RCMicMicrophoneStateSilent;
[weakSelf setMicrophoneState:state];
}];
//
[_viewModel setTakeOverHostResponse:^(NSString * _Nonnull name, NSString * _Nonnull userId, BOOL result) {
[weakSelf stopActiveWheelWithResponse:result isTimeout:NO];
}];
//
[_viewModel setHostTransferResponse:^(NSString * _Nonnull name, NSString * _Nonnull userId, BOOL result) {
[weakSelf stopActiveWheelWithResponse:result isTimeout:NO];
}];
//
[_viewModel setShowTipWithErrorInfo:^(NSString * _Nonnull description) {
[RCMicActiveWheel showPromptHUDAddedTo:RCMicKeyWindow text:description];
}];
//
[_viewModel setBj_kickRoomBlock:^{
RCMicMainThread(^{
[weakSelf backAction];
[BJFloatRoomManager.sharedBJFloatRoomManager closeFloatWindow];
weakSelf.isTotalQuitRoom = YES;
[SVProgressHUD showInfoWithStatus:@"您已被踢出房间"];
})
}];
//
[_viewModel setBj_adminChangeBlock:^{
RCMicMainThread(^{
BOOL haveAuth = weakSelf.viewModel.isRoomOwner || weakSelf.viewModel.isRoomAdministrator;
weakSelf.meiliImgView.hidden = !haveAuth;
[weakSelf.customToolBar updateWithRoleType:weakSelf.viewModel.role auth:haveAuth];
})
}];
//
_viewModel.bj_roomNameChangeBLock = ^(NSString * _Nonnull room_name) {
RCMicMainThread(^{
[weakSelf.customNavigationView updateRoomName:room_name];
})
};
//
_viewModel.bj_roomBGChangeBlock = ^(NSString * _Nonnull room_bg) {
RCMicMainThread(^{
[weakSelf.backgroundView sd_setImageWithURL:[NSURL URLWithString:room_bg]];
})
};
//
[_viewModel setBj_emojiBlock:^(NSDictionary * _Nonnull eInfo) {
RCMicMainThread(^{
[weakSelf.participantsArea bj_showEmojiWith:eInfo];
})
}];
//退
[_viewModel setBj_lockRoomBlock:^{
weakSelf.isTotalQuitRoom = YES;
[weakSelf backAction];
}];
//
[_viewModel setXr_receiveInviteBlock:^(NSDictionary * _Nonnull dict) {
YYRoomInviteAlert *view = LoadNib(@"YYRoomInviteAlert");
view.frame = [UIScreen mainScreen].bounds;
view.rid = [dict safeStringForKey:@"rid"];
view.micro_id = [dict safeStringForKey:@"micro_id"];
[MainWindow() addSubview:view];
}];
//
[_viewModel setXr_updateStatusBlock:^(NSDictionary * _Nonnull dict) {
[weakSelf.participantsArea onUpdateXinrenUIWith:dict];
//room_new_auction_status 1 2
NSInteger status = [dict safeIntForKey:@"room_new_auction_status"];
if (status == 2) {
weakSelf.xrTop3View.hidden = YES;
}
}];
[_viewModel setXr_updateRankBlock:^(NSDictionary * _Nonnull dict) {
NSArray *arr = [YYXinrenTop3Model mj_objectArrayWithKeyValuesArray:dict[@"list"]];
weakSelf.xrTop3View.dataArray = arr;
}];
[_viewModel setXr_qianyueResultBlock:^(NSDictionary * _Nonnull dict) {
[weakSelf onXRQianyueResult:dict];
}];
// //PK
// [self onFetchPKDataWithAlert:NO];
// //PKsocket
// [_viewModel setBj_PKSocketBlock:^(NSDictionary * _Nonnull dataDict) {
// [weakSelf onReceivePKSocket:dataDict];
// }];
_viewModel.ktv_UpdateYidianBlock = ^(NSArray * _Nonnull arr, BOOL showTiaoyin) {
[weakSelf.songListV onUpdateYiDian:arr];
};
[_viewModel setKtv_applyUpMicBlock:^(NSDictionary * _Nonnull dict) {
[weakSelf.jyApplyUpV onReceiveSocketWith:dict];
NSInteger count = [dict safeIntForKey:@"priority_count"]+[dict safeIntForKey:@"common_count"];
if (count > 0) {
weakSelf.applyUpNumLab.hidden = NO;
NSString *numStr = [NSString stringWithFormat:@"%ld", count];
weakSelf.applyUpNumLab.text = numStr;
}else {
weakSelf.applyUpNumLab.hidden = YES;
}
}];
[_viewModel setKtv_UpdatePlayBtnStatusBlock:^(BOOL isPlay) {
weakSelf.songSettingV.playBtn.selected = isPlay;
}];
[_viewModel setKtv_updateStatusBlock:^(NSDictionary * _Nonnull dict) {
[weakSelf onUpdateKTVStatusWith:dict];
}];
[_viewModel setKtv_zhizuorenTipsBlock:^(NSDictionary * _Nonnull dict) {
YYKTVTipsAlert *view = LoadNib(@"YYKTVTipsAlert");
view.frame = [UIScreen mainScreen].bounds;
[MainWindow() addSubview:view];
view.rid = [dict safeStringForKey:@"rid"];
}];
[_viewModel setKtv_loadLyricBlock:^(NSString * _Nonnull lyricUrl, BOOL isQingchang) {
[weakSelf.lrcView setLrcUrlWithUrl:lyricUrl];
}];
//
[_viewModel setJiao_updateStageBlock:^(NSDictionary * _Nonnull dict) {
[weakSelf.participantsArea onUpdateJiaoyouUIWith:dict];
}];
[_viewModel setJiao_chooseRelationBlock:^(NSDictionary * _Nonnull dict) {
weakSelf.jyRelationV.dataDict = dict;
[MainWindow() addSubview:weakSelf.jyRelationV];
}];
[_viewModel setSimi_enterOrLeaveBlock:^(BOOL enter) {
[weakSelf.customToolBar onEnterOrLeaveSimiRoom:enter];
if (enter) {
weakSelf.simiRoomV.prid = weakSelf.viewModel.roomInfo.simiRid;
[weakSelf.view insertSubview:weakSelf.simiRoomV belowSubview:weakSelf.chatView];
[MainWindow() addSubview:weakSelf.jySimiVapView];
if (weakSelf.viewModel.roomInfo.is_xiangqin == 1){
NSString *path = [[NSBundle mainBundle] pathForResource:@"酒吧房私密小屋特效" ofType:@"mp4"];
[weakSelf.jySimiVapView playHWDMP4:path repeatCount:0 delegate:weakSelf];
}else{
NSString *path = [[NSBundle mainBundle] pathForResource:@"jy_牵手" ofType:@"mp4"];
[weakSelf.jySimiVapView playHWDMP4:path repeatCount:0 delegate:weakSelf];
}
}else {
[weakSelf.simiRoomV removeFromSuperview];
}
}];
[_viewModel setSimi_updateTimeBlock:^(NSDictionary * _Nonnull dict) {
[weakSelf.simiRoomV onUpdateSurplusTime:[dict safeIntForKey:@"surplus_time"]];
}];
[_viewModel setSimi_updateZhenxinBlock:^(NSDictionary * _Nonnull dict) {
[weakSelf.simiRoomV onUpdateZhenxinContent:[dict safeStringForKey:@"content"]];
}];
[_viewModel setSimi_updateGuangquanBlock:^(NSString * _Nonnull uid) {
[weakSelf.simiRoomV onUpdateGuangquanWith:uid];
}];
[_viewModel setJiao_pendantGiftBlock:^(NSDictionary * _Nonnull dict) {
weakSelf.pendantGiftV.dataDict = dict;
[weakSelf.view addSubview:weakSelf.pendantGiftV];
}];
//
[_viewModel setPm_updateStatusBlock:^(NSDictionary * _Nonnull dict) {
[weakSelf.participantsArea onUpdatePaimaiUIWith:dict];
}];
[_viewModel setPm_paimaiResultBlock:^(NSDictionary * _Nonnull dict) {
[weakSelf onPMPaimaiResult:dict];
}];
//
[_viewModel setReceivedGiftTuopan:^(NSDictionary * _Nonnull dict) {
RCMicMainThread(^{
[weakSelf onShowGiftTuopanWith:dict];
[weakSelf onShowLuckyVapWith:dict];
})
}];
//
[_viewModel setBj_receiveCloseRoomBlock:^(NSDictionary * _Nonnull dict) {
weakSelf.isTotalQuitRoom = YES;
[weakSelf backAction];
[BJFloatRoomManager.sharedBJFloatRoomManager closeFloatWindow];
NSInteger type = [dict safeIntForKey:@"type"];
NSString *rid = [dict safeStringForKey:@"rid"];
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
if (type == 1) {
UIAlertController *alert = [UIAlertController alertControllerWithTitle:nil message:@"房间类型已更改,是否重新进入该房间" preferredStyle:UIAlertControllerStyleAlert];
[alert addAction:[UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
}]];
[alert addAction:[UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
[UIViewController goMicRoomWithRid:rid withPwd:@""];
}]];
[[UIViewController currentViewController] presentViewController:alert animated:YES completion:nil];
}else if (type == 2) {
UIAlertController *alert = [UIAlertController alertControllerWithTitle:nil message:@"该房间已关闭" preferredStyle:UIAlertControllerStyleAlert];
[alert addAction:[UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
}]];
[[UIViewController currentViewController] presentViewController:alert animated:YES completion:nil];
}
});
}];
[_viewModel setBj_receiveLaba:^(NSDictionary * _Nonnull dataDict) {
[weakSelf onReceiveLaba:dataDict];
}];
[_viewModel setBj_PlayInRoomCPTXBlock:^(NSDictionary * _Nonnull cp_info) {
weakSelf.cpvapView.hidden = NO;
[weakSelf.cpvapView playVapWithDict:cp_info];
}];
[_viewModel setBj_MotianlunDayBlcok:^(NSDictionary * _Nonnull info) {
NSLog(@"%@",info);
BJFlyWordModel *model = [BJFlyWordModel new];
NSString *name = [info safeStringForKey:@"u_nick_name"];
NSString *u_receive_name = [info safeStringForKey:@"u_receive_name"];
NSString *gift_name = [info safeStringForKey:@"gift_name"];
model.flyType = 3;
model.totalStr = [NSString stringWithFormat:@"恭喜%@与%@在恋爱摩天轮中获得%@!",name,u_receive_name,gift_name];
model.roomId = weakSelf.viewModel.roomInfo.roomId;
//
[BJFlyWordManager.sharedBJFlyWordManager showFlyWordWithModel:model];
}];
_viewModel.bj_sudGameStart = ^{
[weakSelf onSudLoginGame];
};
_viewModel.bj_sudGameEnd = ^{
[weakSelf onSudLogoutGame];
};
//
[_viewModel setXiangqin_updateStageBlock:^(NSDictionary * _Nonnull dict) {
[weakSelf.participantsArea onUpdateXiangqinUIWith:dict];
}];
[_viewModel setXq_receiveGoSimiRoomBlock:^(NSDictionary * _Nonnull dict) {
[MainWindow() addSubview:weakSelf.jySimiVapView];
if (weakSelf.viewModel.roomInfo.is_xiangqin == 1){
NSString *path = [[NSBundle mainBundle] pathForResource:@"酒吧房私密小屋特效" ofType:@"mp4"];
[weakSelf.jySimiVapView playHWDMP4:path repeatCount:0 delegate:weakSelf];
}
}];
//
[_viewModel setXq_receiveInviteBlock:^(NSDictionary * _Nonnull dict) {
// YYXQInviteAlert *view = LoadNib(@"YYXQInviteAlert");
// view.frame = [UIScreen mainScreen].bounds;
// [MainWindow() addSubview:view];
// view.dataDict = dict;
//
NSDictionary *params = @{@"rid":[dict safeStringForKey:@"rid"], @"id":[dict safeStringForKey:@"id"], @"micro_id":[dict safeStringForKey:@"micro_id"], @"type":@"1"};
[[AFNetworkRequset shared] postRequestWithParams:params Path:@"/api/room/operate_room_owner_up_micro" Loading:YES Hud:YES Success:^(id _Nonnull responseDic) {
} Failure:^(id _Nonnull errorData) {
}];
}];
[_viewModel setXiangqin_agreeJoinHechang:^{
[weakSelf xiangqinHechangLrcView];
}];
//
[_viewModel setBj_JiubaGifBlock:^(NSDictionary * _Nonnull eInfo) {
RCMicMainThread(^{
[weakSelf.participantsArea bj_showJiubaGifWith:eInfo];
})
}];
//
[_viewModel setBj_JiubaGifArrListBlock:^(NSDictionary * _Nonnull eInfo) {
RCMicMainThread(^{
[weakSelf.participantsArea bj_showJiubaGifArrListWith:eInfo];
})
}];
//退
_viewModel.bj_RoomOwnerCloseAccountBlock = ^{
RCMicMainThread(^{
weakSelf.isTotalQuitRoom = YES;
[weakSelf backAction];
})
};
}
- (void)addSubviews {
[self.view addGestureRecognizer:self.tapGesture];
[self.view addSubview:self.backgroundView];
[self.view addSubview:self.participantsArea];
[self.view addSubview:self.customNavigationView];
[self.view addSubview:self.meiliImgView];
[self.view addSubview:self.room_noticeBtn];
[self.view addSubview:self.descBtn];
[self onAddTop3AndUsersView];
[self.view addSubview:self.chatView];
[self.view addSubview:self.publicSelectView];
[self.view addSubview:self.customToolBar];
[self.view addSubview:self.inputBar];
[self.view addSubview:self.blinkExcelView];
[self.view addSubview:self.rankBtn];
[self.view addSubview:self.blindShowV];
self.rankBtn.hidden = YES;
[self onCreateBangdanBgView];
[self.view addSubview:self.applyUpBtn];
[self.view addSubview:self.applyUpNumLab];
[self onRequestPendantGiftData];
}
- (void)addConstraints {
[self.backgroundView mas_makeConstraints:^(MASConstraintMaker *make) {
make.edges.equalTo(self.view);
}];
[self.customNavigationView mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.equalTo(self.view);
make.right.equalTo(self.view);
CGFloat margin = [RCMicUtil statusBarHeight];
make.top.equalTo(self.view).with.offset(margin);
make.height.mas_equalTo(44);
}];
[self.participantsArea mas_makeConstraints:^(MASConstraintMaker *make) {
make.centerX.equalTo(self.view);
make.width.equalTo(self.view);
make.top.equalTo(self.customNavigationView.mas_bottom);
// make.height.mas_equalTo(320);
make.bottom.equalTo(self.customToolBar.mas_top).offset(0);
}];
[self.publicSelectView mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.equalTo(self.view);
make.width.mas_equalTo(260);
make.height.mas_equalTo(30);
make.bottom.equalTo(self.chatView.mas_top);
}];
[self.chatView mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.equalTo(self.customNavigationView.mas_bottom).offset(305);
make.left.equalTo(self.view);
make.right.equalTo(self.view).offset(-90);
make.bottom.equalTo(self.customToolBar.mas_top);
}];
[self.customToolBar mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.equalTo(self.view);
make.width.equalTo(self.view);
make.height.mas_equalTo(ToolBarHeight);
make.bottom.equalTo(self.view).with.offset(-yb_HomeIndicator_H);
}];
[self.applyUpBtn mas_makeConstraints:^(MASConstraintMaker *make) {
make.right.mas_equalTo(-15);
make.bottom.equalTo(self.customToolBar.mas_top).offset(-5);
make.width.mas_equalTo(90);
make.height.mas_equalTo(28);
}];
[self.applyUpNumLab mas_makeConstraints:^(MASConstraintMaker *make) {
make.right.equalTo(self.applyUpBtn).offset(3);
make.top.equalTo(self.applyUpBtn).offset(-5);
make.width.mas_equalTo(16);
make.height.mas_equalTo(16);
}];
LMCPInRoomVapView *vapView = LoadNib(@"LMCPInRoomVapView");
vapView.frame = CGRectMake(0, 0, APPW, APPH);
[MainWindow() addSubview:vapView];
self.cpvapView = vapView;
self.cpvapView.hidden = YES;
}
- (void)joinMicRoom {
__weak typeof(self) weakSelf = self;
//
[self.viewModel joinMicRoom:^{
//
[weakSelf.viewModel bj_showRoomWelcome];
[weakSelf.viewModel bj_showOwnerNotice];
// [weakSelf.viewModel bj_sendMyCommingWithVipInfo:@{@"contribution_level_image":@""}];
// viewmodel KvSyncCompleted KV
weakSelf.joinRoomSuccess = YES;
[weakSelf checkRoomStatus];
//VIP
[weakSelf checkVipPetStatus];
} imError:^{
RCMicMainThread(^{
//#warning
[RCMicActiveWheel showPromptHUDAddedTo:RCMicKeyWindow text:RCMicLocalizedNamed(@"room_joinIM_failed")];
// weakSelf.isTotalQuitRoom = YES;
// [weakSelf.navigationController popViewControllerAnimated:YES];//
})
} rtcError:^{
RCMicMainThread(^{
[RCMicActiveWheel showPromptHUDAddedTo:RCMicKeyWindow text:RCMicLocalizedNamed(@"room_joinRTC_failed")];
// weakSelf.isTotalQuitRoom = YES;
// [weakSelf.navigationController popViewControllerAnimated:YES];//
})
}];
}
- (void)checkRoomStatus {
// KV
//
// if (self.joinRoomSuccess && self.kvSyncSuccess) {
// [self loadDataAndPrepareAudioStream];
// }
if (self.joinRoomSuccess) {
[self loadDataAndPrepareAudioStream];
}
}
- (void)checkVipPetStatus {
NSDictionary *dict = @{@"rid":C_string(_viewModel.roomInfo.roomId)};
NSMutableDictionary *paras = [NSMutableDictionary dictionary];
[paras addEntriesFromDictionary:dict];
[SVProgressHUD showWithStatus:nil];
__weak __typeof(self)weakSelf = self;
[RCMicHTTP postWithURLString:@"/api/room/get_room_user_vip" parameters:paras response:^(RCMicHTTPResult *result) {
[SVProgressHUD dismiss];
if (result.success) {
if (result.errorCode == 200 && [result.content isKindOfClass:NSDictionary.class]) {
NSString *petUrl = [result.content safeStringForKey:@"zq_play_image"];
if (petUrl.length > 0) {
[weakSelf.viewModel bj_sendPetMsg:petUrl cpInfo:result.content[@"cp_info"]];
}
NSDictionary *cp_info = result.content[@"cp_info"];
NSString *texiao_img = [cp_info safeStringForKey:@"texiao_img"];
if (texiao_img.length > 0){
[weakSelf.viewModel bj_sendCPTXWithCPInfo:cp_info];
}
RCMicUserVip *userInfo = [RCMicUserVip mj_objectWithKeyValues:result.content];
weakSelf.viewModel.vipInfo = userInfo;
weakSelf.viewModel.roomInfo.is_room_hiding = userInfo.is_room_hiding;
[weakSelf.viewModel bj_sendMyCommingWithVipInfo:result.content];
}else {
[SVProgressHUD showInfoWithStatus:result.message];
}
}else {
[SVProgressHUD showInfoWithStatus:@"网络错误"];
}
}];
}
- (void)loadDataAndPrepareAudioStream {
__weak typeof(self) weakSelf = self;
// UI
// [self.viewModel publishOrSubscribeAudioStream:^{
// } error:^{
// RCMicMainThread(^{
// [RCMicActiveWheel showPromptHUDAddedTo:weakSelf.view text:RCMicLocalizedNamed(@"room_publishOrSubscribeStream_failed")];
// })
// }];
//
[self.viewModel bj_loadAllParticipantViewModel:^(BOOL isOk) {
// no callback
}];
self.viewModel.participantFirstLoad = ^(BOOL isOK) {
if (isOK) {
dispatch_async(dispatch_get_main_queue(), ^{
[weakSelf.participantsArea reloadData];
});
}else {
dispatch_async(dispatch_get_main_queue(), ^{
[RCMicActiveWheel showPromptHUDAddedTo:RCMicKeyWindow text:RCMicLocalizedNamed(@"room_getParticipantInfo_failed")];
//退
[weakSelf backAction];
});
}
};
}
- (void)shouldShowInputBar:(BOOL)show {
//
if (show) {
self.inputBar.hidden = NO;
[self.inputBar becomeFirstResponderIfNeed];
} else {
self.inputBar.hidden = YES;
[self.inputBar resignFirstResponderIfNeed];
}
}
- (void)setSpeakerState:(RCMicSpeakerState)state {
BOOL enable = state == RCMicSpeakerStateOpen ? YES : NO;
[self.viewModel setUseSpeaker:enable];
self.customToolBar.speakerState = state;
}
- (void)setMicrophoneState:(RCMicMicrophoneState)state {
BOOL enable = state == RCMicMicrophoneStateNormal ? YES : NO;
[self.viewModel setUseMicrophone:enable];
self.customToolBar.microPhoneState = state;
}
- (void)activeWheelTimerAction {
[self stopActiveWheelWithResponse:NO isTimeout:YES];
}
/**
*
*
* @param accept
* @param timeout
*/
- (void)stopActiveWheelWithResponse:(BOOL)accept isTimeout:(BOOL)timeout {
[RCMicActiveWheel hideHUDForView:RCMicKeyWindow animated:YES];
if (timeout) {
[RCMicActiveWheel showPromptHUDAddedTo:RCMicKeyWindow text:RCMicLocalizedNamed(@"room_tip_noresponse")];
} else {
if (!accept) {
[RCMicActiveWheel showPromptHUDAddedTo:RCMicKeyWindow text:RCMicLocalizedNamed(@"room_tip_refuse")];
}
}
[self.wheelDismissTimer invalidate];
self.wheelDismissTimer = nil;
}
- (void)configAndPresentController:(UIViewController *)controller {
controller.modalPresentationStyle = UIModalPresentationOverCurrentContext;
controller.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
[self.navigationController presentViewController:controller animated:YES completion:nil];
}
#pragma mark - Actions
- (void)tapAction {
[self shouldShowInputBar:NO];
}
- (void)backAction {
[self.navigationController popToRootViewControllerAnimated:YES];
}
- (void)speakerAction {
RCMicSpeakerState state = self.customToolBar.speakerState == RCMicSpeakerStateOpen ? RCMicSpeakerStateClose : RCMicSpeakerStateOpen;
[self setSpeakerState:state];
}
- (void)microphoneAction {
if (_viewModel.currentParticipantInfo.state == RCMicParticipantStateSilent) {
[SVProgressHUD showInfoWithStatus:@"你已被禁止说话"];
return;
}
RCMicMicrophoneState microphoneState = self.customToolBar.microPhoneState == RCMicMicrophoneStateNormal ? RCMicMicrophoneStateSilent : RCMicMicrophoneStateNormal;
[self setMicrophoneState:microphoneState];
}
///
- (void)navTouchMenu {
UIAlertController *sheetAlert = [UIAlertController alertControllerWithTitle:nil message:nil preferredStyle:UIAlertControllerStyleActionSheet];
UIAlertAction *action1 = [UIAlertAction actionWithTitle:@"最小化房间" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
[self backAction];
}];
[action1 setValue:HEXCOLOR(0x333333) forKey:@"_titleTextColor"];
[sheetAlert addAction:action1];
UIAlertAction *action2 = [UIAlertAction actionWithTitle:@"退出房间" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
self.isTotalQuitRoom = YES;
[self backAction];
}];
[action2 setValue:HEXCOLOR(0x333333) forKey:@"_titleTextColor"];
[sheetAlert addAction:action2];
UIAlertAction *action3 = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:nil];
[action3 setValue:HEXCOLOR(0x333333) forKey:@"_titleTextColor"];
[sheetAlert addAction:action3];
[self presentViewController:sheetAlert animated:YES completion:nil];
}
///
- (void)navTouchMsgBtn {
// [SVProgressHUD showInfoWithStatus:@"点击消息"];
TXMessageVC *vc = [TXMessageVC new];
vc.isFromRoom = YES;
vc.naviVC = self.navigationController;
[vc popupWithPopType:HWPopTypeNone dismissType:HWDismissTypeNone position:HWPopPositionBottom];
}
- (void)navWanfaBtn {
RoomNoticeAlertView *view = [[NSBundle mainBundle] loadNibNamed:@"RoomNoticeAlertView" owner:self options:nil].firstObject;
view.frame = CGRectMake(0, 0, ScreenWidth, ScreenHeight);
[MainWindow() addSubview:view];
view.contentStr = self.viewModel.roomInfo.room_intro;
}
- (void)showBaoMaiAlert {
[self.userAlert showOnView:self.view haveSearchTf:YES];
}
#pragma mark -
- (void)bjkeyboardDidHide {
self.inputBar.hidden = YES;
}
#pragma mark - UIGestureRecognizerDelegate
- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch {
if ([touch.view isKindOfClass:[UICollectionView class]] || [touch.view isKindOfClass:[UICollectionReusableView class]] || [touch.view isKindOfClass:[UITableView class]]) {
if ([touch.view isKindOfClass:NSClassFromString(@"RoomBtoMoreCell")]) {
return NO;
}
return YES;
}
return NO;
}
#pragma mark - RCMicRoomNavigationViewDelegate
- (void)roomNavigationView:(RCMicRoomNavigationView *)navigationView didSelectItemWithTag:(RCMicRoomNavigationViewTag)tag {
switch (tag) {
case RCMicRoomNavigationViewBackButton:
[self backAction];
break;
case RCMicRoomNavigationViewMenuButton:
[self navTouchMenu];
break;
case RCMicRoomNavigationViewMsgButton:
[self navTouchMsgBtn];
break;
case RCMicRoomNavigationViewPeopleButton:
[self.userAlert showOnView:self.view haveSearchTf:NO];
break;
case RCMicRoomNavigationViewWanfaButton:
[self navWanfaBtn];
break;
default:
break;
}
}
#pragma mark - RCMicParticipantsAreaDelegate
- (void)participantsArea:(RCMicParticipantsArea *)participantsArea didSelectItemWithViewModel:(RCMicParticipantViewModel *)participantViewModel {
__block NSString *areaId = @(participantViewModel.participantInfo.position-1).stringValue;
__weak __typeof(self)weakSelf = self;
NSString *seatUseId = participantViewModel.participantInfo.userId;
// //
// if (participantViewModel.participantInfo.xq_uid_sm==2 && ![self.viewModel isRoomHost]){
// [HelpPageDefine showMessage:@"用户未亮相"];
// return;
// }
//
if (seatUseId.length > 0) {
//
if ([seatUseId isEqualToString:BJUserManager.userInfo.uid]) {
[self.operationAlert loadUserDataAndShowWithUid:seatUseId style:BJOperationAlertTypeClickSelf area:participantViewModel];
}
//
else {
if (_viewModel.isRoomAdministrator || _viewModel.isRoomOwner) {
if ([_viewModel uidIsRoomOwner:seatUseId]) {
NSLog(@"房管点击房主,只显示魅力值");
[self.operationAlert loadUserDataAndShowWithUid:seatUseId style:BJOperationAlertTypeOnlyMeiLiBtn area:participantViewModel];
}else {
NSLog(@"点击普通用户显示5个按钮");
[self.operationAlert loadUserDataAndShowWithUid:seatUseId style:BJOperationAlertTypeFiveBtn area:participantViewModel];
}
}else {
NSLog(@"普通用户点击别人,中间按钮都不显示");
[self.operationAlert loadUserDataAndShowWithUid:seatUseId style:BJOperationAlertTypeZeroBtn area:participantViewModel];
}
}
}
//
else {
if (participantViewModel.participantInfo.state == RCMicParticipantStateClosed) {
//
if (_viewModel.isRoomAdministrator || _viewModel.isRoomOwner){
NSLog(@"显示放开麦位");
UIAlertController *sheetAlert = [UIAlertController alertControllerWithTitle:nil message:nil preferredStyle:UIAlertControllerStyleActionSheet];
[sheetAlert addAction:[UIAlertAction actionWithTitle:@"放开麦位" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
[weakSelf.viewModel bj_lockPositionWithmicid:areaId lock:NO];
}]];
[sheetAlert addAction:[UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:nil]];
[self presentViewController:sheetAlert animated:YES completion:nil];
}else {
NSLog(@"普通用户点击有锁麦位,无响应");
}
}else {
//normal
if (participantViewModel.participantInfo.position == 0) {
//
if (_viewModel.isRoomAdministrator) {
NSLog(@"房管点击空主持,上麦");
[self.viewModel bj_upHostMic];
}else if (_viewModel.isRoomOwner){
NSLog(@"房主点击空主持,上麦");
[self.viewModel bj_upHostMic];
}else {
NSLog(@"普通用户空主持,无响应");
}
}else {
//
if (_viewModel.isRoomAdministrator || _viewModel.isRoomOwner) {
NSLog(@"底部弹框显示 上麦抱人上麦锁麦一共3项");
UIAlertController *sheetAlert = [UIAlertController alertControllerWithTitle:nil message:nil preferredStyle:UIAlertControllerStyleActionSheet];
[sheetAlert addAction:[UIAlertAction actionWithTitle:@"上麦" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
[weakSelf.viewModel bj_upParticipantWithMicId:areaId finish:^(BOOL isOk) {
}];
}]];
[sheetAlert addAction:[UIAlertAction actionWithTitle:@"抱人上麦" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
GVUSER.position = NSStringFormat(@"%ld",participantViewModel.participantInfo.position-1
);
[weakSelf showBaoMaiAlert];
}]];
[sheetAlert addAction:[UIAlertAction actionWithTitle:@"锁麦" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
[weakSelf.viewModel bj_lockPositionWithmicid:areaId lock:YES];
}]];
[sheetAlert addAction:[UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:nil]];
[self presentViewController:sheetAlert animated:YES completion:nil];
}else {
NSLog(@"普通用户直接上麦");
[_viewModel bj_upParticipantWithMicId:areaId finish:^(BOOL isOk) {
}];
}
}
}
}
}
#pragma mark --------------------------------------------
//type,1,view2view
- (void)showWithType:(NSInteger )type {
if (type==1) {
}
}
#pragma mark - bj BJMicRoomOperationAlertDelegate
- (void)operationAlertTrigerAction:(BJOperation)operation targetUserModel:(BJOperationAlertUserModel *)tUserModel area:(nonnull RCMicParticipantViewModel *)aModel {
__weak typeof(self) weakSelf = self;
NSString *areaId = @(aModel.participantInfo.position-1).stringValue;
if (operation == BJOperationDonate) {
// [SVProgressHUD showInfoWithStatus:@"转赠"];
//
MH_ZhuanZengView *view = [[NSBundle mainBundle] loadNibNamed:@"MH_ZhuanZengView" owner:nil options:nil].lastObject;
view.frame = CGRectMake(0, 0, ScreenWidth, ScreenHeight);
view.userInfoModel = tUserModel;
[[UIViewController currentViewController].view addSubview:view];
}
//
else if (operation == BJOperationChat) {
TXSingleChatVC *vc = [[TXSingleChatVC alloc] init];
vc.userId = tUserModel.uid;
vc.titleStr = tUserModel.nick_name;
[self.navigationController pushViewController:vc animated:YES];
}else if (operation == BJOperationGift){
//
[self.roomGiftView bj_showMicDownGiftWithDict:tUserModel.mj_JSONObject];
// if ([self.viewModel getUserMicmsgWithUid:tUserModel.uid]) {
// [self.roomGiftView bj_showGiftAlertWithTargetUser:tUserModel.uid helpUid:nil];
// }else {
// [self.roomGiftView bj_showMicDownGiftWithDict:tUserModel.mj_JSONObject];
// }
}
else if (operation == BJOperationHome){
//
//
// [BJFloatRoomManager.sharedBJFloatRoomManager showFloatWindowWithModel:_viewModel WithRoomCtrl:self];
[UIViewController goUserMainpageWith:tUserModel.uid withRid:C_string(_viewModel.roomInfo.roomId)];
}
//
else if (operation == BJOperationForceUp) {
// [SVProgressHUD showInfoWithStatus:@"抱上麦"];
[_viewModel bj_forceMicUpWithParticipant:tUserModel.uid micid:areaId];
[_viewModel bj_sendOperationRoomMessageTo:tUserModel.uid type:BJIMMsgType_BeUpMic];
}
else if (operation == BJOperationForceDown){
// [SVProgressHUD showInfoWithStatus:@"强制下麦"];
[_viewModel bj_forceMicDownWithParticipant:tUserModel.uid];
[_viewModel bj_sendOperationRoomMessageTo:tUserModel.uid type:BJIMMsgType_BeDownMic];
}
else if (operation == BJOperationVoiceOpen){
[SVProgressHUD showInfoWithStatus:@"开麦"];
[_viewModel bj_unlockVoiceWithParticipant:tUserModel.uid];
[_viewModel bj_sendOperationRoomMessageTo:tUserModel.uid type:BJIMMsgType_EnableVoice];
}
else if (operation == BJOperationVoiceClose){
[SVProgressHUD showInfoWithStatus:@"禁麦"];
[_viewModel bj_lockVoiceWithParticipant:tUserModel.uid];
[_viewModel bj_sendOperationRoomMessageTo:tUserModel.uid type:BJIMMsgType_DisableVoice];
}
else if (operation == BJOperationMsgOpen){
[SVProgressHUD showInfoWithStatus:@"解除禁言"];
[_viewModel bj_unlockMsgWithParticipant:tUserModel.uid];
[_viewModel bj_sendOperationRoomMessageTo:tUserModel.uid type:BJIMMsgType_EnableMsg];
// [self getAdd_adminWithParameters:tUserModel.uid rid:_viewModel.roomInfo.roomId];
}
else if (operation == BJOperationMsgClose){
[SVProgressHUD showInfoWithStatus:@"禁言"];
[_viewModel bj_lockMsgWithParticipant:tUserModel.uid success:^(BOOL isOK) {
[weakSelf.viewModel bj_sendOperationRoomMessageTo:tUserModel.uid type:BJIMMsgType_DisableMsg];
}];
// [self getRemove_adminWithParameters:tUserModel.uid rid:_viewModel.roomInfo.roomId];
}
else if (operation == BJOperationKickRoom){
[SVProgressHUD showInfoWithStatus:@"踢出房间"];
[_viewModel bj_kickUserOutRoom:tUserModel.uid success:^{
//
[weakSelf.viewModel bj_sendKickRoomMessageTo:tUserModel.uid];
} error:^(RCMicHTTPCode errCode) {
}];
}
else if (operation == BJOperationLockSeat){
[SVProgressHUD showInfoWithStatus:@"封闭座位"];
[_viewModel bj_lockSeatWithUid:tUserModel.uid position:aModel.participantInfo.position success:^(BOOL isOK) {
}];
}else if (operation == BJOperationClearCharm) {
[_viewModel bj_clearCharmValueWithUid:tUserModel.uid success:^(BOOL isOK) {
}];
}else if (operation == BJOperationSiliaoTa) {//ta
self.siliaoId = tUserModel.uid;
[self.inputBar setText:[NSString stringWithFormat:@"私聊%@ ", tUserModel.nick_name]];
[self bot_showMsgInput];
}else if (operation == BJOperationAtTa) {//@ta
[self.inputBar setText:[NSString stringWithFormat:@"@%@ ", tUserModel.nick_name]];
[self bot_showMsgInput];
}else if (operation == BJOperationSelfDownMic) {//
[self bot_micChangeAction];
}
}
- (void)getAdd_adminWithParameters:(NSString *)uid rid:(NSString *)rid{
NSDictionary *dict = @{@"uid":uid, @"rid":rid};
NSMutableDictionary *paras = [NSMutableDictionary dictionary];
[paras addEntriesFromDictionary:dict];
__weak typeof(self) weakSelf = self;
// [SVProgressHUD showWithStatus:nil];
[RCMicHTTP postWithURLString:@"/api/room/set_room_admin" parameters:paras response:^(RCMicHTTPResult *result) {
[SVProgressHUD dismiss];
if (result.success) {
if (result.errorCode == 200) {
[SVProgressHUD showInfoWithStatus:result.message];
[weakSelf.viewModel bj_sendAdminChangeMessageTo:uid isAdmin:YES];
}else {
[SVProgressHUD showInfoWithStatus:result.message];
}
}else {
[SVProgressHUD showInfoWithStatus:@"网络错误"];
}
}];
}
- (void)getRemove_adminWithParameters:(NSString *)uid rid:(NSString *)rid{
NSDictionary *dict = @{@"uid":uid, @"rid":rid};
NSMutableDictionary *paras = [NSMutableDictionary dictionary];
[paras addEntriesFromDictionary:dict];
__weak typeof(self) weakSelf = self;
// [SVProgressHUD showWithStatus:nil];
[RCMicHTTP postWithURLString:@"/api/room/unset_room_admin" parameters:paras response:^(RCMicHTTPResult *result) {
[SVProgressHUD dismiss];
if (result.success) {
if (result.errorCode == 200) {
[SVProgressHUD showInfoWithStatus:result.message];
[weakSelf.viewModel bj_sendAdminChangeMessageTo:uid isAdmin:NO];
}else {
[SVProgressHUD showInfoWithStatus:result.message];
}
}else {
[SVProgressHUD showInfoWithStatus:@"网络错误"];
}
}];
}
/*
RCMicRoomToolBarMessageButton = 100,//
RCMicRoomToolBarMicChangeButton,//
RCMicRoomToolBarSpeakerButton,//
RCMicRoomToolBarMicrophoneButton,//
RCMicRoomToolBarEmojiButton,//
RCMicRoomToolBarMoreButton,//
RCMicRoomToolBarGameButton,//
RCMicRoomToolBarGiftButton,//
*/
#pragma mark - RCMicRoomToolBarDelegate
- (void)roomToolBar:(RCMicRoomToolBar *)toolBar didSelectItemWithTag:(RCMicRoomToolBarViewTag)tag {
switch (tag) {
case RCMicRoomToolBarMessageButton:
[self bot_showMsgInput];
break;
case RCMicRoomToolBarMicChangeButton:
[self bot_micChangeAction];
break;
case RCMicRoomToolBarSpeakerButton:
[self speakerAction];
break;
case RCMicRoomToolBarMicrophoneButton:
[self microphoneAction];
break;
case RCMicRoomToolBarEmojiButton:
[self bot_emojiAction];
break;
case RCMicRoomToolBarMoreButton:
// [self bot_emojiAction];
[self bot_moreAction];
break;
case RCMicRoomToolBarGameButton:
[self bot_gameAction];
break;
case RCMicRoomToolBarGiftButton:
[self bot_giftAction];
break;
case RCMicRoomToolBarSiliaoButton:
[self bot_siliao];
break;
case RCMicRoomToolBarCPRankButton:
{
// YYRoomCPRankView *view = LoadNib(@"YYRoomCPRankView");
// view.frame = [UIScreen mainScreen].bounds;
// [KEYWINDOW addSubview:view];
LMLoveSkyWheelViewController *swvc = [[LMLoveSkyWheelViewController alloc] init];
[swvc pushSelf];
}
break;
default:
break;
}
}
- (void)bot_showMsgInput {
[self shouldShowInputBar:YES];
}
- (void)bot_micChangeAction {
if (_viewModel.currentParticipantInfo) {
if (_viewModel.currentParticipantInfo.position == 0) {
[_viewModel bj_downHostMic];
}else {
[_viewModel bj_downParticipant:^(BOOL isOK) {
}];
}
}else {
//for
RCMicParticipantViewModel *emptyModel;
NSArray *noOrderKeys = _viewModel.participantDataSource.allKeys;
NSArray *allKeys = [noOrderKeys sortedArrayUsingSelector:@selector(compare:)];
for (int i=1; i<allKeys.count; i++) {
RCMicParticipantViewModel *model = _viewModel.participantDataSource[allKeys[i]];
if (model.participantInfo.userId.length==0 && model.participantInfo.state!=RCMicParticipantStateClosed) {
emptyModel = model;
break;
}
}
if (emptyModel) {
NSString *areaId = @(emptyModel.participantInfo.position-1).stringValue;
[_viewModel bj_upParticipantWithMicId:areaId finish:^(BOOL isOk) {
}];
}else {
[SVProgressHUD showInfoWithStatus:@"当前没有空闲的麦位"];
}
}
}
- (void)bot_moreAction {
__weak __typeof(self)weakSelf = self;
//
RoomBotMoreView *botMoreView = [[RoomBotMoreView alloc] initWithFrame:CGRectMake(0, 0, ScreenWidth, ScreenHeight) viewModel:_viewModel];
[MainWindow() addSubview:botMoreView];
//
botMoreView.voiceClickBLock = ^(BOOL isClose) {
weakSelf.viewModel.useSpeaker = isClose;
[weakSelf speakerAction];
};
//
botMoreView.texiaoClickBlock = ^(BOOL isClose) {
GVUSER.closeGiftEffect = !GVUSER.closeGiftEffect;
if (GVUSER.closeGiftEffect) {
[[BJSvgaManager sharedBJSvgaManager] stopAllSvga];
[weakSelf.luckyVapView removeFromSuperview];
}
};
//
botMoreView.roomSetClickBlock = ^{
[UIViewController goRoomSetWithId:weakSelf.viewModel.roomInfo.roomId roomInfo:^{
//room_info
[weakSelf get_roomInfoRequest];
}];
// YYRoomSettingVC *vc = [[YYRoomSettingVC alloc] init];
// vc.rid = weakSelf.viewModel.roomInfo.roomId;
// vc.onUpdateInfoBlock = ^(NSDictionary * _Nonnull dict) {
// //
// [weakSelf.viewModel bj_sendRoomSettingMsg:dict];
// //
// [weakSelf handleRoomChangeWithRoomDic:dict];
// };
// [weakSelf.navigationController pushViewController:vc animated:YES];
};
//
botMoreView.setAdminClickBlock = ^{
[weakSelf bot_setAdmin];
};
//
botMoreView.msgClickBlock = ^{
TXMessageVC *vc = [TXMessageVC new];
vc.isFromRoom = YES;
vc.naviVC = weakSelf.navigationController;
[vc popupWithPopType:HWPopTypeNone dismissType:HWDismissTypeNone position:HWPopPositionBottom];
};
//
botMoreView.clearClickBlock = ^{
[weakSelf.viewModel bj_sendAdminClearMsg];
};
//
botMoreView.setChaoguanClickBlock = ^{
[weakSelf bot_setChaoguan];
};
//PK
botMoreView.createPKBlock = ^{
AmPKVC *vc = [[AmPKVC alloc]init];
vc.roomId = weakSelf.viewModel.roomInfo.roomId;
[vc pushSelf];
};
//
botMoreView.lockRoomBlock = ^(BOOL isLock) {
[weakSelf lockRoomRequest:isLock];
};
//
botMoreView.musicClickBlock = ^{
[weakSelf.view addSubview:weakSelf.musicView];
};
botMoreView.onPublishGBHeadBlock = ^{
[weakSelf showRoomHeadlinePublishView];
};
botMoreView.blackListBlock = ^{
LMRoomBlackListViewController *vc = [[LMRoomBlackListViewController alloc] init];
vc.rid = weakSelf.viewModel.roomInfo.roomId;
[weakSelf.navigationController pushViewController:vc animated:YES];
};
}
- (void)lockRoomRequest:(BOOL)isLock {
NSDictionary *dict = @{@"rid":C_string(_viewModel.roomInfo.roomId)};
NSMutableDictionary *paras = [NSMutableDictionary dictionary];
[paras addEntriesFromDictionary:dict];
NSString *urlStr = isLock ? @"api/room/lock_room" : @"api/room/unlock_room";
[SVProgressHUD showWithStatus:nil];
[RCMicHTTP postWithURLString:urlStr parameters:paras response:^(RCMicHTTPResult *result) {
[SVProgressHUD dismiss];
if (result.success) {
[SVProgressHUD showInfoWithStatus:result.message];
self.viewModel.roomInfo.is_lock = isLock ? 2 : 1;
}else {
[SVProgressHUD showInfoWithStatus:@"网络错误"];
}
}];
}
#pragma mark --------------------------------------------
- (void)get_roomInfoRequest {
NSDictionary *dict = @{@"rid":C_string(_viewModel.roomInfo.roomId)};
NSMutableDictionary *paras = [NSMutableDictionary dictionary];
[paras addEntriesFromDictionary:dict];
[SVProgressHUD showWithStatus:nil];
__weak __typeof(self)weakSelf = self;
[RCMicHTTP postWithURLString:@"/api/room/get_room_info" parameters:paras response:^(RCMicHTTPResult *result) {
[SVProgressHUD dismiss];
if (result.success) {
if (result.errorCode == 200) {
//
[weakSelf.viewModel bj_sendRoomSettingMsg:result.content];
//
[weakSelf handleRoomChangeWithRoomDic:result.content];
}
}else {
[SVProgressHUD showInfoWithStatus:@"网络错误"];
}
}];
}
- (void)handleRoomChangeWithRoomDic:(NSDictionary *)info {
NSString *room_name = [info safeStringForKey:@"room_name"];
NSString *room_intro = [info safeStringForKey:@"room_intro"];
NSString *room_background_image = [info safeStringForKey:@"room_background_image"];
if ([_viewModel.roomInfo.roomName isEqualToString:room_name]) {
}else{
_viewModel.roomInfo.roomName = room_name;
}
if ([_viewModel.roomInfo.room_background_image isEqualToString:room_background_image]) {
}else{
_viewModel.roomInfo.room_background_image = room_background_image;
[self.backgroundView sd_setImageWithURL:[NSURL URLWithString:room_background_image]];
}
if ([_viewModel.roomInfo.room_intro isEqualToString:room_intro]) {
}else{
_viewModel.roomInfo.room_intro = room_intro;
[_viewModel bj_showOwnerNotice];
}
}
- (void)bot_gameAction {
UIAlertController *sheet = [UIAlertController alertControllerWithTitle:nil message:nil preferredStyle:UIAlertControllerStyleActionSheet];
[sheet addAction:[UIAlertAction actionWithTitle:@"开宝箱" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
[self bot_subBoxGame];
}]];
[sheet addAction:[UIAlertAction actionWithTitle:@"星球探险" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
[self bot_subExploreGame];
}]];
[sheet addAction:[UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:nil]];
[self presentViewController:sheet animated:YES completion:nil];
}
///
- (void)bot_giftAction {
[self.roomGiftView bj_showGiftAlertWithTargetUser:nil helpUid:nil];
}
- (void)bot_emojiAction {
if (!_emojiAlert) {
_emojiAlert = [[BJRoomEmojiAlert alloc] initWithRoomModel:_viewModel];
}
[_emojiAlert showOnView:self.view];
}
- (void)bot_setAdmin {
BJRoomSetAdminiCtrl *VC = [[BJRoomSetAdminiCtrl alloc] init];
VC.rid = _viewModel.roomInfo.roomId;
__weak typeof(self) weakSelf = self;
VC.adminiStrClickBlock = ^(BJRoomBaomaiModel *adminiModel) {
[weakSelf.viewModel bj_sendAdminChangeMessageTo:adminiModel.uid isAdmin:adminiModel.is_admin];
};
[self.navigationController pushViewController:VC animated:YES];
}
- (void)bot_subBoxGame {
}
- (void)bot_subExploreGame {
}
- (void)bot_setChaoguan {
BJRoomSetChaoguanCtrl *VC = [[BJRoomSetChaoguanCtrl alloc] init];
VC.rid = _viewModel.roomInfo.roomId;
// __weak typeof(self) weakSelf = self;
VC.adminiStrClickBlock = ^(BJRoomBaomaiModel *adminiModel) {
// [weakSelf.viewModel bj_sendAdminChangeMessageTo:adminiModel.uid isAdmin:adminiModel.is_admin];
};
[self.navigationController pushViewController:VC animated:YES];
}
- (void)bot_siliao {
TXMessageVC *vc = [[TXMessageVC alloc] init];
vc.isFromRoom = YES;
vc.naviVC = self.navigationController;
[vc popupWithPopType:HWPopTypeNone dismissType:HWDismissTypeNone position:HWPopPositionBottom];
}
#pragma mark - RCMicChatViewDelegate cell
- (void)chatView:(RCMicChatView *)chatView didTapMessageCell:(RCMicMessageBaseCell *)cell withViewModel:(BJChatMsgModel *)messageViewModel {
//
NSInteger chatType = messageViewModel.messageType.integerValue;
if (chatType == BJIMMsgType_RoomNotice) {
// [SVProgressHUD showInfoWithStatus:@"点击公告"];
}
else if (chatType == BJIMMsgType_EnterRoom) {
// [SVProgressHUD showInfoWithStatus:@"进入直播间"];
}
else if (chatType == BJIMMsgType_SendChat) {
[SVProgressHUD showInfoWithStatus:[NSString stringWithFormat:@"点击%@的发言", messageViewModel.nickName]];
}
else if (chatType == BJIMMsgType_SendGift) {
// [SVProgressHUD showInfoWithStatus:@"点击礼物消息"];
}
}
- (void)chatView:(RCMicChatView *)chateView didClickUserNameWithUserID:(NSString *)uid{
RCMicParticipantViewModel *model = [_viewModel getUserMicmsgWithUid:uid];
// __weak __typeof(self)weakSelf = self;
if ([uid isEqualToString:BJUserManager.userInfo.uid]) {
[self.operationAlert loadUserDataAndShowWithUid:uid style:BJOperationAlertTypeClickSelf area:model];
}else{
if (_viewModel.isRoomAdministrator || _viewModel.isRoomOwner) {
if ([_viewModel uidIsRoomOwner:uid]) {
NSLog(@"房管点击房主,只显示魅力值");
[self.operationAlert loadUserDataAndShowWithUid:uid style:BJOperationAlertTypeOnlyMeiLiBtn area:model];
}else {
NSLog(@"点击普通用户显示5个按钮");
[self.operationAlert loadUserDataAndShowWithUid:uid style:BJOperationAlertTypeFiveBtn area:model];
}
}else {
NSLog(@"普通用户点击别人,中间按钮都不显示");
[self.operationAlert loadUserDataAndShowWithUid:uid style:BJOperationAlertTypeZeroBtn area:model];
}
}
}
#pragma mark - RCMicInputBarControlDelegate
- (void)inputBar:(RCMicInputBar *)inputBar didTouchsendButton:(NSString *)text {
NSDictionary *params = @{@"rid":self.viewModel.roomInfo.roomId};
[[AFNetworkRequset shared] postRequestWithParams:params Path:@"/api/room/get_user_world_status" Loading:YES Hud:NO Success:^(id _Nonnull responseDic) {
BOOL isNormal = [responseDic[@"data"] safeIntForKey:@"lock_status"]==1; //1
if (isNormal) {
[[AFNetworkRequset shared] postRequestWithParams:params Path:@"api/user/check_user_is_real" Loading:YES Hud:NO Success:^(id _Nonnull responseDic) {
NSDictionary *data = [responseDic safeDictionaryForKey:@"data"];
//1- 2-
NSInteger is_real = [data safeIntForKey:@"is_real"];
if (is_real == 1){
[inputBar clearInputView];
[self shouldShowInputBar:NO];
[self.viewModel bj_sendInputString:text siliao_id:self.siliaoId];
self.siliaoId = @"";
}else{
[SVProgressHUD showInfoWithStatus:@"请实名认证"];
}
} Failure:^(id _Nonnull errorData) {
}];
}else {
[SVProgressHUD showInfoWithStatus:@"你已被禁止公屏发言"];
}
} Failure:^(id _Nonnull errorData) {
}];
}
#pragma mark -
- (BJRoomGiftAlert *)roomGiftView{
if (!_roomGiftView) {
__weak typeof(self) weakSelf = self;
_roomGiftView = [[BJRoomGiftAlert alloc] initWithRoomModel:_viewModel];
_roomGiftView.topUpButtonClickBlock = ^{
[UIViewController goRechageCtrl];
};
_roomGiftView.judgeBoxBlock = ^{
[weakSelf.chatView onRequestJudgeShowBox];
};
}
return _roomGiftView;
}
- (void)showNorGiftPathAnimate:(NSString *)url uid:(NSString *)uid {
// CGPoint startCenter = CGPointMake(APPW-30, APPH-yb_HomeIndicator_H-30);
CGPoint startCenter = CGPointMake(30, yb_NavigationBar_H+30);
CGPoint end = [self.participantsArea bj_pointWithUid:uid];
CGPoint fixEndCenter = CGPointMake(_participantsArea.x+end.x, _participantsArea.y+end.y);
if (end.x==0 && end.y==0) {
//
return;
}
NSInteger startWidth = 60;
CGRect startRect = CGRectMake(startCenter.x-startWidth/2, startCenter.y-startWidth/2, startWidth, startWidth);
UIImageView *norImg = [ControlCreator createImageView:MainWindow() rect:startRect imageName:nil backguoundColor:nil];
norImg.contentMode = UIViewContentModeScaleAspectFit;
[norImg sd_setImageWithURL:URL(C_string(url))];
NSInteger endWidth = 40;
CGRect endRect = CGRectMake(fixEndCenter.x-endWidth/2, fixEndCenter.y-endWidth/2, endWidth, endWidth);
[UIView transitionWithView:norImg duration:0.6 options:UIViewAnimationOptionCurveEaseOut | UIViewAnimationOptionTransitionFlipFromRight animations:^{
norImg.frame = endRect;
} completion:^(BOOL finished) {
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
[norImg removeFromSuperview];
});
}];
}
#pragma mark ------------------- PK ---------------------
-(UIButton *)stopPkBtn{
if(!_stopPkBtn){
_stopPkBtn = [ControlCreator createButton:nil rect:CGRectZero text:@"结束PK" font:YBFont(12) color:kWhiteColor backguoundColor:[mainDeepColor colorWithAlphaComponent:0.2] imageName:nil target:self action:nil];
_stopPkBtn.hidden = YES;
[self.view addSubview:_stopPkBtn];
_stopPkBtn.layer.cornerRadius = 12.5;
_stopPkBtn.layer.borderWidth = 0.5;
_stopPkBtn.layer.borderColor = mainDeepColor.CGColor;
[_stopPkBtn buttonAddTaget:^(UIButton *btn) {
NSDictionary *params = @{@"rid":self.viewModel.roomInfo.roomId};
[[AFNetworkRequset shared] postRequestWithParams:params Path:@"api/room/close_room_pk_by_rid" Loading:NO Hud:NO Success:^(id _Nonnull responseDic) {
} Failure:^(id _Nonnull errorData) {
}];
} forControlEvents:UIControlEventTouchUpInside];
[_stopPkBtn mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.mas_equalTo(yb_NavigationBar_H+70);
make.right.mas_equalTo(-15);
make.size.mas_equalTo(CGSizeMake(58, 25));
}];
}
return _stopPkBtn;
}
- (PklineView *)pkView {
if (!_pkView) {
_pkView = [[NSBundle mainBundle] loadNibNamed:@"PklineView" owner:self options:nil].firstObject;
_pkView.hidden = YES;
[self.view addSubview:_pkView];
[_pkView mas_makeConstraints:^(MASConstraintMaker *make) {
make.bottom.equalTo(self.participantsArea.mas_bottom).offset(10);
make.left.right.equalTo(self.view);
make.height.mas_equalTo(65);
}];
}
return _pkView;
}
- (void)onFetchPKDataWithAlert:(BOOL)isShowAlert {
NSDictionary *params = @{@"rid":C_string(self.viewModel.roomInfo.roomId)};
[[AFNetworkRequset shared] postRequestWithParams:params Path:@"api/room/get_room_pk_info" Loading:NO Hud:NO Success:^(id _Nonnull responseDic) {
SPPKInfoModel *model = [SPPKInfoModel mj_objectWithKeyValues:responseDic[@"data"]];
if (model.is_close == 1) {//PK
self.pkView.model = model;
self.pkView.hidden = NO;
if (self.viewModel.isRoomAdministrator || self.viewModel.isRoomOwner) {
self.stopPkBtn.hidden = NO;
}else{
self.stopPkBtn.hidden = YES;
}
[self.participantsArea ishowImagetype:NO winteam:@""];
}else {
//PK
self.stopPkBtn.hidden = YES;
self.pkView.hidden = YES;
}
[self.participantsArea mas_updateConstraints:^(MASConstraintMaker *make) {
make.height.mas_equalTo(model.is_close==1?370:320);
}];
} Failure:^(id _Nonnull errorData) {
}];
}
- (void)onReceivePKSocket:(NSDictionary *)dataDict {
SPPKInfoModel *model = [SPPKInfoModel mj_objectWithKeyValues:dataDict];
self.pkView.model = model;
self.pkView.hidden = NO;
[self.participantsArea ishowImagetype:NO winteam:@""];
if (_viewModel.isRoomAdministrator || _viewModel.isRoomOwner) {
self.stopPkBtn.hidden = NO;
}else{
self.stopPkBtn.hidden = YES;
}
if ([dataDict safeIntForKey:@"is_close"] != 1) {//
self.stopPkBtn.hidden = YES;
NSString *win = [NSString stringWithFormat:@"%@",dataDict[@"winner_group"]];
[self.participantsArea ishowWinTeam:win];
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(10 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
self.pkView.hidden = YES;
[self.participantsArea mas_updateConstraints:^(MASConstraintMaker *make) {
make.height.mas_equalTo(320);
}];
});
}else {
[self.participantsArea mas_updateConstraints:^(MASConstraintMaker *make) {
make.height.mas_equalTo(370);
}];
}
}
#pragma mark - Getters & Setters
- (UITapGestureRecognizer *)tapGesture {
if (!_tapGesture) {
_tapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapAction)];
_tapGesture.delegate = self;
}
return _tapGesture;
}
- (UIImageView *)backgroundView {
if (!_backgroundView) {
_backgroundView = [[UIImageView alloc] initWithFrame:CGRectZero];
_backgroundView.contentMode = UIViewContentModeScaleAspectFill;
_backgroundView.layer.masksToBounds = YES;
UIImage *placeImg = [UIImage imageNamed:@"room_background"];
[_backgroundView sd_setImageWithURL:URL(_viewModel.roomInfo.room_background_image) placeholderImage:placeImg];
}
return _backgroundView;
}
- (RCMicRoomNavigationView *)customNavigationView {
if (!_customNavigationView) {
_customNavigationView = [[RCMicRoomNavigationView alloc] initWithFrame:CGRectZero viewModel:self.viewModel];
_customNavigationView.delegate = self;
}
return _customNavigationView;
}
- (RCMicRoomToolBar *)customToolBar {
if (!_customToolBar) {
_customToolBar = [[RCMicRoomToolBar alloc] initWithFrame:CGRectZero];
_customToolBar.delegate = self;
BOOL haveAuth = _viewModel.isRoomOwner || _viewModel.isRoomAdministrator;
[_customToolBar updateWithRoleType:self.viewModel.role auth:haveAuth];
}
return _customToolBar;
}
- (RCMicParticipantsArea *)participantsArea {
if (!_participantsArea) {
_participantsArea = [[RCMicParticipantsArea alloc] initWithFrame:CGRectZero viewModel:self.viewModel];
_participantsArea.delegate = self;
WEAK_SELF
_participantsArea.jiao_micHelpBlock = ^(NSString * _Nonnull uid) {
[weakSelf.roomGiftView bj_showGiftAlertWithTargetUser:uid helpUid:uid];
};
}
return _participantsArea;
}
- (RCMicChatView *)chatView {
if (!_chatView) {
_chatView = [[RCMicChatView alloc] initWithFrame:CGRectZero viewModel:self.viewModel];
_chatView.delegate = self;
}
return _chatView;
}
- (RCMicInputBar *)inputBar {
if (!_inputBar) {
CGFloat height = [RCMicUtil bottomSafeAreaHeight] + InputBarHeight;
CGFloat originY = RCMicScreenHeight - height;
_inputBar = [[RCMicInputBar alloc] initWithFrame:CGRectMake(0, originY, RCMicScreenWidth, height)];
_inputBar.delegate = self;
_inputBar.hidden = YES;
}
return _inputBar;
}
- (RoomPublicSelectView *)publicSelectView {
if (!_publicSelectView) {
_publicSelectView = [[RoomPublicSelectView alloc] initWithFrame:CGRectZero viewModel:self.viewModel];
_publicSelectView.backgroundColor = kClearColor;
WEAK_SELF
_publicSelectView.onSelectBlock = ^{
[weakSelf onChangeSelectChat];
};
}
return _publicSelectView;
}
- (RCMicBlinkExcelView *)blinkExcelView {
if (!_blinkExcelView) {
_blinkExcelView = [[RCMicBlinkExcelView alloc] initWithFrame:CGRectMake(0, 0, RCMicScreenWidth, RCMicScreenHeight) viewModel:self.viewModel];
_blinkExcelView.backgroundColor = [UIColor colorWithRed:0 green:0 blue:0 alpha:0.35];
_blinkExcelView.hidden = YES;
}
return _blinkExcelView;
}
- (BJMicRoomOperationAlert *)operationAlert {
if (_viewModel == nil) {
return nil;
}
if (_operationAlert == nil) {
_operationAlert = [BJMicRoomOperationAlert initOperationAlertWithRoomModel:_viewModel];
_operationAlert.delegate = self;
}
return _operationAlert;
}
- (UIButton *)rankBtn {
if (!_rankBtn) {
_rankBtn = [UIButton buttonWithType:UIButtonTypeCustom];
[_rankBtn setImage:ImageNamed(@"room_rank") forState:UIControlStateNormal];
_rankBtn.frame = CGRectMake(15, ZJTopNavH+15, 60, 18);
WEAK_SELF
[_rankBtn buttonAddTaget:^(UIButton *btn) {
// SPBangDanContainerVC *vc = [[SPBangDanContainerVC alloc] init];
// vc.rid = weakSelf.viewModel.roomInfo.roomId;
// [vc pushSelf];
[weakSelf.view addSubview:weakSelf.bangdanBgView];
} forControlEvents:UIControlEventTouchUpInside];
}
return _rankBtn;
}
- (UIButton *)room_noticeBtn {
if (!_room_noticeBtn) {
_room_noticeBtn = [UIButton buttonWithType:UIButtonTypeCustom];
[_room_noticeBtn setImage:ImageNamed(@"room_nav_wanfa") forState:UIControlStateNormal];
if ([_viewModel.roomInfo.enter_user_type integerValue]<3) {
_room_noticeBtn.frame = CGRectMake(APPW-65, yb_NavigationBar_H+15, 50, 25);
}else{
_room_noticeBtn.frame = CGRectMake(APPW-65, yb_NavigationBar_H+15, 50, 25);
}
WEAK_SELF
[_room_noticeBtn buttonAddTaget:^(UIButton *btn) {
[weakSelf navWanfaBtn];
} forControlEvents:UIControlEventTouchUpInside];
}
return _room_noticeBtn;
}
- (UIButton *)descBtn {
if (!_descBtn) {
_descBtn = [UIButton buttonWithType:UIButtonTypeCustom];
_descBtn.titleLabel.font = YBBoldFont(10);
[_descBtn setTitle:@"玩法说明" forState:UIControlStateNormal];
[_descBtn setTitleColor:kWhiteColor forState:UIControlStateNormal];
[_descBtn setImage:ImageNamed(@"xq_room_wanfa") forState:UIControlStateNormal];
_descBtn.frame = CGRectMake(self.room_noticeBtn.right+15, yb_NavigationBar_H+15, 70, 25);
[_descBtn ba_button_setButtonLayoutType:BAKit_ButtonLayoutTypeLeftImageLeft padding:5];
_descBtn.hidden = YES;
[_descBtn buttonAddTaget:^(UIButton *btn) {
//
[UIViewController goWebWithUrl:[VERSION_HTTPS_SERVER stringByAppendingString:@"index.php/index/index/page_show?id=22"]];
} forControlEvents:UIControlEventTouchUpInside];
}
return _descBtn;
}
- (UIImageView *)meiliImgView {
if (!_meiliImgView) {
_meiliImgView = [[UIImageView alloc] initWithFrame:CGRectMake(16, yb_NavigationBar_H+15, 50, 25)];
_meiliImgView.image = ImageNamed(@"room_clean_meili");
_meiliImgView.contentMode = UIViewContentModeCenter;
if ([_viewModel.roomInfo.enter_user_type integerValue]<3) {
_meiliImgView.hidden = NO;
}else{
_meiliImgView.hidden = YES;
}
__weak typeof(self) weakSelf = self;
_meiliImgView.touchViewBlock = ^{
SPAlertController *controller = [SPAlertController alertControllerWithTitle:@"是否清空魅力值?" message:@"" preferredStyle:SPAlertControllerStyleAlert];
SPAlertAction *cancel = [SPAlertAction actionWithTitle:@"取消" style:SPAlertActionStyleCancel handler:^(SPAlertAction * _Nonnull action) {
}];
SPAlertAction *queding = [SPAlertAction actionWithTitle:@"确定" style:SPAlertActionStyleCancel handler:^(SPAlertAction * _Nonnull action) {
[weakSelf clearRoomMeiliRequest];
}];
[controller addAction:cancel];
[controller addAction:queding];
[weakSelf presentViewController:controller animated:YES completion:nil];
};
}
return _meiliImgView;
}
- (BlindXunlehuiShowView *)blindShowV {
if (!_blindShowV) {
_blindShowV = LoadNib(@"BlindXunlehuiShowView");
_blindShowV.frame = CGRectMake(ScreenWidth-120, [RCMicUtil statusBarHeight]+480, 110, 110);
_blindShowV.hidden = YES;
if ([GVUSER.is_open_blindXlh isEqual:@"1"]) {
_blindShowV.leftTimeL.text = [NSString stringWithFormat:@"剩余时间:%@", [NSString minuteAndSecStringWithTime:[_viewModel.roomInfo.blind_box_term_over_time intValue]]];
self.leftSecond = [_viewModel.roomInfo.blind_box_term_over_time intValue];
[self.timer startGCDTimer:1 delegate:self];
_blindShowV.hidden = NO;
}else {
_blindShowV.leftTimeL.text = @"0:00";
_blindShowV.hidden = YES;
}
}
return _blindShowV;
}
//
- (void)BlindStartAction:(NSNotification *)notify {
NSDictionary *data = notify.userInfo;
_blindShowV.leftTimeL.text = [NSString stringWithFormat:@"剩余时间:%@", [NSString minuteAndSecStringWithTime:[data safeIntForKey:@"over_time"]]];
_blindShowV.hidden = NO;
self.leftSecond = [data safeIntForKey:@"over_time"];
[self.timer startGCDTimer:1 delegate:self];
}
//
-(void)BlindUpdateTime:(NSNotification *)notify {
NSDictionary *data = notify.userInfo;
_blindShowV.leftTimeL.text = [NSString stringWithFormat:@"剩余时间:%@", [NSString minuteAndSecStringWithTime:[data safeIntForKey:@"end_time"]]];
self.leftSecond = [data safeIntForKey:@"end_time"];
[self.timer startGCDTimer:1 delegate:self];
}
//
- (void)BlindEndAction {
_blindShowV.leftTimeL.text = @"0:00";
_blindShowV.hidden = YES;
}
- (ZWTimer *)timer {
if (!_timer) {
_timer = [[ZWTimer alloc] init];
}
return _timer;
}
#pragma mark -------------------------------------------
- (void)clearRoomMeiliRequest {
[BJHttpTool clear_user_charm_allWithParameters:@{@"rid":C_string(_viewModel.roomInfo.roomId)} success:^(id response) {
[MBProgressHUD showAutoMessage:response[@"msg"]];
} failure:^(NSError *error) {
}];
}
- (BJRoomBaomaiAlert *)userAlert{
if (!_userAlert) {
_userAlert = [[BJRoomBaomaiAlert alloc] initWithRoomModel:_viewModel];
WEAK_SELF
_userAlert.onClickUserBlock = ^(NSString *uid) {
[weakSelf chatView:weakSelf.chatView didClickUserNameWithUserID:uid];
};
}
return _userAlert;
}
#pragma mark ----------------------------------
- (void)onAddTop3AndUsersView {
self.top3View = [[NSBundle mainBundle] loadNibNamed:@"SPRoomTop3View" owner:self options:nil].firstObject;
[self.view addSubview:self.top3View];
WEAK_SELF
[self.top3View dg_Tapped:^{
[weakSelf.view addSubview:weakSelf.bangdanBgView];
}];
[self.top3View mas_makeConstraints:^(MASConstraintMaker *make) {
make.centerY.mas_equalTo(self.customNavigationView);
make.right.equalTo(self.view).offset(-50);
make.size.mas_equalTo(CGSizeMake(75, 34));
}];
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
[self onRequestTop3AndUsersView];
});
}
- (void)onRequestTop3AndUsersView {
NSDictionary *rankParams = @{@"rid":C_string(self.viewModel.roomInfo.roomId), @"type":@(1),@"time":@(1)};
[AFNetworkRequset.shared postRequestWithParams:rankParams Path:@"api/room/get_room_rank" Loading:NO Hud:NO Success:^(id _Nonnull responseDic) {
NSArray *arr = [SPBangDanListModel mj_objectArrayWithKeyValuesArray:responseDic[@"data"][@"list"]];
self.top3View.dataArray = arr;
} Failure:^(id _Nonnull errorData) {
}];
}
- (void)onCreateBangdanBgView {
self.bangdanVC = [[YYRoomRankVC alloc] init];
self.bangdanVC.rid = self.viewModel.roomInfo.roomId;
[self addChildViewController:self.bangdanVC];
self.bangdanBgView = [[UIView alloc] initWithFrame:[UIScreen mainScreen].bounds];
self.bangdanVC.view.frame = CGRectMake(0, ScreenHeight-521, ScreenWidth, 521);
[self.bangdanBgView addSubview:self.bangdanVC.view];
UIImageView *touchImgV = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, ScreenWidth, ScreenHeight-521)];
[self.bangdanBgView addSubview:touchImgV];
touchImgV.backgroundColor = [kBlackColor colorWithAlphaComponent:0.5];
touchImgV.userInteractionEnabled = YES;
WEAK_SELF
[touchImgV dg_Tapped:^{
[weakSelf.bangdanBgView removeFromSuperview];
}];
self.bangdanVC.onDismissBlock = ^{
[weakSelf.bangdanBgView removeFromSuperview];
};
}
- (UIButton *)applyUpBtn {
if (!_applyUpBtn) {
_applyUpBtn = [UIButton buttonWithType:UIButtonTypeCustom];
[_applyUpBtn setImage:ImageNamed(@"room_applyUp") forState:UIControlStateNormal];
WEAK_SELF
[_applyUpBtn buttonAddTaget:^(UIButton *btn) {
weakSelf.applyUpNumLab.hidden = YES;
weakSelf.jyApplyUpV.viewModel = weakSelf.viewModel;
[weakSelf.view addSubview:weakSelf.jyApplyUpV];
} forControlEvents:UIControlEventTouchUpInside];
}
return _applyUpBtn;
}
- (UILabel *)applyUpNumLab {
if (!_applyUpNumLab) {
_applyUpNumLab = [ControlCreator createLabel:nil rect:CGRectZero text:@"0" font:YBBoldFont(10) color:kWhiteColor backguoundColor:kRedColor align:NSTextAlignmentCenter lines:1];
_applyUpNumLab.hidden = YES;
_applyUpNumLab.layer.cornerRadius = 8;
_applyUpNumLab.layer.masksToBounds = YES;
}
return _applyUpNumLab;
}
- (YYJYApplyUpView *)jyApplyUpV {
if (!_jyApplyUpV) {
_jyApplyUpV = LoadNib(@"YYJYApplyUpView");
_jyApplyUpV.frame = [UIScreen mainScreen].bounds;
WEAK_SELF
_jyApplyUpV.onClickUserBlock = ^(NSString *uid) {
[weakSelf chatView:weakSelf.chatView didClickUserNameWithUserID:uid];
};
}
return _jyApplyUpV;
}
#pragma mark -------------
- (void)onCreateXinrenViews {
if (self.viewModel.roomInfo.is_xinren != 1) {
return;
}
_xrTop3View = LoadNib(@"YYXinrenTop3View");
_xrTop3View.hidden = YES;
[self.view addSubview:_xrTop3View];
[_xrTop3View mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.mas_equalTo(12);
make.top.mas_equalTo(yb_NavigationBar_H+80);
make.width.mas_equalTo(114);
make.height.mas_equalTo(138);
}];
NSDictionary *params = @{@"rid":self.viewModel.roomInfo.roomId};
[[AFNetworkRequset shared] postRequestWithParams:params Path:@"/api/new_room/get_room_new_auction_rank" Loading:NO Hud:NO Success:^(id _Nonnull responseDic) {
NSArray *arr = [YYXinrenTop3Model mj_objectArrayWithKeyValuesArray:responseDic[@"data"][@"list"]];
self.xrTop3View.dataArray = arr;
} Failure:^(id _Nonnull errorData) {
}];
}
- (void)onXRQianyueResult:(NSDictionary *)dict {
NSString *chujiaUid = [dict[@"auction_user_info"] safeStringForKey:@"uid"];
if ([chujiaUid integerValue] == [BJUserManager.userInfo.uid integerValue]) {
YYQianyueSelfAlert *view = LoadNib(@"YYQianyueSelfAlert");
view.frame = [UIScreen mainScreen].bounds;
view.dataDict = dict;
[MainWindow() addSubview:view];
}else {
YYQianyueSuccessAlert *view = LoadNib(@"YYQianyueSuccessAlert");
view.frame = [UIScreen mainScreen].bounds;
view.dataDict = dict;
[MainWindow() addSubview:view];
}
}
#pragma mark -------------
- (void)onCreatePaimaiViews {
if (self.viewModel.roomInfo.is_paimai != 1) {
return;
}
[self.chatView mas_updateConstraints:^(MASConstraintMaker *make) {
make.top.equalTo(self.customNavigationView.mas_bottom).offset(425);
}];
}
- (void)onPMPaimaiResult:(NSDictionary *)dict {
NSString *chujiaUid = [dict[@"auction_user_info"] safeStringForKey:@"uid"];
if ([chujiaUid integerValue] == [BJUserManager.userInfo.uid integerValue]) {
YYPMSelfAlert *view = LoadNib(@"YYPMSelfAlert");
view.frame = [UIScreen mainScreen].bounds;
view.dataDict = dict;
[MainWindow() addSubview:view];
}else {
YYPMSuccessAlert *view = LoadNib(@"YYPMSuccessAlert");
view.frame = [UIScreen mainScreen].bounds;
view.dataDict = dict;
[MainWindow() addSubview:view];
}
}
- (void)onPMAutoChooseAlert {
if ([self.viewModel currentParticipantInfo].position == 1) {
YYPMPickRelationView *view = LoadNib(@"YYPMPickRelationView");
view.frame = [UIScreen mainScreen].bounds;
[MainWindow() addSubview:view];
view.rid = self.viewModel.roomInfo.roomId;
}
}
#pragma mark ----------------------------------
- (void)onJuageJiaoyouRoom {
if (self.viewModel.roomInfo.is_dating != 1) {
return;
}
[self.chatView mas_updateConstraints:^(MASConstraintMaker *make) {
make.top.equalTo(self.customNavigationView.mas_bottom).offset(460);
}];
}
- (YYJYRelationView *)jyRelationV {
if (!_jyRelationV) {
_jyRelationV = LoadNib(@"YYJYRelationView");
_jyRelationV.viewModel = self.viewModel;
_jyRelationV.frame = [UIScreen mainScreen].bounds;
}
return _jyRelationV;
}
- (YYJYSimiRoomView *)simiRoomV {
if (!_simiRoomV) {
_simiRoomV = LoadNib(@"YYJYSimiRoomView");
_simiRoomV.frame = [UIScreen mainScreen].bounds;
[_simiRoomV.bgImgV sd_setImageWithURL:URL(_viewModel.roomInfo.room_background_image) placeholderImage:ImageNamed(@"room_background")];
WEAK_SELF
_simiRoomV.onRollTouziBlock = ^{
[weakSelf.viewModel bj_requestSimiTouziData];
};
_simiRoomV.onChangeSimiBlock = ^(BOOL close) {
weakSelf.viewModel.roomInfo.is_send_simiMsg = close ? 2 : 1;
};
}
return _simiRoomV;
}
#pragma mark ----------------------------------
- (void)onJuageXiangqinRoomView {
if (self.viewModel.roomInfo.is_xiangqin != 1) {
return;
}
[self.chatView mas_updateConstraints:^(MASConstraintMaker *make) {
if (APPW > 414) {
make.top.equalTo(self.customNavigationView.mas_bottom).offset(500);
}else {
make.top.equalTo(self.customNavigationView.mas_bottom).offset(450);
}
}];
// k
BOOL haveAuth = self.viewModel.isRoomOwner || self.viewModel.isRoomAdministrator;
if (haveAuth) {
_room_noticeBtn.frame = CGRectMake(80, yb_NavigationBar_H+15, 50, 25);
}else {
_room_noticeBtn.frame = CGRectMake(16, yb_NavigationBar_H+15, 50, 25);
}
self.descBtn.hidden = NO;
_descBtn.frame = CGRectMake(self.room_noticeBtn.right+15, yb_NavigationBar_H+15, 70, 25);
}
- (void)participantsAreaXqKTVStartArea:(RCMicParticipantsArea *)participants withStage:(NSInteger)stage;
{
if (stage == 2){
[_lrcView removeFromSuperview];
_lrcView = nil;
_lrcView = [[AgoraLrcScoreView alloc] initWithDelegate:self logDelegate:self];
_lrcView.frame = CGRectMake(75, yb_NavigationBar_H+200, ScreenWidth-75*2, 80);
_lrcView.downloadDelegate = self;
_lrcView.layer.cornerRadius = 5;
_lrcView.backgroundColor = HEXCOLORA(0x000000, 0.6);
[self.view addSubview:_lrcView];
[_lrcView mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.equalTo(self.chatView).offset(20);
make.top.equalTo(self.chatView).offset(20);
make.width.mas_equalTo(260);
make.height.mas_equalTo(120);
}];
AgoraLrcScoreConfigModel *config = [[AgoraLrcScoreConfigModel alloc] init];
config.isHiddenScoreView = YES;
AgoraScoreItemConfigModel *scoreConfig = [[AgoraScoreItemConfigModel alloc] init];
config.scoreConfig = scoreConfig;
AgoraLrcConfigModel *lrcConfig = [[AgoraLrcConfigModel alloc] init];
config.lrcConfig = lrcConfig;
lrcConfig.tipsColor = mainDeepColor;
lrcConfig.separatorLineColor = kWhiteColor;
lrcConfig.lrcNormalColor = kWhiteColor;
lrcConfig.lrcHighlightColor = mainDeepColor;
lrcConfig.lrcDrawingColor = mainDeepColor;
lrcConfig.lrcFontSize = YBMediumFont(13);
lrcConfig.lrcHighlightFontSize = YBMediumFont(15);
lrcConfig.maxWidth = 260;
lrcConfig.lrcTopAndBottomMargin = 5;
lrcConfig.waitingViewSize = 6;
lrcConfig.isHiddenBottomMask = YES;
lrcConfig.isHiddenWatitingView = YES;
_lrcView.config = config;
// _ktvTiaoyinBtn = [ControlCreator createButton:self.view rect:CGRectZero text:@"" font:YBBoldFont(11) color:kWhiteColor backguoundColor:nil imageName:@"xq_kgeset_image" target:self action:@selector(onKTVTiaoyin)];
//
// [_ktvTiaoyinBtn mas_makeConstraints:^(MASConstraintMaker *make) {
// make.right.mas_equalTo(-16);
// make.top.equalTo(self.participantsArea).offset(165);
// make.width.mas_equalTo(58);
// make.height.mas_equalTo(22);
// }];
[self.songListV onShow];
}else{
[_ktvTiaoyinBtn removeFromSuperview];
[_lrcView removeFromSuperview];
_ktvTiaoyinBtn = nil;
_lrcView = nil;
// [self.viewModel ktv_SelfChangeSong];
[self.viewModel ktv_DestoryKtvPlayer];
self.viewModel.playPosition = 0;
self.viewModel.isHechang = NO;
}
}
- (void)participantsAreaXqSet:(RCMicParticipantsArea *)participants withStage:(NSInteger)stage {
[self.songSettingV onShow];
}
- (void)xiangqinHechangLrcView
{
if (_lrcView){
return;
}
_lrcView = [[AgoraLrcScoreView alloc] initWithDelegate:self logDelegate:self];
_lrcView.frame = CGRectMake(75, yb_NavigationBar_H+200, ScreenWidth-75*2, 80);
_lrcView.downloadDelegate = self;
_lrcView.layer.cornerRadius = 5;
_lrcView.backgroundColor = HEXCOLORA(0x000000, 0.6);
[self.view addSubview:_lrcView];
[_lrcView mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.equalTo(self.chatView).offset(20);
make.top.equalTo(self.chatView).offset(20);
make.width.mas_equalTo(260);
make.height.mas_equalTo(120);
}];
AgoraLrcScoreConfigModel *config = [[AgoraLrcScoreConfigModel alloc] init];
config.isHiddenScoreView = YES;
AgoraScoreItemConfigModel *scoreConfig = [[AgoraScoreItemConfigModel alloc] init];
config.scoreConfig = scoreConfig;
AgoraLrcConfigModel *lrcConfig = [[AgoraLrcConfigModel alloc] init];
config.lrcConfig = lrcConfig;
lrcConfig.tipsColor = mainDeepColor;
lrcConfig.separatorLineColor = kWhiteColor;
lrcConfig.lrcNormalColor = kWhiteColor;
lrcConfig.lrcHighlightColor = mainDeepColor;
lrcConfig.lrcDrawingColor = mainDeepColor;
lrcConfig.lrcFontSize = YBMediumFont(13);
lrcConfig.lrcHighlightFontSize = YBMediumFont(15);
lrcConfig.maxWidth = 260;
lrcConfig.lrcTopAndBottomMargin = 5;
lrcConfig.waitingViewSize = 6;
lrcConfig.isHiddenBottomMask = YES;
lrcConfig.isHiddenWatitingView = YES;
_lrcView.config = config;
}
- (void)participantsAreaXiangqinStageBimai
{
RCMicMicrophoneState micState = RCMicMicrophoneStateSilent;
[self setMicrophoneState:micState];
}
#pragma mark ----------------------------------
- (void)onJuageXiangqinJiubaRoom {
if (self.viewModel.roomInfo.is_blind_date != 1) {
return;
}
[self.chatView mas_updateConstraints:^(MASConstraintMaker *make) {
make.top.equalTo(self.customNavigationView.mas_bottom).offset(420);
}];
}
#pragma mark ----------------------------------
- (void)onRequestPendantGiftData {
NSDictionary *params = @{@"rid":C_string(self.viewModel.roomInfo.roomId)};
[[AFNetworkRequset shared] postRequestWithParams:params Path:@"/api/dating_room/get_room_pendant_gift_info" Loading:NO Hud:NO Success:^(id _Nonnull responseDic) {
NSInteger uid = [responseDic[@"data"][@"user_info"] safeIntForKey:@"uid"];
if (uid > 0) {
self.pendantGiftV.dataDict = responseDic[@"data"];
[self.view addSubview:self.pendantGiftV];
}
} Failure:^(id _Nonnull errorData) {
}];
}
- (YYJYPendantGiftView *)pendantGiftV {
if (!_pendantGiftV) {
_pendantGiftV = LoadNib(@"YYJYPendantGiftView");
_pendantGiftV.frame = CGRectMake(0, yb_NavigationBar_H+340, 150, 180);
}
return _pendantGiftV;
}
#pragma mark - mp4 hwd delegate
- (void)vapWrap_viewDidStopPlayMP4:(NSInteger)lastFrameIndex view:(VAPView *)container {
//线
dispatch_async(dispatch_get_main_queue(),^{
if (container == self.jySimiVapView) {
[self.jySimiVapView removeFromSuperview];
}else if (container == self.luckyVapView) {
[self.luckyVapView removeFromSuperview];
}
});
}
- (QGVAPWrapView *)jySimiVapView {
if (!_jySimiVapView) {
_jySimiVapView = [[QGVAPWrapView alloc] initWithFrame:[UIScreen mainScreen].bounds];
_jySimiVapView.hwd_Delegate = self;
_jySimiVapView.contentMode = QGVAPWrapViewContentModeScaleToFill;
_jySimiVapView.userInteractionEnabled = NO;
// _jySimiVapView.autoDestoryAfterFinish = NO;
}
return _jySimiVapView;
}
#pragma mark -------KUI------
- (void)onCreateKTVViews {
if (self.viewModel.roomInfo.is_song != 1) {
return;
}
[self.chatView mas_updateConstraints:^(MASConstraintMaker *make) {
make.top.equalTo(self.customNavigationView.mas_bottom).offset(460);
}];
_ktvStartBtn = [ControlCreator createButton:self.view rect:CGRectZero text:nil font:nil color:nil backguoundColor:nil imageName:@"ktv_host_start" target:self action:@selector(onKTVStart)];
_ktvNextBtn = [ControlCreator createButton:self.view rect:CGRectMake(0, 0, 45, 80) text:@"" font:YBMediumFont(13) color:kWhiteColor backguoundColor:nil imageName:@"ktv_qiege" target:self action:@selector(onKTVNext)];
_ktvNextBtn.hidden = YES;
// [_ktvNextBtn ba_button_setButtonLayoutType:BAKit_ButtonLayoutTypeCenterImageTop padding:3];
// [self.view addSubview:self.ktvChujiaInfoV];
[self.view addSubview:self.ktvCenterV];
_ktvTiaoyinBtn = [ControlCreator createButton:self.view rect:CGRectZero text:nil font:nil color:nil backguoundColor:nil imageName:@"ktv_tiaoyin" target:self action:@selector(onKTVTiaoyin)];
_ktvDiangeBtn = [ControlCreator createButton:self.view rect:CGRectZero text:nil font:nil color:nil backguoundColor:nil imageName:@"ktv_diange" target:self action:@selector(onKTVDiange)];
_ktvDiangeBtn.hidden = YES;
[_ktvStartBtn mas_makeConstraints:^(MASConstraintMaker *make) {
make.centerX.mas_equalTo(0);
make.top.mas_equalTo(yb_NavigationBar_H+10);
}];
[_ktvNextBtn mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.mas_equalTo(45);
make.top.mas_equalTo(yb_NavigationBar_H+100);
make.size.mas_equalTo(CGSizeMake(50, 50));
}];
// [self.ktvChujiaInfoV mas_makeConstraints:^(MASConstraintMaker *make) {
// make.left.mas_equalTo(12);
// make.top.mas_equalTo(yb_NavigationBar_H+45);
// make.size.mas_equalTo(CGSizeMake(114, 190));
// }];
[self.ktvCenterV mas_makeConstraints:^(MASConstraintMaker *make) {
make.centerX.mas_equalTo(0);
make.top.mas_equalTo(yb_NavigationBar_H+10);
make.size.mas_equalTo(CGSizeMake(120, 220));
}];
[_ktvTiaoyinBtn mas_makeConstraints:^(MASConstraintMaker *make) {
make.right.mas_equalTo(-15);
make.bottom.equalTo(self.applyUpBtn.mas_top).offset(-8);
}];
[_ktvDiangeBtn mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.centerX.equalTo(_ktvCenterV);
}];
_lrcView = [[AgoraLrcScoreView alloc] initWithDelegate:self logDelegate:self];
_lrcView.hidden = YES;
_lrcView.frame = CGRectMake(75, yb_NavigationBar_H+200, ScreenWidth-75*2, 80);
_lrcView.downloadDelegate = self;
_lrcView.layer.cornerRadius = 5;
[self.view addSubview:_lrcView];
AgoraLrcScoreConfigModel *config = [[AgoraLrcScoreConfigModel alloc] init];
config.isHiddenScoreView = YES;
AgoraScoreItemConfigModel *scoreConfig = [[AgoraScoreItemConfigModel alloc] init];
config.scoreConfig = scoreConfig;
AgoraLrcConfigModel *lrcConfig = [[AgoraLrcConfigModel alloc] init];
config.lrcConfig = lrcConfig;
lrcConfig.tipsColor = mainDeepColor;
lrcConfig.separatorLineColor = kWhiteColor;
lrcConfig.lrcNormalColor = kWhiteColor;
lrcConfig.lrcHighlightColor = mainDeepColor;
lrcConfig.lrcDrawingColor = mainDeepColor;
lrcConfig.lrcFontSize = YBMediumFont(13);
lrcConfig.lrcHighlightFontSize = YBMediumFont(15);
lrcConfig.maxWidth = ScreenWidth-75*2;
lrcConfig.lrcTopAndBottomMargin = 5;
lrcConfig.waitingViewSize = 6;
lrcConfig.isHiddenBottomMask = YES;
lrcConfig.isHiddenWatitingView = YES;
_lrcView.config = config;
// UIView *blackView = [[UIView alloc] initWithFrame:_lrcView.bounds];
// blackView.backgroundColor = HEXCOLORA(0x000000, 0.2);
// blackView.userInteractionEnabled = NO;
// [_lrcView insertSubview:blackView atIndex:0];
// k
BOOL haveAuth = self.viewModel.isRoomOwner || self.viewModel.isRoomAdministrator;
if (haveAuth) {
_room_noticeBtn.frame = CGRectMake(80, yb_NavigationBar_H+15, 50, 25);
}else {
_room_noticeBtn.frame = CGRectMake(16, yb_NavigationBar_H+15, 50, 25);
}
}
//
- (void)downloadLrcFinishedWithUrl:(NSString *)url {
[_lrcView start];
}
- (NSTimeInterval)getPlayerCurrentTime {
return _viewModel.playPosition;
}
- (void)onKTVStart {
NSString *urlStr = @"/api/ktv_room/open_auction";
NSDictionary *params = @{@"rid":C_string(self.viewModel.roomInfo.roomId)};
[[AFNetworkRequset shared] postRequestWithParams:params Path:urlStr Loading:YES Hud:YES Success:^(id _Nonnull responseDic) {
} Failure:^(id _Nonnull errorData) {
}];
}
- (void)onKTVNext {
// [self.viewModel ktv_SelfChangeSong];
NSString *urlStr = @"/api/ktv_room/finish_user_song";
NSDictionary *params = @{@"rid":C_string(self.viewModel.roomInfo.roomId), @"user_id":C_string(self.ktvCurrentUid)};
[[AFNetworkRequset shared] postRequestWithParams:params Path:urlStr Loading:YES Hud:YES Success:^(id _Nonnull responseDic) {
} Failure:^(id _Nonnull errorData) {
}];
}
- (void)onKTVTiaoyin {
[self.songSettingV onShow];
}
- (void)onKTVDiange {
[self.songListV onShow];
}
//KUI
- (void)onUpdateKTVStatusWith:(NSDictionary *)dataDict {
self.ktvCurrentUid = [dataDict[@"room_song_info"][@"user_info"] safeStringForKey:@"uid"];
self.ktvZhizuoUid = [dataDict[@"room_song_info"][@"producer_info"] safeStringForKey:@"uid"];
_lrcView.hidden = YES;
//K 1 2 3
NSInteger status = [dataDict safeIntForKey:@"room_song_status"];
self.viewModel.songCurrentUid = self.ktvCurrentUid;
self.viewModel.songCurrentStatus = status;
if (status == 1) {
_ktvStartBtn.hidden = ![self.viewModel isRoomHost];
_ktvNextBtn.hidden = YES;
// _ktvChujiaInfoV.hidden = YES;
_ktvCenterV.hidden = YES;
}else if (status == 2) {
_ktvStartBtn.hidden = YES;
_ktvNextBtn.hidden = ![self.viewModel isRoomHost];
// _ktvChujiaInfoV.hidden = YES;
_ktvCenterV.hidden = NO;
[_ktvCenterV onUpdateUIWith:dataDict isHost:[self.viewModel isRoomHost]];
if ([self.ktvCurrentUid integerValue] == [BJUserManager.userInfo.uid integerValue]) {
_lrcView.hidden = NO;
[_viewModel ktv_UpdateSelfSong];
}
}else if (status == 3) {
_ktvStartBtn.hidden = YES;
_ktvNextBtn.hidden = ![self.viewModel isRoomHost];
// _ktvChujiaInfoV.hidden = NO;
_ktvCenterV.hidden = NO;
// _ktvChujiaInfoV.dataDict = dataDict;
[_ktvCenterV onUpdateUIWith:dataDict isHost:[self.viewModel isRoomHost]];
if ([self.ktvCurrentUid integerValue] == [BJUserManager.userInfo.uid integerValue]) {
//
[_viewModel ktv_DestoryKtvPlayer];
}
}
NSDictionary *singInfo = dataDict[@"room_song_info"][@"user_info"];
if ([singInfo safeIntForKey:@"uid"] == [BJUserManager.userInfo.uid integerValue]) {
_ktvTiaoyinBtn.hidden = NO;
}else {
_ktvTiaoyinBtn.hidden = YES;
}
if (status != 3 && [self.viewModel currentParticipantInfo].position >= 1 && [self.viewModel currentParticipantInfo].position <= 4) {
_ktvDiangeBtn.hidden = NO;
} else {
_ktvDiangeBtn.hidden = YES;
}
[self.participantsArea onKTVChangeStatus:status > 1];
}
- (void)onKTVChujia {
YYRoomChujiaAlert *view = LoadNib(@"YYRoomChujiaAlert");
view.frame = [UIScreen mainScreen].bounds;
[MainWindow() addSubview:view];
view.rid = self.viewModel.roomInfo.roomId;
view.is_ktv = YES;
view.ktvCurrentUid = self.ktvCurrentUid;
}
- (void)onKTVEnd {
NSString *urlStr = @"/api/ktv_room/finish_auction";
NSDictionary *params = @{@"rid":C_string(self.viewModel.roomInfo.roomId), @"user_id":C_string(self.ktvCurrentUid)};
[[AFNetworkRequset shared] postRequestWithParams:params Path:urlStr Loading:YES Hud:YES Success:^(id _Nonnull responseDic) {
} Failure:^(id _Nonnull errorData) {
}];
}
- (YYKTVChujiaInfoView *)ktvChujiaInfoV {
if (!_ktvChujiaInfoV) {
_ktvChujiaInfoV = LoadNib(@"YYKTVChujiaInfoView");
_ktvChujiaInfoV.hidden = YES;
}
return _ktvChujiaInfoV;
}
- (YYKTVCenterView *)ktvCenterV {
if (!_ktvCenterV) {
_ktvCenterV = LoadNib(@"YYKTVCenterView");
_ktvCenterV.hidden = YES;
WEAK_SELF
[_ktvCenterV.chujiaBtn buttonAddTaget:^(UIButton *btn) {
[weakSelf onKTVChujia];
} forControlEvents:UIControlEventTouchUpInside];
[_ktvCenterV.hostChujiaBtn buttonAddTaget:^(UIButton *btn) {
[weakSelf onKTVChujia];
} forControlEvents:UIControlEventTouchUpInside];
[_ktvCenterV.hostEndBtn buttonAddTaget:^(UIButton *btn) {
[weakSelf onKTVEnd];
} forControlEvents:UIControlEventTouchUpInside];
[_ktvCenterV.singAvatarImgV dg_Tapped:^{
if ([weakSelf.ktvCurrentUid integerValue] > 0) {
[weakSelf chatView:weakSelf.chatView didClickUserNameWithUserID:weakSelf.ktvCurrentUid];
}
}];
[_ktvCenterV.zhizuoAvatarImgV dg_Tapped:^{
if ([weakSelf.ktvZhizuoUid integerValue] > 0) {
[UIViewController goUserMainpageWith:weakSelf.ktvZhizuoUid withRid:@""];
}
}];
}
return _ktvCenterV;
}
- (RoomSongView *)songListV {
if (!_songListV) {
_songListV = [[RoomSongView alloc] initWithFrame:CGRectMake(0, 0, ScreenWidth, ScreenHeight)];
_songListV.viewModel = self.viewModel;
}
return _songListV;
}
- (RoomSongSettingView *)songSettingV {
if (!_songSettingV) {
_songSettingV = LoadNib(@"RoomSongSettingView");
_songSettingV.frame = [UIScreen mainScreen].bounds;
_songSettingV.viewModel = self.viewModel;
}
return _songSettingV;
}
#pragma mark ---------------
- (void)onRequestCurrentLaba {
NSDictionary *rankParams = @{};
[AFNetworkRequset.shared postRequestWithParams:rankParams Path:@"/api/user_top_line/get_user_top_line_list" Loading:NO Hud:NO Success:^(id _Nonnull responseDic) {
[self onReceiveLaba:responseDic[@"data"]];
} Failure:^(id _Nonnull errorData) {
}];
}
- (void)onReceiveLaba:(NSDictionary *)dataDict {
NSLog(@"dataDict : %@",dataDict);
SEARoomHeadlineModel *model = [SEARoomHeadlineModel mj_objectWithKeyValues:dataDict];
self.endTime = model.over_time;
[self.GBTimer startGCDTimer:1 delegate:self];
[self.view addSubview:self.headlineShowView];
self.headlineShowView.model = model;
_headlineShowView.hidden = NO;
}
- (void)onTimerFired:(ZWTimer *)timer {
if (timer == self.GBTimer) {
self.endTime = self.endTime-1;
if (self.endTime<=0){
[self.GBTimer stopTimer];
[self.headlineShowView removeFromSuperview];
}
}else if (timer == self.timer) {
self.leftSecond -= 1;
if (self.leftSecond < 0) {
self.leftSecond = 0;
[self.timer stopTimer];
}
self.blindShowV.leftTimeL.text = [NSString stringWithFormat:@"剩余时间:%02ld:%02ld", self.leftSecond/60, self.leftSecond%60];
}
}
- (ZWTimer *)GBTimer {
if (!_GBTimer) {
_GBTimer = [[ZWTimer alloc] init];
}
return _GBTimer;
}
- (SEARoomHeadlineShowView *)headlineShowView
{
if (!_headlineShowView){
_headlineShowView = LoadNib(@"SEARoomHeadlineShowView");
_headlineShowView.hidden = YES;
_headlineShowView.frame = CGRectMake(0, yb_NavigationBar_H+380, 300, 60);
WEAK_SELF;
_headlineShowView.goBlock = ^{
[weakSelf showRoomHeadlinePublishView];
};
_headlineShowView.caiBlock = ^(NSString * _Nonnull rid) {
if (![rid isEqualToString:weakSelf.viewModel.roomInfo.roomId]){
[UIViewController goMicRoomWithRid:rid withPwd:@""];
}else{
[HelpPageDefine showMessage:@"当前房间无需跳转"];
}
};
}
return _headlineShowView;
}
//广
- (void)showRoomHeadlinePublishView
{
SEARoomHeadlinesPublishView *publishv = LoadNib(@"SEARoomHeadlinesPublishView");
publishv.frame = CGRectMake(0, 0, APPW, APPH);
publishv.rid = self.viewModel.roomInfo.roomId;
[[UIViewController currentViewController].view addSubview:publishv];
[publishv sheetViewforViewAppear];
publishv.topUpButtonClickBlock = ^{
[UIViewController goRechageCtrl];
};
}
#pragma mark --------- 西 ----------
- (void)onSudJuageGameRoom {
if (self.viewModel.roomInfo.is_Game == 1) {
[self onSudCreateGameUI];
// SudMDPWrapper
[self createSudMGPWrapper];
if (self.viewModel.roomInfo.game_status == 1) {
[self onSudLoginGame];
}
}
}
- (void)onSudCreateGameUI {
self.gameView = [[UIView alloc] init];
[self.view insertSubview:self.gameView aboveSubview:self.backgroundView];
[self.gameView mas_makeConstraints:^(MASConstraintMaker *make) {
make.edges.equalTo(self.view);
}];
if (self.viewModel.isRoomOwner || self.viewModel.roomInfo.is_host == 1) {
UIButton *pickBtn = [ControlCreator createButton:self.view rect:CGRectZero text:@"选择游戏" font:YBMediumFont(10) color:kBlackColor backguoundColor:[kWhiteColor colorWithAlphaComponent:0.1] imageName:nil target:self action:@selector(onSudHostPickGame)];
pickBtn.layer.cornerRadius = 10;
pickBtn.backgroundColor = [UIColor bm_colorGradientChangeWithSize:CGSizeMake(60, 20) direction:(FXGradientChangeDirectionHorizontal) startColor:mainLightColor endColor:mainDeepColor];
UIButton *endBtn = [ControlCreator createButton:self.view rect:CGRectZero text:@"关闭游戏" font:YBMediumFont(10) color:kBlackColor backguoundColor:[kWhiteColor colorWithAlphaComponent:0.1] imageName:nil target:self action:@selector(onSudHostEndGame)];
endBtn.layer.cornerRadius = 10;
endBtn.backgroundColor = [UIColor bm_colorGradientChangeWithSize:CGSizeMake(60, 20) direction:(FXGradientChangeDirectionHorizontal) startColor:mainLightColor endColor:mainDeepColor];
[endBtn mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.mas_equalTo(yb_NavigationBar_H+20);
make.right.mas_equalTo(-16-60-10);
make.size.mas_equalTo(CGSizeMake(60, 20));
}];
[pickBtn mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.equalTo(endBtn);
make.right.equalTo(endBtn.mas_left).offset(-10);
make.size.mas_equalTo(CGSizeMake(60, 20));
}];
}
UIButton *pickBtn = [ControlCreator createButton:self.view rect:CGRectZero text:@"隐藏麦位" font:YBMediumFont(10) color:kBlackColor backguoundColor:[kWhiteColor colorWithAlphaComponent:0.1] imageName:nil target:self action:@selector(hiddenParticipantsAreaMethod:)];
[pickBtn setTitle:@"显示麦位" forState:(UIControlStateSelected)];
pickBtn.layer.cornerRadius = 10;
pickBtn.backgroundColor = [UIColor bm_colorGradientChangeWithSize:CGSizeMake(60, 20) direction:(FXGradientChangeDirectionHorizontal) startColor:mainLightColor endColor:mainDeepColor];
[pickBtn mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.mas_equalTo(yb_NavigationBar_H+20);
make.right.mas_equalTo(-16);
make.size.mas_equalTo(CGSizeMake(60, 20));
}];
//
[self.participantsArea mas_remakeConstraints:^(MASConstraintMaker *make) {
make.top.equalTo(self.customNavigationView.mas_bottom).offset(40);
make.left.right.mas_equalTo(0);
make.height.mas_equalTo(100);
}];
// [self.participantsArea onChangeGameUI];
//
BOOL haveAuth = self.viewModel.isRoomOwner || self.viewModel.isRoomAdministrator;
if (haveAuth) {
_room_noticeBtn.frame = CGRectMake(80, yb_NavigationBar_H+15, 50, 25);
}else {
_room_noticeBtn.frame = CGRectMake(16, yb_NavigationBar_H+15, 50, 25);
}
}
- (void)hiddenParticipantsAreaMethod:(UIButton *)btn
{
btn.selected = !btn.selected;
self.participantsArea.hidden = self.publicSelectView.hidden = !self.participantsArea.hidden;
}
- (void)onSudHostPickGame {
YYRoomGamePickView *view = LoadNib(@"YYRoomGamePickView");
view.frame = [UIScreen mainScreen].bounds;
[MainWindow() addSubview:view];
WEAK_SELF
view.onPickGameBlock = ^(NSString * _Nonnull gameId) {
weakSelf.viewModel.roomInfo.game_id = gameId;
[weakSelf onSudHostStartGame];
};
}
- (void)onSudHostStartGame {
NSDictionary *paramDict = @{@"rid":C_string(_viewModel.roomInfo.roomId), @"game_id":C_string(_viewModel.roomInfo.game_id)};
[RCMicHTTP requestWithHTTPMethod:RCMicHTTPMethodPost URLString:@"/api/room/room_game_start" parameters:paramDict response:^(RCMicHTTPResult *result) {
if (result.errorCode == 200) {
[SVProgressHUD showSuccessWithStatus:result.message];
} else {
[SVProgressHUD showInfoWithStatus:result.message];
}
}];
}
- (void)onSudHostEndGame {
NSDictionary *paramDict = @{@"rid":C_string(_viewModel.roomInfo.roomId), @"game_id":C_string(_viewModel.roomInfo.game_id)};
[RCMicHTTP requestWithHTTPMethod:RCMicHTTPMethodPost URLString:@"/api/room/room_game_end" parameters:paramDict response:^(RCMicHTTPResult *result) {
if (result.errorCode == 200) {
[SVProgressHUD showSuccessWithStatus:result.message];
} else {
[SVProgressHUD showInfoWithStatus:result.message];
}
}];
}
- (void)onSudLoginGame {
// SudMGP
SudMGPLoadConfigModel *sudGameConfigModel = [[SudMGPLoadConfigModel alloc] init];
sudGameConfigModel.gameId = [self.viewModel.roomInfo.game_id integerValue];
sudGameConfigModel.roomId = self.viewModel.roomInfo.roomId;
sudGameConfigModel.language = @"zh-CN";
sudGameConfigModel.gameView = self.gameView;
sudGameConfigModel.userId = BJUserManager.userInfo.uid;
self.sudMGPLoadConfigModel = sudGameConfigModel;
//
if (self.sudMGPLoadConfigModel.gameId > 0) {
[self loginGame:self.sudMGPLoadConfigModel];
[self onSudUpdateChatUI];
}
}
- (void)onSudLogoutGame {
[self logoutGame];
[self onSudUpdateChatUI];
}
- (void)onSudUpdateChatUI {
if (self.viewModel.roomInfo.is_Game != 1) {
return;
}
if (self.viewModel.roomInfo.game_status == 1) {
[self.chatView mas_updateConstraints:^(MASConstraintMaker *make) {
make.top.equalTo(self.customNavigationView.mas_bottom).offset(APPW/375*540);
}];
}else {
[self.chatView mas_updateConstraints:^(MASConstraintMaker *make) {
make.top.equalTo(self.customNavigationView.mas_bottom).offset(305);
}];
}
}
- (void)onUpdateGameMsg:(NSString *)str {
[self.viewModel bj_sendSudGameMsg:str];
}
- (BOOL)onGetIsRoomOwner {
return [self.viewModel isRoomOwner];
}
- (void)setGameBanMic:(BOOL)gameBanMic {
_gameBanMic = gameBanMic;
_viewModel.gameBanMic = gameBanMic;
}
- (void)setGameBanSpeaker:(BOOL)gameBanSpeaker {
_gameBanSpeaker = gameBanSpeaker;
_viewModel.gameBanSpeaker = gameBanSpeaker;
}
- (void)onChangeGameMic:(BOOL)open {
[self.viewModel setUseMicrophone:open];
}
- (void)onChangeGameSpeaker:(BOOL)open {
[self.viewModel setUseSpeaker:open];
}
#pragma mark ---------------
- (void)onChangeSelectChat {
NSArray *indexs = @[];
if ([GVUSER.publicType intValue] == 1) {//
indexs = @[@(self.viewModel.siliaoMsgArray.count - 1)];
}else if ([GVUSER.publicType intValue] == 2) {//@
indexs = @[@(self.viewModel.atMsgArray.count - 1)];
}else if ([GVUSER.publicType intValue] == 3) {//
indexs = @[@(self.viewModel.systemMsgArray.count - 1)];
}else {
indexs = @[@(self.viewModel.messageDataSource.count - 1)];
}
[self.chatView updateTableViewWithType:RCMicMessageChangedTypeReload indexs:indexs];
}
- (RoomMusicView *)musicView {
if (!_musicView) {
_musicView = [[RoomMusicView alloc] initWithViewModel:self.viewModel];
}
return _musicView;
}
#pragma mark --------------------------
- (void)onShowGiftTuopanWith:(NSDictionary *)dict {
TCCustomMessageModel *model = [[TCCustomMessageModel alloc] init];
NSString *identity = [NSString stringWithFormat:@"%@%@%@", dict[@"send_user_info"][@"uid"], dict[@"recived_user_info"][@"uid"], [dict safeStringForKey:@"gift_name"]];
model.imUserId = identity;
model.imUserName = C_string(dict[@"send_user_info"][@"nick_name"]);
model.imUserIconUrl = C_string(dict[@"send_user_info"][@"head_pic"]);
model.giftUrl = [dict safeStringForKey:@"base_image"];
model.msg = [NSString stringWithFormat:@"赠送了 %@", dict[@"recived_user_info"][@"nick_name"]];
model.win_multiple = [dict safeIntForKey:@"win_multiple"];
[self.lianjiView sendGiftWith:model];
}
- (void)onShowLuckyVapWith:(NSDictionary *)dict {
if (GVUSER.closeGiftEffect) {
return;
}
//
NSInteger win_multiple = [dict safeIntForKey:@"win_multiple"];
if (win_multiple >= 30) {//30
NSString *vapStr = @"1_满贯元宝";
if (win_multiple <= 300) {
vapStr = @"1_满贯元宝";
}else if (win_multiple < 500) {
vapStr = @"2_财神到";
}else if (win_multiple < 1000) {
vapStr = @"3_宝藏";
}else if (win_multiple >= 1000) {
vapStr = @"4_恭喜发财";
}
[self.view addSubview:self.luckyVapView];
NSString *path = [[NSBundle mainBundle] pathForResource:vapStr ofType:@"mp4"];
[self.luckyVapView playHWDMP4:path repeatCount:0 delegate:self];
}
}
- (GiftTableView *)lianjiView {
if (!_lianjiView) {
_lianjiView = [[GiftTableView alloc] init];
_lianjiView.backgroundColor = [UIColor clearColor];
_lianjiView.userInteractionEnabled = NO;
[self.view addSubview:_lianjiView];
[_lianjiView mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.right.mas_equalTo(self.view);
make.height.mas_equalTo(140);
make.top.mas_equalTo(self.view).offset(250);
}];
}
return _lianjiView;
}
- (QGVAPWrapView *)luckyVapView {
if (!_luckyVapView) {
_luckyVapView = [[QGVAPWrapView alloc] initWithFrame:[UIScreen mainScreen].bounds];
_luckyVapView.hwd_Delegate = self;
_luckyVapView.contentMode = QGVAPWrapViewContentModeScaleToFill;
_luckyVapView.userInteractionEnabled = NO;
}
return _luckyVapView;
}
//便
- (void)onRankPopUserAlert:(NSString *)uid {
[self chatView:self.chatView didClickUserNameWithUserID:uid];
}
- (void)showCPInfoTxVapWithDict:(NSDictionary *)dict
{
LMCPInRoomVapView *vapView = LoadNib(@"LMCPInRoomVapView");
vapView.frame = CGRectMake(0, 0, APPW, APPH);
[self.view addSubview:vapView];
[vapView playVapWithDict:dict];
}
@end