Authored by liangxs

热门品类楼层完成

@@ -25,7 +25,7 @@ app.engine('.hbs', hbs({ @@ -25,7 +25,7 @@ app.engine('.hbs', hbs({
25 defaultLayout: 'layout', 25 defaultLayout: 'layout',
26 layoutsDir: doraemon, 26 layoutsDir: doraemon,
27 partialsDir: [`${partials}/partials`, `${doraemon}/partial`], 27 partialsDir: [`${partials}/partials`, `${doraemon}/partial`],
28 - helpers: 'helpers' 28 + helpers: require('../../library/helpers')
29 })); 29 }));
30 30
31 // router 31 // router
@@ -90,19 +90,20 @@ const getNewReportFloorData = data => { @@ -90,19 +90,20 @@ const getNewReportFloorData = data => {
90 const getHotGoodsFloorData = data => { 90 const getHotGoodsFloorData = data => {
91 let list = []; 91 let list = [];
92 92
93 - _.forEach(data, (item) => { 93 + _.forEach(data, (item, index) => {
94 if (item.template_intro === '热门品类') { 94 if (item.template_intro === '热门品类') {
95 let object = {}, 95 let object = {},
96 keyword = [], 96 keyword = [],
97 category = [], 97 category = [],
98 brands = [], 98 brands = [],
99 - types = []; 99 + types = [],
  100 + navs = {},
  101 + products = [];
100 102
101 - // product = [];  
102 // console.log(item.data); 103 // console.log(item.data);
103 // console.log(item.data.menuNav); 104 // console.log(item.data.menuNav);
104 // console.log(item.data.navs); 105 // console.log(item.data.navs);
105 - // return false; 106 +
106 107
107 _.forEach(item.data.menuNav.list, (it) => { 108 _.forEach(item.data.menuNav.list, (it) => {
108 let obj = {}; 109 let obj = {};
@@ -121,24 +122,39 @@ const getHotGoodsFloorData = data => { @@ -121,24 +122,39 @@ const getHotGoodsFloorData = data => {
121 keyword.push(obj); 122 keyword.push(obj);
122 }); 123 });
123 124
124 - _.forEach(item.data.imgs, (it, index) => { 125 + _.forEach(item.data.imgs, (it, idx) => {
125 let obj = {}; 126 let obj = {};
126 127
127 obj.name = it.title; 128 obj.name = it.title;
128 obj.href = it.url; 129 obj.href = it.url;
129 obj.img = it.img; 130 obj.img = it.img;
130 131
131 - if (index < 2) { 132 + if (idx === 0 || idx === 4) {
132 brands.push(obj); 133 brands.push(obj);
133 } else { 134 } else {
134 types.push(obj); 135 types.push(obj);
135 } 136 }
136 }); 137 });
137 138
  139 + _.forEach(data[index + 1].data, (it) => {
  140 + let obj = {};
  141 +
  142 + obj.name = it.title;
  143 + obj.href = it.url;
  144 + obj.img = it.src;
  145 +
  146 + products.push(obj);
  147 + });
  148 +
  149 + navs.name = item.data.navs.list[0].name;
  150 + navs.href = item.data.navs.list[0].url;
  151 + object.name = item.data.name;
138 object.keyword = keyword; 152 object.keyword = keyword;
139 object.category = category; 153 object.category = category;
140 object.brands = brands; 154 object.brands = brands;
141 object.types = types; 155 object.types = types;
  156 + object.navs = navs;
  157 + object.products = products;
142 list.push(object); 158 list.push(object);
143 } 159 }
144 }); 160 });
@@ -188,7 +204,8 @@ exports.getContent = (type) => { @@ -188,7 +204,8 @@ exports.getContent = (type) => {
188 data.recommend = { 204 data.recommend = {
189 tplrecommend: getHotGoodsFloorData(contentData.list) 205 tplrecommend: getHotGoodsFloorData(contentData.list)
190 }; 206 };
191 - console.log(data.newReport); 207 +
  208 + // console.log(contentData.list);
192 return data; 209 return data;
193 }); 210 });
194 }; 211 };
@@ -5,7 +5,7 @@ @@ -5,7 +5,7 @@
5 <div class="tpl-nav"> 5 <div class="tpl-nav">
6 <div class="tpl-keywords"> 6 <div class="tpl-keywords">
7 {{#each keyword}} 7 {{#each keyword}}
8 - <a class="keywords{{@index}}" title="{{name}}" href="{{href}}" target= "_blank"><img class="lazy" data-original="{{img}}"/></a> 8 + <a class="keywords{{@index}}" title="{{name}}" href="{{href}}" target= "_blank"><img class="lazy" src="{{image img 185 152}}"/></a>
9 {{/each}} 9 {{/each}}
10 </div> 10 </div>
11 <div class="tpl-category clearfix"> 11 <div class="tpl-category clearfix">
@@ -17,14 +17,14 @@ @@ -17,14 +17,14 @@
17 <div class="tpl-brands imgopacity clearfix"> 17 <div class="tpl-brands imgopacity clearfix">
18 <ul> 18 <ul>
19 {{#each brands}} 19 {{#each brands}}
20 - <li><a title="{{name}}" href="{{href}}" target= "_blank"><img class="lazy" data-original="{{img img 100 100}}"/></a></li> 20 + <li><a title="{{name}}" href="{{href}}" target= "_blank"><img class="lazy" src="{{image img 378 248}}"/></a></li>
21 {{/each}} 21 {{/each}}
22 </ul> 22 </ul>
23 </div> 23 </div>
24 <div class="tpl-types imgopacity clearfix"> 24 <div class="tpl-types imgopacity clearfix">
25 <ul> 25 <ul>
26 {{#each types}} 26 {{#each types}}
27 - <li><a title="{{name}}" href="{{href}}" target= "_blank"><img class="lazy" data-original="{{img}}"/></a></li> 27 + <li><a title="{{name}}" href="{{href}}" target= "_blank"><img class="lazy" src="{{image img 185 248}}"/></a></li>
28 {{/each}} 28 {{/each}}
29 </ul> 29 </ul>
30 </div> 30 </div>
@@ -32,7 +32,7 @@ @@ -32,7 +32,7 @@
32 <div class="tpl-products imgopacity clearfix"> 32 <div class="tpl-products imgopacity clearfix">
33 <ul> 33 <ul>
34 {{#each products}} 34 {{#each products}}
35 - <li><a href="{{href}}" title="{{name}}" target= "_blank"><img class="lazy" data-original="{{img}}"/></a></li> 35 + <li><a href="{{href}}" title="{{name}}" target= "_blank"><img class="lazy" src="{{image img 222 298}}"/></a></li>
36 {{/each}} 36 {{/each}}
37 </ul> 37 </ul>
38 </div> 38 </div>