Authored by biao

update for accordion

... ... @@ -423,8 +423,6 @@ const getPreBrandTopData = (args, type) => {
data.preferenceBrands.imgBrand.push(o);
});
// data.preferenceBrands[type + 'Channel'] = true;
setChannelType(data.preferenceBrands, type);
return data;
... ... @@ -655,8 +653,6 @@ exports.getNewArrival = channel => {
let data = [],
result = [];
console.log(res);
_.forEach(sortList, (it, index) => {
if (res[index].data.product_list.length === sortList[index].viewNum) {
data = data.concat(res[index].data.product_list);
... ... @@ -671,6 +667,59 @@ exports.getNewArrival = channel => {
});
};
const getCategoryFloorData = args => {
const data = {
category: {
name: args[0].data.text,
navs: getNavs(args[1].data),
list: []
}
};
_.forEach(args[2].data, (it, index) => {
let obj = {};
obj.href = it.url;
obj.img = it.src;
// 设置图片大小
if (index === 1) {
obj.w = '377;';
obj.h = '504;';
} else {
obj.w = '185';
obj.h = '510';
}
data.category.list.push(obj);
});
return data;
};
const getAccordionFloorData = args => {
let data = {
accordion: {
name: args[0].data.text,
navs: getNavs(args[1].data),
slide: []
}
};
_.forEach(args[2].data, it => {
let obj = {};
obj.name = it.title;
obj.img = it.src;
obj.href = it.url;
data.accordion.slide.push(obj);
});
return data;
};
const requestContent = type => {
let data = sign.apiSign({
... ... @@ -694,6 +743,8 @@ const floorMap = {
优选品牌: getPreBrandTopData,
最新上架: getNewGoodsFloorData,
ad: getadbannerData,
category: getCategoryFloorData,
accordion: getAccordionFloorData,
debrisSlide: getDebrisSlide
};
... ... @@ -701,14 +752,14 @@ const processFloorData = (rawData, type) => {
let floorList = [];
_.forEach(rawData, (data, index) => {
let floorData;
let floorData = null;
if (data.template_name === 'recommend_content_three' ||
(data.template_intro === '焦点图' && index === 0)) {
(data.template_intro === '焦点图' && index === 0)) { // 处理banner
floorData = floorMap.slide.call(null, data.data);
} else if (data.template_intro === '热门品类') {
} else if (data.template_intro === '热门品类') { // 处理热门品类
floorData = floorMap.hot.call(null, rawData.slice(index, index + 2), type);
} else if (data.data.text) {
} else if (data.data.text) { // 处理一般楼层
let text = data.data.text.split(' ')[0];
const regResult = /\w+/.exec(text);
... ... @@ -718,10 +769,21 @@ const processFloorData = (rawData, type) => {
floorData = floorMap[text] &&
floorMap[text].call(null, rawData.slice(index, index + 6), type);
} else if (data.template_name === 'debrisSlider') {
} else if (data.template_name === 'debrisSlider') { // 处理girls的banner
floorData = floorMap.debrisSlide.call(null, data.data);
}
// 处理lifestyle分类楼层
if (!floorData && index + 3 < rawData.length && rawData[index + 1].template_name === 'textNav' &&
rawData[index + 2].template_name === 'floor' && rawData[index + 3].template_name === 'text') {
floorData = floorMap.category.call(null, rawData.slice(index, index + 4));
}
// 处理手风琴楼层
if (!floorData && index + 2 < rawData.length && rawData[index + 1].template_name === 'textNav' &&
rawData[index + 2].template_name === 'focus' && rawData[index + 3].template_name === 'text') {
floorData = floorMap.accordion.call(null, rawData.slice(index, index + 4));
}
if (!_.isNil(floorData)) {
_.isArray(floorData) ?
... ...
... ... @@ -135,6 +135,14 @@
{{/ recommend}}
{{#accordion}}
{{> slide-accordion}}
{{/accordion}}
{{# category}}
{{> category-floor}}
{{/ category}}
{{! 新品上架}}
{{# newArrivls}}
... ...
{{> floor-header}}
<div class="categorys-list imgopacity">
<ul class="clearfix">
{{# list}}
<li class="cate-item{{@index}}">
<a href="{{href}}" target= "_blank">
<img class="lazy" data-original="{{image img w h}}" alt="">
</a>
</li>
{{/ list}}
</ul>
</div>
... ...
{{> floor-header}}
<div class="slide-accordion clearfix">
<ul>
{{#each slide}}
<li><a title="{{name}}" href="{{href}}" target= "_blank"><div class="g-mask"></div><img class="lazy" data-original="{{image img 650 400}}"/></a></li>
{{/each}}
</ul>
</div>
... ...