Authored by 徐炜

Merge remote-tracking branch 'origin/feature/goodsDetail'

... ... @@ -18,8 +18,8 @@ const SingleAPI = global.yoho.SingleAPI;
*/
const getProductBaseAsync = (productId, uid, skn) => {
let params = {
method: 'h5.product.data',
productId: productId
method: 'app.product.data',
product_id: productId
};
if (uid) {
... ...
... ... @@ -255,12 +255,12 @@ const setBrandBanner = (base, brand, shop) => {
let resData = {},
banner = {};
if (base.brand) {
let info = base.brand;
if (base.brandInfo) {
let info = base.brandInfo;
// 基础品牌数据
banner = {
brandId: info.id,
brandId: info.brandId,
bgColor: '#000',
brandLogo: {
link: `/product/shop/${info.brandDomain}`, // 品牌跳转链接
... ... @@ -319,12 +319,12 @@ const setBrandBanner = (base, brand, shop) => {
*/
const setProductData = base => {
let resData = {
id: base.id,
id: base.productId,
name: base.productName,
brandName: _.has(base, 'brand.brandName') ? base.brand.brandName : '',
brandName: _.has(base, 'brandInfo.brandName') ? base.brandInfo.brandName : '',
intro: base.salesPhrase,
sellPrice: base.productPriceBo.salesPrice,
marketPrice: base.productPriceBo.marketPrice,
sellPrice: base.salesPrice,
marketPrice: base.marketPrice,
total: 0
};
... ... @@ -350,7 +350,7 @@ const setProductData = base => {
return;
}
if (value.goodsImagesList) {
if (value.imagesList) {
group = {
name: value.colorName,
title: `${resData.name} ${value.colorName}`,
... ... @@ -369,7 +369,7 @@ const setProductData = base => {
}
// 商品颜色列表
_.forEach(value.goodsImagesList, function(subValue) {
_.forEach(value.imagesList, function(subValue) {
thumbs.push(subValue.imageUrl);
});
group.thumbs = thumbs;
... ... @@ -390,22 +390,22 @@ const setProductData = base => {
}
// 商品尺码列表
_.forEach(value.goodsSizeBoList, function(subValue) {
_.forEach(value.sizeList, function(subValue) {
let size = {
name: subValue.sizeName,
title: subValue.sizeName,
sku: subValue.goodsSizeSkuId,
num: _.toInteger(subValue.goodsSizeStorageNum),
goodsId: subValue.goodsId
sku: subValue.productSku,
num: _.toInteger(subValue.storageNumber),
goodsId: value.goodsId
};
// 虚拟商品,增加为一件
if (subValue.attribute === 3) {
if (base.attribute === 3) {
size.num = size.num > 1 ? 1 : 0;
}
// 如果status为0,即skc下架时,则库存设为0
if (subValue.status === 0) {
if (base.status === 0 || subValue.status === 0) {
size.num = 0;
}
... ...
... ... @@ -10,9 +10,8 @@ const itemApi = require('./item-api');
const brandApi = require('./brand-api');
const shopApi = require('./shop-api');
const itemFun = require('./item-handler');
const search = require('./search-api');
const camelCase = global.yoho.camelCase;
/**
* 根据商品基本信息获取商品品牌、材质、尺码、描述、详情等
... ... @@ -21,10 +20,10 @@ const search = require('./search-api');
* @return { Object } 返回单个商品品牌、材质、尺码、描述、详情等信息
*/
const _getMultiResourceByBaseInfo = (base) => {
const productId = base.id;
const skn = base.erpProductId;
const brandId = base.brandId || 0;
const brandDomain = _.get(base, 'brand.brandDomain', false);
const productId = base.productId;
const skn = base.productSkn;
const brandId = base.brandInfo.brandId || 0;
const brandDomain = _.get(base, 'brandInfo.brandName', false);
const shopId = base.shopId || 0;
let apiIndex = {};
... ... @@ -57,6 +56,7 @@ const _getMultiResourceByBaseInfo = (base) => {
}
return Promise.all(promiseData).then(result => {
return {
sizeInfo: result[0],
comfort: result[1].data,
... ... @@ -91,14 +91,22 @@ const getProductItemData = (params, url, uid) => {
let resData = {};
let data = {};
// 如果status为0,即商品下架时则返回空对象
if (!result.status) {
return resData;
result = camelCase(result.data);
if (!result) {
return;
}
// 如果status为0,即商品下架时则返回空对象
// if (!result.status) {
// return resData;
// }
if (!result.productName &&
!result.erpProductId &&
!result.productPriceBo) {
!result.productSkn &&
!result.salesPrice &&
!result.marketPrice
) {
return resData;
}
... ... @@ -109,12 +117,11 @@ const getProductItemData = (params, url, uid) => {
data.goodInfo = itemFun.setProductData(result);
// BRAND品牌简介
if (result.brand) {
Object.assign(data, itemFun.setBrandIntro(result.brand));
if (result.brandInfo) {
Object.assign(data, itemFun.setBrandIntro(result.brandInfo));
}
return _getMultiResourceByBaseInfo(result).then(mulRes => {
Object.assign(data,
itemFun.setBrandBanner(result, mulRes.brandBanner, mulRes.shopInfo), // banner
itemFun.setPathNav(mulRes.sort, result.productName, params.channel), // 面包屑导航
... ...
... ... @@ -58,7 +58,7 @@
text-align: center;
}
.trade-wrapper{
.trade-wrapper {
text-align: center;
}
... ... @@ -93,7 +93,7 @@
}
.option-content {
/*width: 226px;*/
/* width: 226px; */
margin: 0 auto;
padding: 40px 0 20px;
display: inline-block;
... ... @@ -117,7 +117,8 @@
float: left;
margin-right: 20px;
margin-bottom: 10px;
&:last-child{
&:last-child {
margin-right: 0;
}
}
... ... @@ -140,7 +141,7 @@
cursor: pointer;
font-size: 14px;
&:last-child{
&:last-child {
margin-right: 0;
}
}
... ... @@ -291,6 +292,7 @@
.intro-text {
line-height: 2;
word-wrap: break-word;
}
}
... ...