组件权限开通:小程序MP-功能-物流服务-申请开通「查询组件」
"mp-weixin" : {
"appid": "", //你自己的appid
"setting" : {
"urlCheck": false,
"es6":true,
"minified":false,
"postcss":true
},
"usingComponents" : true,
"permission" : {
"scope.userLocation": {
"desc": "为了更好的为您服务"
}
},
"plugins" : {
"logisticsPlugin": {
"version": "2.1.12",
"provider": "wx9ad912bf20548d92"
}
}
},
<text class="button" @tap="toDeliveryPage">查看物流</text>
<script>
var plugin = requirePlugin("logisticsPlugin")
export default {
data() {
return {
waybillToken: '', //通过后台接口获取到的值
};
},
methods: {
/**
* 查看物流
*/
toDeliveryPage: function(e) {
var ths = this;
uni.showLoading();
var params = {
url: "", //请求后端接口获取waybillToken
method: "GET",
data: {
},
callBack: function(res) {
//console.log(res);
if(res!=''&&res!=null&&res!=undefined){
const waybillToken = res;
// console.log(plugin.openWaybillTracking)
// 在此通过调用api来查询微信快递服务详情
//必须用预览才能测试这个功能,无法在工具端模拟
console.log(res)
plugin.openWaybillTracking({
waybillToken: waybillToken
});
}else{
uni.showToast({
title: "查询失败!",
icon: "none"
})
}
}
};
http.request(params);
},
}
};
</script>
然后就可以啦哈哈哈,文件别搞错咯,我搞错了找原因找半天