Authored by cailing

update

... ... @@ -86,6 +86,59 @@ const getNewReportFloorData = data => {
return list;
};
//人气单品
const getSingleHotFloorData = data => {
let list = [];
_.forEach(data, (item, index) => {
let len = 10;
if (item.data.text === '人气单品') {
for (let i = 0; i < len; i ++) {
let pos = i;
let val = {};
let obj = {};
if (i == 1) {
val = data[index + 1].data[0]; // 第二个是大图
}
else if (i == len - 1) {
val = data[index + 1].data[1]; // 最后一个是大图
}
else {
if (pos > 1) { // 小图
pos = pos - 1;
}
val = data[index + 2].data[pos];
}
obj.href = val.url;
obj.img = val.src;
list.push(obj);
}
}
});
return list;
};
const getadbannerData = data => {
let adbanner = [];
let temp = [];
let obj = {};
_.forEach(data, (item, index) => {
if(item.template_name === 'single_image'){
temp.push(item);
}
})
console.log(temp);
obj.href = temp[2].data[0].url;
obj.img = temp[2].data[0].src;
obj.name = temp[2].data[0].title;
adbanner.push(obj);
return adbanner;
}
const requestContent = (type) => {
let data = sign.apiSign({
/* eslint-disable */
... ... @@ -124,6 +177,14 @@ exports.getContent = (type) => {
name: '最新速报',
list: getNewReportFloorData(contentData.list)
};
data.singlehot = {
name: '人气单品',
imgHot: getSingleHotFloorData(contentData.list)
};
//广告
data.adbanner = getadbannerData(contentData.list);
... ...
... ... @@ -74,7 +74,7 @@
{{! 广告}}
{{# adbanner}}
<div class="floor-ad">
<a href="{{href}}" target= "_blank"><img class="lazy" data-original="{{img}}"/></a>
<a href="{{href}}" target= "_blank"><img class="lazy" data-original="{{image img 1150 129}}"/></a>
</div>
{{/ adbanner}}
... ...
<div class="singlehot clearfix">
{{> index/floor-header}}
<ul class="g-list imgopacity">
{{#each imgHot}}
{{#if @last}}
<li><a class="impo{{@index}}" href="{{href}}" target= "_blank"><img class="lazy" src="{{image img 378 248}}"/></a></li>
{{^}}
<li><a class="impo{{@index}}" href="{{href}}" target= "_blank"><img class="lazy" src="{{image img 185 248}}"/></a></li>
{{/if}}
{{/each}}
</ul>
</div>
... ...
<div class="floor-header clearfix">
<h2 class="floor-title">{{name}}</h2>
{{#if navs}}
<ul class="header-navs">
{{# navs}}
<li data-classify="{{id}}">
<a target="_blank" href="{{href}}">{{name}}</a>
</li>
{{/ navs}}
</ul>
{{/if}}
</div>
\ No newline at end of file
... ...