...
|
...
|
@@ -6,6 +6,17 @@ |
|
|
const _ = require('lodash');
|
|
|
const helpers = global.yoho.helpers;
|
|
|
const productNameProcess = require('./product-name-process');
|
|
|
const productPrcs = require('./product-process');
|
|
|
|
|
|
/**
|
|
|
* 将商品转化成以 product_skn 为键名的对象
|
|
|
* @param {*} goodsArray
|
|
|
*/
|
|
|
const _goodsArrayToObj = (goodsArray) => {
|
|
|
return _.keyBy(goodsArray, value => {
|
|
|
return value.product_skn;
|
|
|
});
|
|
|
};
|
|
|
|
|
|
/**
|
|
|
* [将首字符为//的url转换为http://]
|
...
|
...
|
@@ -344,6 +355,7 @@ const formatProduct = (productData, showTags, showNew, showSale, width, height, |
|
|
|
|
|
const processArticleDetail = (articleContent, isApp, gender, isWeixin, isqq, isWeibo) => {
|
|
|
let finalDetail = [];
|
|
|
let allgoods = '';
|
|
|
|
|
|
_.forEach(articleContent, (value, index) => {
|
|
|
|
...
|
...
|
@@ -413,6 +425,10 @@ const processArticleDetail = (articleContent, isApp, gender, isWeixin, isqq, isW |
|
|
let relatedReco = [];
|
|
|
let moreThanOne = _.get(value, 'goods.data', []).length > 1;
|
|
|
|
|
|
_.forEach(_.get(value, 'goods.data', []), item => {
|
|
|
allgoods += item.id + ',';
|
|
|
});
|
|
|
|
|
|
if (moreThanOne) {
|
|
|
relatedReco = _.get(value, 'goods.data', []);
|
|
|
} else {
|
...
|
...
|
@@ -431,6 +447,10 @@ const processArticleDetail = (articleContent, isApp, gender, isWeixin, isqq, isW |
|
|
_.forEach(_.get(value, 'goodsGroup.data', []), item => {
|
|
|
let cover = _.get(item, 'cover', '');
|
|
|
|
|
|
_.forEach(_.get(item, 'list', []), item2 => {
|
|
|
allgoods += item2.id + ',';
|
|
|
});
|
|
|
|
|
|
collocation.push({
|
|
|
thumb: cover ?
|
|
|
helpers.image(cover.cover, 235, 314) : '',
|
...
|
...
|
@@ -453,8 +473,31 @@ const processArticleDetail = (articleContent, isApp, gender, isWeixin, isqq, isW |
|
|
|
|
|
});
|
|
|
|
|
|
console.log(JSON.stringify(finalDetail, 2, 2));
|
|
|
console.log('-------------------------------------------------------------------------');
|
|
|
return {
|
|
|
finalDetail: finalDetail,
|
|
|
allgoods: allgoods
|
|
|
};
|
|
|
};
|
|
|
|
|
|
const pushGoodsInfo = (finalDetail, goodsList) => {
|
|
|
let goodsObj = _goodsArrayToObj(productPrcs.processProductList(goodsList));
|
|
|
|
|
|
// console.log(goodsList);
|
|
|
_.forEach(finalDetail, (value, key) => {
|
|
|
// if (value.relatedReco) {
|
|
|
// console.log(value.relatedReco);
|
|
|
// }
|
|
|
|
|
|
if (value.collocation) {
|
|
|
_.forEach(value.collocation, (item, subKey) => {
|
|
|
_.forEach(item.goods, (thItem, thKey) => {
|
|
|
finalDetail[key].collocation[subKey].goods[thKey] = goodsObj[thItem.id];
|
|
|
});
|
|
|
});
|
|
|
}
|
|
|
});
|
|
|
|
|
|
// console.log(JSON.stringify(finalDetail, 2, 2));
|
|
|
return finalDetail;
|
|
|
};
|
|
|
|
...
|
...
|
@@ -464,5 +507,6 @@ module.exports = { |
|
|
getFilterUrl,
|
|
|
formatProduct,
|
|
|
getProductIcon,
|
|
|
processArticleDetail
|
|
|
processArticleDetail,
|
|
|
pushGoodsInfo
|
|
|
}; |
...
|
...
|
|