From b990f01a6e048c88c631a40ceed5768726deb595 Mon Sep 17 00:00:00 2001 From: liyuhua <15626451870@163.com> Date: Mon, 3 Jun 2024 18:59:43 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dbug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../View/RoomGame/Api/Api+MSRoomGameApi.h | 3 ++ .../View/RoomGame/Api/Api+MSRoomGameApi.m | 4 +++ .../YMRoom/View/RoomGame/View/MSRoomGameVC.m | 29 +++++++++++++++++-- .../View/SubView/MSTabbarBeginGameView.m | 2 +- .../YMTabbar/View/TabbarViewController.m | 4 +-- YuMi/ar.lproj/Localizable.strings | 1 + YuMi/en.lproj/Localizable.strings | 1 + YuMi/zh-Hans.lproj/Localizable.strings | 1 + YuMi/zh-Hant.lproj/Localizable.strings | 1 + 9 files changed, 40 insertions(+), 6 deletions(-) diff --git a/YuMi/Modules/YMRoom/View/RoomGame/Api/Api+MSRoomGameApi.h b/YuMi/Modules/YMRoom/View/RoomGame/Api/Api+MSRoomGameApi.h index d846c1d4..3b9275cc 100644 --- a/YuMi/Modules/YMRoom/View/RoomGame/Api/Api+MSRoomGameApi.h +++ b/YuMi/Modules/YMRoom/View/RoomGame/Api/Api+MSRoomGameApi.h @@ -18,6 +18,9 @@ NS_ASSUME_NONNULL_BEGIN +(void)getRoomGameDetails:(HttpRequestHelperCompletion)completion roomType:(NSString *)roomType; ///退出房间 +(void)closeRoomGame:(HttpRequestHelperCompletion)completion roomId:(NSString *)roomId; + +///首页得到房间详情 ++(void)getRoomGameDetailsForHoem:(HttpRequestHelperCompletion)completion; @end NS_ASSUME_NONNULL_END diff --git a/YuMi/Modules/YMRoom/View/RoomGame/Api/Api+MSRoomGameApi.m b/YuMi/Modules/YMRoom/View/RoomGame/Api/Api+MSRoomGameApi.m index e2097ad2..e49eebaa 100644 --- a/YuMi/Modules/YMRoom/View/RoomGame/Api/Api+MSRoomGameApi.m +++ b/YuMi/Modules/YMRoom/View/RoomGame/Api/Api+MSRoomGameApi.m @@ -20,6 +20,10 @@ +(void)getRoomGameDetails:(HttpRequestHelperCompletion)completion roomType:(NSString *)roomType{ [self makeRequest:@"chatRoom/getByType" method:HttpRequestHelperMethodGET completion:completion, __FUNCTION__,roomType,nil]; } +///首页得到房间详情 ++(void)getRoomGameDetailsForHoem:(HttpRequestHelperCompletion)completion { + [self makeRequest:@"miniGame/nav/resumeRoom" method:HttpRequestHelperMethodGET completion:completion, __FUNCTION__,nil]; +} ///退出房间 +(void)closeRoomGame:(HttpRequestHelperCompletion)completion roomId:(NSString *)roomId{ [self makeRequest:@"miniGame/nav/close" method:HttpRequestHelperMethodGET completion:completion, __FUNCTION__,roomId,nil]; diff --git a/YuMi/Modules/YMRoom/View/RoomGame/View/MSRoomGameVC.m b/YuMi/Modules/YMRoom/View/RoomGame/View/MSRoomGameVC.m index 5bfb98cd..d2c9db2b 100644 --- a/YuMi/Modules/YMRoom/View/RoomGame/View/MSRoomGameVC.m +++ b/YuMi/Modules/YMRoom/View/RoomGame/View/MSRoomGameVC.m @@ -50,7 +50,6 @@ [super viewDidLoad]; [self installUI]; [self installConstraints]; - [self.presenter getRoomGameDetailWithRoomType:@"0"]; [[NIMSDK sharedSDK].chatroomManager addDelegate:self]; [[NIMSDK sharedSDK].chatManager addDelegate:self]; [[NIMSDK sharedSDK].loginManager addDelegate:self]; @@ -159,7 +158,13 @@ self.headView.roomGameModel = model; self.headView.userInfo = self.userinfo; self.roomId = model.roomId; - [self.presenter enterNIMRoom:model.roomId user:self.userinfo]; + + + + [self enterNIMRoomWithRoomId:self.roomId]; + + + if(model.data.matchStatus == MSRoomGameInfoModelMatchSuccessfully && model.data.roundStatus == 0){ self.roomGameView.gameModel = model; if(self.roomGameView.superview == nil){ @@ -177,6 +182,24 @@ } } +-(void)enterNIMRoomWithRoomId:(NSString *)roomUid{ + NIMChatroomMemberRequest *request = [[NIMChatroomMemberRequest alloc]init]; + request. roomId = [NSString stringWithFormat:@"%@", self.roomId]; + request. type = NIMChatroomFetchMemberTypeRegular; + [[NIMSDK sharedSDK]. chatroomManager fetchChatroomMembers:request completion:^(NSError * _Nullable error, NSArray * _Nullable members) { + BOOL isEnterRoom = NO; + NSString *uid = [[AccountInfoStorage instance]getUid]; + for (NIMChatroomMember *obj in members) { + if([obj.userId isEqualToString:uid]){ + isEnterRoom = YES; + break; + } + } + if(isEnterRoom == NO){ + [self.presenter enterNIMRoom:roomUid user:self.userinfo]; + } + }]; +} #pragma mark -MSRoomGameVictoryViewDelegate - (void)closeGameAction{ self.isShowResults = NO; @@ -263,7 +286,7 @@ if(![self.roomId isEqualToString:model.roomId]){ [self.presenter exitNIMRoom:self.roomId]; self.roomId = model.roomId; - [self.presenter enterNIMRoom:model.roomId user:self.userinfo]; + [self enterNIMRoomWithRoomId:self.roomId]; } self.headView.roomGameModel = model; self.roomGameView.gameModel = model; diff --git a/YuMi/Modules/YMRoom/View/RoomGame/View/SubView/MSTabbarBeginGameView.m b/YuMi/Modules/YMRoom/View/RoomGame/View/SubView/MSTabbarBeginGameView.m index d8792958..09cf358a 100644 --- a/YuMi/Modules/YMRoom/View/RoomGame/View/SubView/MSTabbarBeginGameView.m +++ b/YuMi/Modules/YMRoom/View/RoomGame/View/SubView/MSTabbarBeginGameView.m @@ -96,7 +96,7 @@ - (void)setItemModel:(MSTabbarRoomGameItemModel *)itemModel{ _itemModel = itemModel; _coinNumView.text = _itemModel.ticket; - _titleView.text = _itemModel.modeName; + _titleView.text = [NSString stringWithFormat:YMLocalizedString(@"MSRoomGameHeadView4"),_itemModel.modeName]; } -(void)ruleBtnAction{ if(self.delegate && [self.delegate respondsToSelector:@selector(clickRuleActionWithModel:)]){ diff --git a/YuMi/Modules/YMTabbar/View/TabbarViewController.m b/YuMi/Modules/YMTabbar/View/TabbarViewController.m index be69228f..8be42fb1 100644 --- a/YuMi/Modules/YMTabbar/View/TabbarViewController.m +++ b/YuMi/Modules/YMTabbar/View/TabbarViewController.m @@ -254,7 +254,7 @@ UIKIT_EXTERN NSString *kTabShowAnchorCardKey; } } -(void)getRoomGameInfo{ - [Api getRoomGameDetails:^(BaseModel * _Nullable data, NSInteger code, NSString * _Nullable msg) { + [Api getRoomGameDetailsForHoem:^(BaseModel * _Nullable data, NSInteger code, NSString * _Nullable msg) { if(code == 200){ MSRoomGameModel *model = [MSRoomGameModel modelWithJSON:data.data]; if(model.data.matchStatus == 1 && model.data.roundStatus == 0){ @@ -268,7 +268,7 @@ UIKIT_EXTERN NSString *kTabShowAnchorCardKey; } } - } roomType:@"0"]; + }]; } #pragma mark -MSRoomGameQuitGameViewDelegate ///退出游戏 diff --git a/YuMi/ar.lproj/Localizable.strings b/YuMi/ar.lproj/Localizable.strings index 6f475ec0..79714ea9 100644 --- a/YuMi/ar.lproj/Localizable.strings +++ b/YuMi/ar.lproj/Localizable.strings @@ -3817,6 +3817,7 @@ ineHeadView12" = "الحمل"; "MSRoomGameHeadView1"="تمت المطابقة "; "MSRoomGameHeadView2"="الفوز بمكافأة %@ عملة ذهبية"; "MSRoomGameHeadView3"="%@ عملة ذهبية"; +"MSRoomGameHeadView4"="(%@)رسوم الدخول "; //MSRoomGameVC "MSRoomGameVC0"="فشلت المطابقة"; "MSRoomGameVC1"="المحفظة"; diff --git a/YuMi/en.lproj/Localizable.strings b/YuMi/en.lproj/Localizable.strings index 27b661a3..a797150c 100644 --- a/YuMi/en.lproj/Localizable.strings +++ b/YuMi/en.lproj/Localizable.strings @@ -3625,6 +3625,7 @@ "MSRoomGameHeadView1"="Match successful"; "MSRoomGameHeadView2"="Winning reward %@ gold coins"; "MSRoomGameHeadView3"="%@ gold coins"; +"MSRoomGameHeadView4"="Entry Fee(%@)"; //MSRoomGameVC "MSRoomGameVC0"="Match failed"; "MSRoomGameVC1"="Wallet"; diff --git a/YuMi/zh-Hans.lproj/Localizable.strings b/YuMi/zh-Hans.lproj/Localizable.strings index 03510b2e..f2dfcd25 100644 --- a/YuMi/zh-Hans.lproj/Localizable.strings +++ b/YuMi/zh-Hans.lproj/Localizable.strings @@ -3280,6 +3280,7 @@ "MSRoomGameHeadView1"="匹配成功"; "MSRoomGameHeadView2"="获胜奖励%@金币"; "MSRoomGameHeadView3"="%@金币"; +"MSRoomGameHeadView4"="入场费(%@)"; //MSRoomGameVC "MSRoomGameVC0"="匹配失败"; "MSRoomGameVC1"="钱包"; diff --git a/YuMi/zh-Hant.lproj/Localizable.strings b/YuMi/zh-Hant.lproj/Localizable.strings index e4d0a3bf..7b412672 100644 --- a/YuMi/zh-Hant.lproj/Localizable.strings +++ b/YuMi/zh-Hant.lproj/Localizable.strings @@ -3274,6 +3274,7 @@ "MSRoomGameHeadView1"="匹配成功"; "MSRoomGameHeadView2"="获胜奖励%@金币"; "MSRoomGameHeadView3"="%@金币"; +"MSRoomGameHeadView4"="入場費(%@)"; //MSRoomGameVC "MSRoomGameVC0"="匹配失败"; "MSRoomGameVC1"="钱包";