Commit 4af0ed5f authored by Facius's avatar Facius

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

parent 85c30197
<template> <template>
<view class="upload-progress"> <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="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> <image class="icon" :src="icon"></image>
</view> </view>
</view> </view>
...@@ -66,17 +66,19 @@ ...@@ -66,17 +66,19 @@
data() { data() {
return { return {
open: false, open: false,
progressStatus: false progressStatus: false,
clicked: 1
} }
}, },
computed: { computed: {
icon() { icon() {
console.log(process.uniEnv.qn_base_url + 'upload-photo.png')
return process.uniEnv.qn_base_url + 'upload-photo.png' return process.uniEnv.qn_base_url + 'upload-photo.png'
}, },
defaultImg() { defaultImg() {
return process.uniEnv.qn_base_url + 'upload-default.png' return process.uniEnv.qn_base_url + 'upload-default.png'
}, },
taskCount() { taskCount() {
return this.uploadTotal return this.uploadTotal
}, },
uploadStatusName() { uploadStatusName() {
...@@ -101,7 +103,7 @@ ...@@ -101,7 +103,7 @@
const num = this.uploadSuccess const num = this.uploadSuccess
const total = this.uploadTotal const total = this.uploadTotal
return total > 0 ? Math.floor(Math.round(num / total * 10000) / 100.00) : 0 return total > 0 ? Math.floor(Math.round(num / total * 10000) / 100.00) : 0
} },
}, },
watch: { watch: {
uploadStatus(newValue) { uploadStatus(newValue) {
...@@ -109,13 +111,22 @@ ...@@ -109,13 +111,22 @@
this.$nextTick(() => { this.$nextTick(() => {
this.progressStatus = true this.progressStatus = true
}) })
} },
}, open(val) {
if (val == false) {
this.changeActive()
}
},
},
created() {
this.changeActive()
},
methods: { methods: {
closePopup() { closePopup() {
this.progressStatus = false this.progressStatus = false
}, },
openpRrogress() { openpRrogress() {
this.clicked += 1
this.open = true this.open = true
this.progressStatus = false this.progressStatus = false
setTimeout(() => { setTimeout(() => {
...@@ -124,7 +135,13 @@ ...@@ -124,7 +135,13 @@
}, },
retry() { retry() {
if(this.uploadStatus !== 2) upload.uploadImageTask(this) if(this.uploadStatus !== 2) upload.uploadImageTask(this)
} },
changeActive() {
setTimeout(() => {
// 三秒不点击,算失去活跃
this.clicked = Math.max(0, this.clicked - 1)
}, 3000)
}
} }
} }
</script> </script>
...@@ -135,16 +152,20 @@ ...@@ -135,16 +152,20 @@
height: 100%; height: 100%;
.suspension { .suspension {
position: fixed; position: fixed;
right: 5%; right: 20rpx;
bottom: 20%; bottom: 20%;
width: 80rpx; width: 80rpx;
height: 80rpx; height: 80rpx;
border-radius: 50%; border-radius: 50%;
background: #2272FF; background: #2272FF;
z-index: 999; z-index: 999;
opacity: 1;
&.error { &.error {
background: #FA5A49; background: #FA5A49;
} }
&.no-active {
opacity: 0.6;
}
.progress { .progress {
font-size: 24rpx; font-size: 24rpx;
color: #fff; 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