平台兼容性
Android | iOS |
---|---|
× | √ |
原生插件通用使用流程:
- 购买插件,选择该插件绑定的项目。
- 在HBuilderX里找到项目,在manifest的app原生插件配置中勾选模块,如需要填写参数则参考插件作者的文档添加。
- 根据插件作者的提供的文档开发代码,在代码中引用插件,调用插件功能。
- 打包自定义基座,选择插件,得到自定义基座,然后运行时选择自定义基座,进行log输出测试。
- 开发完毕后正式云打包
付费原生插件目前不支持离线打包。
Android 离线打包原生插件另见文档 https://nativesupport.dcloud.net.cn/NativePlugin/offline_package/android
iOS 离线打包原生插件另见文档 https://nativesupport.dcloud.net.cn/NativePlugin/offline_package/ios
注意事项:使用HBuilderX2.7.14以下版本,如果同一插件且同一appid下购买并绑定了多个包名,提交云打包界面提示包名绑定不一致时,需要在HBuilderX项目中manifest.json->“App原生插件配置”->”云端插件“列表中删除该插件重新选择
阿里百川电商sdk苹果版
功能如下
百川初始化,
授权并登录,
用户是否已登录,
退出登录,
跳转购物车
跳转到我的订单
跳转到优惠券
打开淘宝商品
使用说明
-
请使用V4安全图片放入 \nativeplugins\dasu-Baichuan\ios
-
在mainfest.json 源码视图中 配置app-plus->distribute -> ios (urlschemes必须tbopen前缀) "ios" : { "urltypes" : [ { "urlschemes" : [ "tbopen您的appkey" ],// 示例:"urlschemes" : [ "tbopen25816822" ] "id" : "tbopen" } ], "urlschemewhitelist" : [ "taobao", "tianmao", "tbopen", "tmall" ] }
-
app-plus节点增加下面两个配置 "schemeWhitelist" : [ "tbopen", "tmall", "taobao", "tianmao" ], "appWhitelist" : [ "tbopen", "tmall", "taobao", "tianmao" ]
代码示例
const taobao = uni.requireNativePlugin('dasu-Baichuan');
export default {
data() {
return {
title: '阿里百川电商sdk苹果版',
btnTitles: [
'百川初始化',
'授权并登录',
'用户是否已登录',
'退出登录',
'跳转购物车',
'跳转到我的订单',
'跳转到优惠券',
'打开淘宝商品'
],
result: '',
}
},
onLoad() {
},
methods: {
btnclick: function(e) {
const _this=this;
switch (e) {
case 0:
taobao.BCSDKInitWithAppkey('', result => {
uni.showModal({
title:'百川初始化',
content:'code:'+result['code'] + '\nmessage:' + result['message']
});
_this.result =JSON.stringify(result);
});
break;
case 1:
taobao.BCAuth(result => {
uni.showModal({
title:'授权登录',
content:'code:'+result['code'] + '\nmessage:' + result['message']
})
_this.result =JSON.stringify(result);
});
break;
case 2:
taobao.BCIsUserLogin(result => {
uni.showModal({
title:'用户是否登录',
content:'code:'+result['code'] + '\nmessage:' + result['message']
});
_this.result =JSON.stringify(result);
});
break;
case 3:
taobao.BCUserLogout(result => {
uni.showModal({
title:'退出登录',
content:'code:'+result['code'] + '\nmessage:' + result['message']
});
_this.result =JSON.stringify(result);
});
break;
case 4:
taobao.BCJumpMyCart(result => {
uni.showModal({
title:'跳转到我的购物车',
content:'code:'+result['code'] + '\nmessage:' + result['message']
});
_this.result =JSON.stringify(result);
});
break;
case 5:
taobao.BCJumpMyOrder(result => {
uni.showModal({
title:'跳转到我的订单',
content:'code:'+result['code'] + '\nmessage:' + result['message']
});
_this.result =JSON.stringify(result);
});
break;
case 6:
taobao.BCGetCoupons("https:\/\/uland.taobao.com/coupon/edetail?e=bv45wXFXDV0GQASttHIRqYvw81bTTFV3AoNz1oh6sSBw24URnwfVYZkqkkGn1ka4Io61VIt2QOAlLeoz%2FuwL9wBa6vm8LTMVFpTdiJGYMLzZzF%2F7iLsQj%2Bdth9k8bqqSHKTgBzHkoM7XTQC0vfau6E%2F9Zk7cDx8UPY2GSU4OeGfCMAzsjqHNZlTH5bfxlzo3&traceId=0b15337b15522805995965072e&union_lens=lensId:0b0fc0d4_0bf6_1696b223c3d_2b97&xId=TNqIni6VJhuZ9lqkONqDbz9lYtQjXIVM9Vi4arlsiXoIG879SnaSb2HjXpRzY0CIEsykszYfmZWzbvz2I68AfA", result => {
uni.showModal({
title:'跳转到优惠券',
content:'code:'+result['code'] + '\nmessage:' + result['message']
});
_this.result =JSON.stringify(result);
});
break;
case 7:
taobao.BCGetCoupons("https://detail.tmall.com/item.htm?id=575281288136&ali_refid=a3_430652_1007:1103167263:N:1027761750_0_100:4ef0f6625c5f76b0f1fffc8b19ae1425&ali_trackid=1_4ef0f6625c5f76b0f1fffc8b19ae1425&spm=a231k.8263137.100001.3", result => {
uni.showModal({
title:'打开淘宝商品',
content:'code:'+result['code'] + '\nmessage:' + result['message']
});
_this.result =JSON.stringify(result);
});
break;
default:break;
}
}
}
}
</script>