You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
71 lines
1.8 KiB
71 lines
1.8 KiB
<script> |
|
import config from './config.js' |
|
import { getAccessToken, setOpenId, getOpenId } from '@/utils/auth' |
|
export default { |
|
data() { |
|
return {} |
|
}, |
|
async onLaunch(options) { |
|
await this.initApp() |
|
}, |
|
onShow() { |
|
const updateManager = uni.getUpdateManager() |
|
|
|
updateManager.onCheckForUpdate(function (res) { |
|
// 请求完新版本信息的回调 |
|
// console.log(res.hasUpdate) |
|
}) |
|
|
|
updateManager.onUpdateReady(function (res) { |
|
uni.showModal({ |
|
title: '更新提示', |
|
content: '新版本已经准备好,是否重启应用?', |
|
showCancel: false, |
|
success(res) { |
|
if (res.confirm) { |
|
// 新的版本已经下载好,调用 applyUpdate 应用新版本并重启 |
|
updateManager.applyUpdate() |
|
} |
|
} |
|
}) |
|
}) |
|
|
|
updateManager.onUpdateFailed(function (res) { |
|
// 新的版本下载失败 |
|
console.log('download error') |
|
uni.showModal({ |
|
title: '提示', |
|
content: |
|
'新版小程序下载失败\n请自行退出程序,手动卸载本程序,再运行', |
|
confirmText: '知道了' |
|
}) |
|
}) |
|
}, |
|
methods: { |
|
// 初始化应用 |
|
initApp() { |
|
uni.hideTabBar() |
|
// 初始化应用配置 |
|
this.initConfig() |
|
}, |
|
initConfig() { |
|
this.globalData.config = config |
|
uni.getSystemInfoAsync({ |
|
success: res => { |
|
uni.setStorageSync('MOBILE', res.model) |
|
uni.setStorageSync('SYSTEM', res.system) |
|
uni.setStorageSync('PIXELRATIO', res.pixelRatio) |
|
}, |
|
fail: err => { |
|
console.error('获取设备信息失败:', err) |
|
} |
|
}) |
|
} |
|
} |
|
} |
|
</script> |
|
|
|
<style lang="scss"> |
|
@import '@/uni_modules/windi-css-uniapp/index.scss'; |
|
@import '@/static/scss/index.scss'; |
|
</style>
|
|
|