Authored by htoooth

健状性增强

... ... @@ -1033,26 +1033,17 @@ const _getSizeData = (sizeInfo) => {
* @param productId
*/
const _getProductModelCard = () => {
let result = [];
let data = _getCacheDataByName('ItemData::getProductModelCard');
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 || _.get(data, 'code', 400) !== 200) {
return [];
}
return result;
return _.get(data, 'data', []).map((value) => ({
url: helpers.getForceSourceUrl(value.modelImg),
size: value.size,
name: value.modelName
}));
};
/**
... ... @@ -1133,11 +1124,9 @@ const _getDetailDataBySizeInfo = (sizeInfo) => {
let details = '';
// 详情配图
if (_.get(sizeInfo, 'productIntroBo.productIntro', null)) {
if (_.get(sizeInfo, 'productIntroBo.phrase', null)) {
if (_.has(sizeInfo, 'productIntroBo.phrase')) {
details += `${sizeInfo.productDescBo.phrase}<br/>`;
}
}
// 图片换成懒加载方式
const replacePairs = {
... ... @@ -1207,42 +1196,35 @@ const _getProductModelTry = () => {
* @param sizeInfoBo
*/
const _getSizeAttrByMaxSortId = (maxSortId, sizeList) => {
let attributeIds = null;
if (_.isEmpty(sizeList)) {
return [];
}
// 不同分类,取得属性值不同
switch (maxSortId) {
case 1:
case 2:
attributeIds = [3, 4];
break;
case 3:
attributeIds = [6, 10];
break;
case 6:
attributeIds = [13];
break;
default:
attributeIds = [];
let attributeIds = (function(id) {
if (id === 1 && id === 2) {
return [3, 4];
} else if (id === 3) {
return [6, 10];
} else if (id === 6) {
return [13];
} else {
return [];
}
}(maxSortId));
let sizeInfos = [];
let attributeNames = {};
if (_.isEmpty(sizeList)) {
return sizeInfos;
}
// 获取属性名称
sizeList.sizeAttributeBos.forEach(size => {
_.get(sizeList, 'sizeAttributeBos', []).forEach((size) => {
attributeNames[size.id] = size.attributeName;
});
sizeList.sizeBoList.forEach(size => {
_.get(sizeList, 'sizeBoList', []).forEach((size) => {
let sizeValues = [];
size.sortAttributes.forEach(sort => {
_.get(size, 'sortAttributes', []).forEach((sort) => {
if (_.includes(attributeIds, sort.id)) {
if (sort.sizeValue) {
sizeValues.push(
... ... @@ -1270,16 +1252,18 @@ const _getSizeAttrByMaxSortId = (maxSortId, sizeList) => {
* @return object
*/
const _getSizeInfo = (productSkn, maxSortId)=> {
let result = {};
if (!productSkn) {
return {};
}
if (productSkn) {
// 并发资源中是否存在数据
let sizeInfo = _getCacheDataByName('ItemData::sizeInfo');
if (!sizeInfo) {
return result;
if (_.isEmpty(sizeInfo)) {
return {};
}
let result = {};
// 描述数据
result.description = _getDescriptionDataBySizeInfo(sizeInfo);
... ... @@ -1312,7 +1296,6 @@ const _getSizeInfo = (productSkn, maxSortId)=> {
// 获取尺寸说明
result.sizeTitleJson =
sizeInfo.sizeInfoBo ? JSON.stringify(_getSizeAttrByMaxSortId(maxSortId, sizeInfo.sizeInfoBo)) : '';
}
return result;
};
... ...