1
|
-import { get, foreach, keyby, uniq, remove, clonedeep } from 'lodash';
|
1
|
+import { get, forEach, keyBy, uniq, remove, cloneDeep } from 'lodash';
|
2
|
|
2
|
|
3
|
let domainList = {
|
3
|
let domainList = {
|
4
|
'01': [
|
4
|
'01': [
|
|
@@ -89,14 +89,14 @@ export function processArticleDetail(articleContent) { |
|
@@ -89,14 +89,14 @@ export function processArticleDetail(articleContent) { |
89
|
|
89
|
|
90
|
// 普通商品
|
90
|
// 普通商品
|
91
|
if (tagList.length > 0) {
|
91
|
if (tagList.length > 0) {
|
92
|
- foreach(tagList, (tag, tagIndex) => {
|
92
|
+ forEach(tagList, (tag, tagIndex) => {
|
93
|
tagList[tagIndex].href = '//m.yohobuy.com/product/' + tag.product_skn + '.html';
|
93
|
tagList[tagIndex].href = '//m.yohobuy.com/product/' + tag.product_skn + '.html';
|
94
|
});
|
94
|
});
|
95
|
}
|
95
|
}
|
96
|
|
96
|
|
97
|
// 全球购商品
|
97
|
// 全球购商品
|
98
|
if (tagListGlobal.length > 0) {
|
98
|
if (tagListGlobal.length > 0) {
|
99
|
- foreach(tagListGlobal, tagGlobal => {
|
99
|
+ forEach(tagListGlobal, tagGlobal => {
|
100
|
tagList.push(Object.assign(tagGlobal, {
|
100
|
tagList.push(Object.assign(tagGlobal, {
|
101
|
href: '//m.yohobuy.com/product/global/' + tagGlobal.product_skn + '.html',
|
101
|
href: '//m.yohobuy.com/product/global/' + tagGlobal.product_skn + '.html',
|
102
|
noCart: true
|
102
|
noCart: true
|
|
@@ -106,7 +106,7 @@ export function processArticleDetail(articleContent) { |
|
@@ -106,7 +106,7 @@ export function processArticleDetail(articleContent) { |
106
|
|
106
|
|
107
|
// 限定商品
|
107
|
// 限定商品
|
108
|
if (tagListLimit.length > 0) {
|
108
|
if (tagListLimit.length > 0) {
|
109
|
- foreach(tagListLimit, tagLimit => {
|
109
|
+ forEach(tagListLimit, tagLimit => {
|
110
|
tagList.push(Object.assign(tagLimit, {
|
110
|
tagList.push(Object.assign(tagLimit, {
|
111
|
href: '//m.yohobuy.com/product/' + tagLimit.product_skn + '.html',
|
111
|
href: '//m.yohobuy.com/product/' + tagLimit.product_skn + '.html',
|
112
|
noCart: true
|
112
|
noCart: true
|
|
@@ -148,18 +148,18 @@ export function processArticleDetail(articleContent) { |
|
@@ -148,18 +148,18 @@ export function processArticleDetail(articleContent) { |
148
|
let goodsDataLimit = get(value, 'goods.dataLimit', []);
|
148
|
let goodsDataLimit = get(value, 'goods.dataLimit', []);
|
149
|
|
149
|
|
150
|
// 普通商品
|
150
|
// 普通商品
|
151
|
- foreach(goodsData, (item) => {
|
151
|
+ forEach(goodsData, (item) => {
|
152
|
allgoods.push(item.id);
|
152
|
allgoods.push(item.id);
|
153
|
});
|
153
|
});
|
154
|
|
154
|
|
155
|
// 全球购商品
|
155
|
// 全球购商品
|
156
|
- foreach(goodsDataGlobal, (item) => {
|
156
|
+ forEach(goodsDataGlobal, (item) => {
|
157
|
allgoods.push(item.id);
|
157
|
allgoods.push(item.id);
|
158
|
goodsData.push(item);
|
158
|
goodsData.push(item);
|
159
|
});
|
159
|
});
|
160
|
|
160
|
|
161
|
// 限定商品
|
161
|
// 限定商品
|
162
|
- foreach(goodsDataLimit, (item) => {
|
162
|
+ forEach(goodsDataLimit, (item) => {
|
163
|
allgoods.push(item.id);
|
163
|
allgoods.push(item.id);
|
164
|
goodsData.push(item);
|
164
|
goodsData.push(item);
|
165
|
});
|
165
|
});
|
|
@@ -201,7 +201,7 @@ export function processArticleDetail(articleContent) { |
|
@@ -201,7 +201,7 @@ export function processArticleDetail(articleContent) { |
201
|
function processProductList(list) {
|
201
|
function processProductList(list) {
|
202
|
const pruductList = [];
|
202
|
const pruductList = [];
|
203
|
|
203
|
|
204
|
- foreach(list, (product) => {
|
204
|
+ forEach(list, (product) => {
|
205
|
if (!product) {
|
205
|
if (!product) {
|
206
|
return;
|
206
|
return;
|
207
|
}
|
207
|
}
|
|
@@ -281,7 +281,7 @@ function processProductList(list) { |
|
@@ -281,7 +281,7 @@ function processProductList(list) { |
281
|
}
|
281
|
}
|
282
|
|
282
|
|
283
|
const _goodsArrayToObj = (goodsArray) => {
|
283
|
const _goodsArrayToObj = (goodsArray) => {
|
284
|
- return keyby(goodsArray, value => {
|
284
|
+ return keyBy(goodsArray, value => {
|
285
|
return value.product_skn;
|
285
|
return value.product_skn;
|
286
|
});
|
286
|
});
|
287
|
};
|
287
|
};
|
|
@@ -292,18 +292,18 @@ const _goodsArrayToObj = (goodsArray) => { |
|
@@ -292,18 +292,18 @@ const _goodsArrayToObj = (goodsArray) => { |
292
|
export function pushGoodsInfo(finalDetail, goodsList) {
|
292
|
export function pushGoodsInfo(finalDetail, goodsList) {
|
293
|
let goodsObj = _goodsArrayToObj(processProductList(goodsList));
|
293
|
let goodsObj = _goodsArrayToObj(processProductList(goodsList));
|
294
|
|
294
|
|
295
|
- foreach(finalDetail, (value, key) => {
|
295
|
+ forEach(finalDetail, (value, key) => {
|
296
|
if (value.relatedReco) {
|
296
|
if (value.relatedReco) {
|
297
|
let goodsIds = [];
|
297
|
let goodsIds = [];
|
298
|
|
298
|
|
299
|
- foreach(value.relatedReco.goods, relatedGoods => {
|
299
|
+ forEach(value.relatedReco.goods, relatedGoods => {
|
300
|
goodsIds.push(relatedGoods.id);
|
300
|
goodsIds.push(relatedGoods.id);
|
301
|
});
|
301
|
});
|
302
|
|
302
|
|
303
|
goodsIds = uniq(goodsIds);
|
303
|
goodsIds = uniq(goodsIds);
|
304
|
finalDetail[key].relatedReco.goods = [];
|
304
|
finalDetail[key].relatedReco.goods = [];
|
305
|
|
305
|
|
306
|
- foreach(goodsIds, (item, subKey) => {
|
306
|
+ forEach(goodsIds, (item, subKey) => {
|
307
|
if (goodsObj[item]) {
|
307
|
if (goodsObj[item]) {
|
308
|
finalDetail[key].relatedReco.goods[subKey] = goodsObj[item];
|
308
|
finalDetail[key].relatedReco.goods[subKey] = goodsObj[item];
|
309
|
} else {
|
309
|
} else {
|
|
@@ -321,13 +321,13 @@ export function pushGoodsInfo(finalDetail, goodsList) { |
|
@@ -321,13 +321,13 @@ export function pushGoodsInfo(finalDetail, goodsList) { |
321
|
}
|
321
|
}
|
322
|
|
322
|
|
323
|
if (value.collocation) {
|
323
|
if (value.collocation) {
|
324
|
- foreach(value.collocation, (item, subKey) => {
|
|
|
325
|
- foreach(item.goods, (thItem, thKey) => {
|
324
|
+ forEach(value.collocation, (item, subKey) => {
|
|
|
325
|
+ forEach(item.goods, (thItem, thKey) => {
|
326
|
if (thItem) {
|
326
|
if (thItem) {
|
327
|
finalDetail[key].collocation[subKey].goods[thKey] = goodsObj[thItem.id];
|
327
|
finalDetail[key].collocation[subKey].goods[thKey] = goodsObj[thItem.id];
|
328
|
|
328
|
|
329
|
if (goodsObj[thItem.id]) {
|
329
|
if (goodsObj[thItem.id]) {
|
330
|
- let newGoods = clonedeep(goodsObj[thItem.id]);
|
330
|
+ let newGoods = cloneDeep(goodsObj[thItem.id]);
|
331
|
|
331
|
|
332
|
newGoods.default_images = thItem.src;
|
332
|
newGoods.default_images = thItem.src;
|
333
|
finalDetail[key].collocation[subKey].goods[thKey] = newGoods;
|
333
|
finalDetail[key].collocation[subKey].goods[thKey] = newGoods;
|