...
|
...
|
@@ -12,11 +12,15 @@ const images = require(`${global.utils}/images`); |
|
|
* 否则优先从cover1 --》 cover2 -- 》 images_url
|
|
|
*
|
|
|
*/
|
|
|
const procProductImg = (product, gender) => {
|
|
|
const procProductImg = (product, gender, newSort) => {
|
|
|
if (gender === '2,3') {
|
|
|
return product.cover2 || product.cover1 || product.imagesUrl || '';
|
|
|
}
|
|
|
|
|
|
if (newSort && gender === '1,2,3') {
|
|
|
return product.imagesUrl || '';
|
|
|
}
|
|
|
|
|
|
return product.cover1 || product.cover2 || product.imagesUrl || '';
|
|
|
};
|
|
|
|
...
|
...
|
@@ -39,7 +43,35 @@ const handleGoodsListData = (origin) => { |
|
|
};
|
|
|
|
|
|
/**
|
|
|
* 根据性别来决定 默认图片获取字段 如果是 2、3
|
|
|
* 处理搜索返回同一skc分男女封分别返回问题
|
|
|
* @param array $images
|
|
|
* @return string 商品图片
|
|
|
*/
|
|
|
const procGoodsList = (goodsList) => {
|
|
|
let list = {};
|
|
|
|
|
|
if (!_.isEmpty(goodsList)) {
|
|
|
let goods = _.cloneDeep(goodsList);
|
|
|
|
|
|
_.forEach(goods, value => {
|
|
|
if (!list[value.productSkc]) {
|
|
|
list[value.productSkc] = value;
|
|
|
} else {
|
|
|
if (value.cover1) {
|
|
|
list[value.productSkc].cover1 = value.cover1;
|
|
|
}
|
|
|
if (value.cover2) {
|
|
|
list[value.productSkc].cover2 = value.cover2;
|
|
|
}
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
|
|
|
return _.toArray(list);
|
|
|
};
|
|
|
|
|
|
/**
|
|
|
* 处理
|
|
|
*
|
|
|
* 2、3: cover2 --> images_url -> cover1
|
|
|
* 1,3 :cover1 --> images_url -> cover2
|
...
|
...
|
@@ -72,9 +104,8 @@ exports.processProductList = (list, options) => { |
|
|
showTags: true,
|
|
|
showNew: true,
|
|
|
showSale: true,
|
|
|
|
|
|
// 显示折扣
|
|
|
showDiscount: true,
|
|
|
showDiscount: true, // 显示折扣
|
|
|
newCoverSort: false, // 新封面排序
|
|
|
width: 290,
|
|
|
height: 388,
|
|
|
isApp: false,
|
...
|
...
|
@@ -105,17 +136,17 @@ exports.processProductList = (list, options) => { |
|
|
}
|
|
|
|
|
|
// 如果设置了默认图片,就取默认的图片
|
|
|
_.forEach(product.goodsList, (goods) => {
|
|
|
_.forEach(procGoodsList(product.goodsList), (goods) => {
|
|
|
|
|
|
// (颜色优先)
|
|
|
if (options.color) {
|
|
|
if (goods.colorId === options.color) {
|
|
|
product.defaultImages = procProductImg(goods, options.gender);
|
|
|
product.defaultImages = procProductImg(goods, options.gender, options.newCoverSort);
|
|
|
return;
|
|
|
}
|
|
|
} else {
|
|
|
if (goods.isDefault === 'Y') {
|
|
|
product.defaultImages = procProductImg(goods, options.gender);
|
|
|
product.defaultImages = procProductImg(goods, options.gender, options.newCoverSort);
|
|
|
return;
|
|
|
}
|
|
|
}
|
...
|
...
|
@@ -123,7 +154,7 @@ exports.processProductList = (list, options) => { |
|
|
|
|
|
// 如果还未赋值,则取第一个skc产品的默认图片
|
|
|
if (!product.defaultImages) {
|
|
|
product.defaultImages = procProductImg(product.goodsList[0]);
|
|
|
product.defaultImages = procProductImg(product.goodsList[0], options.gender, options.newCoverSort);
|
|
|
}
|
|
|
|
|
|
product = Object.assign(product, {
|
...
|
...
|
|