// pages/storeMessage/select.js Page({ /** * 页面的初始数据 */ data: { selectItem: '注册商户', //选中项 }, /** * 生命周期函数--监听页面加载 */ onLoad: function (options) { }, /* 选择入口 */ selectAccess(e) { const { name } = e.target.dataset; this.setData({ selectItem: name }) }, /* 跳转页面 */ submit() { if (this.data.selectItem == '注册商户') { wx.redirectTo({ url: '/pages/storeMessage/index', }) } else { wx.scanCode({ success(res) { console.log("扫码", res) if (res.errMsg != 'scanCode:ok') return wx.showToast({ title: '扫码失败', }); let q = res.result; const data = { type: q.slice(q.indexOf("type=") + 5, q.indexOf('&')), id: q.slice(q.lastIndexOf('=') + 1), name: q.slice(q.lastIndexOf('fbrand=') + 7, q.lastIndexOf('&')) } wx.setStorageSync('qrCodeMsg', data); console.log(wx.getStorageSync('qrCodeMsg')) wx.switchTab({ url: '/pages/tabbar-pages/home/index', }) }, fail(err) { console.log("扫码失败", err) wx.showToast({ title: '扫码失败', icon: "error" }); } }) } }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady: function () { }, /** * 生命周期函数--监听页面显示 */ onShow: function () { }, /** * 生命周期函数--监听页面隐藏 */ onHide: function () { }, /** * 生命周期函数--监听页面卸载 */ onUnload: function () { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh: function () { }, /** * 页面上拉触底事件的处理函数 */ onReachBottom: function () { }, /** * 用户点击右上角分享 */ onShareAppMessage: function () { } })