dev
jevononlie 5 months ago
parent 26c953ed97
commit 1e7a6e0ed0

@ -2,7 +2,7 @@
* @Author: 王文杰 * @Author: 王文杰
* @Date: 2024-01-04 12:54:56 * @Date: 2024-01-04 12:54:56
* @LastEditors: jevononlie 728254585@qq.com * @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 * @FilePath: /app-nx-personal/src/App.vue
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE * @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 () => { onLaunch(async () => {
console.log('App Launch') console.log('App Launch')
//#ifdef APP-PLUS //#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 = { // const params = { //
appId: 'com.chanko.yunxi.mes.android' appId: 'com.chanko.yunxi.mes.android'
} }
const res = await appUpdateApi(params) const res = await appUpdateApi(params)
console.log('App Show-----', res) plus.runtime.getProperty(plus.runtime.appid, function (wgtinfo) {
if (res.versionId !== version) { const version = wgtinfo.version || plus.runtime.version
uni.showModal({ // if (res.versionId !== version) {
title: '更新提示', uni.showModal({ //
showCancel: false, title: '版本更新',
content: res.remark || '有新版本更新,请点击确定下载', showCancel: false,
success: (res) => { confirmText: '立即更新',
if (res.confirm) { content: res.remark || 'APP有新版本发布点击 立即更新 进行最新版本下载。',
plus.runtime.openURL(res.url); success: (res) => {
if (res.confirm) {
onSureClick(res.url)
}
} }
} })
}) }
} })
//#endif //#endif
}) })
onShow(() => { onShow(async () => {
//#ifdef APP-PLUS
console.log('App Show') console.log('App Show')
let version = ''; //#endif
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);
}
}
})
}
}) })
onHide(() => { onHide(() => {
console.log('App Hide') 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> </script>
<style lang="scss"> <style lang="scss">

Loading…
Cancel
Save