//index.js //获取应用实例 const app = getApp() Page({ data: { carInfo: {}, // tab active: 0, // 是否可以领取积分 disabled: false, // 用户信息 userInfo: {} }, //事件处理函数 receiveBtn: function () { let user = this.data.userInfo; wx.request({ url: app.globalData.publicUrl + '/api/htyd/carShow/check', method: "get", data: { id: user._id }, success: (res) => { if (res.data.errcode === 0) { wx.request({ url: app.globalData.publicUrl + '/api/htyd/carShow/getShow', method: "get", data: { id: user._id }, success: (arr) => { if (arr.data.errcode === 0) { wx.showToast({ title: '领取积分成功', icon: 'success', duration: 2000 }) } } }) } else { wx.showToast({ title: '条件不足', icon: 'error', duration: 2000 }) } } }) }, onLoad: function () { // 用户信息 let data = app.globalData.userInfo; if (data) this.setData({ userInfo: data }) // 查询信息 wx.request({ url: app.globalData.publicUrl + '/api/htyd/config/car', method: "get", data: {}, success: (res) => { this.setData({ carInfo: res.data.data }) } }) }, })