...
|
...
|
@@ -39,6 +39,31 @@ const handleGoodsListData = (origin) => { |
|
|
};
|
|
|
|
|
|
/**
|
|
|
* 根据性别来决定 默认图片获取字段 如果是 2、3
|
|
|
*
|
|
|
* 2、3: cover2 --> images_url -> cover1
|
|
|
* 1,3 :cover1 --> images_url -> cover2
|
|
|
* 其他: cover1 --> cover2 --> images_url
|
|
|
*
|
|
|
* @param array $images
|
|
|
* @return string 商品图片
|
|
|
*/
|
|
|
const procProductImgs = (images, gender) => {
|
|
|
let imgUrl = images['images_url'] ? images['images_url'] : '',
|
|
|
cover1 = images['cover_1'] ? images['cover_1'] : '',
|
|
|
cover2 = images['cover_2'] ? images['cover_2'] : '';
|
|
|
if (gender === '2,3') {
|
|
|
return cover2 ? cover2 : (imgUrl ? imgUrl : cover1);
|
|
|
}
|
|
|
else if (gender == '1,3') {
|
|
|
return cover1 ? cover1 : (imgUrl ? imgUrl : cover2);
|
|
|
}
|
|
|
else {
|
|
|
return cover1 ? cover1 : (cover2 ? cover2 : imgUrl);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 商品搜索商品数据处理
|
|
|
*/
|
|
|
exports.processProductList = (list, options) => {
|
...
|
...
|
@@ -297,12 +322,12 @@ exports.processProduct = (productData, options) => { |
|
|
// 设置默认图片
|
|
|
_.forEach(productData.goods_list, item => {
|
|
|
if (item.is_default === 'Y') {
|
|
|
productData.default_images = item.images_url;
|
|
|
productData.default_images = procProductImgs(item, options.gender);
|
|
|
}
|
|
|
});
|
|
|
|
|
|
if (!productData.default_images) {
|
|
|
productData.default_images = productData.goods_list[0].images_url;
|
|
|
productData.default_images = procProductImgs(productData.goods_list[0], options.gender);
|
|
|
}
|
|
|
|
|
|
result.id = productData.product_skn;
|
...
|
...
|
|