...
|
...
|
@@ -7,12 +7,41 @@ |
|
|
|
|
|
'use strict';
|
|
|
const _ = require('lodash');
|
|
|
const productProcess = require(`${global.utils}/product-process`);
|
|
|
|
|
|
const api = global.yoho.API;
|
|
|
const helpers = global.yoho.helpers;
|
|
|
|
|
|
const _formatProduct = (data) => {
|
|
|
let list = [];
|
|
|
|
|
|
_.forEach(data, function(value) {
|
|
|
if (!value.product_skn || !value.goods_list || !value.goods_list.length) {
|
|
|
return;
|
|
|
}
|
|
|
value.goodsId = value.goods_list[0].goods_id;
|
|
|
|
|
|
let goods = {
|
|
|
salePrice: value.sales_price ? value.sales_price : '',
|
|
|
price: value.market_price ? value.market_price : '',
|
|
|
url: helpers.urlFormat(`/product/pro_${value.product_id}_${value.goodsId}/${value.cn_alphabet}.html`),
|
|
|
thumb: value.default_images,
|
|
|
name: value.product_name
|
|
|
|
|
|
};
|
|
|
|
|
|
// 市场价和售价一样,则不显示市场价
|
|
|
if (goods.salePrice === goods.price) {
|
|
|
goods.price = false;
|
|
|
}
|
|
|
|
|
|
list.push(goods);
|
|
|
});
|
|
|
|
|
|
return list;
|
|
|
};
|
|
|
|
|
|
module.exports = (data) => {
|
|
|
let finalResult;
|
|
|
let finalResult = {};
|
|
|
|
|
|
return api.get('', {
|
|
|
method: 'h5.preference.Search',
|
...
|
...
|
@@ -20,9 +49,8 @@ module.exports = (data) => { |
|
|
yhchannel: data.yhchannel,
|
|
|
brandId: data.brandId
|
|
|
}).then(result => {
|
|
|
if (!_.isEmpty(result) && result.code === 200) {
|
|
|
// 为你优选数据处理,接口没有数据,待处理,待验证
|
|
|
finalResult = productProcess.processProductList(result.data);
|
|
|
if (result) {
|
|
|
finalResult.recommendList = _formatProduct(result);
|
|
|
}
|
|
|
|
|
|
return finalResult;
|
...
|
...
|
|