...
|
...
|
@@ -6,8 +6,10 @@ |
|
|
|
|
|
'use strict';
|
|
|
|
|
|
const api = global.yoho.API;
|
|
|
const _ = require('lodash');
|
|
|
const comment = require('./consult-comment');
|
|
|
|
|
|
const api = global.yoho.API;
|
|
|
const helpers = global.yoho.helpers;
|
|
|
|
|
|
/**
|
...
|
...
|
@@ -237,23 +239,6 @@ const _detailDataPkg = (origin, uid, vipLevel, ua) => { |
|
|
dest.periodOfMarket = `${origin.expectArrivalTime}月`;
|
|
|
}
|
|
|
|
|
|
// 促销信息 TODO: 换新接口
|
|
|
if (origin.promotionBoList) {
|
|
|
let discountList = [];
|
|
|
|
|
|
_.forEach(origin.promotionBoList, function(value) {
|
|
|
discountList.push({
|
|
|
text: `【${value.promotionType}】${value.promotionTitle}`
|
|
|
});
|
|
|
});
|
|
|
|
|
|
if (discountList.length) {
|
|
|
dest.goodsDiscount = {
|
|
|
list: discountList
|
|
|
};
|
|
|
}
|
|
|
}
|
|
|
|
|
|
// 商品咨询
|
|
|
dest.feedbacks = {
|
|
|
consults: [],
|
...
|
...
|
@@ -277,7 +262,7 @@ const _detailDataPkg = (origin, uid, vipLevel, ua) => { |
|
|
|
|
|
if (_.has(dest, 'feedbacks.consultsNum')) {
|
|
|
consultParams.total = dest.feedbacks.consultsNum;
|
|
|
dest.feedbacks.consultsUrl = helpers.urlFormat('/product/detail/consult', consultParams);
|
|
|
dest.feedbacks.consultsUrl = helpers.urlFormat('/product/detail/consults', consultParams);
|
|
|
} else {
|
|
|
dest.feedbacks.consultsUrl = helpers.urlFormat('/product/detail/consultform', consultParams);
|
|
|
}
|
...
|
...
|
@@ -367,7 +352,7 @@ const _detailDataPkg = (origin, uid, vipLevel, ua) => { |
|
|
};
|
|
|
|
|
|
allSizeList[sizeName] = (allSizeList[sizeName] === null ||
|
|
|
typeof allSizeList[sizeName] === 'undefined') ? build :
|
|
|
typeof allSizeList[sizeName] === 'undefined') ? build :
|
|
|
allSizeList[sizeName];
|
|
|
|
|
|
colorStorageNum += parseInt(size.goodsSizeStorageNum, 10);
|
...
|
...
|
@@ -399,10 +384,10 @@ const _detailDataPkg = (origin, uid, vipLevel, ua) => { |
|
|
sizeGroup[0] = {
|
|
|
size: []
|
|
|
};
|
|
|
_.forEach(allSizeList, function(value) {
|
|
|
_.forEach(allSizeList, function(value, key) {
|
|
|
// 默认尺码
|
|
|
sizeGroup[0].size.push({
|
|
|
name: sizeName,
|
|
|
name: key,
|
|
|
sizeNum: _.toNumber(value.storage) > 0 ? true : false,
|
|
|
id: value.id
|
|
|
});
|
...
|
...
|
@@ -415,10 +400,10 @@ const _detailDataPkg = (origin, uid, vipLevel, ua) => { |
|
|
_.forEach(colorList, function(colorArr) {
|
|
|
colorArr.colorNum = 0;
|
|
|
if (colorStorageGroup[colorArr.skcId] &&
|
|
|
colorStorageGroup[colorArr.skcId][sizeName]) {
|
|
|
colorArr.colorNum = colorStorageGroup[colorArr.skcId][sizeName];
|
|
|
colorStorageGroup[colorArr.skcId][key]) {
|
|
|
colorArr.colorNum = colorStorageGroup[colorArr.skcId][key];
|
|
|
}
|
|
|
colorGroup[i].color.push(colorArr);
|
|
|
colorGroup[i].color.push(Object.assign({}, colorArr));
|
|
|
});
|
|
|
colorGroup[i].id = value.id;
|
|
|
|
...
|
...
|
@@ -443,6 +428,7 @@ const _detailDataPkg = (origin, uid, vipLevel, ua) => { |
|
|
++i;
|
|
|
});
|
|
|
|
|
|
|
|
|
// 商品图:多个
|
|
|
if (goodsGroup.length > 1) {
|
|
|
let bannerList = [];
|
...
|
...
|
@@ -492,7 +478,7 @@ const _detailDataPkg = (origin, uid, vipLevel, ua) => { |
|
|
if (origin.isLimitBuy === 'Y') {
|
|
|
// 是否开售
|
|
|
let isBeginSale = (origin.saleStatus !== null && typeof origin.saleStatus !== 'undefined' &&
|
|
|
origin.saleStatus === 1);
|
|
|
origin.saleStatus === 1);
|
|
|
|
|
|
// 限购商品有关的展示状态
|
|
|
let showStatus = 1;
|
...
|
...
|
@@ -560,6 +546,28 @@ let _getPromotionInfo = (skn) => { |
|
|
});
|
|
|
};
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 获取默认咨询列表
|
|
|
*/
|
|
|
const _getCommonConsult = () => {
|
|
|
let params = {
|
|
|
method: 'app.consult.common'
|
|
|
};
|
|
|
|
|
|
return api.get('', params, {
|
|
|
code: 200
|
|
|
}).then(result => {
|
|
|
let data = {};
|
|
|
|
|
|
if (result.data) {
|
|
|
data = result.data;
|
|
|
}
|
|
|
|
|
|
return data;
|
|
|
});
|
|
|
};
|
|
|
|
|
|
let getProductData = (data) => {
|
|
|
let finalResult;
|
|
|
let params = {
|
...
|
...
|
@@ -577,12 +585,32 @@ let getProductData = (data) => { |
|
|
return api.get('', params, {
|
|
|
cache: true
|
|
|
}).then(result => {
|
|
|
return Promise.all([_getShopsInfo(result.brandId), _getPromotionInfo(result.erpProductId)]).then((info) => {
|
|
|
if (result.code === 500) {
|
|
|
return {};
|
|
|
}
|
|
|
return Promise.all([
|
|
|
_getShopsInfo(result.brandId),
|
|
|
_getPromotionInfo(result.erpProductId),
|
|
|
comment.getCommentInfo({
|
|
|
productId: result.id
|
|
|
}),
|
|
|
_getCommonConsult()
|
|
|
]).then((info) => {
|
|
|
result.promotionBoList = info[1];
|
|
|
|
|
|
finalResult = _detailDataPkg(result, data.uid, data.vipLevel, data.ua);
|
|
|
finalResult.enterStore = info[0];
|
|
|
|
|
|
Object.assign(finalResult.feedbacks, info[2]);
|
|
|
|
|
|
if (!_.isEmpty(info[3]) && !_.get(info[2], 'feedbacks.consultsNum', 0)) {
|
|
|
Object.assign(finalResult.feedbacks, {
|
|
|
commonConsults: true,
|
|
|
consultsNum: true,
|
|
|
consults: _.take(info[3], 2)
|
|
|
});
|
|
|
}
|
|
|
|
|
|
return finalResult;
|
|
|
});
|
|
|
|
...
|
...
|
|