Commit d786ddff by 李伟康

海报缓存

1 parent 17cfcddc
...@@ -17,6 +17,10 @@ Component({ ...@@ -17,6 +17,10 @@ Component({
else this.begin() else this.begin()
}).catch(() => this.begin()) }).catch(() => this.begin())
} }
},
findKey: {
type: String,
value: 'activityId'
} }
}, },
...@@ -37,7 +41,10 @@ Component({ ...@@ -37,7 +41,10 @@ Component({
}, },
check(n) { check(n) {
const fileList = wx.$storage.get('fileList') || [], const fileList = wx.$storage.get('fileList') || [],
fn = wx.getFileSystemManager() fn = wx.getFileSystemManager(),
{
findKey
} = this.data
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
if (fileList.length) { if (fileList.length) {
fn.readdir({ fn.readdir({
...@@ -45,9 +52,9 @@ Component({ ...@@ -45,9 +52,9 @@ Component({
success({ success({
files files
}) { }) {
console.log(files,'文件列表') console.log(files, '文件列表')
if (files.length < 21) { if (files.length < 21) {
let item = fileList.find(e => e.activityId === n.activityId) let item = fileList.find(e => e[findKey] === n[findKey])
if (item) { if (item) {
const poster = files.find(s => s.includes(item.fileId)) const poster = files.find(s => s.includes(item.fileId))
wx.hideLoading() wx.hideLoading()
...@@ -56,7 +63,7 @@ Component({ ...@@ -56,7 +63,7 @@ Component({
} else reject() } else reject()
} else { } else {
wx.$storage.rm('fileList') wx.$storage.rm('fileList')
files.map(e =>{ files.map(e => {
fn.unlink({ fn.unlink({
filePath: `${wx.env.USER_DATA_PATH}/${e}` filePath: `${wx.env.USER_DATA_PATH}/${e}`
}) })
...@@ -101,6 +108,9 @@ Component({ ...@@ -101,6 +108,9 @@ Component({
userInfo userInfo
} = wx.$storage.get(), } = wx.$storage.get(),
merchantName = userInfo.merchantName.length > 12 ? `${userInfo.merchantName.substring(0, 12)}...` : userInfo.merchantName, merchantName = userInfo.merchantName.length > 12 ? `${userInfo.merchantName.substring(0, 12)}...` : userInfo.merchantName,
{
findKey
} = this.data,
res = await drawfun.begin({ res = await drawfun.begin({
imageList: [{ imageList: [{
x: 0, x: 0,
...@@ -161,7 +171,7 @@ Component({ ...@@ -161,7 +171,7 @@ Component({
fileList.push({ fileList.push({
fileId: res.fileId, fileId: res.fileId,
path: res.path, path: res.path,
activityId: n.activityId [findKey]: n[findKey]
}) })
wx.$storage.set('fileList', fileList) wx.$storage.set('fileList', fileList)
}, },
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!