...
|
...
|
@@ -159,11 +159,11 @@ const _detailDataPkg = (origin, uid, vipLevel, ua) => { |
|
|
if (!uid) {
|
|
|
let params = {};
|
|
|
|
|
|
params.refer = helpers.urlFormat('/product/show_' + origin.erpProductId + '.html');
|
|
|
params.refer = helpers.urlFormat('/product/show_' + origin.productSkn + '.html');
|
|
|
dest.loginUrl = helpers.urlFormat('/signin.html', params);
|
|
|
}
|
|
|
|
|
|
// 商品促销短语
|
|
|
// 商品促销短语 (app不确定)
|
|
|
if (origin.salesPhrase) {
|
|
|
dest.goodsSubtitle = origin.salesPhrase;
|
|
|
}
|
...
|
...
|
@@ -186,11 +186,11 @@ const _detailDataPkg = (origin, uid, vipLevel, ua) => { |
|
|
}
|
|
|
|
|
|
// 商品标签
|
|
|
if (origin.productTagBoList) {
|
|
|
if (origin.tags) {
|
|
|
let productTags = {};
|
|
|
|
|
|
_.forEach(origin.productTagBoList, function(value) {
|
|
|
switch (value.tagLabel) {
|
|
|
_.forEach(origin.tags, function(value) {
|
|
|
switch (value) {
|
|
|
case 'is_soon_sold_out':
|
|
|
productTags.is_soon_sold_out = true;
|
|
|
break;
|
...
|
...
|
@@ -218,29 +218,26 @@ const _detailDataPkg = (origin, uid, vipLevel, ua) => { |
|
|
}
|
|
|
|
|
|
// 商品价格
|
|
|
if (origin.productPriceBo) {
|
|
|
let originPrice = origin.productPriceBo;
|
|
|
let goodsPrice = {
|
|
|
currentPrice: originPrice.formatSalesPrice
|
|
|
};
|
|
|
let goodsPrice = {
|
|
|
currentPrice: origin.formatMarketPrice
|
|
|
};
|
|
|
|
|
|
if (originPrice.formatMarketPrice !== originPrice.formatSalesPrice) {
|
|
|
goodsPrice.previousPrice = originPrice.formatMarketPrice;
|
|
|
}
|
|
|
if (origin.formatMarketPrice !== origin.formatSalesPrice) {
|
|
|
goodsPrice.previousPrice = origin.formatMarketPrice;
|
|
|
}
|
|
|
|
|
|
dest.goodsPrice = goodsPrice;
|
|
|
dest.goodsPrice = goodsPrice;
|
|
|
|
|
|
// 商品返回 YOHO 币
|
|
|
if (originPrice.yohoCoinNum) {
|
|
|
dest.commodityReturn = originPrice.yohoCoinNum;
|
|
|
}
|
|
|
// 商品返回 YOHO 币
|
|
|
if (origin.yohoCoinNum) {
|
|
|
dest.commodityReturn = origin.yohoCoinNum;
|
|
|
}
|
|
|
|
|
|
// VIP 商品价格
|
|
|
if (origin.productPriceBo.vipPrices) {
|
|
|
if (origin.vipPrices) {
|
|
|
let vipList = [];
|
|
|
|
|
|
_.forEach(origin.productPriceBo.vipPrices, function(value) {
|
|
|
_.forEach(origin.vipPrices, function(value) {
|
|
|
vipList.push({
|
|
|
level: value.vipLevel,
|
|
|
text: value.vipPrice,
|
...
|
...
|
@@ -268,7 +265,7 @@ const _detailDataPkg = (origin, uid, vipLevel, ua) => { |
|
|
};
|
|
|
|
|
|
let consultParams = {
|
|
|
product_id: origin.id
|
|
|
product_id: origin.productId
|
|
|
};
|
|
|
|
|
|
if (_.has(dest, 'feedbacks.consultsNum')) {
|
...
|
...
|
@@ -298,19 +295,19 @@ const _detailDataPkg = (origin, uid, vipLevel, ua) => { |
|
|
dest.feedbacks.comments = commentList;
|
|
|
|
|
|
dest.feedbacks.commentsUrl = helpers.urlFormat('/product/detail/comments', {
|
|
|
product_id: origin.id,
|
|
|
product_id: origin.productId,
|
|
|
total: dest.feedbacks.commentsNum
|
|
|
});
|
|
|
}
|
|
|
|
|
|
// 品牌信息
|
|
|
if (origin.brand) {
|
|
|
let extra = `?productSkn=${origin.erpProductId}&brandId=${origin.brand.id}`;
|
|
|
let extra = `?productSkn=${origin.productSkn}&brandId=${origin.brandInfo.brandId}`;
|
|
|
|
|
|
dest.preferenceUrl = `/product/detail/preference${extra}`;
|
|
|
}
|
|
|
|
|
|
dest.productSkn = origin.erpProductId;
|
|
|
dest.productSkn = origin.productSkn;
|
|
|
|
|
|
// 商品信息
|
|
|
if (origin.goodsList) {
|
...
|
...
|
@@ -328,12 +325,11 @@ const _detailDataPkg = (origin, uid, vipLevel, ua) => { |
|
|
}
|
|
|
|
|
|
colorStorageNum = 0;
|
|
|
|
|
|
// 商品分组
|
|
|
if (value.goodsImagesList) {
|
|
|
_.forEach(value.goodsImagesList, function(good) {
|
|
|
if (value.imagesList) {
|
|
|
_.forEach(value.imagesList, function(good) {
|
|
|
goodsGroup.push({
|
|
|
goodsId: good.goodsId,
|
|
|
goodsId: value.goodsId,
|
|
|
img: good.imageUrl
|
|
|
});
|
|
|
});
|
...
|
...
|
@@ -341,16 +337,16 @@ const _detailDataPkg = (origin, uid, vipLevel, ua) => { |
|
|
|
|
|
// 商品的尺码列表
|
|
|
colorStorageGroup[value.productSkc] = {};
|
|
|
if (value.goodsSizeBoList) {
|
|
|
if (value.sizeList) {
|
|
|
sizeList[value.productSkc] = [];
|
|
|
_.forEach(value.goodsSizeBoList, function(size) {
|
|
|
_.forEach(value.sizeList, function(size) {
|
|
|
sizeList[value.productSkc].push({
|
|
|
id: size.id,
|
|
|
skuId: size.goodsSizeSkuId,
|
|
|
goodsId: size.goodsId,
|
|
|
colorId: size.colorId,
|
|
|
id: size.sizeId,
|
|
|
skuId: size.productSku,
|
|
|
goodsId: value.goodsId,
|
|
|
colorId: value.colorId,
|
|
|
name: size.sizeName,
|
|
|
sizeNum: size.goodsSizeStorageNum
|
|
|
sizeNum: size.storageNumber
|
|
|
});
|
|
|
|
|
|
sizeName = size.sizeName;
|
...
|
...
|
@@ -358,16 +354,16 @@ const _detailDataPkg = (origin, uid, vipLevel, ua) => { |
|
|
// 所有尺码列表,赋值用于前端展示默认尺码的时候
|
|
|
// 判断出没有库存则显示灰色
|
|
|
let build = {
|
|
|
id: size.id,
|
|
|
storage: size.goodsSizeStorageNum
|
|
|
id: size.sizeId,
|
|
|
storage: size.storageNumber
|
|
|
};
|
|
|
|
|
|
allSizeList[sizeName] = (allSizeList[sizeName] === null ||
|
|
|
typeof allSizeList[sizeName] === 'undefined') ? build :
|
|
|
allSizeList[sizeName];
|
|
|
|
|
|
colorStorageNum += parseInt(size.goodsSizeStorageNum, 10);
|
|
|
colorStorageGroup[value.productSkc][sizeName] = parseInt(size.goodsSizeStorageNum, 10);
|
|
|
colorStorageNum += parseInt(size.storageNumber, 10);
|
|
|
colorStorageGroup[value.productSkc][sizeName] = parseInt(size.storageNumber, 10);
|
|
|
});
|
|
|
|
|
|
// 颜色分组
|
...
|
...
|
@@ -375,7 +371,6 @@ const _detailDataPkg = (origin, uid, vipLevel, ua) => { |
|
|
id: value.colorId,
|
|
|
skcId: value.productSkc,
|
|
|
name: value.colorName,
|
|
|
goodsName: value.goodsName,
|
|
|
colorNum: colorStorageNum
|
|
|
});
|
|
|
}
|
...
|
...
|
@@ -395,9 +390,7 @@ const _detailDataPkg = (origin, uid, vipLevel, ua) => { |
|
|
sizeGroup[0] = {
|
|
|
size: []
|
|
|
};
|
|
|
|
|
|
_.forEach(allSizeList, (value, key) => {
|
|
|
|
|
|
// 默认尺码
|
|
|
sizeGroup[0].size.push({
|
|
|
name: key,
|
...
|
...
|
@@ -408,7 +401,6 @@ const _detailDataPkg = (origin, uid, vipLevel, ua) => { |
|
|
colorGroup[i] = {
|
|
|
color: []
|
|
|
};
|
|
|
|
|
|
// 各个颜色的尺码, 每行显示一个尺码对应的颜色
|
|
|
_.forEach(colorList, (colorArr) => {
|
|
|
let tempColorArr = _.cloneDeep(colorArr);
|
...
|
...
|
@@ -446,6 +438,7 @@ const _detailDataPkg = (origin, uid, vipLevel, ua) => { |
|
|
|
|
|
|
|
|
// 商品图:多个
|
|
|
console.log(goodsGroup);
|
|
|
if (goodsGroup.length > 1) {
|
|
|
let bannerList = [];
|
|
|
|
...
|
...
|
@@ -469,18 +462,17 @@ const _detailDataPkg = (origin, uid, vipLevel, ua) => { |
|
|
dest.cartInfo = {
|
|
|
cartUrl: helpers.urlFormat('/cart/index/index'),
|
|
|
numInCart: 0,
|
|
|
goodsInstore: origin.storage
|
|
|
goodsInstore: origin.storageSum
|
|
|
};
|
|
|
|
|
|
let soldOut = (origin.storage === 0) || (origin.status === 0 || totalStorageNum === 0);
|
|
|
let soldOut = (origin.storageSum === 0) || (origin.status === 0 || totalStorageNum === 0); //status
|
|
|
let notForSale = origin.attribute === 2;
|
|
|
|
|
|
// 显示加入购物车链接
|
|
|
if (!soldOut && !notForSale) {
|
|
|
_.orderBy(colorGroup);
|
|
|
|
|
|
Object.assign(dest.cartInfo, {
|
|
|
productId: origin.id,
|
|
|
productId: origin.productId,
|
|
|
thumbs: thumbImageList,
|
|
|
name: dest.goodsName ? dest.goodsName : '',
|
|
|
price: dest.goodsPrice.previousPrice ? dest.goodsPrice.previousPrice : '',
|
...
|
...
|
@@ -491,7 +483,7 @@ const _detailDataPkg = (origin, uid, vipLevel, ua) => { |
|
|
});
|
|
|
|
|
|
// 限购商品
|
|
|
if (origin.isLimitBuy === 'Y') {
|
|
|
if (origin.isLimitBuy) {
|
|
|
// 是否开售
|
|
|
let isBeginSale = (origin.saleStatus !== null && typeof origin.saleStatus !== 'undefined' &&
|
|
|
origin.saleStatus === 1);
|
...
|
...
|
@@ -507,11 +499,11 @@ const _detailDataPkg = (origin, uid, vipLevel, ua) => { |
|
|
dest = _procShowStatus(dest, showStatus, isBeginSale);
|
|
|
|
|
|
dest.cartInfo.limitProductCode = origin.limitProductCode;
|
|
|
dest.cartInfo.limitCodeUrl = _getLimitCodeUrl(origin.limitProductCode, origin.erpProductId, ua);
|
|
|
dest.cartInfo.limitCodeUrl = _getLimitCodeUrl(origin.limitProductCode, origin.productSkn, ua);
|
|
|
dest.cartInfo.limitProductPay = helpers.urlFormat('/cart/index/orderEnsure');
|
|
|
} else {
|
|
|
dest.cartInfo.addToCartUrl = helpers.urlFormat('/product/buy_' + origin.id + '_' +
|
|
|
origin.goodsList.id + '.html');
|
|
|
dest.cartInfo.addToCartUrl = helpers.urlFormat('/product/buy_' + origin.productId + '_' +
|
|
|
origin.goodsList.goodsId + '.html');
|
|
|
}
|
|
|
} else if (notForSale) {
|
|
|
dest.cartInfo.notForSale = true;
|
...
|
...
|
@@ -527,8 +519,8 @@ const _detailDataPkg = (origin, uid, vipLevel, ua) => { |
|
|
}
|
|
|
|
|
|
// 底部简介URL链接
|
|
|
dest.introUrl = '/product/detail/intro/' + origin.erpProductId;
|
|
|
dest.id = origin.id;
|
|
|
dest.introUrl = '/product/detail/intro/' + origin.productSkn;
|
|
|
dest.id = origin.productId;
|
|
|
|
|
|
// 虚拟商品(门票)
|
|
|
if (origin.attribute * 1 === 3) {
|
...
|
...
|
@@ -536,7 +528,7 @@ const _detailDataPkg = (origin, uid, vipLevel, ua) => { |
|
|
dest.ticketsConfirm = helpers.urlFormat('/cart/index/ticketsConfirm');
|
|
|
|
|
|
// 展览票
|
|
|
if (origin.erpProductId * 1 === SINGLE_TICKETS_SKN) {
|
|
|
if (origin.productSkn * 1 === SINGLE_TICKETS_SKN) {
|
|
|
dest.single = true;
|
|
|
} else {
|
|
|
// 套票
|
...
|
...
|
@@ -613,12 +605,12 @@ const _getCommonConsult = () => { |
|
|
let getProductData = (data) => {
|
|
|
let finalResult;
|
|
|
let params = {
|
|
|
method: 'h5.product.data'
|
|
|
method: 'app.product.data'
|
|
|
};
|
|
|
|
|
|
if (data.id) { // 通过 productId 获取商品详情
|
|
|
Object.assign(params, {
|
|
|
productId: _.toString(data.id)
|
|
|
product_id: _.toString(data.id)
|
|
|
});
|
|
|
} else if (data.productSkn) { // 通过 productSkn 获取商品详情
|
|
|
Object.assign(params, {
|
...
|
...
|
@@ -634,22 +626,22 @@ let getProductData = (data) => { |
|
|
data.vipLevel = (user.data && user.data.vip_info && user.data.vip_info.cur_level) || '0';
|
|
|
|
|
|
return api.get('', params, {
|
|
|
cache: false
|
|
|
}).then(result => {
|
|
|
code: 200
|
|
|
}).then(global.yoho.camelCase).then(result => {
|
|
|
if (result.code === 500) {
|
|
|
return {};
|
|
|
}
|
|
|
result = result.data;
|
|
|
return Promise.all([
|
|
|
_getShopsInfo(result.brandId),
|
|
|
_getPromotionInfo(result.erpProductId),
|
|
|
_getShopsInfo(result.brandInfo.brandId),
|
|
|
_getPromotionInfo(result.productSkn),
|
|
|
comment.getCommentInfo({
|
|
|
productId: result.id
|
|
|
productId: result.productId
|
|
|
}),
|
|
|
_getCommonConsult(),
|
|
|
comment.getConsults(result.id, 1, 2)
|
|
|
comment.getConsults(result.productId, 1, 2)
|
|
|
]).then((info) => {
|
|
|
result.promotionBoList = info[1];
|
|
|
|
|
|
finalResult = _detailDataPkg(result, data.uid, data.vipLevel, data.ua);
|
|
|
finalResult.enterStore = info[0];
|
|
|
|
...
|
...
|
|