|
|
import { get, foreach, keyby, uniq, remove, clonedeep } from 'lodash';
|
|
|
import { get, forEach, keyBy, uniq, remove, cloneDeep } from 'lodash';
|
|
|
|
|
|
let domainList = {
|
|
|
'01': [
|
...
|
...
|
@@ -89,14 +89,14 @@ export function processArticleDetail(articleContent) { |
|
|
|
|
|
// 普通商品
|
|
|
if (tagList.length > 0) {
|
|
|
foreach(tagList, (tag, tagIndex) => {
|
|
|
forEach(tagList, (tag, tagIndex) => {
|
|
|
tagList[tagIndex].href = '//m.yohobuy.com/product/' + tag.product_skn + '.html';
|
|
|
});
|
|
|
}
|
|
|
|
|
|
// 全球购商品
|
|
|
if (tagListGlobal.length > 0) {
|
|
|
foreach(tagListGlobal, tagGlobal => {
|
|
|
forEach(tagListGlobal, tagGlobal => {
|
|
|
tagList.push(Object.assign(tagGlobal, {
|
|
|
href: '//m.yohobuy.com/product/global/' + tagGlobal.product_skn + '.html',
|
|
|
noCart: true
|
...
|
...
|
@@ -106,7 +106,7 @@ export function processArticleDetail(articleContent) { |
|
|
|
|
|
// 限定商品
|
|
|
if (tagListLimit.length > 0) {
|
|
|
foreach(tagListLimit, tagLimit => {
|
|
|
forEach(tagListLimit, tagLimit => {
|
|
|
tagList.push(Object.assign(tagLimit, {
|
|
|
href: '//m.yohobuy.com/product/' + tagLimit.product_skn + '.html',
|
|
|
noCart: true
|
...
|
...
|
@@ -148,18 +148,18 @@ export function processArticleDetail(articleContent) { |
|
|
let goodsDataLimit = get(value, 'goods.dataLimit', []);
|
|
|
|
|
|
// 普通商品
|
|
|
foreach(goodsData, (item) => {
|
|
|
forEach(goodsData, (item) => {
|
|
|
allgoods.push(item.id);
|
|
|
});
|
|
|
|
|
|
// 全球购商品
|
|
|
foreach(goodsDataGlobal, (item) => {
|
|
|
forEach(goodsDataGlobal, (item) => {
|
|
|
allgoods.push(item.id);
|
|
|
goodsData.push(item);
|
|
|
});
|
|
|
|
|
|
// 限定商品
|
|
|
foreach(goodsDataLimit, (item) => {
|
|
|
forEach(goodsDataLimit, (item) => {
|
|
|
allgoods.push(item.id);
|
|
|
goodsData.push(item);
|
|
|
});
|
...
|
...
|
@@ -201,7 +201,7 @@ export function processArticleDetail(articleContent) { |
|
|
function processProductList(list) {
|
|
|
const pruductList = [];
|
|
|
|
|
|
foreach(list, (product) => {
|
|
|
forEach(list, (product) => {
|
|
|
if (!product) {
|
|
|
return;
|
|
|
}
|
...
|
...
|
@@ -281,7 +281,7 @@ function processProductList(list) { |
|
|
}
|
|
|
|
|
|
const _goodsArrayToObj = (goodsArray) => {
|
|
|
return keyby(goodsArray, value => {
|
|
|
return keyBy(goodsArray, value => {
|
|
|
return value.product_skn;
|
|
|
});
|
|
|
};
|
...
|
...
|
@@ -292,18 +292,18 @@ const _goodsArrayToObj = (goodsArray) => { |
|
|
export function pushGoodsInfo(finalDetail, goodsList) {
|
|
|
let goodsObj = _goodsArrayToObj(processProductList(goodsList));
|
|
|
|
|
|
foreach(finalDetail, (value, key) => {
|
|
|
forEach(finalDetail, (value, key) => {
|
|
|
if (value.relatedReco) {
|
|
|
let goodsIds = [];
|
|
|
|
|
|
foreach(value.relatedReco.goods, relatedGoods => {
|
|
|
forEach(value.relatedReco.goods, relatedGoods => {
|
|
|
goodsIds.push(relatedGoods.id);
|
|
|
});
|
|
|
|
|
|
goodsIds = uniq(goodsIds);
|
|
|
finalDetail[key].relatedReco.goods = [];
|
|
|
|
|
|
foreach(goodsIds, (item, subKey) => {
|
|
|
forEach(goodsIds, (item, subKey) => {
|
|
|
if (goodsObj[item]) {
|
|
|
finalDetail[key].relatedReco.goods[subKey] = goodsObj[item];
|
|
|
} else {
|
...
|
...
|
@@ -321,13 +321,13 @@ export function pushGoodsInfo(finalDetail, goodsList) { |
|
|
}
|
|
|
|
|
|
if (value.collocation) {
|
|
|
foreach(value.collocation, (item, subKey) => {
|
|
|
foreach(item.goods, (thItem, thKey) => {
|
|
|
forEach(value.collocation, (item, subKey) => {
|
|
|
forEach(item.goods, (thItem, thKey) => {
|
|
|
if (thItem) {
|
|
|
finalDetail[key].collocation[subKey].goods[thKey] = goodsObj[thItem.id];
|
|
|
|
|
|
if (goodsObj[thItem.id]) {
|
|
|
let newGoods = clonedeep(goodsObj[thItem.id]);
|
|
|
let newGoods = cloneDeep(goodsObj[thItem.id]);
|
|
|
|
|
|
newGoods.default_images = thItem.src;
|
|
|
finalDetail[key].collocation[subKey].goods[thKey] = newGoods;
|
...
|
...
|
|