Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

重新整理了下JSBridge的文档 #139

Open
mishe opened this issue Aug 15, 2016 · 0 comments
Open

重新整理了下JSBridge的文档 #139

mishe opened this issue Aug 15, 2016 · 0 comments

Comments

@mishe
Copy link
Owner

mishe commented Aug 15, 2016

P2P 类 JSBridge 开发接口文档

标签(空格分隔): JSBridge


约定

  • 只注入一个对象:JF, 示例:JF.navigator_setTitle()
  • 异步callback
  • 命名空间:navigator、passport等
  • 参数:(JSON jsonString, Callback callbackString)
  • 重载(callback可传,可不传)
  • 容错处理

callback定义:

{
"status": 0,
"message": "xxx",
"data": {},
}

Error Code 定义

待定...


passport

用户登录

JF.passport_login({string phoneNum,string backURL});

phoneNum 可以为空,用户的注册手机号
backURL 登录成功后的返回页面


用户注册

JF.passport_register({string phoneNum,string backURL});

phoneNum 可以为空,用户的注册手机号
backURL 登录成功后的返回页面

邀请好友

JF.passport_invite( Callback callback);


导航 navigator

设置顶部标题

JF.navigator_setTitle(String title, Callback callback);

title 要设置的标题
callback 设置成功后的回调


设置广告位

JF.navigator_setBanner(String json, Callback callback);

json格式:

{
    "images": "http://share.png", 
    "link": "http://sss/sd.html" 
    ...
}

设置导航栏右侧按钮关联动作。

JF.navigator_setAction(String json, Callback callback);

json格式:

[
    {
        "icon": "http://share.png | share", // 导航栏右边添加图标,url或者local icon name(可约定默认本地图标名称)
        "title": "分享", // 或者在更多中显示的名称
        "actionName": "share" // JS调用的方法名
    },
    {
        "icon": "http://share.png | share.png", // 导航栏右边添加图标,url或者local icon name(可约定默认本地图标名称)
        "title": "分享", // 或者在更多中显示的名称
        "actionName": "share" // JS调用的方法名
    }
]

移除导航栏右侧按钮关联动作

JF.navigator_removeAction(Callback callback);


设置页面的分享信息

JF.navigator_setShareInfo(string json)

json:

{
    title:'', //分享标题
    desc:'', //分享描述
    icon:'' //分享的小图片,
    link:'' //分享后的连接地址
}

关闭当前窗口

JF.navigator_closeWindow();


打开外部浏览器

JF.navigator_openURL(String URL);


弹窗 window

显示原生的提示框

确认框 confirm

JF.window_confirm(String json, Callback callback);

json格式:

{
"title": "提示", 
"message": "确定删除", 
"yes": "确定",
"no": "取消"
}

callback:

{
"status":0,
"message":'',
"data": 1  //1 确认, 0 取消
}

显示提示框 toast

JF.window_toast(String json, Callback callback);

json格式:

{
"message": "xxxx", // 消息内容
"duration": "2000", // 持续2秒
}

显示或隐藏正在加载提示框 loading

JF.window_loading(String json, Callback callback);

json格式:

{
"action": "show" or "hide", // 显示或隐藏
"title": "loading...", // 显示的标题
"masked": true or false // 是有全屏遮罩,默认为true
}

分享 share

JF.window_share(string json,callback)

显示分享弹窗

json:

{
    title:'', //分享标题
    desc:'', //分享描述
    icon:'' //分享的小图片,
    link:'' //分享的连接
}

设备相关 device

获取设备信息 info

JF.device_info(Callback callback);

callback:

{
    "status":
    "message":
    "data": {
        "device_id": "00000000", //
        "bundle_id": 程序包ID
        ...
    }
}

捕获音频 captureAudio

JF.device_captureAudio(Callback callback);

callback:

{
"status":
"message":
"data": {"filePath": "xxxxx"}
}

捕获图片 captureImage

JF.device_captureImage(String json, Callback callback)

json格式:

{
"type": "jpg", //
}

callback:

{
"status":
"message":
"data": {"filePath": "xxxxx"}
}

捕获视屏captureVideo

JF.device_captureVideo(String json, Callback callback);

json格式:

{
"type": "mp4", //
}

callback:

{
"status":
"message":
"data": {"filePath": "xxxxx"}
}

获取网络连接情况 network

JF.device_network(Callback callback);

callback:

{
"status":
"message":
"data": {"status" : "WIFI"}
}

网络连接情况。

  • Constants
  • UNKNOWN
  • NONE
  • WIFI
  • ...可以事先约定

支付 parment

立即支付

JF.parment_order(string orderId,Callback callback)

orderId 生成的订单id


购买产品

JF.parment_buy(string json,Callback callback)

json:

{
    type:1,
    product_id:xxxx,
    ....
}

去投资

JF.parment_gobuy()

跳转到原生APP的商品分类或列表页

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant