Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
T
take_order
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
和慭琛
take_order
Commits
c8f11bba
Commit
c8f11bba
authored
May 11, 2021
by
Damon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
拍照图片缓存到本地
parent
321432ba
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
47 additions
and
7 deletions
+47
-7
preview.vue
take-order/pages/photo/preview.vue
+47
-7
No files found.
take-order/pages/photo/preview.vue
View file @
c8f11bba
...
@@ -13,7 +13,8 @@
...
@@ -13,7 +13,8 @@
</
template
>
</
template
>
<
script
>
<
script
>
import
qiniup
from
'@/components/upload/qiniup'
;
import
qiniup
from
'@/components/upload/qiniup'
;
import
cache
from
'../../common/cache.js'
const
app
=
getApp
()
const
app
=
getApp
()
export
default
{
export
default
{
mixins
:
[
qiniup
],
mixins
:
[
qiniup
],
...
@@ -82,9 +83,9 @@
...
@@ -82,9 +83,9 @@
})
})
}
}
}
}
if
(
photo
.
currentItem
){
//
if(photo.currentItem){
photo
.
currentItem
.
imageList
.
unshift
(
photo
.
tempPath
.
mixWater
)
//
photo.currentItem.imageList.unshift(photo.tempPath.mixWater)
}
//
}
// if(photo.productList && photo.productList[photo.topIndex]){
// if(photo.productList && photo.productList[photo.topIndex]){
// const topArr = photo.productList[photo.topIndex]
// const topArr = photo.productList[photo.topIndex]
// if(topArr[photo.itemIndex]){
// if(topArr[photo.itemIndex]){
...
@@ -94,7 +95,8 @@
...
@@ -94,7 +95,8 @@
// photo.
// photo.
if
(
photo
.
tempPath
.
mixWater
){
if
(
photo
.
tempPath
.
mixWater
){
// 保存水印处理图片到本地
// 保存水印处理图片到本地
path
=
photo
.
tempPath
.
mixWater
path
=
photo
.
tempPath
.
mixWater
this
.
saveToStroage
(
path
)
// 保存到本地缓存
let
result1
=
await
this
.
saveLocal
(
path
)
let
result1
=
await
this
.
saveLocal
(
path
)
if
(
result1
){
if
(
result1
){
uni
.
showToast
({
uni
.
showToast
({
...
@@ -103,6 +105,26 @@
...
@@ -103,6 +105,26 @@
})
})
}
}
}
}
},
saveToStroage
(
path
)
{
const
photo
=
getApp
().
globalData
.
photo
const
currentItem
=
photo
.
currentItem
uni
.
saveFile
({
tempFilePath
:
path
,
success
(
e
)
{
const
{
savedFilePath
}
=
e
currentItem
.
imageList
.
unshift
(
savedFilePath
)
// 从缓存数据中找到修改对象并替换
const
data
=
cache
.
getCache
(
currentItem
.
system_id
)
data
.
result
.
forEach
(
v
=>
{
const
index
=
v
.
list
.
findIndex
(
item
=>
item
.
_id
===
currentItem
.
_id
)
if
(
index
>
-
1
)
{
v
.
list
[
index
]
=
currentItem
}
})
cache
.
setCache
(
currentItem
.
system_id
,
data
)
}
})
},
},
saveLocal
(
path
){
saveLocal
(
path
){
return
new
Promise
((
resolve
,
reject
)
=>
{
return
new
Promise
((
resolve
,
reject
)
=>
{
...
@@ -145,8 +167,26 @@
...
@@ -145,8 +167,26 @@
uni
.
showLoading
({
uni
.
showLoading
({
title
:
'图片保存中…'
title
:
'图片保存中…'
})
})
self
.
saveTempToLocal
()
self
.
saveTempToLocal
()
self
.
confirmUpload
(
true
)
self
.
handleResult
()
//self.confirmUpload(true)
},
handleResult
()
{
const
photo
=
getApp
().
globalData
.
photo
if
(
photo
.
currentItemLength
<
10
)
photo
.
currentItemLength
=
photo
.
currentItemLength
+
1
uni
.
hideLoading
()
console
.
log
(
photo
)
// 当前项的图片显示
// 拍照项张数目增加 等于10张
if
(
photo
.
currentItemLength
<
10
){
uni
.
navigateBack
({
delta
:
1
})
}
else
{
uni
.
navigateBack
({
delta
:
2
})
}
},
},
submitFile
()
{
submitFile
()
{
let
self
=
this
let
self
=
this
...
...
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