Commit d13d82df authored by Damon's avatar Damon

merge

parents 8f8d2e8e b6b87dd5
......@@ -4,6 +4,8 @@ import { AnalysysAgent } from "@/utils/analysys_paas.js";
import util from "@/utils/util.js";
import login from "@/utils/login.js";
import upload from '@/components/upload/task.js'
import { ERROR } from "@/common/log.js"
export default {
globalData: {
// 开发环境
......@@ -74,8 +76,6 @@ export default {
this.getSystemInfo();
// 系统自动登录::每次运行小程序重新获取用户信息
await this.autoLogin();
//this.deleteTempImg()
},
onShow: function () {
// 应用启动,或从后台进入前台显示
......@@ -85,6 +85,9 @@ export default {
},
onHide: function () {
// 应用从前台进入后台
// if (this.uploadTask.length > 0) {
// ERROR('onUnload', {task: this.uploadTask.length, mobile: this.vuex_user.mobile})
// }
},
watch: {
uploadTask: function(newValue, oldValue) {
......@@ -92,18 +95,6 @@ export default {
}
},
methods: {
// 处理已上传完成的图片
deleteTempImg() {
const result = uni.getStorageSync('delImg')
if (result.length > 0) {
for (let i of result) {
uni.removeSavedFile({
filePath: i
})
}
uni.setStorageSync('delImg', [])
}
},
getSystemInfo() {
try {
let a = this.$u.sys();
......
......@@ -76,6 +76,9 @@ const install = (Vue, vm) => {
function getMsg(res){
const result = res.data || res
let msg = result.message || result.errMsg || res.message || res.errMsg
if (msg.indexOf('request:fail') !== -1) {
msg = '当前网络较差,请重试'
}
if(res.code == 200 || res.status == true || msg) {
return msg
}
......
......@@ -17,7 +17,7 @@
@click.stop="prviewImage(item, index)"
fade
lazy-load
></u-image>
><view slot="error" style="font-size: 24rpx;">上传中</view></u-image>
<view
class="icon-del-box"
v-if="!disabled"
......
<template>
<view class="upload-progress">
<view :class="['u-flex', 'suspension', {'error': uploadStatus === 3}]" @click="openpRrogress">
<view class="progress" v-if="taskCount > 0">{{ uploadPercentage }}%</view>
<view class="upload-img" v-if="taskCount === 0">
<image class="icon" :src="icon"></image>
</view>
</view>
<u-popup
v-model="open"
border-radius="12"
mode="center"
:animation="false"
@close="closePopup"
width="690rpx">
<view class="slot-content">
<view class="upload-title">
<text class='status-txt'>图片上传进度</text>
</view>
<view v-if="taskCount > 0">
<view class="progress-circle">
<u-loading class="loading" 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>
</view>
<view class="u-flex upload-data">
<view class="u-flex">
<view class="title">需上传</view>
<view class="pending">{{ taskCount }}</view>
</view>
<view class="u-flex">
<view class="title">已上传</view>
<view class="resolve">{{ uploadSuccess }}</view>
</view>
<view class="u-flex">
<view class="title">状态</view>
<view :class="['status', {'error': uploadStatus === 3}]">{{ uploadStatusName }}</view>
</view>
</view>
<view class="upload-bottom" v-if="uploadStatus === 3">
<view class="button confirm" @click="$u.throttle(retry, 500)">重试</view>
</view>
</view>
<view class="u-flex default" v-if="taskCount === 0">
<view><image class="default-img" :src="defaultImg"></image></view>
<view class="text">当前暂无上传图片</view>
</view>
</view>
</u-popup>
</view>
</template>
<script>
/**
* upload-progress 图片上传进度
*/
import upload from '@/components/upload/task.js'
export default {
name:"upload-progress",
data() {
return {
open: false,
progressStatus: false
}
},
computed: {
icon() {
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: {
uploadStatus(newValue) {
this.progressStatus = false
this.$nextTick(() => {
this.progressStatus = true
})
}
},
methods: {
closePopup() {
this.progressStatus = false
},
openpRrogress() {
this.open = true
this.progressStatus = false
setTimeout(() => {
this.progressStatus = true
}, 300)
},
retry() {
if(this.uploadStatus !== 2) upload.uploadImageTask(this)
}
}
}
</script>
<style lang="scss" scoped>
.upload-progress {
width: 100%;
height: 100%;
.suspension {
position: fixed;
right: 5%;
bottom: 20%;
width: 80rpx;
height: 80rpx;
border-radius: 50%;
background: #2272FF;
&.error {
background: #FA5A49;
}
.progress {
font-size: 24rpx;
color: #fff;
width: 100%;
text-align: center;
}
.upload-img {
width: 100%;
text-align: center;
padding-top: 8rpx;
.icon {
width: 36rpx;
height: 32rpx;
}
}
}
.slot-content {
padding: 40rpx 30rpx 0rpx 30rpx;
.upload-title {
margin: 20rpx 0 50rpx 0;
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;
}
}
}
.upload-data {
margin: 50rpx 0 30rpx 0;
.u-flex {
flex-flow: column;
font-size: 48rpx;
width: 210rpx;
height: 120rpx;
.title {
color: #666;
font-size: 28rpx;
padding-bottom: 20rpx;
}
.pending {
color: #333;
}
.resolve {
color: #2272FF;
}
.status {
color: #2272FF;
font-size: 36rpx;
&.error {
color: #FA5A49;
}
}
}
}
.upload-bottom {
display: flex;
justify-content: center;
align-items: center;
.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;
margin: 150rpx 0;
.default-img {
width: 360rpx;
height: 240rpx;
}
.text {
color: #666;
font-size: 28rpx;
margin-top: 50rpx;
}
}
}
}
</style>
......@@ -69,14 +69,14 @@ export default {
...order
}
})
// for (let i = 0; i < files.length; i++) {
// const path = files[i]
// const row = await this.saveFiles(path)
// lists.push(row)
// }
const data = JSON.parse(JSON.stringify(this.uploadTask))
const saveLists = data.concat(lists)
this.$u.vuex('uploadTask', saveLists)
const newTotal = this.uploadTotal + lists.length
this.$u.vuex('uploadTotal', newTotal)
//this.$u.vuex('uploadSuccess', 0)
return lists
},
/**
......
......@@ -19,6 +19,9 @@ export default {
* 执行任务队列
*/
async uploadImageTask(that) {
if (that.uploadStatus === 2) return
that.$u.vuex('uploadStatus', 2)
const uploadTask = JSON.parse(JSON.stringify(that.uploadTask)).reverse()
const networkType = await getNetworkType()
const options = {
......@@ -41,10 +44,12 @@ export default {
}
uploader.qnFileUpload(options).then(res => {
const newSuccess = that.uploadSuccess + res.length
that.$u.vuex('uploadSuccess', newSuccess)
this.refreshTask(that, res)
}).catch(err => {
console.log("err", err)
that.$u.vuex('uploadStatus', 3)
err.mobile = that.vuex_user.mobile
if(!err.key) err.files = uploadTask
if(!err.orderNumber) err.orderNumber = uploadTask[0].orderNumber
......@@ -54,6 +59,7 @@ export default {
if (err.errMsg && (err.errMsg.indexOf('fail file not found') !== -1 || err.errMsg.indexOf('file doesn') !== -1)) { // 在任务中删除不存在的图片
const newTask = uploadTask.filter(v => v.key !== err.key)
that.$u.vuex('uploadTask', newTask)
this.resetProgress(that)
}
})
},
......@@ -66,7 +72,16 @@ export default {
}
})
// uni.setStorageSync('delImg', delImg) // 已上传完的图片,会在启动系统的时候做一次清理
that.$u.vuex('uploadStatus', 1)
that.$u.vuex('uploadTask', newTask)
this.resetProgress(that)
},
// 重置任务状态
resetProgress(that) {
if (that.uploadTask.length === 0) { // 上传完本地所有照片
that.$u.vuex('uploadSuccess', 0)
that.$u.vuex('uploadTotal', 0)
that.$u.vuex('uploadStatus', 1)
}
}
}
......@@ -23,8 +23,10 @@
<!-- <text class="rightContent u-m-t-14 u-m-l-30 u-p-b-30">{{item.describe}}</text> -->
</view>
<view class="rightImageView" v-if="item.orderImages && item.orderImages.length > 0">
<image class="rightImage" v-for="(image, index) in item.orderImages" :src="image"
:key="index" @click.stop="handleClickImage(item, index)" mode="aspectFill"></image>
<u-image class="rightImage" v-for="(image, index) in item.orderImages" :src="image + '?imageView2/1/w/100/h/100/q/75'"
:key="index" @tap.stop="handleClickImage(item, index)" width="116" height="116">
<view slot="error" style="font-size: 24rpx;">上传中</view>
</u-image>
</view>
</view>
</template>
......@@ -419,8 +421,8 @@
.rightImage {
background-color: #F3F3F3;
width: 116rpx;
height: 116rpx;
/* width: 116rpx;
height: 116rpx; */
margin: 0rpx 12rpx 12rpx 0rpx;
}
......
......@@ -12,7 +12,7 @@ try {
}
// 需要永久存储,且下次APP启动需要取出的,在state中的变量名
let saveStateKeys = ['vuex_user', 'vuex_wx_uid', 'vuex_token', 'vuex_cache', 'uploadTask', 'vuex_superuser', 'vuex_last_five_orders'];
let saveStateKeys = ['vuex_user', 'vuex_wx_uid', 'vuex_token', 'vuex_cache', 'uploadTask', 'uploadTotal', 'uploadSuccess', 'vuex_superuser'];
// 保存变量到本地存储中
const saveLifeData = function(key, value) {
......@@ -43,7 +43,13 @@ const store = new Vuex.Store({
// 授权用户信息
vuex_auth_user: {},
// 上传队列
uploadTask: lifeData.uploadTask ? lifeData.uploadTask : []
uploadTask: lifeData.uploadTask ? lifeData.uploadTask : [],
// 上传状态 1 未开始 2 上传中 3 上传中断
uploadStatus: 1,
// 上传总数量
uploadTotal: lifeData.uploadTotal ? lifeData.uploadTotal : 0,
// 已上传数量
uploadSuccess: lifeData.uploadSuccess ? lifeData.uploadSuccess : 0,
},
mutations: {
$uStore(state, payload) {
......
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