Merge branch 'release/newSearch' of http://git.yoho.cn/fe/yohobuy-node into release/newSearch
Showing
5 changed files
with
55 additions
and
18 deletions
@@ -197,10 +197,14 @@ exports.isFavoriteBrand = (req, res, next) => { | @@ -197,10 +197,14 @@ exports.isFavoriteBrand = (req, res, next) => { | ||
197 | let uid = req.user.uid; | 197 | let uid = req.user.uid; |
198 | let brandId = req.body.brandId; | 198 | let brandId = req.body.brandId; |
199 | 199 | ||
200 | - if (!req.xhr || !req.body.brandId || !uid) { | 200 | + if (!req.xhr) { |
201 | return next(); | 201 | return next(); |
202 | } | 202 | } |
203 | 203 | ||
204 | + if (!req.body.brandId || !uid) { | ||
205 | + return res.json({code: 400, message: '用户未登录或缺少参数'}); | ||
206 | + } | ||
207 | + | ||
204 | searchApi.isFavoriteBrand(uid, brandId).then(result => { | 208 | searchApi.isFavoriteBrand(uid, brandId).then(result => { |
205 | res.json(result); | 209 | res.json(result); |
206 | }).catch(next); | 210 | }).catch(next); |
@@ -81,16 +81,20 @@ exports.getListData = (params, channel) => { | @@ -81,16 +81,20 @@ exports.getListData = (params, channel) => { | ||
81 | 81 | ||
82 | // 获取左侧类目数据 | 82 | // 获取左侧类目数据 |
83 | if (result[1].code === 200) { | 83 | if (result[1].code === 200) { |
84 | + let dps = {}; | ||
85 | + | ||
86 | + if (params.gender) { | ||
87 | + dps.gender = params.gender; | ||
88 | + } | ||
84 | finalResult.list = Object.assign( | 89 | finalResult.list = Object.assign( |
85 | searchHandler.handlePathNavData(result[1].data.sort, params, 'sort', channel), { | 90 | searchHandler.handlePathNavData(result[1].data.sort, params, 'sort', channel), { |
86 | - leftContent: searchHandler.handleSortData(result[1].data.sort, params) | 91 | + leftContent: searchHandler.handleSortData(result[1].data.sort, dps) |
87 | }); | 92 | }); |
88 | } | 93 | } |
89 | 94 | ||
90 | // 获取商品数据和顶部筛选条件 | 95 | // 获取商品数据和顶部筛选条件 |
91 | if (result[2].code === 200) { | 96 | if (result[2].code === 200) { |
92 | Object.assign(finalResult.list, { | 97 | Object.assign(finalResult.list, { |
93 | - // filters: searchHandler.handleFilterData(result[2].data.filter, params), | ||
94 | filters: searchHandler.handleFilterDataAll(result[2].data, params), | 98 | filters: searchHandler.handleFilterDataAll(result[2].data, params), |
95 | opts: searchHandler.handleOptsData(params, result[2].data.total, result[2].data.filter), | 99 | opts: searchHandler.handleOptsData(params, result[2].data.total, result[2].data.filter), |
96 | totalCount: result[2].data.total, | 100 | totalCount: result[2].data.total, |
@@ -148,19 +152,23 @@ exports.getListNewData = (params, channel) => { | @@ -148,19 +152,23 @@ exports.getListNewData = (params, channel) => { | ||
148 | leftContent: {} | 152 | leftContent: {} |
149 | } | 153 | } |
150 | }; | 154 | }; |
155 | + let dps = {}; | ||
156 | + | ||
157 | + if (params.gender) { | ||
158 | + dps.gender = params.gender; | ||
159 | + } | ||
151 | 160 | ||
152 | // 获取左侧类目数据 | 161 | // 获取左侧类目数据 |
153 | if (result[1].code === 200) { | 162 | if (result[1].code === 200) { |
154 | finalResult.list = Object.assign( | 163 | finalResult.list = Object.assign( |
155 | searchHandler.handlePathNavData(result[1].data.sort, params, 'new', channel), { | 164 | searchHandler.handlePathNavData(result[1].data.sort, params, 'new', channel), { |
156 | - leftContent: searchHandler.handleSortData(result[1].data.sort, params) | 165 | + leftContent: searchHandler.handleSortData(result[1].data.sort, dps) |
157 | }); | 166 | }); |
158 | } | 167 | } |
159 | 168 | ||
160 | // 获取商品数据和顶部筛选条件 | 169 | // 获取商品数据和顶部筛选条件 |
161 | if (result[2].code === 200) { | 170 | if (result[2].code === 200) { |
162 | Object.assign(finalResult.list, { | 171 | Object.assign(finalResult.list, { |
163 | - // filters: searchHandler.handleFilterData(result[2].data.filter, params), | ||
164 | filters: searchHandler.handleFilterDataAll(result[2].data, params), | 172 | filters: searchHandler.handleFilterDataAll(result[2].data, params), |
165 | opts: searchHandler.handleOptsData(params, result[2].data.total, result[2].data.filter), | 173 | opts: searchHandler.handleOptsData(params, result[2].data.total, result[2].data.filter), |
166 | totalCount: result[2].data.total, | 174 | totalCount: result[2].data.total, |
@@ -176,7 +184,7 @@ exports.getListNewData = (params, channel) => { | @@ -176,7 +184,7 @@ exports.getListNewData = (params, channel) => { | ||
176 | 184 | ||
177 | // 新品上架 | 185 | // 新品上架 |
178 | if (result[3] && result[3].code === 200) { | 186 | if (result[3] && result[3].code === 200) { |
179 | - Object.assign(finalResult.list.leftContent, searchHandler.handleWeekNew(result[3].data, params)); | 187 | + Object.assign(finalResult.list.leftContent, searchHandler.handleWeekNew(result[3].data, dps)); |
180 | } | 188 | } |
181 | 189 | ||
182 | finalResult.criteo = {skn: searchHandler.getCriteo(_.get(finalResult.list, 'goods'))}; | 190 | finalResult.criteo = {skn: searchHandler.getCriteo(_.get(finalResult.list, 'goods'))}; |
@@ -247,8 +255,13 @@ exports.getBrandData = (params, extra, channel) => { | @@ -247,8 +255,13 @@ exports.getBrandData = (params, extra, channel) => { | ||
247 | 255 | ||
248 | // 获取左侧类目数据 | 256 | // 获取左侧类目数据 |
249 | if (result[1].code === 200) { | 257 | if (result[1].code === 200) { |
258 | + let dps = {}; | ||
259 | + | ||
260 | + if (params.gender) { | ||
261 | + dps.gender = params.gender; | ||
262 | + } | ||
250 | Object.assign(finalResult.brand, { | 263 | Object.assign(finalResult.brand, { |
251 | - leftContent: searchHandler.handleSortData(result[1].data.sort, params) | 264 | + leftContent: searchHandler.handleSortData(result[1].data.sort, dps) |
252 | }, searchHandler.handlePathNavData(extra, params, 'brand', channel)); | 265 | }, searchHandler.handlePathNavData(extra, params, 'brand', channel)); |
253 | } | 266 | } |
254 | 267 | ||
@@ -564,7 +577,8 @@ exports.getShopData = (shopId, channel, params, shopInfo) => { | @@ -564,7 +577,8 @@ exports.getShopData = (shopId, channel, params, shopInfo) => { | ||
564 | for (let i = 0; i < 3; i++) { | 577 | for (let i = 0; i < 3; i++) { |
565 | trendList.push({ | 578 | trendList.push({ |
566 | href: articleList[i].url, | 579 | href: articleList[i].url, |
567 | - src: articleList[i].src, | 580 | + src: helpers.getForceSourceUrl(articleList[i].src) + |
581 | + '?imageView/1/w/{width}/h/{height}', | ||
568 | mainTitle: articleList[i].title, | 582 | mainTitle: articleList[i].title, |
569 | Subtitle: articleList[i].intro | 583 | Subtitle: articleList[i].intro |
570 | }); | 584 | }); |
@@ -481,7 +481,7 @@ exports.handleSortData = (origin, params) => { | @@ -481,7 +481,7 @@ exports.handleSortData = (origin, params) => { | ||
481 | sortId: value.sort_id | 481 | sortId: value.sort_id |
482 | } | 482 | } |
483 | ], | 483 | ], |
484 | - href: handleFilterUrl(params, {msort: value.sort_id}), | 484 | + href: handleFilterUrl(params, {msort: value.sort_id}, {misort: true}), |
485 | active: params.msort === value.sort_id, | 485 | active: params.msort === value.sort_id, |
486 | sortId: value.sort_id | 486 | sortId: value.sort_id |
487 | }; | 487 | }; |
@@ -604,19 +604,27 @@ exports.handleFilterData = (origin, params, total) => { | @@ -604,19 +604,27 @@ exports.handleFilterData = (origin, params, total) => { | ||
604 | 604 | ||
605 | // 处理用户自主填写的价格区间 | 605 | // 处理用户自主填写的价格区间 |
606 | if (!priceRangechecked && params.price) { | 606 | if (!priceRangechecked && params.price) { |
607 | - let customPrice = _.split(params.price, ','); | 607 | + let customPrice = _.split(params.price, ','), |
608 | + min = customPrice[0] || 0, | ||
609 | + name; | ||
610 | + | ||
611 | + customPrice[0] = customPrice[0]; | ||
612 | + name = `¥ ${min}-${customPrice[1]}`; | ||
613 | + | ||
614 | + if (!customPrice[1]) { | ||
615 | + customPrice[1] = ''; | ||
616 | + name = `¥ ${min}以上`; | ||
617 | + } | ||
608 | 618 | ||
609 | - if (customPrice[1] !== '99999') { | ||
610 | dest.customPrice = { | 619 | dest.customPrice = { |
611 | min: customPrice[0], | 620 | min: customPrice[0], |
612 | max: customPrice[1] | 621 | max: customPrice[1] |
613 | }; | 622 | }; |
614 | dest.checkedConditions.conditions.push({ | 623 | dest.checkedConditions.conditions.push({ |
615 | - name: '¥ ' + customPrice[0] + '-' + customPrice[1], | ||
616 | - href: handleFilterUrl(params, {price: ''}) | 624 | + name: name, |
625 | + href: handleFilterUrl(params, {}, {price: true}) | ||
617 | }); | 626 | }); |
618 | } | 627 | } |
619 | - } | ||
620 | 628 | ||
621 | // 处理性别数据 | 629 | // 处理性别数据 |
622 | dest.gender = [{ | 630 | dest.gender = [{ |
@@ -851,7 +859,10 @@ exports.handleSeniorFilterData = (data, params) => { | @@ -851,7 +859,10 @@ exports.handleSeniorFilterData = (data, params) => { | ||
851 | return resData; | 859 | return resData; |
852 | }; | 860 | }; |
853 | 861 | ||
854 | -exports.handleFilterDataAll = (data, params) => { | 862 | +exports.handleFilterDataAll = (data, qs) => { |
863 | + let params = _.cloneDeep(qs); | ||
864 | + | ||
865 | + _.unset(params, 'page'); // 去除筛选项page | ||
855 | 866 | ||
856 | let baseFilter = this.handleFilterData(data.filter, params, data.total); | 867 | let baseFilter = this.handleFilterData(data.filter, params, data.total); |
857 | let seniorFilter = this.handleSeniorFilterData({ | 868 | let seniorFilter = this.handleSeniorFilterData({ |
@@ -44,8 +44,13 @@ exports.getSearchData = (params, channel) => { | @@ -44,8 +44,13 @@ exports.getSearchData = (params, channel) => { | ||
44 | 44 | ||
45 | // 获取左侧类目数据 | 45 | // 获取左侧类目数据 |
46 | if (result[1].code === 200) { | 46 | if (result[1].code === 200) { |
47 | + let dps = {}; | ||
48 | + | ||
49 | + if (params.query) { | ||
50 | + dps.query = params.query; | ||
51 | + } | ||
47 | finalResult.search = { | 52 | finalResult.search = { |
48 | - leftContent: searchHandler.handleSortData(result[1].data.sort, params) | 53 | + leftContent: searchHandler.handleSortData(result[1].data.sort, dps) |
49 | }; | 54 | }; |
50 | } | 55 | } |
51 | 56 |
@@ -7,7 +7,6 @@ | @@ -7,7 +7,6 @@ | ||
7 | 7 | ||
8 | module.exports = () => { | 8 | module.exports = () => { |
9 | return (req, res, next) => { | 9 | return (req, res, next) => { |
10 | - | ||
11 | let searchReg = /^\/product\//; | 10 | let searchReg = /^\/product\//; |
12 | 11 | ||
13 | if (req.subdomains.length) { | 12 | if (req.subdomains.length) { |
@@ -28,7 +27,11 @@ module.exports = () => { | @@ -28,7 +27,11 @@ module.exports = () => { | ||
28 | } | 27 | } |
29 | break; | 28 | break; |
30 | case 'list': // 商品列表 | 29 | case 'list': // 商品列表 |
31 | - req.url = req.path === '/new' ? '/product/list/new' : '/product/list/index'; | 30 | + if (!req.path || req.path === '/') { |
31 | + req.url = '/product/list/index'; | ||
32 | + } else if (req.path === '/new') { | ||
33 | + req.url = '/product/list/new'; | ||
34 | + } | ||
32 | break; | 35 | break; |
33 | case 'sale': // 促销 | 36 | case 'sale': // 促销 |
34 | if (!req.path || req.path === '/') { | 37 | if (!req.path || req.path === '/') { |
-
Please register or login to post a comment