...
|
...
|
@@ -4,16 +4,15 @@ const _ = require('lodash'); |
|
|
const camelCase = global.yoho.camelCase;
|
|
|
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
|
|
|
};
|
|
|
// TODO 删除from参数,暂时保留注释
|
|
|
// 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
|
|
|
// };
|
|
|
|
|
|
/**
|
|
|
* 根据性别来决定 默认图片获取字段 如果是 2、3
|
...
|
...
|
@@ -112,8 +111,10 @@ const procCnAlphabetName = (nameStr) => { |
|
|
*/
|
|
|
exports.processProductList = (list, options) => {
|
|
|
const pruductList = [];
|
|
|
let itemNum = 0,
|
|
|
itemFrom;
|
|
|
|
|
|
// TODO 删除from参数,暂时保留注释
|
|
|
// let itemNum = 0,
|
|
|
// itemFrom;
|
|
|
|
|
|
options = Object.assign({
|
|
|
showTags: true,
|
...
|
...
|
@@ -131,24 +132,25 @@ exports.processProductList = (list, options) => { |
|
|
from: {} // 来源
|
|
|
}, options);
|
|
|
|
|
|
// TODO 删除from参数,暂时保留注释
|
|
|
// 处理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}_`;
|
|
|
}
|
|
|
// 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) => {
|
|
|
|
...
|
...
|
@@ -204,15 +206,13 @@ exports.processProductList = (list, options) => { |
|
|
// tar add 1606071146 品牌链接处理
|
|
|
product.brandUrl = helpers.urlFormat('', '', product.brand_domain);
|
|
|
|
|
|
// APP访问需要加附加的参数
|
|
|
// 备注:如果以后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}`;
|
|
|
}
|
|
|
// TODO 删除from参数,暂时保留注释
|
|
|
// if (itemFrom) {
|
|
|
// // 累加商品数量
|
|
|
// itemNum++;
|
|
|
// product.url += `?${itemFrom}${itemNum}`;
|
|
|
// }
|
|
|
|
|
|
if (options.showTags) {
|
|
|
let tags = [],
|
|
|
isfew = false;
|
...
|
...
|
|