|
|
@ -79,39 +79,11 @@ |
|
|
|
<view class="item" @click="$u.route({url:'/pages/home/news'})"> |
|
|
|
<text class="plant-xitongxiaoxi"/> <text>系统消息</text> <text class="number">{{$store.state.sysMsgNum}}</text> <text class="plant-youbian"/> |
|
|
|
</view> |
|
|
|
<view class="item" @click="getVersion"> |
|
|
|
<text class="plant-banbenhao"/> <text>检测更新</text> <text class="number">{{appVersion}}</text> <text class="plant-youbian"/> |
|
|
|
</view> |
|
|
|
<view class="item" @click="outLogin"> |
|
|
|
<text class="plant-tuichu"/> <text>退出</text> <text class="plant-youbian"/> |
|
|
|
</view> |
|
|
|
</view> |
|
|
|
|
|
|
|
<!-- 升级模态框 --> |
|
|
|
<u-modal |
|
|
|
:show="isShowModal" |
|
|
|
ref="modal" |
|
|
|
closeOnClickOverlay |
|
|
|
:confirm-text="modalOptions.okText" |
|
|
|
cancel-text="暂不升级" |
|
|
|
:async-close="modalOptions.asyncClose" |
|
|
|
:title="modalOptions.modalTitle" |
|
|
|
:content="modalOptions.modalContent" |
|
|
|
:show-confirm-button="true" |
|
|
|
:show-cancel-button="modalOptions.isShowCancel" |
|
|
|
@close="!modalOptions.isDownApp && (isShowModal=false)" |
|
|
|
@cancel="isShowModal=false" |
|
|
|
@confirm="upgrade"> |
|
|
|
<template v-if="modalOptions.isDownApp"> |
|
|
|
<u-circle-progress active-color="#2979ff" :percent="modalOptions.process" style="display:flex;margin:50rpx auto;"> |
|
|
|
<view class="u-progress-content"> |
|
|
|
<view class="u-progress-dot"></view> |
|
|
|
<text class='u-progress-info'>{{modalOptions.process}}%</text> |
|
|
|
</view> |
|
|
|
</u-circle-progress> |
|
|
|
</template> |
|
|
|
</u-modal> |
|
|
|
|
|
|
|
</view> |
|
|
|
</template> |
|
|
|
<script> |
|
|
@ -120,18 +92,6 @@ import request,{host} from '@/common/request' |
|
|
|
data(){ |
|
|
|
return{ |
|
|
|
host, |
|
|
|
appVersion:"", |
|
|
|
appDownLoadUrl:"", |
|
|
|
isShowModal:false, |
|
|
|
modalOptions:{ |
|
|
|
isShowCancel:true, |
|
|
|
isDownApp:false, |
|
|
|
modalContent:"请升级app到最新版本!", |
|
|
|
process:0, |
|
|
|
modalTitle:"监测到有新版本", |
|
|
|
okText:"立刻升级", |
|
|
|
asyncClose:true, |
|
|
|
}, |
|
|
|
} |
|
|
|
}, |
|
|
|
onLoad(options){ |
|
|
@ -140,12 +100,6 @@ import request,{host} from '@/common/request' |
|
|
|
uni.navigateTo({url:`/pages/purchase/${options.toPage}`}) |
|
|
|
} |
|
|
|
}) |
|
|
|
|
|
|
|
//#ifdef APP-PLUS |
|
|
|
plus.runtime.getProperty(plus.runtime.appid, async info=>{ |
|
|
|
this.appVersion = info.version |
|
|
|
}) |
|
|
|
//#endif |
|
|
|
}, |
|
|
|
onShow(){ |
|
|
|
this.$store.commit("setSysMsgShow",false) |
|
|
@ -168,74 +122,6 @@ import request,{host} from '@/common/request' |
|
|
|
} |
|
|
|
}) |
|
|
|
}, |
|
|
|
async getVersion(){ |
|
|
|
var res=await request("/appVersion/plantAppVersion/getAppVersion") |
|
|
|
if(res.statu){ |
|
|
|
if(res.data.appVersion!=this.appVersion){ |
|
|
|
this.isShowModal=true |
|
|
|
this.appDownLoadUrl=res.data.appDownloadUrl |
|
|
|
}else{ |
|
|
|
uni.showModal({ |
|
|
|
title:"提示", |
|
|
|
content:"当前版本已是最新版本!", |
|
|
|
showCancel:false, |
|
|
|
}) |
|
|
|
} |
|
|
|
}else{ |
|
|
|
uni.showModal({ |
|
|
|
title:"提示", |
|
|
|
content:res.msg||"获取版本号失败!", |
|
|
|
showCancel:false, |
|
|
|
}) |
|
|
|
} |
|
|
|
}, |
|
|
|
//下载最新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="下载升级包失败!" |
|
|
|
} |
|
|
|
}) |
|
|
|
console.log(dtask,'--dtask---') |
|
|
|
if(dtask){ |
|
|
|
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(); |
|
|
|
}else{ |
|
|
|
this.isShowModal=false |
|
|
|
this.modalOptions=this.$options.data().modalOptions |
|
|
|
uni.showModal({ |
|
|
|
title:"提示", |
|
|
|
content:"下载最新版本失败!", |
|
|
|
showCancel:false, |
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
|
//#endif |
|
|
|
}, |
|
|
|
}, |
|
|
|
} |
|
|
|
</script> |