// pages/prompt/prompt.js const app = getApp() Page({ /** * 页面的初始数据 */ data: { companyName:"沪上阿姨" }, /** * 生命周期函数--监听页面加载 */ onLoad: async function (options) { console.log(options) let page = options.page if (options.page === 'pages/appointment/appointment') { page = `${page}?shopId=${options.shopId}&productId=${options.productId}` } if(options.storeId && options.tableId){ this.setData({ storeId: options.storeId, tableId: options.tableId, }) } this.setData({ fromPage: page }) let userInfo = await app.getWxUserInfo() console.log(userInfo); if (userInfo){ this.setData({ userInfo: userInfo, hasUserInfo: true, hasMobile: userInfo.mobile ? true : false }) } }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady: function () { }, /** * 生命周期函数--监听页面显示 */ onShow: function () { }, /** * 生命周期函数--监听页面隐藏 */ onHide: function () { }, /** * 生命周期函数--监听页面卸载 */ onUnload: function () { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh: function () { }, /** * 页面上拉触底事件的处理函数 */ onReachBottom: function () { }, /** * 用户点击右上角分享 */ onShareAppMessage: function () { }, getInfo : async function(e){ const _self = this let userInfo = e.detail.userInfo userInfo['encryptedData'] = e.detail.encryptedData userInfo['iv'] = e.detail.iv let info = await app.wxLogin(userInfo); let hasMobile = false; if (info.mobile){ hasMobile = true } _self.setData({ hasUserInfo: true, userInfo: info, hasMobile: hasMobile, }) if(_self.data.fromPage=="pages/personorder/personorder"){ wx.switchTab({ url: '/'+_self.data.fromPage, }) return; }/* else{ wx.redirectTo({ url: '/'+_self.data.fromPage, }) } */ if(_self.data.fromPage=="pages/comments/comments"){ wx.redirectTo({ url: '../comments/comments?title=我的评论&commentstype=my', }) return; } if(_self.data.fromPage=="pages/food/food"){ wx.redirectTo({ url: '/'+_self.data.fromPage+"?tableId="+this.data.tableId+"&storeId="+this.data.storeId, }) return; } wx.redirectTo({ url: '/'+_self.data.fromPage, }) console.log(_self.data.fromPage) } })