upVdnModule VDN模块
模块概述
为H5页面提供在新的webview中打开指定页面,以及跳转native页面等功能
方法列表
- goToPage(跳转指定页面)
- goToPageForResult(跳转页面获取参数)
- goBackWithResult(携带参数返回之前页面)
公共数据
所有数据均以JSON结构返回,由代码,信息和数据三部分组成
{
"retCode": "000000", //接口状态标识码,错误标识码以14开头
"retInfo": "操作成功",//接口信息说明
"retData": null //业务数据
}
具体定义:返回数据通用
模块变更记录
- V3.7.0
- 新增:跳转App权限管理页面URL,跳转到家庭管理浮窗页URL。
- V3.5.0
- 新增:NFC空白标签写入和逻辑。
V3.0.0
模块名由vdnModule更改为upVdnModule
新增方法:
- goToPageForResult(跳转页面获取参数)
- goBackWithResult(携带参数返回之前页面)
删除方法:
- 无
方法变更:
- 无
- V3.2.0
- VDN模块未定义的retCode编码按照通用数据规定变为990001,操作失败retCode变为000001,非法参数错误retCode变为000002
方法说明
goToPage
goToPage({params})
使用说明
调用该接口会通过native在新的webview中打开指定的页面,或者通过一个URL地址跳转到新的native页面
参数url里面可以携带参数,例如需要登录: ?uplusOAuth=1,跳转后的新页面参数可通过uplus-api初始化中的获取URL中的参数 (getUrlParams)方法获取
适用性
容器 | cordova | APICloud | Nebula | |
---|---|---|---|---|
支持情况 | 是 | 是 | 否 | 是 |
APP版本 | 5.3.0及以上 | 5.3.0及以上 | 6.12.0 及以上 |
params 输入参数
属性名 | 数据类型 | 是否必填 | 说明 |
---|---|---|---|
url | String | 是 | 目标页面地址 |
错误返回 retCode说明
retCode编码 | retInfo说明 |
---|---|
000001 | 跳转失败 |
正确返回 retData说明
无
示例
upVdnModule.goToPage({url: 'http://www.baidu.com'}).then((result) => {
console.log('result',result);
},(err)=>{
console.log('err',err);
})
goToPageForResult
goToPageForResult({params})
使用说明
调用该接口会通过一个URL地址(跳转地址需向相关native开发获取)跳转到新的native页面并等待native页面的成功回调,成功回调中测数据是相对应方法goBackWithResult中所传递的参数值
适用性
容器 | cordova | APICloud | Nebula |
---|---|---|---|
支持情况 | 是 | 是 | 是 |
APP版本 | 6.2.0及以上 | 6.2.0及以上 | 6.12.0 及以上 |
params 输入参数
属性名 | 数据类型 | 是否必填 | 说明 |
---|---|---|---|
url | String | 是 | 目标页面地址 |
错误返回 retCode说明
retCode编码 | retInfo说明 |
---|---|
000001 | 跳转失败 |
示例
upVdnModule.goToPageForResult({url:'uphybrid://vdnDemo/index.html'}).then((res) => {
console.log('result',res);
this.setState({ nickname:res.retData.resultFromH5});
},(err)=>{
console.log('err',err);
});
成功返回数据
{
"retCode":"000000",
"retInfo":"操作成功",
"retData":{
"resultFromH5":"value",
}
}
goBackWithResult
goBackWithResult({params})
使用说明
调用该接口会从当前native页面跳转回上一个native页面,并且将此方法中传入参数值作为对应方法goToPageForResult的成功回调结果进行传递。 注意:从cordova容器下跳转到cordova容器现在存在问题,会导致goBackWithResult返回上一页面时异常
适用性
容器 | cordova | APICloud | Nebula |
---|---|---|---|
支持情况 | 是 | 是 | 是 |
APP版本 | 6.2.0及以上 | 6.2.0及以上 | 6.12.0 及以上 |
params 输入参数
属性名 | 数据类型 | 是否必填 | 说明 |
---|---|---|---|
result | String | 否 | 传给native的json字符串 |
错误返回 retCode说明
retCode编码 | retInfo说明 |
---|---|
000001 | 跳转失败 |
正确返回 retData说明
无
示例
upVdnModule.goBackWithResult({result:'cute考拉'}).then((result) => {
console.log('result',result);
},(err)=>{
console.log('err',err);
});
常用VDN跳转地址汇总
- 跳转至设备信息编辑页:http://uplus.haier.com/uplusapp/DeviceList/DeviceEditView.html?mac=XXXXXX
- 跳转至登录页:mpaas://usercenter
- 跳转至设备绑定页面:http://uplus.haier.com/uplusapp/main/qrcodescan.html?selectIndex=1(1,2,3分别对应绑定页的扫描,手动,附件家电)
- 跳转至原生扫一扫:http://uplus.haier.com/uplusapp/scan/commonscanpage.html(具体用法详见扫一扫模块)
- 跳转至设备详情页:http://uplus.haier.com/uplusapp/DeviceList/DetailView.html?deviceId=XXXXX (当前传入的mac地址必须在当前登录账户下)
- mpaas容器开启原生标题栏配置: url后面拼接参数: ?show_title_bar=true
- 语音助手(可以使用https的跳转地址,原生映射到对应资源包):https://uplus.haier.com/uplusapp/aivoice/aivoice.html -> mpaas://xiaoYVoice
https://uplus.haier.com/uplusapp/aivoice/aivoicey.html -> mpaas://xiaoYVoiceY
- nfc空白标签写入URL:http://uplus.haier.com/uplusapp/main/nfcwrite.html Native需要参数+NFC固定参数+NFC自定义参数(注意:所有参数都要进行ulr编码)示例:untype=scene&sid=111&fid=111&nfccustom=12sddgs NFC自定义参数:nfccustom=xxxxxxx (进行url编码,编码前格式:a=xxx&b=xxx&c=xxxx) APP会在https://zj.haier.net? 后拼接NFC固定参数的key-value、NFC自定义参数的value(本身是key-value格式),并编码后写入NFC 设备详情:http://uplus.haier.com/uplusapp/main/nfcwrite.html?untype=devcie&model=设备机编&did=设备deviceid&nfccustom=12sddgs 跳转jumpurl:http://uplus.haier.com/uplusapp/main/nfcwrite.html?untype=jumpurl&uncode=唯一标识&nfccustom=12sddgs 跳转场景:http://uplus.haier.com/uplusapp/main/nfcwrite.html?untype=scene&sid=实例化的场景id&fid=家庭id&nfccustom=12sddgs
- App权限管理页面:http://uplus.haier.com/uplusapp/main/appPermission.html
- 家庭管理浮窗页:http://uplus.haier.com/uplusapp/main/familyFloatView.html