diff --git a/YuMi.xcodeproj/xcshareddata/xcschemes/YuMi.xcscheme b/YuMi.xcodeproj/xcshareddata/xcschemes/YuMi.xcscheme index 9e3921f5..d258e3d3 100644 --- a/YuMi.xcodeproj/xcshareddata/xcschemes/YuMi.xcscheme +++ b/YuMi.xcodeproj/xcshareddata/xcschemes/YuMi.xcscheme @@ -31,7 +31,7 @@ @@ -233,10 +232,10 @@ } - (void)rechargeButtonAction:(UIButton *)sender { -// XPMineRechargeViewController *vc = [[XPMineRechargeViewController alloc] init]; - XPIAPRechargeViewController * rechargeVC = [[XPIAPRechargeViewController alloc] init]; - rechargeVC.type = @"4"; - [self.navigationController pushViewController:rechargeVC animated:YES]; + XPWebViewController * webVC =[[XPWebViewController alloc] init]; + webVC.url = [NSString stringWithFormat:URLWithType(kThirdPartyPay),@"4",[YYUtility deviceID]]; + webVC.isPush = YES; + [self.navigationController pushViewController:webVC animated:YES]; } #pragma mark - Getters And Setters diff --git a/YuMi/Modules/YMMine/View/IncomeRecord/XPIncomeRecordVC.m b/YuMi/Modules/YMMine/View/IncomeRecord/XPIncomeRecordVC.m index 2cb75fe1..0cd9b15b 100644 --- a/YuMi/Modules/YMMine/View/IncomeRecord/XPIncomeRecordVC.m +++ b/YuMi/Modules/YMMine/View/IncomeRecord/XPIncomeRecordVC.m @@ -12,7 +12,6 @@ #import "XPWebViewController.h" #import "XPExchangeDiamondsVC.h" #import "XPIncomeRecordGoldDetailsVC.h" -#import "XPIAPRechargeViewController.h" ///Present #import "XPIncomeRecordPresent.h" ///Protocol @@ -116,8 +115,9 @@ } case ClickType_Diamond_Pay: { - XPIAPRechargeViewController * webVC =[[XPIAPRechargeViewController alloc] init]; - webVC.type = @"4"; + XPWebViewController * webVC =[[XPWebViewController alloc] init]; + webVC.url = [NSString stringWithFormat:URLWithType(kThirdPartyPay),@"4",[YYUtility deviceID]]; + webVC.isPush = YES; [self.navigationController pushViewController:webVC animated:YES]; break; } @@ -138,16 +138,16 @@ default: { -// NSString * myUid = [AccountInfoStorage instance].getUid; -// if(![self.clanInfo.clan.elderUid isEqualToString:myUid]){ + NSString * myUid = [AccountInfoStorage instance].getUid; + if(![self.clanInfo.clan.elderUid isEqualToString:myUid]){ XPWebViewController * webVC =[[XPWebViewController alloc] init]; webVC.url = URLWithType(kGoldEarningsRecord); [self.navigationController pushViewController:webVC animated:YES]; -// return; -// -// } -// XPIncomeRecordGoldDetailsVC *goldDetailVC = [XPIncomeRecordGoldDetailsVC new]; -// [self.navigationController pushViewController:goldDetailVC animated:YES]; + return; + + } + XPIncomeRecordGoldDetailsVC *goldDetailVC = [XPIncomeRecordGoldDetailsVC new]; + [self.navigationController pushViewController:goldDetailVC animated:YES]; break; } } diff --git a/YuMi/Modules/YMMine/View/Noble/View/XPNobleCenterViewController.m b/YuMi/Modules/YMMine/View/Noble/View/XPNobleCenterViewController.m index bb599888..cf9db609 100644 --- a/YuMi/Modules/YMMine/View/Noble/View/XPNobleCenterViewController.m +++ b/YuMi/Modules/YMMine/View/Noble/View/XPNobleCenterViewController.m @@ -17,8 +17,8 @@ #import "DJDKMIMOMColor.h" #import "ThemeColor+NobleCenter.h" #import "Api+NobleCenter.h" -#import "Api+Main.h" +#import "XPIAPHelper.h" #import "RechargeStorage.h" #import "AccountInfoStorage.h" #import "UIImage+Utils.h" @@ -31,7 +31,6 @@ #import "XPWebViewController.h" #import "XPNobleSettingViewController.h" #import "XPSkillCardPlayerManager.h" -#import "SessionViewController.h" ///P #import "XPNobleCenterPresenter.h" #import "Api+Gift.h" @@ -43,9 +42,6 @@ #import "WalletInfoModel.h" #import "XPNobleCenterPayView.h" #import "XPNobleCenterProtocol.h" -#import "XPIAPRechargeViewController.h" -#import "YuMi-swift.h" -#import "ClientConfig.h" @interface XPNobleCenterViewController () ///分页标题 @property (nonatomic, strong) NSArray *titles; @@ -82,7 +78,6 @@ @property (nonatomic, assign) NSInteger roomUid; @property (nonatomic,strong) WalletInfoModel * infoModel; @property(nonatomic,strong) UIButton *rankBtn; -@property(nonatomic,assign) BOOL pi_IsNative; @end @implementation XPNobleCenterViewController @@ -96,18 +91,19 @@ } - (void)dealloc { - + [XPIAPHelper shareHelper].delegate = nil; } - (void)viewDidLoad { [super viewDidLoad]; - self.pi_IsNative = YES; + + [XPIAPHelper shareHelper].delegate = self; [[NIMSDK sharedSDK].systemNotificationManager addDelegate:self]; [self requestHttp]; [self initSubViews]; [self initSubViewConstraints]; } - + - (BOOL)isHiddenNavBar { return YES; } @@ -119,8 +115,8 @@ [self.presenter getUserInfo]; } if([XPSkillCardPlayerManager shareInstance].isInRoom == YES && [XPSkillCardPlayerManager shareInstance].isInRoomFirstRecharge == NO){ - [XPSkillCardPlayerManager shareInstance].isInRoomFirstRecharge = YES; - } + [XPSkillCardPlayerManager shareInstance].isInRoomFirstRecharge = YES; + } } - (XPNobleCenterPresenter *)createPresenter { @@ -147,7 +143,7 @@ make.leading.top.trailing.mas_equalTo(self.view); make.height.mas_equalTo(height); }]; - + [self.navView mas_makeConstraints:^(MASConstraintMaker *make) { make.leading.trailing.top.mas_equalTo(self.view); make.height.mas_equalTo(kNavigationHeight); @@ -157,7 +153,7 @@ make.height.mas_equalTo(40); make.top.mas_equalTo(self.navView.mas_bottom); }]; - + [self.lineView mas_makeConstraints:^(MASConstraintMaker *make) { make.leading.trailing.bottom.mas_equalTo(self.view); make.top.mas_equalTo(self.titleView.mas_bottom); @@ -181,7 +177,7 @@ make.width.height.mas_equalTo(20); make.centerY.equalTo(self.openNobleView); make.trailing.equalTo(self.openNobleButton.mas_leading).mas_offset(-2); - + }]; [self.rankBtn mas_makeConstraints:^(MASConstraintMaker *make) { make.width.mas_equalTo(57); @@ -189,7 +185,7 @@ make.trailing.mas_equalTo(-24); make.top.mas_equalTo(139); }]; - + } #pragma mark - XPNobleCenterPayViewDelegate - (void)payWithType:(NobleCenterPayType)type{ @@ -199,11 +195,12 @@ config.message = YMLocalizedString(@"XPNobleCenterViewController3"); config.actionStyle = TTAlertActionBothStyle; [TTPopup alertWithConfig:config showBorder:NO confirmHandler:^{ - - XPIAPRechargeViewController * webVC =[[XPIAPRechargeViewController alloc] init]; + XPWebViewController * webVC =[[XPWebViewController alloc] init]; + webVC.url = [NSString stringWithFormat:URLWithType(kThirdPartyPay),@"5",[YYUtility deviceID]]; + webVC.isPush = YES; [self.navigationController pushViewController:webVC animated:YES]; } cancelHandler:^{ - + }]; return; } @@ -211,22 +208,10 @@ [self.presenter openVipWithDiamondRoomUid:roomUid]; return; } - - if(self.pi_IsNative == NO){ - XPWebViewController *vc = [[XPWebViewController alloc]init]; - NSString *channel = @"p"; - channel = [NSString stringWithFormat:@"%@a",channel]; - channel = [NSString stringWithFormat:@"%@y",channel]; - NSString *url = [NSString stringWithFormat:URLWithType(kChannelUrl),channel,@"5",[YYUtility deviceID]]; - vc.url = url; - [self.navigationController pushViewController:vc animated:YES]; - return; - } - - if(self.rechargeModel.list.count == 0)return; - [XNDJTDDLoadingTool showOnlyView:kWindow]; - RechargeListModel *rechargeModel = [self.rechargeModel.list safeObjectAtIndex1:0]; - [self.presenter requestNobleIAPRechargeOrderWithChargeProdId:rechargeModel.chargeProdId roomUid:self.roomUid ? [NSString stringWithFormat:@"%zd", self.roomUid] : nil]; + XPWebViewController * webVC =[[XPWebViewController alloc] init]; + webVC.url = [NSString stringWithFormat:URLWithType(kThirdPartyPay),@"5",[YYUtility deviceID]]; + webVC.isPush = YES; + [self.navigationController pushViewController:webVC animated:YES]; } -(void)openVipWithDiamondSuccess{ [self requestHttp]; @@ -247,34 +232,14 @@ self.infoModel = model; } } uid:uid ticket:ticket]; - - - - if([ClientConfig shareConfig].canOpen){ - [Api requestMineChannel:^(BaseModel * _Nullable data, NSInteger code, NSString * _Nullable msg) { - if(code == 200){ - if(data.data[@"isNative"] != nil){ - self.pi_IsNative = [data.data[@"isNative"] boolValue]; - - } - - } - - }]; - - } - } ///批量验证 - (void)checkTranscationIds { NSString * uid = [AccountInfoStorage instance].getUid; NSArray * array = [RechargeStorage getAllReciptsWithUid:uid]; - for (NSDictionary *transcation in array) { - NSString *orderId = transcation[@"orderId"]; - NSString *transcationId = transcation[@"transcationId"]; - ///二次验证 - [self.presenter checkReceiptWithOrderId:orderId transcationId:transcationId errorToast:NO]; + if (array.count > 0) { + [self.presenter checkTranscationIds:array]; } } @@ -319,185 +284,12 @@ self.openNobleButton.text = title; } -///请求充值id的状态成功 -- (void)requestIAPRechargeOrderSuccess:(NSString *)orderId chargeProdId:(NSString *)chargeProdId uuid:(NSString *)uuid{ - if (orderId.length > 0) { - self.orderId = orderId; - if (@available(iOS 15.0, *)) { - - PIIAPRegulate *iap = [PIIAPRegulate shared]; - [iap demandCommodityThingWithProductId:chargeProdId uuid:uuid completionHandler:^(NSError * _Nullable error) { - - }]; - @kWeakify(self); - iap.ConditionBlock = ^(enum StoreConditionResult state, NSDictionary * _Nullable result) { - @kStrongify(self); - - [self rechargeNewProcessStatus:state]; - switch (state) { - case StoreConditionResultVerifiedServer: - { - NSString *transactionId = result[@"transactionId"]; - - [self rechargeSuccess:transactionId]; - - } - break; - - default: - { - - - } - break; - } - }; - - } else { - [XNDJTDDLoadingTool hideOnlyView:kWindow]; - [self showErrorToast:YMLocalizedString(@"XPIAPRechargeViewController10")]; - } - - - } else { - [XNDJTDDLoadingTool hideOnlyView:kWindow]; - } -} -///请求充值账单失败 -- (void)requestIAPRechargeOrderFail:(NSString *)message code:(NSInteger)code { - [XNDJTDDLoadingTool hideOnlyView:kWindow]; - - if(code == 50000){ - - TTAlertConfig *config = [[TTAlertConfig alloc]init]; - config.title = YMLocalizedString(@"XPIAPRechargeViewController7"); - config.message = YMLocalizedString(@"XPIAPRechargeViewController8"); - TTAlertButtonConfig *confirmButtonConfig = [[TTAlertButtonConfig alloc]init]; - confirmButtonConfig.title = YMLocalizedString(@"XPIAPRechargeViewController9"); - UIImage *image = [UIImage gradientColorImageFromColors:@[UIColorFromRGB(0x13E2F5),UIColorFromRGB(0x9DB4FF),UIColorFromRGB(0xCC67FF)] gradientType:GradientTypeLeftToRight imgSize:CGSizeMake(200, 200)]; - confirmButtonConfig.backgroundColor = [UIColor colorWithPatternImage:image]; - confirmButtonConfig.cornerRadius = 38/2; - config.confirmButtonConfig = confirmButtonConfig; - [TTPopup alertWithConfig:config confirmHandler:^{ - [self.presenter getContactCustomerService]; - } cancelHandler:^{ - }]; - return; - } - - - [self showErrorToast:message]; - - - -} -- (void)getContactCustomerServiceSuccessWithUid:(NSString *)uid{ - [self hideHUD]; - dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ - NIMSession * session = [NIMSession session:uid type:NIMSessionTypeP2P]; - SessionViewController * sessionVC = [[SessionViewController alloc] initWithSession:session]; - [self.navigationController pushViewController:sessionVC animated:YES]; - }); - -} -///二次校验成功 -- (void)checkReceiptSuccess:(NSString *)transcationId { - [XNDJTDDLoadingTool hideOnlyView:kWindow]; - if (@available(iOS 15.0, *)) { - PIIAPRegulate *iap = [PIIAPRegulate shared]; - [iap verifyBusinessAccomplishWithTransaction:[NSString stringWithFormat:@"%@",transcationId] completionHandler:^{ - - }]; - } - [self deleteRechageReciptWithTransactionIdentifier:transcationId]; - self.orderId = nil; - //5秒之后如果没有收到开通成功的云信消息,则请求一次用户信息 - dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(5.0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ - if (!self.userInfo.userVipInfoVO) { - ///刷新一下用户的信息 - [self.presenter getUserInfo]; - } - }); -} -- (void)checkReceiptFailWithCode:(NSInteger)code transcationId:(NSString *)transcationId{ - [XNDJTDDLoadingTool hideOnlyView:kWindow]; - if(code == 1444){ - if (@available(iOS 15.0, *)) { - PIIAPRegulate *iap = [PIIAPRegulate shared]; - [iap verifyBusinessAccomplishWithTransaction:[NSString stringWithFormat:@"%@",transcationId] completionHandler:^{ - - }]; - } - [self deleteRechageReciptWithTransactionIdentifier:transcationId]; - } -} -///删除本地保存的 -- (void)deleteRechageReciptWithTransactionIdentifier:(NSString *)transactionIdentifier { - NSString * uid = [AccountInfoStorage instance].getUid; - BOOL deleteSuccess = [RechargeStorage delegateTranscationId:transactionIdentifier uid:uid]; - if (deleteSuccess) { -#warning to do 保存失败 需要埋点 - } -} - -- (void)checkTranscationIdsSuccess { - NSString * uid = [AccountInfoStorage instance].getUid; - [RechargeStorage delegateAllTranscationIdsWithUid:uid]; -} -(void)rankAction{ XPWebViewController * webVC =[[XPWebViewController alloc] init]; webVC.url = URLWithType(kNobleRankURL); [self.navigationController pushViewController:webVC animated:YES]; } -#pragma mark - XPIAPHelperDelegate -///当前充值的状态 -- (void)rechargeNewProcessStatus:(StoreConditionResult)status { - - - if (status == StoreConditionResultPay || status == StoreConditionResultStart || status == StoreConditionResultVerifiedServer) { - - }else if (status == StoreConditionResultUnowned) { - [XNDJTDDLoadingTool hideOnlyView:kWindow]; - [self showErrorToast:YMLocalizedString(@"XPIAPRechargeViewController1")]; - }else{ - [XNDJTDDLoadingTool hideOnlyView:kWindow]; - [self showErrorToast:YMLocalizedString(@"XPIAPRechargeViewController0")]; - } -} - -///充值成功回调id -- (void)rechargeSuccess:(NSString *)transactionIdentifier { - ///保存唯一凭证 - [self saveRechageReciptWithTransactionIdentifier:transactionIdentifier]; - ///二次验证 - [self.presenter checkReceiptWithOrderId:self.orderId transcationId:transactionIdentifier errorToast:YES]; -} - -///充值成功之后保存订单到钥匙串 -- (void)saveRechageReciptWithTransactionIdentifier:(NSString *)transactionIdentifier { - NSData *receipt = [NSData dataWithContentsOfURL:[[NSBundle mainBundle] appStoreReceiptURL]]; - NSString *encodeStr = [receipt base64EncodedStringWithOptions:NSDataBase64EncodingEndLineWithLineFeed]; - NSMutableDictionary *dictionary = [NSMutableDictionary dictionary]; - if(transactionIdentifier != nil){ - [dictionary setObject:transactionIdentifier forKey:@"transcationId"]; - } - if(encodeStr != nil){ - [dictionary setObject:encodeStr forKey:@"recipt"]; - } - if(self.orderId != nil){ - [dictionary setObject:self.orderId forKey:@"orderId"]; - } - if(dictionary.allKeys.count == 0)return; - NSString *reciptJson = [dictionary toJSONString]; - NSString * uid = [AccountInfoStorage instance].getUid; - BOOL saveSuccess = [RechargeStorage saveTranscationId:transactionIdentifier recipt:reciptJson uid:uid]; - if (!saveSuccess) { -#warning to do 保存失败 需要埋点 - } -} - - #pragma mark - JXCategoryViewDelegate - (NSInteger)numberOfListsInlistContainerView:(JXCategoryListContainerView *)listContainerView { return self.titles.count; @@ -568,7 +360,7 @@ payView.delegate = self; [self.view addSubview:payView]; - + } #pragma mark - Getters And Setters @@ -645,7 +437,7 @@ _openNobleButton.textColor = [DJDKMIMOMColor mainTextColor]; _openNobleButton.numberOfLines = 0; _openNobleButton.textAlignment = NSTextAlignmentCenter; - + } return _openNobleButton; } diff --git a/YuMi/Modules/YMMine/View/Recharge/XPIAPRechargeViewController.m b/YuMi/Modules/YMMine/View/Recharge/XPIAPRechargeViewController.m index f0cb6bb2..2a7f7850 100644 --- a/YuMi/Modules/YMMine/View/Recharge/XPIAPRechargeViewController.m +++ b/YuMi/Modules/YMMine/View/Recharge/XPIAPRechargeViewController.m @@ -120,7 +120,7 @@ NSString *channel = @"p"; channel = [NSString stringWithFormat:@"%@a",channel]; channel = [NSString stringWithFormat:@"%@y",channel]; - NSString *url = [NSString stringWithFormat:URLWithType(kChannelUrl),channel,self.type,[YYUtility deviceID]]; + NSString *url = [NSString stringWithFormat:URLWithType(kTreasureTicketBuyURL),channel,self.type,[YYUtility deviceID]]; vc.url = url; [self addChildViewController:vc]; vc.view.frame = self.view.frame; diff --git a/YuMi/Modules/YMMine/View/XPMineViewController.m b/YuMi/Modules/YMMine/View/XPMineViewController.m index 4886b2da..97ffbb9b 100644 --- a/YuMi/Modules/YMMine/View/XPMineViewController.m +++ b/YuMi/Modules/YMMine/View/XPMineViewController.m @@ -55,13 +55,8 @@ #import "XPMineCollectRoomListViewController.h" #import "XPMineMainGuildListVC.h" #import "XPMineGiveDiamondVC.h" -#import "XPIAPRechargeViewController.h" #import "XPIncomeRecordVC.h" #import "XPNobleCenterViewController.h" -#import "LittleGameInfoModel.h" -#import "HomeLittleGameRoomModel.h" -#import "XPLittleGameRoomOpenView.h" -#import "XPMineGameTableViewCell.h" UIKIT_EXTERN NSString *kRequestRicket; @interface XPMineViewController () @@ -87,10 +82,6 @@ UIKIT_EXTERN NSString *kRequestRicket; @property (nonatomic,assign) BOOL isRefreshRoomInfo; ///是否正在请示数据,防止过多请求 @property (nonatomic,assign) BOOL isRequestData; -///游戏列表 -@property (nonatomic, strong) NSMutableArray *littleGameArray; - - @end @implementation XPMineViewController @@ -228,22 +219,8 @@ UIKIT_EXTERN NSString *kRequestRicket; break; case XPMineItemType_My_Room: { - NSString* roomUid = [NSString stringWithFormat:@"%ld", (long)self.userInfo.uid]; - [Api getRoomInfo:^(BaseModel * _Nullable data, NSInteger code, NSString * _Nullable msg) { - if (code == 200) { - RoomInfoModel * roomInfo = [RoomInfoModel modelWithJSON:data.data]; - if (roomInfo.isReselect) { - XPLittleGameRoomOpenView * roomOpenView = [[XPLittleGameRoomOpenView alloc] init]; - roomOpenView.roomInfo = roomInfo; - roomOpenView.currentVC = self; - [TTPopup popupView:roomOpenView style:TTPopupStyleActionSheet]; - } else { - [XPRoomViewController openRoom:roomUid viewController:self]; - } - } else { - [self showErrorToast:msg]; - } - } uid:roomUid intoUid:roomUid]; + NSString* roomUid = [NSString stringWithFormat:@"%ld", (long)self.userInfo.uid]; + [XPRoomViewController openRoom:roomUid viewController:self]; } break; case XPMineItemType_Collect_Room://收藏房间 @@ -431,9 +408,10 @@ UIKIT_EXTERN NSString *kRequestRicket; } ///点击充值 -(void)pushThirdPartyPayVC{ - XPIAPRechargeViewController * webVC =[[XPIAPRechargeViewController alloc] init]; - webVC.type = @"4"; - [self.navigationController pushViewController:webVC animated:YES]; + XPWebViewController * webVC =[[XPWebViewController alloc] init]; + webVC.url = [NSString stringWithFormat:URLWithType(kThirdPartyPay),@"4",[YYUtility deviceID]]; + webVC.isPush = YES; + [self.navigationController pushViewController:webVC animated:YES]; } ///点击收益记录 -(void)pushEarningsRecordVC{ @@ -447,24 +425,9 @@ UIKIT_EXTERN NSString *kRequestRicket; ///点击我的房间 -(void)pushMyRoomVC{ if(self.isRefreshRoomInfo == YES)return; - self.isRefreshRoomInfo = YES; - NSString* roomUid = [NSString stringWithFormat:@"%ld", (long)self.userInfo.uid]; - [Api getRoomInfo:^(BaseModel * _Nullable data, NSInteger code, NSString * _Nullable msg) { - self.isRefreshRoomInfo = NO; - if (code == 200) { - RoomInfoModel * roomInfo = [RoomInfoModel modelWithJSON:data.data]; - if (roomInfo.isReselect) { - XPLittleGameRoomOpenView * roomOpenView = [[XPLittleGameRoomOpenView alloc] init]; - roomOpenView.roomInfo = roomInfo; - roomOpenView.currentVC = self; - [TTPopup popupView:roomOpenView style:TTPopupStyleActionSheet]; - } else { - [XPRoomViewController openRoom:roomUid viewController:self]; - } - } else { - [self showErrorToast:msg]; - } - } uid:roomUid intoUid:roomUid]; + self.isRefreshRoomInfo = YES; + NSString* roomUid = [NSString stringWithFormat:@"%ld", (long)self.userInfo.uid]; + [XPRoomViewController openRoom:roomUid viewController:self]; } #pragma mark - XPMineHeadViewDelegate ///点击头像 @@ -522,21 +485,7 @@ UIKIT_EXTERN NSString *kRequestRicket; - (void)onGetMineFuntionItemFailWithGroup:(dispatch_group_t)group{ dispatch_group_leave(group); } -///获取小游戏列表 -- (void)onGetLittleGameListSuccess:(NSArray *)items WithGroup:(nonnull dispatch_group_t)group{ - [self.littleGameArray removeAllObjects]; - [self.littleGameArray addObjectsFromArray:items]; - dispatch_group_leave(group); - NSMutableArray *array = [NSMutableArray array]; - for (LittleGameInfoModel *item in self.littleGameArray) { - [array addObject:item.name]; - } - NSString *trackName = [array componentsJoinedByString:@","]; - [StatisticsServiceHelper trackEventWithKey:StatisticsServiceEventusercenter_quick_entry_show eventAttributes:@{@"gameName" : trackName}]; -} -- (void)onGetLittleGameListFailWithGroup:(dispatch_group_t)group{ - dispatch_group_leave(group); -} + ///获取个人中心banner - (void)onGetPersonalBannerListSuccess:(NSArray *)items WithGroup:(nonnull dispatch_group_t)group{ [self.bannerArray removeAllObjects]; @@ -585,10 +534,7 @@ UIKIT_EXTERN NSString *kRequestRicket; dispatch_group_async(group, queue, ^{ [self.presenter getPersonItemListWithGroup:group]; }); - dispatch_group_enter(group); - dispatch_group_async(group, queue, ^{ - [self.presenter getLittleGameListWithGroup:group]; - }); + dispatch_group_enter(group); dispatch_group_async(group, queue, ^{ [self.presenter getMineBannerListWithGroup:group]; @@ -597,8 +543,6 @@ UIKIT_EXTERN NSString *kRequestRicket; dispatch_group_async(group, queue, ^{ [self.presenter getNobleInfoWithGroup:group]; }); - - dispatch_group_notify(group,dispatch_get_main_queue(), ^{ self.isRequestData = NO; self.userInfo = userInfo; @@ -636,58 +580,6 @@ UIKIT_EXTERN NSString *kRequestRicket; - (void)onGetClanDetailInfofailWithGroup:(dispatch_group_t)group{ dispatch_group_leave(group); } - -///匹配游戏房成功 -- (void)quickMatchLittleGameRoomSuccess:(HomeLittleGameRoomModel *)roomInfo mgId:(NSString *)mgId { - if (roomInfo.isPick && roomInfo.uid.length > 0) { - [StatisticsServiceHelper trackEventWithKey:StatisticsServiceEventusercenter_quick_entrysuccess_click eventAttributes:@{@"roomUid" : roomInfo.uid}]; - [XPRoomViewController openRoom:roomInfo.uid viewController:self]; - } else if (roomInfo.needOpenSelfRoom) { - NSString* roomUid = [NSString stringWithFormat:@"%ld", (long)self.userInfo.uid]; - [StatisticsServiceHelper trackEventWithKey:StatisticsServiceEventusercenter_quick_entrysuccess_click eventAttributes:@{@"roomUid" : roomUid}]; - [Api getRoomInfo:^(BaseModel * _Nullable data, NSInteger code, NSString * _Nullable msg) { - if (code == 200) { - RoomInfoModel * roomInfo = [RoomInfoModel modelWithJSON:data.data]; - if (roomInfo.mgId != [mgId intValue]) {///更新房间游戏类型 - NSMutableDictionary * params = [NSMutableDictionary dictionary]; - NSString * uid = [AccountInfoStorage instance].getUid; - NSString * ticket = [AccountInfoStorage instance].getTicket; - [params setObject:ticket forKey:@"ticket"]; - [params setObject:uid forKey:@"uid"]; - [params setObject:[NSString stringWithFormat:@"%ld", roomInfo.uid] forKey:@"roomUid"]; - if (roomInfo.title.length > 0) { - [params setObject:roomInfo.title forKey:@"title"]; - } - if (roomInfo.roomPwd.length > 0) { - [params setObject:roomInfo.roomPwd forKey:@"roomPwd"]; - } else{ - [params setObject:@"" forKey:@"roomPwd"]; - } - if (roomInfo.tagId > 0) { - [params setObject:[NSString stringWithFormat:@"%ld", roomInfo.tagId] forKey:@"tagId"]; - } - [params setObject:@(RoomType_MiniGame) forKey:@"type"]; - [params setObject:mgId forKey:@"mgId"]; - [params setObject:@(roomInfo.hasAnimationEffect) forKey:@"hasAnimationEffect"]; - [Api ownerUpdateRoomInfo:^(BaseModel * _Nullable data, NSInteger code, NSString * _Nullable msg) { - if (code == 200) { - [XPRoomViewController openRoom:[AccountInfoStorage instance].getUid mgId:mgId viewController:self]; - } - } params:params]; - } - } else { - [self showErrorToast:msg]; - } - } uid:roomUid intoUid:roomUid]; - } -} - -///匹配游戏房失败 -- (void)quickMatchLittleGameRoomFail:(NSString *)mgId { - [XPRoomViewController openRoom:[NSString stringWithFormat:@"%ld", self.userInfo.uid] mgId:mgId viewController:self]; -} - - #pragma mark - XPMineHeadItemTableViewCellDelegate - (void)xPMineHeadItemTableViewCell:(XPMineHeadItemTableViewCell *)cell didSelectItem:(XPMineFuntionItemModel *)item { [StatisticsServiceHelper trackEventWithKey:StatisticsServiceEventusercenter_function_click eventAttributes:@{@"functionName" : item.centerName}]; @@ -717,11 +609,7 @@ UIKIT_EXTERN NSString *kRequestRicket; break; } } -#pragma mark - XPMineGameTableViewCellDelegate -///选择了某个游戏 -- (void)xPMineGameTableViewCell:(XPMineGameTableViewCell *)cell didSelectItem:(LittleGameInfoModel *)item { - [self.presenter quickMatchLittleGameWithMgId:item.mgId]; -} + #pragma mark - NSNotification - (void)onVisitorUnReadCountUpdate:(NSNotification *)noti { @@ -735,6 +623,7 @@ UIKIT_EXTERN NSString *kRequestRicket; _tableView.delegate = self; _tableView.dataSource = self; _tableView.showsVerticalScrollIndicator = NO; + _tableView.contentInset = UIEdgeInsetsMake(0, 0, 100, 0); _tableView.separatorStyle = UITableViewCellSeparatorStyleNone;; [_tableView registerClass:[XPMineTheGuildCell class] forCellReuseIdentifier:NSStringFromClass([XPMineTheGuildCell class])]; [_tableView registerClass:[XPMinePersonalCenterCell class] forCellReuseIdentifier:NSStringFromClass([XPMinePersonalCenterCell class])]; @@ -767,12 +656,6 @@ UIKIT_EXTERN NSString *kRequestRicket; } return _functionArray; } -- (NSMutableArray *)littleGameArray { - if (!_littleGameArray) { - _littleGameArray = [NSMutableArray array]; - } - return _littleGameArray; -} - (NSMutableArray *)bannerArray { if (!_bannerArray) { diff --git a/YuMi/Modules/YMMine/View/XPSimpleMineViewController.m b/YuMi/Modules/YMMine/View/XPSimpleMineViewController.m index 91090c67..d2fd472c 100644 --- a/YuMi/Modules/YMMine/View/XPSimpleMineViewController.m +++ b/YuMi/Modules/YMMine/View/XPSimpleMineViewController.m @@ -44,7 +44,6 @@ #import "XPMineUserInfoViewController.h" #import "XPMineSimpleUserInfoViewController.h" #import "XPMineRechargeViewController.h" -#import "XPIAPRechargeViewController.h" #import "XPWebViewController.h" #import "XPRoomViewController.h" #import "XPMineDressUpViewController.h" @@ -59,7 +58,6 @@ #import "XPMineCollectRoomListViewController.h" #import "XPMineFeedbackViewController.h" #import "XPMineSimpleUserInfoViewController.h" -#import "XPIAPRechargeViewController.h" @interface XPSimpleMineViewController () @@ -137,10 +135,10 @@ break; case XPMineItemType_Account: { -// XPMineRechargeViewController * rechargeVC = [[XPMineRechargeViewController alloc] init]; - XPIAPRechargeViewController *rechargeVC = [[XPIAPRechargeViewController alloc] init]; - rechargeVC.type = @"4"; - [self.navigationController pushViewController:rechargeVC animated:YES]; + XPWebViewController * webVC =[[XPWebViewController alloc] init]; + webVC.url = [NSString stringWithFormat:URLWithType(kThirdPartyPay),@"4",[YYUtility deviceID]]; + webVC.isPush = YES; + [self.navigationController pushViewController:webVC animated:YES]; } break; case XPMineItemType_Personinfo: @@ -441,7 +439,7 @@ _tableView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever; [_tableView registerClass:[XPMineItemTableViewCell class] forCellReuseIdentifier:NSStringFromClass([XPMineItemTableViewCell class])]; [_tableView registerClass:[XPHomeBannerTableViewCell class] forCellReuseIdentifier:NSStringFromClass([XPHomeBannerTableViewCell class])]; - + _tableView.contentInset = UIEdgeInsetsMake(0, 0, 100, 0); } return _tableView; } diff --git a/YuMi/Modules/YMRoom/View/CandyTree/View/XPCandyTreeViewController.m b/YuMi/Modules/YMRoom/View/CandyTree/View/XPCandyTreeViewController.m index 8c232ea0..bfd7b6e8 100644 --- a/YuMi/Modules/YMRoom/View/CandyTree/View/XPCandyTreeViewController.m +++ b/YuMi/Modules/YMRoom/View/CandyTree/View/XPCandyTreeViewController.m @@ -30,7 +30,6 @@ #import "XCCurrentVCStackManager.h" #import "XPCandyTreeInsufficientBalanceView.h" #import "XPWebViewController.h" -#import "XPIAPRechargeViewController.h" #import "XPCandyTreeBuyView.h" #import "XPCandyTreeConfirmBuyView.h" #import "XPCandyTreeBuySuccessView.h" @@ -41,7 +40,7 @@ #define KitemHeight (20 + 5) UIKIT_EXTERN NSString * const kRoomReceivedCandyNotificationKey; -@interface XPCandyTreeViewController () +@interface XPCandyTreeViewController () @property(nonatomic,strong) UIButton *backView; ///中间内容的容器 @@ -454,12 +453,18 @@ UIKIT_EXTERN NSString * const kRoomReceivedCandyNotificationKey; #pragma mark -XPCandyTreeInsufficientBalanceViewDelegate - (void)payBalanceAction{ - XPIAPRechargeViewController * webVC =[[XPIAPRechargeViewController alloc] init]; - webVC.delegate = self; - webVC.type = @"4"; + + XPWebViewController * webVC =[[XPWebViewController alloc] init]; + webVC.url = [NSString stringWithFormat:URLWithType(kThirdPartyPay),@"4",[YYUtility deviceID]]; + webVC.isPush = YES; + @kWeakify(self) + webVC.CloseWebViewBlock = ^(BOOL result){ + @kStrongify(self) + [self.presenter getCandyTreeInfo]; + }; [[XCCurrentVCStackManager shareManager].getCurrentVC.navigationController pushViewController:webVC animated:YES]; } -#pragma mark - XPIAPRechargeViewControllerDelegate + -(void)paySuccess{ [self.presenter getLoveSettingInfo]; } diff --git a/YuMi/Modules/YMRoom/View/FirstRecharge/View/XPFirstRechargeView.h b/YuMi/Modules/YMRoom/View/FirstRecharge/View/XPFirstRechargeView.h index 67348634..f903b65c 100644 --- a/YuMi/Modules/YMRoom/View/FirstRecharge/View/XPFirstRechargeView.h +++ b/YuMi/Modules/YMRoom/View/FirstRecharge/View/XPFirstRechargeView.h @@ -1,8 +1,8 @@ // // XPFirstRechargeView.h -// YuMi +// xplan-ios // -// Created by YuMi on 2023/2/27. +// Created by duoban on 2023/2/27. // #import diff --git a/YuMi/Modules/YMRoom/View/FirstRecharge/View/XPFirstRechargeView.m b/YuMi/Modules/YMRoom/View/FirstRecharge/View/XPFirstRechargeView.m index 6d11a078..24eee612 100644 --- a/YuMi/Modules/YMRoom/View/FirstRecharge/View/XPFirstRechargeView.m +++ b/YuMi/Modules/YMRoom/View/FirstRecharge/View/XPFirstRechargeView.m @@ -1,26 +1,15 @@ // // XPFirstRechargeView.m -// YuMi +// xplan-ios // -// Created by YuMi on 2023/2/27. +// Created by duoban on 2023/2/27. // ///Third #import -#import ///Tool -#import -#import "YUMIMacroUitls.h" #import "ThemeColor+FirstRecharge.h" #import "UIImage+Utils.h" #import "XPFirstRechargeFlowLayout.h" -#import "NSArray+Safe.h" -#import "XNDJTDDLoadingTool.h" -#import "AccountInfoStorage.h" -#import "YYUtility.h" -#import "Api+Mine.h" -#import "Api+Main.h" - -#import "RechargeStorage.h" ///Model #import "FirstRechargeModel.h" ///View @@ -31,14 +20,11 @@ #import "XPFirstRechargeProtocol.h" ///VC #import "XPMineRechargeViewController.h" - #import "XPWebViewController.h" #import "XPFirstRechargeView.h" #import "Api+FirstRecharge.h" #import "FirstRechargeModel.h" #import "XPSkillCardPlayerManager.h" -#import "YuMi-swift.h" -#import "ClientConfig.h" @interface XPFirstRechargeView () /// @property (nonatomic,strong) UIButton *backBtn; @@ -70,25 +56,16 @@ @property (nonatomic,weak) UINavigationController * currentNav; /// @property (nonatomic,strong) XPFirstRechargeCollectionView *rechargeView; -@property (nonatomic,strong) FirstRechargeModel *currentInfo; -@property (nonatomic,copy) NSString *orderId; -@property(nonatomic,assign) BOOL pi_IsNative; @end @implementation XPFirstRechargeView -- (void)dealloc { - -} - - -(instancetype)initWithFrame:(CGRect)frame{ self = [super initWithFrame:frame]; if(self){ [self initSubViews]; [self initSubViewConstraints]; [self getFirstRechargeRewardList]; - - + } return self; } @@ -104,22 +81,6 @@ } [XNDJTDDLoadingTool showErrorWithMessage:msg]; } channelType:@"3"]; - [self checkTranscationIds]; - if([ClientConfig shareConfig].canOpen){ - - [Api requestMineChannel:^(BaseModel * _Nullable data, NSInteger code, NSString * _Nullable msg) { - - if(code == 200){ - if(data.data[@"isNative"] != nil){ - self.pi_IsNative = [data.data[@"isNative"] boolValue]; - - } - - } - - }]; - - } } #pragma mark - Private Method - (void)initSubViews { @@ -211,8 +172,8 @@ NSString * title = model.chargeProdTitle; NSString * giveMoneyStr = [NSString stringWithFormat:@"%ld", model.giveMoney]; - NSMutableAttributedString * attribute = [[NSMutableAttributedString alloc] initWithString:title attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:12], NSForegroundColorAttributeName:UIColorFromRGB(0xBE5AF6)}]; - [attribute addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:12 weight:UIFontWeightSemibold] range:[title rangeOfString:giveMoneyStr]]; + NSMutableAttributedString * attribute = [[NSMutableAttributedString alloc] initWithString:title attributes:@{NSFontAttributeName:kFontRegular(12), NSForegroundColorAttributeName:UIColorFromRGB(0xBE5AF6)}]; + [attribute addAttribute:NSFontAttributeName value:kFontSemibold(12) range:[title rangeOfString:giveMoneyStr]]; [self.extraButton setAttributedTitle:attribute forState:UIControlStateNormal]; } @@ -221,7 +182,6 @@ if (array.count <= 0) return; self.typeArrowView.hidden = NO; self.originArray = array; - self.currentInfo = [array safeObjectAtIndex1:0]; if (self.segmentView.arrangedSubviews.count > 0) { [[self.segmentView arrangedSubviews] enumerateObjectsUsingBlock:^(__kindof UIView * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) { [obj removeFromSuperview]; @@ -229,11 +189,11 @@ } for (int i = 0 ; i < array.count; i++) { FirstRechargeModel * modelInfo = [array safeObjectAtIndex1:i]; - NSString * title = [NSString stringWithFormat:@"$%.2f", modelInfo.chargeMoney]; + NSString * title = [NSString stringWithFormat:@"$%.2f ", modelInfo.chargeMoney]; UIButton * button = [UIButton buttonWithType:UIButtonTypeCustom]; [button setTitleColor:[UIColor whiteColor] forState:UIControlStateSelected]; [button setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal]; - button.titleLabel.font = [UIFont systemFontOfSize:15 weight:UIFontWeightMedium]; + button.titleLabel.font = kFontMedium(15); [button setTitle:title forState:UIControlStateNormal]; [button setTitle:title forState:UIControlStateSelected]; button.tag = i; @@ -281,232 +241,17 @@ return cell; } -#pragma mark - 充值 -/// 获取充值的订单编号 -/// @param chargeProdId 苹果服务器的充值 的id -- (void)requestIAPRechargeOrderWithChargeProdId:(NSString *)chargeProdId { - - NSString * uid = [AccountInfoStorage instance].getUid; - NSString * ticket = [AccountInfoStorage instance].getTicket; - NSString * deviceInfo = [YYUtility deviceID]; - NSString * clientIp= [YYUtility ipAddress]; - [Api requestIAPRecharge:^(BaseModel * _Nullable data, NSInteger code, NSString * _Nullable msg) { - if (code == 200) { - NSString *orderId = (NSString *)data.data[@"recordId"]; - NSString *uuid = (NSString *)data.data[@"appAccountToken"]; - [self requestIAPRechargeOrderSuccess:orderId chargeProdId:chargeProdId uuid:uuid]; - } else { - [XNDJTDDLoadingTool hideOnlyView:kWindow]; - if(code == 50000){ - if(self.delegate && [self.delegate respondsToSelector:@selector(contactCustomerService)]){ - [self.delegate contactCustomerService]; - } - [self backAction]; - return; - } - [XNDJTDDLoadingTool showErrorWithMessage:msg]; - } - } chargeProdId:chargeProdId uid:uid ticket:ticket deviceInfo:deviceInfo clientIp:clientIp]; -} - - -- (void)requestIAPRechargeOrderSuccess:(NSString *)orderId chargeProdId:(NSString *)chargeProdId uuid:(NSString *)uuid{ - if (orderId.length > 0) { - self.orderId = orderId; - - if (@available(iOS 15.0, *)) { - - PIIAPRegulate *iap = [PIIAPRegulate shared]; - [iap demandCommodityThingWithProductId:chargeProdId uuid:uuid completionHandler:^(NSError * _Nullable error) { - - }]; - @kWeakify(self); - iap.ConditionBlock = ^(enum StoreConditionResult state, NSDictionary * _Nullable result) { - @kStrongify(self); - - [self rechargeNewProcessStatus:state]; - switch (state) { - case StoreConditionResultVerifiedServer: - { - NSString *transactionId = result[@"transactionId"]; - - [self rechargeSuccess:transactionId]; - - } - break; - - default: - { - - - } - break; - } - }; - - } else { - [XNDJTDDLoadingTool hideOnlyView:kWindow]; - [XNDJTDDLoadingTool showErrorWithMessage:YMLocalizedString(@"XPIAPRechargeViewController10")]; - } - - - }else{ - [XNDJTDDLoadingTool hideOnlyView:kWindow]; - } -} -#pragma mark - XPIAPHelperDelegate - -///当前充值的状态 -- (void)rechargeNewProcessStatus:(StoreConditionResult)status { - - - if (status == StoreConditionResultPay || status == StoreConditionResultStart || status == StoreConditionResultVerifiedServer) { - - }else if (status == StoreConditionResultUnowned) { - [XNDJTDDLoadingTool hideOnlyView:kWindow]; - [XNDJTDDLoadingTool showErrorWithMessage:YMLocalizedString(@"XPIAPRechargeViewController1")]; - }else{ - [XNDJTDDLoadingTool hideOnlyView:kWindow]; - [XNDJTDDLoadingTool showErrorWithMessage:YMLocalizedString(@"XPIAPRechargeViewController0")]; - } -} - - -///充值成功回调id -- (void)rechargeSuccess:(NSString *)transactionIdentifier { - ///保存唯一凭证 - [self saveRechageReciptWithTransactionIdentifier:transactionIdentifier]; - ///二次验证 - [self checkReceiptWithOrderId:self.orderId transcationId:transactionIdentifier errorToast:YES]; -} - -///充值成功之后保存订单到钥匙串 -- (void)saveRechageReciptWithTransactionIdentifier:(NSString *)transactionIdentifier { - NSData *receipt = [NSData dataWithContentsOfURL:[[NSBundle mainBundle] appStoreReceiptURL]]; - NSString *encodeStr = [receipt base64EncodedStringWithOptions:NSDataBase64EncodingEndLineWithLineFeed]; - NSMutableDictionary *dictionary = [NSMutableDictionary dictionary]; - if(transactionIdentifier != nil){ - [dictionary setObject:transactionIdentifier forKey:@"transcationId"]; - } - if(encodeStr != nil){ - [dictionary setObject:encodeStr forKey:@"recipt"]; - } - if(self.orderId != nil){ - [dictionary setObject:self.orderId forKey:@"orderId"]; - } - if(dictionary.allKeys.count == 0)return; - NSString *reciptJson = [dictionary toJSONString]; - NSString * uid = [AccountInfoStorage instance].getUid; - BOOL saveSuccess = [RechargeStorage saveTranscationId:transactionIdentifier recipt:reciptJson uid:uid]; - if (!saveSuccess) { -#warning to do 保存失败 需要埋点 - } -} - -///删除本地保存的 -- (void)deleteRechageReciptWithTransactionIdentifier:(NSString *)transactionIdentifier { - NSString * uid = [AccountInfoStorage instance].getUid; - BOOL deleteSuccess = [RechargeStorage delegateTranscationId:transactionIdentifier uid:uid]; - if (deleteSuccess) { -#warning to do 保存失败 需要埋点 - } -} -///批量验证 -- (void)checkTranscationIds { - NSString * uid = [AccountInfoStorage instance].getUid; - NSArray * array = [RechargeStorage getAllReciptsWithUid:uid]; - -// [self.presenter checkReceiptWithOrderId:self.orderId transcationId:transactionIdentifier]; -// NSMutableArray *list = [NSMutableArray array]; -// for (NSDictionary *transcationDic in array) { -// NSString *transcationId = transcationDic[@"transcationId"]; -// if(transcationId){ -// [list addObject:transcationId]; -// } -// } -// if(list.count > 0){ -// if (@available(iOS 15.0, *)) { -// PIIAPRegulate *iap = [PIIAPRegulate shared]; -// [iap allTransactionWithList:list completionHandler:^{ -// -// }]; -// -// } -// } - - for (NSDictionary *transcation in array) { - NSString *orderId = transcation[@"orderId"]; - NSString *transcationId = transcation[@"transcationId"]; - ///二次验证 - [self checkReceiptWithOrderId:orderId transcationId:transcationId errorToast:NO] ; - } - -} -- (void)checkReceiptWithOrderId:(NSString *)orderId transcationId:(NSString *)transcationId errorToast:(BOOL)errorToast{ - NSString * uid = [AccountInfoStorage instance].getUid; - NSString * ticket = [AccountInfoStorage instance].getTicket; - - [Api checkReceipt:^(BaseModel * _Nullable data, NSInteger code, NSString * _Nullable msg) { - [XNDJTDDLoadingTool hideOnlyView:kWindow]; - if (code == 200) { - [self checkReceiptSuccess:transcationId]; - } else { - if(code == 1444){ - if (@available(iOS 15.0, *)) { - PIIAPRegulate *iap = [PIIAPRegulate shared]; - [iap verifyBusinessAccomplishWithTransaction:[NSString stringWithFormat:@"%@",transcationId] completionHandler:^{ - - }]; - } - [self deleteRechageReciptWithTransactionIdentifier:transcationId]; - } - if(errorToast == YES){ - [XNDJTDDLoadingTool showErrorWithMessage:msg]; - } - - } - } chooseEnv:@"true" chargeRecordId:orderId transcationId:transcationId uid:uid ticket:ticket]; - -} - -///二次验证成功 -- (void)checkReceiptSuccess:(NSString *)transcationId { - if (@available(iOS 15.0, *)) { - PIIAPRegulate *iap = [PIIAPRegulate shared]; - [iap verifyBusinessAccomplishWithTransaction:[NSString stringWithFormat:@"%@",transcationId] completionHandler:^{ - - }]; - } - [self deleteRechageReciptWithTransactionIdentifier:transcationId]; - self.orderId = nil; -} - #pragma mark - Event Response - - - (void)rewardHelpButtonAction:(UIButton *)sender { sender.selected = !sender.selected; self.descripBgView.hidden = !sender.selected; } - (void)rechargeButtonAction { - - if(self.pi_IsNative == NO){ - if(self.delegate && [self.delegate respondsToSelector:@selector(rechargeHandle)]){ - [self.delegate rechargeHandle]; - } - [self backAction]; - return; - } - - if (self.currentInfo == nil|| self.currentInfo.chargeProdId == nil) { - return; - } - FirstRechargeModel *model = self.currentInfo; - if (model.chargeProdId) { - [XNDJTDDLoadingTool showOnlyView:kWindow]; - [self requestIAPRechargeOrderWithChargeProdId:model.chargeProdId]; + if(self.delegate && [self.delegate respondsToSelector:@selector(rechargeHandle)]){ + [self.delegate rechargeHandle]; } + [self backAction]; } -(void)backAction{ [self removeFromSuperview]; @@ -514,7 +259,6 @@ - (void)buttonAction:(UIButton *)sender { if (sender.tag <= self.originArray.count) { FirstRechargeModel * model = [self.originArray safeObjectAtIndex1:sender.tag]; - self.currentInfo = model; [self createExtraRewardAttrebute:model]; self.rewardArray = model.firstChargeRewardList; self.collectionView.hidden = self.rewardArray.count < 2; @@ -598,7 +342,7 @@ - (UIButton *)extraButton { if (!_extraButton) { _extraButton = [UIButton buttonWithType:UIButtonTypeCustom]; - [_extraButton setBackgroundImage:[UIImage imageNamed:@"room_first_recharge_extra"] forState:UIControlStateNormal]; + [_extraButton setBackgroundImage:kImage(@"room_first_recharge_extra") forState:UIControlStateNormal]; } return _extraButton; @@ -653,7 +397,7 @@ [_rechargeButton setBackgroundImage:[UIImage imageNamed:@"room_first_recharge_recharge"] forState:UIControlStateNormal]; [_rechargeButton setBackgroundImage:[UIImage imageNamed:@"room_first_recharge_recharge"] forState:UIControlStateSelected]; [_rechargeButton setTitle:YMLocalizedString(@"XPFirstRechargeViewController1") forState:UIControlStateNormal]; - _rechargeButton.titleLabel.font = [UIFont systemFontOfSize:18 weight:UIFontWeightSemibold]; + _rechargeButton.titleLabel.font = kFontSemibold(18); [_rechargeButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal]; [_rechargeButton addTarget:self action:@selector(rechargeButtonAction) forControlEvents:UIControlEventTouchUpInside]; } @@ -662,7 +406,7 @@ - (UIImageView *)typeArrowView{ if (!_typeArrowView){ _typeArrowView = [UIImageView new]; - _typeArrowView.image = [UIImage imageNamed:@"room_first_recharge_recharge_arrow"]; + _typeArrowView.image = kImage(@"room_first_recharge_recharge_arrow"); _typeArrowView.hidden = YES; } return _typeArrowView; @@ -678,7 +422,7 @@ if (!_backBtn){ _backBtn = [UIButton new]; [_backBtn addTarget:self action:@selector(backAction) forControlEvents:UIControlEventTouchUpInside]; - + } return _backBtn; } diff --git a/YuMi/Modules/YMRoom/View/SendGiftView/View/XPSendGiftView.m b/YuMi/Modules/YMRoom/View/SendGiftView/View/XPSendGiftView.m index 0edbb268..92e49f0b 100644 --- a/YuMi/Modules/YMRoom/View/SendGiftView/View/XPSendGiftView.m +++ b/YuMi/Modules/YMRoom/View/SendGiftView/View/XPSendGiftView.m @@ -44,9 +44,8 @@ #import "XPGiftProtocol.h" ///VC #import "XPMineRechargeViewController.h" -#import "XPIAPRechargeViewController.h" #import "XPWebViewController.h" -UIKIT_EXTERN NSString * const kFreeGiftCountdownNotification; + UIKIT_EXTERN NSString * kShowFirstRechargeView; @interface XPSendGiftView ()< XPGiftBarViewDelegate, XPGiftProtocol, XPGiftInfoViewDelegate, XPGraffitiGiftViewDelegate, XPGiftUsersViewDelegate, XPGiftHeadTypeViewDelegate, XPGiftLuckyGiftBroadcastViewDelegate, XPGiftTwelveStarBroadcastViewDelegate> @@ -89,8 +88,6 @@ UIKIT_EXTERN NSString * kShowFirstRechargeView; @property (nonatomic,assign) GiftSegmentType segmentType; ///福袋礼物全服记录 @property (nonatomic,strong) NSArray *records; -///背包礼物数据 -@property (nonatomic,copy) NSArray * packGiftList; @end @implementation XPSendGiftView @@ -99,9 +96,7 @@ UIKIT_EXTERN NSString * kShowFirstRechargeView; return [[XPGiftPresenter alloc] init]; } --(void)dealloc{ - [[NSNotificationCenter defaultCenter]removeObserver:self]; -} + - (instancetype)initWithType:(SendGiftType)type uid:(NSString * __nullable)uid{ if (self = [super init]) { self.modalPresentationStyle = UIModalPresentationOverFullScreen; @@ -129,17 +124,8 @@ UIKIT_EXTERN NSString * kShowFirstRechargeView; [self.stackView addArrangedSubview:self.giftInfoView]; [self.stackView addArrangedSubview:self.giftBarView]; [self.stackView addArrangedSubview:self.bottomView]; - [[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(getFreeGiftCountdownNotification:) name:kFreeGiftCountdownNotification object:nil]; -} --(void)getFreeGiftCountdownNotification:(NSNotification *)not{ - NSDictionary *freeDic = not.userInfo; - BOOL isReset = [freeDic[@"isReset"] boolValue];///礼物清零 - - if(isReset == YES){ - [self.presenter getPackGiftList]; - self.giftInfoView.isDelFreeGift = NO; - } } + - (void)initSubViewConstraints { [self.topView mas_makeConstraints:^(MASConstraintMaker *make) { make.left.right.top.mas_equalTo(self.view); @@ -448,12 +434,11 @@ UIKIT_EXTERN NSString * kShowFirstRechargeView; ///充值 - (void)xPGiftBarViewDidClickRecharge:(XPGiftBarView *)view { - [self dismissViewControllerAnimated:NO completion:^{ -// XPMineRechargeViewController * rechargeVC = [[XPMineRechargeViewController alloc] init]; - XPIAPRechargeViewController * rechargeVC = [[XPIAPRechargeViewController alloc] init]; - rechargeVC.type = @"4"; - [[XCCurrentVCStackManager shareManager].getCurrentVC.navigationController pushViewController:rechargeVC animated:YES]; - }]; + [self dismissViewControllerAnimated:YES completion:nil]; + XPWebViewController * webVC =[[XPWebViewController alloc] init]; + webVC.isPush = YES; + webVC.url = [NSString stringWithFormat:URLWithType(kThirdPartyPay),@"4",[YYUtility deviceID]]; + [self.delegate.getCurrentNav pushViewController:webVC animated:YES]; } - (void)xPGiftBarViewDidClickFirstRecharge:(XPGiftBarView *)view { @@ -627,28 +612,7 @@ UIKIT_EXTERN NSString * kShowFirstRechargeView; } ///背包礼物 - (void)getPacketGiftListSuccess:(NSArray *)giftList { - self.packGiftList = giftList; - NSMutableArray *giftArray = [NSMutableArray arrayWithArray:self.packGiftList]; - BOOL isHaveFreeGift = NO; - for (int i = 0 ; i < self.packGiftList.count; i++) { - GiftInfoModel *infoModel = self.packGiftList[i]; - if(infoModel.giftId == self.freeModel.giftId.integerValue){ - [giftArray removeObjectAtIndex:i]; - [giftArray insertObject:infoModel atIndex:0]; - isHaveFreeGift = YES; - break; - } - } - if(isHaveFreeGift == NO && self.freeModel.curStage != nil && self.freeModel.curStage.integerValue == 0 ){ - GiftInfoModel *infoModel = [GiftInfoModel new]; - infoModel.giftId = self.freeModel.giftId.integerValue; - infoModel.count = 0; - infoModel.giftUrl = self.freeModel.giftUrl; - infoModel.giftName = self.freeModel.giftName; - [giftArray insertObject:infoModel atIndex:0]; - } - self.giftInfoView.freeModel = self.freeModel; - self.giftInfoView.packOriginArray = giftArray; + self.giftInfoView.packOriginArray = giftList; } - (void)getPacketGiftListFail:(NSString *)message { @@ -682,11 +646,7 @@ UIKIT_EXTERN NSString * kShowFirstRechargeView; } else { [self.presenter getUserWallInfo]; } - dispatch_time_t delayTime = dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)); - dispatch_after(delayTime, dispatch_get_main_queue(), ^{ - [self sendCustomMessage:receiveInfo oringinDic:originDic]; - }); - + [self sendCustomMessage:receiveInfo oringinDic:originDic]; ///发送涂鸦礼物消息 [self sendGraffitiGiftMessage]; if (self.segmentType == GiftSegmentType_Graffiti) { diff --git a/YuMi/Modules/YMRoom/View/SendRedPacket/XPRoomSendRedPacketViewController.m b/YuMi/Modules/YMRoom/View/SendRedPacket/XPRoomSendRedPacketViewController.m index 7767bb5b..ce53bced 100644 --- a/YuMi/Modules/YMRoom/View/SendRedPacket/XPRoomSendRedPacketViewController.m +++ b/YuMi/Modules/YMRoom/View/SendRedPacket/XPRoomSendRedPacketViewController.m @@ -21,8 +21,8 @@ #import "XPMinePayPwdViewController.h" #import "BaseNavigationController.h" #import "XPMineRechargeViewController.h" -#import "XPIAPRechargeViewController.h" #import "XPRoomHalfWebView.h" +#import "XPWebViewController.h" ///P #import "XPRoomRedPacketPresenter.h" #import "XPRoomRedPacketProtocol.h" @@ -31,6 +31,7 @@ #import "RoomInfoModel.h" #import "UserInfoModel.h" + @interface XPRoomSendRedPacketViewController () ///host代理 @@ -403,10 +404,10 @@ } - (void)onRechargeButtonClick:(UIButton *)sender { -// XPMineRechargeViewController *rechargeVC = [[XPMineRechargeViewController alloc] init]; - XPIAPRechargeViewController * rechargeVC = [[XPIAPRechargeViewController alloc] init]; - rechargeVC.type = @"4"; - [self.navigationController pushViewController:rechargeVC animated:YES]; + XPWebViewController * webVC =[[XPWebViewController alloc] init]; + webVC.url = [NSString stringWithFormat:URLWithType(kThirdPartyPay),@"4",[YYUtility deviceID]]; + webVC.isPush = YES; + [self.navigationController pushViewController:webVC animated:YES]; } - (void)onRuleButtonClick:(UIButton *)sender { diff --git a/YuMi/Modules/YMRoom/View/TreasureFairy/View/XPTreasureFairyViewController.m b/YuMi/Modules/YMRoom/View/TreasureFairy/View/XPTreasureFairyViewController.m index 24fa4c42..85a37f0c 100644 --- a/YuMi/Modules/YMRoom/View/TreasureFairy/View/XPTreasureFairyViewController.m +++ b/YuMi/Modules/YMRoom/View/TreasureFairy/View/XPTreasureFairyViewController.m @@ -40,9 +40,10 @@ ///P #import "XPTreasureFailyPresenter.h" #import "XPTreasureFailyProtocol.h" -#import "XPIAPRechargeViewController.h" + #import "TreasureFairyUserInfoModel.h" -@interface XPTreasureFairyViewController () +@interface XPTreasureFairyViewController () + ///点击消失 @property (nonatomic,strong) UIView *dismissView; ///背景 @@ -476,71 +477,44 @@ #pragma mark - XPTreasureFairyWebViewDelegate -(void)payWithFairyHandler{ [TTPopup dismiss]; - - XPIAPRechargeViewController * rechargeVC = [[XPIAPRechargeViewController alloc] init]; - rechargeVC.delegate = self; - rechargeVC.isFairyPay = YES; - rechargeVC.type = @"4"; - rechargeVC.view.backgroundColor = [UIColor whiteColor]; - [self addChildViewController:rechargeVC]; - [self.view addSubview:rechargeVC.view]; - - rechargeVC.view.frame = CGRectMake(0, KScreenHeight, KScreenWidth, KScreenHeight); - [UIView animateWithDuration:0.5 animations:^{ - rechargeVC.view.frame = CGRectMake(0, 0, KScreenWidth, KScreenHeight); - }completion:^(BOOL finished) { - - - }]; + XPWebViewController *payVC = [[XPWebViewController alloc] initWithCustomizeNav:YES]; + payVC.view.backgroundColor = [UIColor whiteColor]; + payVC.webview.opaque = NO; + payVC.isFairyPay = YES; + [self addChildViewController:payVC]; + [self.view addSubview:payVC.view]; + @kWeakify(payVC); + payVC.CloseWebViewBlock = ^(BOOL result) { + @kStrongify(payVC); + dispatch_async(dispatch_get_main_queue(), ^{ + [UIView animateWithDuration:0.5 animations:^{ + payVC.view.frame = CGRectMake(0, KScreenHeight, KScreenWidth, KScreenHeight); + }completion:^(BOOL finished) { + [payVC.view removeFromSuperview]; + [self getDiamonds]; + }]; + }); + + }; + payVC.view.frame = CGRectMake(0, KScreenHeight, KScreenWidth, KScreenHeight); + [UIView animateWithDuration:0.5 animations:^{ + payVC.view.frame = CGRectMake(0, 0, KScreenWidth, KScreenHeight); + }completion:^(BOOL finished) { + dispatch_async(dispatch_get_main_queue(), ^{ + payVC.roomUid = self.roomUid; + payVC.url = [NSString stringWithFormat:URLWithType(kThirdPartyPay),@"4",[YYUtility deviceID]]; + }); + + }]; } -#pragma mark - XPIAPRechargeViewController -- (void)paySuccess{ -// [self ticketRecognizer]; - [self getDiamonds]; - [self showSuccessToast:YMLocalizedString(@"PITreasureFairyBuyElfShardView3")]; -} #pragma mark - Event Response - (void)dismissVC { [self dismissViewControllerAnimated:YES completion:nil]; } -- (void)ticketRecognizer { - self.moreView.hidden = YES; - XPIAPRechargeViewController * rechargeVC = [[XPIAPRechargeViewController alloc] init]; - rechargeVC.delegate = self; - rechargeVC.isFairyPay = YES; - rechargeVC.type = @"4"; - rechargeVC.view.backgroundColor = [UIColor whiteColor]; - [self addChildViewController:rechargeVC]; - [self.view addSubview:rechargeVC.view]; - rechargeVC.view.frame = CGRectMake(0, KScreenHeight, KScreenWidth, KScreenHeight); - [UIView animateWithDuration:0.5 animations:^{ - rechargeVC.view.frame = CGRectMake(0, 0, KScreenWidth, KScreenHeight); - }completion:^(BOOL finished) { - - - }]; - - -// CGFloat kscale = 550.0 / 375.0; -// XPTreasureFairyWebView * webView = [[XPTreasureFairyWebView alloc] initWithFrame:CGRectMake(0, 0, KScreenWidth, KScreenWidth * kscale)]; -// webView.delegate = self; -// webView.url = URLWithType(kTreasureTicketBuyURL); -// TTPopupService * config = [[TTPopupService alloc] init]; -// config.style = TTPopupStyleActionSheet; -// config.contentView = webView; -// config.maskBackgroundAlpha = 0.5; -// @kWeakify(self); -// config.didFinishDismissHandler = ^(BOOL isDismissOnBackgroundTouch) { -// @kStrongify(self); -// [self.presenter getTreasureFailyInfo]; -// }; -// [TTPopup popupWithConfig:config]; -} - - (void)fairyDrawRecognizer { self.moreView.hidden = YES; if (self.isRewardAnimting) { @@ -663,7 +637,7 @@ config.message = YMLocalizedString(@"XPTreasureFairyViewController5"); config.confirmButtonConfig.title = YMLocalizedString(@"XPTreasureFairyViewController6"); [TTPopup alertWithConfig:config confirmHandler:^{ - [self ticketRecognizer]; + [self payWithFairyHandler]; } cancelHandler:^{ }]; diff --git a/YuMi/Modules/YMRoom/View/XPRoomViewController.m b/YuMi/Modules/YMRoom/View/XPRoomViewController.m index 45c9f8ad..374ce73a 100644 --- a/YuMi/Modules/YMRoom/View/XPRoomViewController.m +++ b/YuMi/Modules/YMRoom/View/XPRoomViewController.m @@ -147,19 +147,19 @@ NSString * const kHadQuitOtherRoomKey = @"kHadQuitOtherRoomKey";//是否退出 @implementation XPRoomViewController + (BOOL)openRoom:(NSString *)roomUid viewController:(UIViewController *)viewController { - return [self openRoom:roomUid fromNick:nil fromType:0 fromUid:nil viewController:viewController]; + return [self openRoom:roomUid fromNick:nil fromType:0 fromUid:nil viewController:viewController]; } + (BOOL) openRoom:(NSString*)roomUid fromNick:(NSString * __nullable)fromNick fromType:(UserEnterRoomFromType)fromType fromUid:(NSString * __nullable)fromUid viewController:(UIViewController*)viewController { - XPRoomViewController * roomVC = [[self alloc] init]; - roomVC.roomUid = roomUid; - roomVC.fromUid = fromUid; - roomVC.fromType = fromType; - roomVC.fromNick = fromNick; - BaseNavigationController * baseNav = [[BaseNavigationController alloc] initWithRootViewController:roomVC]; - baseNav.modalPresentationStyle = UIModalPresentationFullScreen; - [viewController presentViewController:baseNav animated:YES completion:nil]; - return YES; + XPRoomViewController * roomVC = [[self alloc] init]; + roomVC.roomUid = roomUid; + roomVC.fromUid = fromUid; + roomVC.fromType = fromType; + roomVC.fromNick = fromNick; + BaseNavigationController * baseNav = [[BaseNavigationController alloc] initWithRootViewController:roomVC]; + baseNav.modalPresentationStyle = UIModalPresentationFullScreen; + [viewController presentViewController:baseNav animated:YES completion:nil]; + return YES; } /**最小化进房 @@ -167,13 +167,13 @@ NSString * const kHadQuitOtherRoomKey = @"kHadQuitOtherRoomKey";//是否退出 * @params viewController 启动方 */ + (BOOL)openMiniRoom:(NSString*)roomUid viewController:(UIViewController*)viewController { - XPRoomViewController * roomVC = [[self alloc] init]; - roomVC.roomUid = roomUid; - roomVC.isMiniEnter = YES; - BaseNavigationController * baseNav = [[BaseNavigationController alloc] initWithRootViewController:roomVC]; - baseNav.modalPresentationStyle = UIModalPresentationFullScreen; - [viewController presentViewController:baseNav animated:YES completion:nil]; - return roomVC; + XPRoomViewController * roomVC = [[self alloc] init]; + roomVC.roomUid = roomUid; + roomVC.isMiniEnter = YES; + BaseNavigationController * baseNav = [[BaseNavigationController alloc] initWithRootViewController:roomVC]; + baseNav.modalPresentationStyle = UIModalPresentationFullScreen; + [viewController presentViewController:baseNav animated:YES completion:nil]; + return roomVC; } /** XPRoomViewController 不允许外部 init ,请通过该方法启动房间。 @@ -182,13 +182,13 @@ NSString * const kHadQuitOtherRoomKey = @"kHadQuitOtherRoomKey";//是否退出 * @params mgId 小游戏的id */ + (BOOL)openRoom:(NSString*)roomUid mgId:(NSString *)mgId viewController:(UIViewController*)viewController { - XPRoomViewController * roomVC = [[self alloc] init]; - roomVC.roomUid = roomUid; - roomVC.mgId = mgId; - BaseNavigationController * baseNav = [[BaseNavigationController alloc] initWithRootViewController:roomVC]; - baseNav.modalPresentationStyle = UIModalPresentationFullScreen; - [viewController presentViewController:baseNav animated:YES completion:nil]; - return YES; + XPRoomViewController * roomVC = [[self alloc] init]; + roomVC.roomUid = roomUid; + roomVC.mgId = mgId; + BaseNavigationController * baseNav = [[BaseNavigationController alloc] initWithRootViewController:roomVC]; + baseNav.modalPresentationStyle = UIModalPresentationFullScreen; + [viewController presentViewController:baseNav animated:YES completion:nil]; + return YES; } /// h5进房并弹出礼物面板 @@ -196,88 +196,88 @@ NSString * const kHadQuitOtherRoomKey = @"kHadQuitOtherRoomKey";//是否退出 /// @param giftId 礼物id /// @param viewController 启动方 + (BOOL)openRoom:(NSString *)roomUid giftId:(NSString *)giftId viewController:(UIViewController *)viewController { - XPRoomViewController * roomVC = [[self alloc] init]; - roomVC.roomUid = roomUid; - roomVC.giftId = giftId; - BaseNavigationController * baseNav = [[BaseNavigationController alloc] initWithRootViewController:roomVC]; - baseNav.modalPresentationStyle = UIModalPresentationFullScreen; - [viewController presentViewController:baseNav animated:YES completion:nil]; - return YES; + XPRoomViewController * roomVC = [[self alloc] init]; + roomVC.roomUid = roomUid; + roomVC.giftId = giftId; + BaseNavigationController * baseNav = [[BaseNavigationController alloc] initWithRootViewController:roomVC]; + baseNav.modalPresentationStyle = UIModalPresentationFullScreen; + [viewController presentViewController:baseNav animated:YES completion:nil]; + return YES; } - (void)dealloc { #warning to dox - 时刻注意这个方法 功能做完的时候删除此方法 - NSLog(@"房间销毁了"); + NSLog(@"房间销毁了"); [XPSkillCardPlayerManager shareInstance].photoIdList = nil; [XPSkillCardPlayerManager shareInstance].isInRoomVC = NO; - [XPSkillCardPlayerManager shareInstance].isInRoomFirstRecharge = NO; - [XPSkillCardPlayerManager shareInstance].isInRoom = NO; - [XPSkillCardPlayerManager shareInstance].roomUid = @""; - if([[XPRoomMiniManager shareManager] getRoomInfo]==nil){ - [XPSkillCardPlayerManager shareInstance].isMineInMic = NO; - } + [XPSkillCardPlayerManager shareInstance].isInRoomFirstRecharge = NO; + [XPSkillCardPlayerManager shareInstance].isInRoom = NO; + [XPSkillCardPlayerManager shareInstance].roomUid = @""; + if([[XPRoomMiniManager shareManager] getRoomInfo]==nil){ + [XPSkillCardPlayerManager shareInstance].isMineInMic = NO; + } [[CountDownHelper shareHelper] stopCountDown]; [CountDownHelper shareHelper].delegate = nil; - [[NIMSDK sharedSDK].chatroomManager removeDelegate:self]; - [[NIMSDK sharedSDK].chatManager removeDelegate:self]; - [[NIMSDK sharedSDK].loginManager removeDelegate:self]; - [[NIMSDK sharedSDK].conversationManager removeDelegate:self]; + [[NIMSDK sharedSDK].chatroomManager removeDelegate:self]; + [[NIMSDK sharedSDK].chatManager removeDelegate:self]; + [[NIMSDK sharedSDK].loginManager removeDelegate:self]; + [[NIMSDK sharedSDK].conversationManager removeDelegate:self]; [[NIMSDK sharedSDK].broadcastManager removeDelegate:self]; - [[NSNotificationCenter defaultCenter] removeObserver:self]; + [[NSNotificationCenter defaultCenter] removeObserver:self]; } - (XPRoomPresenter *)createPresenter { - return [[XPRoomPresenter alloc] init]; + return [[XPRoomPresenter alloc] init]; } - (BOOL)isHiddenNavBar { - return YES; + return YES; } - (void)viewDidLoad { - [super viewDidLoad]; - [self exitOldRoom]; - [self initSubViews]; - [self initSubViewConstraints]; - if (self.isMiniEnter) { - [self initEnterRoomSuccess:[XPRoomMiniManager shareManager].getRoomInfo user:[XPRoomMiniManager shareManager].getUserInfo]; - } else { - [XNDJTDDLoadingTool showAnchorLoading:self.navigationController.view]; - [self.presenter initEnterRoom:self.roomUid user:[AccountInfoStorage instance].getUid]; - } - /// 公屏 福袋礼物爆出的礼物 需要依赖 当前房间中的礼物列表 需要提前获取礼物列表 可以拿到礼物 没有想到别的方法去解决这个问题 有需要改的在修改吧 - [self.presenter getNormalGiftList:self.roomUid]; - ///获取房间超管列表 - [self.presenter getRoomSuperAdmin:self.roomUid]; + [super viewDidLoad]; + [self exitOldRoom]; + [self initSubViews]; + [self initSubViewConstraints]; + if (self.isMiniEnter) { + [self initEnterRoomSuccess:[XPRoomMiniManager shareManager].getRoomInfo user:[XPRoomMiniManager shareManager].getUserInfo]; + } else { + [XNDJTDDLoadingTool showAnchorLoading:self.navigationController.view]; + [self.presenter initEnterRoom:self.roomUid user:[AccountInfoStorage instance].getUid]; + } + /// 公屏 福袋礼物爆出的礼物 需要依赖 当前房间中的礼物列表 需要提前获取礼物列表 可以拿到礼物 没有想到别的方法去解决这个问题 有需要改的在修改吧 + [self.presenter getNormalGiftList:self.roomUid]; + ///获取房间超管列表 + [self.presenter getRoomSuperAdmin:self.roomUid]; ///获取免费礼物 [self.presenter getFreeGiftData]; - ///获取首充次数 - [self.presenter getRoomFirstCharegWindow:self.roomUid]; + ///获取首充次数 + [self.presenter getRoomFirstCharegWindow:self.roomUid]; if ([ClientConfig shareConfig].canOpen) { ///获取已解锁照片id列表 [self.presenter getUnlockRoomAlbumPhotoListWithRoomUid:self.roomUid]; } - //监听云信消息x - [[NIMSDK sharedSDK].chatroomManager addDelegate:self]; - [[NIMSDK sharedSDK].chatManager addDelegate:self]; - [[NIMSDK sharedSDK].loginManager addDelegate:self]; - [[NIMSDK sharedSDK].conversationManager addDelegate:self]; + //监听云信消息x + [[NIMSDK sharedSDK].chatroomManager addDelegate:self]; + [[NIMSDK sharedSDK].chatManager addDelegate:self]; + [[NIMSDK sharedSDK].loginManager addDelegate:self]; + [[NIMSDK sharedSDK].conversationManager addDelegate:self]; [[NIMSDK sharedSDK].broadcastManager addDelegate:self]; [CountDownHelper shareHelper].delegate = self; - [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(myGiftEffectUpdate:) name:kRoomGiftEffectUpdateNotificationKey object:nil]; - [[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(showRoomFirstChargeWindowFormNot:) name:kShowFirstRechargeView object:nil]; - [XPSkillCardPlayerManager shareInstance].isInRoom = YES; + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(myGiftEffectUpdate:) name:kRoomGiftEffectUpdateNotificationKey object:nil]; + [[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(showRoomFirstChargeWindowFormNot:) name:kShowFirstRechargeView object:nil]; + [XPSkillCardPlayerManager shareInstance].isInRoom = YES; } - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { - [self.menuContainerView menuResignFirstResponder]; + [self.menuContainerView menuResignFirstResponder]; } - (void)viewWillAppear:(BOOL)animated { - [super viewWillAppear:animated]; - [UIApplication sharedApplication].statusBarStyle = UIStatusBarStyleLightContent; + [super viewWillAppear:animated]; + [UIApplication sharedApplication].statusBarStyle = UIStatusBarStyleLightContent; } -(void)viewWillDisappear:(BOOL)animated{ [super viewWillDisappear:animated]; @@ -290,30 +290,30 @@ NSString * const kHadQuitOtherRoomKey = @"kHadQuitOtherRoomKey";//是否退出 [XPSkillCardPlayerManager shareInstance].isInRoomVC = NO; } - (void)viewDidAppear:(BOOL)animated { - [super viewDidAppear:animated]; + [super viewDidAppear:animated]; self.freeView.hidden = NO; self.navigationController.interactivePopGestureRecognizer.enabled = NO; [XPSkillCardPlayerManager shareInstance].isInRoomVC = YES; - if([XPSkillCardPlayerManager shareInstance].isInRoomFirstRecharge == YES && self.isShowFirstRecharge == NO){ - [XPSkillCardPlayerManager shareInstance].isInRoomFirstRecharge = NO; - ///获取首充次数 - [self.presenter getRoomFirstCharegWindow:self.roomUid]; - } + if([XPSkillCardPlayerManager shareInstance].isInRoomFirstRecharge == YES && self.isShowFirstRecharge == NO){ + [XPSkillCardPlayerManager shareInstance].isInRoomFirstRecharge = NO; + ///获取首充次数 + [self.presenter getRoomFirstCharegWindow:self.roomUid]; + } } #pragma mark - Private Method - (void)initSubViews { - self.view.backgroundColor = [UIColor clearColor]; - [self.view addSubview:self.backContainerView]; + self.view.backgroundColor = [UIColor clearColor]; + [self.view addSubview:self.backContainerView]; [self.view addSubview:self.littleGameView]; - [self.view addSubview:self.stageView]; - [self.view addSubview:self.messageContainerView]; - [self.view addSubview:self.quickMessageContainerView]; - [self.view addSubview:self.menuContainerView]; - [self.view addSubview:self.activityContainerView]; - [self.view addSubview:self.roomHeaderView]; - [self.view addSubview:self.functionView]; - [self.view addSubview:self.animationView]; + [self.view addSubview:self.stageView]; + [self.view addSubview:self.messageContainerView]; + [self.view addSubview:self.quickMessageContainerView]; + [self.view addSubview:self.menuContainerView]; + [self.view addSubview:self.activityContainerView]; + [self.view addSubview:self.roomHeaderView]; + [self.view addSubview:self.functionView]; + [self.view addSubview:self.animationView]; self.activityContainerView.hidden = YES; self.littleGameView.hidden = YES; if ([ClientConfig shareConfig].canOpen) { @@ -323,168 +323,168 @@ NSString * const kHadQuitOtherRoomKey = @"kHadQuitOtherRoomKey";//是否退出 } - (void)initSubViewConstraints { - [self.backContainerView mas_makeConstraints:^(MASConstraintMaker *make) { - make.edges.mas_equalTo(self.view); - }]; + [self.backContainerView mas_makeConstraints:^(MASConstraintMaker *make) { + make.edges.mas_equalTo(self.view); + }]; [self.littleGameView mas_makeConstraints:^(MASConstraintMaker *make) { make.edges.mas_equalTo(self.view); }]; - [self.roomHeaderView mas_makeConstraints:^(MASConstraintMaker *make) { - make.left.right.top.mas_equalTo(self.view); - make.height.mas_equalTo(kNavigationHeight); - }]; + [self.roomHeaderView mas_makeConstraints:^(MASConstraintMaker *make) { + make.left.right.top.mas_equalTo(self.view); + make.height.mas_equalTo(kNavigationHeight); + }]; - [self.stageView mas_makeConstraints:^(MASConstraintMaker *make) { - make.left.right.mas_equalTo(self.view); - make.top.mas_equalTo(self.roomHeaderView.mas_bottom); - make.height.mas_equalTo(self.stageView.hightForStageView); - }]; + [self.stageView mas_makeConstraints:^(MASConstraintMaker *make) { + make.left.right.mas_equalTo(self.view); + make.top.mas_equalTo(self.roomHeaderView.mas_bottom); + make.height.mas_equalTo(self.stageView.hightForStageView); + }]; - [self.messageContainerView mas_makeConstraints:^(MASConstraintMaker *make) { - make.top.equalTo(self.stageView.mas_bottom); - make.bottom.equalTo(self.quickMessageContainerView.mas_top).offset(-5); - make.left.equalTo(self.view); - make.right.equalTo(self.activityContainerView.mas_left).offset(-10); - }]; - CGFloat quickMsgHeight = 30; - //记录最后关闭时间 - NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; - NSNumber *closeCount = [defaults objectForKey:kRoomQuickMessageCloseCount]; - if (closeCount.intValue > 3) { - quickMsgHeight = 0; - } else { - quickMsgHeight = 30; - } - [self.quickMessageContainerView mas_makeConstraints:^(MASConstraintMaker *make) { - make.bottom.mas_equalTo(self.menuContainerView.mas_top); - make.height.mas_equalTo(quickMsgHeight); - make.left.right.mas_equalTo(self.view); - }]; - [self.menuContainerView mas_makeConstraints:^(MASConstraintMaker *make) { + [self.messageContainerView mas_makeConstraints:^(MASConstraintMaker *make) { + make.top.equalTo(self.stageView.mas_bottom); + make.bottom.equalTo(self.quickMessageContainerView.mas_top).offset(-5); + make.left.equalTo(self.view); + make.right.equalTo(self.activityContainerView.mas_left).offset(-10); + }]; + CGFloat quickMsgHeight = 30; + //记录最后关闭时间 + NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; + NSNumber *closeCount = [defaults objectForKey:kRoomQuickMessageCloseCount]; + if (closeCount.intValue > 3) { + quickMsgHeight = 0; + } else { + quickMsgHeight = 30; + } + [self.quickMessageContainerView mas_makeConstraints:^(MASConstraintMaker *make) { + make.bottom.mas_equalTo(self.menuContainerView.mas_top); + make.height.mas_equalTo(quickMsgHeight); + make.left.right.mas_equalTo(self.view); + }]; + [self.menuContainerView mas_makeConstraints:^(MASConstraintMaker *make) { make.left.right.bottom.mas_equalTo(self.view); make.height.mas_equalTo(52 + kSafeAreaBottomHeight); - }]; + }]; - [self.activityContainerView mas_makeConstraints:^(MASConstraintMaker *make) { - make.top.mas_equalTo(self.messageContainerView); - make.right.mas_equalTo(self.view); - make.bottom.mas_equalTo(self.quickMessageContainerView.mas_top).offset(-5); - make.width.mas_equalTo(80); - }]; - - [self.animationView mas_makeConstraints:^(MASConstraintMaker *make) { - make.edges.mas_equalTo(self.view); - }]; + [self.activityContainerView mas_makeConstraints:^(MASConstraintMaker *make) { + make.top.mas_equalTo(self.messageContainerView); + make.right.mas_equalTo(self.view); + make.bottom.mas_equalTo(self.quickMessageContainerView.mas_top).offset(-5); + make.width.mas_equalTo(80); + }]; + + [self.animationView mas_makeConstraints:^(MASConstraintMaker *make) { + make.edges.mas_equalTo(self.view); + }]; - [self.functionView mas_makeConstraints:^(MASConstraintMaker *make) { - make.edges.mas_equalTo(self.view); - }]; + [self.functionView mas_makeConstraints:^(MASConstraintMaker *make) { + make.edges.mas_equalTo(self.view); + }]; } - (void)updateViewConstraintsOnAnchorRoom { - [self.anchorScrollView mas_makeConstraints:^(MASConstraintMaker *make) { - make.edges.mas_equalTo(self.view); - }]; - [self.backContainerView mas_makeConstraints:^(MASConstraintMaker *make) { - make.edges.mas_equalTo(self.anchorScrollView.middleImageView); - }]; - [self.roomHeaderView mas_makeConstraints:^(MASConstraintMaker *make) { - make.left.right.top.mas_equalTo(self.anchorScrollView.middleImageView); - make.height.mas_equalTo(kNavigationHeight); - }]; - [self.stageView mas_makeConstraints:^(MASConstraintMaker *make) { - make.left.right.mas_equalTo(self.anchorScrollView.middleImageView); - make.top.mas_equalTo(self.roomHeaderView.mas_bottom); - make.height.mas_equalTo(self.stageView.hightForStageView); - }]; - [self.messageContainerView mas_makeConstraints:^(MASConstraintMaker *make) { - make.top.equalTo(self.stageView.mas_bottom); - make.bottom.mas_equalTo(self.quickMessageContainerView.mas_top).mas_offset(-5); - make.left.equalTo(self.anchorScrollView.middleImageView); - make.right.equalTo(self.activityContainerView.mas_left).offset(-10); - }]; - [self.quickMessageContainerView mas_makeConstraints:^(MASConstraintMaker *make) { - make.height.mas_equalTo(30); - make.bottom.mas_equalTo(self.backContainerView).mas_offset(-5-40-8-kSafeAreaBottomHeight); - make.left.equalTo(self.anchorScrollView.middleImageView); - make.right.equalTo(self.activityContainerView.mas_left).offset(-10); - }]; - [self.menuContainerView mas_makeConstraints:^(MASConstraintMaker *make) { + [self.anchorScrollView mas_makeConstraints:^(MASConstraintMaker *make) { + make.edges.mas_equalTo(self.view); + }]; + [self.backContainerView mas_makeConstraints:^(MASConstraintMaker *make) { + make.edges.mas_equalTo(self.anchorScrollView.middleImageView); + }]; + [self.roomHeaderView mas_makeConstraints:^(MASConstraintMaker *make) { + make.left.right.top.mas_equalTo(self.anchorScrollView.middleImageView); + make.height.mas_equalTo(kNavigationHeight); + }]; + [self.stageView mas_makeConstraints:^(MASConstraintMaker *make) { + make.left.right.mas_equalTo(self.anchorScrollView.middleImageView); + make.top.mas_equalTo(self.roomHeaderView.mas_bottom); + make.height.mas_equalTo(self.stageView.hightForStageView); + }]; + [self.messageContainerView mas_makeConstraints:^(MASConstraintMaker *make) { + make.top.equalTo(self.stageView.mas_bottom); + make.bottom.mas_equalTo(self.quickMessageContainerView.mas_top).mas_offset(-5); + make.left.equalTo(self.anchorScrollView.middleImageView); + make.right.equalTo(self.activityContainerView.mas_left).offset(-10); + }]; + [self.quickMessageContainerView mas_makeConstraints:^(MASConstraintMaker *make) { + make.height.mas_equalTo(30); + make.bottom.mas_equalTo(self.backContainerView).mas_offset(-5-40-8-kSafeAreaBottomHeight); + make.left.equalTo(self.anchorScrollView.middleImageView); + make.right.equalTo(self.activityContainerView.mas_left).offset(-10); + }]; + [self.menuContainerView mas_makeConstraints:^(MASConstraintMaker *make) { make.left.right.bottom.mas_equalTo(self.anchorScrollView.middleImageView); make.height.mas_equalTo(52 + kSafeAreaBottomHeight); - }]; - [self.activityContainerView mas_makeConstraints:^(MASConstraintMaker *make) { - make.top.mas_equalTo(self.messageContainerView); - make.right.mas_equalTo(self.anchorScrollView.middleImageView); - make.bottom.mas_equalTo(self.quickMessageContainerView.mas_top).mas_offset(-5); - make.width.mas_equalTo(80); - }]; - [self.functionView mas_makeConstraints:^(MASConstraintMaker *make) { - make.edges.mas_equalTo(self.anchorScrollView.middleImageView); - }]; + }]; + [self.activityContainerView mas_makeConstraints:^(MASConstraintMaker *make) { + make.top.mas_equalTo(self.messageContainerView); + make.right.mas_equalTo(self.anchorScrollView.middleImageView); + make.bottom.mas_equalTo(self.quickMessageContainerView.mas_top).mas_offset(-5); + make.width.mas_equalTo(80); + }]; + [self.functionView mas_makeConstraints:^(MASConstraintMaker *make) { + make.edges.mas_equalTo(self.anchorScrollView.middleImageView); + }]; } - (void)exitOldRoom { - NSString * roomUid = [NSString stringWithFormat:@"%ld", [XPRoomMiniManager shareManager].getRoomInfo.uid]; - if (roomUid.integerValue > 0 && roomUid.integerValue != self.roomUid.integerValue) { - //有最小化房间 并且要进入的房间和最小化的房间不一样的话 就先退掉 最小化的房间 - NSString * roomId = [NSString stringWithFormat:@"%ld", [XPRoomMiniManager shareManager].getRoomInfo.roomId]; - [self.presenter exitNIMRoom:roomId]; - [[RtcManager instance] exitRoom]; - [[XPRoomMiniManager shareManager] resetLocalMessage]; - [self.presenter reportUserOutRoom:roomUid]; - } + NSString * roomUid = [NSString stringWithFormat:@"%ld", [XPRoomMiniManager shareManager].getRoomInfo.uid]; + if (roomUid.integerValue > 0 && roomUid.integerValue != self.roomUid.integerValue) { + //有最小化房间 并且要进入的房间和最小化的房间不一样的话 就先退掉 最小化的房间 + NSString * roomId = [NSString stringWithFormat:@"%ld", [XPRoomMiniManager shareManager].getRoomInfo.roomId]; + [self.presenter exitNIMRoom:roomId]; + [[RtcManager instance] exitRoom]; + [[XPRoomMiniManager shareManager] resetLocalMessage]; + [self.presenter reportUserOutRoom:roomUid]; + } } - (void)userEnterRoomSuccess { - AttachmentModel *attachment = [[AttachmentModel alloc]init]; - attachment.first = CustomMessageType_Car_Notify; - attachment.second = Custom_Message_Sub_Car_EnterRoom; - NSMutableDictionary *att = [NSMutableDictionary dictionary]; - if (self.userInfo.userVipInfoVO.enterHide) {///贵族隐身进房,不发座驾消息 - return; - } - if (self.userInfo.viewUrl.length > 0) { - [att safeSetObject:self.userInfo.nick forKey:@"nick"]; - [att safeSetObject:self.userInfo.viewUrl forKey:@"viewUrl"]; - [att safeSetObject:@(self.userInfo.otherViewType) forKey:@"otherViewType"]; - } else if (self.userInfo.carEffect.length > 0) { - [att safeSetObject:self.userInfo.carEffect forKey:@"effect"]; - [att safeSetObject:self.userInfo.nick forKey:@"nick"]; - } else { - return; - } - attachment.data = att; - NSString *sessionID = [NSString stringWithFormat:@"%ld",self.roomInfo.roomId]; - NIMMessage *message = [[NIMMessage alloc]init]; - NIMCustomObject *object = [[NIMCustomObject alloc] init]; - object.attachment = attachment; - message.messageObject = object; - //构造会话 - NIMSession *session = [NIMSession session:sessionID type:NIMSessionTypeChatroom]; - [[NIMSDK sharedSDK].chatManager sendMessage:message toSession:session error:nil]; + AttachmentModel *attachment = [[AttachmentModel alloc]init]; + attachment.first = CustomMessageType_Car_Notify; + attachment.second = Custom_Message_Sub_Car_EnterRoom; + NSMutableDictionary *att = [NSMutableDictionary dictionary]; + if (self.userInfo.userVipInfoVO.enterHide) {///贵族隐身进房,不发座驾消息 + return; + } + if (self.userInfo.viewUrl.length > 0) { + [att safeSetObject:self.userInfo.nick forKey:@"nick"]; + [att safeSetObject:self.userInfo.viewUrl forKey:@"viewUrl"]; + [att safeSetObject:@(self.userInfo.otherViewType) forKey:@"otherViewType"]; + } else if (self.userInfo.carEffect.length > 0) { + [att safeSetObject:self.userInfo.carEffect forKey:@"effect"]; + [att safeSetObject:self.userInfo.nick forKey:@"nick"]; + } else { + return; + } + attachment.data = att; + NSString *sessionID = [NSString stringWithFormat:@"%ld",self.roomInfo.roomId]; + NIMMessage *message = [[NIMMessage alloc]init]; + NIMCustomObject *object = [[NIMCustomObject alloc] init]; + object.attachment = attachment; + message.messageObject = object; + //构造会话 + NIMSession *session = [NIMSession session:sessionID type:NIMSessionTypeChatroom]; + [[NIMSDK sharedSDK].chatManager sendMessage:message toSession:session error:nil]; } - (void)changeStageViewOnRoomUpdate { - if (self.roomInfo.roomModeType == RoomModeType_Open_Blind && ![self.stageView isKindOfClass:[DatingStageView class]]) { - [self.stageView removeFromSuperview]; - self.stageView = nil; - self.stageView = [[DatingStageView alloc] initWithDelegate:self]; - } else if(self.roomInfo.datingState == RoomDatingStateChangeType_Close && ![self.stageView isKindOfClass:[SocialStageView class]]) { - [self.stageView removeFromSuperview]; - self.stageView = nil; - self.stageView = [[SocialStageView alloc] initWithDelegate:self]; - } else if (self.roomInfo.type == RoomType_Anchor) { - if (self.roomInfo.roomModeType == RoomModeType_Open_AcrossRoomPK_mode && ![self.stageView isKindOfClass:[AnchorPKStageView class]]) { - [self.stageView removeFromSuperview]; - self.stageView = nil; - self.stageView = [[AnchorPKStageView alloc] initWithDelegate:self]; - } else if(self.roomInfo.roomModeType == RoomModeType_Normal_Mode && ![self.stageView isKindOfClass:[AnchorStageView class]]) { - [self.stageView removeFromSuperview]; - self.stageView = nil; - self.stageView = [[AnchorStageView alloc] initWithDelegate:self]; - } - }else if(self.roomInfo.type == RoomType_MiniGame) { + if (self.roomInfo.roomModeType == RoomModeType_Open_Blind && ![self.stageView isKindOfClass:[DatingStageView class]]) { + [self.stageView removeFromSuperview]; + self.stageView = nil; + self.stageView = [[DatingStageView alloc] initWithDelegate:self]; + } else if(self.roomInfo.datingState == RoomDatingStateChangeType_Close && ![self.stageView isKindOfClass:[SocialStageView class]]) { + [self.stageView removeFromSuperview]; + self.stageView = nil; + self.stageView = [[SocialStageView alloc] initWithDelegate:self]; + } else if (self.roomInfo.type == RoomType_Anchor) { + if (self.roomInfo.roomModeType == RoomModeType_Open_AcrossRoomPK_mode && ![self.stageView isKindOfClass:[AnchorPKStageView class]]) { + [self.stageView removeFromSuperview]; + self.stageView = nil; + self.stageView = [[AnchorPKStageView alloc] initWithDelegate:self]; + } else if(self.roomInfo.roomModeType == RoomModeType_Normal_Mode && ![self.stageView isKindOfClass:[AnchorStageView class]]) { + [self.stageView removeFromSuperview]; + self.stageView = nil; + self.stageView = [[AnchorStageView alloc] initWithDelegate:self]; + } + }else if(self.roomInfo.type == RoomType_MiniGame) { if (self.roomInfo.mgMicNum > 6 && ![self.stageView isKindOfClass:[LittleGameScrollStageView class]]) { [self.stageView removeFromSuperview]; self.stageView = nil; @@ -495,122 +495,122 @@ NSString * const kHadQuitOtherRoomKey = @"kHadQuitOtherRoomKey";//是否退出 self.stageView = [[LittleGameStageView alloc] initWithDelegate:self]; } }else if(self.roomInfo.hadChangeRoomType && ![self.stageView isKindOfClass:[SocialStageView class]]) { - [self.stageView removeFromSuperview]; - self.stageView = nil; - self.stageView = [[SocialStageView alloc] initWithDelegate:self]; - } else { - return; - } + [self.stageView removeFromSuperview]; + self.stageView = nil; + self.stageView = [[SocialStageView alloc] initWithDelegate:self]; + } else { + return; + } - - if (!self.stageView.superview) { - [self.view insertSubview:self.stageView belowSubview:self.roomHeaderView]; - } + + if (!self.stageView.superview) { + [self.view insertSubview:self.stageView belowSubview:self.roomHeaderView]; + } [self.functionView updateRankViewConstraintsWityType:self.roomInfo.type]; - if (self.roomInfo.type == RoomType_MiniGame) { - [self.stageView mas_remakeConstraints:^(MASConstraintMaker *make) { - make.left.right.mas_equalTo(self.view); - make.top.mas_equalTo(self.roomHeaderView.mas_bottom).offset(26 + 4); - make.height.mas_equalTo(self.stageView.hightForStageView); - }]; + if (self.roomInfo.type == RoomType_MiniGame) { + [self.stageView mas_remakeConstraints:^(MASConstraintMaker *make) { + make.left.right.mas_equalTo(self.view); + make.top.mas_equalTo(self.roomHeaderView.mas_bottom).offset(26 + 4); + make.height.mas_equalTo(self.stageView.hightForStageView); + }]; CGFloat height = 70; if (iPhoneXSeries) { height = 70; } else { height = 50; } - [self.messageContainerView mas_remakeConstraints:^(MASConstraintMaker *make) { - make.height.mas_equalTo(height); - make.bottom.mas_equalTo(self.quickMessageContainerView.mas_top).offset(-5); - make.left.mas_equalTo(self.view); - make.right.mas_equalTo(self.activityContainerView.mas_left).offset(-10); - }]; + [self.messageContainerView mas_remakeConstraints:^(MASConstraintMaker *make) { + make.height.mas_equalTo(height); + make.bottom.mas_equalTo(self.quickMessageContainerView.mas_top).offset(-5); + make.left.mas_equalTo(self.view); + make.right.mas_equalTo(self.activityContainerView.mas_left).offset(-10); + }]; self.quickMessageContainerView.hidden = YES; [self.quickMessageContainerView mas_updateConstraints:^(MASConstraintMaker *make) { make.height.mas_equalTo(0); }]; - [self.activityContainerView mas_remakeConstraints:^(MASConstraintMaker *make) { - make.height.mas_equalTo(65); - make.right.mas_equalTo(self.view); - make.bottom.mas_equalTo(self.quickMessageContainerView.mas_top).offset(-5); - make.width.mas_equalTo(80); - }]; + [self.activityContainerView mas_remakeConstraints:^(MASConstraintMaker *make) { + make.height.mas_equalTo(65); + make.right.mas_equalTo(self.view); + make.bottom.mas_equalTo(self.quickMessageContainerView.mas_top).offset(-5); + make.width.mas_equalTo(80); + }]; - } else { + } else { self.quickMessageContainerView.hidden = NO; [self.quickMessageContainerView mas_updateConstraints:^(MASConstraintMaker *make) { make.height.mas_equalTo(30); }]; - [self.stageView mas_remakeConstraints:^(MASConstraintMaker *make) { - make.left.right.mas_equalTo(self.view); - make.top.mas_equalTo(self.roomHeaderView.mas_bottom); - make.height.mas_equalTo(self.stageView.hightForStageView); - }]; - - [self.messageContainerView mas_remakeConstraints:^(MASConstraintMaker *make) { - make.top.mas_equalTo(self.stageView.mas_bottom); - make.bottom.mas_equalTo(self.quickMessageContainerView.mas_top).offset(-5); - make.left.mas_equalTo(self.view); - make.right.mas_equalTo(self.activityContainerView.mas_left).offset(-10); - }]; - - [self.activityContainerView mas_remakeConstraints:^(MASConstraintMaker *make) { - make.top.mas_equalTo(self.messageContainerView); - make.right.mas_equalTo(self.view); - make.bottom.mas_equalTo(self.quickMessageContainerView.mas_top).offset(-5); - make.width.mas_equalTo(80); - }]; - } + [self.stageView mas_remakeConstraints:^(MASConstraintMaker *make) { + make.left.right.mas_equalTo(self.view); + make.top.mas_equalTo(self.roomHeaderView.mas_bottom); + make.height.mas_equalTo(self.stageView.hightForStageView); + }]; + + [self.messageContainerView mas_remakeConstraints:^(MASConstraintMaker *make) { + make.top.mas_equalTo(self.stageView.mas_bottom); + make.bottom.mas_equalTo(self.quickMessageContainerView.mas_top).offset(-5); + make.left.mas_equalTo(self.view); + make.right.mas_equalTo(self.activityContainerView.mas_left).offset(-10); + }]; + + [self.activityContainerView mas_remakeConstraints:^(MASConstraintMaker *make) { + make.top.mas_equalTo(self.messageContainerView); + make.right.mas_equalTo(self.view); + make.bottom.mas_equalTo(self.quickMessageContainerView.mas_top).offset(-5); + make.width.mas_equalTo(80); + }]; + } } - (void)changeStageViewOnAnchorRoom { - if (self.roomInfo.roomModeType == RoomModeType_Open_AcrossRoomPK_mode && ![self.stageView isKindOfClass:[AnchorPKStageView class]]) { - [self.stageView removeFromSuperview]; - self.stageView = nil; - self.stageView = [[AnchorPKStageView alloc] initWithDelegate:self]; - } else if(self.roomInfo.roomModeType == RoomModeType_Normal_Mode && ![self.stageView isKindOfClass:[AnchorStageView class]]) { - [self.stageView removeFromSuperview]; - self.stageView = nil; - self.stageView = [[AnchorStageView alloc] initWithDelegate:self]; - } - if (!self.stageView.superview) { - [self.anchorScrollView insertSubview:self.stageView belowSubview:self.roomHeaderView]; - } + if (self.roomInfo.roomModeType == RoomModeType_Open_AcrossRoomPK_mode && ![self.stageView isKindOfClass:[AnchorPKStageView class]]) { + [self.stageView removeFromSuperview]; + self.stageView = nil; + self.stageView = [[AnchorPKStageView alloc] initWithDelegate:self]; + } else if(self.roomInfo.roomModeType == RoomModeType_Normal_Mode && ![self.stageView isKindOfClass:[AnchorStageView class]]) { + [self.stageView removeFromSuperview]; + self.stageView = nil; + self.stageView = [[AnchorStageView alloc] initWithDelegate:self]; + } + if (!self.stageView.superview) { + [self.anchorScrollView insertSubview:self.stageView belowSubview:self.roomHeaderView]; + } - [self.stageView mas_remakeConstraints:^(MASConstraintMaker *make) { - make.left.right.mas_equalTo(self.anchorScrollView.middleImageView); - make.top.mas_equalTo(self.roomHeaderView.mas_bottom); - make.height.mas_equalTo(self.stageView.hightForStageView); - }]; - [self.messageContainerView mas_remakeConstraints:^(MASConstraintMaker *make) { - make.top.mas_equalTo(self.stageView.mas_bottom); - make.bottom.mas_equalTo(self.quickMessageContainerView.mas_top).mas_offset(-5); - make.left.mas_equalTo(self.anchorScrollView.middleImageView); - make.right.mas_equalTo(self.activityContainerView.mas_left).offset(-10); - }]; + [self.stageView mas_remakeConstraints:^(MASConstraintMaker *make) { + make.left.right.mas_equalTo(self.anchorScrollView.middleImageView); + make.top.mas_equalTo(self.roomHeaderView.mas_bottom); + make.height.mas_equalTo(self.stageView.hightForStageView); + }]; + [self.messageContainerView mas_remakeConstraints:^(MASConstraintMaker *make) { + make.top.mas_equalTo(self.stageView.mas_bottom); + make.bottom.mas_equalTo(self.quickMessageContainerView.mas_top).mas_offset(-5); + make.left.mas_equalTo(self.anchorScrollView.middleImageView); + make.right.mas_equalTo(self.activityContainerView.mas_left).offset(-10); + }]; - CGFloat quickMsgHeight = 30; - //记录最后关闭时间 - NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; - NSNumber *closeCount = [defaults objectForKey:kRoomQuickMessageCloseCount]; - if (closeCount.intValue > 3 || self.roomInfo.speakTemplate.count <=0) { - quickMsgHeight = 0; - } else { - quickMsgHeight = 30; - } - self.quickMessageContainerView.titleArray = self.roomInfo.speakTemplate; - [self.quickMessageContainerView mas_remakeConstraints:^(MASConstraintMaker *make) { - make.height.mas_equalTo(quickMsgHeight); - make.bottom.mas_equalTo(self.backContainerView).mas_offset(-5-40-8-kSafeAreaBottomHeight); - make.left.right.mas_equalTo(self.anchorScrollView.middleImageView); - }]; - [self.activityContainerView mas_remakeConstraints:^(MASConstraintMaker *make) { - make.top.mas_equalTo(self.messageContainerView); - make.right.mas_equalTo(self.anchorScrollView.middleImageView); - make.bottom.mas_equalTo(self.quickMessageContainerView.mas_top).mas_offset(-5); - make.width.mas_equalTo(80); - }]; + CGFloat quickMsgHeight = 30; + //记录最后关闭时间 + NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; + NSNumber *closeCount = [defaults objectForKey:kRoomQuickMessageCloseCount]; + if (closeCount.intValue > 3 || self.roomInfo.speakTemplate.count <=0) { + quickMsgHeight = 0; + } else { + quickMsgHeight = 30; + } + self.quickMessageContainerView.titleArray = self.roomInfo.speakTemplate; + [self.quickMessageContainerView mas_remakeConstraints:^(MASConstraintMaker *make) { + make.height.mas_equalTo(quickMsgHeight); + make.bottom.mas_equalTo(self.backContainerView).mas_offset(-5-40-8-kSafeAreaBottomHeight); + make.left.right.mas_equalTo(self.anchorScrollView.middleImageView); + }]; + [self.activityContainerView mas_remakeConstraints:^(MASConstraintMaker *make) { + make.top.mas_equalTo(self.messageContainerView); + make.right.mas_equalTo(self.anchorScrollView.middleImageView); + make.bottom.mas_equalTo(self.quickMessageContainerView.mas_top).mas_offset(-5); + make.width.mas_equalTo(80); + }]; } #pragma mark - CountDownHelperDelegate @@ -637,225 +637,225 @@ NSString * const kHadQuitOtherRoomKey = @"kHadQuitOtherRoomKey";//是否退出 } -(void)showRoomFirstChargeWindowFormNot:(NSNotification *)not{ - if(not != nil){ - NSDictionary *parameter = not.object; - if(parameter != nil){ - self.firstRechargeView.type = parameter[@"type"]; - self.firstRechargeView.diamonds = parameter[@"diamonds"]; - } - } - [NSObject cancelPreviousPerformRequestsWithTarget:self selector:@selector(showRoomFirstChargeWindow) object:nil]; - [[UIApplication sharedApplication].keyWindow addSubview:self.firstRechargeView]; - [self.presenter updateRoomFirstCharegWindow:self.roomUid]; + if(not != nil){ + NSDictionary *parameter = not.object; + if(parameter != nil){ + self.firstRechargeView.type = parameter[@"type"]; + self.firstRechargeView.diamonds = parameter[@"diamonds"]; + } + } + [NSObject cancelPreviousPerformRequestsWithTarget:self selector:@selector(showRoomFirstChargeWindow) object:nil]; + [[UIApplication sharedApplication].keyWindow addSubview:self.firstRechargeView]; + [self.presenter updateRoomFirstCharegWindow:self.roomUid]; } -(void)showRoomFirstChargeWindow{ - if([XPSkillCardPlayerManager shareInstance].isInRoomFirstRecharge == YES){ - self.isShowFirstRecharge = NO; - return; - } - UIViewController *viewController = [XCCurrentVCStackManager shareManager].getCurrentVC; - if(![viewController isKindOfClass:[XPRoomViewController class]]){ - [viewController dismissViewControllerAnimated:YES completion:nil]; - } - self.isShowFirstRecharge = NO; - [self.presenter updateRoomFirstCharegWindow:self.roomUid]; - [[UIApplication sharedApplication].keyWindow addSubview:self.firstRechargeView]; + if([XPSkillCardPlayerManager shareInstance].isInRoomFirstRecharge == YES){ + self.isShowFirstRecharge = NO; + return; + } + UIViewController *viewController = [XCCurrentVCStackManager shareManager].getCurrentVC; + if(![viewController isKindOfClass:[XPRoomViewController class]]){ + [viewController dismissViewControllerAnimated:YES completion:nil]; + } + self.isShowFirstRecharge = NO; + [self.presenter updateRoomFirstCharegWindow:self.roomUid]; + [[UIApplication sharedApplication].keyWindow addSubview:self.firstRechargeView]; } - (void)cancelRoomArrangeMic { - ///退出排麦 - if (self.roomInfo.roomModeType == RoomModeType_Open_Micro_Mode || self.roomInfo.roomModeType == RoomModeType_Open_Blind) { - NSString * roomUid = [NSString stringWithFormat:@"%ld", self.roomInfo.uid]; - NSString * uid = [AccountInfoStorage instance].getUid; - [Api getRoomArrangeMicList:^(BaseModel * _Nullable data, NSInteger code, NSString * _Nullable msg) { - if (code == 200) { - ArrangeMicModel * arrangeMicModel= [ArrangeMicModel modelWithJSON:data.data]; - if (arrangeMicModel.myPos.intValue > 0) { - __block NSString * grouptype = @"0"; - if (self.roomInfo.roomModeType == RoomModeType_Open_Blind) { - [arrangeMicModel.queue enumerateObjectsUsingBlock:^(ArrangeMicUserModel * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) { - if (obj.uid.integerValue == [AccountInfoStorage instance].getUid.integerValue) { - grouptype = [NSString stringWithFormat:@"%ld", obj.groupType]; - *stop = YES; - } - }]; - - } - [Api cancelArrangeMic:^(BaseModel * _Nullable data, NSInteger code, NSString * _Nullable msg) {} roomUid:roomUid operUid:uid groupType:grouptype]; - } - } - } roomUid:roomUid operUid:uid page:@"1" pageSize:@"50"]; - }else if(self.roomInfo.roomModeType == RoomModeType_Open_PK_Mode) { - NSString * roomUid = [NSString stringWithFormat:@"%ld", self.roomInfo.uid]; - NSString * uid = [AccountInfoStorage instance].getUid; - [Api getRoomPKUserList:^(BaseModel * _Nullable data, NSInteger code, NSString * _Nullable msg) { - if (code == 200) { - ArrangeMicModel * arrangeMicModel= [ArrangeMicModel modelWithJSON:data.data]; - if (arrangeMicModel.myPos.intValue > 0) { - __block NSString * grouptype = @"0"; - [arrangeMicModel.queue enumerateObjectsUsingBlock:^(ArrangeMicUserModel * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) { - if (obj.uid.integerValue == [AccountInfoStorage instance].getUid.integerValue) { - grouptype = [NSString stringWithFormat:@"%ld", obj.groupType]; - *stop = YES; - } - }]; - [Api cancelRoomPKArrangeMic:^(BaseModel * _Nullable data, NSInteger code, NSString * _Nullable msg) { - - } roomUid:roomUid operUid:uid groupType:grouptype]; - } - } - } roomUid:roomUid operUid:uid page:@"1" pageSize:@"50"]; - } + ///退出排麦 + if (self.roomInfo.roomModeType == RoomModeType_Open_Micro_Mode || self.roomInfo.roomModeType == RoomModeType_Open_Blind) { + NSString * roomUid = [NSString stringWithFormat:@"%ld", self.roomInfo.uid]; + NSString * uid = [AccountInfoStorage instance].getUid; + [Api getRoomArrangeMicList:^(BaseModel * _Nullable data, NSInteger code, NSString * _Nullable msg) { + if (code == 200) { + ArrangeMicModel * arrangeMicModel= [ArrangeMicModel modelWithJSON:data.data]; + if (arrangeMicModel.myPos.intValue > 0) { + __block NSString * grouptype = @"0"; + if (self.roomInfo.roomModeType == RoomModeType_Open_Blind) { + [arrangeMicModel.queue enumerateObjectsUsingBlock:^(ArrangeMicUserModel * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) { + if (obj.uid.integerValue == [AccountInfoStorage instance].getUid.integerValue) { + grouptype = [NSString stringWithFormat:@"%ld", obj.groupType]; + *stop = YES; + } + }]; + + } + [Api cancelArrangeMic:^(BaseModel * _Nullable data, NSInteger code, NSString * _Nullable msg) {} roomUid:roomUid operUid:uid groupType:grouptype]; + } + } + } roomUid:roomUid operUid:uid page:@"1" pageSize:@"50"]; + }else if(self.roomInfo.roomModeType == RoomModeType_Open_PK_Mode) { + NSString * roomUid = [NSString stringWithFormat:@"%ld", self.roomInfo.uid]; + NSString * uid = [AccountInfoStorage instance].getUid; + [Api getRoomPKUserList:^(BaseModel * _Nullable data, NSInteger code, NSString * _Nullable msg) { + if (code == 200) { + ArrangeMicModel * arrangeMicModel= [ArrangeMicModel modelWithJSON:data.data]; + if (arrangeMicModel.myPos.intValue > 0) { + __block NSString * grouptype = @"0"; + [arrangeMicModel.queue enumerateObjectsUsingBlock:^(ArrangeMicUserModel * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) { + if (obj.uid.integerValue == [AccountInfoStorage instance].getUid.integerValue) { + grouptype = [NSString stringWithFormat:@"%ld", obj.groupType]; + *stop = YES; + } + }]; + [Api cancelRoomPKArrangeMic:^(BaseModel * _Nullable data, NSInteger code, NSString * _Nullable msg) { + + } roomUid:roomUid operUid:uid groupType:grouptype]; + } + } + } roomUid:roomUid operUid:uid page:@"1" pageSize:@"50"]; + } } ///超管进入密码房间 - (void)superAdminEnterPwdRoom:(RoomInfoModel *)roomInfo { - __block BOOL isSuperAdmin = NO; - [self.superMangerList enumerateObjectsUsingBlock:^(GuildSuperAdminInfoModel * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) { - if ([obj.uid isEqualToString:[AccountInfoStorage instance].getUid]) { - isSuperAdmin = YES; - *stop = YES; - } - }]; - if (!isSuperAdmin) { - XPRoomSettingInputView * titleView = [[XPRoomSettingInputView alloc] init]; - titleView.maxCount = 15; - titleView.delegate = self; - titleView.type = RoomSettingInputType_Input_Pwd; - TTPopupConfig * config = [[TTPopupConfig alloc] init]; - config.contentView = titleView; - config.maskBackgroundAlpha = 1; - config.shouldDismissOnBackgroundTouch = NO; - [TTPopup popupWithConfig:config]; - } else { - self.roomInfo.datingState = roomInfo.roomModeType == RoomModeType_Open_Blind ? RoomDatingStateChangeType_Open : RoomDatingStateChangeType_Normal; - [self changeStageViewOnRoomUpdate]; - [self.roomHeaderView onRoomEntered]; - [self.activityContainerView onRoomEntered]; - [self.menuContainerView onRoomEntered]; - [self.backContainerView onRoomEntered]; + __block BOOL isSuperAdmin = NO; + [self.superMangerList enumerateObjectsUsingBlock:^(GuildSuperAdminInfoModel * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) { + if ([obj.uid isEqualToString:[AccountInfoStorage instance].getUid]) { + isSuperAdmin = YES; + *stop = YES; + } + }]; + if (!isSuperAdmin) { + XPRoomSettingInputView * titleView = [[XPRoomSettingInputView alloc] init]; + titleView.maxCount = 15; + titleView.delegate = self; + titleView.type = RoomSettingInputType_Input_Pwd; + TTPopupConfig * config = [[TTPopupConfig alloc] init]; + config.contentView = titleView; + config.maskBackgroundAlpha = 1; + config.shouldDismissOnBackgroundTouch = NO; + [TTPopup popupWithConfig:config]; + } else { + self.roomInfo.datingState = roomInfo.roomModeType == RoomModeType_Open_Blind ? RoomDatingStateChangeType_Open : RoomDatingStateChangeType_Normal; + [self changeStageViewOnRoomUpdate]; + [self.roomHeaderView onRoomEntered]; + [self.activityContainerView onRoomEntered]; + [self.menuContainerView onRoomEntered]; + [self.backContainerView onRoomEntered]; [self.littleGameView onRoomEntered]; - if ([XPRoomMiniManager shareManager].getRoomInfo.uid != self.roomUid.integerValue) {// 最小化进房 还是原来的房间的话 不需要重新进入云信 因为压根没退 - [self.presenter enterNIMRoom:[NSString stringWithFormat:@"%ld", self.roomInfo.roomId] user:self.userInfo]; - [self.functionView onRoomEntered]; - [self.messageContainerView onRoomEntered]; - } else { - //虽然没退出房间 但是队列还是要拿的 - [self.stageView onRoomMiniEntered]; - [self.messageContainerView onRoomMiniEntered]; - [self.functionView onRoomMiniEntered]; - [self.functionView onRoomEntered]; - } - [[XPRoomMiniManager shareManager] configRoomInfo:nil]; - [[XPRoomMiniManager shareManager] configUserInfo:nil]; - [[XPRoomMiniManager shareManager] configCurrentMusic:nil isPlaying:NO]; - } + if ([XPRoomMiniManager shareManager].getRoomInfo.uid != self.roomUid.integerValue) {// 最小化进房 还是原来的房间的话 不需要重新进入云信 因为压根没退 + [self.presenter enterNIMRoom:[NSString stringWithFormat:@"%ld", self.roomInfo.roomId] user:self.userInfo]; + [self.functionView onRoomEntered]; + [self.messageContainerView onRoomEntered]; + } else { + //虽然没退出房间 但是队列还是要拿的 + [self.stageView onRoomMiniEntered]; + [self.messageContainerView onRoomMiniEntered]; + [self.functionView onRoomMiniEntered]; + [self.functionView onRoomEntered]; + } + [[XPRoomMiniManager shareManager] configRoomInfo:nil]; + [[XPRoomMiniManager shareManager] configUserInfo:nil]; + [[XPRoomMiniManager shareManager] configCurrentMusic:nil isPlaying:NO]; + } } ///超管进个播有密码房间 - (void)handleSuperManagerEnterAnchorRoom:(RoomInfoModel *)roomInfo { - __block BOOL isSuperAdmin = NO; - [self.superMangerList enumerateObjectsUsingBlock:^(GuildSuperAdminInfoModel * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) { - if ([obj.uid isEqualToString:[AccountInfoStorage instance].getUid]) { - isSuperAdmin = YES; - *stop = YES; - } - }]; - if (!isSuperAdmin) { - XPRoomSettingInputView * titleView = [[XPRoomSettingInputView alloc] init]; - titleView.maxCount = 15; - titleView.delegate = self; - titleView.type = RoomSettingInputType_Input_Pwd; - TTPopupConfig * config = [[TTPopupConfig alloc] init]; - config.contentView = titleView; - config.maskBackgroundAlpha = 1; - config.shouldDismissOnBackgroundTouch = NO; - [TTPopup popupWithConfig:config]; - } else { - self.roomInfo.datingState = roomInfo.roomModeType == RoomModeType_Open_Blind ? RoomDatingStateChangeType_Open : RoomDatingStateChangeType_Normal; - if (!self.anchorScrollView.superview) { - [self.view insertSubview:self.anchorScrollView belowSubview:self.menuContainerView]; - } - [self.backContainerView removeFromSuperview]; - [self.stageView removeFromSuperview]; - [self.messageContainerView removeFromSuperview]; - [self.quickMessageContainerView removeFromSuperview]; - [self.activityContainerView removeFromSuperview]; - [self.roomHeaderView removeFromSuperview]; - [self.functionView removeFromSuperview]; + __block BOOL isSuperAdmin = NO; + [self.superMangerList enumerateObjectsUsingBlock:^(GuildSuperAdminInfoModel * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) { + if ([obj.uid isEqualToString:[AccountInfoStorage instance].getUid]) { + isSuperAdmin = YES; + *stop = YES; + } + }]; + if (!isSuperAdmin) { + XPRoomSettingInputView * titleView = [[XPRoomSettingInputView alloc] init]; + titleView.maxCount = 15; + titleView.delegate = self; + titleView.type = RoomSettingInputType_Input_Pwd; + TTPopupConfig * config = [[TTPopupConfig alloc] init]; + config.contentView = titleView; + config.maskBackgroundAlpha = 1; + config.shouldDismissOnBackgroundTouch = NO; + [TTPopup popupWithConfig:config]; + } else { + self.roomInfo.datingState = roomInfo.roomModeType == RoomModeType_Open_Blind ? RoomDatingStateChangeType_Open : RoomDatingStateChangeType_Normal; + if (!self.anchorScrollView.superview) { + [self.view insertSubview:self.anchorScrollView belowSubview:self.menuContainerView]; + } + [self.backContainerView removeFromSuperview]; + [self.stageView removeFromSuperview]; + [self.messageContainerView removeFromSuperview]; + [self.quickMessageContainerView removeFromSuperview]; + [self.activityContainerView removeFromSuperview]; + [self.roomHeaderView removeFromSuperview]; + [self.functionView removeFromSuperview]; - [self.anchorScrollView addSubview:self.backContainerView]; - [self.anchorScrollView addSubview:self.stageView]; - [self.anchorScrollView addSubview:self.messageContainerView]; - [self.anchorScrollView addSubview:self.quickMessageContainerView]; - [self.anchorScrollView addSubview:self.activityContainerView]; - [self.anchorScrollView addSubview:self.roomHeaderView]; - [self.anchorScrollView addSubview:self.functionView]; - if (!self.menuContainerView.superview) { - [self.view addSubview:self.menuContainerView]; - } - [self.view bringSubviewToFront:self.animationView]; + [self.anchorScrollView addSubview:self.backContainerView]; + [self.anchorScrollView addSubview:self.stageView]; + [self.anchorScrollView addSubview:self.messageContainerView]; + [self.anchorScrollView addSubview:self.quickMessageContainerView]; + [self.anchorScrollView addSubview:self.activityContainerView]; + [self.anchorScrollView addSubview:self.roomHeaderView]; + [self.anchorScrollView addSubview:self.functionView]; + if (!self.menuContainerView.superview) { + [self.view addSubview:self.menuContainerView]; + } + [self.view bringSubviewToFront:self.animationView]; - [self updateViewConstraintsOnAnchorRoom]; - [self changeStageViewOnAnchorRoom]; + [self updateViewConstraintsOnAnchorRoom]; + [self changeStageViewOnAnchorRoom]; - [self.roomHeaderView onRoomEntered]; - [self.activityContainerView onRoomEntered]; - [self.menuContainerView onRoomEntered]; - [self.backContainerView onRoomEntered]; + [self.roomHeaderView onRoomEntered]; + [self.activityContainerView onRoomEntered]; + [self.menuContainerView onRoomEntered]; + [self.backContainerView onRoomEntered]; [self.littleGameView onRoomEntered]; - if ([XPRoomMiniManager shareManager].getRoomInfo.uid != self.roomUid.integerValue) {// 最小化进房 还是原来的房间的话 不需要重新进入云信 因为压根没退 - [self.presenter enterNIMRoom:[NSString stringWithFormat:@"%ld", self.roomInfo.roomId] user:self.userInfo]; - [self.functionView onRoomEntered]; - [self.messageContainerView onRoomEntered]; - } else { - //虽然没退出房间 但是队列还是要拿的 - [self.stageView onRoomMiniEntered]; - [self.messageContainerView onRoomMiniEntered]; - [self.functionView onRoomMiniEntered]; - [self.functionView onRoomEntered]; - } - [[XPRoomMiniManager shareManager] configRoomInfo:nil]; - [[XPRoomMiniManager shareManager] configUserInfo:nil]; - [[XPRoomMiniManager shareManager] configCurrentMusic:nil isPlaying:NO]; - } + if ([XPRoomMiniManager shareManager].getRoomInfo.uid != self.roomUid.integerValue) {// 最小化进房 还是原来的房间的话 不需要重新进入云信 因为压根没退 + [self.presenter enterNIMRoom:[NSString stringWithFormat:@"%ld", self.roomInfo.roomId] user:self.userInfo]; + [self.functionView onRoomEntered]; + [self.messageContainerView onRoomEntered]; + } else { + //虽然没退出房间 但是队列还是要拿的 + [self.stageView onRoomMiniEntered]; + [self.messageContainerView onRoomMiniEntered]; + [self.functionView onRoomMiniEntered]; + [self.functionView onRoomEntered]; + } + [[XPRoomMiniManager shareManager] configRoomInfo:nil]; + [[XPRoomMiniManager shareManager] configUserInfo:nil]; + [[XPRoomMiniManager shareManager] configCurrentMusic:nil isPlaying:NO]; + } } ///展示个播上划引导 - (void)showAnchorScrollTipView { - NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; - NSString *anchoScrollTip = [defaults objectForKey:kHadShowAnchorRoomTipKey]; - if (!anchoScrollTip) { - UIWindow *window = [UIApplication sharedApplication].delegate.window; - [window addSubview:self.anchorScrollTipView]; - [window bringSubviewToFront:self.anchorScrollTipView]; - } + NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; + NSString *anchoScrollTip = [defaults objectForKey:kHadShowAnchorRoomTipKey]; + if (!anchoScrollTip) { + UIWindow *window = [UIApplication sharedApplication].delegate.window; + [window addSubview:self.anchorScrollTipView]; + [window bringSubviewToFront:self.anchorScrollTipView]; + } } ///判断是否被踢出房间 - (BOOL)isKictOutLatest:(RoomInfoModel *)roomInfo { - NSString *currentUid = [AccountInfoStorage instance].getUid; - NSString *key = [NSString stringWithFormat:@"%@_%ld", currentUid, roomInfo.uid]; - NSString *kictOutTime = [[NSUserDefaults standardUserDefaults] objectForKey:key]; - if (kictOutTime) { - NSDate* date = [NSDate dateWithTimeIntervalSinceNow:0]; - NSTimeInterval time = [date timeIntervalSince1970]; - NSString *currentTime = [NSString stringWithFormat:@"%.0f", time]; - //是否超过5分钟 - if ([currentTime intValue] - [kictOutTime intValue] > 5 * 60) { - [[NSUserDefaults standardUserDefaults] removeObjectForKey:key]; - [[NSUserDefaults standardUserDefaults] synchronize]; - return NO; - } else { - [XNDJTDDLoadingTool showErrorWithMessage:YMLocalizedString(@"XPRoomViewController0")]; - [self dismissViewControllerAnimated:YES completion:nil]; - return YES; - } - } else { - return NO; - } + NSString *currentUid = [AccountInfoStorage instance].getUid; + NSString *key = [NSString stringWithFormat:@"%@_%ld", currentUid, roomInfo.uid]; + NSString *kictOutTime = [[NSUserDefaults standardUserDefaults] objectForKey:key]; + if (kictOutTime) { + NSDate* date = [NSDate dateWithTimeIntervalSinceNow:0]; + NSTimeInterval time = [date timeIntervalSince1970]; + NSString *currentTime = [NSString stringWithFormat:@"%.0f", time]; + //是否超过5分钟 + if ([currentTime intValue] - [kictOutTime intValue] > 5 * 60) { + [[NSUserDefaults standardUserDefaults] removeObjectForKey:key]; + [[NSUserDefaults standardUserDefaults] synchronize]; + return NO; + } else { + [XNDJTDDLoadingTool showErrorWithMessage:YMLocalizedString(@"XPRoomViewController0")]; + [self dismissViewControllerAnimated:YES completion:nil]; + return YES; + } + } else { + return NO; + } } -(void)requesstShieldingAction{ [self.presenter requesstShieldingWtihType:@"1" objId:[NSString stringWithFormat:@"%ld",self.roomInfo.uid]]; @@ -867,10 +867,10 @@ NSString * const kHadQuitOtherRoomKey = @"kHadQuitOtherRoomKey";//是否退出 } #pragma mark - 本地礼物特效更新 - (void)myGiftEffectUpdate:(NSNotification *)notification { - NSDictionary * dic = notification.object; - self.roomInfo.hasAnimationEffect = ((NSNumber *)dic[@"hasAnimationEffect"]).boolValue; - self.hasAnimationEffect = self.roomInfo.hasAnimationEffect; - [self.roomHeaderView onRoomUpdate]; + NSDictionary * dic = notification.object; + self.roomInfo.hasAnimationEffect = ((NSNumber *)dic[@"hasAnimationEffect"]).boolValue; + self.hasAnimationEffect = self.roomInfo.hasAnimationEffect; + [self.roomHeaderView onRoomUpdate]; } #pragma mark - XPRoomProtocol ///获取已解锁照片id列表 @@ -883,320 +883,320 @@ NSString * const kHadQuitOtherRoomKey = @"kHadQuitOtherRoomKey";//是否退出 } - (void)initEnterRoomSuccess:(RoomInfoModel *)roomInfo user:(UserInfoModel *)userInfo { - [XNDJTDDLoadingTool hideHUDInView:self.navigationController.view]; - [XPSkillCardPlayerManager shareInstance].roomUid = @(roomInfo.uid).stringValue; - userInfo.fromUid = self.fromUid; - userInfo.fromType = self.fromType; - userInfo.fromNick = self.fromNick; - self.hasAnimationEffect = roomInfo.hasAnimationEffect; - self.roomInfo = roomInfo; - self.userInfo = userInfo; - //判断5分钟内是否被踢出过房间 - if ([self isKictOutLatest:roomInfo]) { - return; - } - if (roomInfo.type == RoomType_Anchor) {//个播房,获取下一个房间 - [self handleInitAnchorRoom]; - [self showAnchorScrollTipView]; - return; - } - if (roomInfo.valid) { // 房间有效,直接进入房间 - if (roomInfo.roomPwd.length > 0 && roomInfo.uid != [AccountInfoStorage instance].getUid.integerValue && [XPRoomMiniManager shareManager].getRoomInfo.uid != self.roomUid.integerValue) {//进房密码的情况 - if (!self.isRequestSuperAdmin) { - [Api getRoomSuperAdminList:^(BaseModel * _Nullable data, NSInteger code, NSString * _Nullable msg) { - NSArray * array = [GuildSuperAdminInfoModel modelsWithArray:data.data]; - self.superMangerList = array; - [self superAdminEnterPwdRoom:roomInfo]; - } roomUid:self.roomUid]; - } else { - [self superAdminEnterPwdRoom:roomInfo]; - } - } else { - self.roomInfo.datingState = roomInfo.roomModeType == RoomModeType_Open_Blind ? RoomDatingStateChangeType_Open : RoomDatingStateChangeType_Normal; - [self changeStageViewOnRoomUpdate]; - [self.roomHeaderView onRoomEntered]; - [self.activityContainerView onRoomEntered]; - [self.menuContainerView onRoomEntered]; - [self.backContainerView onRoomEntered]; + [XNDJTDDLoadingTool hideHUDInView:self.navigationController.view]; + [XPSkillCardPlayerManager shareInstance].roomUid = @(roomInfo.uid).stringValue; + userInfo.fromUid = self.fromUid; + userInfo.fromType = self.fromType; + userInfo.fromNick = self.fromNick; + self.hasAnimationEffect = roomInfo.hasAnimationEffect; + self.roomInfo = roomInfo; + self.userInfo = userInfo; + //判断5分钟内是否被踢出过房间 + if ([self isKictOutLatest:roomInfo]) { + return; + } + if (roomInfo.type == RoomType_Anchor) {//个播房,获取下一个房间 + [self handleInitAnchorRoom]; + [self showAnchorScrollTipView]; + return; + } + if (roomInfo.valid) { // 房间有效,直接进入房间 + if (roomInfo.roomPwd.length > 0 && roomInfo.uid != [AccountInfoStorage instance].getUid.integerValue && [XPRoomMiniManager shareManager].getRoomInfo.uid != self.roomUid.integerValue) {//进房密码的情况 + if (!self.isRequestSuperAdmin) { + [Api getRoomSuperAdminList:^(BaseModel * _Nullable data, NSInteger code, NSString * _Nullable msg) { + NSArray * array = [GuildSuperAdminInfoModel modelsWithArray:data.data]; + self.superMangerList = array; + [self superAdminEnterPwdRoom:roomInfo]; + } roomUid:self.roomUid]; + } else { + [self superAdminEnterPwdRoom:roomInfo]; + } + } else { + self.roomInfo.datingState = roomInfo.roomModeType == RoomModeType_Open_Blind ? RoomDatingStateChangeType_Open : RoomDatingStateChangeType_Normal; + [self changeStageViewOnRoomUpdate]; + [self.roomHeaderView onRoomEntered]; + [self.activityContainerView onRoomEntered]; + [self.menuContainerView onRoomEntered]; + [self.backContainerView onRoomEntered]; [self.littleGameView onRoomEntered]; - self.quickMessageContainerView.titleArray = self.roomInfo.speakTemplate; - if ([XPRoomMiniManager shareManager].getRoomInfo.uid != self.roomUid.integerValue) {// 最小化进房 还是原来的房间的话 不需要重新进入云信 因为压根没退 - [self.presenter enterNIMRoom:[NSString stringWithFormat:@"%ld", self.roomInfo.roomId] user:self.userInfo]; - [self.functionView onRoomEntered]; - [self.messageContainerView onRoomEntered]; - } else { - //虽然没退出房间 但是队列还是要拿的 - [self.stageView onRoomMiniEntered]; - [self.messageContainerView onRoomMiniEntered]; - [self.functionView onRoomMiniEntered]; - [self.functionView onRoomEntered]; - } - [[XPRoomMiniManager shareManager] configRoomInfo:nil]; - [[XPRoomMiniManager shareManager] configUserInfo:nil]; - [[XPRoomMiniManager shareManager] configCurrentMusic:nil isPlaying:NO]; - } - } else { // 房间无效,分是否为自己房间进行处理 - if ([self.roomUid isEqualToString:[NSString stringWithFormat:@"%ld", userInfo.uid]]) { // 当前用户进入自己房间 - if (roomInfo.roomId > 0) { // 存在房间信息,直接使用房间信息开房 - if (roomInfo.type == RoomType_MiniGame && roomInfo.mgId > 0) { - self.mgId = [NSString stringWithFormat:@"%lld", roomInfo.mgId]; - } - [self.presenter openRoom:roomInfo.title type:roomInfo.type roomPwd:roomInfo.roomPwd roomDesc:roomInfo.roomDesc backPic:@"" mgId:self.mgId]; - } else { // 不存在房间信息,全新开房 - NSString* title = [NSString stringWithFormat:YMLocalizedString(@"XPRoomViewController1"), userInfo.nick]; - RoomType type = RoomType_Game; - if (self.mgId.length > 0) { - type = RoomType_MiniGame; - } - [self.presenter openRoom:title type:type roomPwd:@"" roomDesc:@"" backPic:@"" mgId:self.mgId]; - } - } else { // 当前用户进入别人房间 - // TODO: 房主已经下线。 - [self showSuccessToast:YMLocalizedString(@"XPRoomViewController2")]; - [self enterRoomFail:0]; - } - } + self.quickMessageContainerView.titleArray = self.roomInfo.speakTemplate; + if ([XPRoomMiniManager shareManager].getRoomInfo.uid != self.roomUid.integerValue) {// 最小化进房 还是原来的房间的话 不需要重新进入云信 因为压根没退 + [self.presenter enterNIMRoom:[NSString stringWithFormat:@"%ld", self.roomInfo.roomId] user:self.userInfo]; + [self.functionView onRoomEntered]; + [self.messageContainerView onRoomEntered]; + } else { + //虽然没退出房间 但是队列还是要拿的 + [self.stageView onRoomMiniEntered]; + [self.messageContainerView onRoomMiniEntered]; + [self.functionView onRoomMiniEntered]; + [self.functionView onRoomEntered]; + } + [[XPRoomMiniManager shareManager] configRoomInfo:nil]; + [[XPRoomMiniManager shareManager] configUserInfo:nil]; + [[XPRoomMiniManager shareManager] configCurrentMusic:nil isPlaying:NO]; + } + } else { // 房间无效,分是否为自己房间进行处理 + if ([self.roomUid isEqualToString:[NSString stringWithFormat:@"%ld", userInfo.uid]]) { // 当前用户进入自己房间 + if (roomInfo.roomId > 0) { // 存在房间信息,直接使用房间信息开房 + if (roomInfo.type == RoomType_MiniGame && roomInfo.mgId > 0) { + self.mgId = [NSString stringWithFormat:@"%lld", roomInfo.mgId]; + } + [self.presenter openRoom:roomInfo.title type:roomInfo.type roomPwd:roomInfo.roomPwd roomDesc:roomInfo.roomDesc backPic:@"" mgId:self.mgId]; + } else { // 不存在房间信息,全新开房 + NSString* title = [NSString stringWithFormat:YMLocalizedString(@"XPRoomViewController1"), userInfo.nick]; + RoomType type = RoomType_Game; + if (self.mgId.length > 0) { + type = RoomType_MiniGame; + } + [self.presenter openRoom:title type:type roomPwd:@"" roomDesc:@"" backPic:@"" mgId:self.mgId]; + } + } else { // 当前用户进入别人房间 + // TODO: 房主已经下线。 + [self showSuccessToast:YMLocalizedString(@"XPRoomViewController2")]; + [self enterRoomFail:0]; + } + } } - (void)openRoomSuccess:(RoomInfoModel *)roomInfo { - [XNDJTDDLoadingTool hideHUDInView:self.navigationController.view]; - [self hideHUD]; - self.roomInfo = roomInfo; - if (roomInfo.type == RoomType_Anchor) { - [self handleInitAnchorRoom]; - [self showAnchorScrollTipView]; - return; - } - [self changeStageViewOnRoomUpdate]; - [self.roomHeaderView onRoomEntered]; - [self.activityContainerView onRoomEntered]; - [self.backContainerView onRoomEntered]; + [XNDJTDDLoadingTool hideHUDInView:self.navigationController.view]; + [self hideHUD]; + self.roomInfo = roomInfo; + if (roomInfo.type == RoomType_Anchor) { + [self handleInitAnchorRoom]; + [self showAnchorScrollTipView]; + return; + } + [self changeStageViewOnRoomUpdate]; + [self.roomHeaderView onRoomEntered]; + [self.activityContainerView onRoomEntered]; + [self.backContainerView onRoomEntered]; [self.littleGameView onRoomEntered]; - [self.functionView onRoomEntered]; - [self.messageContainerView onRoomEntered]; - self.quickMessageContainerView.titleArray = self.roomInfo.speakTemplate; - [self.presenter enterNIMRoom:[NSString stringWithFormat:@"%ld", self.roomInfo.roomId] user:self.userInfo]; + [self.functionView onRoomEntered]; + [self.messageContainerView onRoomEntered]; + self.quickMessageContainerView.titleArray = self.roomInfo.speakTemplate; + [self.presenter enterNIMRoom:[NSString stringWithFormat:@"%ld", self.roomInfo.roomId] user:self.userInfo]; } - (void)enterRoomSuccess:(NIMChatroom *)chatRoom { - [XNDJTDDLoadingTool hideHUDInView:self.navigationController.view]; - // room/get中的房间在线人数 是定时更新的 不是及时刷新 - self.roomInfo.onlineNum = chatRoom.onlineUserCount; - [self.stageView onRoomEntered]; - [self.functionView onRoomEntered]; - //上报进房 - if (self.roomInfo != nil) { - [self.presenter reportUserInterRoom:[NSString stringWithFormat:@"%zd", self.roomInfo.uid]]; - [StatisticsServiceHelper trackEventWithKey:StatisticsServiceEventuser_visit_room eventAttributes:@{@"roomUid" : @(self.roomInfo.uid)}]; - } - if (self.giftId.length) { - ///有的时候 拉取麦序的话 可能会有点延迟 导致送礼物的人 没有拉取到 - dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ - [[NSNotificationCenter defaultCenter] postNotificationName:@"kShowGiftView" object:@{@"giftId": self.giftId}]; - }); - } - //获取一下红包信息 - [self.presenter getRedPacket:[NSString stringWithFormat:@"%ld", self.roomInfo.uid]]; + [XNDJTDDLoadingTool hideHUDInView:self.navigationController.view]; + // room/get中的房间在线人数 是定时更新的 不是及时刷新 + self.roomInfo.onlineNum = chatRoom.onlineUserCount; + [self.stageView onRoomEntered]; + [self.functionView onRoomEntered]; + //上报进房 + if (self.roomInfo != nil) { + [self.presenter reportUserInterRoom:[NSString stringWithFormat:@"%zd", self.roomInfo.uid]]; + [StatisticsServiceHelper trackEventWithKey:StatisticsServiceEventuser_visit_room eventAttributes:@{@"roomUid" : @(self.roomInfo.uid)}]; + } + if (self.giftId.length) { + ///有的时候 拉取麦序的话 可能会有点延迟 导致送礼物的人 没有拉取到 + dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ + [[NSNotificationCenter defaultCenter] postNotificationName:@"kShowGiftView" object:@{@"giftId": self.giftId}]; + }); + } + //获取一下红包信息 + [self.presenter getRedPacket:[NSString stringWithFormat:@"%ld", self.roomInfo.uid]]; } - (void)enterRoomFail:(NSInteger)code { - [XNDJTDDLoadingTool hideHUDInView:self.navigationController.view]; - [self hideHUD]; - if (code == 13003) { - [self showErrorToast:YMLocalizedString(@"XPRoomViewController3")]; - } - [self dismissViewControllerAnimated:YES completion:nil]; + [XNDJTDDLoadingTool hideHUDInView:self.navigationController.view]; + [self hideHUD]; + if (code == 13003) { + [self showErrorToast:YMLocalizedString(@"XPRoomViewController3")]; + } + [self dismissViewControllerAnimated:YES completion:nil]; } ///请求房间超管成功 ///这个接口本来是想和roominfo 和userinfo 一起请求的 但是 进房的同步操作 只有超管进入密码房间才会有同步的问题 - (void)getRoomSuperAdminScuccess:(NSArray *)list { - self.isRequestSuperAdmin = YES; - self.superMangerList = list; + self.isRequestSuperAdmin = YES; + self.superMangerList = list; } ///获取推荐滚动的个播房列表(只有第一次进房获取) - (void)getNextAnchorRoomSuccess:(RoomInfoModel *)roomInfo { - [self hideHUD]; - if (roomInfo) { //获取下一个房间成功 - if (![self.anchorRoomList containsObject:self.roomUid]) { - [self.anchorRoomList addObject:self.roomUid]; - } - self.anchorIndex = self.anchorRoomList.count -1; - //1、退出房间操作 - self.anchorScrollView.isCanScrollTop = YES; - self.anchorScrollView.contentOffset = CGPointMake(0, KScreenHeight); - self.isRequestSuperAdmin = NO; - [self exitOldRoom]; - [self.presenter exitNIMRoom:[NSString stringWithFormat:@"%ld", self.roomInfo.roomId]]; - [[XPRoomMiniManager shareManager] resetLocalMessage]; - [[RtcManager instance] exitRoom]; - [self.presenter reportUserOutRoom:[NSString stringWithFormat:@"%ld", self.roomInfo.uid]]; - [self.functionView onRoomChange]; - //2、移除房间子控件 - [self.stageView removeFromSuperview]; - [self.messageContainerView removeFromSuperview]; - [self.quickMessageContainerView removeFromSuperview]; - [self.activityContainerView removeFromSuperview]; - [self.roomHeaderView removeFromSuperview]; - [self.functionView removeFromSuperview]; - self.functionView = nil; - self.messageContainerView = nil; - self.stageView = nil; - [self.menuContainerView removeFromSuperview]; - self.menuContainerView = nil; - //3、重新进入房间 - self.roomUid = [NSString stringWithFormat:@"%zd", roomInfo.uid]; - [self.presenter initEnterRoom:self.roomUid user:[AccountInfoStorage instance].getUid]; - /// 公屏 福袋礼物爆出的礼物 需要依赖 当前房间中的礼物列表 需要提前获取礼物列表 可以拿到礼物 没有想到别的方法去解决这个问题 有需要改的在修改吧 - [self.presenter getNormalGiftList:self.roomUid]; - ///获取房间超管列表 - [self.presenter getRoomSuperAdmin:self.roomUid]; - } else { - if (self.anchorScrollView.isCanScrollTop) { - self.anchorScrollView.contentOffset = CGPointMake(0, KScreenHeight); - } else { - self.anchorScrollView.contentOffset = CGPointMake(0, 0); - } - [self showErrorToast:YMLocalizedString(@"XPRoomViewController4")]; - } + [self hideHUD]; + if (roomInfo) { //获取下一个房间成功 + if (![self.anchorRoomList containsObject:self.roomUid]) { + [self.anchorRoomList addObject:self.roomUid]; + } + self.anchorIndex = self.anchorRoomList.count -1; + //1、退出房间操作 + self.anchorScrollView.isCanScrollTop = YES; + self.anchorScrollView.contentOffset = CGPointMake(0, KScreenHeight); + self.isRequestSuperAdmin = NO; + [self exitOldRoom]; + [self.presenter exitNIMRoom:[NSString stringWithFormat:@"%ld", self.roomInfo.roomId]]; + [[XPRoomMiniManager shareManager] resetLocalMessage]; + [[RtcManager instance] exitRoom]; + [self.presenter reportUserOutRoom:[NSString stringWithFormat:@"%ld", self.roomInfo.uid]]; + [self.functionView onRoomChange]; + //2、移除房间子控件 + [self.stageView removeFromSuperview]; + [self.messageContainerView removeFromSuperview]; + [self.quickMessageContainerView removeFromSuperview]; + [self.activityContainerView removeFromSuperview]; + [self.roomHeaderView removeFromSuperview]; + [self.functionView removeFromSuperview]; + self.functionView = nil; + self.messageContainerView = nil; + self.stageView = nil; + [self.menuContainerView removeFromSuperview]; + self.menuContainerView = nil; + //3、重新进入房间 + self.roomUid = [NSString stringWithFormat:@"%zd", roomInfo.uid]; + [self.presenter initEnterRoom:self.roomUid user:[AccountInfoStorage instance].getUid]; + /// 公屏 福袋礼物爆出的礼物 需要依赖 当前房间中的礼物列表 需要提前获取礼物列表 可以拿到礼物 没有想到别的方法去解决这个问题 有需要改的在修改吧 + [self.presenter getNormalGiftList:self.roomUid]; + ///获取房间超管列表 + [self.presenter getRoomSuperAdmin:self.roomUid]; + } else { + if (self.anchorScrollView.isCanScrollTop) { + self.anchorScrollView.contentOffset = CGPointMake(0, KScreenHeight); + } else { + self.anchorScrollView.contentOffset = CGPointMake(0, 0); + } + [self showErrorToast:YMLocalizedString(@"XPRoomViewController4")]; + } } - (void)getCurrentRoomInfoSuccess:(RoomInfoModel *)roomInfo { - [self hideHUD]; - self.anchorScrollView.contentOffset = CGPointMake(0, KScreenHeight); - if (roomInfo && roomInfo.valid) { - //1、退出房间操作 - self.isRequestSuperAdmin = NO; - [self exitOldRoom]; - [self.presenter exitNIMRoom:[NSString stringWithFormat:@"%ld", self.roomInfo.roomId]]; - [[XPRoomMiniManager shareManager] resetLocalMessage]; - [[RtcManager instance] exitRoom]; - [self.presenter reportUserOutRoom:[NSString stringWithFormat:@"%ld", self.roomInfo.uid]]; - //2、移除房间子控件 -// [self.backContainerView removeFromSuperview]; - [self.stageView removeFromSuperview]; - [self.messageContainerView removeFromSuperview]; - [self.quickMessageContainerView removeFromSuperview]; - [self.activityContainerView removeFromSuperview]; - [self.roomHeaderView removeFromSuperview]; - [self.functionView removeFromSuperview]; - self.functionView = nil; - self.messageContainerView = nil; - self.stageView = nil; - [self.menuContainerView removeFromSuperview]; - self.menuContainerView = nil; - //3、重新进入房间 - self.roomUid = [NSString stringWithFormat:@"%zd", roomInfo.uid]; - [self.presenter initEnterRoom:self.roomUid user:[AccountInfoStorage instance].getUid]; - /// 公屏 福袋礼物爆出的礼物 需要依赖 当前房间中的礼物列表 需要提前获取礼物列表 可以拿到礼物 没有想到别的方法去解决这个问题 有需要改的在修改吧 - [self.presenter getNormalGiftList:self.roomUid]; - ///获取房间超管列表 - [self.presenter getRoomSuperAdmin:self.roomUid]; - } else { - [self showErrorToast:YMLocalizedString(@"XPRoomViewController5")]; - } + [self hideHUD]; + self.anchorScrollView.contentOffset = CGPointMake(0, KScreenHeight); + if (roomInfo && roomInfo.valid) { + //1、退出房间操作 + self.isRequestSuperAdmin = NO; + [self exitOldRoom]; + [self.presenter exitNIMRoom:[NSString stringWithFormat:@"%ld", self.roomInfo.roomId]]; + [[XPRoomMiniManager shareManager] resetLocalMessage]; + [[RtcManager instance] exitRoom]; + [self.presenter reportUserOutRoom:[NSString stringWithFormat:@"%ld", self.roomInfo.uid]]; + //2、移除房间子控件 +// [self.backContainerView removeFromSuperview]; + [self.stageView removeFromSuperview]; + [self.messageContainerView removeFromSuperview]; + [self.quickMessageContainerView removeFromSuperview]; + [self.activityContainerView removeFromSuperview]; + [self.roomHeaderView removeFromSuperview]; + [self.functionView removeFromSuperview]; + self.functionView = nil; + self.messageContainerView = nil; + self.stageView = nil; + [self.menuContainerView removeFromSuperview]; + self.menuContainerView = nil; + //3、重新进入房间 + self.roomUid = [NSString stringWithFormat:@"%zd", roomInfo.uid]; + [self.presenter initEnterRoom:self.roomUid user:[AccountInfoStorage instance].getUid]; + /// 公屏 福袋礼物爆出的礼物 需要依赖 当前房间中的礼物列表 需要提前获取礼物列表 可以拿到礼物 没有想到别的方法去解决这个问题 有需要改的在修改吧 + [self.presenter getNormalGiftList:self.roomUid]; + ///获取房间超管列表 + [self.presenter getRoomSuperAdmin:self.roomUid]; + } else { + [self showErrorToast:YMLocalizedString(@"XPRoomViewController5")]; + } } ///个播房初始化一些操作 - (void)handleInitAnchorRoom { - if (self.roomInfo.valid) { // 房间有效,直接进入房间 - if (self.roomInfo.roomPwd.length > 0 && self.roomInfo.uid != [AccountInfoStorage instance].getUid.integerValue && [XPRoomMiniManager shareManager].getRoomInfo.uid != self.roomUid.integerValue) {//进房密码的情况 - if (!self.isRequestSuperAdmin) { - [Api getRoomSuperAdminList:^(BaseModel * _Nullable data, NSInteger code, NSString * _Nullable msg) { - NSArray * array = [GuildSuperAdminInfoModel modelsWithArray:data.data]; - self.superMangerList = array; - [self handleSuperManagerEnterAnchorRoom:self.roomInfo]; - } roomUid:self.roomUid]; - } else { - [self handleSuperManagerEnterAnchorRoom:self.roomInfo]; - } - } else { - self.roomInfo.datingState = self.roomInfo.roomModeType == RoomModeType_Open_Blind ? RoomDatingStateChangeType_Open : RoomDatingStateChangeType_Normal; - if (!self.anchorScrollView.superview) { - [self.view addSubview:self.anchorScrollView]; - } - [self.backContainerView removeFromSuperview]; - [self.stageView removeFromSuperview]; - [self.messageContainerView removeFromSuperview]; - [self.quickMessageContainerView removeFromSuperview]; - [self.activityContainerView removeFromSuperview]; - [self.roomHeaderView removeFromSuperview]; - [self.functionView removeFromSuperview]; - [self.menuContainerView removeFromSuperview]; + if (self.roomInfo.valid) { // 房间有效,直接进入房间 + if (self.roomInfo.roomPwd.length > 0 && self.roomInfo.uid != [AccountInfoStorage instance].getUid.integerValue && [XPRoomMiniManager shareManager].getRoomInfo.uid != self.roomUid.integerValue) {//进房密码的情况 + if (!self.isRequestSuperAdmin) { + [Api getRoomSuperAdminList:^(BaseModel * _Nullable data, NSInteger code, NSString * _Nullable msg) { + NSArray * array = [GuildSuperAdminInfoModel modelsWithArray:data.data]; + self.superMangerList = array; + [self handleSuperManagerEnterAnchorRoom:self.roomInfo]; + } roomUid:self.roomUid]; + } else { + [self handleSuperManagerEnterAnchorRoom:self.roomInfo]; + } + } else { + self.roomInfo.datingState = self.roomInfo.roomModeType == RoomModeType_Open_Blind ? RoomDatingStateChangeType_Open : RoomDatingStateChangeType_Normal; + if (!self.anchorScrollView.superview) { + [self.view addSubview:self.anchorScrollView]; + } + [self.backContainerView removeFromSuperview]; + [self.stageView removeFromSuperview]; + [self.messageContainerView removeFromSuperview]; + [self.quickMessageContainerView removeFromSuperview]; + [self.activityContainerView removeFromSuperview]; + [self.roomHeaderView removeFromSuperview]; + [self.functionView removeFromSuperview]; + [self.menuContainerView removeFromSuperview]; - [self.anchorScrollView addSubview:self.backContainerView]; - [self.anchorScrollView addSubview:self.stageView]; - [self.anchorScrollView addSubview:self.messageContainerView]; - [self.anchorScrollView addSubview:self.quickMessageContainerView]; - [self.anchorScrollView addSubview:self.activityContainerView]; - [self.anchorScrollView addSubview:self.roomHeaderView]; - [self.anchorScrollView addSubview:self.functionView]; - [self.anchorScrollView addSubview:self.menuContainerView]; - [self.view bringSubviewToFront:self.animationView]; + [self.anchorScrollView addSubview:self.backContainerView]; + [self.anchorScrollView addSubview:self.stageView]; + [self.anchorScrollView addSubview:self.messageContainerView]; + [self.anchorScrollView addSubview:self.quickMessageContainerView]; + [self.anchorScrollView addSubview:self.activityContainerView]; + [self.anchorScrollView addSubview:self.roomHeaderView]; + [self.anchorScrollView addSubview:self.functionView]; + [self.anchorScrollView addSubview:self.menuContainerView]; + [self.view bringSubviewToFront:self.animationView]; - [self updateViewConstraintsOnAnchorRoom]; - [self changeStageViewOnAnchorRoom]; + [self updateViewConstraintsOnAnchorRoom]; + [self changeStageViewOnAnchorRoom]; - [self.roomHeaderView onRoomEntered]; - [self.activityContainerView onRoomEntered]; - [self.menuContainerView onRoomEntered]; - [self.backContainerView onRoomEntered]; + [self.roomHeaderView onRoomEntered]; + [self.activityContainerView onRoomEntered]; + [self.menuContainerView onRoomEntered]; + [self.backContainerView onRoomEntered]; [self.littleGameView onRoomEntered]; - if ([XPRoomMiniManager shareManager].getRoomInfo.uid != self.roomUid.integerValue) {// 最小化进房 还是原来的房间的话 不需要重新进入云信 因为压根没退 - [self.presenter enterNIMRoom:[NSString stringWithFormat:@"%ld", self.roomInfo.roomId] user:self.userInfo]; - [self.functionView onRoomEntered]; - [self.messageContainerView onRoomEntered]; - } else { - //虽然没退出房间 但是队列还是要拿的 - [self.stageView onRoomMiniEntered]; - [self.messageContainerView onRoomMiniEntered]; - [self.functionView onRoomMiniEntered]; - [self.functionView onRoomEntered]; - } - [[XPRoomMiniManager shareManager] configRoomInfo:nil]; - [[XPRoomMiniManager shareManager] configUserInfo:nil]; - [[XPRoomMiniManager shareManager] configCurrentMusic:nil isPlaying:NO]; - } - } else { // 房间无效,分是否为自己房间进行处理 - if ([self.roomUid isEqualToString:[NSString stringWithFormat:@"%ld", self.userInfo.uid]]) { // 当前用户进入自己房间 - if (self.roomInfo.roomId > 0) { // 存在房间信息,直接使用房间信息开房 - if (self.roomInfo.type == RoomType_MiniGame && self.roomInfo.mgId > 0) { - self.mgId = [NSString stringWithFormat:@"%lld", self.roomInfo.mgId]; - } - [self.presenter openRoom:self.roomInfo.title type:self.roomInfo.type roomPwd:self.roomInfo.roomPwd roomDesc:self.roomInfo.roomDesc backPic:@"" mgId:self.mgId]; - } else { // 不存在房间信息,全新开房 - NSString* title = [NSString stringWithFormat:YMLocalizedString(@"XPRoomViewController6"), self.userInfo.nick]; - RoomType type = RoomType_Game; - if (self.mgId.length > 0) { - type = RoomType_MiniGame; - } - [self.presenter openRoom:title type:type roomPwd:@"" roomDesc:@"" backPic:@"" mgId:self.mgId]; - } - } else { // 当前用户进入别人房间 - // TODO: 房主已经下线。 - [self showSuccessToast:YMLocalizedString(@"XPRoomViewController7")]; - [self enterRoomFail:0]; - } - } + if ([XPRoomMiniManager shareManager].getRoomInfo.uid != self.roomUid.integerValue) {// 最小化进房 还是原来的房间的话 不需要重新进入云信 因为压根没退 + [self.presenter enterNIMRoom:[NSString stringWithFormat:@"%ld", self.roomInfo.roomId] user:self.userInfo]; + [self.functionView onRoomEntered]; + [self.messageContainerView onRoomEntered]; + } else { + //虽然没退出房间 但是队列还是要拿的 + [self.stageView onRoomMiniEntered]; + [self.messageContainerView onRoomMiniEntered]; + [self.functionView onRoomMiniEntered]; + [self.functionView onRoomEntered]; + } + [[XPRoomMiniManager shareManager] configRoomInfo:nil]; + [[XPRoomMiniManager shareManager] configUserInfo:nil]; + [[XPRoomMiniManager shareManager] configCurrentMusic:nil isPlaying:NO]; + } + } else { // 房间无效,分是否为自己房间进行处理 + if ([self.roomUid isEqualToString:[NSString stringWithFormat:@"%ld", self.userInfo.uid]]) { // 当前用户进入自己房间 + if (self.roomInfo.roomId > 0) { // 存在房间信息,直接使用房间信息开房 + if (self.roomInfo.type == RoomType_MiniGame && self.roomInfo.mgId > 0) { + self.mgId = [NSString stringWithFormat:@"%lld", self.roomInfo.mgId]; + } + [self.presenter openRoom:self.roomInfo.title type:self.roomInfo.type roomPwd:self.roomInfo.roomPwd roomDesc:self.roomInfo.roomDesc backPic:@"" mgId:self.mgId]; + } else { // 不存在房间信息,全新开房 + NSString* title = [NSString stringWithFormat:YMLocalizedString(@"XPRoomViewController6"), self.userInfo.nick]; + RoomType type = RoomType_Game; + if (self.mgId.length > 0) { + type = RoomType_MiniGame; + } + [self.presenter openRoom:title type:type roomPwd:@"" roomDesc:@"" backPic:@"" mgId:self.mgId]; + } + } else { // 当前用户进入别人房间 + // TODO: 房主已经下线。 + [self showSuccessToast:YMLocalizedString(@"XPRoomViewController7")]; + [self enterRoomFail:0]; + } + } } - (void)getRedPacketSuccess:(NSArray *)list { - if (list.count == 0) { - return; - } - for (XPRedPacketModel *data in list) { - XPReceiveRedPacketView *view = [[XPReceiveRedPacketView alloc] initWithFrame:CGRectMake(0, 0, KScreenWidth, KScreenHeight)]; - view.receiveModel = data; - for (UIView *subView in self.view.subviews) { - if([subView isKindOfClass:[XPReceiveRedPacketView class]]) { - view.alphaView.backgroundColor = [UIColor clearColor]; - break; - } - } - [self.view addSubview:view]; - [self.view bringSubviewToFront:view]; - } + if (list.count == 0) { + return; + } + for (XPRedPacketModel *data in list) { + XPReceiveRedPacketView *view = [[XPReceiveRedPacketView alloc] initWithFrame:CGRectMake(0, 0, KScreenWidth, KScreenHeight)]; + view.receiveModel = data; + for (UIView *subView in self.view.subviews) { + if([subView isKindOfClass:[XPReceiveRedPacketView class]]) { + view.alphaView.backgroundColor = [UIColor clearColor]; + break; + } + } + [self.view addSubview:view]; + [self.view bringSubviewToFront:view]; + } } -(void)getFreeGiftDataSuccess:(XPFreeGiftModel *)freeModel{ self.freeModel = freeModel; @@ -1222,248 +1222,248 @@ NSString * const kHadQuitOtherRoomKey = @"kHadQuitOtherRoomKey";//是否退出 } - (void)getRoomFirstChargeWindowSuccess:(FirstChargeRoomWindowModel *)model{ - if(model.needToShow == NO || model.showAfterSecond <= 0 || self.isShowFirstRecharge == YES)return; - self.isShowFirstRecharge = YES; - [self performSelector:@selector(showRoomFirstChargeWindow) withObject:nil afterDelay:model.showAfterSecond]; + if(model.needToShow == NO || model.showAfterSecond <= 0 || self.isShowFirstRecharge == YES)return; + self.isShowFirstRecharge = YES; + [self performSelector:@selector(showRoomFirstChargeWindow) withObject:nil afterDelay:model.showAfterSecond]; } #pragma mark - NIMChatroomManagerDelegate - (void)chatroomBeKicked:(NIMChatroomBeKickedResult *)result { - if (result.reason == 2) { - [self showErrorToast:YMLocalizedString(@"XPRoomViewController8")]; - ///保存被踢出时的时间 - NSDate* date = [NSDate dateWithTimeIntervalSinceNow:0];//获取当前时间0秒后的时间 - NSTimeInterval time=[date timeIntervalSince1970]; - NSString *currentTime = [NSString stringWithFormat:@"%.0f", time]; - NSString *key = [NSString stringWithFormat:@"%@_%ld", [AccountInfoStorage instance].getUid, self.roomInfo.uid]; - [[NSUserDefaults standardUserDefaults] setObject:currentTime forKey:key]; - [[NSUserDefaults standardUserDefaults] synchronize]; - } else if (result.reason == 5) { - [self showErrorToast:YMLocalizedString(@"XPRoomViewController9")]; - } - [self.presenter exitNIMRoom:[NSString stringWithFormat:@"%ld", self.roomInfo.roomId]]; - [[XPRoomMiniManager shareManager] resetLocalMessage]; - [self cancelRoomArrangeMic]; - [[RtcManager instance] exitRoom]; - [self.presenter reportUserOutRoom:[NSString stringWithFormat:@"%ld", self.roomInfo.uid]]; + if (result.reason == 2) { + [self showErrorToast:YMLocalizedString(@"XPRoomViewController8")]; + ///保存被踢出时的时间 + NSDate* date = [NSDate dateWithTimeIntervalSinceNow:0];//获取当前时间0秒后的时间 + NSTimeInterval time=[date timeIntervalSince1970]; + NSString *currentTime = [NSString stringWithFormat:@"%.0f", time]; + NSString *key = [NSString stringWithFormat:@"%@_%ld", [AccountInfoStorage instance].getUid, self.roomInfo.uid]; + [[NSUserDefaults standardUserDefaults] setObject:currentTime forKey:key]; + [[NSUserDefaults standardUserDefaults] synchronize]; + } else if (result.reason == 5) { + [self showErrorToast:YMLocalizedString(@"XPRoomViewController9")]; + } + [self.presenter exitNIMRoom:[NSString stringWithFormat:@"%ld", self.roomInfo.roomId]]; + [[XPRoomMiniManager shareManager] resetLocalMessage]; + [self cancelRoomArrangeMic]; + [[RtcManager instance] exitRoom]; + [self.presenter reportUserOutRoom:[NSString stringWithFormat:@"%ld", self.roomInfo.uid]]; [self.littleGameView handleSelfInExitEvent]; [self.littleGameView destroyMG]; - [self dismissViewControllerAnimated:YES completion:nil]; + [self dismissViewControllerAnimated:YES completion:nil]; } #pragma mark - NIMChatManagerDelegate - (void)onRecvMessages:(NSArray *)messages { - for (NIMMessage * message in messages) { - ///房间内收到p2p的消息 比如升级消息 - if (message.session.sessionType == NIMSessionTypeP2P) { - if(message.messageType == NIMMessageTypeCustom) { - NIMCustomObject *obj = (NIMCustomObject *)message.messageObject; - if (obj.attachment != nil && [obj.attachment isKindOfClass:[AttachmentModel class]]) { - AttachmentModel * attachment = (AttachmentModel *)obj.attachment; - if (attachment.first == CustomMessageType_User_UpGrade) { - ContentLevelUpgradeModel * levelInfo = [ContentLevelUpgradeModel modelWithDictionary:attachment.data]; - if (attachment.second == Custom_Message_Sub_User_UpGrade_Exper) { - self.userInfo.userLevelVo.experLevelSeq = levelInfo.levelSeq; - } else if(attachment.second == Custom_Message_Sub_User_UpGrade_Charm) { - self.userInfo.userLevelVo.charmLevelSeq = levelInfo.levelSeq; - } - } - } - } - } - - // 非房间内消息不处理 - if (message.session.sessionType != NIMSessionTypeChatroom) { - continue; - } + for (NIMMessage * message in messages) { + ///房间内收到p2p的消息 比如升级消息 + if (message.session.sessionType == NIMSessionTypeP2P) { + if(message.messageType == NIMMessageTypeCustom) { + NIMCustomObject *obj = (NIMCustomObject *)message.messageObject; + if (obj.attachment != nil && [obj.attachment isKindOfClass:[AttachmentModel class]]) { + AttachmentModel * attachment = (AttachmentModel *)obj.attachment; + if (attachment.first == CustomMessageType_User_UpGrade) { + ContentLevelUpgradeModel * levelInfo = [ContentLevelUpgradeModel modelWithDictionary:attachment.data]; + if (attachment.second == Custom_Message_Sub_User_UpGrade_Exper) { + self.userInfo.userLevelVo.experLevelSeq = levelInfo.levelSeq; + } else if(attachment.second == Custom_Message_Sub_User_UpGrade_Charm) { + self.userInfo.userLevelVo.charmLevelSeq = levelInfo.levelSeq; + } + } + } + } + } + + // 非房间内消息不处理 + if (message.session.sessionType != NIMSessionTypeChatroom) { + continue; + } - // 非本房间不处理 - if (![message.session.sessionId isEqualToString:[NSString stringWithFormat:@"%ld", self.roomInfo.roomId]]) { - continue; - } + // 非本房间不处理 + if (![message.session.sessionId isEqualToString:[NSString stringWithFormat:@"%ld", self.roomInfo.roomId]]) { + continue; + } - if (message.messageType == NIMMessageTypeNotification) { - NIMNotificationObject *notiMsg = (NIMNotificationObject *)message.messageObject; - NIMChatroomNotificationContent *content = (NIMChatroomNotificationContent *)notiMsg.content; - NSInteger onLineNumber = self.roomInfo.onlineNum; - switch (content.eventType) { - case NIMChatroomEventTypeInfoUpdated: // 麦序状态更新 - { - NSDictionary *data = [content.notifyExt toJSONObject]; - int type = [data[@"type"] intValue]; - switch (type) { - case 1: - case 3: - { - NSMutableDictionary *lastRoomInfoDic = [NSMutableDictionary dictionaryWithDictionary:[self.roomInfo model2dictionary]]; - [lastRoomInfoDic addEntriesFromDictionary: ((NSString *)data[@"roomInfo"]).toJSONObject]; - RoomInfoModel *newRoomInfo = [RoomInfoModel modelWithJSON:lastRoomInfoDic]; - //TODO: 从小游戏房间切换到普通房间的话 mgid不会被清除掉 - if (newRoomInfo.type != RoomType_MiniGame) { - newRoomInfo.mgId = 0; - } - newRoomInfo.hasAnimationEffect = self.hasAnimationEffect; - if (newRoomInfo.roomModeType == RoomModeType_Open_Blind && self.roomInfo.roomModeType != RoomModeType_Open_Blind) { - ///普通房 切换为相亲房 - newRoomInfo.datingState = RoomDatingStateChangeType_Open; - } else if(newRoomInfo.roomModeType != RoomModeType_Open_Blind && self.roomInfo.roomModeType == RoomModeType_Open_Blind) { - ///关闭了相亲房 - newRoomInfo.datingState = RoomDatingStateChangeType_Close; - } else { - newRoomInfo.datingState = RoomDatingStateChangeType_Normal; - } - //房间类型是否变更了(从个播->普通,个播->小游戏等) - newRoomInfo.hadChangeRoomType = self.roomInfo.type != newRoomInfo.type; - BOOL anchorToOther = newRoomInfo.type != RoomType_Anchor && self.roomInfo.type == RoomType_Anchor;//个播变其他房 - self.roomInfo = newRoomInfo; - [self.backContainerView onRoomUpdate]; - self.quickMessageContainerView.titleArray = self.roomInfo.speakTemplate; - if (self.roomInfo.type == RoomType_Anchor && self.roomInfo.hadChangeRoomType) {///从其他房变为个播房 - [self handleInitAnchorRoom]; - [self showAnchorScrollTipView]; - } else if (anchorToOther) { - [self.anchorScrollView removeFromSuperview]; - [self.backContainerView removeFromSuperview]; - [self.stageView removeFromSuperview]; - [self.messageContainerView removeFromSuperview]; - [self.quickMessageContainerView removeFromSuperview]; - [self.activityContainerView removeFromSuperview]; - [self.roomHeaderView removeFromSuperview]; - [self.functionView removeFromSuperview]; + if (message.messageType == NIMMessageTypeNotification) { + NIMNotificationObject *notiMsg = (NIMNotificationObject *)message.messageObject; + NIMChatroomNotificationContent *content = (NIMChatroomNotificationContent *)notiMsg.content; + NSInteger onLineNumber = self.roomInfo.onlineNum; + switch (content.eventType) { + case NIMChatroomEventTypeInfoUpdated: // 麦序状态更新 + { + NSDictionary *data = [content.notifyExt toJSONObject]; + int type = [data[@"type"] intValue]; + switch (type) { + case 1: + case 3: + { + NSMutableDictionary *lastRoomInfoDic = [NSMutableDictionary dictionaryWithDictionary:[self.roomInfo model2dictionary]]; + [lastRoomInfoDic addEntriesFromDictionary: ((NSString *)data[@"roomInfo"]).toJSONObject]; + RoomInfoModel *newRoomInfo = [RoomInfoModel modelWithJSON:lastRoomInfoDic]; + //TODO: 从小游戏房间切换到普通房间的话 mgid不会被清除掉 + if (newRoomInfo.type != RoomType_MiniGame) { + newRoomInfo.mgId = 0; + } + newRoomInfo.hasAnimationEffect = self.hasAnimationEffect; + if (newRoomInfo.roomModeType == RoomModeType_Open_Blind && self.roomInfo.roomModeType != RoomModeType_Open_Blind) { + ///普通房 切换为相亲房 + newRoomInfo.datingState = RoomDatingStateChangeType_Open; + } else if(newRoomInfo.roomModeType != RoomModeType_Open_Blind && self.roomInfo.roomModeType == RoomModeType_Open_Blind) { + ///关闭了相亲房 + newRoomInfo.datingState = RoomDatingStateChangeType_Close; + } else { + newRoomInfo.datingState = RoomDatingStateChangeType_Normal; + } + //房间类型是否变更了(从个播->普通,个播->小游戏等) + newRoomInfo.hadChangeRoomType = self.roomInfo.type != newRoomInfo.type; + BOOL anchorToOther = newRoomInfo.type != RoomType_Anchor && self.roomInfo.type == RoomType_Anchor;//个播变其他房 + self.roomInfo = newRoomInfo; + [self.backContainerView onRoomUpdate]; + self.quickMessageContainerView.titleArray = self.roomInfo.speakTemplate; + if (self.roomInfo.type == RoomType_Anchor && self.roomInfo.hadChangeRoomType) {///从其他房变为个播房 + [self handleInitAnchorRoom]; + [self showAnchorScrollTipView]; + } else if (anchorToOther) { + [self.anchorScrollView removeFromSuperview]; + [self.backContainerView removeFromSuperview]; + [self.stageView removeFromSuperview]; + [self.messageContainerView removeFromSuperview]; + [self.quickMessageContainerView removeFromSuperview]; + [self.activityContainerView removeFromSuperview]; + [self.roomHeaderView removeFromSuperview]; + [self.functionView removeFromSuperview]; - [self.view addSubview:self.backContainerView]; - [self.view addSubview:self.stageView]; - [self.view addSubview:self.messageContainerView]; - [self.view addSubview:self.quickMessageContainerView]; - [self.view addSubview:self.activityContainerView]; - [self.view addSubview:self.roomHeaderView]; - [self.view addSubview:self.functionView]; - [self.view bringSubviewToFront:self.menuContainerView]; - [self.view bringSubviewToFront:self.animationView]; - [self initSubViewConstraints]; - [self changeStageViewOnRoomUpdate]; - [self.stageView onRoomUpdate]; - [self.menuContainerView onRoomUpdate]; - [self.functionView onRoomUpdate]; - [self.activityContainerView onRoomUpdate]; - [self.messageContainerView onRoomUpdate]; + [self.view addSubview:self.backContainerView]; + [self.view addSubview:self.stageView]; + [self.view addSubview:self.messageContainerView]; + [self.view addSubview:self.quickMessageContainerView]; + [self.view addSubview:self.activityContainerView]; + [self.view addSubview:self.roomHeaderView]; + [self.view addSubview:self.functionView]; + [self.view bringSubviewToFront:self.menuContainerView]; + [self.view bringSubviewToFront:self.animationView]; + [self initSubViewConstraints]; + [self changeStageViewOnRoomUpdate]; + [self.stageView onRoomUpdate]; + [self.menuContainerView onRoomUpdate]; + [self.functionView onRoomUpdate]; + [self.activityContainerView onRoomUpdate]; + [self.messageContainerView onRoomUpdate]; [self.littleGameView onRoomUpdate]; - } else { - if (self.roomInfo.type == RoomType_Anchor) { - [self changeStageViewOnAnchorRoom]; - } else { - [self changeStageViewOnRoomUpdate]; - } - [self.stageView onRoomUpdate]; - [self.menuContainerView onRoomUpdate]; - [self.functionView onRoomUpdate]; - [self.activityContainerView onRoomUpdate]; - [self.messageContainerView onRoomUpdate]; + } else { + if (self.roomInfo.type == RoomType_Anchor) { + [self changeStageViewOnAnchorRoom]; + } else { + [self changeStageViewOnRoomUpdate]; + } + [self.stageView onRoomUpdate]; + [self.menuContainerView onRoomUpdate]; + [self.functionView onRoomUpdate]; + [self.activityContainerView onRoomUpdate]; + [self.messageContainerView onRoomUpdate]; [self.littleGameView onRoomUpdate]; - } - } - break; - } - } - break; - case NIMChatroomEventTypeEnter: - if (content.source.userId.integerValue != [AccountInfoStorage instance].getUid.integerValue && self.userInfo.platformRole != 1) { - onLineNumber += 1; - }else {///如果是自己的话 如果有坐骑的话 - [self userEnterRoomSuccess]; - ///在活动页面 判断是否显示 相亲加入的按钮 所以需要等用户进房成功之后才能获取 房间角色 - [self.activityContainerView onRoomUpdate]; - [self.menuContainerView onRoomUpdate]; - } - break; - case NIMChatroomEventTypeAddBlack: - case NIMChatroomEventTypeKicked: - case NIMChatroomEventTypeExit: - onLineNumber -= 1; - break; - case NIMChatroomEventTypeQueueChange: // 麦序上下麦 - { - NSDictionary* data = (NSDictionary *)content.ext; - UserInfoModel* userInfo = [UserInfoModel modelWithJSON:[data objectForKey:NIMChatroomEventInfoQueueChangeItemValueKey]]; - NSInteger changeType = [data[NIMChatroomEventInfoQueueChangeTypeKey] integerValue]; - if (changeType == 1 && userInfo.uid == [AccountInfoStorage instance].getUid.integerValue) { - [self cancelRoomArrangeMic]; - } - } - break; - default: - break; - } - self.roomInfo.onlineNum = onLineNumber; - [self.roomHeaderView onRoomUpdate]; - [self.stageView handleNIMNotificationMessage:message]; - [self.animationView handleNIMNotificationMessage:message]; - [self.messageContainerView handleNIMNotificationMessage:message]; - [self.activityContainerView handleNIMNotificationMessage:message]; - [self.menuContainerView handleNIMNotificationMessage:message]; - [self.functionView handleNIMNotificationMessage:message]; + } + } + break; + } + } + break; + case NIMChatroomEventTypeEnter: + if (content.source.userId.integerValue != [AccountInfoStorage instance].getUid.integerValue && self.userInfo.platformRole != 1) { + onLineNumber += 1; + }else {///如果是自己的话 如果有坐骑的话 + [self userEnterRoomSuccess]; + ///在活动页面 判断是否显示 相亲加入的按钮 所以需要等用户进房成功之后才能获取 房间角色 + [self.activityContainerView onRoomUpdate]; + [self.menuContainerView onRoomUpdate]; + } + break; + case NIMChatroomEventTypeAddBlack: + case NIMChatroomEventTypeKicked: + case NIMChatroomEventTypeExit: + onLineNumber -= 1; + break; + case NIMChatroomEventTypeQueueChange: // 麦序上下麦 + { + NSDictionary* data = (NSDictionary *)content.ext; + UserInfoModel* userInfo = [UserInfoModel modelWithJSON:[data objectForKey:NIMChatroomEventInfoQueueChangeItemValueKey]]; + NSInteger changeType = [data[NIMChatroomEventInfoQueueChangeTypeKey] integerValue]; + if (changeType == 1 && userInfo.uid == [AccountInfoStorage instance].getUid.integerValue) { + [self cancelRoomArrangeMic]; + } + } + break; + default: + break; + } + self.roomInfo.onlineNum = onLineNumber; + [self.roomHeaderView onRoomUpdate]; + [self.stageView handleNIMNotificationMessage:message]; + [self.animationView handleNIMNotificationMessage:message]; + [self.messageContainerView handleNIMNotificationMessage:message]; + [self.activityContainerView handleNIMNotificationMessage:message]; + [self.menuContainerView handleNIMNotificationMessage:message]; + [self.functionView handleNIMNotificationMessage:message]; [self.littleGameView handleNIMNotificationMessage:message]; - if([self.stageView findMicroViewByUid:@(self.userInfo.uid).stringValue] != nil){ - [XPSkillCardPlayerManager shareInstance].isMineInMic = YES; - }else{ - [XPSkillCardPlayerManager shareInstance].isMineInMic = NO; - }; - } else if (message.messageType == NIMMessageTypeCustom) { - NIMCustomObject *obj = (NIMCustomObject *)message.messageObject; - if (obj.attachment != nil && [obj.attachment isKindOfClass:[AttachmentModel class]]) { - AttachmentModel * attachment = (AttachmentModel *)obj.attachment; - [self.stageView handleNIMCustomMessage:message]; - [self.animationView handleNIMCustomMessage:message]; - [self.menuContainerView handleNIMCustomMessage:message]; - [self.activityContainerView handleNIMCustomMessage:message]; - [self.functionView handleNIMCustomMessage:message]; + if([self.stageView findMicroViewByUid:@(self.userInfo.uid).stringValue] != nil){ + [XPSkillCardPlayerManager shareInstance].isMineInMic = YES; + }else{ + [XPSkillCardPlayerManager shareInstance].isMineInMic = NO; + }; + } else if (message.messageType == NIMMessageTypeCustom) { + NIMCustomObject *obj = (NIMCustomObject *)message.messageObject; + if (obj.attachment != nil && [obj.attachment isKindOfClass:[AttachmentModel class]]) { + AttachmentModel * attachment = (AttachmentModel *)obj.attachment; + [self.stageView handleNIMCustomMessage:message]; + [self.animationView handleNIMCustomMessage:message]; + [self.menuContainerView handleNIMCustomMessage:message]; + [self.activityContainerView handleNIMCustomMessage:message]; + [self.functionView handleNIMCustomMessage:message]; [self.littleGameView handleNIMCustomMessage:message]; - if (attachment.first == CustomMessageType_First_Recharge_Reward && attachment.second == Custom_Message_Sub_Room_First_Recharge_Reward) { - self.userInfo.isFirstCharge = NO; - [self.menuContainerView onRoomUpdate]; - [self.activityContainerView onRoomUpdate]; - } else if (attachment.first == CustomMessageType_Update_RoomInfo && attachment.second == Custom_Message_Sub_Update_RoomInfo_MessageState) { - ///兼容安卓和iOS 协议不同的问题 - NSDictionary * dic= attachment.data[@"roomInfo"]; - if (dic.allKeys.count <=0) { - dic = attachment.data; - } - RoomInfoModel * roomInfo = [RoomInfoModel modelWithDictionary:dic]; - self.roomInfo.isCloseScreen = roomInfo.isCloseScreen; - [self.menuContainerView onRoomUpdate]; - } else if(attachment.first == CustomMessageType_Queue && attachment.second == Custom_Message_Sub_Queue_Invite) { - NSDictionary *dic = attachment.data; - NSString *uid = dic[@"uid"]; - if (uid.integerValue == [AccountInfoStorage instance].getUid.integerValue) { - [self cancelRoomArrangeMic]; - } - } else if(attachment.first == CustomMessageType_Hall_Super_Admin && attachment.second == Custom_Message_Sub_Hall_Super_Admin_Kick_Manager_Out_Room) { - XPKickUserModel * userInfo = [XPKickUserModel modelWithJSON:attachment.data]; - if (userInfo.targetUid == [AccountInfoStorage instance].getUid.integerValue) { - [self.presenter exitNIMRoom:[NSString stringWithFormat:@"%ld", self.roomInfo.roomId]]; - [[XPRoomMiniManager shareManager] resetLocalMessage]; - [self cancelRoomArrangeMic]; - [[RtcManager instance] exitRoom]; - [self.presenter reportUserOutRoom:[NSString stringWithFormat:@"%ld", self.roomInfo.uid]]; + if (attachment.first == CustomMessageType_First_Recharge_Reward && attachment.second == Custom_Message_Sub_Room_First_Recharge_Reward) { + self.userInfo.isFirstCharge = NO; + [self.menuContainerView onRoomUpdate]; + [self.activityContainerView onRoomUpdate]; + } else if (attachment.first == CustomMessageType_Update_RoomInfo && attachment.second == Custom_Message_Sub_Update_RoomInfo_MessageState) { + ///兼容安卓和iOS 协议不同的问题 + NSDictionary * dic= attachment.data[@"roomInfo"]; + if (dic.allKeys.count <=0) { + dic = attachment.data; + } + RoomInfoModel * roomInfo = [RoomInfoModel modelWithDictionary:dic]; + self.roomInfo.isCloseScreen = roomInfo.isCloseScreen; + [self.menuContainerView onRoomUpdate]; + } else if(attachment.first == CustomMessageType_Queue && attachment.second == Custom_Message_Sub_Queue_Invite) { + NSDictionary *dic = attachment.data; + NSString *uid = dic[@"uid"]; + if (uid.integerValue == [AccountInfoStorage instance].getUid.integerValue) { + [self cancelRoomArrangeMic]; + } + } else if(attachment.first == CustomMessageType_Hall_Super_Admin && attachment.second == Custom_Message_Sub_Hall_Super_Admin_Kick_Manager_Out_Room) { + XPKickUserModel * userInfo = [XPKickUserModel modelWithJSON:attachment.data]; + if (userInfo.targetUid == [AccountInfoStorage instance].getUid.integerValue) { + [self.presenter exitNIMRoom:[NSString stringWithFormat:@"%ld", self.roomInfo.roomId]]; + [[XPRoomMiniManager shareManager] resetLocalMessage]; + [self cancelRoomArrangeMic]; + [[RtcManager instance] exitRoom]; + [self.presenter reportUserOutRoom:[NSString stringWithFormat:@"%ld", self.roomInfo.uid]]; [self.littleGameView handleSelfInExitEvent]; [self.littleGameView destroyMG]; - [self dismissViewControllerAnimated:YES completion:nil]; - } - } else if (attachment.first == CustomMessageType_RedPacket) { - if (attachment.second == Custom_Message_Sub_RoomDiamandRedPacket) { - XPReceiveRedPacketView *view = [[XPReceiveRedPacketView alloc] initWithFrame:CGRectMake(0, 0, KScreenWidth, KScreenHeight)]; - XPReceiveRedPacketModel *data = [XPReceiveRedPacketModel modelWithJSON:attachment.data]; - view.redPacketModel = data; - for (UIView *subView in self.view.subviews) { - if([subView isKindOfClass:[XPReceiveRedPacketView class]]) { - view.alphaView.backgroundColor = [UIColor clearColor]; - break; - } - } - [self.view addSubview:view]; - [self.view bringSubviewToFront:view]; - } - }else if(attachment.first == CustomMessageType_Free_Gift_Star_Reset_Time){ + [self dismissViewControllerAnimated:YES completion:nil]; + } + } else if (attachment.first == CustomMessageType_RedPacket) { + if (attachment.second == Custom_Message_Sub_RoomDiamandRedPacket) { + XPReceiveRedPacketView *view = [[XPReceiveRedPacketView alloc] initWithFrame:CGRectMake(0, 0, KScreenWidth, KScreenHeight)]; + XPReceiveRedPacketModel *data = [XPReceiveRedPacketModel modelWithJSON:attachment.data]; + view.redPacketModel = data; + for (UIView *subView in self.view.subviews) { + if([subView isKindOfClass:[XPReceiveRedPacketView class]]) { + view.alphaView.backgroundColor = [UIColor clearColor]; + break; + } + } + [self.view addSubview:view]; + [self.view bringSubviewToFront:view]; + } + }else if(attachment.first == CustomMessageType_Free_Gift_Star_Reset_Time){ if(attachment.second == Custom_Message_Sub_Free_Gift_Star_Reset_Time){ [self.presenter getFreeGiftData]; [[NSNotificationCenter defaultCenter]postNotificationName:kFreeGiftCountdownNotification object:nil userInfo:@{@"isReset":@(YES)}]; @@ -1473,15 +1473,15 @@ NSString * const kHadQuitOtherRoomKey = @"kHadQuitOtherRoomKey";//是否退出 } } - [self.messageContainerView handleNIMCustomMessage:message]; - } - } else if(message.messageType == NIMMessageTypeText) { - [self.messageContainerView handleNIMTextMessage:message]; + [self.messageContainerView handleNIMCustomMessage:message]; + } + } else if(message.messageType == NIMMessageTypeText) { + [self.messageContainerView handleNIMTextMessage:message]; [self.littleGameView handleNIMTextMessage:message]; - } else if(message.messageType == NIMMessageTypeTip) { - [self.messageContainerView handleNIMTextMessage:message]; - } - } + } else if(message.messageType == NIMMessageTypeTip) { + [self.messageContainerView handleNIMTextMessage:message]; + } + } } #pragma mark - NIMBroadcastDelegate // 广播消息 @@ -1516,149 +1516,149 @@ NSString * const kHadQuitOtherRoomKey = @"kHadQuitOtherRoomKey";//是否退出 } //发送消息成功回调 - (void)sendMessage:(NIMMessage *)message didCompleteWithError:(NSError *)error { - // 非本房间不处理 - if (![message.session.sessionId isEqualToString:[NSString stringWithFormat:@"%ld", self.roomInfo.roomId]]) { - return; - } + // 非本房间不处理 + if (![message.session.sessionId isEqualToString:[NSString stringWithFormat:@"%ld", self.roomInfo.roomId]]) { + return; + } - if (message.yidunAntiSpamRes) { - NSDictionary * spamRes = message.yidunAntiSpamRes.toJSONObject; - NSDictionary * spamResExt = ((NSString *)spamRes[@"ext"]).toJSONObject; - if ([spamResExt[@"antispam"][@"suggestion"] intValue] == 2) { - [self showErrorToast:YMLocalizedString(@"XPRoomViewController10")]; - return; - } - } + if (message.yidunAntiSpamRes) { + NSDictionary * spamRes = message.yidunAntiSpamRes.toJSONObject; + NSDictionary * spamResExt = ((NSString *)spamRes[@"ext"]).toJSONObject; + if ([spamResExt[@"antispam"][@"suggestion"] intValue] == 2) { + [self showErrorToast:YMLocalizedString(@"XPRoomViewController10")]; + return; + } + } - if (error) return; - if (message.messageType == NIMMessageTypeCustom) { - NIMCustomObject *obj = (NIMCustomObject *)message.messageObject; - if (obj.attachment != nil && [obj.attachment isKindOfClass:[AttachmentModel class]]) { - AttachmentModel * attachment = (AttachmentModel *)obj.attachment; - [self.stageView handleNIMCustomMessage:message]; - [self.animationView handleNIMCustomMessage:message]; - [self.functionView handleNIMCustomMessage:message]; - if (attachment.first == CustomMessageType_Update_RoomInfo && attachment.second == Custom_Message_Sub_Update_RoomInfo_MessageState) { - RoomInfoModel * roomInfo = [RoomInfoModel modelWithDictionary:attachment.data[@"roomInfo"]]; - self.roomInfo.isCloseScreen = roomInfo.isCloseScreen; - [self.menuContainerView onRoomUpdate]; - } - [self.messageContainerView handleNIMCustomMessage:message]; - } - }else if(message.messageType == NIMMessageTypeText) { - [self.messageContainerView handleNIMTextMessage:message];; - } + if (error) return; + if (message.messageType == NIMMessageTypeCustom) { + NIMCustomObject *obj = (NIMCustomObject *)message.messageObject; + if (obj.attachment != nil && [obj.attachment isKindOfClass:[AttachmentModel class]]) { + AttachmentModel * attachment = (AttachmentModel *)obj.attachment; + [self.stageView handleNIMCustomMessage:message]; + [self.animationView handleNIMCustomMessage:message]; + [self.functionView handleNIMCustomMessage:message]; + if (attachment.first == CustomMessageType_Update_RoomInfo && attachment.second == Custom_Message_Sub_Update_RoomInfo_MessageState) { + RoomInfoModel * roomInfo = [RoomInfoModel modelWithDictionary:attachment.data[@"roomInfo"]]; + self.roomInfo.isCloseScreen = roomInfo.isCloseScreen; + [self.menuContainerView onRoomUpdate]; + } + [self.messageContainerView handleNIMCustomMessage:message]; + } + }else if(message.messageType == NIMMessageTypeText) { + [self.messageContainerView handleNIMTextMessage:message];; + } } #pragma mark - NIMLoginManagerDelegate - (void)onKickout:(NIMLoginKickoutResult *)result { - [self exitRoom]; - [self dismissViewControllerAnimated:YES completion:nil]; + [self exitRoom]; + [self dismissViewControllerAnimated:YES completion:nil]; } #pragma mark - NIMConversationManagerDelegate - (void)didAddRecentSession:(NIMRecentSession *)recentSession - totalUnreadCount:(NSInteger)totalUnreadCount { - [self.menuContainerView addNIMRecentSession:recentSession]; + totalUnreadCount:(NSInteger)totalUnreadCount { + [self.menuContainerView addNIMRecentSession:recentSession]; } - (void)didUpdateRecentSession:(NIMRecentSession *)recentSession - totalUnreadCount:(NSInteger)totalUnreadCount { - [self.menuContainerView addNIMRecentSession:recentSession]; + totalUnreadCount:(NSInteger)totalUnreadCount { + [self.menuContainerView addNIMRecentSession:recentSession]; } - (void)didRemoveRecentSession:(NIMRecentSession *)recentSession - totalUnreadCount:(NSInteger)totalUnreadCount { - [self.menuContainerView removeNIMRecentSession:recentSession]; + totalUnreadCount:(NSInteger)totalUnreadCount { + [self.menuContainerView removeNIMRecentSession:recentSession]; } #pragma mark - RoomDelegate - (RoomInfoModel *)getRoomInfo { - return self.roomInfo; + return self.roomInfo; } - (UserInfoModel *)getUserInfo { - return self.userInfo; + return self.userInfo; } - (void)exitRoom { - [self.menuContainerView menuResignFirstResponder]; + [self.menuContainerView menuResignFirstResponder]; [self.animationView resumeTimer]; - if (self.roomInfo.roomModeType == RoomModeType_Open_Micro_Mode || self.roomInfo.roomModeType == RoomModeType_Open_Blind) { - NSString * roomUid = [NSString stringWithFormat:@"%ld", self.roomInfo.uid]; - NSString * uid = [AccountInfoStorage instance].getUid; - [Api getRoomArrangeMicList:^(BaseModel * _Nullable data, NSInteger code, NSString * _Nullable msg) { - if (code == 200) { - ArrangeMicModel * arrangeMicModel= [ArrangeMicModel modelWithJSON:data.data]; - if (arrangeMicModel.myPos.intValue > 0) { - [TTPopup alertWithMessage:YMLocalizedString(@"XPRoomViewController11") confirmHandler:^{ - __block NSString * grouptype = @"0"; - if (self.roomInfo.roomModeType == RoomModeType_Open_Blind) { - [arrangeMicModel.queue enumerateObjectsUsingBlock:^(ArrangeMicUserModel * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) { - if (obj.uid.integerValue == [AccountInfoStorage instance].getUid.integerValue) { - grouptype = [NSString stringWithFormat:@"%ld", obj.groupType]; - *stop = YES; - } - }]; - } - [Api cancelArrangeMic:^(BaseModel * _Nullable data, NSInteger code, NSString * _Nullable msg) { - - } roomUid:roomUid operUid:uid groupType:grouptype]; - [self.presenter exitNIMRoom:[NSString stringWithFormat:@"%ld", self.roomInfo.roomId]]; - [[XPRoomMiniManager shareManager] resetLocalMessage]; - [[RtcManager instance] exitRoom]; - [self.presenter reportUserOutRoom:roomUid]; - [self handleFirstOutRoom]; - [self dismissViewControllerAnimated:YES completion:nil]; - } cancelHandler:^{ - - }]; - return; - } - } - [self.presenter exitNIMRoom:[NSString stringWithFormat:@"%ld", self.roomInfo.roomId]]; - [[XPRoomMiniManager shareManager] resetLocalMessage]; - [[RtcManager instance] exitRoom]; - [self.presenter reportUserOutRoom:roomUid]; - [self handleFirstOutRoom]; - [self dismissViewControllerAnimated:YES completion:nil]; - } roomUid:roomUid operUid:uid page:@"1" pageSize:@"50"]; - } else if(self.roomInfo.roomModeType == RoomModeType_Open_PK_Mode) { - NSString * roomUid = [NSString stringWithFormat:@"%ld", self.roomInfo.uid]; - NSString * uid = [AccountInfoStorage instance].getUid; - [Api getRoomPKUserList:^(BaseModel * _Nullable data, NSInteger code, NSString * _Nullable msg) { - if (code == 200) { - ArrangeMicModel * arrangeMicModel= [ArrangeMicModel modelWithJSON:data.data]; - if (arrangeMicModel.myPos.intValue > 0) { - [TTPopup alertWithMessage:YMLocalizedString(@"XPRoomViewController11") confirmHandler:^{ - __block NSString * grouptype = @"0"; - [arrangeMicModel.queue enumerateObjectsUsingBlock:^(ArrangeMicUserModel * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) { - if (obj.uid.integerValue == [AccountInfoStorage instance].getUid.integerValue) { - grouptype = [NSString stringWithFormat:@"%ld", obj.groupType]; - *stop = YES; - } - }]; - [Api cancelRoomPKArrangeMic:^(BaseModel * _Nullable data, NSInteger code, NSString * _Nullable msg) { - - } roomUid:roomUid operUid:uid groupType:grouptype]; - [self.presenter exitNIMRoom:[NSString stringWithFormat:@"%ld", self.roomInfo.roomId]]; - [[XPRoomMiniManager shareManager] resetLocalMessage]; - [[RtcManager instance] exitRoom]; - [self handleFirstOutRoom]; - [self dismissViewControllerAnimated:YES completion:nil]; - } cancelHandler:^{ - - }]; - return; - } - } - [self.presenter exitNIMRoom:[NSString stringWithFormat:@"%ld", self.roomInfo.roomId]]; - [[XPRoomMiniManager shareManager] resetLocalMessage]; - [[RtcManager instance] exitRoom]; - [self handleFirstOutRoom]; - [self dismissViewControllerAnimated:YES completion:nil]; - } roomUid:roomUid operUid:uid page:@"1" pageSize:@"50"]; - }else if(self.roomInfo.type == RoomType_MiniGame) { + if (self.roomInfo.roomModeType == RoomModeType_Open_Micro_Mode || self.roomInfo.roomModeType == RoomModeType_Open_Blind) { + NSString * roomUid = [NSString stringWithFormat:@"%ld", self.roomInfo.uid]; + NSString * uid = [AccountInfoStorage instance].getUid; + [Api getRoomArrangeMicList:^(BaseModel * _Nullable data, NSInteger code, NSString * _Nullable msg) { + if (code == 200) { + ArrangeMicModel * arrangeMicModel= [ArrangeMicModel modelWithJSON:data.data]; + if (arrangeMicModel.myPos.intValue > 0) { + [TTPopup alertWithMessage:YMLocalizedString(@"XPRoomViewController11") confirmHandler:^{ + __block NSString * grouptype = @"0"; + if (self.roomInfo.roomModeType == RoomModeType_Open_Blind) { + [arrangeMicModel.queue enumerateObjectsUsingBlock:^(ArrangeMicUserModel * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) { + if (obj.uid.integerValue == [AccountInfoStorage instance].getUid.integerValue) { + grouptype = [NSString stringWithFormat:@"%ld", obj.groupType]; + *stop = YES; + } + }]; + } + [Api cancelArrangeMic:^(BaseModel * _Nullable data, NSInteger code, NSString * _Nullable msg) { + + } roomUid:roomUid operUid:uid groupType:grouptype]; + [self.presenter exitNIMRoom:[NSString stringWithFormat:@"%ld", self.roomInfo.roomId]]; + [[XPRoomMiniManager shareManager] resetLocalMessage]; + [[RtcManager instance] exitRoom]; + [self.presenter reportUserOutRoom:roomUid]; + [self handleFirstOutRoom]; + [self dismissViewControllerAnimated:YES completion:nil]; + } cancelHandler:^{ + + }]; + return; + } + } + [self.presenter exitNIMRoom:[NSString stringWithFormat:@"%ld", self.roomInfo.roomId]]; + [[XPRoomMiniManager shareManager] resetLocalMessage]; + [[RtcManager instance] exitRoom]; + [self.presenter reportUserOutRoom:roomUid]; + [self handleFirstOutRoom]; + [self dismissViewControllerAnimated:YES completion:nil]; + } roomUid:roomUid operUid:uid page:@"1" pageSize:@"50"]; + } else if(self.roomInfo.roomModeType == RoomModeType_Open_PK_Mode) { + NSString * roomUid = [NSString stringWithFormat:@"%ld", self.roomInfo.uid]; + NSString * uid = [AccountInfoStorage instance].getUid; + [Api getRoomPKUserList:^(BaseModel * _Nullable data, NSInteger code, NSString * _Nullable msg) { + if (code == 200) { + ArrangeMicModel * arrangeMicModel= [ArrangeMicModel modelWithJSON:data.data]; + if (arrangeMicModel.myPos.intValue > 0) { + [TTPopup alertWithMessage:YMLocalizedString(@"XPRoomViewController11") confirmHandler:^{ + __block NSString * grouptype = @"0"; + [arrangeMicModel.queue enumerateObjectsUsingBlock:^(ArrangeMicUserModel * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) { + if (obj.uid.integerValue == [AccountInfoStorage instance].getUid.integerValue) { + grouptype = [NSString stringWithFormat:@"%ld", obj.groupType]; + *stop = YES; + } + }]; + [Api cancelRoomPKArrangeMic:^(BaseModel * _Nullable data, NSInteger code, NSString * _Nullable msg) { + + } roomUid:roomUid operUid:uid groupType:grouptype]; + [self.presenter exitNIMRoom:[NSString stringWithFormat:@"%ld", self.roomInfo.roomId]]; + [[XPRoomMiniManager shareManager] resetLocalMessage]; + [[RtcManager instance] exitRoom]; + [self handleFirstOutRoom]; + [self dismissViewControllerAnimated:YES completion:nil]; + } cancelHandler:^{ + + }]; + return; + } + } + [self.presenter exitNIMRoom:[NSString stringWithFormat:@"%ld", self.roomInfo.roomId]]; + [[XPRoomMiniManager shareManager] resetLocalMessage]; + [[RtcManager instance] exitRoom]; + [self handleFirstOutRoom]; + [self dismissViewControllerAnimated:YES completion:nil]; + } roomUid:roomUid operUid:uid page:@"1" pageSize:@"50"]; + }else if(self.roomInfo.type == RoomType_MiniGame) { if ([self.littleGameView isInSudGame]) { TTAlertConfig *config = [[TTAlertConfig alloc] init]; config.cancelButtonConfig.title = YMLocalizedString(@"XPRoomSettingInputView4"); @@ -1685,13 +1685,13 @@ NSString * const kHadQuitOtherRoomKey = @"kHadQuitOtherRoomKey";//是否退出 } } else { - [self.presenter exitNIMRoom:[NSString stringWithFormat:@"%ld", self.roomInfo.roomId]]; - [[XPRoomMiniManager shareManager] resetLocalMessage]; - [[RtcManager instance] exitRoom]; - [self.presenter reportUserOutRoom:[NSString stringWithFormat:@"%ld", self.roomInfo.uid]]; - [self handleFirstOutRoom]; - [self dismissViewControllerAnimated:YES completion:nil]; - } + [self.presenter exitNIMRoom:[NSString stringWithFormat:@"%ld", self.roomInfo.roomId]]; + [[XPRoomMiniManager shareManager] resetLocalMessage]; + [[RtcManager instance] exitRoom]; + [self.presenter reportUserOutRoom:[NSString stringWithFormat:@"%ld", self.roomInfo.uid]]; + [self handleFirstOutRoom]; + [self dismissViewControllerAnimated:YES completion:nil]; + } } - (void)miniRoom { @@ -1749,57 +1749,57 @@ NSString * const kHadQuitOtherRoomKey = @"kHadQuitOtherRoomKey";//是否退出 } - (UINavigationController *)getCurrentNav { - return self.navigationController; + return self.navigationController; } - (NSMutableDictionary *)getMicroQueue { - return [self.stageView getMicroQueue]; + return [self.stageView getMicroQueue]; } - (NSArray *)getRoomSuperAdminList { - return self.superMangerList; + return self.superMangerList; } - (NSArray *)getRoomPKGroupTeamList { - return [self.functionView getRoomPKGroupTeamList]; + return [self.functionView getRoomPKGroupTeamList]; } - (BOOL)isRoomPKPlaying { - return [self.functionView isRoomPKPlaying]; + return [self.functionView isRoomPKPlaying]; } - (void)onMicroQueueUpdate:(NSMutableDictionary *)queue { - [self.menuContainerView onMicroQueueUpdate:queue]; - [self.functionView onRoomUpdate]; - [self.functionView onMicroQueueUpdate:queue]; + [self.menuContainerView onMicroQueueUpdate:queue]; + [self.functionView onRoomUpdate]; + [self.functionView onMicroQueueUpdate:queue]; - BOOL isOnMic = false; - for (MicroQueueModel * info in queue.allValues) { - if (info.userInfo.uid > 0 && [AccountInfoStorage instance].getUid.integerValue == info.userInfo.uid) { - isOnMic = YES; - break; - } - } + BOOL isOnMic = false; + for (MicroQueueModel * info in queue.allValues) { + if (info.userInfo.uid > 0 && [AccountInfoStorage instance].getUid.integerValue == info.userInfo.uid) { + isOnMic = YES; + break; + } + } - if (isOnMic) { - self.anchorScrollView.scrollEnabled = NO; - } else { - self.anchorScrollView.scrollEnabled = YES; - } + if (isOnMic) { + self.anchorScrollView.scrollEnabled = NO; + } else { + self.anchorScrollView.scrollEnabled = YES; + } } - (CGPoint)animationPointAtStageViewByUid:(NSString *)uid { - return [self.stageView animationPointAtStageViewByUid:uid]; + return [self.stageView animationPointAtStageViewByUid:uid]; } #pragma mark - 首次退出非自己的房间,处理是否需要弹新用户充值优惠 - (void)handleFirstOutRoom { - NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; - if (![defaults boolForKey:kHadQuitOtherRoomKey] && self.userInfo.uid != self.roomInfo.uid && self.userInfo.showLimitCharge) { - [defaults setBool:YES forKey:kHadQuitOtherRoomKey]; - [defaults synchronize]; - [[NSNotificationCenter defaultCenter] postNotificationName:kNewUserRechargeKey object:nil]; - } + NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; + if (![defaults boolForKey:kHadQuitOtherRoomKey] && self.userInfo.uid != self.roomInfo.uid && self.userInfo.showLimitCharge) { + [defaults setBool:YES forKey:kHadQuitOtherRoomKey]; + [defaults synchronize]; + [[NSNotificationCenter defaultCenter] postNotificationName:kNewUserRechargeKey object:nil]; + } } #pragma mark - XPRoomLittleGameContainerViewDelegate - (void)hiddenSudGamePostionView { @@ -1808,109 +1808,109 @@ NSString * const kHadQuitOtherRoomKey = @"kHadQuitOtherRoomKey";//是否退出 #pragma mark - AnchorRoomScrollViewDelegate - (void)anchorScrollViewScrollToNext:(AnchorRoomScrollView *)anchorScrollView { - if (!self) { - return; - } - [self.view endEditing:YES]; - [self showAnchorLoading]; - [self.presenter getCycleAnchorRoomList:[NSString stringWithFormat:@"%ld", self.roomInfo.uid]]; + if (!self) { + return; + } + [self.view endEditing:YES]; + [self showAnchorLoading]; + [self.presenter getCycleAnchorRoomList:[NSString stringWithFormat:@"%ld", self.roomInfo.uid]]; } - (void)anchorScrollViewScrollToPrevious:(AnchorRoomScrollView *)anchorScrollView { - if (!self || self.anchorRoomList.count <= 0) { - return; - } - [self.view endEditing:YES]; - [self showAnchorLoading]; - if (self.anchorIndex < self.anchorRoomList.count) { - NSString * roomUid = [self.anchorRoomList safeObjectAtIndex1:self.anchorIndex]; - [self.presenter getCurrentRoomInfo:roomUid]; - self.anchorIndex --; - }else { - [self showErrorToast:YMLocalizedString(@"XPRoomViewController13")]; - self.anchorScrollView.contentOffset = CGPointMake(0, KScreenHeight); - } + if (!self || self.anchorRoomList.count <= 0) { + return; + } + [self.view endEditing:YES]; + [self showAnchorLoading]; + if (self.anchorIndex < self.anchorRoomList.count) { + NSString * roomUid = [self.anchorRoomList safeObjectAtIndex1:self.anchorIndex]; + [self.presenter getCurrentRoomInfo:roomUid]; + self.anchorIndex --; + }else { + [self showErrorToast:YMLocalizedString(@"XPRoomViewController13")]; + self.anchorScrollView.contentOffset = CGPointMake(0, KScreenHeight); + } } #pragma mark - XPRoomSettingInputViewDelegate ///点击了完成 - (void)xPRoomSettingInputView:(XPRoomSettingInputView *)view didClickConfirm:(NSString *)text type:(RoomSettingInputType)type { - NSString *pwdDes = [DESEncrypt encryptUseDES:text key:KeyWithType(KeyType_PasswordEncode)]; - if ([pwdDes isEqualToString:self.roomInfo.roomPwd]) { - [TTPopup dismiss]; - view.isPwdError = NO; - if (self.roomInfo.type == RoomType_Anchor) { - if (!self.anchorScrollView.superview) { - [self.view insertSubview:self.anchorScrollView belowSubview:self.menuContainerView]; - } - [self.backContainerView removeFromSuperview]; - [self.stageView removeFromSuperview]; - [self.messageContainerView removeFromSuperview]; - [self.quickMessageContainerView removeFromSuperview]; - [self.activityContainerView removeFromSuperview]; - [self.roomHeaderView removeFromSuperview]; - [self.functionView removeFromSuperview]; + NSString *pwdDes = [DESEncrypt encryptUseDES:text key:KeyWithType(KeyType_PasswordEncode)]; + if ([pwdDes isEqualToString:self.roomInfo.roomPwd]) { + [TTPopup dismiss]; + view.isPwdError = NO; + if (self.roomInfo.type == RoomType_Anchor) { + if (!self.anchorScrollView.superview) { + [self.view insertSubview:self.anchorScrollView belowSubview:self.menuContainerView]; + } + [self.backContainerView removeFromSuperview]; + [self.stageView removeFromSuperview]; + [self.messageContainerView removeFromSuperview]; + [self.quickMessageContainerView removeFromSuperview]; + [self.activityContainerView removeFromSuperview]; + [self.roomHeaderView removeFromSuperview]; + [self.functionView removeFromSuperview]; - [self.anchorScrollView addSubview:self.backContainerView]; - [self.anchorScrollView addSubview:self.stageView]; - [self.anchorScrollView addSubview:self.messageContainerView]; - [self.anchorScrollView addSubview:self.quickMessageContainerView]; - [self.anchorScrollView addSubview:self.activityContainerView]; - [self.anchorScrollView addSubview:self.roomHeaderView]; - [self.anchorScrollView addSubview:self.functionView]; - if (!self.menuContainerView.superview) { - [self.view addSubview:self.menuContainerView]; - } - [self.view bringSubviewToFront:self.animationView]; + [self.anchorScrollView addSubview:self.backContainerView]; + [self.anchorScrollView addSubview:self.stageView]; + [self.anchorScrollView addSubview:self.messageContainerView]; + [self.anchorScrollView addSubview:self.quickMessageContainerView]; + [self.anchorScrollView addSubview:self.activityContainerView]; + [self.anchorScrollView addSubview:self.roomHeaderView]; + [self.anchorScrollView addSubview:self.functionView]; + if (!self.menuContainerView.superview) { + [self.view addSubview:self.menuContainerView]; + } + [self.view bringSubviewToFront:self.animationView]; - [self updateViewConstraintsOnAnchorRoom]; - [self changeStageViewOnAnchorRoom]; + [self updateViewConstraintsOnAnchorRoom]; + [self changeStageViewOnAnchorRoom]; - [self.roomHeaderView onRoomEntered]; - [self.activityContainerView onRoomEntered]; - [self.menuContainerView onRoomEntered]; - [self.backContainerView onRoomEntered]; + [self.roomHeaderView onRoomEntered]; + [self.activityContainerView onRoomEntered]; + [self.menuContainerView onRoomEntered]; + [self.backContainerView onRoomEntered]; [self.littleGameView onRoomEntered]; [self.littleGameView onRoomEntered]; - if ([XPRoomMiniManager shareManager].getRoomInfo.uid != self.roomUid.integerValue) {// 最小化进房 还是原来的房间的话 不需要重新进入云信 因为压根没退 - [self.presenter enterNIMRoom:[NSString stringWithFormat:@"%ld", self.roomInfo.roomId] user:self.userInfo]; - [self.functionView onRoomEntered]; - [self.messageContainerView onRoomEntered]; - } else { - //虽然没退出房间 但是队列还是要拿的 - [self.stageView onRoomMiniEntered]; - [self.messageContainerView onRoomMiniEntered]; - [self.functionView onRoomMiniEntered]; - [self.functionView onRoomEntered]; - } - [[XPRoomMiniManager shareManager] configRoomInfo:nil]; - [[XPRoomMiniManager shareManager] configUserInfo:nil]; - [[XPRoomMiniManager shareManager] configCurrentMusic:nil isPlaying:NO]; - } else { - [self.roomHeaderView onRoomEntered]; - [self.activityContainerView onRoomEntered]; - [self.menuContainerView onRoomEntered]; - [self changeStageViewOnRoomUpdate]; - [self.backContainerView onRoomEntered]; + if ([XPRoomMiniManager shareManager].getRoomInfo.uid != self.roomUid.integerValue) {// 最小化进房 还是原来的房间的话 不需要重新进入云信 因为压根没退 + [self.presenter enterNIMRoom:[NSString stringWithFormat:@"%ld", self.roomInfo.roomId] user:self.userInfo]; + [self.functionView onRoomEntered]; + [self.messageContainerView onRoomEntered]; + } else { + //虽然没退出房间 但是队列还是要拿的 + [self.stageView onRoomMiniEntered]; + [self.messageContainerView onRoomMiniEntered]; + [self.functionView onRoomMiniEntered]; + [self.functionView onRoomEntered]; + } + [[XPRoomMiniManager shareManager] configRoomInfo:nil]; + [[XPRoomMiniManager shareManager] configUserInfo:nil]; + [[XPRoomMiniManager shareManager] configCurrentMusic:nil isPlaying:NO]; + } else { + [self.roomHeaderView onRoomEntered]; + [self.activityContainerView onRoomEntered]; + [self.menuContainerView onRoomEntered]; + [self changeStageViewOnRoomUpdate]; + [self.backContainerView onRoomEntered]; [self.littleGameView onRoomEntered]; - [self.functionView onRoomEntered]; - [self.presenter enterNIMRoom:[NSString stringWithFormat:@"%ld", self.roomInfo.roomId] user:self.userInfo]; - [self.messageContainerView onRoomEntered]; + [self.functionView onRoomEntered]; + [self.presenter enterNIMRoom:[NSString stringWithFormat:@"%ld", self.roomInfo.roomId] user:self.userInfo]; + [self.messageContainerView onRoomEntered]; [self.littleGameView onRoomEntered]; - [[XPRoomMiniManager shareManager] configRoomInfo:nil]; - [[XPRoomMiniManager shareManager] configUserInfo:nil]; - [[XPRoomMiniManager shareManager] configCurrentMusic:nil isPlaying:NO]; - } - } else { - view.isPwdError = YES; - } + [[XPRoomMiniManager shareManager] configRoomInfo:nil]; + [[XPRoomMiniManager shareManager] configUserInfo:nil]; + [[XPRoomMiniManager shareManager] configCurrentMusic:nil isPlaying:NO]; + } + } else { + view.isPwdError = YES; + } } - (void)didClickCancel:(RoomSettingInputType)type { - if (type == RoomSettingInputType_Input_Pwd) { - [self enterRoomFail:0]; - } + if (type == RoomSettingInputType_Input_Pwd) { + [self enterRoomFail:0]; + } } @@ -1918,10 +1918,7 @@ NSString * const kHadQuitOtherRoomKey = @"kHadQuitOtherRoomKey";//是否退出 -(void)rechargeHandle{ XPWebViewController * vc =[[XPWebViewController alloc] initWithCustomizeNav:YES]; - NSString *channel = @"p"; - channel = [NSString stringWithFormat:@"%@a",channel]; - channel = [NSString stringWithFormat:@"%@y",channel]; - NSString *url = [NSString stringWithFormat:URLWithType(kChannelUrl),channel,@"6",[YYUtility deviceID]]; + NSString *url = [NSString stringWithFormat:URLWithType(kThirdPartyPay),@"6",[YYUtility deviceID]]; vc.url = url; vc.isPush = YES; vc.modalPresentationStyle = UIModalPresentationFullScreen; @@ -1960,66 +1957,66 @@ NSString * const kHadQuitOtherRoomKey = @"kHadQuitOtherRoomKey";//是否退出 }]; } - (XPRoomBackContainerView *)backContainerView { - if (!_backContainerView) { - _backContainerView = [[XPRoomBackContainerView alloc] initWithdelegate:self]; - } - return _backContainerView; + if (!_backContainerView) { + _backContainerView = [[XPRoomBackContainerView alloc] initWithdelegate:self]; + } + return _backContainerView; } - (RoomHeaderView *)roomHeaderView { - if (!_roomHeaderView) { - _roomHeaderView = [[RoomHeaderView alloc] initWithDelegate:self]; - } - return _roomHeaderView; + if (!_roomHeaderView) { + _roomHeaderView = [[RoomHeaderView alloc] initWithDelegate:self]; + } + return _roomHeaderView; } - (XPRoomMessageContainerView *)messageContainerView { - if (!_messageContainerView) { - _messageContainerView = [[XPRoomMessageContainerView alloc] initWithDelegate:self]; - } - return _messageContainerView; + if (!_messageContainerView) { + _messageContainerView = [[XPRoomMessageContainerView alloc] initWithDelegate:self]; + } + return _messageContainerView; } - (XPRoomQuickMessageContainView *)quickMessageContainerView { - if(!_quickMessageContainerView) { - _quickMessageContainerView = [[XPRoomQuickMessageContainView alloc] initWithDelegate:self]; - } - return _quickMessageContainerView; + if(!_quickMessageContainerView) { + _quickMessageContainerView = [[XPRoomQuickMessageContainView alloc] initWithDelegate:self]; + } + return _quickMessageContainerView; } - (XPRoomMenuContainerView *)menuContainerView { - if (!_menuContainerView) { - _menuContainerView = [[XPRoomMenuContainerView alloc] initWithDelegate:self]; - } - return _menuContainerView; + if (!_menuContainerView) { + _menuContainerView = [[XPRoomMenuContainerView alloc] initWithDelegate:self]; + } + return _menuContainerView; } - (XPRoomActivityContainerView *)activityContainerView { - if (!_activityContainerView) { - _activityContainerView = [[XPRoomActivityContainerView alloc] initWithdelegate:self]; - } - return _activityContainerView; + if (!_activityContainerView) { + _activityContainerView = [[XPRoomActivityContainerView alloc] initWithdelegate:self]; + } + return _activityContainerView; } - (XPRoomAnimationView *)animationView { - if (!_animationView) { - _animationView = [[XPRoomAnimationView alloc] initWithDelegate:self]; - } - return _animationView; + if (!_animationView) { + _animationView = [[XPRoomAnimationView alloc] initWithDelegate:self]; + } + return _animationView; } - (XPRoomFunctionContainerView *)functionView { - if (!_functionView) { - _functionView = [[XPRoomFunctionContainerView alloc] initWithdelegate:self]; - } - return _functionView; + if (!_functionView) { + _functionView = [[XPRoomFunctionContainerView alloc] initWithdelegate:self]; + } + return _functionView; } - (StageView *)stageView { - if (!_stageView) { - _stageView = [[SocialStageView alloc] initWithDelegate:self]; - } - return _stageView; + if (!_stageView) { + _stageView = [[SocialStageView alloc] initWithDelegate:self]; + } + return _stageView; } - (XPRoomLittleGameContainerView *)littleGameView { if (!_littleGameView) { @@ -2029,39 +2026,39 @@ NSString * const kHadQuitOtherRoomKey = @"kHadQuitOtherRoomKey";//是否退出 return _littleGameView; } - (AnchorRoomScrollView *)anchorScrollView { - if (!_anchorScrollView) { - _anchorScrollView = [[AnchorRoomScrollView alloc] initWithFrame:CGRectMake(0, 0, KScreenWidth, KScreenHeight)]; - _anchorScrollView.anchorScrollDelegate = self; - _anchorScrollView.hostDelegate = self; - if (@available(iOS 11.0, *)) { - _anchorScrollView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever; - } - } - return _anchorScrollView; + if (!_anchorScrollView) { + _anchorScrollView = [[AnchorRoomScrollView alloc] initWithFrame:CGRectMake(0, 0, KScreenWidth, KScreenHeight)]; + _anchorScrollView.anchorScrollDelegate = self; + _anchorScrollView.hostDelegate = self; + if (@available(iOS 11.0, *)) { + _anchorScrollView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever; + } + } + return _anchorScrollView; } - (AnchorRoomSrollTipView *)anchorScrollTipView { - if (!_anchorScrollTipView) { - _anchorScrollTipView = [[AnchorRoomSrollTipView alloc] initWithFrame:CGRectMake(0, 0, KScreenWidth, KScreenHeight)]; - } - return _anchorScrollTipView; + if (!_anchorScrollTipView) { + _anchorScrollTipView = [[AnchorRoomSrollTipView alloc] initWithFrame:CGRectMake(0, 0, KScreenWidth, KScreenHeight)]; + } + return _anchorScrollTipView; } - (NSMutableArray *)anchorRoomList { - if (!_anchorRoomList) { - _anchorRoomList = [NSMutableArray array]; - } - return _anchorRoomList; + if (!_anchorRoomList) { + _anchorRoomList = [NSMutableArray array]; + } + return _anchorRoomList; } - (XPFirstRechargeView *)firstRechargeView{ - if (!_firstRechargeView){ - XPFirstRechargeView *firstRechargeView = [[XPFirstRechargeView alloc]initWithFrame:CGRectMake(0, 0, KScreenWidth, KScreenHeight)]; - firstRechargeView.delegate = self; + if (!_firstRechargeView){ + XPFirstRechargeView *firstRechargeView = [[XPFirstRechargeView alloc]initWithFrame:CGRectMake(0, 0, KScreenWidth, KScreenHeight)]; + firstRechargeView.delegate = self; - _firstRechargeView = firstRechargeView; - } - return _firstRechargeView; + _firstRechargeView = firstRechargeView; + } + return _firstRechargeView; } -(XPFreeGiftsObtainView *)freeView{ if (!_freeView){ diff --git a/YuMi/Modules/YMWeb/XPWebViewController.m b/YuMi/Modules/YMWeb/XPWebViewController.m index 0de361c7..502286dc 100644 --- a/YuMi/Modules/YMWeb/XPWebViewController.m +++ b/YuMi/Modules/YMWeb/XPWebViewController.m @@ -27,18 +27,19 @@ #import "Api+Mine.h" #import "XPSkillCardPlayerManager.h" #import "XPWebViewNavView.h" -#import "XPIAPRechargeViewController.h" + #import "SessionViewController.h" #import "XPMonentTopicContainerViewController.h" + typedef NS_ENUM(NSUInteger, RightNavigationPushType){ - ///跳转h5页面 - RightNavigationPushType_Web = 1, - ///分享 - RightNavigationPushType_Share = 2, - ///跳转原生页面 - RightNavigationPushType_AppPage = 3, - ///分享图片 - RightNavigationPushType_SharePicture = 5 + ///跳转h5页面 + RightNavigationPushType_Web = 1, + ///分享 + RightNavigationPushType_Share = 2, + ///跳转原生页面 + RightNavigationPushType_AppPage = 3, + ///分享图片 + RightNavigationPushType_SharePicture = 5 }; @interface WeakWebViewScriptMessageDelegate : NSObject @@ -52,20 +53,20 @@ typedef NS_ENUM(NSUInteger, RightNavigationPushType){ @implementation WeakWebViewScriptMessageDelegate - (instancetype)initWithDelegate:(id)scriptDelegate { - self = [super init]; - if (self) { - _scriptDelegate = scriptDelegate; - } - return self; + self = [super init]; + if (self) { + _scriptDelegate = scriptDelegate; + } + return self; } //遵循WKScriptMessageHandler协议,必须实现如下方法,然后把方法向外传递 //通过接收JS传出消息的name进行捕捉的回调方法 - (void)userContentController:(WKUserContentController *)userContentController didReceiveScriptMessage:(WKScriptMessage *)message { - if ([self.scriptDelegate respondsToSelector:@selector(userContentController:didReceiveScriptMessage:)]) { - [self.scriptDelegate userContentController:userContentController didReceiveScriptMessage:message]; - } + if ([self.scriptDelegate respondsToSelector:@selector(userContentController:didReceiveScriptMessage:)]) { + [self.scriptDelegate userContentController:userContentController didReceiveScriptMessage:message]; + } } @end @@ -109,145 +110,145 @@ NSString * const kJSOpenAppConcernedChat = @"openAppConcernedChat"; - (instancetype)initWithCustomizeNav:(BOOL)isCustom { - self = [super init]; - if (self) { - self.isCustom = isCustom; + self = [super init]; + if (self) { + self.isCustom = isCustom; - } - return self; + } + return self; } -(void)viewWillAppear:(BOOL)animated{ - [super viewWillAppear:animated]; + [super viewWillAppear:animated]; - if([XPSkillCardPlayerManager shareInstance].isInRoom == YES && self.isProperty == NO && [XPSkillCardPlayerManager shareInstance].isInRoomFirstRecharge == NO){ - [XPSkillCardPlayerManager shareInstance].isInRoomFirstRecharge = YES; - } + if([XPSkillCardPlayerManager shareInstance].isInRoom == YES && self.isProperty == NO && [XPSkillCardPlayerManager shareInstance].isInRoomFirstRecharge == NO){ + [XPSkillCardPlayerManager shareInstance].isInRoomFirstRecharge = YES; + } } - (void)viewDidLoad { - [super viewDidLoad]; - [self initView]; + [super viewDidLoad]; + [self initView]; } - (void)initView { - if (self.navigationController.viewControllers.count > 1){ - UIBarButtonItem *leftBarButtonItem = [[UIBarButtonItem alloc]initWithImage:[UIImage imageNamed:@"common_nav_back"] style:UIBarButtonItemStylePlain target:self action:@selector(backButtonClick)]; + if (self.navigationController.viewControllers.count > 1){ + UIBarButtonItem *leftBarButtonItem = [[UIBarButtonItem alloc]initWithImage:[UIImage imageNamed:@"common_nav_back"] style:UIBarButtonItemStylePlain target:self action:@selector(backButtonClick)]; - leftBarButtonItem.tintColor = [DJDKMIMOMColor mainTextColor]; + leftBarButtonItem.tintColor = [DJDKMIMOMColor mainTextColor]; - self.navigationItem.leftBarButtonItem = leftBarButtonItem; - } - if (@available(iOS 11.0, *)) { - self.webview.scrollView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever; - }else{ - self.automaticallyAdjustsScrollViewInsets = NO; - } - if(self.isCustom == YES){ - [self.view addSubview:self.navView]; + self.navigationItem.leftBarButtonItem = leftBarButtonItem; + } + if (@available(iOS 11.0, *)) { + self.webview.scrollView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever; + }else{ + self.automaticallyAdjustsScrollViewInsets = NO; + } + if(self.isCustom == YES){ + [self.view addSubview:self.navView]; - [self.view addSubview:self.webview]; - [self.view addSubview:self.progressView]; - [self.navView mas_makeConstraints:^(MASConstraintMaker *make) { - make.left.right.top.equalTo(self.view); - make.height.mas_equalTo(kNavigationHeight); - }]; - [self.webview mas_makeConstraints:^(MASConstraintMaker *make) { - make.left.right.bottom.equalTo(self.view); - make.top.equalTo(self.navView.mas_bottom); - }]; - [self.progressView mas_makeConstraints:^(MASConstraintMaker *make) { - make.left.right.equalTo(self.view); - make.height.mas_equalTo(1); - make.top.equalTo(self.navView.mas_bottom); - }]; - }else{ - [self.view addSubview:self.webview]; - [self.view addSubview:self.progressView]; - [self.webview mas_makeConstraints:^(MASConstraintMaker *make) { - make.left.right.top.bottom.mas_equalTo(self.view); - }]; - } + [self.view addSubview:self.webview]; + [self.view addSubview:self.progressView]; + [self.navView mas_makeConstraints:^(MASConstraintMaker *make) { + make.left.right.top.equalTo(self.view); + make.height.mas_equalTo(kNavigationHeight); + }]; + [self.webview mas_makeConstraints:^(MASConstraintMaker *make) { + make.left.right.bottom.equalTo(self.view); + make.top.equalTo(self.navView.mas_bottom); + }]; + [self.progressView mas_makeConstraints:^(MASConstraintMaker *make) { + make.left.right.equalTo(self.view); + make.height.mas_equalTo(1); + make.top.equalTo(self.navView.mas_bottom); + }]; + }else{ + [self.view addSubview:self.webview]; + [self.view addSubview:self.progressView]; + [self.webview mas_makeConstraints:^(MASConstraintMaker *make) { + make.left.right.top.bottom.mas_equalTo(self.view); + }]; + } - NSString * uid = [AccountInfoStorage instance].getUid; - NSString * ticket = [AccountInfoStorage instance].getTicket; - [Api getUserWalletInfo:^(BaseModel * _Nullable data, NSInteger code, NSString * _Nullable msg) { - if(code == 200){ - WalletInfoModel * model = [WalletInfoModel modelWithDictionary:data.data]; - self.model = model; - } + NSString * uid = [AccountInfoStorage instance].getUid; + NSString * ticket = [AccountInfoStorage instance].getTicket; + [Api getUserWalletInfo:^(BaseModel * _Nullable data, NSInteger code, NSString * _Nullable msg) { + if(code == 200){ + WalletInfoModel * model = [WalletInfoModel modelWithDictionary:data.data]; + self.model = model; + } - } uid:uid ticket:ticket]; + } uid:uid ticket:ticket]; } - (void)xPWebViewNavView:(XPWebViewNavView *)view didClickBack:(UIButton *)sender{ if(self.is_Pi_FairyPay){ [self.view removeFromSuperview]; return; } - if(self.isFairyPay){ - if(self.CloseWebViewBlock){ - self.CloseWebViewBlock(YES); - } - return; - } - [self dismissViewControllerAnimated:YES completion:nil]; + if(self.isFairyPay){ + if(self.CloseWebViewBlock){ + self.CloseWebViewBlock(YES); + } + return; + } + [self dismissViewControllerAnimated:YES completion:nil]; } //加载完成 - (void)webView:(WKWebView *)webView didFinishNavigation:(WKNavigation *)navigation { - //加载完成后隐藏progressView - self.progressView.hidden = YES; - if (self.urlLoadCompleted) { - self.urlLoadCompleted(YES, nil); - } + //加载完成后隐藏progressView + self.progressView.hidden = YES; + if (self.urlLoadCompleted) { + self.urlLoadCompleted(YES, nil); + } } //加载失败 - (void)webView:(WKWebView *)webView didFailProvisionalNavigation:(WKNavigation *)navigation withError:(NSError *)error { - //加载失败同样需要隐藏progressView - self.progressView.hidden = YES; - if (self.urlLoadCompleted) { - self.urlLoadCompleted(NO, error); - } + //加载失败同样需要隐藏progressView + self.progressView.hidden = YES; + if (self.urlLoadCompleted) { + self.urlLoadCompleted(NO, error); + } } //捕抓打电话事件 - (void)webView:(WKWebView *)webView decidePolicyForNavigationAction:(WKNavigationAction *)navigationAction decisionHandler:(void (^)(WKNavigationActionPolicy))decisionHandler { - NSURL *URL = navigationAction.request.URL; - NSString *scheme = [URL scheme]; - NSURLRequest *request = navigationAction.request; - // Judge is whether to jump to other app. - if (![scheme isEqualToString:@"https"] && ![scheme isEqualToString:@"http"]) { - BOOL canOpen = [[UIApplication sharedApplication] canOpenURL:request.URL]; - if (canOpen) { - [[UIApplication sharedApplication] openURL:request.URL]; - } - decisionHandler(WKNavigationActionPolicyCancel); - return; - } - decisionHandler(WKNavigationActionPolicyAllow); + NSURL *URL = navigationAction.request.URL; + NSString *scheme = [URL scheme]; + NSURLRequest *request = navigationAction.request; + // Judge is whether to jump to other app. + if (![scheme isEqualToString:@"https"] && ![scheme isEqualToString:@"http"]) { + BOOL canOpen = [[UIApplication sharedApplication] canOpenURL:request.URL]; + if (canOpen) { + [[UIApplication sharedApplication] openURL:request.URL]; + } + decisionHandler(WKNavigationActionPolicyCancel); + return; + } + decisionHandler(WKNavigationActionPolicyAllow); } - (void)webView:(WKWebView *)webView didReceiveAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge completionHandler:(void (^)(NSURLSessionAuthChallengeDisposition, NSURLCredential * _Nullable))completionHandler{ - if ([challenge.protectionSpace.authenticationMethod isEqualToString:NSURLAuthenticationMethodServerTrust]) { - dispatch_async(dispatch_get_main_queue(), ^{ - NSURLCredential *card = [[NSURLCredential alloc]initWithTrust:challenge.protectionSpace.serverTrust]; - completionHandler(NSURLSessionAuthChallengeUseCredential,card); - }); + if ([challenge.protectionSpace.authenticationMethod isEqualToString:NSURLAuthenticationMethodServerTrust]) { + dispatch_async(dispatch_get_main_queue(), ^{ + NSURLCredential *card = [[NSURLCredential alloc]initWithTrust:challenge.protectionSpace.serverTrust]; + completionHandler(NSURLSessionAuthChallengeUseCredential,card); + }); - } + } } - (void)userContentController:(WKUserContentController *)userContentController didReceiveScriptMessage:(WKScriptMessage *)message { - [self.webview evaluateJavaScript:@"document.location.href" completionHandler:^(id _Nullable response, NSError * _Nullable error) { - NSLog(@"%@", response); - NSString *currentUrl = [NSString stringWithFormat:@"%@", response]; - ///测试环境只要有host就执行,方便h5连接本地调试 + [self.webview evaluateJavaScript:@"document.location.href" completionHandler:^(id _Nullable response, NSError * _Nullable error) { + NSLog(@"%@", response); + NSString *currentUrl = [NSString stringWithFormat:@"%@", response]; + ///测试环境只要有host就执行,方便h5连接本地调试 #ifdef DEBUG - if (currentUrl != nil) { + if (currentUrl != nil) { #else if (currentUrl != nil && [currentUrl containsString:API_HOST_URL]) { #endif @@ -306,24 +307,27 @@ NSString * const kJSOpenAppConcernedChat = @"openAppConcernedChat"; [TTPopup dismiss]; if(self.isPush){ - XPIAPRechargeViewController * webVC =[[XPIAPRechargeViewController alloc] init]; - webVC.type = @"4"; - [[XCCurrentVCStackManager shareManager].getCurrentVC.navigationController pushViewController:webVC animated:YES]; - return; + XPWebViewController * webVC =[[XPWebViewController alloc] init]; + webVC. url = [NSString stringWithFormat:URLWithType(kThirdPartyPay),@"4",[YYUtility deviceID]]; + webVC. isPush = YES; + [[XCCurrentVCStackManager shareManager].getCurrentVC. navigationController pushViewController:webVC animated:YES]; + return; } UIViewController *controller = [XCCurrentVCStackManager shareManager].getCurrentVC; if (controller.presentingViewController) { - [controller dismissViewControllerAnimated:NO completion:nil]; - dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ - - XPIAPRechargeViewController * webVC =[[XPIAPRechargeViewController alloc] init]; - webVC.type = @"4"; - [[XCCurrentVCStackManager shareManager].getCurrentVC.navigationController pushViewController:webVC animated:YES]; - }); + [controller dismissViewControllerAnimated:NO completion:nil]; + dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ + + XPWebViewController * webVC =[[XPWebViewController alloc] init]; + webVC. isPush = YES; + webVC. url = [NSString stringWithFormat:URLWithType(kThirdPartyPay),@"4",[YYUtility deviceID]]; + [[XCCurrentVCStackManager shareManager].getCurrentVC. navigationController pushViewController:webVC animated:YES]; + }); }else { - XPIAPRechargeViewController * webVC =[[XPIAPRechargeViewController alloc] init]; - webVC.type = @"4"; - [[XCCurrentVCStackManager shareManager].getCurrentVC.navigationController pushViewController:webVC animated:YES]; + XPWebViewController * webVC =[[XPWebViewController alloc] init]; + webVC. isPush = YES; + webVC. url = [NSString stringWithFormat:URLWithType(kThirdPartyPay),@"4",[YYUtility deviceID]]; + [[XCCurrentVCStackManager shareManager].getCurrentVC. navigationController pushViewController:webVC animated:YES]; } } else if ([message.name isEqualToString:kOpenPersonPage]) { NSString *uid = [NSString stringWithFormat:@"%@",message.body]; @@ -385,83 +389,207 @@ NSString * const kJSOpenAppConcernedChat = @"openAppConcernedChat"; [[XCCurrentVCStackManager shareManager].getCurrentVC.navigationController pushViewController:sessionVC animated:YES]; } }else if ([message.name isEqualToString:kJSOpenRoom]) { - NSString *uid = [NSString stringWithFormat:@"%@",message.body]; - if (uid.length > 0) { - [[XCCurrentVCStackManager shareManager].getCurrentVC.navigationController.viewControllers enumerateObjectsUsingBlock:^(__kindof UIViewController * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) { - if ([obj isKindOfClass:[XPRoomViewController class]]) { - [[XCCurrentVCStackManager shareManager].getCurrentVC.navigationController popToRootViewControllerAnimated:NO]; - XPRoomViewController * rooomVC = obj; - [rooomVC exitRoom]; - *stop = YES; - } - }]; - if(self.view.superview){ - [TTPopup dismiss]; - } - dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ - [XPRoomViewController openRoom:uid viewController:[XCCurrentVCStackManager shareManager].getCurrentVC]; - }); - } - } else if([message.name isEqualToString:kJSOpenRoomForGiftId]) { - NSLog(@"%@", message.body); - NSDictionary *bodyDict; - if ([message.body isKindOfClass:[NSDictionary class]]) { - bodyDict = message.body; - } else if ([message.body isKindOfClass:[NSString class]]) { - NSString *str = (NSString *)message.body; - bodyDict = [str toJSONObject]; - } - //房间页 传参:uid - NSString *uid = [NSString stringWithFormat:@"%@", bodyDict[@"uid"]]; - NSString *giftId = [NSString stringWithFormat:@"%@", bodyDict[@"giftId"]]; - if (uid.length) { - [[XCCurrentVCStackManager shareManager].getCurrentVC.navigationController.viewControllers enumerateObjectsUsingBlock:^(__kindof UIViewController * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) { - if ([obj isKindOfClass:[XPRoomViewController class]]) { - [[XCCurrentVCStackManager shareManager].getCurrentVC.navigationController popToRootViewControllerAnimated:NO]; - XPRoomViewController * rooomVC = obj; - [rooomVC exitRoom]; - *stop = YES; - } - }]; - dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ - [XPRoomViewController openRoom:uid giftId:giftId viewController:[XCCurrentVCStackManager shareManager].getCurrentVC]; - }); - } + NSString *uid = [NSString stringWithFormat:@"%@",message.body]; + if (uid.length > 0) { + [[XCCurrentVCStackManager shareManager].getCurrentVC.navigationController.viewControllers enumerateObjectsUsingBlock:^(__kindof UIViewController * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) { + if ([obj isKindOfClass:[XPRoomViewController class]]) { + [[XCCurrentVCStackManager shareManager].getCurrentVC.navigationController popToRootViewControllerAnimated:NO]; + XPRoomViewController * rooomVC = obj; + [rooomVC exitRoom]; + *stop = YES; + } + }]; + if(self.view.superview){ + [TTPopup dismiss]; + } + dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ + [XPRoomViewController openRoom:uid viewController:[XCCurrentVCStackManager shareManager].getCurrentVC]; + }); + } + } else if([message.name isEqualToString:kJSOpenRoomForGiftId]) { + NSLog(@"%@", message.body); + NSDictionary *bodyDict; + if ([message.body isKindOfClass:[NSDictionary class]]) { + bodyDict = message.body; + } else if ([message.body isKindOfClass:[NSString class]]) { + NSString *str = (NSString *)message.body; + bodyDict = [str toJSONObject]; + } + //房间页 传参:uid + NSString *uid = [NSString stringWithFormat:@"%@", bodyDict[@"uid"]]; + NSString *giftId = [NSString stringWithFormat:@"%@", bodyDict[@"giftId"]]; + if (uid.length) { + [[XCCurrentVCStackManager shareManager].getCurrentVC.navigationController.viewControllers enumerateObjectsUsingBlock:^(__kindof UIViewController * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) { + if ([obj isKindOfClass:[XPRoomViewController class]]) { + [[XCCurrentVCStackManager shareManager].getCurrentVC.navigationController popToRootViewControllerAnimated:NO]; + XPRoomViewController * rooomVC = obj; + [rooomVC exitRoom]; + *stop = YES; + } + }]; + dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ + [XPRoomViewController openRoom:uid giftId:giftId viewController:[XCCurrentVCStackManager shareManager].getCurrentVC]; + }); + } + }else if([message.name isEqualToString:kJSChargePayClickPage]){ + if(message.body != nil && self.model.diamonds != nil){ + NSString *type = [NSString stringWithFormat:@"%@",message.body]; + } + }else if ([message.name isEqualToString:kJSOpenChargePage]) { + if(self.delegate && [self.delegate respondsToSelector:@selector(payHandler)]){ + [self.delegate payHandler]; + return; + } + + + + [TTPopup dismiss]; + if(self.isPush){ + XPWebViewController * webVC =[[XPWebViewController alloc] init]; + webVC.url = [NSString stringWithFormat:URLWithType(kThirdPartyPay),@"4",[YYUtility deviceID]]; + webVC.isPush = YES; + [[XCCurrentVCStackManager shareManager].getCurrentVC.navigationController pushViewController:webVC animated:YES]; + return; + } + UIViewController *controller = [XCCurrentVCStackManager shareManager].getCurrentVC; + if (controller.presentingViewController) { + [controller dismissViewControllerAnimated:NO completion:nil]; + dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ + + XPWebViewController * webVC =[[XPWebViewController alloc] init]; + webVC.isPush = YES; + webVC.url = [NSString stringWithFormat:URLWithType(kThirdPartyPay),@"4",[YYUtility deviceID]]; + [[XCCurrentVCStackManager shareManager].getCurrentVC.navigationController pushViewController:webVC animated:YES]; + }); + }else { + XPWebViewController * webVC =[[XPWebViewController alloc] init]; + webVC.isPush = YES; + webVC.url = [NSString stringWithFormat:URLWithType(kThirdPartyPay),@"4",[YYUtility deviceID]]; + [[XCCurrentVCStackManager shareManager].getCurrentVC.navigationController pushViewController:webVC animated:YES]; + } + } else if ([message.name isEqualToString:kOpenPersonPage]) { + NSString *uid = [NSString stringWithFormat:@"%@",message.body]; + if (uid.integerValue > 0) { + [TTPopup dismiss]; + XPMineUserInfoViewController * userInfoVC = [[XPMineUserInfoViewController alloc] init]; + userInfoVC.uid = uid.integerValue; + [[XCCurrentVCStackManager shareManager].getCurrentVC.navigationController pushViewController:userInfoVC animated:YES]; + } + } else if([message.name isEqualToString:kJSInitNav]) { + [self initNav:message.body]; + } else if([message.name isEqualToString:kJSGetRoomUid]) { + NSString *js = [NSString stringWithFormat:@"getMessage(\"roomUid\",\"%@\")",self.roomUid]; + [self.webview evaluateJavaScript:js completionHandler:^(id _Nullable other, NSError * _Nullable error) { + NSLog(@"%@",error); + }]; + } else if([message.name isEqualToString:kInitShowNav]) { + if (((NSNumber *)message.body).intValue == 0) { + if (self.InitShowNavBlock) { + self.InitShowNavBlock(YES); + return; + } + if (self.navigationController) { + [self.navigationController setNavigationBarHidden:YES]; + } + } + } else if([message.name isEqualToString:kCloseWebView]) { + if (self.CloseWebViewBlock) { + self.CloseWebViewBlock(YES); + return; + } + if (self.navigationController) { + [self.navigationController popViewControllerAnimated:YES]; + } + } else if ([message.name isEqualToString:kJumpAppointPage]) { + // h5与原生交互新协议 + NSDictionary *bodyDict; + if ([message.body isKindOfClass:[NSDictionary class]]) { + bodyDict = message.body; + } else if ([message.body isKindOfClass:[NSString class]]) { + NSString *str = (NSString *)message.body; + bodyDict = [str toJSONObject]; + } + NSInteger skyType = [bodyDict[@"routerType"] integerValue]; + [self handleRouterType:skyType message:message]; + } else if ([message.name isEqualToString:kJSOpenRoom]) { + NSString *uid = [NSString stringWithFormat:@"%@",message.body]; + if (uid.length > 0) { + [[XCCurrentVCStackManager shareManager].getCurrentVC.navigationController.viewControllers enumerateObjectsUsingBlock:^(__kindof UIViewController * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) { + if ([obj isKindOfClass:[XPRoomViewController class]]) { + [[XCCurrentVCStackManager shareManager].getCurrentVC.navigationController popToRootViewControllerAnimated:NO]; + XPRoomViewController * rooomVC = obj; + [rooomVC exitRoom]; + *stop = YES; + } + }]; + if(self.view.superview){ + [TTPopup dismiss]; + } + dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ + [XPRoomViewController openRoom:uid viewController:[XCCurrentVCStackManager shareManager].getCurrentVC]; + }); + } + } else if([message.name isEqualToString:kJSOpenRoomForGiftId]) { + NSLog(@"%@", message.body); + NSDictionary *bodyDict; + if ([message.body isKindOfClass:[NSDictionary class]]) { + bodyDict = message.body; + } else if ([message.body isKindOfClass:[NSString class]]) { + NSString *str = (NSString *)message.body; + bodyDict = [str toJSONObject]; + } + //房间页 传参:uid + NSString *uid = [NSString stringWithFormat:@"%@", bodyDict[@"uid"]]; + NSString *giftId = [NSString stringWithFormat:@"%@", bodyDict[@"giftId"]]; + if (uid.length) { + [[XCCurrentVCStackManager shareManager].getCurrentVC.navigationController.viewControllers enumerateObjectsUsingBlock:^(__kindof UIViewController * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) { + if ([obj isKindOfClass:[XPRoomViewController class]]) { + [[XCCurrentVCStackManager shareManager].getCurrentVC.navigationController popToRootViewControllerAnimated:NO]; + XPRoomViewController * rooomVC = obj; + [rooomVC exitRoom]; + *stop = YES; + } + }]; + dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ + [XPRoomViewController openRoom:uid giftId:giftId viewController:[XCCurrentVCStackManager shareManager].getCurrentVC]; + }); + } + + } + } + }]; + } - } - } - }]; - } #pragma mark - private method - (void)handleRouterType:(NSInteger)skyType message:(WKScriptMessage *)message { - NSDictionary *bodyDict = (NSDictionary *)message.body; - switch (skyType) { - case 1: - { - //房间页 传参:uid - NSString *uid = [NSString stringWithFormat:@"%@", bodyDict[@"routerVal"]]; - if (uid.length) { - [XPRoomViewController openRoom:uid viewController:[XCCurrentVCStackManager shareManager].getCurrentVC]; - } - } - break; - case 7: - { - //座驾 - XPMineDressUpViewController *vc = [[XPMineDressUpViewController alloc] init]; - vc.currentIndex = 1; - [[XCCurrentVCStackManager shareManager].getCurrentVC.navigationController pushViewController:vc animated:YES]; - } - break; - case 8: - { - //头饰 - XPMineDressUpViewController *vc = [[XPMineDressUpViewController alloc] init]; - vc.currentIndex = 0; - [[XCCurrentVCStackManager shareManager].getCurrentVC.navigationController pushViewController:vc animated:YES]; - } - break; + NSDictionary *bodyDict = (NSDictionary *)message.body; + switch (skyType) { + case 1: + { + //房间页 传参:uid + NSString *uid = [NSString stringWithFormat:@"%@", bodyDict[@"routerVal"]]; + if (uid.length) { + [XPRoomViewController openRoom:uid viewController:[XCCurrentVCStackManager shareManager].getCurrentVC]; + } + } + break; + case 7: + { + //座驾 + XPMineDressUpViewController *vc = [[XPMineDressUpViewController alloc] init]; + vc.currentIndex = 1; + [[XCCurrentVCStackManager shareManager].getCurrentVC.navigationController pushViewController:vc animated:YES]; + } + break; + case 8: + { + //头饰 + XPMineDressUpViewController *vc = [[XPMineDressUpViewController alloc] init]; + vc.currentIndex = 0; + [[XCCurrentVCStackManager shareManager].getCurrentVC.navigationController pushViewController:vc animated:YES]; + } + break; case 75: {//跳转对应的话题 bodyDict = [bodyDict toJSONObject]; @@ -471,288 +599,288 @@ NSString * const kJSOpenAppConcernedChat = @"openAppConcernedChat"; [[XCCurrentVCStackManager shareManager].getCurrentVC.navigationController pushViewController:topicVC animated:YES]; } break; - default: - break; - } + default: + break; + } } - (void)setUrl:(NSString *)urlString{ - _url = urlString; - if (_url == nil) { - return; - } - if (![_url hasPrefix:@"http"] && ![_url hasPrefix:@"https"]){ - _url = [NSString stringWithFormat:@"%@/%@", API_HOST_URL, _url]; - } + _url = urlString; + if (_url == nil) { + return; + } + if (![_url hasPrefix:@"http"] && ![_url hasPrefix:@"https"]){ + _url = [NSString stringWithFormat:@"%@/%@", API_HOST_URL, _url]; + } - if (![_url containsString:@"?"]) { - _url = [NSString stringWithFormat:@"%@", _url]; - } else { - _url = [NSString stringWithFormat:@"%@", _url]; - } + if (![_url containsString:@"?"]) { + _url = [NSString stringWithFormat:@"%@", _url]; + } else { + _url = [NSString stringWithFormat:@"%@", _url]; + } - // 去掉 urlString 中的空格。 - NSString *noSpaceTextUrl = [_url stringByReplacingOccurrencesOfString:@" " withString:@""]; + // 去掉 urlString 中的空格。 + NSString *noSpaceTextUrl = [_url stringByReplacingOccurrencesOfString:@" " withString:@""]; - NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:noSpaceTextUrl]]; - [self.webview loadRequest:request]; + NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:noSpaceTextUrl]]; + [self.webview loadRequest:request]; } - (void)backButtonClick { - BOOL canGoBack = YES; - if (self.webview.backForwardList.backList.count <= 1) { - canGoBack = NO; - } + BOOL canGoBack = YES; + if (self.webview.backForwardList.backList.count <= 1) { + canGoBack = NO; + } - if ([self.webview canGoBack]) { - [self.webview goBack]; - } else { - [self.navigationController popViewControllerAnimated:YES]; - [self.pi_userContentController removeAllUserScripts]; - } + if ([self.webview canGoBack]) { + [self.webview goBack]; + } else { + [self.navigationController popViewControllerAnimated:YES]; + [self.pi_userContentController removeAllUserScripts]; + } } #pragma mark - 分享 - (void)initNav:(NSDictionary *)response{ - if(!response || ![response isKindOfClass:[NSDictionary class]])return; - self.shareDic = response[@"data"]; - if ([response[@"type"] intValue]== RightNavigationPushType_Web) { - [self addNavigationItemWithTitles:@[response[@"data"][@"title"]] titleColor:[DJDKMIMOMColor alertTitleColor] isLeft:NO target:self action:@selector(gotoWebView) tags:nil]; - }else if ([response[@"type"] intValue]== RightNavigationPushType_Share || [response[@"type"] intValue]== RightNavigationPushType_SharePicture){ - [self addNavigationItemWithImageNames:@[@"family_person_share"] isLeft:NO - target:self action:@selector(showSharePanel) tags:nil]; - } + if(!response || ![response isKindOfClass:[NSDictionary class]])return; + self.shareDic = response[@"data"]; + if ([response[@"type"] intValue]== RightNavigationPushType_Web) { + [self addNavigationItemWithTitles:@[response[@"data"][@"title"]] titleColor:[DJDKMIMOMColor alertTitleColor] isLeft:NO target:self action:@selector(gotoWebView) tags:nil]; + }else if ([response[@"type"] intValue]== RightNavigationPushType_Share || [response[@"type"] intValue]== RightNavigationPushType_SharePicture){ + [self addNavigationItemWithImageNames:@[@"family_person_share"] isLeft:NO + target:self action:@selector(showSharePanel) tags:nil]; + } } - (void)gotoWebView { - if (self.shareDic[@"link"]) { - XPWebViewController * webVC = [[XPWebViewController alloc] init]; - webVC.url = self.shareDic[@"link"]; - [self.navigationController pushViewController:webVC animated:YES]; - } + if (self.shareDic[@"link"]) { + XPWebViewController * webVC = [[XPWebViewController alloc] init]; + webVC.url = self.shareDic[@"link"]; + [self.navigationController pushViewController:webVC animated:YES]; + } } - (void)showSharePanel { - if (self.shareDic.allKeys.count <= 0) { - return; - } - NSDictionary * dic = self.shareDic; - XPShareInfoModel * shareInfo = [[XPShareInfoModel alloc] init]; - shareInfo.shareTitle = self.shareDic[@"title"]; - shareInfo.shareContent = dic[@"desc"]; - shareInfo.shareImageUrl = dic[@"imgUrl"]; - shareInfo.type = ShareType_H5; - shareInfo.uid = [AccountInfoStorage instance].getUid; - NSString *urlStr = ((NSString *)dic[@"url"]).length > 0 ? dic[@"url"] : dic[@"showUrl"]; - if (urlStr.length) { - if ([urlStr containsString:@"?"]) { - urlStr = [NSString stringWithFormat:@"%@&shareUid=%@",urlStr,[AccountInfoStorage instance].getUid]; - } else { - urlStr = [NSString stringWithFormat:@"%@?shareUid=%@",urlStr,[AccountInfoStorage instance].getUid]; - } - } - shareInfo.shareUrl = urlStr; - XPShareItem *cycle = [XPShareItem itemWitTag:XPShareItemTagFaceBook title:@"FaceBook" imageName:@"share_fb" disableImageName:@"share_fb"]; - XPShareItem *wechat = [XPShareItem itemWitTag:XPShareItemTagLine title:@"Line" imageName:@"share_line" disableImageName:@"share_line"]; - XPShareItem *qq = [XPShareItem itemWitTag:XPShareItemTagCopyLink title:YMLocalizedString(@"XPWebViewNavView1") imageName:@"share_copy_link" disableImageName:@"share_copy_link"]; - NSArray * items = @[wechat,cycle, qq]; - CGFloat margin = 15; - CGSize itemSize = CGSizeMake((KScreenWidth-2*margin)/4, 65); - XPShareView *shareView = [[XPShareView alloc] initWithItems:items itemSize:itemSize shareInfo:shareInfo]; - shareView.delegate = self; + if (self.shareDic.allKeys.count <= 0) { + return; + } + NSDictionary * dic = self.shareDic; + XPShareInfoModel * shareInfo = [[XPShareInfoModel alloc] init]; + shareInfo.shareTitle = self.shareDic[@"title"]; + shareInfo.shareContent = dic[@"desc"]; + shareInfo.shareImageUrl = dic[@"imgUrl"]; + shareInfo.type = ShareType_H5; + shareInfo.uid = [AccountInfoStorage instance].getUid; + NSString *urlStr = ((NSString *)dic[@"url"]).length > 0 ? dic[@"url"] : dic[@"showUrl"]; + if (urlStr.length) { + if ([urlStr containsString:@"?"]) { + urlStr = [NSString stringWithFormat:@"%@&shareUid=%@",urlStr,[AccountInfoStorage instance].getUid]; + } else { + urlStr = [NSString stringWithFormat:@"%@?shareUid=%@",urlStr,[AccountInfoStorage instance].getUid]; + } + } + shareInfo.shareUrl = urlStr; + XPShareItem *cycle = [XPShareItem itemWitTag:XPShareItemTagFaceBook title:@"FaceBook" imageName:@"share_fb" disableImageName:@"share_fb"]; + XPShareItem *wechat = [XPShareItem itemWitTag:XPShareItemTagLine title:@"Line" imageName:@"share_line" disableImageName:@"share_line"]; + XPShareItem *qq = [XPShareItem itemWitTag:XPShareItemTagCopyLink title:YMLocalizedString(@"XPWebViewNavView1") imageName:@"share_copy_link" disableImageName:@"share_copy_link"]; + NSArray * items = @[wechat,cycle, qq]; + CGFloat margin = 15; + CGSize itemSize = CGSizeMake((KScreenWidth-2*margin)/4, 65); + XPShareView *shareView = [[XPShareView alloc] initWithItems:items itemSize:itemSize shareInfo:shareInfo]; + shareView.delegate = self; - [TTPopup popupView:shareView style:TTPopupStyleActionSheet]; + [TTPopup popupView:shareView style:TTPopupStyleActionSheet]; } #pragma mark - XCShareViewDelegate - (void)shareViewDidClickCancle:(XPShareView *)shareView { - [TTPopup dismiss]; + [TTPopup dismiss]; } - (void)shareView:(XPShareView *)shareView didSuccess:(XPShareInfoModel *)shareInfo { - [TTPopup dismiss]; - NSMutableDictionary *params = [NSMutableDictionary dictionary]; - NSString *uid = [AccountInfoStorage instance].getUid; - NSString *ticket = [AccountInfoStorage instance].getTicket; - [params setObject:uid forKey:@"uid"]; - [params setObject:@(shareInfo.shareType) forKey:@"shareType"]; - [params setObject:ticket forKey:@"ticket"]; - [params setObject:@(shareInfo.type) forKey:@"sharePageId"]; - if (shareInfo.shareUrl.length > 0) { - [params setObject:shareInfo.shareUrl forKey:@"shareUrl"]; - } - if (shareInfo.roomUid > 0) { - [params setObject:@(shareInfo.roomUid) forKey:@"targetUid"]; - } + [TTPopup dismiss]; + NSMutableDictionary *params = [NSMutableDictionary dictionary]; + NSString *uid = [AccountInfoStorage instance].getUid; + NSString *ticket = [AccountInfoStorage instance].getTicket; + [params setObject:uid forKey:@"uid"]; + [params setObject:@(shareInfo.shareType) forKey:@"shareType"]; + [params setObject:ticket forKey:@"ticket"]; + [params setObject:@(shareInfo.type) forKey:@"sharePageId"]; + if (shareInfo.shareUrl.length > 0) { + [params setObject:shareInfo.shareUrl forKey:@"shareUrl"]; + } + if (shareInfo.roomUid > 0) { + [params setObject:@(shareInfo.roomUid) forKey:@"targetUid"]; + } - [HttpRequestHelper POST:@"usershare/save" params:params success:^(BaseModel * _Nonnull data) { + [HttpRequestHelper POST:@"usershare/save" params:params success:^(BaseModel * _Nonnull data) { - } failure:^(NSInteger resCode, NSString * _Nonnull message) { + } failure:^(NSInteger resCode, NSString * _Nonnull message) { - }]; + }]; } - (void)shareView:(XPShareView *)shareView shareFail:(NSString *)message { - [TTPopup dismiss]; - [self showErrorToast:message]; + [TTPopup dismiss]; + [self showErrorToast:message]; } - (void)shareViewDidClickCancel:(XPShareView *)shareView { - [TTPopup dismiss]; + [TTPopup dismiss]; } - (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context { - if ([keyPath isEqualToString:@"estimatedProgress"]) { - self.progressView.progress = self.webview.estimatedProgress; - if (self.progressView.progress == 1) { - __weak typeof (self)weakSelf = self; - [UIView animateWithDuration:0.25f delay:0.3f options:UIViewAnimationOptionCurveEaseOut animations:^{ - weakSelf.progressView.transform = CGAffineTransformMakeScale(1.0f, 1.0f); - } completion:^(BOOL finished) { - weakSelf.progressView.hidden = YES; - }]; - } - } else if ([keyPath isEqualToString:@"title"]) { - if (object == self.webview) { - self.navigationItem.title = self.webview.title; - if (self.urlLoadCompleted) {//半屏webview如果在加载完成回调后标题还会改变,在此处重新设置一遍 - self.urlLoadCompleted(YES, nil); - } - }else{ - [super observeValueForKeyPath:keyPath ofObject:object change:change context:context]; - } - } else { - [super observeValueForKeyPath:keyPath ofObject:object change:change context:context]; - } + if ([keyPath isEqualToString:@"estimatedProgress"]) { + self.progressView.progress = self.webview.estimatedProgress; + if (self.progressView.progress == 1) { + __weak typeof (self)weakSelf = self; + [UIView animateWithDuration:0.25f delay:0.3f options:UIViewAnimationOptionCurveEaseOut animations:^{ + weakSelf.progressView.transform = CGAffineTransformMakeScale(1.0f, 1.0f); + } completion:^(BOOL finished) { + weakSelf.progressView.hidden = YES; + }]; + } + } else if ([keyPath isEqualToString:@"title"]) { + if (object == self.webview) { + self.navigationItem.title = self.webview.title; + if (self.urlLoadCompleted) {//半屏webview如果在加载完成回调后标题还会改变,在此处重新设置一遍 + self.urlLoadCompleted(YES, nil); + } + }else{ + [super observeValueForKeyPath:keyPath ofObject:object change:change context:context]; + } + } else { + [super observeValueForKeyPath:keyPath ofObject:object change:change context:context]; + } } - (void)dealloc { - [self.webview removeObserver:self forKeyPath:@"estimatedProgress"]; - [self.webview removeObserver:self forKeyPath:@"title"]; + [self.webview removeObserver:self forKeyPath:@"estimatedProgress"]; + [self.webview removeObserver:self forKeyPath:@"title"]; } - (WKWebView *)webview { - if (_webview == nil) { - WKWebViewConfiguration *configuration = [[WKWebViewConfiguration alloc]init]; + if (_webview == nil) { + WKWebViewConfiguration *configuration = [[WKWebViewConfiguration alloc]init]; - if (@available(iOS 10.0, *)) { - configuration.mediaTypesRequiringUserActionForPlayback = NO; - } else { - // Fallback on earlier versions - } - configuration.allowsInlineMediaPlayback = YES; + if (@available(iOS 10.0, *)) { + configuration.mediaTypesRequiringUserActionForPlayback = NO; + } else { + // Fallback on earlier versions + } + configuration.allowsInlineMediaPlayback = YES; - NSString *uid = [[AccountInfoStorage instance] getUid]; - NSString *realCookie = [NSString stringWithFormat:@"%@=%@",@"uid",uid]; + NSString *uid = [[AccountInfoStorage instance] getUid]; + NSString *realCookie = [NSString stringWithFormat:@"%@=%@",@"uid",uid]; - WKUserScript *cookieScript = [[WKUserScript alloc] initWithSource: [NSString stringWithFormat:@"document.cookie = '%@';", realCookie] injectionTime:WKUserScriptInjectionTimeAtDocumentStart forMainFrameOnly:NO]; - [self.pi_userContentController addUserScript:cookieScript]; - ///禁止缩放 - NSString *scaleJs = @"$('meta[name=description]').remove(); $('head').append( '' );"; - WKUserScript *scaleScript = [[WKUserScript alloc] initWithSource:scaleJs injectionTime:WKUserScriptInjectionTimeAtDocumentEnd forMainFrameOnly:NO]; - [self.pi_userContentController addUserScript:scaleScript]; + WKUserScript *cookieScript = [[WKUserScript alloc] initWithSource: [NSString stringWithFormat:@"document.cookie = '%@';", realCookie] injectionTime:WKUserScriptInjectionTimeAtDocumentStart forMainFrameOnly:NO]; + [self.pi_userContentController addUserScript:cookieScript]; + ///禁止缩放 + NSString *scaleJs = @"$('meta[name=description]').remove(); $('head').append( '' );"; + WKUserScript *scaleScript = [[WKUserScript alloc] initWithSource:scaleJs injectionTime:WKUserScriptInjectionTimeAtDocumentEnd forMainFrameOnly:NO]; + [self.pi_userContentController addUserScript:scaleScript]; - //根据生成的WKUserScript对象,初始化WKWebViewConfiguration - configuration.preferences.javaScriptEnabled = YES; - configuration.preferences.javaScriptCanOpenWindowsAutomatically = YES; - configuration.preferences.minimumFontSize = 10; - configuration.selectionGranularity = WKSelectionGranularityCharacter; - configuration.userContentController = self.pi_userContentController; + //根据生成的WKUserScript对象,初始化WKWebViewConfiguration + configuration.preferences.javaScriptEnabled = YES; + configuration.preferences.javaScriptCanOpenWindowsAutomatically = YES; + configuration.preferences.minimumFontSize = 10; + configuration.selectionGranularity = WKSelectionGranularityCharacter; + configuration.userContentController = self.pi_userContentController; - CGSize size = [UIScreen mainScreen].bounds.size; - _webview = [[WKWebView alloc]initWithFrame:CGRectMake(0, 0, size.width,size.height) configuration:configuration]; + CGSize size = [UIScreen mainScreen].bounds.size; + _webview = [[WKWebView alloc]initWithFrame:CGRectMake(0, 0, size.width,size.height) configuration:configuration]; - _webview.navigationDelegate = self; - //添加KVO,WKWebView有一个属性estimatedProgress,就是当前网页加载的进度,所以监听这个属性 - [_webview addObserver:self forKeyPath:@"estimatedProgress" options:NSKeyValueObservingOptionNew context:nil]; - //添加KVO,监听title属性 - [_webview addObserver:self forKeyPath:@"title" options:NSKeyValueObservingOptionNew context:NULL]; + _webview.navigationDelegate = self; + //添加KVO,WKWebView有一个属性estimatedProgress,就是当前网页加载的进度,所以监听这个属性 + [_webview addObserver:self forKeyPath:@"estimatedProgress" options:NSKeyValueObservingOptionNew context:nil]; + //添加KVO,监听title属性 + [_webview addObserver:self forKeyPath:@"title" options:NSKeyValueObservingOptionNew context:NULL]; - UISwipeGestureRecognizer *swipeGesture = [[UISwipeGestureRecognizer alloc]initWithTarget:self action:@selector(backButtonClick)]; - [_webview addGestureRecognizer:swipeGesture]; + UISwipeGestureRecognizer *swipeGesture = [[UISwipeGestureRecognizer alloc]initWithTarget:self action:@selector(backButtonClick)]; + [_webview addGestureRecognizer:swipeGesture]; - [_webview.scrollView setShowsVerticalScrollIndicator:NO]; - [_webview.scrollView setShowsHorizontalScrollIndicator:NO]; + [_webview.scrollView setShowsVerticalScrollIndicator:NO]; + [_webview.scrollView setShowsHorizontalScrollIndicator:NO]; - //set useragent - __weak typeof(self) weakSelf = self; - [_webview evaluateJavaScript:@"navigator.userAgent" completionHandler:^(id result, NSError *error) { - NSString *userAgent = result; + //set useragent + __weak typeof(self) weakSelf = self; + [_webview evaluateJavaScript:@"navigator.userAgent" completionHandler:^(id result, NSError *error) { + NSString *userAgent = result; - if (![userAgent containsString:@"pekoAppIos erbanAppIos"]){ - NSString *newUserAgent = [userAgent stringByAppendingString:@" pekoAppIos erbanAppIos"]; - NSDictionary *dictionary = [NSDictionary dictionaryWithObjectsAndKeys:newUserAgent, @"UserAgent", nil]; - [[NSUserDefaults standardUserDefaults] registerDefaults:dictionary]; - [[NSUserDefaults standardUserDefaults] synchronize]; - [weakSelf.webview setCustomUserAgent:newUserAgent]; - } + if (![userAgent containsString:@"pekoAppIos erbanAppIos"]){ + NSString *newUserAgent = [userAgent stringByAppendingString:@" pekoAppIos erbanAppIos"]; + NSDictionary *dictionary = [NSDictionary dictionaryWithObjectsAndKeys:newUserAgent, @"UserAgent", nil]; + [[NSUserDefaults standardUserDefaults] registerDefaults:dictionary]; + [[NSUserDefaults standardUserDefaults] synchronize]; + [weakSelf.webview setCustomUserAgent:newUserAgent]; + } - }]; - _webview.scrollView.bounces = NO; - } - return _webview; + }]; + _webview.scrollView.bounces = NO; + } + return _webview; } - (UIProgressView *)progressView{ - if (!_progressView) { - _progressView = [[UIProgressView alloc] initWithFrame:CGRectMake(0, 0, [[UIScreen mainScreen] bounds].size.width, 1)]; - _progressView.progressTintColor = [DJDKMIMOMColor appMainColor]; - _progressView.trackTintColor = [UIColor clearColor]; - _progressView.transform = CGAffineTransformMakeScale(1.0f, 1.0f); - } - return _progressView; + if (!_progressView) { + _progressView = [[UIProgressView alloc] initWithFrame:CGRectMake(0, 0, [[UIScreen mainScreen] bounds].size.width, 1)]; + _progressView.progressTintColor = [DJDKMIMOMColor appMainColor]; + _progressView.trackTintColor = [UIColor clearColor]; + _progressView.transform = CGAffineTransformMakeScale(1.0f, 1.0f); + } + return _progressView; } - (WKUserContentController *)pi_userContentController{ - if (!_pi_userContentController) { - //自定义的WKScriptMessageHandler 是为了解决内存不释放的问题 - WeakWebViewScriptMessageDelegate *weakScriptMessageDelegate = [[WeakWebViewScriptMessageDelegate alloc] initWithDelegate:self]; - _pi_userContentController = [[WKUserContentController alloc] init]; - // 分享面板 - [_pi_userContentController addScriptMessageHandler:weakScriptMessageDelegate name:kJSOpenSharePage]; - // 钱包页面 - [_pi_userContentController addScriptMessageHandler:weakScriptMessageDelegate name:kJSOpenPurse]; - // 充值页面 - [_pi_userContentController addScriptMessageHandler:weakScriptMessageDelegate name:kJSOpenChargePage]; - [_pi_userContentController addScriptMessageHandler:weakScriptMessageDelegate name:kJSChargePayPage]; - [_pi_userContentController addScriptMessageHandler:weakScriptMessageDelegate name:kJSChargePayClickPage]; - // 获取uid - [_pi_userContentController addScriptMessageHandler:weakScriptMessageDelegate name:kJSGetUid]; - // 获取设备id - [_pi_userContentController addScriptMessageHandler:weakScriptMessageDelegate name:kJSGetDeviceId]; - // 获取Ticket - [_pi_userContentController addScriptMessageHandler:weakScriptMessageDelegate name:kJSGetTicket]; - // 获取设备info - [_pi_userContentController addScriptMessageHandler:weakScriptMessageDelegate name:kJSGetDeviceInfo]; - // 实人认证: 打开原生人脸认证 - [_pi_userContentController addScriptMessageHandler:weakScriptMessageDelegate name:kJSOpenFaceLiveness]; - // 分享按钮 - [_pi_userContentController addScriptMessageHandler:weakScriptMessageDelegate name:kJSInitNav]; - // 获取房间uid - [_pi_userContentController addScriptMessageHandler:weakScriptMessageDelegate name:kJSGetRoomUid]; - // 进入个人主页 - [_pi_userContentController addScriptMessageHandler:weakScriptMessageDelegate name:kOpenPersonPage]; - // 隐藏导航栏 - [_pi_userContentController addScriptMessageHandler:weakScriptMessageDelegate name:kInitShowNav]; - // 隐藏导航栏 - [_pi_userContentController addScriptMessageHandler:weakScriptMessageDelegate name:kCloseWebView]; - //装扮及其他活动页面 - [_pi_userContentController addScriptMessageHandler:weakScriptMessageDelegate name:kJumpAppointPage]; - //进入房间 - [_pi_userContentController addScriptMessageHandler:weakScriptMessageDelegate name:kJSOpenRoom]; - //进房并弹出礼物面板 - [_pi_userContentController addScriptMessageHandler:weakScriptMessageDelegate name:kJSOpenRoomForGiftId]; + if (!_pi_userContentController) { + //自定义的WKScriptMessageHandler 是为了解决内存不释放的问题 + WeakWebViewScriptMessageDelegate *weakScriptMessageDelegate = [[WeakWebViewScriptMessageDelegate alloc] initWithDelegate:self]; + _pi_userContentController = [[WKUserContentController alloc] init]; + // 分享面板 + [_pi_userContentController addScriptMessageHandler:weakScriptMessageDelegate name:kJSOpenSharePage]; + // 钱包页面 + [_pi_userContentController addScriptMessageHandler:weakScriptMessageDelegate name:kJSOpenPurse]; + // 充值页面 + [_pi_userContentController addScriptMessageHandler:weakScriptMessageDelegate name:kJSOpenChargePage]; + [_pi_userContentController addScriptMessageHandler:weakScriptMessageDelegate name:kJSChargePayPage]; + [_pi_userContentController addScriptMessageHandler:weakScriptMessageDelegate name:kJSChargePayClickPage]; + // 获取uid + [_pi_userContentController addScriptMessageHandler:weakScriptMessageDelegate name:kJSGetUid]; + // 获取设备id + [_pi_userContentController addScriptMessageHandler:weakScriptMessageDelegate name:kJSGetDeviceId]; + // 获取Ticket + [_pi_userContentController addScriptMessageHandler:weakScriptMessageDelegate name:kJSGetTicket]; + // 获取设备info + [_pi_userContentController addScriptMessageHandler:weakScriptMessageDelegate name:kJSGetDeviceInfo]; + // 实人认证: 打开原生人脸认证 + [_pi_userContentController addScriptMessageHandler:weakScriptMessageDelegate name:kJSOpenFaceLiveness]; + // 分享按钮 + [_pi_userContentController addScriptMessageHandler:weakScriptMessageDelegate name:kJSInitNav]; + // 获取房间uid + [_pi_userContentController addScriptMessageHandler:weakScriptMessageDelegate name:kJSGetRoomUid]; + // 进入个人主页 + [_pi_userContentController addScriptMessageHandler:weakScriptMessageDelegate name:kOpenPersonPage]; + // 隐藏导航栏 + [_pi_userContentController addScriptMessageHandler:weakScriptMessageDelegate name:kInitShowNav]; + // 隐藏导航栏 + [_pi_userContentController addScriptMessageHandler:weakScriptMessageDelegate name:kCloseWebView]; + //装扮及其他活动页面 + [_pi_userContentController addScriptMessageHandler:weakScriptMessageDelegate name:kJumpAppointPage]; + //进入房间 + [_pi_userContentController addScriptMessageHandler:weakScriptMessageDelegate name:kJSOpenRoom]; + //进房并弹出礼物面板 + [_pi_userContentController addScriptMessageHandler:weakScriptMessageDelegate name:kJSOpenRoomForGiftId]; ///进入聊天 [_pi_userContentController addScriptMessageHandler:weakScriptMessageDelegate name:kJSOpenChatPage]; ///进入聊天并关注 [_pi_userContentController addScriptMessageHandler:weakScriptMessageDelegate name:kJSOpenAppConcernedChat]; - } - return _pi_userContentController; + } + return _pi_userContentController; } -(XPWebViewNavView *)navView{ - if (!_navView){ - _navView = [[XPWebViewNavView alloc]initWithFrame:CGRectZero]; - _navView.delegate = self; - } - return _navView; + if (!_navView){ + _navView = [[XPWebViewNavView alloc]initWithFrame:CGRectZero]; + _navView.delegate = self; + } + return _navView; } @end