modify:新增小程序
This commit is contained in:
52
Sale/app.js
Normal file
52
Sale/app.js
Normal file
@@ -0,0 +1,52 @@
|
||||
// app.js
|
||||
App({
|
||||
onLaunch() {
|
||||
console.log('钢材价格查询小程序启动')
|
||||
|
||||
// 检查更新
|
||||
this.checkUpdate()
|
||||
},
|
||||
|
||||
/**
|
||||
* 检查小程序更新
|
||||
*/
|
||||
checkUpdate() {
|
||||
if (wx.canIUse('getUpdateManager')) {
|
||||
const updateManager = wx.getUpdateManager()
|
||||
|
||||
updateManager.onCheckForUpdate((res) => {
|
||||
if (res.hasUpdate) {
|
||||
console.log('发现新版本')
|
||||
}
|
||||
})
|
||||
|
||||
updateManager.onUpdateReady(() => {
|
||||
wx.showModal({
|
||||
title: '更新提示',
|
||||
content: '新版本已经准备好,是否重启应用?',
|
||||
success: (res) => {
|
||||
if (res.confirm) {
|
||||
updateManager.applyUpdate()
|
||||
}
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
updateManager.onUpdateFailed(() => {
|
||||
wx.showModal({
|
||||
title: '更新失败',
|
||||
content: '新版本下载失败,请检查网络后重试',
|
||||
showCancel: false
|
||||
})
|
||||
})
|
||||
}
|
||||
},
|
||||
|
||||
globalData: {
|
||||
// API 基础地址
|
||||
apiBaseUrl: 'http://localhost:3000',
|
||||
// 应用信息
|
||||
appName: '钢材价格查询',
|
||||
version: '1.0.0'
|
||||
}
|
||||
})
|
||||
Reference in New Issue
Block a user