...
|
...
|
@@ -222,11 +222,11 @@ const _getLimitCodeUrl = (productCode, skn, ua) => { |
|
|
// if (origin.productPriceBo) {
|
|
|
// let originPrice = origin.productPriceBo;
|
|
|
// let goodsPrice = {
|
|
|
// currentPrice: originPrice.formatSalesPrice
|
|
|
// currentPrice: originPrice.format_sales_price
|
|
|
// };
|
|
|
|
|
|
// if (originPrice.formatMarketPrice !== originPrice.formatSalesPrice) {
|
|
|
// goodsPrice.previousPrice = originPrice.formatMarketPrice;
|
|
|
// if (originPrice.format_market_price !== originPrice.format_sales_price) {
|
|
|
// goodsPrice.previousPrice = originPrice.format_market_price;
|
|
|
// }
|
|
|
|
|
|
// dest.goodsPrice = goodsPrice;
|
...
|
...
|
@@ -566,12 +566,12 @@ const _detailDataPkg = (origin, uid, vipLevel, ua) => { |
|
|
totalStorageNum = 0;
|
|
|
|
|
|
// 商品名称
|
|
|
if (!origin.productName) {
|
|
|
if (!origin.product_name) {
|
|
|
dest.feedbacks = {};
|
|
|
return dest;
|
|
|
}
|
|
|
|
|
|
dest.goodsName = origin.productName;
|
|
|
dest.goodsName = origin.product_name;
|
|
|
|
|
|
// 是否是虚拟商品
|
|
|
dest.virtualGoods = (origin.attribute * 1 === 3);
|
...
|
...
|
@@ -579,12 +579,12 @@ const _detailDataPkg = (origin, uid, vipLevel, ua) => { |
|
|
// 用户未登录时
|
|
|
if (!uid) {
|
|
|
dest.loginUrl = helpers.urlFormat('/signin.html', {
|
|
|
refer: helpers.urlFormat('/product/show_' + origin.productSkn + '.html')
|
|
|
refer: helpers.urlFormat('/product/show_' + origin.product_skn + '.html')
|
|
|
});
|
|
|
}
|
|
|
|
|
|
// 商品促销短语
|
|
|
origin.salesPhrase && (dest.goodsSubtitle = origin.salesPhrase);
|
|
|
origin.sales_phrase && (dest.goodsSubtitle = origin.sales_phrase);
|
|
|
|
|
|
// 促销信息 TODO: 换新接口
|
|
|
if (origin.promotionBoList) {
|
...
|
...
|
@@ -614,11 +614,11 @@ const _detailDataPkg = (origin, uid, vipLevel, ua) => { |
|
|
|
|
|
// 商品价格
|
|
|
let goodsPrice = {
|
|
|
currentPrice: origin.formatSalesPrice === '0' ? origin.formatMarketPrice : origin.formatSalesPrice
|
|
|
currentPrice: origin.format_sales_price === '0' ? origin.format_market_price : origin.format_sales_price
|
|
|
};
|
|
|
|
|
|
if (origin.formatSalesPrice !== '0' && origin.formatMarketPrice !== origin.formatSalesPrice) {
|
|
|
goodsPrice.previousPrice = origin.formatMarketPrice;
|
|
|
if (origin.format_sales_price !== '0' && origin.format_market_price !== origin.format_sales_price) {
|
|
|
goodsPrice.previousPrice = origin.format_market_price;
|
|
|
}
|
|
|
|
|
|
dest.goodsPrice = goodsPrice;
|
...
|
...
|
@@ -648,8 +648,8 @@ const _detailDataPkg = (origin, uid, vipLevel, ua) => { |
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
// 上市期
|
|
|
// TODO 接口文档,实际接口数据中都没有找到这个字段,所以不知道有什么用途
|
|
|
origin.expectArrivalTime && (dest.periodOfMarket = `${origin.expectArrivalTime}月`);
|
|
|
|
|
|
// 商品咨询
|
...
|
...
|
@@ -659,7 +659,7 @@ const _detailDataPkg = (origin, uid, vipLevel, ua) => { |
|
|
};
|
|
|
|
|
|
let consultParams = {
|
|
|
product_id: origin.productId
|
|
|
product_id: origin.product_id
|
|
|
};
|
|
|
|
|
|
if (_.has(dest, 'feedbacks.consultsNum')) {
|
...
|
...
|
@@ -671,20 +671,20 @@ const _detailDataPkg = (origin, uid, vipLevel, ua) => { |
|
|
|
|
|
// 商品评价
|
|
|
dest.feedbacks.commentsUrl = helpers.urlFormat('/product/detail/comments', {
|
|
|
product_id: origin.productId,
|
|
|
product_id: origin.product_id,
|
|
|
});
|
|
|
|
|
|
// 品牌信息
|
|
|
if (origin.brand) {
|
|
|
let extra = `?productSkn=${origin.productSkn}&brandId=${origin.brandInfo.brandId}`;
|
|
|
let extra = `?productSkn=${origin.product_skn}&brandId=${origin.brand_info.brand_id}`;
|
|
|
|
|
|
dest.preferenceUrl = `/product/detail/preference${extra}`;
|
|
|
}
|
|
|
|
|
|
dest.productSkn = origin.productSkn;
|
|
|
dest.productSkn = origin.product_skn;
|
|
|
|
|
|
// 商品信息
|
|
|
if (origin.goodsList) {
|
|
|
if (origin.goods_list) {
|
|
|
let goodsGroup = [],
|
|
|
sizeName = '',
|
|
|
colorList = [],
|
...
|
...
|
@@ -693,7 +693,7 @@ const _detailDataPkg = (origin, uid, vipLevel, ua) => { |
|
|
colorStorageGroup = {},
|
|
|
colorStorageNum = 0;
|
|
|
|
|
|
_.forEach(origin.goodsList, function(value) {
|
|
|
_.forEach(origin.goods_list, function(value) {
|
|
|
if (value.status === 0) {
|
|
|
return;
|
|
|
}
|
...
|
...
|
@@ -701,56 +701,56 @@ const _detailDataPkg = (origin, uid, vipLevel, ua) => { |
|
|
colorStorageNum = 0;
|
|
|
|
|
|
// 商品分组
|
|
|
if (value.imagesList) {
|
|
|
_.forEach(value.imagesList, function(good) {
|
|
|
if (value.images_list) {
|
|
|
_.forEach(value.images_list, function(good) {
|
|
|
goodsGroup.push({
|
|
|
goodsId: value.goodsId,
|
|
|
img: good.imageUrl
|
|
|
goodsId: value.goods_id,
|
|
|
img: good.image_url
|
|
|
});
|
|
|
});
|
|
|
}
|
|
|
|
|
|
// 商品的尺码列表
|
|
|
colorStorageGroup[value.productSkc] = {};
|
|
|
if (value.sizeList) {
|
|
|
sizeList[value.productSkc] = [];
|
|
|
_.forEach(value.sizeList, function(size) {
|
|
|
sizeList[value.productSkc].push({
|
|
|
id: size.sizeId,
|
|
|
skuId: size.productSku,
|
|
|
goodsId: value.goodsId,
|
|
|
colorId: value.colorId,
|
|
|
name: size.sizeName,
|
|
|
sizeNum: size.storageNumber
|
|
|
colorStorageGroup[value.product_skc] = {};
|
|
|
if (value.size_list) {
|
|
|
sizeList[value.product_skc] = [];
|
|
|
_.forEach(value.size_list, function(size) {
|
|
|
sizeList[value.product_skc].push({
|
|
|
id: size.size_id,
|
|
|
skuId: size.product_sku,
|
|
|
goodsId: value.goods_id,
|
|
|
colorId: value.color_id,
|
|
|
name: size.size_name,
|
|
|
sizeNum: size.storage_number
|
|
|
});
|
|
|
|
|
|
sizeName = size.sizeName;
|
|
|
sizeName = size.size_name;
|
|
|
|
|
|
// 所有尺码列表,赋值用于前端展示默认尺码的时候
|
|
|
// 判断出没有库存则显示灰色
|
|
|
let build = {
|
|
|
id: size.sizeId,
|
|
|
storage: size.storageNumber
|
|
|
id: size.size_id,
|
|
|
storage: size.storage_number
|
|
|
};
|
|
|
|
|
|
allSizeList[sizeName] = (allSizeList[sizeName] === null ||
|
|
|
typeof allSizeList[sizeName] === 'undefined') ? build : allSizeList[sizeName];
|
|
|
colorStorageNum += parseInt(size.storageNumber, 10);
|
|
|
colorStorageGroup[value.productSkc][sizeName] = parseInt(size.storageNumber, 10);
|
|
|
colorStorageNum += parseInt(size.storage_number, 10);
|
|
|
colorStorageGroup[value.product_skc][sizeName] = parseInt(size.storage_number, 10);
|
|
|
});
|
|
|
|
|
|
// 颜色分组
|
|
|
colorList.push({
|
|
|
id: value.colorId,
|
|
|
skcId: value.productSkc,
|
|
|
name: value.colorName,
|
|
|
id: value.color_id,
|
|
|
skcId: value.product_skc,
|
|
|
name: value.color_name,
|
|
|
colorNum: colorStorageNum
|
|
|
});
|
|
|
}
|
|
|
|
|
|
// 缩略图
|
|
|
thumbImageList.push({
|
|
|
img: value.colorImage
|
|
|
img: value.color_image
|
|
|
});
|
|
|
|
|
|
// 商品库存总数
|
...
|
...
|
@@ -835,9 +835,9 @@ const _detailDataPkg = (origin, uid, vipLevel, ua) => { |
|
|
dest.cartInfo = {
|
|
|
cartUrl: helpers.urlFormat('/cart/index/index'),
|
|
|
numInCart: 0,
|
|
|
goodsInstore: origin.storageSum
|
|
|
goodsInstore: origin.storage_sum
|
|
|
};
|
|
|
let soldOut = (origin.storageSum === 0) || (totalStorageNum === 0); // status
|
|
|
let soldOut = (origin.storage_sum === 0) || (totalStorageNum === 0); // status
|
|
|
let notForSale = origin.attribute === 2;
|
|
|
|
|
|
// 显示加入购物车链接
|
...
|
...
|
@@ -845,7 +845,7 @@ const _detailDataPkg = (origin, uid, vipLevel, ua) => { |
|
|
_.orderBy(colorGroup);
|
|
|
|
|
|
Object.assign(dest.cartInfo, {
|
|
|
productId: origin.productId,
|
|
|
productId: origin.product_id,
|
|
|
thumbs: thumbImageList,
|
|
|
name: dest.goodsName ? dest.goodsName : '',
|
|
|
price: dest.goodsPrice.previousPrice ? dest.goodsPrice.previousPrice : '',
|
...
|
...
|
@@ -869,11 +869,11 @@ const _detailDataPkg = (origin, uid, vipLevel, ua) => { |
|
|
dest = _procShowStatus(dest, showStatus, isBeginSale);
|
|
|
|
|
|
dest.cartInfo.limitProductCode = origin.limitProductCode;
|
|
|
dest.cartInfo.limitCodeUrl = _getLimitCodeUrl(origin.limitProductCode, origin.productSkn, ua);
|
|
|
dest.cartInfo.limitCodeUrl = _getLimitCodeUrl(origin.limitProductCode, origin.product_skn, ua);
|
|
|
dest.cartInfo.limitProductPay = helpers.urlFormat('/cart/index/orderEnsure');
|
|
|
} else {
|
|
|
dest.cartInfo.addToCartUrl = helpers.urlFormat('/product/buy_' + origin.productId + '_' +
|
|
|
origin.goodsList.goodsId + '.html');
|
|
|
dest.cartInfo.addToCartUrl = helpers.urlFormat('/product/buy_' + origin.product_id + '_' +
|
|
|
origin.goods_list.goods_id + '.html');
|
|
|
}
|
|
|
} else if (notForSale) {
|
|
|
dest.cartInfo.notForSale = true;
|
...
|
...
|
@@ -883,14 +883,14 @@ const _detailDataPkg = (origin, uid, vipLevel, ua) => { |
|
|
|
|
|
// 是否收藏
|
|
|
dest.isCollect = false;
|
|
|
if (origin.isCollect === 'Y') {
|
|
|
if (origin.is_collect === 'Y') {
|
|
|
dest.isCollect = true;
|
|
|
dest.cartInfo.isCollect = true;
|
|
|
}
|
|
|
|
|
|
// 底部简介URL链接
|
|
|
dest.introUrl = '/product/detail/intro/' + origin.productSkn;
|
|
|
dest.id = origin.productId;
|
|
|
dest.introUrl = '/product/detail/intro/' + origin.product_skn;
|
|
|
dest.id = origin.product_id;
|
|
|
|
|
|
// 虚拟商品(门票)
|
|
|
if (origin.attribute * 1 === 3) {
|
...
|
...
|
@@ -898,7 +898,7 @@ const _detailDataPkg = (origin, uid, vipLevel, ua) => { |
|
|
dest.ticketsConfirm = helpers.urlFormat('/cart/index/ticketsConfirm');
|
|
|
|
|
|
// 展览票
|
|
|
if (origin.productSkn * 1 === SINGLE_TICKETS_SKN) {
|
|
|
if (origin.product_skn * 1 === SINGLE_TICKETS_SKN) {
|
|
|
dest.single = true;
|
|
|
} else {
|
|
|
// 套票
|
...
|
...
|
@@ -1000,19 +1000,19 @@ let getProductData = (data) => { |
|
|
|
|
|
return api.get('', params, {
|
|
|
code: 200
|
|
|
}).then(global.yoho.camelCase).then(result => {
|
|
|
}).then(result => {
|
|
|
if (result.code === 500 || !result.data) {
|
|
|
return {};
|
|
|
}
|
|
|
result = result.data;
|
|
|
return Promise.all([
|
|
|
_getShopsInfo(result.brandInfo.brandId),
|
|
|
_getPromotionInfo(result.productSkn),
|
|
|
_getShopsInfo(result.brand_info.brand_id),
|
|
|
_getPromotionInfo(result.product_skn),
|
|
|
comment.getCommentInfo({
|
|
|
productId: result.productId
|
|
|
productId: result.product_id
|
|
|
}),
|
|
|
_getCommonConsult(),
|
|
|
comment.getConsults(result.productId, 1, 2)
|
|
|
comment.getConsults(result.product_id, 1, 2)
|
|
|
]).then((info) => {
|
|
|
result.promotionBoList = info[1];
|
|
|
finalResult = _detailDataPkg(result, data.uid, data.vipLevel, data.ua);
|
...
|
...
|
|