Files
steel_prices_service/Sale/app.js
2026-01-06 18:00:43 +08:00

53 lines
1.1 KiB
JavaScript

// 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'
}
})