Files
ruo-shan-cloud-redirect/miniprogram/app.ts
T
2026-08-20 09:07:29 +08:00

74 lines
2.0 KiB
TypeScript

// app.ts
// import { BASE_URL, appId } from './env'
// const DEFAULT_SHARE_CONFIG = {
// title: '吉林敖东控糖胶囊 辅助降血糖',
// imageUrl: '/pages/index/assets/test.jpg',
// }
App<IAppOption>({
globalData: {
// shareConfig: { ...DEFAULT_SHARE_CONFIG },
},
onLaunch() {
const updateManager = wx.getUpdateManager()
updateManager.onCheckForUpdate(function (res) {
// 请求完新版本信息的回调
console.log('是否有新版本', res.hasUpdate)
})
updateManager.onUpdateReady(function () {
// 新版本下载完毕,强制重启应用
wx.showModal({
title: '更新提示',
content: '新版本已就绪,即将重启应用',
showCancel: false,
success: function (res) {
if (res.confirm) {
// 强制重启,应用新版本
updateManager.applyUpdate()
}
}
})
})
updateManager.onUpdateFailed(function () {
// 新版本下载失败
wx.showModal({
title: '更新提示',
content: '新版本下载失败,请检查网络后重试',
showCancel: false
})
})
const envVersion = wx.getAccountInfoSync().miniProgram.envVersion
if (envVersion !== 'release') {
wx.reLaunch({ url: '/pages/tools/index' })
return
}
// this.fetchShareConfig()
},
// fetchShareConfig() {
// wx.request({
// url: `${BASE_URL}/api/ad/ww-join-fans/share/${appId}`,
// method: 'GET',
// success: (res: any) => {
// const data = res.data?.data ?? res.data
// if (data?.title || data?.imageUrl) {
// this.globalData.shareConfig = {
// title: data.title || DEFAULT_SHARE_CONFIG.title,
// imageUrl: data.imageUrl || DEFAULT_SHARE_CONFIG.imageUrl,
// }
// }
// },
// fail: () => {
// // 请求失败时继续使用默认分享文案和背景图
// },
// })
// },
})