Browse Source

修改版本更新弹框功能

master
邓宏 7 months ago
parent
commit
e04e4034e3
  1. 45
      pages/home/login.vue

45
pages/home/login.vue

@ -71,13 +71,16 @@
:content="modalOptions.modalContent"
:show-confirm-button="true"
:show-cancel-button="modalOptions.isShowCancel"
@close="!modalOptions.isDownApp && (isShowModal=false)"
@close="modalOptions.isShowCancel&&(isShowModal=false)"
@cancel="isShowModal=false"
@confirm="upgrade"/>
@confirm="upgrade">
<text v-if="!modalOptions.isShowCancel&&modalOptions.asyncClose" style="width:200rpx;height:200rpx;background-size:contain" :style='{backgroundImage:`url("${icon}")`}'/>
</u-modal>
</view>
</template>
<script>
import request,{host} from "@/common/request"
import {SVGToBase64} from 'black-knight/lib/config/tools'
export default {
data(){
return{
@ -94,22 +97,33 @@ export default {
isShowModal:false,
modalOptions:{
isShowCancel:true,
isDownApp:false,
modalContent:"请升级app到最新版本!",
process:0,
modalTitle:"测到有新版本",
modalTitle:"测到有新版本",
okText:"立刻升级",
asyncClose:true,
},
}
},
computed:{
icon(){
return SVGToBase64(`
<svg width="440" height="440">
<circle cx="220" cy="220" r="170" stroke-width="50" stroke="#D1D3D7" fill="none"></circle>
<circle cx="220" cy="220" r="170" stroke-width="50" stroke="#10C176" stroke-linecap="round" fill="none" transform="matrix(0,-1,1,0,0,440)" stroke-dasharray="${this.modalOptions.process/100*Math.PI*2*170} 1069"></circle>
<text x="220" y="240" font-size="75" text-anchor="middle">${this.modalOptions.process}%</text>
</svg>
`)
}
},
onLoad(options){
this.formData.username=options.phone||uni.getStorageSync('username')||""
if(process.env.NODE_ENV === 'development'){
this.formData.username="18788469459"
this.formData.password="1qaz@WSX"
}
//#ifdef APP-PLUS
this.getVersion()
plus.runtime.getProperty(plus.runtime.appid, async info=>{
@ -143,30 +157,26 @@ export default {
params:{type:1}
})
if(res.statu){
console.log(res.data.appVersionCode,'当前运行版本号----')
console.log(this.versionCode,'当前运行版本号----')
console.log(res.data.appVersionCode,'最新版本号----')
if(res.data.appVersionCode > this.versionCode){
this.isShowModal=true
this.appDownLoadUrl=host("version",res.data.appDownloadUrl)
}
this.appDownLoadUrl=host("version",res.data.appDownloadUrl)
this.isShowModal=true//res.data.appVersionCode > this.versionCode
}
},
//app
upgrade(){
//#ifdef APP-PLUS
if(this.modalOptions.isShowCancel){
// #ifdef APP-PLUS
if(this.modalOptions.asyncClose){
this.modalOptions.modalTitle="开始下载"
this.modalOptions.modalContent="下载中..."
this.modalOptions.isDownApp=true
this.modalOptions.isShowCancel=false
console.log(this.appDownLoadUrl,'-----url----')
var dtask=plus.downloader.createDownload(this.appDownLoadUrl,{
filename: "_downloads/",
timeout:30,
retry:1
},(d,status)=>{
console.log(d,status,'----111----')
this.modalOptions.isDownApp=false
this.modalOptions.asyncClose=false
this.modalOptions.okText="确认"
this.$refs.modal.loading=false
@ -180,7 +190,6 @@ export default {
this.modalOptions.modalContent="下载升级包失败!"
}
})
console.log(dtask,'--dtask----')
if(dtask){
dtask.addEventListener("statechanged",e=>{
// console.log(`totalSize:${e.totalSize};downloadedSize:${e.downloadedSize}`)

Loading…
Cancel
Save