Authored by ccbikai

首页商品列表增加数据缓存

... ... @@ -8,9 +8,10 @@
const $ = require('jquery');
const titleFloor = require('component/resources/title-floor.vue');
const productList = require('component/product/list.vue');
const bus = require('common/vue-bus');
const dataCache = {};
module.exports = {
data() {
return {
... ... @@ -28,13 +29,23 @@
if (!productSkn.length) {
return;
}
productSkn = productSkn.join(',');
if (dataCache[productSkn]) {
this.productList = this.productList.concat(dataCache[productSkn]);
return;
}
$.ajax({
url: '/channel/goods.json',
data: {
productSkn: productSkn.join(',')
productSkn: productSkn
}
}).then(result => {
this.productList = this.productList.concat(result);
if (result.length) {
dataCache[productSkn] = result;
}
});
}
},
... ...