@edoc/native
v0.0.10
Published
> TODO: description
Downloads
7
Readme
[TOC]
总体说明
sdk 接入方式
<script src="https://render.yuema.cn/game-sdk/v1.0.0/sdk.js"></script>
demo
通用解释:
如需页面初始化执行的逻辑必须放在 ready 函数回调中 如需使用 app 端提供回调,使用
on('nativeCallback', () => {})
的方式 key 联系对接人员获取 如果是测试服 请添加参数dev: true
房间 id (数字 、字母或者下划线的组合,最多 6 位, 自行编写)
H5 调用本地 SDK 方法名:trigger()
let sdk = new SDK({ key: "ssss", dev: true });
sdk.on("ready", () => {
sdk.trigger("up_micro", {}).then((res) => {
console.log("trigger_up_micro");
});
});
sdk.trigger("up_micro", {}).then((res) => {
console.log("trigger_up_micro");
});
获取 app 回调数据方式: nativeCallback
let sdk = new SDK({ key: "ssss" });
sdk.on("nativeCallback", (params) => {
console.log(params);
});
h5 调用 app 方法
示例在 【总体说明】内
传输的数据结构
{
type:""
params:{}
}
| 参数名 | 类型 | 说明 | | ------ | ------ | ------------------------------------------------------------------------ | | type | string | 交互类型,以此字段判断具体行为和相关的 params 数据类型,具体类型定义参考 | | params | json | 此次方法调用传递的数据,数据类型根据 type 类型去定义 |
进入充值页面
| 参数名 | 类型 | 说明 | | ------ | ------ | --------------------- | | type | string | 类型: recharge_remain |
params 数据类型
{
"type": "recharge_remain"
}
进入聊天室
| 参数名 | 类型 | 说明 | | ------ | ------ | ------------------------------------------------ | | type | string | 类型: enter_room | | params | | | | roomId | string | 房间 id (数字 、字母或者下划线的组合,最多 6 位) |
params 数据类型
{
"type":"enter_room",
"params":{
"roomId":"12121212",
}
}
离开聊天室
| 参数名 | 类型 | 说明 | | ------ | ------ | --------------- | | type | string | 类型: exit_room | | params | | | | roomId | string | 房间 id |
params 数据类型
{
"type": "exit_room",
"params": {
"roomId": "12121212"
}
}
上麦
| 参数名 | 类型 | 说明 | | ------ | ------ | -------------- | | type | string | 类型: up_micro |
params 数据类型
{
"type": "up_micro"
}
下麦
| 参数名 | 类型 | 说明 | | ------ | ------ | ---------------- | | type | string | 类型: down_micro |
params 数据类型
{
"type": "down_micro"
}
开麦
| 参数名 | 类型 | 说明 | | ------ | ------ | ---------------- | | type | string | 类型: open_micro |
params 数据类型
{
"type": "open_micro"
}
闭麦
| 参数名 | 类型 | 说明 | | ------ | ------ | ----------------- | | type | string | 类型: close_micro |
params 数据类型
{
"type": "close_micro"
}
分享
params.link 暂不可用
| 参数名 | 类型 | 说明 | | ------------ | ------ | -------------------------------------------- | | type | string | 类型: page_share | | params | | | | shareType | int | 每次分享内容的活动类型:见下方 | | shareChannel | int | 分享方式: 1:所有分享方式 2:朋友圈 3:微信好友 | | title | string | 分享标题 | | content | string | 分享内容 | | image | string | 分享内容的图片链接 | | link | string | 页面链接 | | isShow | int | 是否原生显示分享 0 不显示 1 显示 |
| 分享类型 | 说明 | | -------- | -------------------------------------------------------- | | 5 | 普通分享(不需要上报分享) | | 6 | 歪歌分享 | | 7 | 国庆活动分享 | | 8 | 微信分享 同时需要传递 title,content,link,image 字段 | | 9 | 朋友圈分享 同时需要传递 title,content,link,image 字段 | | 10 | 春节活动分享 同时需要传递 title,content,link,image 字段 |
params 数据类型
{
"type":"page_share",
"params":{
"shareType":1,
}
}
调用收银台
| 参数名 | 类型 | 说明 |
| ---------- | ------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| type | string | 类型: invoke_third_pay |
| params | | |
| trade_info | json | 格式参考{"pay_fee":"10","third_trade_no":"BY2028610X14899","order_desc":"捕鱼消费充值"}
,pay_fee(支付金额),third_trade_no(第三方业务编号),order_desc(第三方业务描述) |
params 数据类型
{
"type":"invoke_third_pay",
"params":{
"trade_info":{
}
}
}
开启全屏
| 参数名 | 类型 | 说明 | | ------ | ------ | ----------------------- | | type | string | 类型: enter_full_screen |
params 数据类型
{
"type": "enter_full_screen"
}
退出全屏
| 参数名 | 类型 | 说明 | | ------ | ------ | ---------------------- | | type | string | 类型: quit_full_screen |
params 数据类型
{
"type": "quit_full_screen"
}
开启竖屏
| 参数名 | 类型 | 说明 | | ------ | ------ | -------------------------------------- | | type | string | 类型: game_screen_orientation_portrait |
params 数据类型
{
"type": "game_screen_orientation_portrait"
}
开启横屏
| 参数名 | 类型 | 说明 | | ------ | ------ | --------------------------------------- | | type | string | 类型: game_screen_orientation_landscape |
params 数据类型 注: 开启横屏方法必须第一优先级调用,否则其他再此之前的方法调用会失效, 例如:显示悬浮球,和全屏显示,必须在横屏方法后调用,否则会失效
{
"type": "game_screen_orientation_landscape"
}
显示悬浮球
| 参数名 | 类型 | 说明 | | ------ | ------ | --------------------- | | type | string | 类型: show_float_ball |
params 数据类型
{
"type": "show_float_ball"
}
隐藏悬浮球
| 参数名 | 类型 | 说明 | | ------ | ------ | --------------------- | | type | string | 类型: hide_float_ball |
params 数据类型
{
"type": "hide_float_ball"
}
邀请消息
| 参数名 | 类型 | 说明 | | ------ | ------ | ------------------------- | | type | string | 类型: user_invite_message | | params | | | | url | string | 跳转 h5 页面地址 |
params 数据类型
{
"type":"user_invite_message",
"params":{
}
}
进入 im 聊天
| 参数名 | 类型 | 说明 | | ---------- | ------ | ------------------- | | type | string | 类型: enter_im_chat | | params | | | | userImId | string | 用户 im id | | userAvatar | string | 用户头像 | | userName | string | 用户昵称 |
params 数据类型
{
"type":"enter_im_chat",
"params":{
}
}
用户个人主页
| 参数名 | 类型 | 说明 | | ------ | ------ | -------------------- | | type | string | 类型: user_main_page | | params | | | | userId | string | 用户 id |
params 数据类型
{
"type":"user_main_page",
"params":{
}
}
关闭当前页面
| 参数名 | 类型 | 说明 | | ------ | ------ | ---------------- | | type | string | 类型: close_page |
params 数据类型
{
"type": "close_page"
}
app 回调 h5
示例在 【总体说明】内
传输的数据结构
{
type:""
params:{}
}
| 参数名 | 类型 | 说明 | | ------ | ------ | ------------------------------------------------------------------------ | | type | string | 交互类型,以此字段判断具体行为和相关的 params 数据类型,具体类型定义参考 | | params | json | 此次方法调用传递的数据,数据类型根据 type 类型去定义 |
收银台支付结果通知
| 参数名 | 类型 | 说明 | | -------------- | ------ | ------------------------------------------------------------------------------- | | type | string | 类型:third_pay_result | | params | | | | path | string | 音频地址 | | duration | int | 音频时长 | | _id | string | 账单数据 ID | | uid | string | 账单的用户 ID | | appid | string | 发起业务的应用 ID | | pay_fee | int | 账单金额,单位:分 | | pay_way | string | 支付方式, balance 余额 wechat 微信 alipay 支付宝 | | status | int | 账单状态, 0 等待用户支付, 1 支付成功,等待确认 2 确认成功,交易结束 -1 账单已退款 | | out_trade_no | string | 约吗收银业务账单编号 | | third_trade_no | string | 应用方业务账单编号 | | order_desc | string | 应用方提交的业务描述 | | pay_time | int | 支付成功的时间戳(秒), 未支付时值为 0 | | itime | int | 账单创建的时间戳(秒) |
& 示例
{
"type":"third_pay_result" ,
"params":"{
"_id": "2xdu2j5v8zyi",
"uid": "152e6645bf563ee4",
"appid": "ym2x4lwicjyxx0",
"pay_fee": 1000,
"pay_way": "balance",
"status": 1,
"third_trade_no": "YX200807222948787C4",
"order_desc": "游戏购买宝石",
"out_trade_no": "CS200807222948787C4",
"pay_time": 1597046779,
"itime": 1597046779
}"
}