|
|
|
@ -1396,8 +1396,24 @@ |
|
|
|
saveHomeAdImageCache(cache) { |
|
|
|
uni.setStorageSync(HOME_AD_IMAGE_CACHE_KEY, cache) |
|
|
|
}, |
|
|
|
isSavedFileExists(filePath) { |
|
|
|
if (!filePath || filePath.indexOf('__tmp__') !== -1) return false |
|
|
|
try { |
|
|
|
const fs = (uni.getFileSystemManager && uni.getFileSystemManager()) |
|
|
|
|| (typeof wx !== 'undefined' && wx.getFileSystemManager ? wx.getFileSystemManager() : null) |
|
|
|
if (fs && fs.accessSync) { |
|
|
|
fs.accessSync(filePath) |
|
|
|
return true |
|
|
|
} |
|
|
|
} catch (e) { |
|
|
|
return false |
|
|
|
} |
|
|
|
return true |
|
|
|
}, |
|
|
|
isHomeAdImageCacheValid(cacheItem) { |
|
|
|
return !!(cacheItem && cacheItem.path && cacheItem.path.indexOf('__tmp__') === -1 && Date.now() - Number(cacheItem.savedAt || 0) < HOME_AD_IMAGE_CACHE_TTL) |
|
|
|
return !!(cacheItem |
|
|
|
&& Date.now() - Number(cacheItem.savedAt || 0) < HOME_AD_IMAGE_CACHE_TTL |
|
|
|
&& this.isSavedFileExists(cacheItem.path)) |
|
|
|
}, |
|
|
|
applyCachedAdImages(mallAds) { |
|
|
|
const cache = this.getHomeAdImageCache() |
|
|
|
@ -1416,6 +1432,9 @@ |
|
|
|
item.adDisplayImage = cacheItem.path |
|
|
|
return |
|
|
|
} |
|
|
|
if (cacheItem && cacheItem.path) { |
|
|
|
delete cache[imageUrl] |
|
|
|
} |
|
|
|
this.cacheHomeAdImage(imageUrl) |
|
|
|
}) |
|
|
|
this.pruneHomeAdImageCache(cache, activeUrls) |
|
|
|
@ -1429,9 +1448,13 @@ |
|
|
|
this.homeMenuIconImages[key] = cacheItem.path |
|
|
|
return |
|
|
|
} |
|
|
|
if (cacheItem && cacheItem.path) { |
|
|
|
delete cache[imageUrl] |
|
|
|
} |
|
|
|
this.homeMenuIconImages[key] = '' |
|
|
|
this.cacheHomeMenuIcon(key, imageUrl) |
|
|
|
}) |
|
|
|
this.saveHomeAdImageCache(cache) |
|
|
|
}, |
|
|
|
cacheHomeMenuIcon(key, imageUrl) { |
|
|
|
if (homeAdImageDownloading[imageUrl]) return |
|
|
|
|