Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
self-support
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
李俊赕
self-support
Commits
d13d82df
Commit
d13d82df
authored
Sep 06, 2021
by
Damon
Browse files
Options
Browse Files
Download
Plain Diff
merge
parents
8f8d2e8e
b6b87dd5
Changes
8
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
300 additions
and
28 deletions
+300
-28
App.vue
src/App.vue
+5
-14
http.interceptor.js
src/common/http.interceptor.js
+3
-0
XhFiles.vue
src/components/createCom/XhFiles.vue
+1
-1
upload-progress.vue
src/components/upload-progress/upload-progress.vue
+255
-0
index.js
src/components/upload/index.js
+5
-5
task.js
src/components/upload/task.js
+17
-2
list.vue
src/pages/photo/list.vue
+6
-4
index.js
src/store/index.js
+8
-2
No files found.
src/App.vue
View file @
d13d82df
...
...
@@ -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
();
...
...
src/common/http.interceptor.js
View file @
d13d82df
...
...
@@ -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
}
...
...
src/components/createCom/XhFiles.vue
View file @
d13d82df
...
...
@@ -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"
...
...
src/components/upload-progress/upload-progress.vue
0 → 100644
View file @
d13d82df
<
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
>
src/components/upload/index.js
View file @
d13d82df
...
...
@@ -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
},
/**
...
...
src/components/upload/task.js
View file @
d13d82df
...
...
@@ -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
)
}
}
}
src/pages/photo/list.vue
View file @
d13d82df
...
...
@@ -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
:
116
rpx
;
height
:
116
rpx
;
/*
width: 116rpx;
height: 116rpx;
*/
margin
:
0
rpx
12
rpx
12
rpx
0
rpx
;
}
...
...
src/store/index.js
View file @
d13d82df
...
...
@@ -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
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment