生成小程序码时只设置一个参数,后台java代码:
String params = "{\"scene\":\"itemId=" + id + "\"}";
开发扫码进入小程序指定页面,在onLaunch事件中对options解码
var url = decodeURIComponent(options.query.scene)
var itemId = url.split('=')[1]
if(null == itemId){
this.globalData.pageInfo = '/pages/statistics/index'
} else {
this.globalData.pageInfo = '/pages/my/confirm?id=' + itemId
}
......
if (this.globalData.pageInfo.indexOf('statistics') != -1){
wx.switchTab({
url: this.globalData.pageInfo
})
} else {
wx.redirectTo({
url: this.globalData.pageInfo,
})
}
用户第一次微信扫码可以跳转到指定页面(/pages/my/confirm),但再次扫码是只能进入首页(/pages/statistics/index)。
如何解决?
放在onShow里呢
请问解决了吗?
你在onLaunch里面把参数存在页面上或者本地呀,在onShow的时候去拿存的参数,不就行了