...
|
...
|
@@ -10,10 +10,9 @@ const library = '../../../library'; |
|
|
const API = require(`${library}/api`).API;
|
|
|
const sign = require(`${library}/sign`);
|
|
|
const _ = require('lodash');
|
|
|
const HELPERS = require(`${library}/helpers`);
|
|
|
const helpers = require(`${library}/helpers`);
|
|
|
|
|
|
var api = new API();
|
|
|
var helpers = new HELPERS();
|
|
|
|
|
|
/**
|
|
|
* 处理品牌关联店铺信息
|
...
|
...
|
@@ -25,10 +24,10 @@ const getShopsInfo = (data) => { |
|
|
|
|
|
_.forEach(data, function(value, key) {
|
|
|
enterStore[key] = {};
|
|
|
enterStore[key].img = helpers.getImageUrl(value.brand_ico, 47, 47);
|
|
|
enterStore[key].img = value.brand_ico;
|
|
|
enterStore[key].storeName = value.brand_name;
|
|
|
|
|
|
if (value.shop_id !== null && value.shop_id !== undefined) {
|
|
|
if (value.shop_id !== null && typeof value.shop_id !== 'undefined') {
|
|
|
let params = {};
|
|
|
|
|
|
params.shop_id = value.shop_id;
|
...
|
...
|
@@ -127,14 +126,14 @@ const detailDataPkg = (origin, uid, vipLevel, ua) => { |
|
|
totalStorageNum = 0;
|
|
|
|
|
|
// 商品名称
|
|
|
if (origin.productName === null || origin.productName === undefined) {
|
|
|
if (origin.productName === null || typeof origin.productName === 'undefined') {
|
|
|
return dest;
|
|
|
}
|
|
|
|
|
|
dest.goodsName = origin.productName;
|
|
|
|
|
|
// 用户未登录时 待处理
|
|
|
if (uid === null || uid === undefined) {
|
|
|
if (uid === null || typeof uid === 'undefined') {
|
|
|
let params = {};
|
|
|
|
|
|
params.refer = helpers.url('/product/show_' + origin.erpProductId + '.html');
|
...
|
...
|
@@ -142,12 +141,12 @@ const detailDataPkg = (origin, uid, vipLevel, ua) => { |
|
|
}
|
|
|
|
|
|
// 商品促销短语
|
|
|
if (origin.salesPhrase !== null && origin.salesPhrase !== undefined) {
|
|
|
if (origin.salesPhrase !== null && typeof origin.salesPhrase !== 'undefined') {
|
|
|
dest.goodsSubtitle = origin.salesPhrase;
|
|
|
}
|
|
|
|
|
|
// 商品标签
|
|
|
if (origin.productTagBoList !== null && origin.productTagBoList !== undefined) {
|
|
|
if (origin.productTagBoList !== null && typeof origin.productTagBoList !== 'undefined') {
|
|
|
_.forEach(origin.productTagBoList, function(value) {
|
|
|
switch (value.tagLabel) {
|
|
|
case 'is_soon_sold_out':
|
...
|
...
|
@@ -177,7 +176,7 @@ const detailDataPkg = (origin, uid, vipLevel, ua) => { |
|
|
// 商品价格
|
|
|
dest.goodsPrice = {};
|
|
|
|
|
|
if (origin.productPriceBo !== null && origin.productPriceBo !== undefined) {
|
|
|
if (origin.productPriceBo !== null && typeof origin.productPriceBo !== 'undefined') {
|
|
|
dest.goodsPrice.currentPrice = origin.productPriceBo.formatSalesPrice;
|
|
|
if (origin.productPriceBo.formatMarketPrice !== origin.productPriceBo.formatSalesPrice) {
|
|
|
dest.goodsPrice.previousPrice = origin.productPriceBo.formatMarketPrice;
|
...
|
...
|
@@ -193,7 +192,7 @@ const detailDataPkg = (origin, uid, vipLevel, ua) => { |
|
|
dest.vipLevel = {};
|
|
|
dest.vipLevel.list = {};
|
|
|
|
|
|
if (origin.productPriceBo.vipPrices !== null && origin.productPriceBo.vipPrices !== undefined) {
|
|
|
if (origin.productPriceBo.vipPrices !== null && typeof origin.productPriceBo.vipPrices !== 'undefined') {
|
|
|
_.forEach(origin.productPriceBo.vipPrices, function(value, key) {
|
|
|
dest.vipLevel.list[key] = {};
|
|
|
dest.vipLevel.list[key].level = value.vipLevel;
|
...
|
...
|
@@ -203,7 +202,7 @@ const detailDataPkg = (origin, uid, vipLevel, ua) => { |
|
|
}
|
|
|
|
|
|
// 上市期
|
|
|
if (origin.expectArrivalTime !== null && origin.expectArrivalTime !== undefined) {
|
|
|
if (origin.expectArrivalTime !== null && typeof origin.expectArrivalTime !== 'undefined') {
|
|
|
dest.periodOfMarket = origin.expectArrivalTime + '月';
|
|
|
}
|
|
|
|
...
|
...
|
@@ -211,7 +210,7 @@ const detailDataPkg = (origin, uid, vipLevel, ua) => { |
|
|
dest.goodsDiscount = {};
|
|
|
dest.goodsDiscount.list = {};
|
|
|
|
|
|
if (origin.promotionBoList !== null && origin.promotionBoList !== undefined) {
|
|
|
if (origin.promotionBoList !== null && typeof origin.promotionBoList !== 'undefined') {
|
|
|
_.forEach(origin.promotionBoList, function(value, key) {
|
|
|
dest.goodsDiscount.list[key] = {};
|
|
|
dest.goodsDiscount.list[key].text = '【' + value.promotionType + '】' +
|
...
|
...
|
@@ -224,7 +223,7 @@ const detailDataPkg = (origin, uid, vipLevel, ua) => { |
|
|
dest.feedbacks.consults = {};
|
|
|
dest.feedbacks.consultsNum = 0;
|
|
|
|
|
|
if (origin.consultBoWrapper !== null && origin.consultBoWrapper !== undefined) {
|
|
|
if (origin.consultBoWrapper !== null && typeof origin.consultBoWrapper !== 'undefined') {
|
|
|
dest.feedbacks.consultsNum = origin.consultBoWrapper.consultTotal;
|
|
|
_.forEach(origin.consultBoWrapper.consultBoList, function(value, key) {
|
|
|
dest.feedbacks.consults[key] = {};
|
...
|
...
|
@@ -251,7 +250,7 @@ const detailDataPkg = (origin, uid, vipLevel, ua) => { |
|
|
|
|
|
// 商品评价
|
|
|
dest.feedbacks.commentsNum = 0;
|
|
|
if (origin.commentBoWrapper !== null && origin.commentBoWrapper !== undefined) {
|
|
|
if (origin.commentBoWrapper !== null && typeof origin.commentBoWrapper !== 'undefined') {
|
|
|
dest.feedbacks.commentsNum = origin.commentBoWrapper.commentTotal;
|
|
|
dest.feedbacks.comments = {};
|
|
|
|
...
|
...
|
@@ -261,7 +260,7 @@ const detailDataPkg = (origin, uid, vipLevel, ua) => { |
|
|
dest.feedbacks.comments[key].desc = value.colorName +
|
|
|
'/' + value.sizeName;
|
|
|
dest.feedbacks.comments[key].content = (value.content !== null &&
|
|
|
value.content !== undefined) ? value.content : '';
|
|
|
typeof value.content !== 'undefined') ? value.content : '';
|
|
|
dest.feedbacks.comments[key].time = value.createTime;
|
|
|
});
|
|
|
|
...
|
...
|
@@ -274,13 +273,7 @@ const detailDataPkg = (origin, uid, vipLevel, ua) => { |
|
|
}
|
|
|
|
|
|
// 品牌信息
|
|
|
if (origin.brand !== null && origin.brand !== undefined) {
|
|
|
|
|
|
// dest.enterStore[0] = {};
|
|
|
// dest.enterStore[0].img =
|
|
|
// helpers.getImageUrl(origin.brand.brandIco, 47, 47);
|
|
|
// dest.enterStore[0].storeName = origin.brand.brandName;
|
|
|
// dest.enterStore[0].url = helpers.url('', null, origin.brand.brandDomain);
|
|
|
if (origin.brand !== null && typeof origin.brand !== 'undefined') {
|
|
|
|
|
|
// 为你优选的链接
|
|
|
let params = {};
|
...
|
...
|
@@ -293,7 +286,7 @@ const detailDataPkg = (origin, uid, vipLevel, ua) => { |
|
|
dest.productSkn = origin.erpProductId;
|
|
|
|
|
|
// 商品信息
|
|
|
if (origin.goodsList !== null && origin.goodsList !== undefined) {
|
|
|
if (origin.goodsList !== null && typeof origin.goodsList !== 'undefined') {
|
|
|
let goodsGroup = {},
|
|
|
sizeName = '',
|
|
|
colorList = {},
|
...
|
...
|
@@ -310,7 +303,7 @@ const detailDataPkg = (origin, uid, vipLevel, ua) => { |
|
|
colorStorageNum = 0;
|
|
|
|
|
|
// 商品分组
|
|
|
if (value.goodsImagesList !== null && value.goodsImagesList !== undefined) {
|
|
|
if (value.goodsImagesList !== null && typeof value.goodsImagesList !== 'undefined') {
|
|
|
_.forEach(value.goodsImagesList, function(good, keyForGood) {
|
|
|
goodsGroup[keyForGood] = {};
|
|
|
goodsGroup[keyForGood].goodsId = good.goodsId;
|
...
|
...
|
@@ -320,7 +313,7 @@ const detailDataPkg = (origin, uid, vipLevel, ua) => { |
|
|
|
|
|
// 商品的尺码列表
|
|
|
colorStorageGroup[value.productSkc] = {};
|
|
|
if (value.goodsSizeBoList !== null && value.goodsSizeBoList !== undefined) {
|
|
|
if (value.goodsSizeBoList !== null && typeof value.goodsSizeBoList !== 'undefined') {
|
|
|
|
|
|
_.forEach(value.goodsSizeBoList, function(size, keyForSize) {
|
|
|
sizeList[value.productSkc] = {};
|
...
|
...
|
@@ -341,11 +334,11 @@ const detailDataPkg = (origin, uid, vipLevel, ua) => { |
|
|
build.storage = size.goodsSizeStorageNum;
|
|
|
build.id = size.id;
|
|
|
allSizeList[sizeName] = (allSizeList[sizeName] === null ||
|
|
|
allSizeList[sizeName] === undefined) ? build :
|
|
|
typeof allSizeList[sizeName] === 'undefined') ? build :
|
|
|
allSizeList[sizeName];
|
|
|
|
|
|
colorStorageNum += parseInt(size.goodsSizeStorageNum);
|
|
|
colorStorageGroup[value.productSkc][sizeName] = parseInt(size.goodsSizeStorageNum);
|
|
|
colorStorageNum += parseInt(size.goodsSizeStorageNum, 10);
|
|
|
colorStorageGroup[value.productSkc][sizeName] = parseInt(size.goodsSizeStorageNum, 10);
|
|
|
});
|
|
|
|
|
|
// 颜色分组
|
...
|
...
|
@@ -360,7 +353,7 @@ const detailDataPkg = (origin, uid, vipLevel, ua) => { |
|
|
// 缩略图
|
|
|
let params = {};
|
|
|
|
|
|
params.img = helpers.getImageUrl(value.colorImage, 60, 60);
|
|
|
params.img = value.colorImage;
|
|
|
thumbImageList[key] = params;
|
|
|
|
|
|
// 商品库存总数
|
...
|
...
|
@@ -378,7 +371,8 @@ const detailDataPkg = (origin, uid, vipLevel, ua) => { |
|
|
sizeGroup[0].size = {};
|
|
|
sizeGroup[0].size[key] = {};
|
|
|
sizeGroup[0].size[key].name = sizeName;
|
|
|
sizeGroup[0].size[key].sizeNum = (value.storage === undefined || value.storage === null) ? false : true;
|
|
|
sizeGroup[0].size[key].sizeNum = (typeof value.storage === 'undefined' ||
|
|
|
value.storage === null) ? false : true;
|
|
|
sizeGroup[0].size[key].id = value.id;
|
|
|
|
|
|
// 各个颜色的尺码, 每行显示一个尺码对应的颜色
|
...
|
...
|
@@ -388,7 +382,7 @@ const detailDataPkg = (origin, uid, vipLevel, ua) => { |
|
|
colorGroup[i].color[keyForColorArr] = {};
|
|
|
colorGroup[i].color[keyForColorArr].colorNum =
|
|
|
(colorStorageGroup[colorArr.skcId][sizeName] !== null &&
|
|
|
colorStorageGroup[colorArr.skcId][sizeName] !== undefined) ?
|
|
|
typeof colorStorageGroup[colorArr.skcId][sizeName] !== 'undefined') ?
|
|
|
colorStorageGroup[colorArr.skcId][sizeName] : 0;
|
|
|
});
|
|
|
colorGroup[i].id = value.id;
|
...
|
...
|
@@ -414,19 +408,19 @@ const detailDataPkg = (origin, uid, vipLevel, ua) => { |
|
|
});
|
|
|
|
|
|
// 商品图:多个
|
|
|
if (goodsGroup[1] !== null && goodsGroup[1] !== undefined) {
|
|
|
if (goodsGroup[1] !== null && typeof goodsGroup[1] !== 'undefined') {
|
|
|
_.forEach(goodsGroup, function(value, key) {
|
|
|
dest.bannerTop = {};
|
|
|
|
|
|
dest.bannerTop.list = {};
|
|
|
let params = {};
|
|
|
|
|
|
params.img = helpers.getImageUrl(value.img, 450, 600);
|
|
|
params.img = value.img;
|
|
|
dest.bannerTop.list[key] = params;
|
|
|
});
|
|
|
} else if (goodsGroup[0] !== null && goodsGroup[0] !== undefined) {
|
|
|
} else if (goodsGroup[0] !== null && typeof goodsGroup[0] !== 'undefined') {
|
|
|
dest.bannerTop = {};
|
|
|
dest.bannerTop.img = helpers.getImageUrl(goodsGroup[0].img, 450, 600);
|
|
|
dest.bannerTop.img = goodsGroup[0].img;
|
|
|
}
|
|
|
}
|
|
|
|
...
|
...
|
@@ -446,11 +440,11 @@ const detailDataPkg = (origin, uid, vipLevel, ua) => { |
|
|
dest.cartInfo = {};
|
|
|
dest.cartInfo.productId = origin.id;
|
|
|
dest.cartInfo.thumbs = thumbImageList;
|
|
|
dest.cartInfo.name = (dest.goodsName !== null && dest.goodsName !== undefined) ? dest.goodsName : '';
|
|
|
dest.cartInfo.name = (dest.goodsName !== null && typeof dest.goodsName !== 'undefined') ? dest.goodsName : '';
|
|
|
dest.cartInfo.price = (dest.goodsPrice.previousPrice !== null &&
|
|
|
dest.goodsPrice.previousPrice !== undefined) ? dest.goodsPrice.previousPrice : '';
|
|
|
typeof dest.goodsPrice.previousPrice !== 'undefined') ? dest.goodsPrice.previousPrice : '';
|
|
|
dest.cartInfo.salePrice = (dest.goodsPrice.currentPrice !== null &&
|
|
|
dest.goodsPrice.currentPrice !== undefined) ? dest.goodsPrice.currentPrice : '';
|
|
|
typeof dest.goodsPrice.currentPrice !== 'undefined') ? dest.goodsPrice.currentPrice : '';
|
|
|
dest.cartInfo.totalNum = totalStorageNum;
|
|
|
dest.cartInfo.colors = colorGroup;
|
|
|
dest.cartInfo.sizes = sizeGroup;
|
...
|
...
|
@@ -458,14 +452,14 @@ const detailDataPkg = (origin, uid, vipLevel, ua) => { |
|
|
// 限购商品
|
|
|
if (origin.isLimitBuy === 'Y') {
|
|
|
// 是否开售
|
|
|
let isBeginSale = (origin.saleStatus !== null && origin.saleStatus !== undefined &&
|
|
|
let isBeginSale = (origin.saleStatus !== null && typeof origin.saleStatus !== 'undefined' &&
|
|
|
origin.saleStatus === 1);
|
|
|
|
|
|
// 限购商品有关的展示状态
|
|
|
let showStatus = 1;
|
|
|
|
|
|
if (origin.showStatus !== null && origin.showStatus !== undefined) {
|
|
|
showStatus = parseInt(origin.showStatus);
|
|
|
if (origin.showStatus !== null && typeof origin.showStatus !== 'undefined') {
|
|
|
showStatus = parseInt(origin.showStatus, 10);
|
|
|
}
|
|
|
|
|
|
// 处理限购商品有关的按钮状态
|
...
|
...
|
@@ -486,7 +480,7 @@ const detailDataPkg = (origin, uid, vipLevel, ua) => { |
|
|
// 是否收藏
|
|
|
|
|
|
dest.isCollect = false;
|
|
|
if (origin.isCollect !== null && origin.isCollect !== undefined && origin.isCollect === 'Y') {
|
|
|
if (origin.isCollect !== null && typeof origin.isCollect !== 'undefined' && origin.isCollect === 'Y') {
|
|
|
dest.isCollect = true;
|
|
|
}
|
|
|
|
...
|
...
|
|