Authored by zzzzzzz

商品详情

... ... @@ -12,7 +12,7 @@ const comment = require('./consult-comment');
const api = global.yoho.API;
const helpers = global.yoho.helpers;
const SINGLE_TICKETS_SKN = 51335912;// 展览票
const SINGLE_TICKETS_SKN = 51335912; // 展览票
/**
* 获取用户数据信息
... ... @@ -163,7 +163,7 @@ const _detailDataPkg = (origin, uid, vipLevel, ua) => {
dest.loginUrl = helpers.urlFormat('/signin.html', params);
}
// 商品促销短语 (app不确定)
// 商品促销短语
if (origin.salesPhrase) {
dest.goodsSubtitle = origin.salesPhrase;
}
... ... @@ -219,10 +219,10 @@ const _detailDataPkg = (origin, uid, vipLevel, ua) => {
// 商品价格
let goodsPrice = {
currentPrice: origin.formatMarketPrice
currentPrice: origin.formatSalesPrice === '0' ? origin.formatMarketPrice : origin.formatSalesPrice
};
if (origin.formatMarketPrice !== origin.formatSalesPrice) {
if (origin.formatSalesPrice !== '0' && origin.formatMarketPrice !== origin.formatSalesPrice) {
goodsPrice.previousPrice = origin.formatMarketPrice;
}
... ... @@ -234,13 +234,18 @@ const _detailDataPkg = (origin, uid, vipLevel, ua) => {
}
// VIP 商品价格
if (origin.vipPrices) {
if (origin.vip) {
let vipList = [];
let levelList = {
银卡: 1,
金卡: 2,
白金: 3
};
_.forEach(origin.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)
});
});
... ... @@ -275,30 +280,10 @@ 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.productId,
total: dest.feedbacks.commentsNum
});
}
dest.feedbacks.commentsUrl = helpers.urlFormat('/product/detail/comments', {
product_id: origin.productId,
});
// 品牌信息
if (origin.brand) {
... ... @@ -325,6 +310,7 @@ const _detailDataPkg = (origin, uid, vipLevel, ua) => {
}
colorStorageNum = 0;
// 商品分组
if (value.imagesList) {
_.forEach(value.imagesList, function(good) {
... ... @@ -359,7 +345,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.storageNumber, 10);
... ... @@ -401,6 +387,7 @@ const _detailDataPkg = (origin, uid, vipLevel, ua) => {
colorGroup[i] = {
color: []
};
// 各个颜色的尺码, 每行显示一个尺码对应的颜色
_.forEach(colorList, (colorArr) => {
let tempColorArr = _.cloneDeep(colorArr);
... ... @@ -438,7 +425,6 @@ const _detailDataPkg = (origin, uid, vipLevel, ua) => {
// 商品图:多个
console.log(goodsGroup);
if (goodsGroup.length > 1) {
let bannerList = [];
... ... @@ -464,9 +450,9 @@ const _detailDataPkg = (origin, uid, vipLevel, ua) => {
numInCart: 0,
goodsInstore: origin.storageSum
};
let soldOut = (origin.storageSum === 0) || (origin.status === 0 || totalStorageNum === 0); //status
let soldOut = (origin.storageSum === 0) || (totalStorageNum === 0); // status
let notForSale = origin.attribute === 2;
// 显示加入购物车链接
if (!soldOut && !notForSale) {
_.orderBy(colorGroup);
... ... @@ -486,7 +472,7 @@ const _detailDataPkg = (origin, uid, vipLevel, ua) => {
if (origin.isLimitBuy) {
// 是否开售
let isBeginSale = (origin.saleStatus !== null && typeof origin.saleStatus !== 'undefined' &&
origin.saleStatus === 1);
origin.saleStatus === 1);
// 限购商品有关的展示状态
let showStatus = 1;
... ... @@ -663,7 +649,6 @@ let getProductData = (data) => {
consults: _.take(info[3], 2)
});
}
return finalResult;
});
... ...
... ... @@ -348,7 +348,7 @@ let getintroIntro = (data) => {
result = result('#productDesc');
return result.html().replace(/<img src=/g, '<img class="lazy" src="data:image/gif;' +
return (result.html() || '').replace(/<img src=/g, '<img class="lazy" src="data:image/gif;' +
'base64,R0lGODlhAQABAJEAAAAAAP///93d3f///yH5BAEAAAMALAAAAAABAAEAAAICVAEAOw=="' +
' data-original=').replace(/<img border="0" src=/g, '<img border="0" class="lazy" ' +
'src="data:image/gif;base64,' +
... ...