...
|
...
|
@@ -6,7 +6,7 @@ |
|
|
'use strict';
|
|
|
const serviceAPI = global.yoho.ServiceAPI;
|
|
|
|
|
|
// const api = global.yoho.API;
|
|
|
const api = global.yoho.API;
|
|
|
const camelCase = global.yoho.camelCase;
|
|
|
const _ = require('lodash');
|
|
|
const Promise = require('bluebird');
|
...
|
...
|
@@ -258,31 +258,33 @@ const _processHeadData = (list) => { |
|
|
|
|
|
|
|
|
// 推荐商品
|
|
|
// const _getRelatedData = (id) => {
|
|
|
// return api.get('', {
|
|
|
// query: id,
|
|
|
// method: 'app.search.li'
|
|
|
// }).then((result) => {
|
|
|
// let productList = {};
|
|
|
|
|
|
// if (result && result.code === 200) {
|
|
|
// // console.log(result);
|
|
|
// _.forEach(result.data. product_list, function(data) {
|
|
|
// // console.log(data)
|
|
|
// productList.name = data.product_name;
|
|
|
// productList.price = data.sales_price;
|
|
|
// productList.id = data.product_id;
|
|
|
// productList.cnAlphabet = data.cn_alphabet;
|
|
|
// });
|
|
|
const _getRelatedData = () => {
|
|
|
// console.log(id);
|
|
|
return api.get('', {
|
|
|
query: '51152761,51178582,51146105,51149561,51149414,51082157,51079256',
|
|
|
method: 'app.search.li'
|
|
|
}).then((result) => {
|
|
|
let productList = [];
|
|
|
|
|
|
// // console.log(productList)
|
|
|
// return productList;
|
|
|
// } else {
|
|
|
// logger.error('推荐商品 cood 不是 200');
|
|
|
// return {};
|
|
|
// }
|
|
|
// });
|
|
|
// };
|
|
|
if (result && result.code === 200) {
|
|
|
|
|
|
_.forEach(result.data.product_list, function(data) {
|
|
|
productList.push({
|
|
|
name: data.product_name,
|
|
|
price: data.sales_price,
|
|
|
id: data.product_id,
|
|
|
cnAlphabet: data.cn_alphabet
|
|
|
});
|
|
|
});
|
|
|
|
|
|
// console.log(productList)
|
|
|
return productList;
|
|
|
} else {
|
|
|
logger.error('推荐商品 cood 不是 200');
|
|
|
return {};
|
|
|
}
|
|
|
});
|
|
|
};
|
|
|
|
|
|
/**
|
|
|
* 详情页文章内容数据处理
|
...
|
...
|
@@ -294,7 +296,8 @@ const _processContentData = (list) => { |
|
|
list = camelCase(list);
|
|
|
|
|
|
let contentData = {
|
|
|
contents: []
|
|
|
contents: [],
|
|
|
collecation: []
|
|
|
};
|
|
|
|
|
|
_.forEach(list, function(value) {
|
...
|
...
|
@@ -313,32 +316,46 @@ const _processContentData = (list) => { |
|
|
|
|
|
contentData.contents = list;
|
|
|
|
|
|
// console.log(list)
|
|
|
// let collocation = {};
|
|
|
// let idList = '';
|
|
|
let formatData = [];
|
|
|
|
|
|
// _.forEach(contentData.contents, function(value) {
|
|
|
// // console.log(value)
|
|
|
_.forEach(contentData.contents, function(value) {
|
|
|
|
|
|
// if (value.goods) {
|
|
|
// console.log(value);
|
|
|
if (value.goods) {
|
|
|
|
|
|
// _.forEach(value.goods.data, function(data) {
|
|
|
_.forEach(value.goods.data, function(data) {
|
|
|
|
|
|
// _getRelatedData(51152761).then((result) => {
|
|
|
// idList += data.id + ',';
|
|
|
// idList = '51152761';
|
|
|
formatData.push(data);
|
|
|
});
|
|
|
}
|
|
|
});
|
|
|
|
|
|
// data = _.assign(data, result);
|
|
|
// data = _.assign(data, {
|
|
|
// link: `${config.siteUrl}/product/pro_${result.id}_${data.productSkc}/${result.cnAlphabet}`
|
|
|
// });
|
|
|
// });
|
|
|
// });
|
|
|
// }
|
|
|
|
|
|
// if (value.goodsGroup) {
|
|
|
// _.forEach(value.goodsGroup.data, function(data) {
|
|
|
// // console.log(data)
|
|
|
// _.forEach(data.list, function(value) {
|
|
|
// // console.log(value)
|
|
|
// console.log(formatData)
|
|
|
|
|
|
_getRelatedData().then((result) => {
|
|
|
// formatData.push(result);
|
|
|
// console.log(formatData);
|
|
|
|
|
|
_.forEach(formatData, function(data, index) {
|
|
|
|
|
|
data[index] = _.assign(result[index]);
|
|
|
|
|
|
});
|
|
|
|
|
|
// console.log(formatData);
|
|
|
return formatData;
|
|
|
|
|
|
}).then(() => {
|
|
|
|
|
|
});
|
|
|
|
|
|
// if (value.goodsGroup) {
|
|
|
// _.forEach(value.goodsGroup.data, function(data) {
|
|
|
// // console.log(data)
|
|
|
// _.forEach(data.list, function(value) {
|
|
|
// // console.log(value)
|
|
|
// _getRelatedData(51152761).then((result) => {
|
|
|
// // console.log(result)
|
|
|
// value = _.assign(value, result);
|
...
|
...
|
@@ -348,10 +365,9 @@ const _processContentData = (list) => { |
|
|
|
|
|
// // console.log(value)
|
|
|
// });
|
|
|
// });
|
|
|
// });
|
|
|
// }
|
|
|
// });
|
|
|
// });
|
|
|
// });
|
|
|
// }
|
|
|
|
|
|
return contentData;
|
|
|
};
|
...
|
...
|
|