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
5114719f
Commit
5114719f
authored
Aug 25, 2021
by
Damon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
perf: 日志增加图片大小、网络类型
parent
9429d5eb
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
66 additions
and
17 deletions
+66
-17
preview.vue
src/components/photo/preview.vue
+1
-0
index.vue
src/components/take/index.vue
+26
-3
index.js
src/components/upload/index.js
+14
-2
task.js
src/components/upload/task.js
+18
-2
complete.vue
src/pages/order/complete.vue
+1
-2
detail.vue
src/pages/order/detail.vue
+1
-2
list.vue
src/pages/photo/list.vue
+1
-2
utils.js
src/plugins/uploader/request/upload/utils.js
+4
-4
No files found.
src/components/photo/preview.vue
View file @
5114719f
...
@@ -185,6 +185,7 @@
...
@@ -185,6 +185,7 @@
// 拍照项张数目增加 等于10张
// 拍照项张数目增加 等于10张
photo
.
allImages
.
unshift
(
photo
.
allImages
.
unshift
(
{
{
size
:
photo
.
tempPath
.
size
,
path
:
photo
.
tempPath
.
mixWater
,
path
:
photo
.
tempPath
.
mixWater
,
src
:
photo
.
tempPath
.
mixWater
,
src
:
photo
.
tempPath
.
mixWater
,
key
:
this
.
fileMaps
[
0
]
?
this
.
fileMaps
[
0
].
key
:
''
,
key
:
this
.
fileMaps
[
0
]
?
this
.
fileMaps
[
0
].
key
:
''
,
...
...
src/components/take/index.vue
View file @
5114719f
...
@@ -44,6 +44,15 @@
...
@@ -44,6 +44,15 @@
</
template
>
</
template
>
<
script
>
<
script
>
const
formatSize
=
function
(
size
,
pointLength
,
units
)
{
var
unit
;
units
=
units
||
[
'B'
,
'K'
,
'M'
,
'G'
];
while
(
(
unit
=
units
.
shift
())
&&
size
>
1024
)
{
size
=
size
/
1024
;
}
return
(
unit
===
'B'
?
size
:
size
.
toFixed
(
pointLength
===
undefined
?
2
:
pointLength
))
+
unit
;
}
let
r
=
require
(
"@/libs/bmap-wx.min.js"
);
let
r
=
require
(
"@/libs/bmap-wx.min.js"
);
let
h
=
new
r
.
BMapWX
({
let
h
=
new
r
.
BMapWX
({
// ak: "rpVq5d3yxaRCoKzVwmFMo0o4iC524CAG",
// ak: "rpVq5d3yxaRCoKzVwmFMo0o4iC524CAG",
...
@@ -382,7 +391,7 @@
...
@@ -382,7 +391,7 @@
})
})
},
},
// 第二步:绘制画布
// 第二步:绘制画布
drawCanvas
:
function
(
tempPath
)
{
drawCanvas
:
async
function
(
tempPath
)
{
uni
.
showLoading
({
uni
.
showLoading
({
title
:
'数据处理中...'
,
title
:
'数据处理中...'
,
icon
:
'loading'
icon
:
'loading'
...
@@ -449,9 +458,11 @@
...
@@ -449,9 +458,11 @@
width
:
canvasWidth
,
width
:
canvasWidth
,
height
:
canvasHeight
,
height
:
canvasHeight
,
canvasId
:
'canvas'
,
canvasId
:
'canvas'
,
success
:
(
res
)
=>
{
success
:
async
(
res
)
=>
{
const
size
=
await
this
.
getImageSize
(
res
.
tempFilePath
)
this
.
tempImgs
.
mixWater
=
res
.
tempFilePath
this
.
tempImgs
.
mixWater
=
res
.
tempFilePath
globalTempPath
.
origin
=
this
.
tempImgs
.
origin
globalTempPath
.
origin
=
this
.
tempImgs
.
origin
globalTempPath
.
size
=
formatSize
(
size
)
||
''
globalTempPath
.
mixWater
=
res
.
tempFilePath
globalTempPath
.
mixWater
=
res
.
tempFilePath
let
timer
=
setTimeout
(()
=>
{
let
timer
=
setTimeout
(()
=>
{
//this.goPage('/pages/photo/preview')
//this.goPage('/pages/photo/preview')
...
@@ -483,7 +494,19 @@
...
@@ -483,7 +494,19 @@
fail
()
{}
fail
()
{}
})
})
},
},
getImageSize
(
path
)
{
return
new
Promise
((
resolve
,
reject
)
=>
{
wx
.
getFileInfo
({
filePath
:
path
,
success
(
res
)
{
resolve
(
res
.
size
)
},
fail
()
{
resolve
(
0
)
}
})
})
},
showPreviewFn
(
img
)
{
showPreviewFn
(
img
)
{
uni
.
previewImage
({
uni
.
previewImage
({
current
:
0
,
current
:
0
,
...
...
src/components/upload/index.js
View file @
5114719f
import
uploader
from
'@/plugins/uploader/index.js'
import
uploader
from
'@/plugins/uploader/index.js'
const
globalUrl
=
process
.
uniEnv
||
{}
const
globalUrl
=
process
.
uniEnv
||
{}
const
randomChar
=
function
(
l
,
url
=
""
)
{
const
randomChar
=
function
(
l
,
url
=
""
)
{
const
x
=
"0123456789qwertyuioplkjhgfdsazxcvbnm"
;
const
x
=
"0123456789qwertyuioplkjhgfdsazxcvbnm"
;
let
tmp
=
""
;
let
tmp
=
""
;
...
@@ -14,6 +15,16 @@ const randomChar = function(l, url = "") {
...
@@ -14,6 +15,16 @@ const randomChar = function(l, url = "") {
tmp
tmp
);
);
}
}
const
formatSize
=
function
(
size
,
pointLength
,
units
)
{
var
unit
;
units
=
units
||
[
'B'
,
'K'
,
'M'
,
'G'
];
while
(
(
unit
=
units
.
shift
())
&&
size
>
1024
)
{
size
=
size
/
1024
;
}
return
(
unit
===
'B'
?
size
:
size
.
toFixed
(
pointLength
===
undefined
?
2
:
pointLength
))
+
unit
;
}
export
default
{
export
default
{
name
:
'upload'
,
name
:
'upload'
,
components
:
{},
components
:
{},
...
@@ -52,7 +63,8 @@ export default {
...
@@ -52,7 +63,8 @@ export default {
return
{
return
{
time
:
this
.
$u
.
timeFormat
(
new
Date
().
getTime
(),
'yyyy-mm-dd hh:MM:ss'
),
time
:
this
.
$u
.
timeFormat
(
new
Date
().
getTime
(),
'yyyy-mm-dd hh:MM:ss'
),
key
:
key
,
key
:
key
,
path
:
v
,
path
:
v
.
path
,
size
:
formatSize
(
v
.
size
)
||
''
,
src
:
key
,
src
:
key
,
...
order
...
order
}
}
...
@@ -79,7 +91,7 @@ export default {
...
@@ -79,7 +91,7 @@ export default {
sizeType
:
data
.
sizeType
||
[
'original'
,
'compressed'
],
//可以指定是原图还是压缩图,默认二者都有
sizeType
:
data
.
sizeType
||
[
'original'
,
'compressed'
],
//可以指定是原图还是压缩图,默认二者都有
sourceType
:
data
.
sourceType
||
[
'album'
,
'camera'
],
//从相册选择
sourceType
:
data
.
sourceType
||
[
'album'
,
'camera'
],
//从相册选择
success
:
function
(
res
)
{
success
:
function
(
res
)
{
const
lists
=
self
.
saveToTask
(
res
.
tempFile
Path
s
,
order
)
const
lists
=
self
.
saveToTask
(
res
.
tempFiles
,
order
)
resolve
(
lists
)
resolve
(
lists
)
},
},
fail
:
err
=>
{
fail
:
err
=>
{
...
...
src/components/upload/task.js
View file @
5114719f
import
uploader
from
'@/plugins/uploader/index.js'
import
uploader
from
'@/plugins/uploader/index.js'
import
{
RUN
,
ERROR
}
from
"@/common/log.js"
import
{
RUN
,
ERROR
}
from
"@/common/log.js"
const
getNetworkType
=
function
()
{
return
new
Promise
((
resolve
,
reject
)
=>
{
uni
.
getNetworkType
({
success
(
res
)
{
resolve
(
res
.
networkType
)
},
fail
(
res
)
{
resolve
(
'获取失败'
)
}
})
})
}
export
default
{
export
default
{
/**
/**
* 执行任务队列
* 执行任务队列
*/
*/
async
uploadImageTask
(
that
)
{
async
uploadImageTask
(
that
)
{
const
uploadTask
=
JSON
.
parse
(
JSON
.
stringify
(
that
.
uploadTask
))
const
uploadTask
=
JSON
.
parse
(
JSON
.
stringify
(
that
.
uploadTask
))
const
networkType
=
await
getNetworkType
()
const
options
=
{
const
options
=
{
files
:
uploadTask
,
// 必填 临时文件路径 格式: [{path: "图片地址"}]
files
:
uploadTask
,
// 必填 临时文件路径 格式: [{path: "图片地址"}]
load
:
false
,
//(默认 true 说明:本接口是否提示加载动画)
load
:
false
,
//(默认 true 说明:本接口是否提示加载动画)
...
@@ -15,7 +29,8 @@ export default {
...
@@ -15,7 +29,8 @@ export default {
const
log
=
{
const
log
=
{
...
res
,
...
res
,
mobile
:
that
.
vuex_user
.
mobile
mobile
:
that
.
vuex_user
.
mobile
,
networkType
:
networkType
}
}
delete
log
.
files
delete
log
.
files
RUN
(
'upload_photo_success'
,
log
)
RUN
(
'upload_photo_success'
,
log
)
...
@@ -33,6 +48,7 @@ export default {
...
@@ -33,6 +48,7 @@ export default {
err
.
mobile
=
that
.
vuex_user
.
mobile
err
.
mobile
=
that
.
vuex_user
.
mobile
if
(
!
err
.
key
)
err
.
files
=
uploadTask
if
(
!
err
.
key
)
err
.
files
=
uploadTask
if
(
!
err
.
orderNumber
)
err
.
orderNumber
=
uploadTask
[
0
].
orderNumber
if
(
!
err
.
orderNumber
)
err
.
orderNumber
=
uploadTask
[
0
].
orderNumber
if
(
!
err
.
networkType
)
err
.
networkType
=
networkType
ERROR
(
'upload_photo_error'
,
err
)
ERROR
(
'upload_photo_error'
,
err
)
if
(
err
.
errMsg
&&
(
err
.
errMsg
.
indexOf
(
'fail file not found'
)
!==
-
1
||
err
.
errMsg
.
indexOf
(
'file doesn'
)
!==
-
1
))
{
// 在任务中删除不存在的图片
if
(
err
.
errMsg
&&
(
err
.
errMsg
.
indexOf
(
'fail file not found'
)
!==
-
1
||
err
.
errMsg
.
indexOf
(
'file doesn'
)
!==
-
1
))
{
// 在任务中删除不存在的图片
...
...
src/pages/order/complete.vue
View file @
5114719f
...
@@ -1147,14 +1147,13 @@ export default {
...
@@ -1147,14 +1147,13 @@ export default {
// 拍照回调
// 拍照回调
async
closeTake
(
val
)
{
async
closeTake
(
val
)
{
if
(
val
&&
val
.
length
>
0
)
{
if
(
val
&&
val
.
length
>
0
)
{
const
files
=
val
.
map
((
v
)
=>
v
.
path
)
const
order
=
{
const
order
=
{
orderNumber
:
this
.
orderNumber
,
orderNumber
:
this
.
orderNumber
,
fieldsName
:
this
.
photoItem
.
fieldsName
,
fieldsName
:
this
.
photoItem
.
fieldsName
,
fieldsTitle
:
this
.
photoItem
.
fieldsTitle
,
fieldsTitle
:
this
.
photoItem
.
fieldsTitle
,
uploadType
:
'camera'
uploadType
:
'camera'
}
}
const
value
=
await
this
.
saveToTask
(
files
,
order
)
const
value
=
await
this
.
saveToTask
(
val
,
order
)
this
.
$refs
[
this
.
$refs
[
`fileChild
${
this
.
photoItem
.
groupIndex
}${
this
.
photoItem
.
itemIndex
}
`
`fileChild
${
this
.
photoItem
.
groupIndex
}${
this
.
photoItem
.
itemIndex
}
`
][
0
].
setTmpValue
(
value
)
][
0
].
setTmpValue
(
value
)
...
...
src/pages/order/detail.vue
View file @
5114719f
...
@@ -534,8 +534,7 @@ export default {
...
@@ -534,8 +534,7 @@ export default {
// 获取返回的图片 ,如果返回的图片存在则直接异常签约,成功后跳转到去完工页面,
// 获取返回的图片 ,如果返回的图片存在则直接异常签约,成功后跳转到去完工页面,
if
(
img
)
{
if
(
img
)
{
// 拍照完成
// 拍照完成
const
files
=
img
.
map
((
v
)
=>
v
.
path
)
const
value
=
await
this
.
saveToTask
(
img
)
const
value
=
await
this
.
saveToTask
(
files
)
this
.
isErrorSign
=
true
this
.
isErrorSign
=
true
this
.
errorSignUrl
=
value
[
0
].
key
this
.
errorSignUrl
=
value
[
0
].
key
this
.
handleBtn
()
this
.
handleBtn
()
...
...
src/pages/photo/list.vue
View file @
5114719f
...
@@ -257,14 +257,13 @@
...
@@ -257,14 +257,13 @@
if
(
!
this
.
currentItemDate
.
orderImages
)
this
.
currentItemDate
.
orderImages
=
[]
if
(
!
this
.
currentItemDate
.
orderImages
)
this
.
currentItemDate
.
orderImages
=
[]
// 真实地址key
// 真实地址key
let
saveList
=
this
.
currentItemDate
.
key
let
saveList
=
this
.
currentItemDate
.
key
const
files
=
img
.
map
(
v
=>
v
.
path
)
const
order
=
{
const
order
=
{
orderNumber
:
this
.
orderNumber
,
orderNumber
:
this
.
orderNumber
,
fieldsName
:
this
.
currentItemDate
.
fieldsName
,
fieldsName
:
this
.
currentItemDate
.
fieldsName
,
fieldsTitle
:
this
.
currentItemDate
.
fieldsTitle
,
fieldsTitle
:
this
.
currentItemDate
.
fieldsTitle
,
uploadType
:
'camera'
uploadType
:
'camera'
}
}
const
value
=
await
this
.
saveToTask
(
files
,
order
)
const
value
=
await
this
.
saveToTask
(
img
,
order
)
value
.
forEach
(
item
=>
{
value
.
forEach
(
item
=>
{
// 文件key添加保存数组中
// 文件key添加保存数组中
saveList
.
push
(
item
.
key
)
saveList
.
push
(
item
.
key
)
...
...
src/plugins/uploader/request/upload/utils.js
View file @
5114719f
const
qiniuUploader
=
require
(
"./qiniuUploader"
);
const
qiniuUploader
=
require
(
"./qiniuUploader"
);
//七牛云上传文件命名
//七牛云上传文件命名
export
const
randomChar
=
function
(
l
,
url
=
""
)
{
export
const
randomChar
=
function
(
l
,
url
=
""
)
{
const
x
=
"0123456789qwertyuioplkjhgfdsazxcvbnm"
;
const
x
=
"0123456789qwertyuioplkjhgfdsazxcvbnm"
;
...
@@ -69,7 +70,7 @@ export const chooseVideo = function(data) {
...
@@ -69,7 +70,7 @@ export const chooseVideo = function(data) {
}
}
// 七牛云上传
// 七牛云上传
export
const
qiniuUpload
=
function
(
requestInfo
,
qnRes
)
{
export
const
qiniuUpload
=
function
(
requestInfo
,
qnRes
)
{
return
new
Promise
((
resolve
,
reject
)
=>
{
return
new
Promise
(
async
(
resolve
,
reject
)
=>
{
if
(
Array
.
isArray
(
requestInfo
.
files
))
{
if
(
Array
.
isArray
(
requestInfo
.
files
))
{
let
len
=
requestInfo
.
files
.
length
;
let
len
=
requestInfo
.
files
.
length
;
let
fileList
=
new
Array
;
let
fileList
=
new
Array
;
...
@@ -87,7 +88,6 @@ export const qiniuUpload = function(requestInfo, qnRes) {
...
@@ -87,7 +88,6 @@ export const qiniuUpload = function(requestInfo, qnRes) {
qnRes
.
visitPrefix
=
qnRes
.
visitPrefix
.
substring
(
0
,
prefixLen
-
1
)
qnRes
.
visitPrefix
=
qnRes
.
visitPrefix
.
substring
(
0
,
prefixLen
-
1
)
}
}
uploadFile
(
0
);
uploadFile
(
0
);
function
uploadFile
(
i
)
{
function
uploadFile
(
i
)
{
let
item
=
requestInfo
.
files
[
i
];
let
item
=
requestInfo
.
files
[
i
];
let
updateUrl
=
item
.
key
//randomChar(10, qnRes.folderPath);
let
updateUrl
=
item
.
key
//randomChar(10, qnRes.folderPath);
...
@@ -114,10 +114,10 @@ export const qiniuUpload = function(requestInfo, qnRes) {
...
@@ -114,10 +114,10 @@ export const qiniuUpload = function(requestInfo, qnRes) {
}
else
{
}
else
{
resolve
(
fileList
);
resolve
(
fileList
);
}
}
},
(
error
)
=>
{
},
async
(
error
)
=>
{
const
rejectMsg
=
{
const
rejectMsg
=
{
...
error
,
...
error
,
...
item
...
item
,
}
}
reject
(
rejectMsg
);
reject
(
rejectMsg
);
},
{
},
{
...
...
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