Authored by 王水玲

商品详情页

... ... @@ -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) {
... ...
... ... @@ -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,17 +390,17 @@ 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;
}
... ...
... ... @@ -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 = {};
... ... @@ -91,14 +90,18 @@ const getProductItemData = (params, url, uid) => {
let resData = {};
let data = {};
result = camelCase(result.data);
// 如果status为0,即商品下架时则返回空对象
if (!result.status) {
if (!result.goodsList[0].status) {
return resData;
}
if (!result.productName &&
!result.erpProductId &&
!result.productPriceBo) {
!result.productSkn &&
!result.salesPrice &&
!result.marketPrice
) {
return resData;
}
... ... @@ -109,8 +112,8 @@ 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 => {
... ...