...
|
...
|
@@ -2,14 +2,39 @@ |
|
|
* @Author: Targaryen
|
|
|
* @Date: 2017-03-23 11:02:31
|
|
|
* @Last Modified by: Targaryen
|
|
|
* @Last Modified time: 2017-03-28 14:50:20
|
|
|
* @Last Modified time: 2017-03-28 17:57:48
|
|
|
*/
|
|
|
/* 红人店铺数据处理 */
|
|
|
|
|
|
const _ = require('lodash');
|
|
|
const helpers = global.yoho.helpers;
|
|
|
|
|
|
let countCarouselImage = 0; // 轮播图模块统计
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 链接处理
|
|
|
* @param {*} linkParent
|
|
|
*/
|
|
|
const _linkhandle = (linkParent) => {
|
|
|
if (linkParent.linkType) {
|
|
|
switch (parseInt(linkParent.linkType, 10)) {
|
|
|
case 0:
|
|
|
return helpers.urlFormat('', {
|
|
|
categoryId: linkParent.resource
|
|
|
}, 'list');
|
|
|
case 1:
|
|
|
return helpers.urlFormat('/product/' + linkParent.resource + '.html');
|
|
|
case 2:
|
|
|
return linkParent.resource;
|
|
|
default:
|
|
|
break;
|
|
|
}
|
|
|
} else {
|
|
|
return false;
|
|
|
}
|
|
|
};
|
|
|
|
|
|
/**
|
|
|
* 图片处理
|
|
|
* @param {*} moduleData
|
...
|
...
|
@@ -19,7 +44,9 @@ const _picsHandle = (moduleData) => { |
|
|
|
|
|
_.forEach(_.get(moduleData, 'data', []), value => {
|
|
|
pics.push({
|
|
|
src: value.pic
|
|
|
src: value.pic,
|
|
|
link: _linkhandle(value),
|
|
|
text: value.text
|
|
|
});
|
|
|
});
|
|
|
return pics;
|
...
|
...
|
@@ -38,7 +65,8 @@ const _tools = { |
|
|
return {
|
|
|
module_type: 'Title',
|
|
|
text: _.get(moduleData, 'data[0].text', ''),
|
|
|
isModuleMargin: _.get(moduleData, 'properties.isModuleMargin', false)
|
|
|
isModuleMargin: _.get(moduleData, 'properties.isModuleMargin', 0),
|
|
|
link: _linkhandle(_.get(moduleData, 'data[0]', 0))
|
|
|
};
|
|
|
},
|
|
|
|
...
|
...
|
@@ -52,6 +80,7 @@ const _tools = { |
|
|
title: _.get(moduleData, 'data[0].text.title', ''),
|
|
|
content: _.get(moduleData, 'data[0].text.content', ''),
|
|
|
pic: _.get(moduleData, 'data[0].pic', ''),
|
|
|
isModuleMargin: _.get(moduleData, 'properties.isModuleMargin', 0),
|
|
|
};
|
|
|
},
|
|
|
|
...
|
...
|
@@ -60,11 +89,12 @@ const _tools = { |
|
|
* @param {*} moduleData
|
|
|
*/
|
|
|
carouselImage(moduleData) {
|
|
|
console.log(moduleData);
|
|
|
return {
|
|
|
module_type: 'CarouselImage',
|
|
|
num: countCarouselImage,
|
|
|
pics: _picsHandle(moduleData),
|
|
|
isModuleMargin: _.get(moduleData, 'properties.isModuleMargin', false),
|
|
|
isModuleMargin: Boolean(_.get(moduleData, 'properties.isModuleMargin', 0)),
|
|
|
};
|
|
|
},
|
|
|
|
...
|
...
|
@@ -82,7 +112,7 @@ const _tools = { |
|
|
width: _.get(moduleData, 'properties.width', ''),
|
|
|
height: _.get(moduleData, 'data[0].text', ''),
|
|
|
moduleHeight: _.get(moduleData, 'properties.moduleHeight', ''),
|
|
|
isModuleMargin: _.get(moduleData, 'properties.isModuleMargin', false),
|
|
|
isModuleMargin: _.get(moduleData, 'properties.isModuleMargin', 0),
|
|
|
};
|
|
|
},
|
|
|
|
...
|
...
|
@@ -94,7 +124,7 @@ const _tools = { |
|
|
return {
|
|
|
module_type: 'DoubleImage',
|
|
|
pics: _picsHandle(moduleData),
|
|
|
isModuleMargin: _.get(moduleData, 'properties.isModuleMargin', false),
|
|
|
isModuleMargin: _.get(moduleData, 'properties.isModuleMargin', 0),
|
|
|
};
|
|
|
},
|
|
|
|
...
|
...
|
@@ -103,12 +133,12 @@ const _tools = { |
|
|
* @param {*} moduleData
|
|
|
*/
|
|
|
tripleImage(moduleData) {
|
|
|
let displayType = _.get(moduleData, 'properties.displayType', 1);
|
|
|
let displayType = _.get(moduleData, 'properties.displayType', 0);
|
|
|
|
|
|
return {
|
|
|
module_type: 'TripleImage',
|
|
|
pics: _picsHandle(moduleData),
|
|
|
isModuleMargin: _.get(moduleData, 'properties.isModuleMargin', false),
|
|
|
isModuleMargin: _.get(moduleData, 'properties.isModuleMargin', 0),
|
|
|
displayType: parseInt(displayType, 10),
|
|
|
};
|
|
|
},
|
...
|
...
|
|