...
|
...
|
@@ -14,6 +14,34 @@ const logger = global.yoho.logger; |
|
|
// brand: {domain: 'brand', module: 'b'}, // xxx.yohobuy.com[品牌域名]
|
|
|
// saleSpecial: {domain: 'sale', module: 's'}// sale.yohobuy.com
|
|
|
// };
|
|
|
//
|
|
|
//
|
|
|
|
|
|
/**
|
|
|
* 处理接口返回图片链接,兼容非正常链接(如:/2015/10/22/08/023a5aa1cbdac7bdcd1685bfdab118b0c5.jpg)
|
|
|
*
|
|
|
*/
|
|
|
const handleGoodsThumb = (url, bucket) => {
|
|
|
url = url || '';
|
|
|
|
|
|
if (!url || url.indexOf('http') >= 0) {
|
|
|
return url;
|
|
|
}
|
|
|
|
|
|
let urlArr = url.split('/'),
|
|
|
stag = urlArr[urlArr.length - 1].substr(0, 2),
|
|
|
domain = `static.yhbimg.com/${bucket}`;
|
|
|
|
|
|
url = domain + url.split('?')[0] + '?imageMogr2/thumbnail/{width}x{height}/background/d2hpdGU=/position/center/quality/80'; // eslint-disable-line
|
|
|
|
|
|
if (stag === '01') {
|
|
|
return `//img11.${url}`;
|
|
|
} else if (stag === '03') {
|
|
|
return `//flv01.${url}`;
|
|
|
} else {
|
|
|
return `//img12.${url}`;
|
|
|
}
|
|
|
};
|
|
|
|
|
|
/**
|
|
|
* 根据性别来决定 默认图片获取字段 如果是 2、3
|
...
|
...
|
@@ -172,7 +200,7 @@ exports.processProductList = (list, options) => { |
|
|
}
|
|
|
|
|
|
// 商品信息有问题,则不显示
|
|
|
if (!product || !product.product_skn || !_.get(product, 'goods_list.length', 0)) {
|
|
|
if (!product || !product.product_skn) {
|
|
|
return;
|
|
|
}
|
|
|
|
...
|
...
|
@@ -186,6 +214,13 @@ exports.processProductList = (list, options) => { |
|
|
// 判别默认的商品是否将默认的图片URL赋值到skn
|
|
|
let flag = false;
|
|
|
|
|
|
// 6.7 搜索去掉goods_list, 兼容处理
|
|
|
if (_.isEmpty(product.goods_list)) {
|
|
|
product.goods_list = [{
|
|
|
images_url: product.default_images
|
|
|
}];
|
|
|
}
|
|
|
|
|
|
_.remove(product.goods_list, function(n) {
|
|
|
return !+n.status;
|
|
|
});
|
...
|
...
|
@@ -210,6 +245,9 @@ exports.processProductList = (list, options) => { |
|
|
product.default_images = procProductImg(product.goods_list[0]);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
product.default_images = handleGoodsThumb(product.default_images, 'goodsimg');
|
|
|
|
|
|
product = Object.assign(product, {
|
|
|
id: product.product_skn,
|
|
|
thumb: product.default_images
|
...
|
...
|
|