返回首页
goHome: function() { const pages = getCurrentPages() if (pages.length === 2) { wx.navigateBack() } else if (pages.length === 1) { wx.redirectTo({ url: '../index/index', }) } else { wx.reLaunch({ url: '../index/index', }) } }
上一步
prevStep: function() { this.setData({ step: this.data.step - 1 })},
下一步
nextStep: function() { // 在第一步,需检查是否有 openid,如无需获取 if (this.data.step === 1 && !this.data.openid) { wx.cloud.callFunction({ name: 'login', data: {}, success: res => { app.globalData.openid = res.result.openid this.setData({ step: 2, openid: res.result.openid }) }, fail: err => { wx.showToast({ icon: 'none', title: '获取 openid 失败,请检查是否有部署 login 云函数', }) console.log('[云函数] [login] 获取 openid 失败,请检查是否有部署云函数,错误信息:', err) } }) } else { const callback = this.data.step !== 6 ? function() {} : function() { console.group('数据库文档') console.log('https://developers.weixin.qq.com/miniprogram/dev/wxcloud/guide/database.html') console.groupEnd() } this.setData({ step: this.data.step + 1 }, callback) }},