...
|
...
|
@@ -14,13 +14,11 @@ const pager = require(`${global.utils}/pager`).setPager; |
|
|
const productProcess = require(`${global.utils}/product-process`);
|
|
|
|
|
|
const getGlobalProductListData = (params, yoho) => {
|
|
|
params.limit = params.limit ? params.limit - 1 : 59;
|
|
|
|
|
|
return Promise.props({
|
|
|
header: headerModel.requestHeaderData(yoho.channel),
|
|
|
list: globalApi.getGlobalProductListAsync(Object.assign({
|
|
|
physical_channel: yoho.channelNum
|
|
|
}, params))
|
|
|
}, params, {limit: params.limit ? params.limit - 1 : 59}))
|
|
|
}).then(result => {
|
|
|
let resData = {};
|
|
|
|
...
|
...
|
@@ -50,12 +48,77 @@ const getGlobalProductListData = (params, yoho) => { |
|
|
});
|
|
|
};
|
|
|
|
|
|
const getGlobalProductDetailData = () => {
|
|
|
const getGlobalProductDetailData = (skn, channelNum, channel) => {
|
|
|
return Promise.props({
|
|
|
header: headerModel.requestHeaderData(channel),
|
|
|
detail: globalApi.getGlobalProductDetailAsync(skn, channelNum),
|
|
|
html: globalApi.getGlobalProductHtmlAsync(skn, channelNum)
|
|
|
}).then(result => {
|
|
|
let resData = {};
|
|
|
let detailInfo, html = '';
|
|
|
|
|
|
if (+result.detail.code === 200) {
|
|
|
detailInfo = _.get(result, 'detail.data', {});
|
|
|
|
|
|
if (!_.isEmpty(detailInfo.goods_list)) {
|
|
|
let colors = [];
|
|
|
|
|
|
_.forEach(detailInfo.goods_list, (value, index) => {
|
|
|
let size = [];
|
|
|
|
|
|
|
|
|
_.forEach(value.size_list || [], subVal => {
|
|
|
size.push({
|
|
|
sku: subVal.product_sku,
|
|
|
name: subVal.size_name,
|
|
|
soldOut: subVal.storage_number * 1 <= 0
|
|
|
});
|
|
|
});
|
|
|
|
|
|
|
|
|
if (_.isEmpty(value.images_list)) {
|
|
|
value.images_list = [{
|
|
|
image_url: value.color_image
|
|
|
}];
|
|
|
}
|
|
|
|
|
|
if (index === 0 && !detailInfo.mainThumb) {
|
|
|
value.focus = true;
|
|
|
detailInfo.mainThumb = _.get(value, 'images_list[0].image_url', value.color_image);
|
|
|
}
|
|
|
|
|
|
colors.push({
|
|
|
src: value.color_image,
|
|
|
name: value.color_name,
|
|
|
title: value.color_name,
|
|
|
imgList: value.images_list,
|
|
|
focus: value.focus,
|
|
|
size: size
|
|
|
});
|
|
|
});
|
|
|
|
|
|
detailInfo.colors = colors;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
if (result.html) {
|
|
|
let regContent = /<body[^>]*>([\s\S]*)<\/body>/.exec(result.html);
|
|
|
|
|
|
html = regContent[1] || '';
|
|
|
html = html.replace(/<script.*?>.*?<\/script>/ig, '');
|
|
|
}
|
|
|
|
|
|
// console.log(result.detail.code);
|
|
|
Object.assign(resData, result.header, {
|
|
|
goodsInfo: detailInfo,
|
|
|
detailHtml: html || ''
|
|
|
});
|
|
|
|
|
|
return resData;
|
|
|
});
|
|
|
};
|
|
|
|
|
|
module.exports = {
|
|
|
getGlobalProductListData,
|
|
|
getGlobalProductDetailData
|
|
|
}; |
|
|
|
...
|
...
|
|