Merge branch 'hotfix/brand-fav' into release/new-product-detail-api
Showing
14 changed files
with
87 additions
and
34 deletions
@@ -33,7 +33,7 @@ exports.getNewArrival = (req, res, next) => { | @@ -33,7 +33,7 @@ exports.getNewArrival = (req, res, next) => { | ||
33 | let reqBody = req.body, | 33 | let reqBody = req.body, |
34 | pageIndex = reqBody.pageIndex, | 34 | pageIndex = reqBody.pageIndex, |
35 | pageCount = reqBody.pageCount, | 35 | pageCount = reqBody.pageCount, |
36 | - channel = reqBody.type, | 36 | + channel = reqBody.type || req.yoho.channel, |
37 | goods = [], | 37 | goods = [], |
38 | result = {}; | 38 | result = {}; |
39 | 39 |
@@ -15,7 +15,7 @@ const searchApi = require(`${mRoot}/search-api`); | @@ -15,7 +15,7 @@ const searchApi = require(`${mRoot}/search-api`); | ||
15 | const shop = (shopId, req, res, next, brandInfo) => { | 15 | const shop = (shopId, req, res, next, brandInfo) => { |
16 | shopId = parseInt(shopId, 10); | 16 | shopId = parseInt(shopId, 10); |
17 | 17 | ||
18 | - list.getShopInfo(shopId, req.user.id).then(shopInfo => { | 18 | + list.getShopInfo(shopId, req.user.uid).then(shopInfo => { |
19 | if (+shopInfo.shopTemplateType === 2) { // 经典模板 | 19 | if (+shopInfo.shopTemplateType === 2) { // 经典模板 |
20 | let pjax = req.query._pjax; | 20 | let pjax = req.query._pjax; |
21 | 21 | ||
@@ -158,7 +158,7 @@ exports.shopList = (req, res, next) => { | @@ -158,7 +158,7 @@ exports.shopList = (req, res, next) => { | ||
158 | return next(); | 158 | return next(); |
159 | } | 159 | } |
160 | 160 | ||
161 | - list.getShopListData(req.yoho.channel, req.query).then(result => { | 161 | + list.getShopListData(req.yoho.channel, req.query, req.user.uid).then(result => { |
162 | Object.assign(result, { | 162 | Object.assign(result, { |
163 | page: 'shop', | 163 | page: 'shop', |
164 | shopId: shopId | 164 | shopId: shopId |
@@ -16,7 +16,7 @@ const sale = require(`${mRoot}/sale`); // sale 页 model | @@ -16,7 +16,7 @@ const sale = require(`${mRoot}/sale`); // sale 页 model | ||
16 | * @return {[type]} [description] | 16 | * @return {[type]} [description] |
17 | */ | 17 | */ |
18 | exports.index = (req, res, next) => { | 18 | exports.index = (req, res, next) => { |
19 | - let channel = req.query.channel || req.cookies._Channel || 'boys'; | 19 | + let channel = req.query.channel || req.yoho.channel; |
20 | 20 | ||
21 | // 真实数据输出 | 21 | // 真实数据输出 |
22 | sale.getSaleIndexData(channel).then(result => { | 22 | sale.getSaleIndexData(channel).then(result => { |
@@ -41,7 +41,7 @@ exports.discount = (req, res, next) => { | @@ -41,7 +41,7 @@ exports.discount = (req, res, next) => { | ||
41 | saleType: '3' | 41 | saleType: '3' |
42 | }, req.query); | 42 | }, req.query); |
43 | 43 | ||
44 | - let channel = req.query.channel || req.cookies._Channel || 'boys'; | 44 | + let channel = req.query.channel || req.yoho.channel; |
45 | 45 | ||
46 | let responseData = { | 46 | let responseData = { |
47 | module: 'product', | 47 | module: 'product', |
@@ -68,7 +68,7 @@ exports.vip = (req, res, next) => { | @@ -68,7 +68,7 @@ exports.vip = (req, res, next) => { | ||
68 | saleType: '2' | 68 | saleType: '2' |
69 | }, req.query); | 69 | }, req.query); |
70 | 70 | ||
71 | - let channel = req.query.channel || req.cookies._Channel || 'boys'; | 71 | + let channel = req.query.channel || req.yoho.channel; |
72 | 72 | ||
73 | params.uid = req.user.uid || 0; | 73 | params.uid = req.user.uid || 0; |
74 | 74 | ||
@@ -95,7 +95,7 @@ exports.newSale = (req, res, next) => { | @@ -95,7 +95,7 @@ exports.newSale = (req, res, next) => { | ||
95 | order: 's_t_desc' | 95 | order: 's_t_desc' |
96 | }, req.query); | 96 | }, req.query); |
97 | 97 | ||
98 | - let channel = req.query.channel || req.cookies._Channel || 'boys'; | 98 | + let channel = req.query.channel || req.yoho.channel; |
99 | 99 | ||
100 | sale.getSaleOthersData(params, channel).then((result) => { | 100 | sale.getSaleOthersData(params, channel).then((result) => { |
101 | res.render('sale/other', Object.assign({ | 101 | res.render('sale/other', Object.assign({ |
@@ -119,7 +119,7 @@ exports.breakingYards = (req, res, next) => { | @@ -119,7 +119,7 @@ exports.breakingYards = (req, res, next) => { | ||
119 | saleType: '5' | 119 | saleType: '5' |
120 | }, req.query); | 120 | }, req.query); |
121 | 121 | ||
122 | - let channel = req.query.channel || req.cookies._Channel || 'boys'; | 122 | + let channel = req.query.channel || req.yoho.channel; |
123 | 123 | ||
124 | let responseData = { | 124 | let responseData = { |
125 | module: 'product', | 125 | module: 'product', |
@@ -217,7 +217,7 @@ const _getBrandDataByProductBaseInfo = (data, additionalData) => { | @@ -217,7 +217,7 @@ const _getBrandDataByProductBaseInfo = (data, additionalData) => { | ||
217 | return {}; | 217 | return {}; |
218 | } | 218 | } |
219 | 219 | ||
220 | - let brandId = data.brand_info.id; | 220 | + let brandId = data.brand_info.brand_id; |
221 | let bgImg = ''; | 221 | let bgImg = ''; |
222 | let logo = ''; | 222 | let logo = ''; |
223 | let bannerInfo = null; | 223 | let bannerInfo = null; |
@@ -118,7 +118,9 @@ const getListData = (params, channel) => { | @@ -118,7 +118,9 @@ const getListData = (params, channel) => { | ||
118 | totalCount: result[2].data.total, | 118 | totalCount: result[2].data.total, |
119 | footPager: searchHandler.handlePagerData(result[2].data.total, params), | 119 | footPager: searchHandler.handlePagerData(result[2].data.total, params), |
120 | goods: productProcess.processProductList(result[2].data.product_list, | 120 | goods: productProcess.processProductList(result[2].data.product_list, |
121 | - Object.assign({showDiscount: false}, params)), | 121 | + Object.assign({showDiscount: false}, params, { |
122 | + from: {type: 'list', params: params} | ||
123 | + })), | ||
122 | hasNextPage: searchHandler.handleNextPage(params, result[2].data.total), | 124 | hasNextPage: searchHandler.handleNextPage(params, result[2].data.total), |
123 | 125 | ||
124 | // 最近浏览记录 | 126 | // 最近浏览记录 |
@@ -194,7 +196,8 @@ const getListNewData = (params, channel) => { | @@ -194,7 +196,8 @@ const getListNewData = (params, channel) => { | ||
194 | totalCount: result[2].data.total, | 196 | totalCount: result[2].data.total, |
195 | footPager: searchHandler.handlePagerData(result[2].data.total, params), | 197 | footPager: searchHandler.handlePagerData(result[2].data.total, params), |
196 | goods: productProcess.processProductList(result[2].data.product_list, | 198 | goods: productProcess.processProductList(result[2].data.product_list, |
197 | - Object.assign({showDiscount: false, showNew: false}, params)), | 199 | + Object.assign({showDiscount: false, showNew: false, |
200 | + from: {type: 'listNew', params: params}}, params)), | ||
198 | hasNextPage: searchHandler.handleNextPage(params, result[2].data.total), | 201 | hasNextPage: searchHandler.handleNextPage(params, result[2].data.total), |
199 | 202 | ||
200 | // 最近浏览记录 | 203 | // 最近浏览记录 |
@@ -265,7 +268,7 @@ const getBrandData = (params, extra, channel) => { | @@ -265,7 +268,7 @@ const getBrandData = (params, extra, channel) => { | ||
265 | let apiMethod = [ | 268 | let apiMethod = [ |
266 | headerModel.requestHeaderData(channel), | 269 | headerModel.requestHeaderData(channel), |
267 | searchApi.getSortList(queryBase), | 270 | searchApi.getSortList(queryBase), |
268 | - searchApi.getProductList(Object.assign({order: order}, searchParams, queryBase)) | 271 | + searchApi.getProductList(Object.assign(searchParams, {order: order}, queryBase)) |
269 | 272 | ||
270 | ]; | 273 | ]; |
271 | 274 | ||
@@ -304,16 +307,16 @@ const getBrandData = (params, extra, channel) => { | @@ -304,16 +307,16 @@ const getBrandData = (params, extra, channel) => { | ||
304 | totalCount: result[2].data.total, | 307 | totalCount: result[2].data.total, |
305 | footPager: searchHandler.handlePagerData(result[2].data.total, params), | 308 | footPager: searchHandler.handlePagerData(result[2].data.total, params), |
306 | goods: productProcess.processProductList(result[2].data.product_list, | 309 | goods: productProcess.processProductList(result[2].data.product_list, |
307 | - Object.assign({showDiscount: false}, params)), | 310 | + Object.assign({showDiscount: false, from: {type: 'brand', params: params}}, params)), |
308 | hasNextPage: searchHandler.handleNextPage(params, result[2].data.total), | 311 | hasNextPage: searchHandler.handleNextPage(params, result[2].data.total), |
309 | 312 | ||
310 | // 最近浏览记录 | 313 | // 最近浏览记录 |
311 | latestWalk: 7 | 314 | latestWalk: 7 |
312 | }); | 315 | }); |
313 | - } | ||
314 | 316 | ||
315 | - // 品牌页不显示品牌筛选项 | ||
316 | - delete finalResult.brand.filters.brand; | 317 | + // 品牌页不显示品牌筛选项 |
318 | + _.unset(finalResult, 'brand.filters.brand'); | ||
319 | + } | ||
317 | 320 | ||
318 | finalResult.criteo = {skn: searchHandler.getCriteo(_.get(finalResult.brand, 'goods'))}; | 321 | finalResult.criteo = {skn: searchHandler.getCriteo(_.get(finalResult.brand, 'goods'))}; |
319 | 322 | ||
@@ -417,7 +420,7 @@ const getShopAbout = (shopId, uid, channel) => { | @@ -417,7 +420,7 @@ const getShopAbout = (shopId, uid, channel) => { | ||
417 | 420 | ||
418 | if (result[1].code === 200) { | 421 | if (result[1].code === 200) { |
419 | let data = result[1].data || {}, | 422 | let data = result[1].data || {}, |
420 | - decorator = shopHandler.getShopDecorator(data, {}, shopId); | 423 | + decorator = shopHandler.getShopDecorator(data, {}, shopId, true); |
421 | 424 | ||
422 | Object.assign(decorator.shopTopBannerBase, { | 425 | Object.assign(decorator.shopTopBannerBase, { |
423 | shopId: shopId, | 426 | shopId: shopId, |
@@ -637,7 +640,8 @@ const getShopData = (shopId, channel, params, shopInfo) => { | @@ -637,7 +640,8 @@ const getShopData = (shopId, channel, params, shopInfo) => { | ||
637 | finalResult.leftContent = searchHandler.handleSortData(groupSort, params); | 640 | finalResult.leftContent = searchHandler.handleSortData(groupSort, params); |
638 | 641 | ||
639 | if (finalResult.allGoods) { | 642 | if (finalResult.allGoods) { |
640 | - Object.assign(finalResult.allGoods, searchHandler.setShopSort(groupSort, params)); | 643 | + Object.assign(finalResult.allGoods, searchHandler.setShopSort(groupSort, Object.assign({}, |
644 | + params, {page: 1}))); | ||
641 | } | 645 | } |
642 | } | 646 | } |
643 | 647 | ||
@@ -652,7 +656,7 @@ const getShopData = (shopId, channel, params, shopInfo) => { | @@ -652,7 +656,7 @@ const getShopData = (shopId, channel, params, shopInfo) => { | ||
652 | 656 | ||
653 | for (let i = 0; i < 3; i++) { | 657 | for (let i = 0; i < 3; i++) { |
654 | trendList.push({ | 658 | trendList.push({ |
655 | - href: articleList[i].url, | 659 | + href: helpers.urlFormat(`/${articleList[i].id}.html`, '', 'guang'), |
656 | src: helpers.getForceSourceUrl(articleList[i].src) + | 660 | src: helpers.getForceSourceUrl(articleList[i].src) + |
657 | '?imageView/1/w/{width}/h/{height}', | 661 | '?imageView/1/w/{width}/h/{height}', |
658 | mainTitle: articleList[i].title, | 662 | mainTitle: articleList[i].title, |
@@ -712,7 +716,8 @@ const getShopGoodsData = (shopId, channel, params) => { | @@ -712,7 +716,8 @@ const getShopGoodsData = (shopId, channel, params) => { | ||
712 | if (subRes.code === 200) { | 716 | if (subRes.code === 200) { |
713 | let groupSort = _.get(subRes, 'data.sort', []); | 717 | let groupSort = _.get(subRes, 'data.sort', []); |
714 | 718 | ||
715 | - Object.assign(resData, searchHandler.setShopSort(groupSort, params)); | 719 | + Object.assign(resData, searchHandler.setShopSort(groupSort, Object.assign(params, |
720 | + {page: 1}))); | ||
716 | } | 721 | } |
717 | 722 | ||
718 | return resData; | 723 | return resData; |
@@ -794,6 +799,9 @@ const getShopListData = (channel, params, uid) => { | @@ -794,6 +799,9 @@ const getShopListData = (channel, params, uid) => { | ||
794 | }), | 799 | }), |
795 | footPager: {tip: tip} | 800 | footPager: {tip: tip} |
796 | }); | 801 | }); |
802 | + | ||
803 | + _.set(finalResult, 'filters.checkedConditions.clearUrl', | ||
804 | + `?navBar=${params.navBar}&shopId=${params.shopId}`); | ||
797 | } else { | 805 | } else { |
798 | finalResult.searchEmpty = true; | 806 | finalResult.searchEmpty = true; |
799 | 807 | ||
@@ -886,6 +894,11 @@ const getBaseShopData = (params, extra, channel, shopId) => { | @@ -886,6 +894,11 @@ const getBaseShopData = (params, extra, channel, shopId) => { | ||
886 | }); | 894 | }); |
887 | } | 895 | } |
888 | 896 | ||
897 | + // 临时删除seo信息 | ||
898 | + _.unset(resData, 'title'); | ||
899 | + _.unset(resData, 'keywords'); | ||
900 | + _.unset(resData, 'description'); | ||
901 | + | ||
889 | return resData; | 902 | return resData; |
890 | }); | 903 | }); |
891 | }; | 904 | }; |
@@ -63,14 +63,14 @@ exports.getSalebreakingYardsSortList = (params) => { | @@ -63,14 +63,14 @@ exports.getSalebreakingYardsSortList = (params) => { | ||
63 | * @return {[type]} [description] | 63 | * @return {[type]} [description] |
64 | */ | 64 | */ |
65 | exports.getSaleActivityList = (params, channel) => { | 65 | exports.getSaleActivityList = (params, channel) => { |
66 | - let tempChannel = _.isEmpty(channel) ? 'boys' : channel; | 66 | + let tempChannel = yhChannel[channel] || yhChannel.boys; |
67 | 67 | ||
68 | return api.get('', { | 68 | return api.get('', { |
69 | id: params.id || null, | 69 | id: params.id || null, |
70 | method: 'app.activity.get', | 70 | method: 'app.activity.get', |
71 | sort: '2', | 71 | sort: '2', |
72 | plateform: '1', | 72 | plateform: '1', |
73 | - yh_channel: yhChannel[tempChannel].channel | 73 | + yh_channel: tempChannel.channel |
74 | }); | 74 | }); |
75 | }; | 75 | }; |
76 | 76 |
@@ -379,7 +379,8 @@ exports.getSaleDiscountData = (params, channel) => { | @@ -379,7 +379,8 @@ exports.getSaleDiscountData = (params, channel) => { | ||
379 | // 处理分页等筛选信息 | 379 | // 处理分页等筛选信息 |
380 | if (subResult[0].code === 200) { | 380 | if (subResult[0].code === 200) { |
381 | Object.assign(finalResult, { | 381 | Object.assign(finalResult, { |
382 | - leftContent: publicHandler.handleSaleSortData(subResult[0].data.filter.group_sort, params, 'discount'), | 382 | + leftContent: publicHandler.handleSaleSortData(subResult[0].data.filter.group_sort, |
383 | + params, 'discount'), | ||
383 | saleList: { | 384 | saleList: { |
384 | footPager: publicHandler.handlePagerData(subResult[0].data.total, params), | 385 | footPager: publicHandler.handlePagerData(subResult[0].data.total, params), |
385 | opts: publicHandler.handleSaleOptsData(params, subResult[0].data.total, 'default') | 386 | opts: publicHandler.handleSaleOptsData(params, subResult[0].data.total, 'default') |
@@ -528,7 +529,7 @@ exports.getSaleSpecialData = (id, params, channel) => { | @@ -528,7 +529,7 @@ exports.getSaleSpecialData = (id, params, channel) => { | ||
528 | limit: limit, | 529 | limit: limit, |
529 | attribute_not: 2 | 530 | attribute_not: 2 |
530 | }); | 531 | }); |
531 | - let banner = JSON.parse(data.banner_img) || []; | 532 | + let banner = data.banner_img ? JSON.parse(data.banner_img) : []; |
532 | 533 | ||
533 | Object.assign(resData, { | 534 | Object.assign(resData, { |
534 | mainBanner: { | 535 | mainBanner: { |
@@ -580,7 +581,8 @@ exports.getSaleSpecialData = (id, params, channel) => { | @@ -580,7 +581,8 @@ exports.getSaleSpecialData = (id, params, channel) => { | ||
580 | Object.assign(resData, { | 581 | Object.assign(resData, { |
581 | filters: searchHandler.handleFilterDataAll(_.get(result[2], 'data', {}), params), | 582 | filters: searchHandler.handleFilterDataAll(_.get(result[2], 'data', {}), params), |
582 | opts: searchHandler.handleOptsData(params, tip.total), | 583 | opts: searchHandler.handleOptsData(params, tip.total), |
583 | - goods: productProcess.processProductList(_.get(result[2], 'data.product_list', [])), | 584 | + goods: productProcess.processProductList(_.get(result[2], 'data.product_list', []), |
585 | + {from: {type: 'saleSpecial', params: params}}), | ||
584 | footPager: {tip: tip} | 586 | footPager: {tip: tip} |
585 | }); | 587 | }); |
586 | 588 |
@@ -311,7 +311,7 @@ exports.handleOptsData = (params, total, extra) => { | @@ -311,7 +311,7 @@ exports.handleOptsData = (params, total, extra) => { | ||
311 | 311 | ||
312 | switch (i) { | 312 | switch (i) { |
313 | case 0: | 313 | case 0: |
314 | - opt.href = handleFilterUrl(params, {order: ''}, {page: true}); | 314 | + opt.href = handleFilterUrl(params, {}, {page: true, order: true}); |
315 | if (extra === 'discont') { // 如果是折扣专场 | 315 | if (extra === 'discont') { // 如果是折扣专场 |
316 | opt.name = '全部'; | 316 | opt.name = '全部'; |
317 | if (_.isEmpty(params.order) || params.order === 's_t_desc') { | 317 | if (_.isEmpty(params.order) || params.order === 's_t_desc') { |
@@ -582,6 +582,9 @@ exports.handleFilterData = (origin, params, total) => { | @@ -582,6 +582,9 @@ exports.handleFilterData = (origin, params, total) => { | ||
582 | if (params.price === key) { | 582 | if (params.price === key) { |
583 | priceRangechecked = true; | 583 | priceRangechecked = true; |
584 | } | 584 | } |
585 | + if (_.isString(value)) { | ||
586 | + value = _.replace(value, '¥', '¥'); | ||
587 | + } | ||
585 | let price = { | 588 | let price = { |
586 | checked: params.price === key, | 589 | checked: params.price === key, |
587 | href: handleFilterUrl(params, {price: key}), | 590 | href: handleFilterUrl(params, {price: key}), |
@@ -68,7 +68,7 @@ exports.getSearchData = (params, channel) => { | @@ -68,7 +68,7 @@ exports.getSearchData = (params, channel) => { | ||
68 | totalCount: result[2].data.total, | 68 | totalCount: result[2].data.total, |
69 | footPager: searchHandler.handlePagerData(result[2].data.total, params), | 69 | footPager: searchHandler.handlePagerData(result[2].data.total, params), |
70 | goods: productProcess.processProductList(result[2].data.product_list, | 70 | goods: productProcess.processProductList(result[2].data.product_list, |
71 | - Object.assign({showDiscount: false}, params)), | 71 | + Object.assign({showDiscount: false, from: {type: 'search', params: params}}, params)), |
72 | latestWalk: 6, | 72 | latestWalk: 6, |
73 | hasNextPage: searchHandler.handleNextPage(params, result[2].data.total), | 73 | hasNextPage: searchHandler.handleNextPage(params, result[2].data.total), |
74 | shopEntry: result[3] | 74 | shopEntry: result[3] |
@@ -78,7 +78,7 @@ | @@ -78,7 +78,7 @@ | ||
78 | </p> | 78 | </p> |
79 | <div class="hideList hide"> | 79 | <div class="hideList hide"> |
80 | {{#goods_list}} | 80 | {{#goods_list}} |
81 | - <li data-src="{{image images_url 280 374}}" data-url="{{../url}}" data-status="{{status}}"></li> | 81 | + <li data-src="{{image images_url 280 382}}" data-url="{{../url}}" data-status="{{status}}"></li> |
82 | {{/goods_list}} | 82 | {{/goods_list}} |
83 | </div> | 83 | </div> |
84 | </div> | 84 | </div> |
@@ -64,7 +64,7 @@ exports.setPager = (total, params)=>{ | @@ -64,7 +64,7 @@ exports.setPager = (total, params)=>{ | ||
64 | for (i = 1; i <= len; i++) { | 64 | for (i = 1; i <= len; i++) { |
65 | let p = currentPage + i + 2; | 65 | let p = currentPage + i + 2; |
66 | 66 | ||
67 | - if (i > total) { | 67 | + if (p > total) { |
68 | break; | 68 | break; |
69 | } | 69 | } |
70 | 70 | ||
@@ -78,7 +78,7 @@ exports.setPager = (total, params)=>{ | @@ -78,7 +78,7 @@ exports.setPager = (total, params)=>{ | ||
78 | for (i = 1; i <= len; i++) { | 78 | for (i = 1; i <= len; i++) { |
79 | let p = currentPage - i - 2; | 79 | let p = currentPage - i - 2; |
80 | 80 | ||
81 | - if (i < 1) { | 81 | + if (p < 1) { |
82 | break; | 82 | break; |
83 | } | 83 | } |
84 | 84 |
@@ -7,6 +7,15 @@ const helpers = global.yoho.helpers; | @@ -7,6 +7,15 @@ const helpers = global.yoho.helpers; | ||
7 | 7 | ||
8 | // const images = require(`${global.utils}/images`); | 8 | // const images = require(`${global.utils}/images`); |
9 | 9 | ||
10 | +const itemFromBase = { | ||
11 | + search: {domain: 'search', module: 's'}, // 搜索页search.yohobuy.com | ||
12 | + list: {domain: 'list', module: 'c'}, // list.yohobuy.com | ||
13 | + listSale: {domain: 'list', module: 's'}, // list.yohobuy.com/sale | ||
14 | + listNew: {domain: 'list', module: 'n'}, // list.yohobuy.com/new | ||
15 | + brand: {domain: 'brand', module: 'b'}, // xxx.yohobuy.com[品牌域名] | ||
16 | + saleSpecial: {domain: 'sale', module: 's'}// sale.yohobuy.com | ||
17 | +}; | ||
18 | + | ||
10 | // NOTE: 这里修改了图片质量的参数 | 19 | // NOTE: 这里修改了图片质量的参数 |
11 | helpers.image = _.flow(helpers.image, fp.replace(/\/quality\/\d*$/, '/quality/90')); | 20 | helpers.image = _.flow(helpers.image, fp.replace(/\/quality\/\d*$/, '/quality/90')); |
12 | 21 | ||
@@ -105,6 +114,8 @@ const procProductImgs = (item, gender) => { | @@ -105,6 +114,8 @@ const procProductImgs = (item, gender) => { | ||
105 | */ | 114 | */ |
106 | exports.processProductList = (list, options) => { | 115 | exports.processProductList = (list, options) => { |
107 | const pruductList = []; | 116 | const pruductList = []; |
117 | + let itemNum = 0, | ||
118 | + itemFrom; | ||
108 | 119 | ||
109 | options = Object.assign({ | 120 | options = Object.assign({ |
110 | showTags: true, | 121 | showTags: true, |
@@ -118,11 +129,30 @@ exports.processProductList = (list, options) => { | @@ -118,11 +129,30 @@ exports.processProductList = (list, options) => { | ||
118 | height: 388, | 129 | height: 388, |
119 | isApp: false, | 130 | isApp: false, |
120 | showPoint: true, | 131 | showPoint: true, |
121 | - gender: '2,3' | 132 | + gender: '2,3', |
133 | + from: {} // 来源 | ||
122 | }, options); | 134 | }, options); |
123 | 135 | ||
124 | - _.forEach(list, (product) => { | 136 | + // 处理item from |
137 | + if (!_.isEmpty(options.from) && itemFromBase[options.from.type]) { | ||
138 | + let f = {domain: '', module: '', key: ''}; | ||
139 | + let params = options.from.params || {}; | ||
140 | + | ||
141 | + f.page = params.page || 1; | ||
142 | + | ||
143 | + Object.assign(f, itemFromBase[options.from.type], { | ||
144 | + page: params.page || 1, | ||
145 | + key: params.misort || params.msort || '' | ||
146 | + }); | ||
125 | 147 | ||
148 | + if (options.from.type === 'search') { | ||
149 | + f.key = params.query || ''; | ||
150 | + } | ||
151 | + | ||
152 | + itemFrom = `from=${f.domain}-${f.module}-${f.key}_${f.page}_`; | ||
153 | + } | ||
154 | + | ||
155 | + _.forEach(list, (product) => { | ||
126 | 156 | ||
127 | // 商品信息有问题,则不显示 | 157 | // 商品信息有问题,则不显示 |
128 | if (!product || !product.product_skn || !product.goods_list.length) { | 158 | if (!product || !product.product_skn || !product.goods_list.length) { |
@@ -166,7 +196,7 @@ exports.processProductList = (list, options) => { | @@ -166,7 +196,7 @@ exports.processProductList = (list, options) => { | ||
166 | }); | 196 | }); |
167 | 197 | ||
168 | product.is_few = product.is_soon_sold_out === 'Y'; | 198 | product.is_few = product.is_soon_sold_out === 'Y'; |
169 | - product.url = helpers.urlFormat(`/product/pro_${product.product_id}_${product.goods_list[0].goods_id}/${product.cn_alphabet}.html`); // eslint-disable-line | 199 | + product.url = helpers.urlFormat(`/product/pro_${product.product_id}_${product.goods_list[0].goods_id}/${product.cn_alphabet}.html`, '', 'item'); // eslint-disable-line |
170 | 200 | ||
171 | // tar add 1606071146 品牌链接处理 | 201 | // tar add 1606071146 品牌链接处理 |
172 | product.brandUrl = helpers.urlFormat('', '', product.brand_domain); | 202 | product.brandUrl = helpers.urlFormat('', '', product.brand_domain); |
@@ -175,6 +205,10 @@ exports.processProductList = (list, options) => { | @@ -175,6 +205,10 @@ exports.processProductList = (list, options) => { | ||
175 | // 备注:如果以后APP的接口太多,可以把这边参数提取出来,变成一个公共的方法来生成,便于以后管理维护 | 205 | // 备注:如果以后APP的接口太多,可以把这边参数提取出来,变成一个公共的方法来生成,便于以后管理维护 |
176 | if (options.isApp) { | 206 | if (options.isApp) { |
177 | product.url += `?openby:yohobuy={"action":"go.productDetail","params":{"product_skn":'${product.product_id}'}}`; // eslint-disable-line | 207 | product.url += `?openby:yohobuy={"action":"go.productDetail","params":{"product_skn":'${product.product_id}'}}`; // eslint-disable-line |
208 | + } else if (itemFrom) { | ||
209 | + // 累加商品数量 | ||
210 | + itemNum++; | ||
211 | + product.url += `?${itemFrom}${itemNum}`; | ||
178 | } | 212 | } |
179 | 213 | ||
180 | if (options.showTags) { | 214 | if (options.showTags) { |
-
Please register or login to post a comment