From f39ead4cb560516f46a0bd52d9ea910933b599a7 Mon Sep 17 00:00:00 2001 From: Stormeye Wu Date: Wed, 12 Jun 2019 14:11:17 +0800 Subject: [PATCH] =?UTF-8?q?[=E5=B0=8F=E7=A8=8B=E5=BA=8F][=E5=BC=BA?= =?UTF-8?q?=E5=88=B6=E6=9B=B4=E6=96=B0]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app.js | 84 +++++++++++++++++++++++++++++++++++++--------------------- 1 file changed, 54 insertions(+), 30 deletions(-) diff --git a/app.js b/app.js index b7d82a4..64011e0 100644 --- a/app.js +++ b/app.js @@ -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