Showing
1 changed file
with
13 additions
and
2 deletions
@@ -8,9 +8,10 @@ | @@ -8,9 +8,10 @@ | ||
8 | const $ = require('jquery'); | 8 | const $ = require('jquery'); |
9 | const titleFloor = require('component/resources/title-floor.vue'); | 9 | const titleFloor = require('component/resources/title-floor.vue'); |
10 | const productList = require('component/product/list.vue'); | 10 | const productList = require('component/product/list.vue'); |
11 | - | ||
12 | const bus = require('common/vue-bus'); | 11 | const bus = require('common/vue-bus'); |
13 | 12 | ||
13 | + const dataCache = {}; | ||
14 | + | ||
14 | module.exports = { | 15 | module.exports = { |
15 | data() { | 16 | data() { |
16 | return { | 17 | return { |
@@ -28,13 +29,23 @@ | @@ -28,13 +29,23 @@ | ||
28 | if (!productSkn.length) { | 29 | if (!productSkn.length) { |
29 | return; | 30 | return; |
30 | } | 31 | } |
32 | + productSkn = productSkn.join(','); | ||
33 | + | ||
34 | + if (dataCache[productSkn]) { | ||
35 | + this.productList = this.productList.concat(dataCache[productSkn]); | ||
36 | + return; | ||
37 | + } | ||
31 | $.ajax({ | 38 | $.ajax({ |
32 | url: '/channel/goods.json', | 39 | url: '/channel/goods.json', |
33 | data: { | 40 | data: { |
34 | - productSkn: productSkn.join(',') | 41 | + productSkn: productSkn |
35 | } | 42 | } |
36 | }).then(result => { | 43 | }).then(result => { |
37 | this.productList = this.productList.concat(result); | 44 | this.productList = this.productList.concat(result); |
45 | + | ||
46 | + if (result.length) { | ||
47 | + dataCache[productSkn] = result; | ||
48 | + } | ||
38 | }); | 49 | }); |
39 | } | 50 | } |
40 | }, | 51 | }, |
-
Please register or login to post a comment