Showing
1 changed file
with
27 additions
and
10 deletions
@@ -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 | }, |
22 | - created() { | ||
23 | - let productSkn = []; | ||
24 | - | ||
25 | - this.floor.forEach(item => { | ||
26 | - productSkn.push(item.id); | ||
27 | - }); | ||
28 | - | 25 | + methods: { |
26 | + getProducts(productSkn) { | ||
27 | + if (!productSkn.length) { | ||
28 | + return; | ||
29 | + } | ||
29 | $.ajax({ | 30 | $.ajax({ |
30 | url: '/channel/goods.json', | 31 | url: '/channel/goods.json', |
31 | data: { | 32 | data: { |
32 | productSkn: productSkn.join(',') | 33 | productSkn: productSkn.join(',') |
33 | } | 34 | } |
34 | }).then(result => { | 35 | }).then(result => { |
35 | - this.productList = result; | 36 | + this.productList = this.productList.concat(result); |
37 | + }); | ||
38 | + } | ||
39 | + }, | ||
40 | + created() { | ||
41 | + const limit = 20; | ||
42 | + let page = 0; | ||
43 | + | ||
44 | + this.floor.forEach(item => { | ||
45 | + this.productSkn.push(item.id); | ||
46 | + }); | ||
47 | + | ||
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 | }; |
-
Please register or login to post a comment