时间:2019-05-03 来源:小程序工厂
这是模拟单点登录的节奏啊
A
onLoad(options) { let isRegister = wx.getStorageSync('isRegister'); if (!isRegister) { let url = Base64.encode(getUrl()); wx.redirectTo({ url: "/pages/authorize/index?page=" + url }); return false; } this.getData();}page: /pages/member/index
B
onLoad(options) { if (!(JSON.stringify(options) === "{}")) { if (options.page) { options.page = Base64.decode(options.page); console.log(options.page); } this.setData({ options: options }); }},
B页面处理跳转
if (res.data.data.isRegister) {wx.setStorageSync('isRegister', true); //默认地址 let url = '/pages/index/index'; if (that.data.options.page) { //来路地址 url = that.data.options.page; } wx.redirectTo({ url: url });} else { wx.setNavigationBarTitle({ title: '注册用户' }); that.setData({ display: true, openid: res.data.data.openid, token: res.data.data.token, nickname: nickname })}
执行结果:fail page "/pages/member/index
结果图片
测试了一下,变量方式传参,正常跳转,你贴下完整代码看看
console.log(JSON.parse(JSON.stringify(that.data.options.page)));
跳转之前打印下 是一样的吗?