Showing
4 changed files
with
48 additions
and
9 deletions
@@ -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 | // 最近浏览记录 |
@@ -304,7 +307,7 @@ const getBrandData = (params, extra, channel) => { | @@ -304,7 +307,7 @@ 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 | // 最近浏览记录 |
@@ -376,7 +376,8 @@ exports.getSaleDiscountData = (params, channel) => { | @@ -376,7 +376,8 @@ exports.getSaleDiscountData = (params, channel) => { | ||
376 | // 处理分页等筛选信息 | 376 | // 处理分页等筛选信息 |
377 | if (subResult[0].code === 200) { | 377 | if (subResult[0].code === 200) { |
378 | Object.assign(finalResult, { | 378 | Object.assign(finalResult, { |
379 | - leftContent: publicHandler.handleSaleSortData(subResult[0].data.filter.group_sort, params, 'discount'), | 379 | + leftContent: publicHandler.handleSaleSortData(subResult[0].data.filter.group_sort, |
380 | + params, 'discount'), | ||
380 | saleList: { | 381 | saleList: { |
381 | footPager: publicHandler.handlePagerData(subResult[0].data.total, params), | 382 | footPager: publicHandler.handlePagerData(subResult[0].data.total, params), |
382 | opts: publicHandler.handleSaleOptsData(params, subResult[0].data.total, 'default') | 383 | opts: publicHandler.handleSaleOptsData(params, subResult[0].data.total, 'default') |
@@ -577,7 +578,8 @@ exports.getSaleSpecialData = (id, params, channel) => { | @@ -577,7 +578,8 @@ exports.getSaleSpecialData = (id, params, channel) => { | ||
577 | Object.assign(resData, { | 578 | Object.assign(resData, { |
578 | filters: searchHandler.handleFilterDataAll(_.get(result[2], 'data', {}), params), | 579 | filters: searchHandler.handleFilterDataAll(_.get(result[2], 'data', {}), params), |
579 | opts: searchHandler.handleOptsData(params, tip.total), | 580 | opts: searchHandler.handleOptsData(params, tip.total), |
580 | - goods: productProcess.processProductList(_.get(result[2], 'data.product_list', [])), | 581 | + goods: productProcess.processProductList(_.get(result[2], 'data.product_list', []), |
582 | + {from: {type: 'saleSpecial', params: params}}), | ||
581 | footPager: {tip: tip} | 583 | footPager: {tip: tip} |
582 | }); | 584 | }); |
583 | 585 |
@@ -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] |
@@ -6,6 +6,15 @@ const camelCase = global.yoho.camelCase; | @@ -6,6 +6,15 @@ const camelCase = global.yoho.camelCase; | ||
6 | const helpers = global.yoho.helpers; | 6 | const helpers = global.yoho.helpers; |
7 | const images = require(`${global.utils}/images`); | 7 | const images = require(`${global.utils}/images`); |
8 | 8 | ||
9 | +const itemFromBase = { | ||
10 | + search: {domain: 'search', module: 's'}, // 搜索页search.yohobuy.com | ||
11 | + list: {domain: 'list', module: 'c'}, // list.yohobuy.com | ||
12 | + listSale: {domain: 'list', module: 's'}, // list.yohobuy.com/sale | ||
13 | + listNew: {domain: 'list', module: 'n'}, // list.yohobuy.com/new | ||
14 | + brand: {domain: 'brand', module: 'b'}, // xxx.yohobuy.com[品牌域名] | ||
15 | + saleSpecial: {domain: 'sale', module: 's'}// sale.yohobuy.com | ||
16 | +}; | ||
17 | + | ||
9 | // NOTE: 这里修改了图片质量的参数 | 18 | // NOTE: 这里修改了图片质量的参数 |
10 | helpers.image = _.flow(helpers.image, fp.replace(/\/quality\/\d*$/, '/quality/90')); | 19 | helpers.image = _.flow(helpers.image, fp.replace(/\/quality\/\d*$/, '/quality/90')); |
11 | 20 | ||
@@ -104,6 +113,8 @@ const procProductImgs = (item, gender) => { | @@ -104,6 +113,8 @@ const procProductImgs = (item, gender) => { | ||
104 | */ | 113 | */ |
105 | exports.processProductList = (list, options) => { | 114 | exports.processProductList = (list, options) => { |
106 | const pruductList = []; | 115 | const pruductList = []; |
116 | + let itemNum = 0, | ||
117 | + itemFrom; | ||
107 | 118 | ||
108 | options = Object.assign({ | 119 | options = Object.assign({ |
109 | showTags: true, | 120 | showTags: true, |
@@ -117,11 +128,30 @@ exports.processProductList = (list, options) => { | @@ -117,11 +128,30 @@ exports.processProductList = (list, options) => { | ||
117 | height: 388, | 128 | height: 388, |
118 | isApp: false, | 129 | isApp: false, |
119 | showPoint: true, | 130 | showPoint: true, |
120 | - gender: '2,3' | 131 | + gender: '2,3', |
132 | + from: {} // 来源 | ||
121 | }, options); | 133 | }, options); |
122 | 134 | ||
123 | - _.forEach(list, (product) => { | 135 | + // 处理item from |
136 | + if (!_.isEmpty(options.from) && itemFromBase[options.from.type]) { | ||
137 | + let f = {domain: '', module: '', key: ''}; | ||
138 | + let params = options.from.params || {}; | ||
139 | + | ||
140 | + f.page = params.page || 1; | ||
141 | + | ||
142 | + Object.assign(f, itemFromBase[options.from.type], { | ||
143 | + page: params.page || 1, | ||
144 | + key: params.misort || params.msort || '' | ||
145 | + }); | ||
124 | 146 | ||
147 | + if (options.from.type === 'search') { | ||
148 | + f.key = params.query || ''; | ||
149 | + } | ||
150 | + | ||
151 | + itemFrom = `from=${f.domain}-${f.module}-${f.key}_${f.page}_`; | ||
152 | + } | ||
153 | + | ||
154 | + _.forEach(list, (product) => { | ||
125 | 155 | ||
126 | // 商品信息有问题,则不显示 | 156 | // 商品信息有问题,则不显示 |
127 | if (!product || !product.product_skn || !product.goods_list.length) { | 157 | if (!product || !product.product_skn || !product.goods_list.length) { |
@@ -165,7 +195,7 @@ exports.processProductList = (list, options) => { | @@ -165,7 +195,7 @@ exports.processProductList = (list, options) => { | ||
165 | }); | 195 | }); |
166 | 196 | ||
167 | product.is_few = product.is_soon_sold_out === 'Y'; | 197 | product.is_few = product.is_soon_sold_out === 'Y'; |
168 | - product.url = helpers.urlFormat(`/product/pro_${product.product_id}_${product.goods_list[0].goods_id}/${product.cn_alphabet}.html`); // eslint-disable-line | 198 | + product.url = helpers.urlFormat(`/product/pro_${product.product_id}_${product.goods_list[0].goods_id}/${product.cn_alphabet}.html`, '', 'item'); // eslint-disable-line |
169 | 199 | ||
170 | // tar add 1606071146 品牌链接处理 | 200 | // tar add 1606071146 品牌链接处理 |
171 | product.brandUrl = helpers.urlFormat('', '', product.brand_domain); | 201 | product.brandUrl = helpers.urlFormat('', '', product.brand_domain); |
@@ -174,6 +204,10 @@ exports.processProductList = (list, options) => { | @@ -174,6 +204,10 @@ exports.processProductList = (list, options) => { | ||
174 | // 备注:如果以后APP的接口太多,可以把这边参数提取出来,变成一个公共的方法来生成,便于以后管理维护 | 204 | // 备注:如果以后APP的接口太多,可以把这边参数提取出来,变成一个公共的方法来生成,便于以后管理维护 |
175 | if (options.isApp) { | 205 | if (options.isApp) { |
176 | product.url += `?openby:yohobuy={"action":"go.productDetail","params":{"product_skn":'${product.product_id}'}}`; // eslint-disable-line | 206 | product.url += `?openby:yohobuy={"action":"go.productDetail","params":{"product_skn":'${product.product_id}'}}`; // eslint-disable-line |
207 | + } else if (itemFrom) { | ||
208 | + // 累加商品数量 | ||
209 | + itemNum++; | ||
210 | + product.url += `?${itemFrom}${itemNum}`; | ||
177 | } | 211 | } |
178 | 212 | ||
179 | if (options.showTags) { | 213 | if (options.showTags) { |
-
Please register or login to post a comment