...
|
...
|
@@ -36,6 +36,7 @@ const _getProductAdditionInfoAsync = (data) => { |
|
|
let uid = data.uid ? data.uid : 0;
|
|
|
let skn = data.erpProductId;
|
|
|
let brandId = data.brand.id ? data.brand.id : 0;
|
|
|
let index = 0;
|
|
|
|
|
|
// 获取相关数据
|
|
|
let promiseData = [
|
...
|
...
|
@@ -53,13 +54,18 @@ const _getProductAdditionInfoAsync = (data) => { |
|
|
|
|
|
let result = yield Promise.all(promiseData);
|
|
|
|
|
|
cachedRequestData['ItemData::getProductBanner'] = result[0];
|
|
|
cachedRequestData['ItemData::sizeInfo'] = result[1];
|
|
|
cachedRequestData['ItemData::getProductComfort'] = result[2];
|
|
|
cachedRequestData['ItemData::getProductModelCard'] = result[3];
|
|
|
cachedRequestData['ItemData::getProductModelTry'] = result[4];
|
|
|
cachedRequestData['BrandData::getBannerInfo'] = result[5];
|
|
|
cachedRequestData['FavoriteData::getUidProductFav'] = result[6];
|
|
|
[
|
|
|
'ItemData::getProductBanner',
|
|
|
'ItemData::sizeInfo',
|
|
|
'ItemData::getProductComfort',
|
|
|
'ItemData::getProductModelCard',
|
|
|
'ItemData::getProductModelTry',
|
|
|
'BrandData::getBannerInfo',
|
|
|
'FavoriteData::getUidProductFav'
|
|
|
].forEach(key => {
|
|
|
cachedRequestData[key] = result[index++];
|
|
|
});
|
|
|
|
|
|
|
|
|
return null;
|
|
|
})();
|
...
|
...
|
@@ -82,11 +88,8 @@ const _getProductFavoriteDataAsync = (uid, pid, bid) => { |
|
|
|
|
|
if (uid) {
|
|
|
if (pid) {
|
|
|
let productData = _getCacheDataByName('FavoriteData::getUidProductFav');
|
|
|
let productData = yield favoriteProductService.isFavoriteAsync(uid, pid);
|
|
|
|
|
|
if (!productData) {
|
|
|
productData = yield favoriteProductService.isFavoriteAsync(uid, pid);
|
|
|
}
|
|
|
result.product = productData.code === 200 && productData.data ? true : false;
|
|
|
}
|
|
|
|
...
|
...
|
@@ -133,8 +136,6 @@ const _getTagsDataByProductInfo = (data) => { |
|
|
case 'yearEnd':// 年终大促
|
|
|
tags.isYearEndPromotion = true;
|
|
|
break;
|
|
|
default:
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
);
|
...
|
...
|
@@ -157,7 +158,7 @@ const _getVipDataByProductBaseInfo = (data, vipLevel, uid) => { |
|
|
level: value.vipLevel,
|
|
|
price: value.vipPrice,
|
|
|
name: value.vipTitle,
|
|
|
cur: value.vipLevel === vipLevel ? true : false
|
|
|
cur: value.vipLevel === vipLevel
|
|
|
});
|
|
|
});
|
|
|
}
|
...
|
...
|
@@ -165,14 +166,14 @@ const _getVipDataByProductBaseInfo = (data, vipLevel, uid) => { |
|
|
vipData.unLogin = false;
|
|
|
|
|
|
if (!uid) {
|
|
|
vipData.unLogin = helpers.urlFormat('signin.html');
|
|
|
vipData.unLogin = helpers.urlFormat('/signin.html');
|
|
|
}
|
|
|
|
|
|
if (!vipLevel && uid) {
|
|
|
vipData.normalUser = true;
|
|
|
}
|
|
|
|
|
|
vipData.vipSchedualUrl = helpers.urlFormat('home/vip', {
|
|
|
vipData.vipSchedualUrl = helpers.urlFormat('/home/vip', {
|
|
|
t: _.random(10000, 9999999)
|
|
|
});
|
|
|
}
|
...
|
...
|
@@ -242,7 +243,7 @@ const _getConsultCommentDataByProductInfo = (data) => { |
|
|
consultComment.commentNum = 0;
|
|
|
if (data.commentBoWrapper) {
|
|
|
consultComment.comments = [];
|
|
|
consultComment.commentUrl = helpers.urlFormat('/home/commnet');
|
|
|
consultComment.commentUrl = helpers.urlFormat('/home/comment');
|
|
|
}
|
|
|
|
|
|
return consultComment;
|
...
|
...
|
@@ -282,8 +283,8 @@ const _getBrandDataByProductBaseInfo = (data) => { |
|
|
}
|
|
|
|
|
|
// banner的logo
|
|
|
if (bannerInfo.logo) {
|
|
|
logo = helpers.image(bannerInfo.logo);
|
|
|
if (bannerInfo && bannerInfo.logo) {
|
|
|
logo = helpers.getForceSourceUrl(bannerInfo.logo);
|
|
|
}
|
|
|
|
|
|
let homeUrl = 'javascript:void(0)';
|
...
|
...
|
@@ -295,7 +296,7 @@ const _getBrandDataByProductBaseInfo = (data) => { |
|
|
// 导航的品牌banner
|
|
|
return {
|
|
|
brandId: brandId,
|
|
|
bgColor: bannerInfo.colorValue ? bannerInfo.colorValue : '#000000',
|
|
|
bgColor: bannerInfo && bannerInfo.colorValue ? bannerInfo.colorValue : '#000000',
|
|
|
bgImg: bgImg,
|
|
|
logo: logo,
|
|
|
alt: data.brand.brandName,
|
...
|
...
|
@@ -374,19 +375,19 @@ const _getSkuDataByProductBaseInfo = (data) => { |
|
|
goodsGroup.size.push({
|
|
|
name: size.sizeName,
|
|
|
sku: size.goodsSizeSkuId,
|
|
|
num: parseInt(size.goodsSizeStorageNum, 10),
|
|
|
num: parseInt(size.goodsSizeStorageNum),
|
|
|
goodsId: size.goodsId
|
|
|
});
|
|
|
|
|
|
// 单个sku商品的总数
|
|
|
goodsGroup.total += parseInt(size.goodsSizeStorageNum, 10);
|
|
|
goodsGroup.total += parseInt(size.goodsSizeStorageNum);
|
|
|
|
|
|
if (goodsGroup.total > 0 && !chooseSkuFlag) { // 默认选中该sku商品
|
|
|
goodsGroup.focus = true;
|
|
|
chooseSkuFlag = true;// 选中sku商品
|
|
|
}
|
|
|
|
|
|
totalStorageNum += parseInt(size.goodsSizeStorageNum, 10);
|
|
|
totalStorageNum += parseInt(size.goodsSizeStorageNum);
|
|
|
|
|
|
});
|
|
|
|
...
|
...
|
@@ -435,41 +436,33 @@ const _getFashionTopGoodsStatus = (uid, showStatus, isBeginSale) => { |
|
|
// 显示获取限购码按钮
|
|
|
switch (showStatus) {
|
|
|
case 1: // 开售前/后,立即分享获得限购码(用户未领取限购码)
|
|
|
{
|
|
|
if (isBeginSale) {
|
|
|
result.buyNow = true;
|
|
|
result.dis = true;
|
|
|
} else {
|
|
|
result.openSoon = true;
|
|
|
result.hasLimitedCode = false;
|
|
|
}
|
|
|
break;
|
|
|
}
|
|
|
case 2: // 开售后,限购码已抢光(用户未领取限购码)
|
|
|
{
|
|
|
if (isBeginSale) {
|
|
|
result.buyNow = true;
|
|
|
result.dis = true;
|
|
|
result.limitedCodeSoldOut = true;
|
|
|
result.getLimitedCode = false;
|
|
|
} else {
|
|
|
result.openSoon = true;
|
|
|
result.hasLimitedCode = false;
|
|
|
break;
|
|
|
}
|
|
|
break;
|
|
|
case 2: // 开售后,限购码已抢光(用户未领取限购码)
|
|
|
result.buyNow = true;
|
|
|
result.dis = true;
|
|
|
result.limitedCodeSoldOut = true;
|
|
|
result.getLimitedCode = false;
|
|
|
result.hasLimitedCode = false;
|
|
|
break;
|
|
|
case 3: // 开售后,商品已经售罄
|
|
|
{
|
|
|
result.soldOut = true;
|
|
|
result.getLimitedCode = false;
|
|
|
break;
|
|
|
}
|
|
|
result.soldOut = true;
|
|
|
result.getLimitedCode = false;
|
|
|
break;
|
|
|
case 4:// 开售后,立即购买(用户已领取限购码)
|
|
|
{
|
|
|
result.buyNow = true;
|
|
|
result.dis = false;
|
|
|
result.hasLimitedCode = true;
|
|
|
if (uid) { // 限购码失效
|
|
|
result.getLimitedCodeDis = true;
|
|
|
}
|
|
|
break;
|
|
|
result.buyNow = true;
|
|
|
result.dis = false;
|
|
|
result.hasLimitedCode = true;
|
|
|
if (uid) { // 限购码失效
|
|
|
result.getLimitedCodeDis = true;
|
|
|
}
|
|
|
break;
|
|
|
case 5: // 开售前,限购码已被抢光(用户未领取限购码)
|
|
|
result.openSoon = true;
|
|
|
result.hasLimitedCode = true;
|
...
|
...
|
@@ -490,9 +483,6 @@ const _getFashionTopGoodsStatus = (uid, showStatus, isBeginSale) => { |
|
|
if (uid) { // 限购码失效
|
|
|
result.getLimitedCodeDis = true;
|
|
|
}
|
|
|
break;
|
|
|
default:
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
|
...
|
...
|
@@ -651,7 +641,7 @@ const _detailDataPkg = (origin, uid, vipLevel) => { |
|
|
let showStatus = 1;
|
|
|
|
|
|
if (origin.showStatus) {
|
|
|
showStatus = parseInt(origin.showStatus, 10);
|
|
|
showStatus = parseInt(origin.showStatus);
|
|
|
}
|
|
|
|
|
|
let fashTopGoods = _getFashionTopGoodsStatus(uid, showStatus, isBeginSale);
|
...
|
...
|
@@ -751,9 +741,6 @@ const _detailDataPkg = (origin, uid, vipLevel) => { |
|
|
banner.bgImg = basisData.shopTopBanner.banner || banner.bgImg;
|
|
|
break;
|
|
|
}
|
|
|
default:
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
}
|
|
|
}
|
...
|
...
|
@@ -761,7 +748,7 @@ const _detailDataPkg = (origin, uid, vipLevel) => { |
|
|
statGoodsInfo.imageUrl = result.img;
|
|
|
statGoodsInfo.productUrl = result.weixinUrl;
|
|
|
statGoodsInfo.smallSortId = result.smallSortId;
|
|
|
statGoodsInfo.soldOut = parseInt(soldOut, 10);
|
|
|
statGoodsInfo.soldOut = parseInt(soldOut);
|
|
|
|
|
|
return {
|
|
|
goodsInfo: result,
|
...
|
...
|
@@ -823,19 +810,13 @@ const _getBasicDescription = (productDescBo) => { |
|
|
|
|
|
switch (productDescBo.gender) {
|
|
|
case 1:
|
|
|
{
|
|
|
sex = '男款';
|
|
|
break;
|
|
|
}
|
|
|
sex = '男款';
|
|
|
break;
|
|
|
case 2:
|
|
|
{
|
|
|
sex = '女款';
|
|
|
break;
|
|
|
}
|
|
|
sex = '女款';
|
|
|
break;
|
|
|
default:
|
|
|
{
|
|
|
sex = '通用';
|
|
|
}
|
|
|
sex = '通用';
|
|
|
}
|
|
|
|
|
|
let basic = [];
|
...
|
...
|
@@ -1214,25 +1195,17 @@ const _getSizeAttrByMaxSortId = (maxSortId, sizeList) => { |
|
|
switch (maxSortId) {
|
|
|
case 1:
|
|
|
case 2:
|
|
|
{
|
|
|
attributeIds = [3, 4];
|
|
|
break;
|
|
|
}
|
|
|
attributeIds = [3, 4];
|
|
|
break;
|
|
|
|
|
|
case 3:
|
|
|
{
|
|
|
attributeIds = [6, 10];
|
|
|
break;
|
|
|
}
|
|
|
attributeIds = [6, 10];
|
|
|
break;
|
|
|
case 6:
|
|
|
{
|
|
|
attributeIds = [13];
|
|
|
break;
|
|
|
}
|
|
|
attributeIds = [13];
|
|
|
break;
|
|
|
default:
|
|
|
{
|
|
|
attributeIds = [];
|
|
|
}
|
|
|
attributeIds = [];
|
|
|
}
|
|
|
|
|
|
let sizeInfos = [];
|
...
|
...
|
@@ -1270,9 +1243,9 @@ const _getSizeAttrByMaxSortId = (maxSortId, sizeList) => { |
|
|
/**
|
|
|
* 商品尺码信息
|
|
|
*
|
|
|
* @param string $productSkn
|
|
|
* @param int $maxSortId
|
|
|
* @return array
|
|
|
* @param productSkn
|
|
|
* @param maxSortId
|
|
|
* @return object
|
|
|
*/
|
|
|
const _getSizeInfo = (productSkn, maxSortId)=> {
|
|
|
let result = {};
|
...
|
...
|
@@ -1323,10 +1296,45 @@ const _getSizeInfo = (productSkn, maxSortId)=> { |
|
|
};
|
|
|
|
|
|
/**
|
|
|
* 获取seo信息
|
|
|
*
|
|
|
* @param array $goodsInfo
|
|
|
* @param array $navs
|
|
|
* @return array
|
|
|
*/
|
|
|
const _getSeoByGoodsInfo = function(goodsInfo, navs) {
|
|
|
let title = '';
|
|
|
let keywords = '';
|
|
|
let brandName = '';
|
|
|
let sortName = '';
|
|
|
let description = '';
|
|
|
|
|
|
if (!_.isEmpty(goodsInfo.brandName)) {
|
|
|
title = goodsInfo.brandName + ' ';
|
|
|
brandName = goodsInfo.brandName;
|
|
|
}
|
|
|
|
|
|
if (!_.isEmpty(navs) && navs[1].name) {
|
|
|
sortName = navs[1].name;
|
|
|
title += navs[1].name + '|';
|
|
|
}
|
|
|
|
|
|
title += goodsInfo.name + '正品 ';
|
|
|
keywords = brandName + sortName + ',' + brandName + '官网专卖店,' + brandName + '官方授权店,' +
|
|
|
brandName + '正品,' + brandName + '打折,' + brandName + '折扣店,' + brandName + '真品,' + brandName + '代购';
|
|
|
description = !goodsInfo.shareDesc ? goodsInfo.name : goodsInfo.shareDesc;
|
|
|
|
|
|
return {
|
|
|
title: title,
|
|
|
keywords: keywords,
|
|
|
description: description
|
|
|
};
|
|
|
};
|
|
|
|
|
|
/**
|
|
|
* 获取某一个商品详情主页面
|
|
|
*/
|
|
|
const showMainAsync = data => {
|
|
|
|
|
|
return co(function * () {
|
|
|
let result = {};
|
|
|
let currentUserProductInfo = _.curry(_detailDataPkg)(_, data.uid, data.vipLevel);
|
...
|
...
|
@@ -1334,28 +1342,29 @@ const showMainAsync = data => { |
|
|
// 获取商品信息
|
|
|
let productInfo = yield productAPI.getProductAsync(data.pid, data.uid).then(currentUserProductInfo);
|
|
|
|
|
|
if (!productInfo || !productInfo.goodsInfo) {
|
|
|
return result;
|
|
|
if (!productInfo || _.isEmpty(productInfo)) {
|
|
|
return Promise.reject({
|
|
|
code: 404
|
|
|
});
|
|
|
}
|
|
|
|
|
|
let requestData = yield Promise.all([
|
|
|
_getSortNavAsync(productInfo.goodsInfo.smallSortId, data.gender),
|
|
|
HeaderModel.requestHeaderData(data.channel)
|
|
|
]);
|
|
|
|
|
|
// 获取商品尺寸相关
|
|
|
let sizeInfo = _getSizeInfo(productInfo.goodsInfo, productInfo.goodsInfo.maxSortId);
|
|
|
|
|
|
// 分类导航
|
|
|
let navs = requestData[0];
|
|
|
const seo = _getSeoByGoodsInfo(productInfo.goodsInfo, navs);
|
|
|
|
|
|
result.seo = seo;
|
|
|
|
|
|
result.headerData = requestData[1];
|
|
|
// 获取商品尺寸相关
|
|
|
let sizeInfo = _getSizeInfo(productInfo.goodsInfo, productInfo.goodsInfo.maxSortId);
|
|
|
|
|
|
result.headerData = requestData[1].headerData;
|
|
|
result.productDetailPage = true;
|
|
|
result.detail = Object.assign(productInfo, sizeInfo);
|
|
|
result.statGoodsInfo = Object.assign({
|
|
|
fullSortName: navs.map(x => x.name).join('-')
|
|
|
},
|
|
|
result.statGoodsInfo = Object.assign({fullSortName: navs.map(x => x.name).join('-')},
|
|
|
productInfo.statGoodsInfo
|
|
|
);
|
|
|
|
...
|
...
|
@@ -1374,6 +1383,7 @@ const showMainAsync = data => { |
|
|
|
|
|
module.exports = {
|
|
|
indexCommentAsync: commentService.indexAsync, // 获取评论列表
|
|
|
getShareOrderListAsync: commentService.getShareOrderListAsync, // 获取评论列表
|
|
|
indexConsultAsync: consultService.indexAsync, // 获取咨询列表
|
|
|
createConsultAsync: consultService.createAsync, // 添加咨询
|
|
|
showMainAsync: showMainAsync, // 获取某一个商品详情主页面
|
...
|
...
|
|