diff --git a/pages/shopmap/index.vue b/pages/shopmap/index.vue
index d778c6f..82a3cbc 100644
--- a/pages/shopmap/index.vue
+++ b/pages/shopmap/index.vue
@@ -22,8 +22,8 @@
-
-
+
+
@@ -150,7 +150,8 @@
isPage: true,
pageSize: 20,
sort: 0,
- address: ''
+ address: '',
+ downloadImages: [] // 已下载过的图片缓存
}
},
onLoad() {
@@ -301,7 +302,6 @@
},
tabChange(index){
this.current = index;
- console.log('重复只想')
this.getActivityList()
},
// 滑块下标值变化
@@ -310,7 +310,6 @@
if(event.detail.source == '') return; // 如果是被动出发,没有事件类型则不做处理
},
changeSort(sort) {
- console.log('排序')
this.sort != this.sort
this.getActivityList()
},
@@ -351,8 +350,7 @@
tab_item.loadingText = '没有更多数据啦~';
}
this.tab_list[this.current].isRefresher = false;
- console.log(this.tab_list[this.current].isRefresher )
- console.log(this.tab_list[this.current])
+
if(tab_item.page == 1){
tab_item.list = res.data.data;
}else{
@@ -369,45 +367,66 @@
createMarkers(res_list){
let markers_self = [];
let p_list = []; // 异步队列
+ let downloadImages = JSON.parse(JSON.stringify(this.downloadImages)); // 已下载过的图片缓存
uni.showLoading({
title: '加载地图信息中'
})
res_list.map(item => {
let itemP = new Promise((resolve, reject) => {
- uni.downloadFile({
- url: item.picture,
- complete: result => {
- let tempFilePath = "";
- if (result.statusCode === 200) {
- tempFilePath = result.tempFilePath;
- }
- let obj = {
- id: item.id,
- name: item.title,
- address: item.address,
- latitude: Number(item.latitude),
- longitude: Number(item.longitude),
- iconPath: tempFilePath,
- width: 30,
- height: 30,
- callout: {
- content: item.title,
- fontSize: 14,
- textAlign: 'center',
- bgColor: "#fff",
- borderRadius: 14,
- padding: 4,
- display: "ALWAYS"
+ let tempFilePath = ""; // 图片临时路径地址
+ let obj = {
+ id: item.id,
+ name: item.title,
+ address: item.address,
+ latitude: Number(item.latitude),
+ longitude: Number(item.longitude),
+ // iconPath: tempFilePath,
+ width: 30,
+ height: 30,
+ callout: {
+ content: item.title,
+ fontSize: 14,
+ textAlign: 'center',
+ bgColor: "#fff",
+ borderRadius: 14,
+ padding: 4,
+ display: "ALWAYS"
+ }
+ };
+
+ let image = downloadImages.filter(function(f_item, f_index, f_arr){
+ return f_item.id == item.id;
+ });
+
+ if(image.length > 0){
+ // 找到缓存匹配项
+ tempFilePath = image[0].url;
+ obj.iconPath = image[0].url;
+ markers_self.push(obj);
+ resolve();
+ }else{
+ // 未放入缓存,将执行download
+ uni.downloadFile({
+ url: item.picture,
+ complete: result => {
+ if (result.statusCode === 200) {
+ tempFilePath = result.tempFilePath;
}
+ obj.iconPath = tempFilePath;
+ markers_self.push(obj);
+ downloadImages.push({
+ id: item.id,
+ url: tempFilePath
+ });
+ resolve();
}
- markers_self.push(obj);
- resolve();
- }
- })
+ })
+ }
});
p_list.push(itemP);
});
Promise.all(p_list).then(res => {
+ this.downloadImages = JSON.parse(JSON.stringify(downloadImages));
this.markers_list = markers_self;
uni.hideLoading();
})