|
|
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);
|
|
|
});
|
...
|
...
|
@@ -198,10 +198,10 @@ export function processArticleDetail(articleContent) { |
|
|
/**
|
|
|
* 商品搜索商品数据处理
|
|
|
*/
|
|
|
function processProductList(list) {
|
|
|
function processProductList(list, favsList) {
|
|
|
const pruductList = [];
|
|
|
|
|
|
foreach(list, (product) => {
|
|
|
forEach(list, (product) => {
|
|
|
if (!product) {
|
|
|
return;
|
|
|
}
|
...
|
...
|
@@ -243,12 +243,24 @@ function processProductList(list) { |
|
|
|
|
|
product.default_images = getSourceUrl(product.default_images, 'goodsimg');
|
|
|
|
|
|
product.productImage = product.default_images;
|
|
|
product.salesPrice = product.sales_price;
|
|
|
product.productName = product.product_name;
|
|
|
|
|
|
product.is_soon_sold_out = product.is_soon_sold_out === 'Y';
|
|
|
|
|
|
if (product.cn_alphabet) {
|
|
|
product.cn_alphabet = productNameProcess(product.cn_alphabet);
|
|
|
}
|
|
|
|
|
|
// fav
|
|
|
const fav = favsList.find(i => i.id === product.product_id);
|
|
|
|
|
|
product.productId = product.product_id;
|
|
|
product.productType = 1;
|
|
|
|
|
|
product.favorite = fav || false;
|
|
|
|
|
|
product.url = product.is_global === 'Y' ? `/product/global/${product.product_skn}.html` :
|
|
|
`/product/${product.product_skn}.html`; // 商品url改版 // eslint-disable-line
|
|
|
|
...
|
...
|
@@ -281,7 +293,7 @@ function processProductList(list) { |
|
|
}
|
|
|
|
|
|
const _goodsArrayToObj = (goodsArray) => {
|
|
|
return keyby(goodsArray, value => {
|
|
|
return keyBy(goodsArray, value => {
|
|
|
return value.product_skn;
|
|
|
});
|
|
|
};
|
...
|
...
|
@@ -289,21 +301,21 @@ const _goodsArrayToObj = (goodsArray) => { |
|
|
/**
|
|
|
* 重新获取商品数据
|
|
|
*/
|
|
|
export function pushGoodsInfo(finalDetail, goodsList) {
|
|
|
let goodsObj = _goodsArrayToObj(processProductList(goodsList));
|
|
|
export function pushGoodsInfo(finalDetail, goodsList, favsList) {
|
|
|
let goodsObj = _goodsArrayToObj(processProductList(goodsList, favsList));
|
|
|
|
|
|
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 +333,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;
|
...
|
...
|
|