新增游戏
This commit is contained in:
@@ -6,6 +6,10 @@
|
||||
//
|
||||
|
||||
#import "MSRoomGameWebVC.h"
|
||||
#import "LittleGameInfoModel.h"
|
||||
#import "RoomInfoModel.h"
|
||||
#import "XPIAPRechargeViewController.h"
|
||||
|
||||
@interface MSWeakWebViewScriptMessageDelegate : NSObject<WKScriptMessageHandler>
|
||||
|
||||
//WKScriptMessageHandler 这个协议类专门用来处理JavaScript调用原生OC的方法
|
||||
@@ -46,11 +50,24 @@ NSString * const kMSGameLoaded = @"gameLoaded";
|
||||
@property (strong, nonatomic) WKWebView *webview;
|
||||
@property (strong, nonatomic) UIProgressView *progressView;
|
||||
@property (nonatomic, strong) WKUserContentController *ms_userContentController;
|
||||
@property (nonatomic,weak) id<RoomHostDelegate> hostDelegate;
|
||||
@property(nonatomic,strong) ActivityInfoModel *gameModel;
|
||||
@end
|
||||
|
||||
@implementation MSRoomGameWebVC
|
||||
|
||||
|
||||
- (instancetype)initWithDelegate:(id<RoomHostDelegate>)delegate gameModel:(ActivityInfoModel *)gameModel
|
||||
{
|
||||
self = [super init];
|
||||
if (self) {
|
||||
self.hostDelegate = delegate;
|
||||
self.gameModel = gameModel;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
- (BOOL)isHiddenNavBar {
|
||||
return YES;
|
||||
}
|
||||
- (void)viewDidLoad {
|
||||
[super viewDidLoad];
|
||||
[self installUI];
|
||||
@@ -80,11 +97,7 @@ NSString * const kMSGameLoaded = @"gameLoaded";
|
||||
//获取当前屏幕的宽⾼
|
||||
int ScreenHeight = [[UIScreen mainScreen] bounds].size.height;
|
||||
int ScreenWidth = [[UIScreen mainScreen] bounds].size.width;
|
||||
//获取状态栏的⾼度
|
||||
CGRect statusBarRect = [[UIApplication sharedApplication]
|
||||
statusBarFrame];
|
||||
int statusBarHeight = statusBarRect.size.height;
|
||||
|
||||
|
||||
self.webview = [[WKWebView alloc] initWithFrame:CGRectMake(0,0,
|
||||
ScreenWidth, ScreenHeight) configuration:config];
|
||||
[self.webview.scrollView setBackgroundColor:[UIColor clearColor]];
|
||||
@@ -98,6 +111,11 @@ NSString * const kMSGameLoaded = @"gameLoaded";
|
||||
UIScrollViewContentInsetAdjustmentNever;
|
||||
}
|
||||
[self.view addSubview:self.webview];
|
||||
|
||||
NSString *h5Url = self.gameModel.skipContent;
|
||||
NSURL *url = [NSURL URLWithString:h5Url];
|
||||
NSURLRequest *request = [[NSURLRequest alloc] initWithURL:url];
|
||||
[self.webview loadRequest:request];
|
||||
}
|
||||
|
||||
- (void)webView:(WKWebView *)webView didReceiveAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge completionHandler:(void (^)(NSURLSessionAuthChallengeDisposition, NSURLCredential * _Nullable))completionHandler{
|
||||
@@ -106,8 +124,6 @@ NSString * const kMSGameLoaded = @"gameLoaded";
|
||||
NSURLCredential *card = [[NSURLCredential alloc]initWithTrust:challenge.protectionSpace.serverTrust];
|
||||
completionHandler(NSURLSessionAuthChallengeUseCredential,card);
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -171,32 +187,58 @@ NSString * const kMSGameLoaded = @"gameLoaded";
|
||||
// 获取信息配置
|
||||
- (void) getConfig:(NSDictionary*)args
|
||||
{
|
||||
|
||||
|
||||
NSLog(@"BSGAME %s","游戏调⽤getConfig");
|
||||
NSString* method = [args objectForKey:@"jsCallback"];
|
||||
RoomInfoModel *roomInfo = self.hostDelegate.getRoomInfo;
|
||||
ActivityInfoItemModel *gameModel = self.gameModel.gameModel;
|
||||
NSString *appChannel = gameModel.appChannel ?: @"";
|
||||
int64_t appId = gameModel.appId;
|
||||
NSString *userId = [AccountInfoStorage instance].getUid;
|
||||
NSString *code = gameModel.code ?: @"";
|
||||
NSString *roomId = [NSString stringWithFormat:@"%ld",roomInfo.uid];
|
||||
NSString *gameMode = gameModel.gameMode ?: @"";
|
||||
NSString *language = gameModel.language ?: @"";
|
||||
NSDictionary *gameConfig = gameModel.gameConfig ?: @{};
|
||||
int gsp = gameModel.gsp;
|
||||
// 数据只是参考值,需要根据⾃⼰APP进⾏赋值
|
||||
NSObject* configData = @{
|
||||
@"appChannel":@"mesh",
|
||||
@"appId":@88888888,
|
||||
@"userId":@"534206265",
|
||||
|
||||
@"code":@"j10NQCb16b6E1oCnAx4o3hHdEaDzm6RLZjyyyEcn34tiJcPXNbkZh5g8Q6Zd",
|
||||
@"roomId":@"20230901",
|
||||
@"gameMode":@"3",
|
||||
@"language":@"2",
|
||||
@"gameConfig":@{
|
||||
@"sceneMode":@0,
|
||||
@"currencyIcon":@"https://bsyx-store.s3.ap-southeast-.amazonaws.com/game-icons/20230906-163004.png",
|
||||
},
|
||||
@"gsp":@101,
|
||||
@"appChannel":appChannel,
|
||||
@"appId":@(appId),
|
||||
@"userId":userId,
|
||||
@"code":code,
|
||||
@"roomId":roomId,
|
||||
@"gameMode":gameMode,
|
||||
@"language":[self getlanguage],
|
||||
@"gameConfig":gameConfig,
|
||||
@"gsp":@(gsp),
|
||||
};
|
||||
[self callJs:method withJavaScriptValue:configData];
|
||||
}
|
||||
|
||||
-(NSString *)getlanguage{
|
||||
NSString *language = [NSBundle getLanguageText];
|
||||
if ([language hasPrefix:@"zh"]) {
|
||||
if ([language rangeOfString:@"Hans"].location != NSNotFound) {
|
||||
language = @"0"; // 简体中文
|
||||
} else {
|
||||
language = @"1"; // 繁體中文
|
||||
}
|
||||
}else if([language hasPrefix:@"ar"]){///阿拉伯语
|
||||
language = @"7";
|
||||
}else{///英文
|
||||
language = @"2";
|
||||
}
|
||||
return language;
|
||||
}
|
||||
// 销毁游戏
|
||||
- (void) destroy:(NSDictionary*)args
|
||||
{
|
||||
NSLog(@"BSGAME %s","游戏调⽤destroy");
|
||||
//关闭游戏 TODO 客⼾端
|
||||
[self willMoveToParentViewController:nil]; //1
|
||||
[self.view removeFromSuperview]; //2
|
||||
[self removeFromParentViewController]; //3
|
||||
}
|
||||
|
||||
// 提⽰余额不⾜
|
||||
@@ -204,6 +246,16 @@ NSString * const kMSGameLoaded = @"gameLoaded";
|
||||
{
|
||||
NSLog(@"BSGAME %s","游戏调⽤gameRecharge");
|
||||
//拉起充值商城 TODO 客⼾端
|
||||
TTAlertConfig *config = [[TTAlertConfig alloc]init];
|
||||
config.message = YMLocalizedString(@"XPNobleCenterViewController3");
|
||||
config.actionStyle = TTAlertActionBothStyle;
|
||||
[TTPopup alertWithConfig:config showBorder:NO confirmHandler:^{
|
||||
XPIAPRechargeViewController * webVC =[[XPIAPRechargeViewController alloc] init];
|
||||
webVC.type = @"4";
|
||||
[self.navigationController pushViewController:webVC animated:YES];
|
||||
} cancelHandler:^{
|
||||
|
||||
}];
|
||||
}
|
||||
|
||||
// 游戏加载完毕
|
||||
|
Reference in New Issue
Block a user