...
|
...
|
@@ -30,8 +30,9 @@ const HeaderModel = require('../../../doraemon/models/header'); |
|
|
|
|
|
const BLANK_STR = ' ';
|
|
|
|
|
|
const multiResourcesUrl = {};
|
|
|
const setMultiResourceByProductBaseInfo = (data) => {
|
|
|
const cachedRequestData = {};
|
|
|
|
|
|
const getProductAdditionInfoByProductBaseInfoAsync = (data) => {
|
|
|
return co(function * () {
|
|
|
let productId = data.id;
|
|
|
let uid = data.uid ? data.uid : 0;
|
...
|
...
|
@@ -42,37 +43,38 @@ const setMultiResourceByProductBaseInfo = (data) => { |
|
|
// 获取相关url
|
|
|
|
|
|
let result = yield Promise.all([
|
|
|
productAPI.getProductBannerAsync(productId, 'web', isOnlyUrl),
|
|
|
productAPI.sizeInfoAsync(skn, isOnlyUrl),
|
|
|
productAPI.getProductComfortAsync(productId, isOnlyUrl),
|
|
|
productAPI.getProductModelCardAsync(productId, isOnlyUrl),
|
|
|
productAPI.getProductModelTryAsync(skn, isOnlyUrl),
|
|
|
brandService.getBannerInfoAsync(brandId, isOnlyUrl)
|
|
|
productAPI.getProductBannerAsync(productId, 'web'),
|
|
|
productAPI.sizeInfoAsync(skn),
|
|
|
productAPI.getProductComfortAsync(productId),
|
|
|
productAPI.getProductModelCardAsync(productId),
|
|
|
productAPI.getProductModelTryAsync(skn),
|
|
|
brandService.getBannerInfoAsync(brandId)
|
|
|
]);
|
|
|
|
|
|
multiResourcesUrl['ItemData::getProductBanner'] = result[0];
|
|
|
multiResourcesUrl['ItemData::sizeInfo'] = result[1];
|
|
|
multiResourcesUrl['ItemData::getProductComfort'] = result[2];
|
|
|
multiResourcesUrl['ItemData::getProductModelCard'] = result[3];
|
|
|
multiResourcesUrl['ItemData::getProductModelTry'] = result[4];
|
|
|
multiResourcesUrl['BrandData::getBannerInfo'] = result[5];
|
|
|
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];
|
|
|
|
|
|
if (uid) {
|
|
|
multiResourcesUrl['FavoriteData::getUidProductFav'] =
|
|
|
cachedRequestData['FavoriteData::getUidProductFav'] =
|
|
|
yield favoriteProductService.isFavoriteAsync(uid, productId, isOnlyUrl);
|
|
|
}
|
|
|
|
|
|
return null;
|
|
|
})();
|
|
|
};
|
|
|
|
|
|
function getMultiDataByResourceName(resourceName) {
|
|
|
return multiResourcesUrl[resourceName] || false;
|
|
|
function getCacheDataByName(resourceName) {
|
|
|
return cachedRequestData[resourceName] || false;
|
|
|
}
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 获取商品的喜欢
|
|
|
*/
|
|
|
const getProductFavoriteData = (uid, pid, bid) => {
|
|
|
const getProductFavoriteDataAsync = (uid, pid, bid) => {
|
|
|
return co(function*() {
|
|
|
|
|
|
let result = {
|
...
|
...
|
@@ -82,7 +84,7 @@ const getProductFavoriteData = (uid, pid, bid) => { |
|
|
|
|
|
if (uid) {
|
|
|
if (pid) {
|
|
|
let productData = getMultiDataByResourceName('FavoriteData::getUidProductFav');
|
|
|
let productData = getCacheDataByName('FavoriteData::getUidProductFav');
|
|
|
|
|
|
if (!productData) {
|
|
|
productData = yield favoriteProductService.isFavoriteAsync(uid, pid);
|
...
|
...
|
@@ -177,49 +179,43 @@ const getVipDataByProductBaseInfo = (data, vipLevel, uid) => { |
|
|
return vipData;
|
|
|
};
|
|
|
|
|
|
function getProductActivityBannerAsync(pid) {
|
|
|
function getProductActivityBanner() {
|
|
|
|
|
|
return co(function*() {
|
|
|
let result = {};
|
|
|
|
|
|
let result = {};
|
|
|
|
|
|
let data = getMultiDataByResourceName('ItemData::getProductBanner');
|
|
|
let data = getCacheDataByName('ItemData::getProductBanner');
|
|
|
|
|
|
if (!data) {
|
|
|
data = yield productAPI.getProductBannerAsync(pid);
|
|
|
}
|
|
|
if (!data) {
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
if (data.code && data.code === 200 && data.data) {
|
|
|
result.activityImg = helpers.image(data.data.bannerImg, 260, 64);
|
|
|
result.url = data.data.promotionUrl;
|
|
|
}
|
|
|
if (data.code && data.code === 200 && data.data) {
|
|
|
result.activityImg = helpers.image(data.data.bannerImg, 260, 64);
|
|
|
result.url = data.data.promotionUrl;
|
|
|
}
|
|
|
|
|
|
return result;
|
|
|
})();
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
const getActivityDataByProductBaseInfo = (data) => {
|
|
|
return co(function *() {
|
|
|
let result = [];
|
|
|
|
|
|
let result = [];
|
|
|
let activityBanner = getProductActivityBanner();
|
|
|
|
|
|
let activityBanner = yield getProductActivityBannerAsync(data.id);
|
|
|
|
|
|
if (activityBanner) {
|
|
|
result.push(activityBanner);
|
|
|
}
|
|
|
if (activityBanner) {
|
|
|
result.push(activityBanner);
|
|
|
}
|
|
|
|
|
|
if (data.promotionBoList) {
|
|
|
data.promotionBoList.forEach(value => {
|
|
|
result.push({
|
|
|
type: value.promotionType,
|
|
|
des: value.promotionTitle
|
|
|
});
|
|
|
if (data.promotionBoList) {
|
|
|
data.promotionBoList.forEach(value => {
|
|
|
result.push({
|
|
|
type: value.promotionType,
|
|
|
des: value.promotionTitle
|
|
|
});
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
|
|
|
return result;
|
|
|
})();
|
|
|
return result;
|
|
|
};
|
|
|
|
|
|
/**
|
...
|
...
|
@@ -232,7 +228,7 @@ const getConsultCommentDataByProductInfo = (data) => { |
|
|
let consultComment = {};
|
|
|
|
|
|
consultComment.consultNum = 0;
|
|
|
consultComment.captchaUrl = helpers.urlFormat('/passport/images', {
|
|
|
consultComment.captchaUrl = helpers.urlFormat('passport/images', {
|
|
|
t: moment().valueOf()
|
|
|
});
|
|
|
|
...
|
...
|
@@ -244,7 +240,7 @@ const getConsultCommentDataByProductInfo = (data) => { |
|
|
consultComment.commentNum = 0;
|
|
|
if (data.commentBoWrapper) {
|
|
|
consultComment.comments = [];
|
|
|
consultComment.commentUrl = helpers.urlFormat('/home/commnet');
|
|
|
consultComment.commentUrl = helpers.urlFormat('home/commnet');
|
|
|
}
|
|
|
|
|
|
return consultComment;
|
...
|
...
|
@@ -255,62 +251,58 @@ const getConsultCommentDataByProductInfo = (data) => { |
|
|
* 获取品牌数据
|
|
|
*/
|
|
|
const getBrandDataByProductBaseInfo = (data) => {
|
|
|
if (!data.brand) {
|
|
|
return {};
|
|
|
}
|
|
|
|
|
|
return co(function *() {
|
|
|
|
|
|
if (!data.brand) {
|
|
|
return {};
|
|
|
}
|
|
|
|
|
|
let brandId = data.brand.id;
|
|
|
let brandId = data.brand.id;
|
|
|
|
|
|
let bgImg = '';
|
|
|
let bgImg = '';
|
|
|
|
|
|
let logo = '';
|
|
|
let logo = '';
|
|
|
|
|
|
let bannerInfo = null;
|
|
|
let bannerInfo = null;
|
|
|
|
|
|
let result = getMultiDataByResourceName('BrandData::getBannerInfo');
|
|
|
let result = getCacheDataByName('BrandData::getBannerInfo');
|
|
|
|
|
|
if (!result) {
|
|
|
result = yield brandService.getBannerInfoAsync(brandId);
|
|
|
}
|
|
|
if (!result) {
|
|
|
return {};
|
|
|
}
|
|
|
|
|
|
if (data.brand.brandIco) {
|
|
|
logo = helpers.getForceSourceUrl(data.brand.brandIco);
|
|
|
}
|
|
|
if (data.brand.brandIco) {
|
|
|
logo = helpers.getForceSourceUrl(data.brand.brandIco);
|
|
|
}
|
|
|
|
|
|
if (result.code && result.code === 200 && result.data) {
|
|
|
bannerInfo = result.data;
|
|
|
if (bannerInfo.bannerUrl) {
|
|
|
bgImg = helpers.getForceSourceUrl(bannerInfo.bannerUrl);
|
|
|
}
|
|
|
if (result.code && result.code === 200 && result.data) {
|
|
|
bannerInfo = result.data;
|
|
|
if (bannerInfo.bannerUrl) {
|
|
|
bgImg = helpers.getForceSourceUrl(bannerInfo.bannerUrl);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
// banner的logo
|
|
|
if (bannerInfo.logo) {
|
|
|
logo = helpers.image(bannerInfo.logo);
|
|
|
}
|
|
|
// banner的logo
|
|
|
if (bannerInfo.logo) {
|
|
|
logo = helpers.image(bannerInfo.logo);
|
|
|
}
|
|
|
|
|
|
let homeUrl = 'javascript:void(0)';
|
|
|
let homeUrl = 'javascript:void(0)';
|
|
|
|
|
|
if (data.brand.brandDomain) {
|
|
|
homeUrl = helpers.urlFormat('', {}, data.brand.brandDomain);
|
|
|
}
|
|
|
if (data.brand.brandDomain) {
|
|
|
homeUrl = helpers.urlFormat('', {}, data.brand.brandDomain);
|
|
|
}
|
|
|
|
|
|
// 导航的品牌banner
|
|
|
return {
|
|
|
brandId: brandId,
|
|
|
bgColor: bannerInfo.colorValue ? bannerInfo.colorValue : '#000000',
|
|
|
bgImg: bgImg,
|
|
|
logo: logo,
|
|
|
alt: data.brand.brandName,
|
|
|
brandName: data.brand.brandName,
|
|
|
brandDomain: data.brand.brandDomain,
|
|
|
homeUrl: homeUrl,
|
|
|
isCollect: false
|
|
|
};
|
|
|
})();
|
|
|
// 导航的品牌banner
|
|
|
return {
|
|
|
brandId: brandId,
|
|
|
bgColor: bannerInfo.colorValue ? bannerInfo.colorValue : '#000000',
|
|
|
bgImg: bgImg,
|
|
|
logo: logo,
|
|
|
alt: data.brand.brandName,
|
|
|
brandName: data.brand.brandName,
|
|
|
brandDomain: data.brand.brandDomain,
|
|
|
homeUrl: homeUrl,
|
|
|
isCollect: false
|
|
|
};
|
|
|
};
|
|
|
|
|
|
/**
|
...
|
...
|
@@ -442,41 +434,41 @@ 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;
|
...
|
...
|
@@ -506,7 +498,6 @@ const getFashionTopGoodsStatus = (uid, showStatus, isBeginSale) => { |
|
|
/**
|
|
|
* 获取分类导航列表
|
|
|
*/
|
|
|
// controller item.php 32;
|
|
|
function getSortNavAsync(smallSortId, gender) {
|
|
|
return co(function*() {
|
|
|
|
...
|
...
|
@@ -562,10 +553,7 @@ const detailDataPkg = (origin, uid, vipLevel) => { |
|
|
result.maxSortId = origin.maxSortId;
|
|
|
result.smallSortId = origin.smallSortId;
|
|
|
result.promotionId = origin.isPromotion;
|
|
|
result.goCartUrl = helpers.urlFormat('/shopping/cart');
|
|
|
|
|
|
// 接口处理数据,设置并发请求数据
|
|
|
yield setMultiResourceByProductBaseInfo(origin);
|
|
|
result.goCartUrl = helpers.urlFormat('shopping/cart');
|
|
|
|
|
|
let brandId = 0;
|
|
|
|
...
|
...
|
@@ -573,8 +561,12 @@ const detailDataPkg = (origin, uid, vipLevel) => { |
|
|
brandId = origin.brand.id;
|
|
|
}
|
|
|
|
|
|
// 处理收藏喜欢数据
|
|
|
let favoriteData = yield getProductFavoriteData(uid, result.productId, brandId);
|
|
|
let requestData = yield Promise.all([
|
|
|
getProductAdditionInfoByProductBaseInfoAsync(origin), // 接口处理数据,设置并发请求数据
|
|
|
getProductFavoriteDataAsync(uid, result.productId, brandId) //处理收藏喜欢数据
|
|
|
]);
|
|
|
|
|
|
let favoriteData = requestData[1];
|
|
|
|
|
|
// 商品标签
|
|
|
result.tags = getTagsDataByProductInfo(origin);
|
...
|
...
|
@@ -599,7 +591,7 @@ const detailDataPkg = (origin, uid, vipLevel) => { |
|
|
result.vipPrice = getVipDataByProductBaseInfo(origin, vipLevel, uid);
|
|
|
|
|
|
// 促销活动banner
|
|
|
result.activity = yield getActivityDataByProductBaseInfo(origin);
|
|
|
result.activity = getActivityDataByProductBaseInfo(origin);
|
|
|
|
|
|
const C_VALUE = {
|
|
|
type: '返YOHO币',
|
...
|
...
|
@@ -632,7 +624,7 @@ const detailDataPkg = (origin, uid, vipLevel) => { |
|
|
result.brandImg = helpers.image(origin.brand.brandIco, 47, 47);
|
|
|
result.brandName = origin.brand.brandName;
|
|
|
result.brandUrl = helpers.urlFormat('', {}, origin.brand.brandDomain);
|
|
|
banner = yield getBrandDataByProductBaseInfo(origin);
|
|
|
banner = getBrandDataByProductBaseInfo(origin);
|
|
|
if (banner.isCollect && favoriteData.brand) {
|
|
|
banner.isCollect = favoriteData.brand;
|
|
|
}
|
...
|
...
|
@@ -661,7 +653,6 @@ const detailDataPkg = (origin, uid, vipLevel) => { |
|
|
|
|
|
let fashTopGoods = getFashionTopGoodsStatus(uid, showStatus, isBeginSale);
|
|
|
|
|
|
|
|
|
result.fashTopGoods = {
|
|
|
getLimitedCode: fashTopGoods.getLimitedCode, // 限购码状态
|
|
|
hasLimitedCode: fashTopGoods.hasLimitedCode, // 是否已经获取限购码
|
...
|
...
|
@@ -702,7 +693,7 @@ const detailDataPkg = (origin, uid, vipLevel) => { |
|
|
} else if (virtualGoods) {
|
|
|
// 虚拟商品
|
|
|
result.buyNow = true; // 是否立即购买
|
|
|
result.buyNowBase = helpers.urlFormat('/ticket', {}, 'shopping');
|
|
|
result.buyNowBase = helpers.urlFormat('ticket', {}, 'shopping');
|
|
|
result.virtualGoods = virtualGoods;
|
|
|
if (result.salePrice) {
|
|
|
result.advancePrice = result.salePrice; // 先行价格
|
...
|
...
|
@@ -723,7 +714,6 @@ const detailDataPkg = (origin, uid, vipLevel) => { |
|
|
result.shareImg = result.img;
|
|
|
result.shareDesc = result.phrase;
|
|
|
|
|
|
|
|
|
// 统计需要的商品信息
|
|
|
let statGoodsInfo = {};
|
|
|
|
...
|
...
|
@@ -745,19 +735,19 @@ const detailDataPkg = (origin, uid, vipLevel) => { |
|
|
if (domainBrand.type && domainBrand.shopId) {
|
|
|
switch (parseInt(domainBrand.type)) {
|
|
|
case 1:
|
|
|
{
|
|
|
{
|
|
|
// 多品店不显示
|
|
|
banner = [];
|
|
|
break;
|
|
|
}
|
|
|
banner = [];
|
|
|
break;
|
|
|
}
|
|
|
case 2:
|
|
|
{
|
|
|
{
|
|
|
// TODO:单品店显示新版的店铺banner,item.php 210
|
|
|
let basisData = shopAPI.basisTemplateAsync(domainBrand.shopId);
|
|
|
let basisData = shopAPI.basisTemplateAsync(domainBrand.shopId);
|
|
|
|
|
|
banner.bgImg = basisData.shopTopBanner.banner || banner.bgImg;
|
|
|
break;
|
|
|
}
|
|
|
banner.bgImg = basisData.shopTopBanner.banner || banner.bgImg;
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
}
|
|
|
}
|
...
|
...
|
@@ -780,102 +770,97 @@ const detailDataPkg = (origin, uid, vipLevel) => { |
|
|
/**
|
|
|
* 获取商品的舒适度
|
|
|
*/
|
|
|
function getProductComfortAsync(productId) {
|
|
|
return co(function*() {
|
|
|
|
|
|
let result = [];
|
|
|
function getProductComfort() {
|
|
|
|
|
|
let comfort = getMultiDataByResourceName('ItemData::getProductComfort');
|
|
|
let result = [];
|
|
|
|
|
|
if (!comfort) {
|
|
|
comfort = yield favoriteBrandService.getProductComfortAsync(productId);
|
|
|
}
|
|
|
let comfort = getCacheDataByName('ItemData::getProductComfort');
|
|
|
|
|
|
if (comfort.data) {
|
|
|
comfort.data.forEach(value => {
|
|
|
let blocks = [];
|
|
|
if (!comfort) {
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
let flag = false;
|
|
|
if (comfort.data) {
|
|
|
comfort.data.forEach(value => {
|
|
|
let blocks = [];
|
|
|
|
|
|
_.range(1, 6).forEach(i => {
|
|
|
if (i === value.wearSense.value) {
|
|
|
flag = true;
|
|
|
blocks.push({
|
|
|
cur: true
|
|
|
});
|
|
|
} else {
|
|
|
blocks.push({});
|
|
|
}
|
|
|
});
|
|
|
let flag = false;
|
|
|
|
|
|
// 存在,添加
|
|
|
if (flag) {
|
|
|
result.push({
|
|
|
name: value.caption.caption,
|
|
|
minDes: value.caption.low,
|
|
|
blocks: blocks,
|
|
|
maxDes: value.caption.high
|
|
|
_.range(1, 6).forEach(i => {
|
|
|
if (i === value.wearSense.value) {
|
|
|
flag = true;
|
|
|
blocks.push({
|
|
|
cur: true
|
|
|
});
|
|
|
} else {
|
|
|
blocks.push({});
|
|
|
}
|
|
|
|
|
|
});
|
|
|
}
|
|
|
|
|
|
return result;
|
|
|
})();
|
|
|
}
|
|
|
// 存在,添加
|
|
|
if (flag) {
|
|
|
result.push({
|
|
|
name: value.caption.caption,
|
|
|
minDes: value.caption.low,
|
|
|
blocks: blocks,
|
|
|
maxDes: value.caption.high
|
|
|
});
|
|
|
}
|
|
|
|
|
|
});
|
|
|
}
|
|
|
|
|
|
function getDescriptionDataBySizeInfoAsync(sizeInfo) {
|
|
|
return co(function *() {
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
let description = {};
|
|
|
|
|
|
if (sizeInfo.productDescBo.erpProductId) {
|
|
|
let sex = '通用';
|
|
|
function getDescriptionDataBySizeInfo(sizeInfo) {
|
|
|
let description = {};
|
|
|
|
|
|
switch (sizeInfo.productDescBo.gender) {
|
|
|
case 1:
|
|
|
{
|
|
|
sex = '男款';
|
|
|
break;
|
|
|
}
|
|
|
case 2:
|
|
|
{
|
|
|
sex = '女款';
|
|
|
break;
|
|
|
}
|
|
|
if (sizeInfo.productDescBo.erpProductId) {
|
|
|
let sex = '通用';
|
|
|
|
|
|
switch (sizeInfo.productDescBo.gender) {
|
|
|
case 1:
|
|
|
{
|
|
|
sex = '男款';
|
|
|
break;
|
|
|
}
|
|
|
case 2:
|
|
|
{
|
|
|
sex = '女款';
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
description.basic = [];
|
|
|
description.basic.push({
|
|
|
key: '编号',
|
|
|
value: sizeInfo.productDescBo.erpProductId
|
|
|
});
|
|
|
description.basic.push({
|
|
|
key: '颜色',
|
|
|
value: sizeInfo.productDescBo.colorName,
|
|
|
dColor: true
|
|
|
});
|
|
|
description.basic.push({
|
|
|
key: '性别',
|
|
|
value: sex
|
|
|
});
|
|
|
description.basic = [];
|
|
|
description.basic.push({
|
|
|
key: '编号',
|
|
|
value: sizeInfo.productDescBo.erpProductId
|
|
|
});
|
|
|
description.basic.push({
|
|
|
key: '颜色',
|
|
|
value: sizeInfo.productDescBo.colorName,
|
|
|
dColor: true
|
|
|
});
|
|
|
description.basic.push({
|
|
|
key: '性别',
|
|
|
value: sex
|
|
|
});
|
|
|
|
|
|
if (sizeInfo.productDescBo.standardBos) {
|
|
|
sizeInfo.productDescBo.standardBos.forEach(value => {
|
|
|
description.basic.push({
|
|
|
key: value.standardName,
|
|
|
value: value.standardVal
|
|
|
});
|
|
|
if (sizeInfo.productDescBo.standardBos) {
|
|
|
sizeInfo.productDescBo.standardBos.forEach(value => {
|
|
|
description.basic.push({
|
|
|
key: value.standardName,
|
|
|
value: value.standardVal
|
|
|
});
|
|
|
}
|
|
|
|
|
|
description.confort = yield getProductComfortAsync(sizeInfo.productBo.id);
|
|
|
});
|
|
|
}
|
|
|
|
|
|
return description;
|
|
|
})();
|
|
|
description.confort = getProductComfort();
|
|
|
}
|
|
|
|
|
|
return description;
|
|
|
}
|
|
|
|
|
|
/**
|
...
|
...
|
@@ -1012,29 +997,27 @@ function getSizeDataBySizeInfo(sizeInfo) { |
|
|
* 获取商品模特卡
|
|
|
* @param productId
|
|
|
*/
|
|
|
function getProductModelCardAsync(productId) {
|
|
|
return co(function*() {
|
|
|
function getProductModelCard() {
|
|
|
|
|
|
let result = [];
|
|
|
let result = [];
|
|
|
|
|
|
let data = getMultiDataByResourceName('ItemData::getProductModelCard');
|
|
|
let data = getCacheDataByName('ItemData::getProductModelCard');
|
|
|
|
|
|
if (!data) {
|
|
|
data = yield productAPI.getProductModelCardAsync(productId);
|
|
|
}
|
|
|
if (!data) {
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
if (data.code && data.code === 200) {
|
|
|
_(data.data).forEach(val => {
|
|
|
result.push({
|
|
|
url: helpers.getForceSourceUrl(val.modelImg),
|
|
|
size: val.size,
|
|
|
name: val.modelName
|
|
|
});
|
|
|
if (data.code && data.code === 200) {
|
|
|
_(data.data).forEach(val => {
|
|
|
result.push({
|
|
|
url: helpers.getForceSourceUrl(val.modelImg),
|
|
|
size: val.size,
|
|
|
name: val.modelName
|
|
|
});
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
|
|
|
return result;
|
|
|
})();
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
/**
|
...
|
...
|
@@ -1155,47 +1138,45 @@ function getDetailDataBySizeInfo(sizeInfo) { |
|
|
* 获取模特试穿
|
|
|
* @param productSkn
|
|
|
*/
|
|
|
function getProductModelTryAsync(productSkn) {
|
|
|
return co(function*() {
|
|
|
let modelTry = {};
|
|
|
function getProductModelTry() {
|
|
|
let modelTry = {};
|
|
|
|
|
|
let result = getMultiDataByResourceName('ItemData::getProductModelTry');
|
|
|
let result = getCacheDataByName('ItemData::getProductModelTry');
|
|
|
|
|
|
if (!result) {
|
|
|
result = yield productAPI.getProductModelTryAsync(productSkn);
|
|
|
}
|
|
|
|
|
|
if (result.code && result.code === 200 && result.data) {
|
|
|
// 先显示模特信息
|
|
|
if (result.data.modelTryBoList) {
|
|
|
modelTry.thead = ['模特', '身高', '体重', '三围', '试穿尺码', '试穿描述'];
|
|
|
modelTry.tbody = [];
|
|
|
|
|
|
result.data.modelTryBoList.forEach(val => {
|
|
|
if (val.modelBo &&
|
|
|
val.sizeBo &&
|
|
|
val.modelBo.modelName &&
|
|
|
val.sizeBo.sizeName) {
|
|
|
|
|
|
modelTry.tbody.push([
|
|
|
val.modelBo.modelName,
|
|
|
val.modelBo.height,
|
|
|
val.modelBo.weight,
|
|
|
val.modelBo.vitalStatistics,
|
|
|
val.sizeBo.sizeName,
|
|
|
val.tryDesc
|
|
|
]);
|
|
|
}
|
|
|
});
|
|
|
} else if (result.data.modelTryImgBoList) {
|
|
|
let tryImg = _.head(result.data.modelTryImgBoList);
|
|
|
if (!result) {
|
|
|
return modelTry;
|
|
|
}
|
|
|
|
|
|
modelTry.frImg = helpers.getForceSourceUrl(tryImg.tryImg);
|
|
|
}
|
|
|
if (result.code && result.code === 200 && result.data) {
|
|
|
// 先显示模特信息
|
|
|
if (result.data.modelTryBoList) {
|
|
|
modelTry.thead = ['模特', '身高', '体重', '三围', '试穿尺码', '试穿描述'];
|
|
|
modelTry.tbody = [];
|
|
|
|
|
|
result.data.modelTryBoList.forEach(val => {
|
|
|
if (val.modelBo &&
|
|
|
val.sizeBo &&
|
|
|
val.modelBo.modelName &&
|
|
|
val.sizeBo.sizeName) {
|
|
|
|
|
|
modelTry.tbody.push([
|
|
|
val.modelBo.modelName,
|
|
|
val.modelBo.height,
|
|
|
val.modelBo.weight,
|
|
|
val.modelBo.vitalStatistics,
|
|
|
val.sizeBo.sizeName,
|
|
|
val.tryDesc
|
|
|
]);
|
|
|
}
|
|
|
});
|
|
|
} else if (result.data.modelTryImgBoList) {
|
|
|
let tryImg = _.head(result.data.modelTryImgBoList);
|
|
|
|
|
|
modelTry.frImg = helpers.getForceSourceUrl(tryImg.tryImg);
|
|
|
}
|
|
|
return modelTry;
|
|
|
})();
|
|
|
|
|
|
}
|
|
|
return modelTry;
|
|
|
}
|
|
|
|
|
|
/**
|
...
|
...
|
@@ -1210,25 +1191,25 @@ function 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,58 +1251,49 @@ function getSizeAttrByMaxSortId(maxSortId, sizeList) { |
|
|
* @param int $maxSortId
|
|
|
* @return array
|
|
|
*/
|
|
|
const getSizeInfoAsync = (productSkn, maxSortId)=> {
|
|
|
return co(function*() {
|
|
|
const getSizeInfo = (productSkn, maxSortId)=> {
|
|
|
|
|
|
let result = {};
|
|
|
|
|
|
if (productSkn) {
|
|
|
// 并发资源中是否存在数据
|
|
|
let sizeInfo = getMultiDataByResourceName('ItemData::sizeInfo');
|
|
|
let result = {};
|
|
|
|
|
|
if (!sizeInfo) {
|
|
|
// 获取尺码
|
|
|
sizeInfo = yield productAPI.sizeInfoAsync(productSkn);
|
|
|
}
|
|
|
if (productSkn) {
|
|
|
// 并发资源中是否存在数据
|
|
|
let sizeInfo = getCacheDataByName('ItemData::sizeInfo');
|
|
|
|
|
|
if (!sizeInfo) {
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
let productId = sizeInfo.productBo.id;
|
|
|
if (!sizeInfo) {
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
// 描述数据
|
|
|
result.description = yield getDescriptionDataBySizeInfoAsync(sizeInfo);
|
|
|
// 描述数据
|
|
|
result.description = getDescriptionDataBySizeInfo(sizeInfo);
|
|
|
|
|
|
// 尺寸数据
|
|
|
result.size = getSizeDataBySizeInfo(sizeInfo);
|
|
|
// 模特卡
|
|
|
result.modelCards = getProductModelCard();
|
|
|
|
|
|
// 模特卡
|
|
|
result.modelCards = yield getProductModelCardAsync(productId);
|
|
|
// 试穿模特
|
|
|
let fittingReport = getProductModelTry();
|
|
|
|
|
|
// 模特数据
|
|
|
result.reference = getReferenceDataBySizeInfo(sizeInfo);
|
|
|
if (!_.isEmpty(fittingReport)) {
|
|
|
result.fittingReport = fittingReport;
|
|
|
}
|
|
|
|
|
|
// 洗涤材质
|
|
|
result.material = getMaterialDataBySizeInfo(sizeInfo);
|
|
|
// 尺寸数据
|
|
|
result.size = getSizeDataBySizeInfo(sizeInfo);
|
|
|
|
|
|
// 商品详情页介绍
|
|
|
result.details = getDetailDataBySizeInfo(sizeInfo);
|
|
|
// 模特数据
|
|
|
result.reference = getReferenceDataBySizeInfo(sizeInfo);
|
|
|
|
|
|
// 试穿模特
|
|
|
let fittingReport = yield getProductModelTryAsync(productSkn);
|
|
|
// 洗涤材质
|
|
|
result.material = getMaterialDataBySizeInfo(sizeInfo);
|
|
|
|
|
|
if (!_.isEmpty(fittingReport)) {
|
|
|
result.fittingReport = fittingReport;
|
|
|
}
|
|
|
// 商品详情页介绍
|
|
|
result.details = getDetailDataBySizeInfo(sizeInfo);
|
|
|
|
|
|
// 获取尺寸说明
|
|
|
result.sizeTitleJson =
|
|
|
sizeInfo.sizeInfoBo ? JSON.stringify(getSizeAttrByMaxSortId(maxSortId, sizeInfo.sizeInfoBo)) : '';
|
|
|
}
|
|
|
// 获取尺寸说明
|
|
|
result.sizeTitleJson =
|
|
|
sizeInfo.sizeInfoBo ? JSON.stringify(getSizeAttrByMaxSortId(maxSortId, sizeInfo.sizeInfoBo)) : '';
|
|
|
}
|
|
|
|
|
|
return result;
|
|
|
})();
|
|
|
return result;
|
|
|
};
|
|
|
|
|
|
/**
|
...
|
...
|
@@ -1346,21 +1318,32 @@ module.exports.showMainAsync = (data) => { |
|
|
|
|
|
return co(function * () {
|
|
|
|
|
|
// 获取商品信息
|
|
|
let productInfo = yield productAPI.getProductInfo(data.id);
|
|
|
let result = {};
|
|
|
|
|
|
productInfo = yield detailDataPkg(productInfo, data.uid, data.vipLevel);
|
|
|
let currentUserProductInfo = _.curry(detailDataPkg)(_, data.uid, data.vipLevel);
|
|
|
|
|
|
// 获取商品信息
|
|
|
let productInfo = yield productAPI.getProductInfo(data.id).then(currentUserProductInfo);
|
|
|
|
|
|
// 获取商品尺寸相关
|
|
|
let sizeInfo = yield getSizeInfoAsync(productInfo.goodsInfo, productInfo.goodsInfo.maxSortId);
|
|
|
let requestData = yield Promise.all([
|
|
|
getSortNavAsync(productInfo.goodsInfo.smallSortId, data.gender),
|
|
|
HeaderModel.requestHeaderData()
|
|
|
]);
|
|
|
|
|
|
let navs = yield getSortNavAsync(productInfo.goodsInfo.smallSortId, data.gender);
|
|
|
let sizeInfo = getSizeInfo(productInfo.goodsInfo, productInfo.goodsInfo.maxSortId);
|
|
|
|
|
|
let result = {
|
|
|
productDetailPage: true,
|
|
|
detail: Object.assign(productInfo, sizeInfo),
|
|
|
statGoodsInfo: Object.assign({fullSortName: navs.map(x => x.name).join('-')}, productInfo.statGoodsInfo)
|
|
|
};
|
|
|
let navs = requestData[0];
|
|
|
|
|
|
result.headerData = requestData[1];
|
|
|
|
|
|
result.productDetailPage = true;
|
|
|
result.detail = Object.assign(productInfo, sizeInfo);
|
|
|
result.statGoodsInfo = Object.assign({
|
|
|
fullSortName: navs.map(x => x.name).join('-')
|
|
|
},
|
|
|
productInfo.statGoodsInfo
|
|
|
);
|
|
|
|
|
|
// 导航
|
|
|
result.detail.pathNav = _.concat(
|
...
|
...
|
@@ -1370,8 +1353,6 @@ module.exports.showMainAsync = (data) => { |
|
|
);
|
|
|
|
|
|
result.detail.lastWalk = 5;
|
|
|
result.headerData = yield HeaderModel.requestHeaderData();
|
|
|
|
|
|
return result;
|
|
|
})();
|
|
|
};
|
...
|
...
|
|