diff --git a/app.js b/app.js index 3ba33ea..ee1bf0a 100644 --- a/app.js +++ b/app.js @@ -50,7 +50,7 @@ App({ config: null, //门店参数 config2: null, //门店配置 code: null, - user_id:null,// 6519870,//5682094, + user_id:null,//1564704,// 10153869,// 6453964,//5682094, buy_now:null, picklist:null, //门店列表 wuliuprice: null, //物流价格表 @@ -78,6 +78,10 @@ App({ onLaunch: function() { wx.hideTabBar(); this.initExt(); + + //检查更新 + this.checkUpdateVersion(); + var t = this.globalData.setting; //console.log(t) t.resourceUrl = t.url + "/template/mobile/rainbow"; @@ -665,6 +669,7 @@ App({ this.globalData.dis_buy_obj=null; //等级卡的购买记录 this.globalData.storeFooter=null; //底部的导航 this.globalData.full_screen=null; //全屏 + }, clear_word:function (word) { @@ -767,6 +772,42 @@ App({ }, + checkUpdateVersion() { + //判断微信版本是否 兼容小程序更新机制API的使用 + if (wx.canIUse('getUpdateManager')) { + //创建 UpdateManager 实例 + const updateManager = wx.getUpdateManager(); + console.log('是否进入模拟更新'); + //检测版本更新 + updateManager.onCheckForUpdate(function(res) { + console.log('是否获取版本'); + // 请求完新版本信息的回调 + if (res.hasUpdate) { + //监听小程序有版本更新事件 + updateManager.onUpdateReady(function() { + + //TODO 新的版本已经下载好,调用 applyUpdate 应用新版本并重启 ( 此处进行了自动更新操作) + updateManager.applyUpdate(); + }) + updateManager.onUpdateFailed(function() { + // 新版本下载失败 + wx.showModal({ + title: '已经有新版本喽~', + content: '请您删除当前小程序,到微信 “发现-小程序” 页,重新搜索打开哦~', + }) + }) + } + }) + } else { + //TODO 此时微信版本太低(一般而言版本都是支持的) + wx.showModal({ + title: '溫馨提示', + content: '当前微信版本过低,无法使用该功能,请升级到最新微信版本后重试。' + }) + } + }, + +