Commit 4af0ed5f authored by Facius's avatar Facius

improve: 上传进度三秒不点击变半透明

parent 85c30197
<template>
<view class="upload-progress">
<view :class="['u-flex', 'suspension', {'error': uploadStatus === 3}]" @click="openpRrogress">
<view :class="['u-flex', 'suspension', {'error': uploadStatus === 3, 'no-active': clicked <= 0}]" @click="openpRrogress">
<view class="progress" v-if="taskCount > 0">{{ uploadPercentage }}%</view>
<view class="upload-img" v-if="taskCount === 0">
<view class="upload-img" v-else>
<image class="icon" :src="icon"></image>
</view>
</view>
......@@ -66,17 +66,19 @@
data() {
return {
open: false,
progressStatus: false
progressStatus: false,
clicked: 1
}
},
computed: {
icon() {
icon() {
console.log(process.uniEnv.qn_base_url + 'upload-photo.png')
return process.uniEnv.qn_base_url + 'upload-photo.png'
},
defaultImg() {
return process.uniEnv.qn_base_url + 'upload-default.png'
},
taskCount() {
taskCount() {
return this.uploadTotal
},
uploadStatusName() {
......@@ -101,7 +103,7 @@
const num = this.uploadSuccess
const total = this.uploadTotal
return total > 0 ? Math.floor(Math.round(num / total * 10000) / 100.00) : 0
}
},
},
watch: {
uploadStatus(newValue) {
......@@ -109,13 +111,22 @@
this.$nextTick(() => {
this.progressStatus = true
})
}
},
},
open(val) {
if (val == false) {
this.changeActive()
}
},
},
created() {
this.changeActive()
},
methods: {
closePopup() {
this.progressStatus = false
},
openpRrogress() {
openpRrogress() {
this.clicked += 1
this.open = true
this.progressStatus = false
setTimeout(() => {
......@@ -124,7 +135,13 @@
},
retry() {
if(this.uploadStatus !== 2) upload.uploadImageTask(this)
}
},
changeActive() {
setTimeout(() => {
// 三秒不点击,算失去活跃
this.clicked = Math.max(0, this.clicked - 1)
}, 3000)
}
}
}
</script>
......@@ -135,16 +152,20 @@
height: 100%;
.suspension {
position: fixed;
right: 5%;
right: 20rpx;
bottom: 20%;
width: 80rpx;
height: 80rpx;
border-radius: 50%;
background: #2272FF;
z-index: 999;
z-index: 999;
opacity: 1;
&.error {
background: #FA5A49;
}
}
&.no-active {
opacity: 0.6;
}
.progress {
font-size: 24rpx;
color: #fff;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment