// pages/home/index.js const app = getApp() Page({ /** * 页面的初始数据 */ data: { height: app.globalData.height * 2 + 25, navbarData: { name: '节俭会' }, background: '', tenant: '', heat: 80, heatColor: { '0%': '#E1FFFF', '25%': '#00FF7F', '50%': '#191970', '75%': '#ee0a24', '100%': '#ff0000', }, thrList: [ { name: '菜名', num: 1, reserve: '100' }, { name: '菜名', num: 1, reserve: '100' }, { name: '菜名', num: 1, reserve: '100' }, ] }, // 查看本周菜谱 reserveBtn: function () { wx.redirectTo({ url: '/pages/food/index', }) }, // 报餐:1,余菜打包:2,卡路里计算:3 twoBtn: function (e) { let type = e.currentTarget.dataset.smile if (type == '1') { wx.switchTab({ url: '/pages/reserve/index', }) } else if (type == '2') { wx.showToast({ title: '暂未开通', }) } else { wx.showToast({ title: '暂未开通', }) // wx.redirectTo({ // url: '/pages/calorie/index', // }) } }, /** * 生命周期函数--监听页面加载 */ onLoad: function (options) { console.log(app.globalData.wxInfo); wx.request({ url: `${app.globalData.publicUrl}/api/st/system/tenant/getTenant/${app.globalData.tenant}`, method: "get", header: { 'x-tenant': app.globalData.tenant }, data: {}, success: res => { const { data } = res.data; this.setData({ background: `${app.globalData.fileUrl}` + data.img.home }) this.setData({ tenant: data.name }) }, error: err => { wx.showToast({ title: err.msg, icon: 'error' }) } }) console.log('function in') wx.getWeRunData({ success(res) { console.log(res); const { encryptedData, iv } = res const session_key = app.globalData.wxInfo.session_key const data = { encryptedData, iv, session_key } // // 拿 encryptedData 到开发者后台解密开放数据 wx.request({ url: `${app.globalData.publicUrl}/api/st/system/weixin/decrypt`, method: "POST", data, header: { 'x-tenant': app.globalData.tenant }, success: (res) => { console.log(res); }, }) } }) }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady: function () { }, /** * 生命周期函数--监听页面显示 */ onShow: function () { if (typeof this.getTabBar === 'function' && this.getTabBar()) { this.getTabBar().setData({ selected: 0 }) } }, /** * 生命周期函数--监听页面隐藏 */ onHide: function () { }, /** * 生命周期函数--监听页面卸载 */ onUnload: function () { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh: function () { }, /** * 页面上拉触底事件的处理函数 */ onReachBottom: function () { }, /** * 用户点击右上角分享 */ onShareAppMessage: function () { } })