This commit is contained in:
aihe 2024-06-19 15:57:49 +08:00
parent 9e5ff8dc57
commit ed71aaab08
3 changed files with 25 additions and 6 deletions

View File

@ -18,6 +18,11 @@ export const getCurrentAppInfo = ()=> {
resolve(widgetInfo)
});
// #endif
// #ifndef APP-PLUS
// TODO MOCK数据
resolve({})
// #endif
})
}
@ -105,12 +110,17 @@ const compareInfo = (curAppInfo, lastAppInfo)=> {
}
}
export const checkUpdate = async ()=> {
export const getCompareVersion = async()=> {
let curAppInfo = await getCurrentAppInfo()
let lastAppInfo = await getLastAppInfo(curAppInfo)
let cmpRes = await compareInfo(curAppInfo, lastAppInfo)
console.log("checkUpdate cmpRes ====", cmpRes)
if(cmpRes.hasNewVersion && cmpRes.url) {
return cmpRes
}
export const checkUpdate = async ()=> {
let cmpRes = await getCompareVersion()
if(cmpRes.hasNewVersion) {
let fmBl = await confirmModal(`app最新版本:${cmpRes.lastAppInfo.version}.${cmpRes.lastAppInfo.versionCode}, 是否更新?`)
if(fmBl) {
await installNewApk(cmpRes.url)

View File

@ -69,3 +69,4 @@ export function createApp() {
}
}
// #endif

View File

@ -58,14 +58,19 @@
</view>
<view class="blk-mdl">
<view v-if="isAppChannel">
<view >
<u-row @click="handleCheckAppVersion" custom-style="padding: 30rpx;" justify="between">
<u-row>
<u-image :src="getCdnUrl(`mine/banbenup.png`)" height="34" width="34"></u-image>
<u-text margin="0 0 0 30rpx" text="版本更新" size="28" color="#333"></u-text>
</u-row>
<u-row>
<u-text margin="0 10rpx 0 0" :text="curAppVersion" size="28" color="#666"></u-text>
<view>
<view v-if="chkVRes.hasNewVersion" class="com-tag-grey">
<text class="clr-prm">新版本</text>
</view>
<u-text v-else margin="0 10rpx 0 0" :text="curAppVersion" size="28" color="#666"></u-text>
</view>
<u-icon name="arrow-right" size="32" color="#333"></u-icon>
</u-row>
</u-row>
@ -135,7 +140,7 @@
import * as apiService from "@/common/api"
import { setSessionSystemInfo, getSessionSystemInfo } from "@/session"
import { getAuthList, authCodeEnum } from "@/common/authCode"
import { getCurrentAppInfo, getSystemInfo, checkUpdate } from "@/common/appUpdate"
import { getCurrentAppInfo, getSystemInfo, checkUpdate, getCompareVersion } from "@/common/appUpdate"
export default {
computed: {
@ -173,6 +178,7 @@
},
saomiao: true,
curAppVersion: '',
chkVRes: {},
curDeviceId: '',
hongWaiSwitch,
}
@ -194,6 +200,8 @@
this.curDeviceId = getSystemInfo()?.deviceId
let appRes = await getCurrentAppInfo()
this.curAppVersion = appRes._appVersion
this.chkVRes = await getCompareVersion()
},
async getAppHomeStatData(){
let res = await apiService.getAppHomeStatData()
@ -205,7 +213,7 @@
},
async handleCheckAppVersion() {
let ckRes = await checkUpdate()
if(!(ckRes.hasNewVersion && ckRes.url)) {
if(!(ckRes.hasNewVersion)) {
this.showToast('已经是最新版本,无需更新')
}
},