使用微信网页wx-open-launch-app跳转APP:
https://developers.weixin.qq.com/doc/oplatform/Mobile_App/WeChat_H5_Launch_APP.html
1.申请微信SDK,获取后端返回的签名及签名相关内容,APPID填写公众号APPID
2.url 传递给后端生成的签名,url为开放平台公众号关联APP 域名的域名, url需要和第一次进入的页面域名一致。
app未启动或启动中获取参数:
https://ask.dcloud.net.cn/article/64
//onLaunch生命周期中使用: 确保启动时每个页面都能监听到
let that = this
plus.globalEvent.addEventListener('newintent', e => {
that.checkArguments();
});
//启动页 onshow生命周期使用:确保未启动时第一次进入可以跳转
setTimeout(function() {
that.checkArguments()
}, 10);
//方法:
checkArguments() {
// plus.runtime.argumrnts为打开时APP传的值(<wx-open-launch-app>中的extinfo),可以传字符串通过符号截取判断类型
if (this.isJsonObject(plus.runtime.arguments)) {
//我截取了字符串,判断是商品并且根据ID跳转到商品详情页
var commodityParams = plus.runtime.arguments;
uni.navigateTo({
url: `/pages/commodityDetails/commodityDetails?sendData=${commodityParams}`
});
plus.runtime.arguments = null;
plus.runtime.arguments = "";
}
},
isJsonObject(variable) {
if (variable) {
try {
JSON.parse(variable);
return true;
} catch (e) {
return false;
}
}
return false;
},
`