Commit 3a8ecc99 authored by June's avatar June

添加版本号

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