This commit is contained in:
aihe 2024-06-16 02:31:52 +08:00
parent 9257d4018d
commit d815574e97

View File

@ -21,10 +21,12 @@ export const getCurrentAppInfo = ()=> {
}
const installNewApk = (url)=> {
console.log("installNewApk url===", url)
return new Promise((resolve, reject)=> {
let downInstance = uni.downloadFile({
url: url,
success: (downloadResult) => {
console.log("===downloadResult===", downloadResult)
hideLoading()
if (downloadResult.statusCode === 200) {
showLoading('正在安装...')
@ -41,11 +43,13 @@ const installNewApk = (url)=> {
reject()
});
} else {
showToast(`文件下载失败, 错误码:${downloadResult.statusCode}`)
reject()
}
},
fail: (err)=> {
console.log('download file err...', err);
console.log('download file err...', err);
showToast("文件下载失败")
hideLoading()
}
});
@ -61,8 +65,8 @@ const getLastAppInfo = async (curAppInfo)=> {
return {
version: '1.0.1',
versionCode: 101,
apkUrl: '',
wgtUrl: '',
apkUrl: 'http://localhost:5173/static/t.apk?t.apk',
wgtUrl: 'http://localhost:5173/static/t.wgt?t.wgt',
// whiteDeviceIds: ['F9E778C90D0E9A8DA9D95AA97B00A3FB'],
}
}
@ -97,8 +101,9 @@ export const checkUpdate = async ()=> {
let curAppInfo = await getCurrentAppInfo()
let lastAppInfo = await getLastAppInfo(curAppInfo)
let cmpRes = await compareInfo(curAppInfo, lastAppInfo)
console.log("checkUpdate cmpRes ====", cmpRes)
if(cmpRes.hasNewVersion) {
let fmBl = confirmModal(`app最新版本:${cmpRes.lastAppInfo.version}.${cmpRes.lastAppInfo.versionCode}, 是否更新?`)
let fmBl = await confirmModal(`app最新版本:${cmpRes.lastAppInfo.version}.${cmpRes.lastAppInfo.versionCode}, 是否更新?`)
if(fmBl) {
await installNewApk(cmpRes.url)
}