...
|
...
|
@@ -138,6 +138,426 @@ const _getLimitCodeUrl = (productCode, skn, ua) => { |
|
|
* @param origin Object 原始数据
|
|
|
* @return dest Object 格式化数据
|
|
|
*/
|
|
|
// 老接口h5的代码
|
|
|
// const _detailDataPkg = (origin, uid, vipLevel, ua) => {
|
|
|
// let dest = {}, // 结果输出
|
|
|
// thumbImageList = [],
|
|
|
// colorGroup = {},
|
|
|
// sizeGroup = [],
|
|
|
// totalStorageNum = 0;
|
|
|
|
|
|
// // 商品名称
|
|
|
// if (origin.productName === null || typeof origin.productName === 'undefined') {
|
|
|
// return dest;
|
|
|
// }
|
|
|
|
|
|
// dest.goodsName = origin.productName;
|
|
|
|
|
|
// // 是否是虚拟商品
|
|
|
// dest.virtualGoods = origin.attribute * 1 === 3 ? true : false;
|
|
|
|
|
|
// // 用户未登录时
|
|
|
// if (!uid) {
|
|
|
// let params = {};
|
|
|
|
|
|
// params.refer = helpers.urlFormat('/product/show_' + origin.erpProductId + '.html');
|
|
|
// dest.loginUrl = helpers.urlFormat('/signin.html', params);
|
|
|
// }
|
|
|
|
|
|
// // 商品促销短语
|
|
|
// if (origin.salesPhrase) {
|
|
|
// dest.goodsSubtitle = origin.salesPhrase;
|
|
|
// }
|
|
|
|
|
|
// // 促销信息 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
|
|
|
// };
|
|
|
// }
|
|
|
// }
|
|
|
|
|
|
// // 商品标签
|
|
|
// if (origin.productTagBoList) {
|
|
|
// let productTags = {};
|
|
|
|
|
|
// _.forEach(origin.productTagBoList, function(value) {
|
|
|
// switch (value.tagLabel) {
|
|
|
// case 'is_soon_sold_out':
|
|
|
// productTags.is_soon_sold_out = true;
|
|
|
// break;
|
|
|
// case 'is_new':
|
|
|
// productTags.is_new = true;
|
|
|
// break;
|
|
|
// case 'is_discount':
|
|
|
// productTags.is_discount = true;
|
|
|
// break;
|
|
|
// case 'is_limited':
|
|
|
// productTags.is_limited = true;
|
|
|
// break;
|
|
|
// case 'is_yohood':
|
|
|
// productTags.is_yohood = true;
|
|
|
// break;
|
|
|
// case 'is_advance':
|
|
|
// productTags.is_advance = true;
|
|
|
// break;
|
|
|
// default:
|
|
|
// break;
|
|
|
// }
|
|
|
// });
|
|
|
|
|
|
// dest.tags = productTags;
|
|
|
// }
|
|
|
|
|
|
// // 商品价格
|
|
|
// if (origin.productPriceBo) {
|
|
|
// let originPrice = origin.productPriceBo;
|
|
|
// let goodsPrice = {
|
|
|
// currentPrice: originPrice.formatSalesPrice
|
|
|
// };
|
|
|
|
|
|
// if (originPrice.formatMarketPrice !== originPrice.formatSalesPrice) {
|
|
|
// goodsPrice.previousPrice = originPrice.formatMarketPrice;
|
|
|
// }
|
|
|
|
|
|
// dest.goodsPrice = goodsPrice;
|
|
|
|
|
|
// // 商品返回 有货币
|
|
|
// if (originPrice.yohoCoinNum) {
|
|
|
// dest.commodityReturn = originPrice.yohoCoinNum;
|
|
|
// }
|
|
|
// }
|
|
|
|
|
|
// // VIP 商品价格
|
|
|
// if (origin.productPriceBo.vipPrices) {
|
|
|
// let vipList = [];
|
|
|
|
|
|
// _.forEach(origin.productPriceBo.vipPrices, function(value) {
|
|
|
// vipList.push({
|
|
|
// level: value.vipLevel,
|
|
|
// text: value.vipPrice,
|
|
|
// currentLevel: (value.vipLevel === vipLevel)
|
|
|
// });
|
|
|
// });
|
|
|
|
|
|
// if (vipList.length) {
|
|
|
// dest.vipLevel = {
|
|
|
// list: vipList
|
|
|
// };
|
|
|
// }
|
|
|
|
|
|
// }
|
|
|
|
|
|
// // 上市期
|
|
|
// if (origin.expectArrivalTime) {
|
|
|
// dest.periodOfMarket = `${origin.expectArrivalTime}月`;
|
|
|
// }
|
|
|
|
|
|
// // 商品咨询
|
|
|
// dest.feedbacks = {
|
|
|
// consults: [],
|
|
|
// consultsNum: 0
|
|
|
// };
|
|
|
|
|
|
// let consultParams = {
|
|
|
// product_id: origin.id
|
|
|
// };
|
|
|
|
|
|
// if (_.has(dest, 'feedbacks.consultsNum')) {
|
|
|
// consultParams.total = dest.feedbacks.consultsNum;
|
|
|
// dest.feedbacks.consultsUrl = helpers.urlFormat('/product/detail/consults', consultParams);
|
|
|
// } else {
|
|
|
// dest.feedbacks.consultsUrl = helpers.urlFormat('/product/detail/consultform', consultParams);
|
|
|
// }
|
|
|
|
|
|
|
|
|
// // 商品评价
|
|
|
// dest.feedbacks.commentsNum = 0;
|
|
|
// if (origin.commentBoWrapper) {
|
|
|
// dest.feedbacks.commentsNum = origin.commentBoWrapper.commentTotal;
|
|
|
|
|
|
// let commentList = [];
|
|
|
|
|
|
// _.forEach(origin.commentBoWrapper.commentBoList, function(value) {
|
|
|
// commentList.push({
|
|
|
// userName: value.nickName,
|
|
|
// desc: `${value.colorName}/${value.sizeName}`,
|
|
|
// content: value.content ? value.content : '',
|
|
|
// time: value.createTime
|
|
|
// });
|
|
|
// });
|
|
|
|
|
|
// dest.feedbacks.comments = commentList;
|
|
|
|
|
|
// dest.feedbacks.commentsUrl = helpers.urlFormat('/product/detail/comments', {
|
|
|
// product_id: origin.id,
|
|
|
// total: dest.feedbacks.commentsNum
|
|
|
// });
|
|
|
// }
|
|
|
|
|
|
// // 品牌信息
|
|
|
// if (origin.brand) {
|
|
|
// let extra = `?productSkn=${origin.erpProductId}&brandId=${origin.brand.id}`;
|
|
|
|
|
|
// dest.preferenceUrl = `/product/detail/preference${extra}`;
|
|
|
// }
|
|
|
|
|
|
// dest.productSkn = origin.erpProductId;
|
|
|
|
|
|
// // 商品信息
|
|
|
// if (origin.goodsList) {
|
|
|
// let goodsGroup = [],
|
|
|
// sizeName = '',
|
|
|
// colorList = [],
|
|
|
// sizeList = {},
|
|
|
// allSizeList = {},
|
|
|
// colorStorageGroup = {},
|
|
|
// colorStorageNum = 0;
|
|
|
|
|
|
// _.forEach(origin.goodsList, function(value) {
|
|
|
// if (value.status === 0) {
|
|
|
// return;
|
|
|
// }
|
|
|
|
|
|
// colorStorageNum = 0;
|
|
|
|
|
|
// // 商品分组
|
|
|
// if (value.goodsImagesList) {
|
|
|
// _.forEach(value.goodsImagesList, function(good) {
|
|
|
// goodsGroup.push({
|
|
|
// goodsId: good.goodsId,
|
|
|
// img: good.imageUrl
|
|
|
// });
|
|
|
// });
|
|
|
// }
|
|
|
|
|
|
// // 商品的尺码列表
|
|
|
// colorStorageGroup[value.productSkc] = {};
|
|
|
// if (value.goodsSizeBoList) {
|
|
|
// sizeList[value.productSkc] = [];
|
|
|
// _.forEach(value.goodsSizeBoList, function(size) {
|
|
|
// sizeList[value.productSkc].push({
|
|
|
// id: size.id,
|
|
|
// skuId: size.goodsSizeSkuId,
|
|
|
// goodsId: size.goodsId,
|
|
|
// colorId: size.colorId,
|
|
|
// name: size.sizeName,
|
|
|
// sizeNum: size.goodsSizeStorageNum
|
|
|
// });
|
|
|
|
|
|
// sizeName = size.sizeName;
|
|
|
|
|
|
// // 所有尺码列表,赋值用于前端展示默认尺码的时候
|
|
|
// // 判断出没有库存则显示灰色
|
|
|
// let build = {
|
|
|
// id: size.id,
|
|
|
// storage: size.goodsSizeStorageNum
|
|
|
// };
|
|
|
|
|
|
// 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);
|
|
|
// });
|
|
|
|
|
|
// // 颜色分组
|
|
|
// colorList.push({
|
|
|
// id: value.colorId,
|
|
|
// skcId: value.productSkc,
|
|
|
// name: value.colorName,
|
|
|
// goodsName: value.goodsName,
|
|
|
// colorNum: colorStorageNum
|
|
|
// });
|
|
|
// }
|
|
|
|
|
|
// // 缩略图
|
|
|
// thumbImageList.push({
|
|
|
// img: value.colorImage
|
|
|
// });
|
|
|
|
|
|
// // 商品库存总数
|
|
|
// totalStorageNum += _.toNumber(colorStorageNum);
|
|
|
// });
|
|
|
|
|
|
// // 遍历所有尺码,构建颜色显示数据
|
|
|
// let i = 1;
|
|
|
|
|
|
// sizeGroup[0] = {
|
|
|
// size: []
|
|
|
// };
|
|
|
|
|
|
// _.forEach(allSizeList, (value, key) => {
|
|
|
|
|
|
// // 默认尺码
|
|
|
// sizeGroup[0].size.push({
|
|
|
// name: key,
|
|
|
// sizeNum: _.toNumber(value.storage) > 0 ? true : false,
|
|
|
// id: value.id
|
|
|
// });
|
|
|
|
|
|
// colorGroup[i] = {
|
|
|
// color: []
|
|
|
// };
|
|
|
|
|
|
// // 各个颜色的尺码, 每行显示一个尺码对应的颜色
|
|
|
// _.forEach(colorList, (colorArr) => {
|
|
|
// let tempColorArr = _.cloneDeep(colorArr);
|
|
|
|
|
|
// if (colorStorageGroup[tempColorArr.skcId] &&
|
|
|
// colorStorageGroup[tempColorArr.skcId][key]) {
|
|
|
// tempColorArr.colorNum = colorStorageGroup[tempColorArr.skcId][key];
|
|
|
// } else {
|
|
|
// tempColorArr.colorNum = 0;
|
|
|
// }
|
|
|
// colorGroup[i].color.push(Object.assign({}, tempColorArr));
|
|
|
// });
|
|
|
// colorGroup[i].id = value.id;
|
|
|
|
|
|
// ++i;
|
|
|
// });
|
|
|
|
|
|
// colorGroup[0] = {
|
|
|
// color: []
|
|
|
// };
|
|
|
|
|
|
// // 遍历所有颜色, 构建尺码显示数据
|
|
|
// i = 1;
|
|
|
// _.forEach(colorList, function(value) {
|
|
|
// // 各个尺码的颜色, 每行显示一个颜色的对应尺码
|
|
|
// sizeGroup[i] = {
|
|
|
// size: sizeList[value.skcId],
|
|
|
// colorId: value.skcId
|
|
|
// };
|
|
|
|
|
|
// // 默认颜色
|
|
|
// colorGroup[0].color.push(value);
|
|
|
// ++i;
|
|
|
// });
|
|
|
|
|
|
|
|
|
// // 商品图:多个
|
|
|
// if (goodsGroup.length > 1) {
|
|
|
// let bannerList = [];
|
|
|
|
|
|
// _.forEach(goodsGroup, function(value) {
|
|
|
// bannerList.push({
|
|
|
// img: value.img
|
|
|
// });
|
|
|
// });
|
|
|
|
|
|
// dest.bannerTop = {
|
|
|
// list: bannerList
|
|
|
// };
|
|
|
// } else if (goodsGroup[0] !== null && typeof goodsGroup[0] !== 'undefined') {
|
|
|
// dest.bannerTop = {
|
|
|
// img: goodsGroup[0].img
|
|
|
// };
|
|
|
// }
|
|
|
// }
|
|
|
|
|
|
// // 悬浮的购物车信息
|
|
|
// dest.cartInfo = {
|
|
|
// cartUrl: helpers.urlFormat('/cart/index/index'),
|
|
|
// numInCart: 0,
|
|
|
// goodsInstore: origin.storage
|
|
|
// };
|
|
|
|
|
|
// let soldOut = (origin.storage === 0) || (origin.status === 0 || totalStorageNum === 0);
|
|
|
// let notForSale = origin.attribute === 2;
|
|
|
|
|
|
// // 显示加入购物车链接
|
|
|
// if (!soldOut && !notForSale) {
|
|
|
// _.orderBy(colorGroup);
|
|
|
|
|
|
// Object.assign(dest.cartInfo, {
|
|
|
// productId: origin.id,
|
|
|
// thumbs: thumbImageList,
|
|
|
// name: dest.goodsName ? dest.goodsName : '',
|
|
|
// price: dest.goodsPrice.previousPrice ? dest.goodsPrice.previousPrice : '',
|
|
|
// salePrice: dest.goodsPrice.currentPrice ? dest.goodsPrice.currentPrice : '',
|
|
|
// totalNum: totalStorageNum,
|
|
|
// colors: _.toArray(colorGroup),
|
|
|
// sizes: sizeGroup
|
|
|
// });
|
|
|
|
|
|
// // 限购商品
|
|
|
// if (origin.isLimitBuy === 'Y') {
|
|
|
// // 是否开售
|
|
|
// let isBeginSale = (origin.saleStatus !== null && typeof origin.saleStatus !== 'undefined' &&
|
|
|
// origin.saleStatus === 1);
|
|
|
|
|
|
// // 限购商品有关的展示状态
|
|
|
// let showStatus = 1;
|
|
|
|
|
|
// if (origin.showStatus !== null && typeof origin.showStatus !== 'undefined') {
|
|
|
// showStatus = parseInt(origin.showStatus, 10);
|
|
|
// }
|
|
|
|
|
|
// // 处理限购商品有关的按钮状态
|
|
|
// dest = _procShowStatus(dest, showStatus, isBeginSale);
|
|
|
|
|
|
// dest.cartInfo.limitProductCode = origin.limitProductCode;
|
|
|
// dest.cartInfo.limitCodeUrl = _getLimitCodeUrl(origin.limitProductCode, origin.erpProductId, ua);
|
|
|
// dest.cartInfo.limitProductPay = helpers.urlFormat('/cart/index/orderEnsure');
|
|
|
// } else {
|
|
|
// dest.cartInfo.addToCartUrl = helpers.urlFormat('/product/buy_' + origin.id + '_' +
|
|
|
// origin.goodsList.id + '.html');
|
|
|
// }
|
|
|
// } else if (notForSale) {
|
|
|
// dest.cartInfo.notForSale = true;
|
|
|
// } else if (soldOut) {
|
|
|
// dest.cartInfo.soldOut = true;
|
|
|
// }
|
|
|
|
|
|
// // 是否收藏
|
|
|
// dest.isCollect = false;
|
|
|
// if (origin.isCollect !== null && typeof origin.isCollect !== 'undefined' && origin.isCollect === 'Y') {
|
|
|
// dest.isCollect = true;
|
|
|
// dest.cartInfo.isCollect = true;
|
|
|
// }
|
|
|
|
|
|
// // 底部简介URL链接
|
|
|
// dest.introUrl = '/product/detail/intro/' + origin.erpProductId;
|
|
|
// dest.id = origin.id;
|
|
|
|
|
|
// // 虚拟商品(门票)
|
|
|
// if (origin.attribute * 1 === 3) {
|
|
|
// dest.tickets = true;
|
|
|
// dest.ticketsConfirm = helpers.urlFormat('/cart/index/ticketsConfirm');
|
|
|
|
|
|
// // 展览票
|
|
|
// if (origin.erpProductId * 1 === SINGLE_TICKETS_SKN) {
|
|
|
// dest.single = true;
|
|
|
// } else {
|
|
|
// // 套票
|
|
|
// dest.package = true;
|
|
|
// }
|
|
|
|
|
|
// // 购票限制
|
|
|
// dest.cartInfo.limit = 4;
|
|
|
|
|
|
// // 清空活动
|
|
|
// dest.goodsDiscount = [];
|
|
|
|
|
|
// // 来自登录页,自动弹出选择框
|
|
|
// // if (isset($_GET['product_type']) && $_GET['product_type'] == 'ticket') {
|
|
|
// // $result['showPannel'] = true;
|
|
|
// // }
|
|
|
// }
|
|
|
|
|
|
// return dest;
|
|
|
// };
|
|
|
const _detailDataPkg = (origin, uid, vipLevel, ua) => {
|
|
|
let dest = {}, // 结果输出
|
|
|
thumbImageList = [],
|
...
|
...
|
@@ -145,28 +565,26 @@ const _detailDataPkg = (origin, uid, vipLevel, ua) => { |
|
|
sizeGroup = [],
|
|
|
totalStorageNum = 0;
|
|
|
|
|
|
// 商品名称
|
|
|
if (origin.productName === null || typeof origin.productName === 'undefined') {
|
|
|
// 商品名称
|
|
|
if (!origin.productName) {
|
|
|
dest.feedbacks = {};
|
|
|
return dest;
|
|
|
}
|
|
|
|
|
|
dest.goodsName = origin.productName;
|
|
|
|
|
|
// 是否是虚拟商品
|
|
|
dest.virtualGoods = origin.attribute * 1 === 3 ? true : false;
|
|
|
// 是否是虚拟商品
|
|
|
dest.virtualGoods = (origin.attribute * 1 === 3);
|
|
|
|
|
|
// 用户未登录时
|
|
|
if (!uid) {
|
|
|
let params = {};
|
|
|
|
|
|
params.refer = helpers.urlFormat('/product/show_' + origin.erpProductId + '.html');
|
|
|
dest.loginUrl = helpers.urlFormat('/signin.html', params);
|
|
|
dest.loginUrl = helpers.urlFormat('/signin.html', {
|
|
|
refer: helpers.urlFormat('/product/show_' + origin.productSkn + '.html')
|
|
|
});
|
|
|
}
|
|
|
|
|
|
// 商品促销短语
|
|
|
if (origin.salesPhrase) {
|
|
|
dest.goodsSubtitle = origin.salesPhrase;
|
|
|
}
|
|
|
// 商品促销短语
|
|
|
origin.salesPhrase && (dest.goodsSubtitle = origin.salesPhrase);
|
|
|
|
|
|
// 促销信息 TODO: 换新接口
|
|
|
if (origin.promotionBoList) {
|
...
|
...
|
@@ -178,94 +596,61 @@ const _detailDataPkg = (origin, uid, vipLevel, ua) => { |
|
|
});
|
|
|
});
|
|
|
|
|
|
if (discountList.length) {
|
|
|
dest.goodsDiscount = {
|
|
|
list: discountList
|
|
|
};
|
|
|
}
|
|
|
discountList.length && (dest.goodsDiscount = {
|
|
|
list: discountList
|
|
|
});
|
|
|
}
|
|
|
|
|
|
// 商品标签
|
|
|
if (origin.productTagBoList) {
|
|
|
// 商品标签
|
|
|
if (origin.tags) {
|
|
|
let productTags = {};
|
|
|
|
|
|
_.forEach(origin.productTagBoList, function(value) {
|
|
|
switch (value.tagLabel) {
|
|
|
case 'is_soon_sold_out':
|
|
|
productTags.is_soon_sold_out = true;
|
|
|
break;
|
|
|
case 'is_new':
|
|
|
productTags.is_new = true;
|
|
|
break;
|
|
|
case 'is_discount':
|
|
|
productTags.is_discount = true;
|
|
|
break;
|
|
|
case 'is_limited':
|
|
|
productTags.is_limited = true;
|
|
|
break;
|
|
|
case 'is_yohood':
|
|
|
productTags.is_yohood = true;
|
|
|
break;
|
|
|
case 'is_advance':
|
|
|
productTags.is_advance = true;
|
|
|
break;
|
|
|
default:
|
|
|
break;
|
|
|
}
|
|
|
_.forEach(origin.tags, function(value) {
|
|
|
productTags[value] = true;
|
|
|
});
|
|
|
|
|
|
dest.tags = productTags;
|
|
|
}
|
|
|
|
|
|
// 商品价格
|
|
|
if (origin.productPriceBo) {
|
|
|
let originPrice = origin.productPriceBo;
|
|
|
let goodsPrice = {
|
|
|
currentPrice: originPrice.formatSalesPrice,
|
|
|
studentPrice: originPrice.studentPrice
|
|
|
};
|
|
|
|
|
|
if (originPrice.formatMarketPrice !== originPrice.formatSalesPrice) {
|
|
|
goodsPrice.previousPrice = originPrice.formatMarketPrice;
|
|
|
}
|
|
|
dest.goodsPrice = goodsPrice;
|
|
|
// 商品价格
|
|
|
let goodsPrice = {
|
|
|
currentPrice: origin.formatSalesPrice === '0' ? origin.formatMarketPrice : origin.formatSalesPrice
|
|
|
};
|
|
|
|
|
|
// 商品返回 有货币
|
|
|
if (origin.formatSalesPrice !== '0' && origin.formatMarketPrice !== origin.formatSalesPrice) {
|
|
|
goodsPrice.previousPrice = origin.formatMarketPrice;
|
|
|
}
|
|
|
|
|
|
if (originPrice.yohoCoinNum) {
|
|
|
dest.commodityReturn = originPrice.yohoCoinNum;
|
|
|
}
|
|
|
dest.goodsPrice = goodsPrice;
|
|
|
|
|
|
// 学生有货币
|
|
|
if (originPrice.studentCoinNum) {
|
|
|
dest.studentCoinNum = originPrice.studentCoinNum;
|
|
|
}
|
|
|
}
|
|
|
// 商品返回 YOHO 币
|
|
|
origin.yohoCoinNum && (dest.commodityReturn = origin.yohoCoinNum);
|
|
|
|
|
|
// VIP 商品价格
|
|
|
if (origin.productPriceBo.vipPrices) {
|
|
|
// VIP 商品价格
|
|
|
if (origin.vip) {
|
|
|
let vipList = [];
|
|
|
let levelList = {
|
|
|
银卡: 1,
|
|
|
金卡: 2,
|
|
|
白金: 3
|
|
|
};
|
|
|
|
|
|
_.forEach(origin.productPriceBo.vipPrices, function(value) {
|
|
|
_.forEach(origin.vip, function(value) {
|
|
|
vipList.push({
|
|
|
level: value.vipLevel,
|
|
|
text: value.vipPrice,
|
|
|
level: levelList[value.caption],
|
|
|
text: value.price,
|
|
|
currentLevel: (value.vipLevel === vipLevel)
|
|
|
});
|
|
|
});
|
|
|
|
|
|
if (vipList.length) {
|
|
|
dest.vipLevel = {
|
|
|
list: vipList
|
|
|
};
|
|
|
}
|
|
|
vipList.length && (dest.vipLevel = {
|
|
|
list: vipList
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
// 上市期
|
|
|
if (origin.expectArrivalTime) {
|
|
|
dest.periodOfMarket = `${origin.expectArrivalTime}月`;
|
|
|
}
|
|
|
// 上市期
|
|
|
origin.expectArrivalTime && (dest.periodOfMarket = `${origin.expectArrivalTime}月`);
|
|
|
|
|
|
// 商品咨询
|
|
|
dest.feedbacks = {
|
...
|
...
|
@@ -274,7 +659,7 @@ const _detailDataPkg = (origin, uid, vipLevel, ua) => { |
|
|
};
|
|
|
|
|
|
let consultParams = {
|
|
|
product_id: origin.id
|
|
|
product_id: origin.productId
|
|
|
};
|
|
|
|
|
|
if (_.has(dest, 'feedbacks.consultsNum')) {
|
...
|
...
|
@@ -284,39 +669,19 @@ const _detailDataPkg = (origin, uid, vipLevel, ua) => { |
|
|
dest.feedbacks.consultsUrl = helpers.urlFormat('/product/detail/consultform', consultParams);
|
|
|
}
|
|
|
|
|
|
|
|
|
// 商品评价
|
|
|
dest.feedbacks.commentsNum = 0;
|
|
|
if (origin.commentBoWrapper) {
|
|
|
dest.feedbacks.commentsNum = origin.commentBoWrapper.commentTotal;
|
|
|
|
|
|
let commentList = [];
|
|
|
|
|
|
_.forEach(origin.commentBoWrapper.commentBoList, function(value) {
|
|
|
commentList.push({
|
|
|
userName: value.nickName,
|
|
|
desc: `${value.colorName}/${value.sizeName}`,
|
|
|
content: value.content ? value.content : '',
|
|
|
time: value.createTime
|
|
|
});
|
|
|
});
|
|
|
|
|
|
dest.feedbacks.comments = commentList;
|
|
|
|
|
|
dest.feedbacks.commentsUrl = helpers.urlFormat('/product/detail/comments', {
|
|
|
product_id: origin.id,
|
|
|
total: dest.feedbacks.commentsNum
|
|
|
});
|
|
|
}
|
|
|
// 商品评价
|
|
|
dest.feedbacks.commentsUrl = helpers.urlFormat('/product/detail/comments', {
|
|
|
product_id: origin.productId,
|
|
|
});
|
|
|
|
|
|
// 品牌信息
|
|
|
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) {
|
...
|
...
|
@@ -335,11 +700,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
|
|
|
});
|
|
|
});
|
...
|
...
|
@@ -347,16 +712,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;
|
...
|
...
|
@@ -364,16 +729,14 @@ 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);
|
|
|
typeof allSizeList[sizeName] === 'undefined') ? build : allSizeList[sizeName];
|
|
|
colorStorageNum += parseInt(size.storageNumber, 10);
|
|
|
colorStorageGroup[value.productSkc][sizeName] = parseInt(size.storageNumber, 10);
|
|
|
});
|
|
|
|
|
|
// 颜色分组
|
...
|
...
|
@@ -381,7 +744,6 @@ const _detailDataPkg = (origin, uid, vipLevel, ua) => { |
|
|
id: value.colorId,
|
|
|
skcId: value.productSkc,
|
|
|
name: value.colorName,
|
|
|
goodsName: value.goodsName,
|
|
|
colorNum: colorStorageNum
|
|
|
});
|
|
|
}
|
...
|
...
|
@@ -401,10 +763,8 @@ const _detailDataPkg = (origin, uid, vipLevel, ua) => { |
|
|
sizeGroup[0] = {
|
|
|
size: []
|
|
|
};
|
|
|
|
|
|
_.forEach(allSizeList, (value, key) => {
|
|
|
|
|
|
// 默认尺码
|
|
|
// 默认尺码
|
|
|
sizeGroup[0].size.push({
|
|
|
name: key,
|
|
|
sizeNum: _.toNumber(value.storage) > 0 ? true : false,
|
...
|
...
|
@@ -464,7 +824,7 @@ const _detailDataPkg = (origin, uid, vipLevel, ua) => { |
|
|
dest.bannerTop = {
|
|
|
list: bannerList
|
|
|
};
|
|
|
} else if (goodsGroup[0] !== null && typeof goodsGroup[0] !== 'undefined') {
|
|
|
} else if (goodsGroup[0]) {
|
|
|
dest.bannerTop = {
|
|
|
img: goodsGroup[0].img
|
|
|
};
|
...
|
...
|
@@ -475,10 +835,9 @@ 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) || (totalStorageNum === 0); // status
|
|
|
let notForSale = origin.attribute === 2;
|
|
|
|
|
|
// 显示加入购物车链接
|
...
|
...
|
@@ -486,7 +845,7 @@ const _detailDataPkg = (origin, uid, vipLevel, ua) => { |
|
|
_.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 : '',
|
...
|
...
|
@@ -496,28 +855,25 @@ const _detailDataPkg = (origin, uid, vipLevel, ua) => { |
|
|
sizes: sizeGroup
|
|
|
});
|
|
|
|
|
|
// 限购商品
|
|
|
if (origin.isLimitBuy === 'Y') {
|
|
|
// 是否开售
|
|
|
let isBeginSale = (origin.saleStatus !== null && typeof origin.saleStatus !== 'undefined' &&
|
|
|
origin.saleStatus === 1);
|
|
|
// 限购商品
|
|
|
if (origin.isLimitBuy) {
|
|
|
// 是否开售
|
|
|
let isBeginSale = (origin.saleStatus === 1);
|
|
|
|
|
|
// 限购商品有关的展示状态
|
|
|
let showStatus = 1;
|
|
|
|
|
|
if (origin.showStatus !== null && typeof origin.showStatus !== 'undefined') {
|
|
|
showStatus = parseInt(origin.showStatus, 10);
|
|
|
}
|
|
|
origin.showStatus && (showStatus = parseInt(origin.showStatus, 10));
|
|
|
|
|
|
// 处理限购商品有关的按钮状态
|
|
|
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,22 +883,22 @@ const _detailDataPkg = (origin, uid, vipLevel, ua) => { |
|
|
|
|
|
// 是否收藏
|
|
|
dest.isCollect = false;
|
|
|
if (origin.isCollect !== null && typeof origin.isCollect !== 'undefined' && origin.isCollect === 'Y') {
|
|
|
if (origin.isCollect === 'Y') {
|
|
|
dest.isCollect = true;
|
|
|
dest.cartInfo.isCollect = true;
|
|
|
}
|
|
|
|
|
|
// 底部简介URL链接
|
|
|
dest.introUrl = '/product/detail/intro/' + origin.erpProductId;
|
|
|
dest.id = origin.id;
|
|
|
// 底部简介URL链接
|
|
|
dest.introUrl = '/product/detail/intro/' + origin.productSkn;
|
|
|
dest.id = origin.productId;
|
|
|
|
|
|
// 虚拟商品(门票)
|
|
|
if (origin.attribute * 1 === 3) {
|
|
|
dest.tickets = true;
|
|
|
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 {
|
|
|
// 套票
|
...
|
...
|
@@ -619,12 +975,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, {
|
...
|
...
|
@@ -643,22 +999,22 @@ let getProductData = (data) => { |
|
|
params.current_vip_level = data.vipLevel;
|
|
|
|
|
|
return api.get('', params, {
|
|
|
cache: false
|
|
|
}).then(result => {
|
|
|
if (result.code === 500) {
|
|
|
code: 200
|
|
|
}).then(global.yoho.camelCase).then(result => {
|
|
|
if (result.code === 500 || !result.data) {
|
|
|
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];
|
|
|
finalResult.isStudent = data.isStudent;
|
...
|
...
|
@@ -681,7 +1037,6 @@ let getProductData = (data) => { |
|
|
consults: _.take(info[3], 2)
|
|
|
});
|
|
|
}
|
|
|
|
|
|
return finalResult;
|
|
|
});
|
|
|
|
...
|
...
|
|