Commit 7056795c authored by Facius's avatar Facius

Merge branch 'dev-1.5.4' of https://git.banshouhui.com/lijundan/self-support into dev-1.5.4

parents f3c2325d fa4d5651
<template> <template>
<view class="upload-progress"> <view class="upload-progress">
<view :class="['u-flex', 'suspension', {'error': uploadStatus === 3, 'no-active': clicked <= 0}]" @click="openpRrogress"> <view
id="_drag_button"
:class="[
'u-flex',
'suspension',
{ error: uploadStatus === 3, 'no-active': clicked <= 0 },
]"
@touchstart.capture="touchstart"
@touchend.capture="touchend"
@touchmove.capture="touchmove"
:style="{
left: left + 'px',
top: top + 'px',
}"
@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-else> <view class="upload-img" v-else>
<image class="icon" :src="icon"></image> <image class="icon" :src="icon"></image>
</view> </view>
</view> </view>
<u-popup <u-popup
v-model="open" v-model="open"
border-radius="12" border-radius="12"
mode="center" mode="center"
:animation="false" :animation="false"
@close="closePopup" @close="closePopup"
width="690rpx"> width="690rpx"
<view class="slot-content"> >
<view class="slot-content">
<view class="upload-title"> <view class="upload-title">
<text class='status-txt'>图片上传进度</text> <text class="status-txt">图片上传进度</text>
</view> </view>
<view v-if="taskCount > 0"> <view v-if="taskCount > 0">
<view class="progress-circle"> <view class="progress-circle">
<u-loading class="loading" v-if="!progressStatus" mode="circle"></u-loading> <u-loading
<u-circle-progress v-if="progressStatus" :width="320" :border-width="20" inactive-color="#F4F5F7" :active-color="progressColor" :percent="uploadPercentage"> class="loading"
<view :class="['u-progress-content', {'error': uploadStatus === 3}]"> {{ uploadPercentage }}%</view> v-if="!progressStatus"
mode="circle"
></u-loading>
<u-circle-progress
v-if="progressStatus"
:width="320"
:border-width="20"
inactive-color="#F4F5F7"
:active-color="progressColor"
:percent="uploadPercentage"
>
<view
:class="['u-progress-content', { error: uploadStatus === 3 }]"
>
{{ uploadPercentage }}%</view
>
</u-circle-progress> </u-circle-progress>
</view> </view>
<view class="u-flex upload-data"> <view class="u-flex upload-data">
<view class="u-flex"> <view class="u-flex">
<view class="title">需上传</view> <view class="title">需上传</view>
...@@ -38,12 +69,16 @@ ...@@ -38,12 +69,16 @@
</view> </view>
<view class="u-flex"> <view class="u-flex">
<view class="title">状态</view> <view class="title">状态</view>
<view :class="['status', {'error': uploadStatus === 3}]">{{ uploadStatusName }}</view> <view :class="['status', { error: uploadStatus === 3 }]">{{
uploadStatusName
}}</view>
</view> </view>
</view> </view>
<view class="upload-bottom" v-if="uploadStatus === 3"> <view class="upload-bottom" v-if="uploadStatus === 3">
<view class="button confirm" @click="$u.throttle(retry, 500)">重试</view> <view class="button confirm" @click="$u.throttle(retry, 500)"
>重试</view
>
</view> </view>
</view> </view>
...@@ -51,227 +86,326 @@ ...@@ -51,227 +86,326 @@
<view><image class="default-img" :src="defaultImg"></image></view> <view><image class="default-img" :src="defaultImg"></image></view>
<view class="text">当前暂无上传图片</view> <view class="text">当前暂无上传图片</view>
</view> </view>
</view> </view>
</u-popup> </u-popup>
</view> </view>
</template> </template>
<script> <script>
/** /**
* upload-progress 图片上传进度 * upload-progress 图片上传进度
*/ */
import upload from '@/components/upload/task.js' import upload from '@/components/upload/task.js'
export default { const sys = uni.getSystemInfoSync()
name:"upload-progress", export default {
data() { name: 'upload-progress',
return { props: {
open: false, // 是否启用自动停靠
progressStatus: false, isDock: {
clicked: 1 type: Boolean,
} default: false,
},
computed: {
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() {
return this.uploadTotal
},
uploadStatusName() {
let status
switch (this.uploadStatus) {
case 1:
status = '等待上传'
break;
case 2:
status = '上传中'
break;
case 3:
status = '上传中断'
break;
}
return status
},
progressColor() {
return this.uploadStatus === 3 ? '#FA5A49' : '#2272FF'
},
uploadPercentage() {
const num = this.uploadSuccess
const total = this.uploadTotal
return total > 0 ? Math.floor(Math.round(num / total * 10000) / 100.00) : 0
},
}, },
watch: { // 当前页面是否包含tabbar
uploadStatus(newValue) { existTabBar: {
this.progressStatus = false type: Boolean,
this.$nextTick(() => { default: false,
this.progressStatus = true },
}) },
}, data() {
open(val) { return {
if (val == false) { open: false,
this.changeActive() progressStatus: false,
} clicked: 1,
}, top: sys.windowHeight - 80,
}, left: sys.windowWidth - 50,
created() { width: 0,
this.changeActive() height: 0,
}, offsetWidth: 0,
methods: { offsetHeight: 0,
closePopup() { windowWidth: 0,
this.progressStatus = false windowHeight: 0,
}, isMove: true,
openpRrogress() { edge: 10,
this.clicked += 1
this.open = true
this.progressStatus = false
setTimeout(() => {
this.progressStatus = true
}, 300)
},
retry() {
if(this.uploadStatus !== 2) upload.uploadImageTask(this)
},
changeActive() {
setTimeout(() => {
// 三秒不点击,算失去活跃
this.clicked = Math.max(0, this.clicked - 1)
}, 3000)
}
} }
} },
computed: {
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() {
return this.uploadTotal
},
uploadStatusName() {
let status
switch (this.uploadStatus) {
case 1:
status = '等待上传'
break
case 2:
status = '上传中'
break
case 3:
status = '上传中断'
break
}
return status
},
progressColor() {
return this.uploadStatus === 3 ? '#FA5A49' : '#2272FF'
},
uploadPercentage() {
const num = this.uploadSuccess
const total = this.uploadTotal
return total > 0
? Math.floor(Math.round((num / total) * 10000) / 100.0)
: 0
},
},
watch: {
uploadStatus(newValue) {
this.progressStatus = false
this.$nextTick(() => {
this.progressStatus = true
})
},
open(val) {
if (val == false) {
this.changeActive()
}
},
},
created() {
this.changeActive()
},
mounted() {
this.windowWidth = sys.windowWidth
this.windowHeight = sys.windowHeight
// #ifdef APP-PLUS
this.existTabBar && (this.windowHeight -= 50)
// #endif
if (sys.windowTop) {
this.windowHeight += sys.windowTop
}
const query = uni.createSelectorQuery().in(this)
query
.select('#_drag_button')
.boundingClientRect((data) => {
this.width = data.width
this.height = data.height
this.offsetWidth = data.width / 2
this.offsetHeight = data.height / 2
// this.left = this.windowWidth - this.width - this.edge
// this.top = this.windowHeight - this.height - this.edge
})
.exec()
},
methods: {
closePopup() {
this.progressStatus = false
},
openpRrogress() {
this.clicked += 1
this.open = true
this.progressStatus = false
setTimeout(() => {
this.progressStatus = true
}, 300)
},
retry() {
if (this.uploadStatus !== 2) upload.uploadImageTask(this)
},
changeActive() {
setTimeout(() => {
// 三秒不点击,算失去活跃
this.clicked = Math.max(0, this.clicked - 1)
}, 3000)
},
touchstart(e) {},
touchend(e) {
if (this.isDock) {
let edgeRigth = this.windowWidth - this.width - this.edge
if (this.left < this.windowWidth / 2 - this.offsetWidth) {
this.left = this.edge
} else {
this.left = edgeRigth
}
}
this.isMove = false
},
touchmove(e) {
// 单指触摸
if (e.touches.length !== 1) {
return false
}
this.isMove = true
let clientY = e.touches[0].clientY - this.offsetHeight
// #ifdef H5
clientY += this.height
// #endif
let edgeBottom = this.windowHeight - this.height - this.edge
// 上下触及边界
if (clientY < this.edge) {
this.top = this.edge
} else if (clientY > edgeBottom) {
this.top = edgeBottom
} else {
this.top = clientY
}
let clientX = e.touches[0].clientX - this.offsetWidth
// #ifdef H5
clientX += this.width
// #endif
let edgeLeft = this.windowWidth - this.width - this.edge
// 左右触及边界
if (clientX < this.edge) {
this.left = this.edge
} else if (clientX > edgeLeft) {
this.left = edgeLeft
} else {
this.left = clientX
}
},
},
}
</script> </script>
<style lang="scss"> <style lang="scss">
.upload-progress { .upload-progress {
width: 100%; width: 100%;
height: 100%; height: 100%;
.suspension { .suspension {
position: fixed; position: fixed;
right: 20rpx; width: 80rpx;
bottom: 20%; height: 80rpx;
width: 80rpx; border-radius: 50%;
height: 80rpx; background: #2272ff;
border-radius: 50%; z-index: 999;
background: #2272FF; opacity: 1;
z-index: 999; &.error {
opacity: 1; background: #fa5a49;
&.error { }
background: #FA5A49; &.no-active {
} opacity: 0.6;
&.no-active { }
opacity: 0.6; .progress {
} font-size: 24rpx;
.progress { color: #fff;
font-size: 24rpx; width: 100%;
color: #fff; text-align: center;
width: 100%; }
text-align: center; .upload-img {
width: 100%;
text-align: center;
padding-top: 8rpx;
.icon {
width: 36rpx;
height: 32rpx;
} }
.upload-img { }
width: 100%; }
text-align: center; .slot-content {
padding-top: 8rpx; padding: 40rpx 30rpx 30rpx 30rpx;
.icon { .upload-title {
width: 36rpx; margin: 20rpx 0 50rpx 0;
height: 32rpx; display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
.status-txt {
height: 46rpx;
font-size: 40rpx;
font-weight: bold;
color: #333;
line-height: 46rpx;
}
}
.progress-circle {
width: 100%;
height: 320rpx;
text-align: center;
.loading {
line-height: 320rpx;
}
.u-progress-content {
color: #2272ff;
font-size: 60rpx;
&.error {
color: #fa5a49;
} }
} }
} }
.slot-content { .upload-data {
padding: 40rpx 30rpx 30rpx 30rpx; margin: 50rpx 0 30rpx 0;
.upload-title { .u-flex {
margin: 20rpx 0 50rpx 0; flex-flow: column;
display: flex; font-size: 48rpx;
flex-direction: column; width: 210rpx;
justify-content: center; height: 120rpx;
align-items: center; .title {
.status-txt { color: #666;
height: 46rpx; font-size: 28rpx;
font-size: 40rpx; padding-bottom: 20rpx;
font-weight: bold; }
.pending {
color: #333; color: #333;
line-height: 46rpx;
} }
} .resolve {
.progress-circle { color: #2272ff;
width: 100%;
height: 320rpx;
text-align: center;
.loading {
line-height: 320rpx;
} }
.u-progress-content { .status {
color: #2272FF; color: #2272ff;
font-size: 60rpx; font-size: 36rpx;
&.error { &.error {
color: #FA5A49; color: #fa5a49;
} }
} }
} }
.upload-data { }
margin: 50rpx 0 30rpx 0; .upload-bottom {
.u-flex { display: flex;
flex-flow: column; justify-content: center;
font-size: 48rpx; align-items: center;
width: 210rpx; .button {
height: 120rpx; text-align: center;
.title { height: 104rpx;
color: #666; width: 300rpx;
font-size: 28rpx; border-radius: 52rpx;
padding-bottom: 20rpx; font-size: 32rpx;
} font-weight: 600;
.pending { line-height: 104rpx;
color: #333;
}
.resolve {
color: #2272FF;
}
.status {
color: #2272FF;
font-size: 36rpx;
&.error {
color: #FA5A49;
}
}
}
} }
.upload-bottom { .confirm {
display: flex; margin: 36rpx 30rpx 52rpx 15rpx;
justify-content: center; background: #2272ff;
align-items: center; color: #ffffff;
.button {
text-align: center;
height: 104rpx;
width: 300rpx;
border-radius: 52rpx;
font-size: 32rpx;
font-weight: 600;
line-height: 104rpx;
}
.confirm {
margin: 36rpx 30rpx 52rpx 15rpx;
background: #2272FF;
color: #FFFFFF;
}
} }
.default { }
flex-flow: column; .default {
margin: 150rpx 0; flex-flow: column;
.default-img { margin: 150rpx 0;
width: 360rpx; .default-img {
height: 240rpx; width: 360rpx;
} height: 240rpx;
.text { }
color: #666; .text {
font-size: 28rpx; color: #666;
margin-top: 50rpx; font-size: 28rpx;
} margin-top: 50rpx;
} }
} }
} }
}
</style> </style>
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