diff --git a/pages/home/my.vue b/pages/home/my.vue
index 6595c5b..f67b359 100644
--- a/pages/home/my.vue
+++ b/pages/home/my.vue
@@ -79,19 +79,19 @@
系统消息 {{$store.state.sysMsgNum}}
-
+
退出
- sfsdf
@@ -119,7 +121,8 @@ import request,{host} from '@/common/request'
return{
host,
appVersion:"1.0.0",
- isShowModal:true,
+ appDownLoadUrl:"",
+ isShowModal:false,
modalOptions:{
isShowCancel:true,
isDownApp:false,
@@ -167,9 +170,11 @@ import request,{host} from '@/common/request'
},
async getVersion(){
var res=await request("/appVersion/plantAppVersion/getAppVersion")
- console.log(res,res.data.appVersion,'---------res----------')
if(res.statu){
- this.isShowModal=true
+ if(res.data.appVersion!=this.appVersion){
+ this.isShowModal=true
+ this.appDownLoadUrl=res.data.appDownloadUrl
+ }
}else{
uni.showModal({
title:"提示",
@@ -178,7 +183,42 @@ import request,{host} from '@/common/request'
})
}
},
- upgrade(){},
+ //下载最新app
+ upgrade(){
+ //#ifdef APP-PLUS
+ if(this.modalOptions.isShowCancel){
+ this.modalOptions.modalTitle="开始下载"
+ this.modalOptions.isDownApp=true
+ this.modalOptions.isShowCancel=false
+ var dtask=plus.downloader.createDownload(this.appDownLoadUrl,{
+ filename: "_downloads/",
+ timeout:30,
+ retry:1
+ },(d,status)=>{
+ this.modalOptions.isDownApp=false
+ this.modalOptions.asyncClose=false
+ this.modalOptions.okText="确认"
+ this.$refs.modal.clearLoading()
+ if(status == 200){
+ plus.runtime.install(d.filename,{force:true},()=>plus.runtime.restart(), e=>{
+ this.modalOptions.modalTitle="提示"
+ this.modalOptions.modalContent="安装升级包失败!"
+ })
+ }else{
+ this.modalOptions.modalTitle="提示"
+ this.modalOptions.modalContent="下载升级包失败!"
+ }
+ })
+ dtask.addEventListener("statechanged",e=>{
+ if(e&&e.totalSize>0){
+ // console.log("state",e.state,"::::","--------statechanged-----------",e.downloadedSize)
+ this.modalOptions.process=Math.floor((e.downloadedSize/e.totalSize)*10000)/100
+ }
+ },false)
+ dtask.start();
+ }
+ //#endif
+ },
},
}
\ No newline at end of file