Browse Source

版本更新

master
邓宏 2 years ago
parent
commit
549f942103
  1. 56
      pages/home/my.vue

56
pages/home/my.vue

@ -79,19 +79,19 @@
<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">
<view class="item" @click="getVersion">
<text class="plant-banbenhao"/> <text>检测更新</text> <text class="number">{{appVersion}}</text> <text class="plant-youbian"/>
</view> -->
</view>
<view class="item" @click="outLogin">
<text class="plant-tuichu"/> <text>退出</text> <text class="plant-youbian"/>
</view>
</view>
<!-- 升级模态框 -->
<u-modal v-model="isShowModal">sfsdf</u-modal>
<u-modal
v-model="isShowModal"
:show="isShowModal"
ref="modal"
closeOnClickOverlay
:confirm-text="modalOptions.okText"
cancel-text="暂不升级"
:async-close="modalOptions.asyncClose"
@ -99,6 +99,8 @@
:content="modalOptions.modalContent"
:show-confirm-button="true"
:show-cancel-button="modalOptions.isShowCancel"
@close="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;">
@ -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
},
},
}
</script>
Loading…
Cancel
Save