Authored by ccbikai

首页 goods 完善

... ... @@ -8,31 +8,48 @@
const titleFloor = require('component/resources/title-floor.vue');
const productList = require('product/list.vue');
const bus = require('common/vue-bus');
module.exports = {
data() {
return {
productList: []
productList: [],
productSkn: []
};
},
props: ['floor'],
components: {
titleFloor: titleFloor,
titleFloor,
productList
},
created() {
let productSkn = [];
this.floor.forEach(item => {
productSkn.push(item.id);
});
methods: {
getProducts(productSkn) {
if (!productSkn.length) {
return;
}
$.ajax({
url: '/channel/goods.json',
data: {
productSkn: productSkn.join(',')
}
}).then(result => {
this.productList = result;
this.productList = this.productList.concat(result);
});
}
},
created() {
const limit = 20;
let page = 0;
this.floor.forEach(item => {
this.productSkn.push(item.id);
});
this.getProducts(this.productSkn.slice(page, limit));
bus.$on('list.paging', () => {
page++;
this.getProducts(this.productSkn.slice(page * limit, (page + 1) * limit));
});
}
};
... ...