...
|
...
|
@@ -7,6 +7,15 @@ const helpers = global.yoho.helpers; |
|
|
|
|
|
// const images = require(`${global.utils}/images`);
|
|
|
|
|
|
const itemFromBase = {
|
|
|
search: {domain: 'search', module: 's'}, // 搜索页search.yohobuy.com
|
|
|
list: {domain: 'list', module: 'c'}, // list.yohobuy.com
|
|
|
listSale: {domain: 'list', module: 's'}, // list.yohobuy.com/sale
|
|
|
listNew: {domain: 'list', module: 'n'}, // list.yohobuy.com/new
|
|
|
brand: {domain: 'brand', module: 'b'}, // xxx.yohobuy.com[品牌域名]
|
|
|
saleSpecial: {domain: 'sale', module: 's'}// sale.yohobuy.com
|
|
|
};
|
|
|
|
|
|
// NOTE: 这里修改了图片质量的参数
|
|
|
helpers.image = _.flow(helpers.image, fp.replace(/\/quality\/\d*$/, '/quality/90'));
|
|
|
|
...
|
...
|
@@ -105,6 +114,8 @@ const procProductImgs = (item, gender) => { |
|
|
*/
|
|
|
exports.processProductList = (list, options) => {
|
|
|
const pruductList = [];
|
|
|
let itemNum = 0,
|
|
|
itemFrom;
|
|
|
|
|
|
options = Object.assign({
|
|
|
showTags: true,
|
...
|
...
|
@@ -118,11 +129,30 @@ exports.processProductList = (list, options) => { |
|
|
height: 388,
|
|
|
isApp: false,
|
|
|
showPoint: true,
|
|
|
gender: '2,3'
|
|
|
gender: '2,3',
|
|
|
from: {} // 来源
|
|
|
}, options);
|
|
|
|
|
|
_.forEach(list, (product) => {
|
|
|
// 处理item from
|
|
|
if (!_.isEmpty(options.from) && itemFromBase[options.from.type]) {
|
|
|
let f = {domain: '', module: '', key: ''};
|
|
|
let params = options.from.params || {};
|
|
|
|
|
|
f.page = params.page || 1;
|
|
|
|
|
|
Object.assign(f, itemFromBase[options.from.type], {
|
|
|
page: params.page || 1,
|
|
|
key: params.misort || params.msort || ''
|
|
|
});
|
|
|
|
|
|
if (options.from.type === 'search') {
|
|
|
f.key = params.query || '';
|
|
|
}
|
|
|
|
|
|
itemFrom = `from=${f.domain}-${f.module}-${f.key}_${f.page}_`;
|
|
|
}
|
|
|
|
|
|
_.forEach(list, (product) => {
|
|
|
|
|
|
// 商品信息有问题,则不显示
|
|
|
if (!product || !product.product_skn || !product.goods_list.length) {
|
...
|
...
|
@@ -166,7 +196,7 @@ exports.processProductList = (list, options) => { |
|
|
});
|
|
|
|
|
|
product.is_few = product.is_soon_sold_out === 'Y';
|
|
|
product.url = helpers.urlFormat(`/product/pro_${product.product_id}_${product.goods_list[0].goods_id}/${product.cn_alphabet}.html`); // eslint-disable-line
|
|
|
product.url = helpers.urlFormat(`/product/pro_${product.product_id}_${product.goods_list[0].goods_id}/${product.cn_alphabet}.html`, '', 'item'); // eslint-disable-line
|
|
|
|
|
|
// tar add 1606071146 品牌链接处理
|
|
|
product.brandUrl = helpers.urlFormat('', '', product.brand_domain);
|
...
|
...
|
@@ -175,6 +205,10 @@ exports.processProductList = (list, options) => { |
|
|
// 备注:如果以后APP的接口太多,可以把这边参数提取出来,变成一个公共的方法来生成,便于以后管理维护
|
|
|
if (options.isApp) {
|
|
|
product.url += `?openby:yohobuy={"action":"go.productDetail","params":{"product_skn":'${product.product_id}'}}`; // eslint-disable-line
|
|
|
} else if (itemFrom) {
|
|
|
// 累加商品数量
|
|
|
itemNum++;
|
|
|
product.url += `?${itemFrom}${itemNum}`;
|
|
|
}
|
|
|
|
|
|
if (options.showTags) {
|
...
|
...
|
|