xuguohong

提交js对接资料

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>H5SDK测试</title>
<script type="text/javascript" src="game_Simulate.js"></script>
<script type="text/javascript" src="https://static.public.sdk.guangkatf.com/h5_sdk/guangkaH5SDK.js?" + new Date().getTime().toString()></script>
<script type="text/javascript">
</script>
</head>
<body>
<center>
<h1>H5SDK测试页面</h1>
</center>
<hr>
<center>
<table>
<tr>
<td>
<pre><button type="button" onclick="game.init()"> 初 始 化 </button></pre>
</td>
<td>
<pre><button type="button" onclick="game.submitInfo()">提交角色信息</button></pre>
</td>
</tr>
<tr>
<td>
<pre><button type="button" onclick="game.login()"> 登 录 </button></pre>
</td>
<td>
<pre><button type="button" onclick="game.logout()"> 注 销 </button></pre>
</td>
</tr>
<tr>
<td>
<pre><button type="button" onclick="game.pay()"> 支 付 </button></pre>
</td>
<td>
<pre><button type="button" onclick="game.switchAccount()"> 切换账号 </button></pre>
</td>
</tr>
<tr>
<td>
<pre><button type="button" onclick="game.statistics()"> 统 计 </button></pre>
</td>
<td>
<pre><button type="button" onclick="game.showExitDialog()"> 退出游戏 </button></pre>
</td>
</tr>
<tr>
<td>
<pre><button type="button" onclick="game.expansionInterface()"> 扩展接口 </button></pre>
</td>
</tr>
</table>
</center>
<hr>
</body>
</html>
\ No newline at end of file
//另一种在代码中引入JS文件的方式
// var newScript = document.createElement('script');
// newScript.setAttribute('type', 'text/javascript');
// newScript.setAttribute('src', 'Test2.js');
// document.getElementsByTagName('head')[0].appendChild(newScript);
document.write("<script type=\"text\/javascript\" src=\"youaiH5SDK.js\"><\/script>");
var game = {
/**
* code: {
INIT_SUCCESS: 1,
INIT_FAIL: -1,
LOGIN_SUCCESS: 10,
LOGIN_FAIL: -10,
LOGOUT_SUCCESS: 100,
LOGOUT_FAIL: -100,
SWITCH_SUCCESS: 1000,
SWITCH_FAIL: -1000,
PAY_SUCCESS: 2,//充值以服务端回调结果为准
PAY_FAIL: -2,
PAY_CANCEL:-3,//支付取消
EXIT_SUCCESS = 4,//退出成功
EXIT_CANCEL = -4//取消退出
}
* @param {*} code 为youaiH5SDK.code中对应值
* @param {*} msg
*/
callback: function (code, msg) {
console.log(code, msg);
switch (code) {
case youaiH5SDK.code.INIT_SUCCESS:
console.log("game init success")
break;
case youaiH5SDK.code.LOGIN_SUCCESS:
console.log("game login success")
console.log("openId:" + msg.openId + "custom:" + msg.custom + "serverSign:" + msg.serverSign + "timestamp:" + msg.timestamp);
break;
case youaiH5SDK.code.LOGOUT_SUCCESS:
console.log("game logout success")
break;
case youaiH5SDK.code.SWITCH_SUCCESS:
console.log("game switch account success")
break;
case youaiH5SDK.code.PAY_SUCCESS:
console.log("game pay success")
break;
case youaiH5SDK.code.EXIT_SUCCESS:
//游戏处理退出逻辑
break;
}
},
init: function () {
var SDKInfo = {
"gameSimpleName": "fytx_test",
"sdkSimpleName": "huoshu_h5",
"sdkClientVersion": "1.0",
"sdkVersionCode": "V1_0",
"statisticsUrl": "",
"channelParameter1": "yy",
"channelParameter2": "yy2"
};
var param = window.location.search.substring(1);
console.log(param);
var params = param.split("&");
console.log(params);
for (var i = 0; i < params.length; i++) {
console.log(params[i]);
var values = params[i].split("=");
console.log(values);
switch (values[0]) {
case "ya_game":
SDKInfo.gameSimpleName = values[1];
break;
case "ya_sn":
SDKInfo.sdkSimpleName = values[1];
break;
case "ya_ssv":
SDKInfo.sdkVersionCode = values[1];
break;
case "ya_sv":
SDKInfo.sdkClientVersion = values[1];
break;
default:
break;
}
}
youaiH5SDK.init(SDKInfo, this.callback);
},
login: function () {
var param = "test";
youaiH5SDK.login(param);
},
logout: function () {
if (youaiH5SDK.hasLogout()) {
youaiH5SDK.logout();
}
},
switchAccount: function () {
if (youaiH5SDK.hasSwitchAccount()) {
console.log("end switch account");
youaiH5SDK.switchAccount();
}
},
submitInfo: function () {
/**
* 为youaiH5SDK.type中对应类型值
type: {
arriveEntrance: 1,//首屏日志
arriveLoadingZero: 2,//刚开始加载资源类型
arriveLoadingFinish: 3,//资源加载完成
arriveCreateRolePage: 4,//到达创建角色页面
arriveServerSelectPage: 5,//到达选服页面
enterServer: 6,//选服完成,点击进入对应服时
arriveFirstScene: 7,//到达游戏内第一场景时调用
enterGame: 8,//进入游戏时调用
createRole: 9,//创建角色时调用
upRoleLevel: 10//角色升级日志
}
*/
var submitType = youaiH5SDK.type.enterGame;
var roleInfo = {
"roleID": "15",
"roleName": "test",
"roleLevel": "15",
"roleSex": "test",
"serverID": "15",
"serverName": "test",
"roleCTime": "15",
"partyName": "test",
"roleType": "test",
"roleChangeTime": "test",
"vipLevel": "15",
"diamond": "15",
"moneyType": "test",
"custom": "test"
};
youaiH5SDK.submitData(submitType, roleInfo);
},
pay: function () {
var payInfo = {
"serverId": "15",
"serverName": "test",
"playerId": "15",
"playerName": "test",
"playerLevel": "15",
"postAmount": "15",
"openId":"123643",
"productId": "15",
"productName": "test",
"productDesc": "test",
"custom": "test",
"exchange": "15",
"otherInfo": "15",
"timeStamp": "15"
};
youaiH5SDK.pay(payInfo);
},
showExitDialog: function () {
if (youaiH5SDK.hasShowExitDialog()) {
youaiH5SDK.showExitDialog();
} else {
//游戏自己处理退出逻辑
youaiH5SDK.exitGame();
}
},
statistics: function () {
var data = [{ "headers": { "product": "roh5" }, "body": "2018-03-14 17:57:21|test|5|qd|dqd|xqd|22222|20qd|10|1050055" }];
var statisticsListener = {
onStatisticsSuccess: function () {
alert("Statistic success!");
},
onStatisticsFail: function () {
alert("Statistic fail!");
}
};
youaiH5SDK.statistics(data, statisticsListener);
},
expansionInterface: function () {
/**
* 传公共sdk扩展类型
* {
gameSetting:100,//功能设置
downloadMicroClent:101,//下载微端
share:102,//分享
focus:103,//关注
save2Desktop:104,//保存到桌面
realVerify:105,//实名认证
back2Game:106,//返回游戏
bindPhone:107,//绑定手机有奖接口
}
*/
var expansion_type = youaiH5SDK.expansion_type.gameSetting;//功能设置
/**
* {
code:0,//0:成功 其他为失败
message:"success",//返回描述
data:{//除了gameSetting类型,其他功能暂时不返回data字段
has_micro_client:0,//是否有微端 0:没有,1:有,2已经在微端中
is_share:0,//是否有分享接口 0:没有,1:有
is_focus:0,//是否有关注 0:没,1:有,2:已经关注
is_apple_pay:0,//是否开启苹果支付 0:不开启 1:开启
is_desktop:0,//是否有保存桌面 0:没有 1:有
is_switch_account:0,//是否有切换账号 0:没有 1有
is_realverify:0,//是否有实名认证 0:没有 1:有 2:已认证
is_super_kefu:0,//是否有超级客服 0:没 1:有
is_backtogame:0,//是否有返回按钮 0:没有,1:有
is_lock:0,//是否竖屏 0:研发默认样式 1:强制竖屏
is_focus_gift:0,//关注有礼 0:关闭 1:开启
is_bindphone:0//绑定手机 0:关闭 1:开启 2:已绑定手机
}
}
* @param {*} result
*/
var expansionCallBack = function(result){
}
youaiH5SDK.expansionInterface(expansion_type,"",expansionCallBack);
}
};
\ No newline at end of file
http://gitlab.9133.com:10080/sdk_9133/sdk_public_android/edit/master/doc/%E5%85%AC%E5%85%B1SDK%E6%9C%8D%E5%8A%A1%E7%AB%AF%E6%8E%A5%E5%85%A5%E6%96%87%E6%A1%A3.md
\ No newline at end of file
This diff is collapsed. Click to expand it.