Showing
5 changed files
with
52 additions
and
34 deletions
@@ -31,20 +31,23 @@ module.exports = { | @@ -31,20 +31,23 @@ module.exports = { | ||
31 | 31 | ||
32 | /* 获取商品列表 */ | 32 | /* 获取商品列表 */ |
33 | getBrandShopGoods: (req, res) => { | 33 | getBrandShopGoods: (req, res) => { |
34 | + let filter = req.body.filter || {}; | ||
35 | + | ||
34 | shopModel.getBrandShopGoodsData({ | 36 | shopModel.getBrandShopGoodsData({ |
37 | + domain: filter.domain, | ||
35 | sort: req.body.sort, | 38 | sort: req.body.sort, |
36 | page: req.body.page, | 39 | page: req.body.page, |
37 | - channel: req.body.filter.channel || 'men', | ||
38 | - gender: req.body.filter.gender || '1,2,3', | ||
39 | - brand: req.body.filter.brand, | ||
40 | - shopId: req.body.filter.shopId, | ||
41 | - order: req.body.filter.order || 's_t_desc', | ||
42 | - limit: req.body.filter.limit || '60', | ||
43 | - color: req.body.filter.color, | ||
44 | - price: req.body.filter.price, | ||
45 | - size: req.body.filter.size, | ||
46 | - pd: req.body.filter.pd, | ||
47 | - tagsFilter: req.body.filter.tagsFilter | 40 | + channel: filter.channel || 'men', |
41 | + gender: filter.gender || '1,2,3', | ||
42 | + brand: filter.brand, | ||
43 | + shopId: filter.shopId, | ||
44 | + order: filter.order || 's_t_desc', | ||
45 | + limit: filter.limit || '60', | ||
46 | + color: filter.color, | ||
47 | + price: filter.price, | ||
48 | + size: filter.size, | ||
49 | + pd: filter.pd, | ||
50 | + tagsFilter: filter.tagsFilter | ||
48 | }).then(result => { | 51 | }).then(result => { |
49 | res.json(result); | 52 | res.json(result); |
50 | }); | 53 | }); |
@@ -7,6 +7,8 @@ | @@ -7,6 +7,8 @@ | ||
7 | 'use strict'; | 7 | 'use strict'; |
8 | 8 | ||
9 | const api = global.yoho.API; | 9 | const api = global.yoho.API; |
10 | +const _ = require('lodash'); | ||
11 | + | ||
10 | const yhChannel = { | 12 | const yhChannel = { |
11 | men: { | 13 | men: { |
12 | channel: '1' | 14 | channel: '1' |
@@ -67,7 +69,7 @@ module.exports = { | @@ -67,7 +69,7 @@ module.exports = { | ||
67 | * @returns {*} | 69 | * @returns {*} |
68 | */ | 70 | */ |
69 | getBrandShopGoodsOriginData(params) { | 71 | getBrandShopGoodsOriginData(params) { |
70 | - return api.get('', { | 72 | + let finalParams = { |
71 | method: 'app.search.brand', | 73 | method: 'app.search.brand', |
72 | yh_channel: params.channel ? yhChannel[params.channel].channel : '1', | 74 | yh_channel: params.channel ? yhChannel[params.channel].channel : '1', |
73 | brand: params.brand, | 75 | brand: params.brand, |
@@ -82,7 +84,16 @@ module.exports = { | @@ -82,7 +84,16 @@ module.exports = { | ||
82 | p_d: params.pd, | 84 | p_d: params.pd, |
83 | sort: params.sort, | 85 | sort: params.sort, |
84 | tags_filter: params.tagsFilter | 86 | tags_filter: params.tagsFilter |
87 | + }; | ||
88 | + | ||
89 | + /* 删除没有参数的条件 */ | ||
90 | + _.forEach(finalParams, (value, key) => { | ||
91 | + if (!value) { | ||
92 | + delete finalParams[key]; | ||
93 | + } | ||
85 | }); | 94 | }); |
95 | + | ||
96 | + return api.get('', finalParams); | ||
86 | }, | 97 | }, |
87 | 98 | ||
88 | /** | 99 | /** |
@@ -109,15 +109,30 @@ const getShopData = params => { | @@ -109,15 +109,30 @@ const getShopData = params => { | ||
109 | const getBrandShopGoodsData = params => { | 109 | const getBrandShopGoodsData = params => { |
110 | let finalResult = {}; | 110 | let finalResult = {}; |
111 | 111 | ||
112 | - return api.all([shopApi.getBrandShopGoodsOriginData(params)]).then(result => { | 112 | + return api.all([ |
113 | + shopApi.getBrandInfoByDomain({ domain: params.domain }) | ||
114 | + ]).then(result => { | ||
113 | if (result[0].code === 200) { | 115 | if (result[0].code === 200) { |
114 | - Object.assign(finalResult, { | ||
115 | - data: { | ||
116 | - productList: processProductList(result[0].data.productList) | 116 | + return api.all([ |
117 | + shopApi.getBrandShopGoodsOriginData(Object.assign(params, { | ||
118 | + brand: result[0].data.id, | ||
119 | + shopId: result[0].data.shop_id | ||
120 | + })) | ||
121 | + ]).then(subResult => { | ||
122 | + if (subResult[0].code === 200) { | ||
123 | + Object.assign(finalResult, { | ||
124 | + data: { | ||
125 | + productList: processProductList(subResult[0].data.productList) | ||
126 | + } | ||
127 | + }); | ||
128 | + } else { | ||
129 | + logger.error('getBrandShopGoodsOriginData api code no 200'); | ||
117 | } | 130 | } |
131 | + | ||
132 | + return camelCase(finalResult); | ||
118 | }); | 133 | }); |
119 | } else { | 134 | } else { |
120 | - logger.error('getBrandShopGoodsOriginData api code no 200'); | 135 | + logger.error('getBrandInfoByDomain api code no 200'); |
121 | } | 136 | } |
122 | 137 | ||
123 | return camelCase(finalResult); | 138 | return camelCase(finalResult); |
@@ -15,7 +15,7 @@ module.exports = { | @@ -15,7 +15,7 @@ module.exports = { | ||
15 | port: 6004, | 15 | port: 6004, |
16 | siteUrl: '//m.yohoblk.com', | 16 | siteUrl: '//m.yohoblk.com', |
17 | domains: { | 17 | domains: { |
18 | - api: 'http://devapi.yoho.cn:58078/', | 18 | + api: 'http://192.168.102.202:8080/gateway/', |
19 | service: 'http://devservice.yoho.cn:58077/' | 19 | service: 'http://devservice.yoho.cn:58077/' |
20 | }, | 20 | }, |
21 | subDomains: { | 21 | subDomains: { |
@@ -33,7 +33,9 @@ | @@ -33,7 +33,9 @@ | ||
33 | // query | 33 | // query |
34 | url: '/product/get-brand-shop-goods', | 34 | url: '/product/get-brand-shop-goods', |
35 | sort: '', | 35 | sort: '', |
36 | - filter: {}, | 36 | + filter: { |
37 | + domain: qs.domain | ||
38 | + }, | ||
37 | page: 0, // page= 0 未搜索, 1 并且productList.length =0 没有数据, page = page_total 全部加载完 | 39 | page: 0, // page= 0 未搜索, 1 并且productList.length =0 没有数据, page = page_total 全部加载完 |
38 | totalPage: 3, | 40 | totalPage: 3, |
39 | 41 | ||
@@ -46,7 +48,7 @@ | @@ -46,7 +48,7 @@ | ||
46 | }, | 48 | }, |
47 | watch: { | 49 | watch: { |
48 | domain: function() { | 50 | domain: function() { |
49 | - this.getShopInfo(); | 51 | + this.search(); |
50 | }, | 52 | }, |
51 | 53 | ||
52 | /* sort 和 filter 改变 都会触发 重新搜索 (想象成清空所有分页) */ | 54 | /* sort 和 filter 改变 都会触发 重新搜索 (想象成清空所有分页) */ |
@@ -80,18 +82,6 @@ | @@ -80,18 +82,6 @@ | ||
80 | tip('网络错误'); | 82 | tip('网络错误'); |
81 | }); | 83 | }); |
82 | }, | 84 | }, |
83 | - getProductList() { | ||
84 | - let data = {}; | ||
85 | - | ||
86 | - $.ajax({ | ||
87 | - url: this.url, | ||
88 | - data: data | ||
89 | - }).done(result => { | ||
90 | - this.productList = result.data.productList; | ||
91 | - }).fail(() => { | ||
92 | - tip('网络错误'); | ||
93 | - }); | ||
94 | - }, | ||
95 | search: function() { | 85 | search: function() { |
96 | const self = this; | 86 | const self = this; |
97 | 87 | ||
@@ -140,8 +130,7 @@ | @@ -140,8 +130,7 @@ | ||
140 | }, | 130 | }, |
141 | created() { | 131 | created() { |
142 | this.getShopInfo(); | 132 | this.getShopInfo(); |
143 | - | ||
144 | -// this.search(); | 133 | + this.search(); |
145 | bus.$on('list.paging', function() { | 134 | bus.$on('list.paging', function() { |
146 | this.search(); | 135 | this.search(); |
147 | }); | 136 | }); |
-
Please register or login to post a comment