...
|
...
|
@@ -6,67 +6,64 @@ const _ = require('lodash'); |
|
|
|
|
|
/**
|
|
|
* 分享页面基础参数
|
|
|
* @param {object} sizeInfo [接口原始数据]
|
|
|
* @return {object} [description]
|
|
|
* @param data
|
|
|
*/
|
|
|
const getPreferenceData = (data) => {
|
|
|
var dest = {};
|
|
|
let dest = {
|
|
|
goods: []
|
|
|
};
|
|
|
|
|
|
let list = data.data || {};
|
|
|
|
|
|
// list = camelCase(list);
|
|
|
_.forEach(list && list.product_list, value => {
|
|
|
|
|
|
let distGoods = [];
|
|
|
|
|
|
_.forEach(list.productList, function(value) {
|
|
|
|
|
|
if (!value.productSkn || !value.goodsList || !value.goodsList.length) {
|
|
|
if (!value.product_skn || !value.goods_list || !value.goods_list.length) {
|
|
|
return;
|
|
|
}
|
|
|
value.goodsId = value.goodsList[0].goodsId;
|
|
|
|
|
|
// let goods = value;
|
|
|
value.goodsId = value.goods_list && value.goods_list[0] && value.goods_list[0].goods_id;
|
|
|
|
|
|
let goods = [];
|
|
|
|
|
|
goods.push({
|
|
|
productSkn: value.product_skn,
|
|
|
productName: value.product_name,
|
|
|
defaultImages: value.default_images,
|
|
|
isSoonSoldOut: value.is_soon_sold_out,
|
|
|
let goods = {
|
|
|
product_skn: value.product_skn,
|
|
|
product_name: value.product_name,
|
|
|
default_images: value.default_images,
|
|
|
is_soon_sold_out: value.is_soon_sold_out === 'Y',
|
|
|
url: helpers.urlFormat(`/product/pro_${value.product_id}_${value.goodsId}/${value.cn_alphabet}.html`),
|
|
|
marketPrice: value.market_price,
|
|
|
salesPrice: value.sales_price
|
|
|
market_price: value.market_price,
|
|
|
sales_price: value.sales_price
|
|
|
};
|
|
|
|
|
|
// if (_.get(value, 'tags[0]', null)) {
|
|
|
// goods.tags = [];
|
|
|
// if (goods.is_new === 'Y') {
|
|
|
// goods.tags.push({is_new: true});
|
|
|
// } else if (goods.is_advance === 'Y') {
|
|
|
// goods.tags.push({isAdvance: true});
|
|
|
// } else if (goods.is_discount === 'Y') {
|
|
|
// goods.tags.push({isDiscount: true});
|
|
|
// } else if (goods.is_yohoood === 'Y') {
|
|
|
// goods.tags.push({isYohoood: true});
|
|
|
// } else if (goods.is_limited === 'Y') {
|
|
|
// goods.tags.push({isLimited: true});
|
|
|
// }
|
|
|
// }
|
|
|
|
|
|
let tags = {};
|
|
|
|
|
|
_.forEach(value.tags, tag => {
|
|
|
tags[tag] = true;
|
|
|
});
|
|
|
goods.tags = tags;
|
|
|
|
|
|
// goods.url = helpers.urlFormat(`/product/pro_${value.product_id}_${value.goodsId}/${value.cn_alphabet}.html`);
|
|
|
|
|
|
if (_.get(goods, 'tags[0]', null)) {
|
|
|
goods.tags = [];
|
|
|
if (goods.isNew === 'Y') {
|
|
|
goods.tags.push({is_new: true});
|
|
|
} else if (goods.is_advance === 'Y') {
|
|
|
goods.tags.push({isAdvance: true});
|
|
|
} else if (goods.is_discount === 'Y') {
|
|
|
goods.tags.push({isDiscount: true});
|
|
|
} else if (goods.is_yohoood === 'Y') {
|
|
|
goods.tags.push({isYohoood: true});
|
|
|
} else if (goods.is_limited === 'Y') {
|
|
|
goods.tags.push({isLimited: true});
|
|
|
}
|
|
|
}
|
|
|
distGoods.push(goods);
|
|
|
dest.goods.push(goods);
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
dest.code = list.code;
|
|
|
dest.goods = distGoods;
|
|
|
dest.rec_id = list.recId;
|
|
|
dest.code = data.code;
|
|
|
dest.rec_id = list.rec_id;
|
|
|
dest.message = list.message;
|
|
|
|
|
|
// 清空变量,释放内存
|
|
|
data = {};
|
|
|
return dest;
|
|
|
};
|
|
|
|
...
|
...
|
|