42 lines
1.1 KiB
JavaScript
42 lines
1.1 KiB
JavaScript
//app.js
|
|
import api from './utils/api.js';
|
|
import pay from './utils/pay.js';
|
|
App({
|
|
onLaunch: function () {
|
|
this.checkUpdate();
|
|
},
|
|
|
|
// 检查并强制更新小程序版本
|
|
checkUpdate: function () {
|
|
if (!wx.canIUse('getUpdateManager')) return;
|
|
const updateManager = wx.getUpdateManager();
|
|
updateManager.onCheckForUpdate(function (res) {
|
|
if (!res.hasUpdate) return;
|
|
updateManager.onUpdateReady(function () {
|
|
wx.showModal({
|
|
title: '发现新版本',
|
|
content: '新版本已准备好,重启后生效,是否立即重启?',
|
|
showCancel: false,
|
|
confirmText: '立即重启',
|
|
success: function () {
|
|
updateManager.applyUpdate();
|
|
}
|
|
});
|
|
});
|
|
updateManager.onUpdateFailed(function () {
|
|
wx.showModal({
|
|
title: '发现新版本',
|
|
content: '新版本下载失败,请删除小程序后重新搜索进入以获取最新版本。',
|
|
showCancel: false,
|
|
confirmText: '我知道了'
|
|
});
|
|
});
|
|
});
|
|
},
|
|
|
|
globalData: {
|
|
userInfo: null
|
|
},
|
|
$api: api,
|
|
$pay: pay
|
|
}) |