Commit 3a8ecc99 authored by June's avatar June

添加版本号

parent 29adb4f9
......@@ -6,7 +6,6 @@ import { removeStorage } from '@/lib/storage/index.js'
export default {
onLaunch: async function() {
this.setMobileData() // 获取系统信息和胶囊信息
this.checkUpdate() // 检查更新
const extConfig = wx.getExtConfigSync ? wx.getExtConfigSync(): {}
this.$store.state.user.appid = extConfig.appid
const token = this.$getStorage('token')
......@@ -18,14 +17,15 @@ export default {
// uni.setEnableDebug({
// enableDebug: true
// })
uni.getStorageInfo({
success: res => {
if(res.currentSize > 5120) {
removeStorage('search-history')
}
}
})
})
this.checkUpdate() // 检查更新
},
globalData: {
......@@ -47,18 +47,20 @@ export default {
// 检查更新
checkUpdate() {
if (wx.canIUse('getUpdateManager')) {
if (uni.canIUse('getUpdateManager')) {
const updateManager = uni.getUpdateManager()
// 请求完新版本信息的回调
// updateManager.onCheckForUpdate(res => {
// console.log(res.hasUpdate)
// })
updateManager.onCheckForUpdate(res => {
console.log(res.hasUpdate)
})
updateManager.onUpdateReady(() => {
uni.showModal({
title: '是否更新',
content: '新版本已经准备好,是否重启应用?',
success: res => {
if(res.confirm) updateManager.applyUpdate()
if(res.confirm) {
updateManager.applyUpdate()
}
}
})
})
......
......@@ -231,7 +231,6 @@ export default {
mixins: [common_share],
created() {
console.log(this.systemInfo)
// 实例化分页方法
this.loadmore = new LoadMore()
this.getHomeCate()
......
......@@ -106,6 +106,7 @@
</view>
</view>
<text class="version font-24">{{version}}</text>
</view>
</template>
......@@ -125,9 +126,11 @@ export default {
wait_receive: 0,
wait_send: 0
},
commentCounts: 0
commentCounts: 0,
version: ''
}
},
computed: {
...mapState({
token: state => state.user.token,
......@@ -135,6 +138,11 @@ export default {
})
},
created() {
const accountInfo = uni.getAccountInfoSync()
this.version = accountInfo.miniProgram.version
},
onShow() { // 获取更新用户信息
this.init()
},
......@@ -324,4 +332,12 @@ export default {
}
}
}
.version {
position: absolute;
left: 50%;
bottom: 10rpx;
transform: translateX(-50%);
color: #f9f9f9;
}
</style>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment