onscanCodeGui() {
const that = this;
// scanCodeResult 1为饿了么 2为美团 3为其他
wx.scanCode({
success (res) {
if (res.result.includes('ele.me')) {
that.setData({
scanCodeResult: 1
})
that.onJump(that.data.scanCodeResult);
}
if (res.result.includes('meituan.com')) {
that.setData({
scanCodeResult: 2
})
that.onJump(that.data.scanCodeResult);
}
},
fail (err) {
wx.showToast({
title: err.errMsg,
icon: 'none',
duration: 2000
})
}
})
},
onJump(codeResult) {
wx.showModal({
title: '提示',
content: `${codeResult == 1 ? '即将要转到饿了么小程序' : '即将要转到美团小程序'}`,
success (res) {
if (res.confirm) {
let appId = `${codeResult == 1 ? 'wxb01f60c7808c9646' : 'wx106b6b04278acec4'}`;
wx.navigateToMiniProgram({ // 这个api微信官方文档自带
appId,
success(res) {
// 打开成功
console.log(res)
},
fail (err) {
console.log(err)
}
})
} else if (res.cancel) {
console.log('用户点击取消')
}
}
})
},
用自己的小程序通过扫码跳到另一个小程序
最新推荐文章于 2024-09-30 20:00:00 发布