Commit 6cde5207 authored by Damon's avatar Damon

离线图片使用临时文件

parent f2474220
...@@ -261,17 +261,17 @@ ...@@ -261,17 +261,17 @@
const self = this const self = this
const photo = getApp().globalData.photo const photo = getApp().globalData.photo
const data = cache.getCache(self.systemId) const data = cache.getCache(self.systemId)
let path = [] // let path = []
data.result.forEach(v => { // data.result.forEach(v => {
v.list.forEach(item => { // v.list.forEach(item => {
if (item.imageList.length > 0) path = path.concat(item.imageList) // if (item.imageList.length > 0) path = path.concat(item.imageList)
}) // })
}) // })
for (let i of path) { // for (let i of path) {
uni.removeSavedFile({ // uni.removeSavedFile({
filePath: i // filePath: i
}) // })
} // }
cache.removeCache(self.systemId) cache.removeCache(self.systemId)
self.isPopShow = false self.isPopShow = false
self.getListData() self.getListData()
......
...@@ -109,22 +109,16 @@ ...@@ -109,22 +109,16 @@
saveToStroage(path) { saveToStroage(path) {
const photo = getApp().globalData.photo const photo = getApp().globalData.photo
const currentItem = photo.currentItem const currentItem = photo.currentItem
uni.saveFile({ currentItem.imageList.unshift(path)
tempFilePath: path, // 从缓存数据中找到修改对象并替换
success(e) { const data = cache.getCache(currentItem.system_id)
const { savedFilePath } = e data.result.forEach(v => {
currentItem.imageList.unshift(savedFilePath) const index = v.list.findIndex(item => item._id === currentItem._id)
// 从缓存数据中找到修改对象并替换 if (index > -1) {
const data = cache.getCache(currentItem.system_id) v.list[index] = currentItem
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)
} }
}) })
cache.setCache(currentItem.system_id, data)
}, },
saveLocal(path){ saveLocal(path){
return new Promise((resolve,reject)=>{ return new Promise((resolve,reject)=>{
......
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