| @@ -34,42 +34,42 @@ App({ | |||
| url: config.api.login, | |||
| data: usrdata | |||
| }) | |||
| .then(res => { | |||
| if (res.data && res.data.score) { | |||
| if (res.data.score != 0) { | |||
| that.globalData.score = res.data.score; | |||
| .then(res => { | |||
| if (res.data && res.data.score) { | |||
| if (res.data.score != 0) { | |||
| that.globalData.score = res.data.score; | |||
| } | |||
| } | |||
| } | |||
| Http.setToken(res.data.token); | |||
| that.globalData.token = res.data.token; | |||
| console.log(that.globalData.token) | |||
| Http.setToken(res.data.token); | |||
| that.globalData.token = res.data.token; | |||
| console.log(that.globalData.token) | |||
| if (that.tokenCallback) { | |||
| that.tokenCallback(res.data.token); | |||
| } | |||
| }) | |||
| .catch(err => { | |||
| console.log(err) | |||
| wx.showModal({ | |||
| title: '提示', | |||
| showCancel: false, | |||
| content: '登录失败,请重新尝试', | |||
| success: function (res) { | |||
| if (res.cancel) { | |||
| //点击取消,默认隐藏弹框 | |||
| } else { | |||
| //点击确定 | |||
| wx.reLaunch({ | |||
| url: '/pages/index/index', | |||
| }) | |||
| } | |||
| if (that.tokenCallback) { | |||
| that.tokenCallback(res.data.token); | |||
| } | |||
| }) | |||
| }) | |||
| .catch(err => { | |||
| console.log(err) | |||
| wx.showModal({ | |||
| title: '提示', | |||
| showCancel: false, | |||
| content: '登录失败,请重新尝试', | |||
| success: function (res) { | |||
| if (res.cancel) { | |||
| //点击取消,默认隐藏弹框 | |||
| } else { | |||
| //点击确定 | |||
| wx.reLaunch({ | |||
| url: '/pages/index/index', | |||
| }) | |||
| } | |||
| } | |||
| }) | |||
| }) | |||
| } | |||
| }) | |||
| }, | |||
| updateManager: function() { | |||
| updateManager: function () { | |||
| /** | |||
| * 小程序版本更新 | |||
| */ | |||
| @@ -89,6 +89,24 @@ App({ | |||
| if (res.confirm) { | |||
| // 新的版本已经下载好,调用 applyUpdate 应用新版本并重启 | |||
| updateManager.applyUpdate() | |||
| } else if (res.cancel) { | |||
| //如果需要强制更新,则给出二次弹窗,如果不需要,则这里的代码都可以删掉了 | |||
| wx.showModal({ | |||
| title: '温馨提示~', | |||
| content: '本次版本更新涉及到新的功能添加,旧版本无法正常访问的哦~', | |||
| success: function (res) { | |||
| self.autoUpdate() | |||
| return; | |||
| //第二次提示后,强制更新 | |||
| if (res.confirm) { | |||
| // 新的版本已经下载好,调用 applyUpdate 应用新版本并重启 | |||
| updateManager.applyUpdate() | |||
| } else if (res.cancel) { | |||
| //重新回到版本更新提示 | |||
| self.autoUpdate() | |||
| } | |||
| } | |||
| }) | |||
| } | |||
| } | |||
| }) | |||
| @@ -102,10 +120,16 @@ App({ | |||
| }) | |||
| } | |||
| }) | |||
| } else { | |||
| // 如果希望用户在最新版本的客户端上体验您的小程序,可以这样子提示 | |||
| wx.showModal({ | |||
| title: '提示', | |||
| content: '当前微信版本过低,无法使用该功能,请升级到最新微信版本后重试。' | |||
| }) | |||
| } | |||
| }, | |||
| globalData: { | |||
| scene:"", | |||
| scene: "", | |||
| // token | |||
| token: null, | |||
| // user openId | |||