49 lines
1.5 KiB
JavaScript
49 lines
1.5 KiB
JavaScript
![]() |
App({
|
||
|
showToast: function (title, icon = 'none', duration = 1500) {
|
||
|
wx.showToast({
|
||
|
title: title,
|
||
|
icon: icon,
|
||
|
duration: duration
|
||
|
});
|
||
|
},
|
||
|
onLaunch(e) {
|
||
|
if (wx.getStorageSync('menuTop') != '' && wx.getStorageSync('menuHeight') != '') return
|
||
|
const button = wx.getMenuButtonBoundingClientRect();
|
||
|
console.log(button);
|
||
|
wx.setStorageSync('menuTop', button.top)
|
||
|
wx.setStorageSync('menuHeight', button.height)
|
||
|
},
|
||
|
onShow(){
|
||
|
const updateManager = wx.getUpdateManager();
|
||
|
|
||
|
updateManager.onCheckForUpdate(function (res) {
|
||
|
console.log(res.hasUpdate); // 检查是否有新版本
|
||
|
console.log("检查是否有新版本",res.hasUpdate); // 检查是否有新版本
|
||
|
});
|
||
|
|
||
|
updateManager.onUpdateReady(function () {
|
||
|
wx.showModal({
|
||
|
title: '更新提示',
|
||
|
content: '新版本已经准备好,是否重启应用?',
|
||
|
success: function (res) {
|
||
|
if (res.confirm) {
|
||
|
// 新的版本已经下载好,调用 applyUpdate 应用新版本并重启
|
||
|
updateManager.applyUpdate()
|
||
|
}
|
||
|
}
|
||
|
})
|
||
|
});
|
||
|
|
||
|
updateManager.onUpdateFailed(function () {
|
||
|
console.log('新版本下载失败'); // 处理下载失败
|
||
|
});
|
||
|
},
|
||
|
globalData: {
|
||
|
teamRefresh: 0, //团队首页是否刷新
|
||
|
homeWorkRefresh: 0, //教师作业列表是否刷新
|
||
|
sex: 1, //性别
|
||
|
areaId: 1, //城市id
|
||
|
gradeId: 1, //年级
|
||
|
isUserLogout: false, //是否用户手动退出登录
|
||
|
},
|
||
|
});
|