Authored by Aiden Xu

Merge remote-tracking branch 'origin/develop' into develop

@@ -8,31 +8,48 @@ @@ -8,31 +8,48 @@
8 const titleFloor = require('component/resources/title-floor.vue'); 8 const titleFloor = require('component/resources/title-floor.vue');
9 const productList = require('product/list.vue'); 9 const productList = require('product/list.vue');
10 10
  11 + const bus = require('common/vue-bus');
  12 +
11 module.exports = { 13 module.exports = {
12 data() { 14 data() {
13 return { 15 return {
14 - productList: [] 16 + productList: [],
  17 + productSkn: []
15 }; 18 };
16 }, 19 },
17 props: ['floor'], 20 props: ['floor'],
18 components: { 21 components: {
19 - titleFloor: titleFloor, 22 + titleFloor,
20 productList 23 productList
21 }, 24 },
  25 + methods: {
  26 + getProducts(productSkn) {
  27 + if (!productSkn.length) {
  28 + return;
  29 + }
  30 + $.ajax({
  31 + url: '/channel/goods.json',
  32 + data: {
  33 + productSkn: productSkn.join(',')
  34 + }
  35 + }).then(result => {
  36 + this.productList = this.productList.concat(result);
  37 + });
  38 + }
  39 + },
22 created() { 40 created() {
23 - let productSkn = []; 41 + const limit = 20;
  42 + let page = 0;
24 43
25 this.floor.forEach(item => { 44 this.floor.forEach(item => {
26 - productSkn.push(item.id); 45 + this.productSkn.push(item.id);
27 }); 46 });
28 47
29 - $.ajax({  
30 - url: '/channel/goods.json',  
31 - data: {  
32 - productSkn: productSkn.join(',')  
33 - }  
34 - }).then(result => {  
35 - this.productList = result; 48 + this.getProducts(this.productSkn.slice(page, limit));
  49 +
  50 + bus.$on('list.paging', () => {
  51 + page++;
  52 + this.getProducts(this.productSkn.slice(page * limit, (page + 1) * limit));
36 }); 53 });
37 } 54 }
38 }; 55 };