dev
jevononlie 5 months ago
parent 26c953ed97
commit 1e7a6e0ed0

@ -2,7 +2,7 @@
* @Author: 王文杰
* @Date: 2024-01-04 12:54:56
* @LastEditors: jevononlie 728254585@qq.com
* @LastEditTime: 2024-05-14 13:41:07
* @LastEditTime: 2024-05-14 14:28:33
* @FilePath: /app-nx-personal/src/App.vue
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
-->
@ -12,66 +12,60 @@ import { appUpdateApi } from '@/services/appUpdate'
onLaunch(async () => {
console.log('App Launch')
//#ifdef APP-PLUS
let version = '';
plus.runtime.getProperty(plus.runtime.appid, function (wgtinfo) {
if (wgtinfo.version) {
version = wgtinfo.version
} else {
version = plus.runtime.version
}
});
console.log('App Show-----',version)
const params = { //
appId: 'com.chanko.yunxi.mes.android'
}
const res = await appUpdateApi(params)
console.log('App Show-----', res)
plus.runtime.getProperty(plus.runtime.appid, function (wgtinfo) {
const version = wgtinfo.version || plus.runtime.version
if (res.versionId !== version) {
uni.showModal({ //
title: '更新提示',
title: '版本更新',
showCancel: false,
content: res.remark || '有新版本更新,请点击确定下载',
confirmText: '立即更新',
content: res.remark || 'APP有新版本发布点击 立即更新 进行最新版本下载。',
success: (res) => {
if (res.confirm) {
plus.runtime.openURL(res.url);
onSureClick(res.url)
}
}
})
}
})
//#endif
})
onShow(() => {
onShow(async () => {
//#ifdef APP-PLUS
console.log('App Show')
let version = '';
plus.runtime.getProperty(plus.runtime.appid, function (wgtinfo) {
if (wgtinfo.version) {
version = wgtinfo.version
} else {
version = plus.runtime.version
}
});
console.log('App Show-----',version)
const params = { //
appId: 'com.chanko.yunxi.mes.android'
}
const res = await appUpdateApi(params)
console.log('App Show-----', res)
if (res.versionId !== version) {
uni.showModal({ //
title: '更新提示',
showCancel: false,
content: res.remark || '有新版本更新,请点击确定下载',
success: (res) => {
if (res.confirm) {
plus.runtime.openURL(res.url);
}
}
})
}
//#endif
})
onHide(() => {
console.log('App Hide')
})
const onSureClick = (upDataUrl) => {
var downloadTask = uni.downloadFile({
url: upDataUrl,
success: (downloadResult) => {
if (downloadResult.statusCode === 200) {
plus.runtime.install(downloadResult.tempFilePath, {
force: false
}, function () {
plus.runtime.restart();
}, (e) => {
console.log(e)
uni.showToast({
title: '安装升级包失败',
icon: 'none'
})
});
}
}
});
//
downloadTask.onProgressUpdate((e) => {
//
})
}
</script>
<style lang="scss">

Loading…
Cancel
Save