213 lines
9.1 KiB
JavaScript
213 lines
9.1 KiB
JavaScript
var TuyooSdkBridge = {
|
|
|
|
loadJsScriptToBridge: function (channelType) {
|
|
var channelTypeFromCS = UTF8ToString(channelType);
|
|
console.log("channelTypeFromCS:" + channelTypeFromCS);
|
|
},
|
|
|
|
InitToBridge: function (initEventInfo) {
|
|
try {
|
|
var initCallback = function (code, result, error) {
|
|
var callbackString = JSON.stringify({ code, result, error });
|
|
SendMessage("NativeCallBack", "InitResult", callbackString);
|
|
}
|
|
var initInfoFromCS = UTF8ToString(initEventInfo);
|
|
var initInfo = JSON.parse(initInfoFromCS);
|
|
var tyInitParams = {};
|
|
tyInitParams.appId = initInfo.tuyooParam.appId;
|
|
tyInitParams.gameId = initInfo.tuyooParam.gameId;
|
|
tyInitParams.pay_version = "hall37";
|
|
tyInitParams.baseurl = initInfo.tuyooParam.serverUrl.endsWith("/") ? initInfo.tuyooParam.serverUrl : initInfo.tuyooParam.serverUrl + "/";
|
|
tyInitParams.bi_base_url = "https://cbi.tuyoo.com/";
|
|
tyInitParams.cloudId = initInfo.tuyooParam.cloudId;
|
|
tyInitParams.packageName = initInfo.package;
|
|
tyInitParams.clientId = initInfo.tuyooParam.clientId;
|
|
tyInitParams.oppo_appId = initInfo.login.oppominigame.oppoAppId;
|
|
console.log("initInfo: " + JSON.stringify(initInfo));
|
|
if (initInfo.login.oppominigame.packageType === "wasmsplit" && GameGlobal.tywx) {
|
|
GameGlobal.tywx.StateInfo.debugMode = initInfo.debug.toLowerCase() === "true";
|
|
GameGlobal.tywx.SystemInfo.loginUrl = initInfo.tuyooParam.serverUrl.endsWith("/") ? initInfo.tuyooParam.serverUrl : initInfo.tuyooParam.serverUrl + "/";
|
|
GameGlobal.tywx.SystemInfo.clientId = initInfo.tuyooParam.clientId;
|
|
GameGlobal.tywx.SystemInfo.cloudId = initInfo.tuyooParam.cloudId;
|
|
GameGlobal.tywx.SystemInfo.appId = initInfo.tuyooParam.appId;
|
|
GameGlobal.tywx.SystemInfo.gameId = initInfo.tuyooParam.gameId;
|
|
GameGlobal.tywx.SystemInfo.wxAppId = initInfo.login.tywx.wx_appId;
|
|
GameGlobal.tywx.SystemInfo.packageName = initInfo.package;
|
|
}
|
|
GameGlobal.TuyooSdk.OnInit(initInfo.tuyooParam.channelType, tyInitParams, initCallback, this);
|
|
} catch (e) {
|
|
console.error("InitToBridge catch error: " + e);
|
|
}
|
|
},
|
|
|
|
// 切换SDK域名
|
|
UpdateServerUrlToBridge: function (serverUrl) {
|
|
try {
|
|
var serverUrlFromCS = UTF8ToString(serverUrl);
|
|
window.TuyooSdk.baseuri = (serverUrlFromCS.substring(serverUrlFromCS.length - 1) === '/') ? serverUrlFromCS.substring(0, serverUrlFromCS.length - 1) : serverUrlFromCS;
|
|
console.log("update serverUrl to: " + window.TuyooSdk.baseuri);
|
|
} catch (e) {
|
|
console.error("UpdateServerUrlToBridge catch error: " + e);
|
|
}
|
|
},
|
|
|
|
LoginToBridge: function (loginEventInfo) {
|
|
try {
|
|
var loginCallback = function (code, result, error) {
|
|
var callbackResult = {
|
|
code: code,
|
|
result: result && result.logindata ? result.logindata : result,
|
|
error: error
|
|
};
|
|
var callbackString = JSON.stringify(callbackResult);
|
|
SendMessage("NativeCallBack", "LoginResult", callbackString);
|
|
}
|
|
var loginInfoFromCS = UTF8ToString(loginEventInfo);
|
|
var loginInfo = JSON.parse(loginInfoFromCS);
|
|
if (loginInfo.loginType === "wx.cn.minigame" && GameGlobal.tywx) {
|
|
GameGlobal.tywx.TuyooSDK.login(loginCallback);
|
|
return;
|
|
}
|
|
var tyLoginParams = {};
|
|
if (loginInfo.loginType) {
|
|
tyLoginParams.ChannelType = loginInfo.loginType;
|
|
}
|
|
if (loginInfo.extraParams) {
|
|
var extraParams = JSON.parse(loginInfo.extraParams);
|
|
tyLoginParams.extraParams = extraParams;
|
|
}
|
|
console.log("tyLoginParams: " + JSON.stringify(tyLoginParams));
|
|
GameGlobal.TuyooSdk.Login(tyLoginParams, loginCallback, this);
|
|
} catch (e) {
|
|
console.error("LoginToBridge catch error: " + e);
|
|
}
|
|
},
|
|
|
|
PayToBridge: function (payEventInfo) {
|
|
try {
|
|
var payCallback = function (code, result, error) {
|
|
var callbackString = JSON.stringify({ code, result, error });
|
|
SendMessage("NativeCallBack", "PayResult", callbackString);
|
|
}
|
|
var payInfoFromCS = UTF8ToString(payEventInfo);
|
|
var payInfo = JSON.parse(payInfoFromCS);
|
|
var tyPayParams = {};
|
|
tyPayParams.prodCount = 1;
|
|
tyPayParams.appInfo = "";
|
|
if (payInfo.chargeService) {
|
|
tyPayParams.ChargeType = payInfo.chargeService;
|
|
}
|
|
if (payInfo.productCount) {
|
|
tyPayParams.prodCount = payInfo.productCount;
|
|
}
|
|
if (payInfo.serverAppInfo) {
|
|
tyPayParams.appInfo = payInfo.serverAppInfo;
|
|
}
|
|
if (payInfo.gameOrderId) {
|
|
tyPayParams.prodOrderId = payInfo.gameOrderId;
|
|
}
|
|
if (payInfo.extraParams) {
|
|
var extraParams = JSON.parse(payInfo.extraParams);
|
|
tyPayParams.extraParams = extraParams;
|
|
}
|
|
tyPayParams.prodId = payInfo.productId;
|
|
tyPayParams.prodName = payInfo.productName;
|
|
tyPayParams.prodPrice = payInfo.productPrice;
|
|
console.log("tyPayParams: " + JSON.stringify(tyPayParams));
|
|
GameGlobal.TuyooSdk.Pay(tyPayParams, payCallback, this);
|
|
} catch (e) {
|
|
console.error("PayToBridge catch error: " + e);
|
|
}
|
|
},
|
|
|
|
SetShareInfoToBridge: function (shareEventInfo) {
|
|
console.error("current channel not support SetShareInfo function");
|
|
},
|
|
|
|
ShareToBridge: function (shareEventInfo) {
|
|
console.error("current channel not support Share function");
|
|
},
|
|
|
|
GAEventTrackToBridge: function (reportEventInfo) {
|
|
try {
|
|
var reportInfoFromCS = UTF8ToString(reportEventInfo);
|
|
var reportInfo = JSON.parse(reportInfoFromCS);
|
|
if (!reportInfo.typeName) {
|
|
reportInfo.typeName = "track";
|
|
}
|
|
GameGlobal.TuyooSdk.bi.trackWithType(reportInfo.typeName, reportInfo.eventName, reportInfo.reportEvent);
|
|
} catch (e) {
|
|
console.error("GAEventTrackToBridge catch error: " + e);
|
|
}
|
|
},
|
|
|
|
GAProfileTrackToBridge: function (reportEventInfo) {
|
|
try {
|
|
var reportInfoFromCS = UTF8ToString(reportEventInfo);
|
|
var reportInfo = JSON.parse(reportInfoFromCS);
|
|
GameGlobal.TuyooSdk.bi.profileTrack(reportInfo.profileType, reportInfo.profileSubjectType, reportInfo.profileSubjectPrimary, reportInfo.reportEvent);
|
|
} catch (e) {
|
|
console.error("GAProfileTrackToBridge catch error: " + e);
|
|
}
|
|
},
|
|
|
|
GetShareInfoBridge: function (shareEventInfo) {
|
|
console.error("current channel not support GetShareInfo function");
|
|
},
|
|
|
|
GetAdInfoBridge: function () {
|
|
console.error("current channel not support GetAdInfo function");
|
|
},
|
|
|
|
TxAdSDKReportToBridge: function (txAdReportInfo) {
|
|
console.error("current channel not support TxAdSDKReport function");
|
|
},
|
|
|
|
CheckBindToBridge: function (bindEventInfo) {
|
|
console.error("current channel not support CheckBind function");
|
|
},
|
|
|
|
SendSmsCodeToBridge: function (loginEventInfo) {
|
|
console.error("current channel not support SendSmsCode function");
|
|
},
|
|
|
|
BindToBridge: function (bindEventInfo) {
|
|
console.error("current channel not support Bind function");
|
|
},
|
|
|
|
SetWxUserInfoToBridge: function (type, userInfo) {
|
|
console.error("current channel not support SetWxUserInfo function");
|
|
},
|
|
|
|
GetDeviceLevelToBridge: function() {
|
|
// try {
|
|
// var callback = function (code, result, error) {
|
|
// var callbackString = JSON.stringify({ code, result, error });
|
|
// SendMessage("NativeCallBack", "GetDeviceLevelResult", callbackString);
|
|
// }
|
|
// GameGlobal.TuyooSdk.getDeviceBenchmarkLevel(callback, this);
|
|
// } catch (error) {
|
|
// console.error("GetDeviceLevelToBridge catch error: " + error);
|
|
// }
|
|
console.error("current channel not support GetDeviceLevelToBridge function");
|
|
},
|
|
|
|
CreatGridGamePanelToBridge: function(gridGameModule) {
|
|
console.error("current channel not support CreatGridGamePanel function");
|
|
},
|
|
|
|
ShowGridGamePanelToBridge: function(panelId) {
|
|
console.error("current channel not support ShowGridGamePanel function");
|
|
},
|
|
|
|
HideGridGamePanelToBridge: function(panelId) {
|
|
console.error("current channel not support HideGridGamePanel function");
|
|
},
|
|
|
|
DestroyGridGamePanelToBridge: function(panelId) {
|
|
console.error("current channel not support DestroyGridGamePanel function");
|
|
}
|
|
|
|
}
|
|
|
|
mergeInto(LibraryManager.library, TuyooSdkBridge); |