Authored by hf

do fixes bug to home show floor data

@@ -11,27 +11,42 @@ class FloorProcess @@ -11,27 +11,42 @@ class FloorProcess
11 { 11 {
12 12
13 /** 13 /**
  14 + * 频道参数
  15 + *
  16 + * @var array
  17 + */
  18 + private static $channel = array(
  19 + '1' => '1,3',
  20 + '2' => '2,3'
  21 + );
  22 +
  23 + /**
14 * 处理首页内容 24 * 处理首页内容
15 * @param $data 25 * @param $data
16 * @param $type 类型 默认1:男首页 2:女首页 3:kids 4:lifestyle 26 * @param $type 类型 默认1:男首页 2:女首页 3:kids 4:lifestyle
17 */ 27 */
18 public static function getContent($data, $type = 1) 28 public static function getContent($data, $type = 1)
19 { 29 {
  30 + if (empty($data['list'])) {
  31 + return array();
  32 + }
  33 +
20 $result = array(); 34 $result = array();
21 - if (!empty($data['list'])) {  
22 - $build = array();  
23 - foreach ($data['list'] as $v) {  
24 - $fun = $v['template_name'];  
25 - if (!is_callable("self::$fun")) {  
26 - continue;  
27 - }  
28 - $build = self::$fun($v['data'], $type);  
29 - if (empty($build)) {  
30 - continue;  
31 - }  
32 - $result[] = $build; 35 +
  36 + $build = array();
  37 + foreach ($data['list'] as $v) {
  38 + $fun = $v['template_name'];
  39 + if (empty($v['data']) || !is_callable("self::$fun")) {
  40 + continue;
  41 + }
  42 + $build = self::$fun($v['data'], $type);
  43 + if (empty($build)) {
  44 + continue;
33 } 45 }
  46 + $result[] = $build;
34 } 47 }
  48 + $build = array();
  49 +
35 return $result; 50 return $result;
36 } 51 }
37 52
@@ -46,16 +61,35 @@ class FloorProcess @@ -46,16 +61,35 @@ class FloorProcess
46 $result = array(); 61 $result = array();
47 62
48 foreach ($data as &$one) { 63 foreach ($data as &$one) {
49 - $one['img'] = Helpers::getImageUrl($one['src'], 750, 364, 1); 64 + $one['url'] = Helpers::getFilterUrl($one['url']);
  65 + $one['img'] = Helpers::getImageUrl($one['src'], 640, 310);
  66 + unset($one['src']);
  67 + }
  68 + $result['bannerTop']['list'] = $data;
  69 +
  70 + return $result;
  71 + }
  72 +
  73 + /**
  74 + * 图标
  75 + */
  76 + private static function floor($data)
  77 + {
  78 + $result = array();
  79 +
  80 + foreach ($data as &$one) {
  81 + $one['url'] = Helpers::getFilterUrl($one['url']);
  82 + $one['img'] = Helpers::getImageUrl($one['src'], 98, 98);
50 unset($one['src']); 83 unset($one['src']);
51 } 84 }
52 - $result['list'] = $data; 85 + $result['iconsEnter']['list'] = $data;
53 86
54 - return array('bannerTop' => $result); 87 + return $result;
55 } 88 }
56 89
57 /** 90 /**
58 * 图标列表数据处理方法 91 * 图标列表数据处理方法
  92 + *
59 * @param array $data 图标列表数据 93 * @param array $data 图标列表数据
60 * @param $type 类型 默认1:男首页 2:女首页 3:kids 4:lifestyle 94 * @param $type 类型 默认1:男首页 2:女首页 3:kids 4:lifestyle
61 * @return array 处理之后的图标列表数据 95 * @return array 处理之后的图标列表数据
@@ -65,36 +99,66 @@ class FloorProcess @@ -65,36 +99,66 @@ class FloorProcess
65 $result = array(); 99 $result = array();
66 100
67 foreach ($data as &$one) { 101 foreach ($data as &$one) {
68 - $one['img'] = Helpers::getImageUrl($one['src'], 186, 203, 1); 102 + $one['url'] = Helpers::getFilterUrl($one['url']);
  103 + $one['img'] = Helpers::getImageUrl($one['src'], 98, 98);
69 unset($one['src']); 104 unset($one['src']);
70 } 105 }
71 - $result['list'] = $data; 106 + $result['iconsEnter']['list'] = $data;
72 107
73 - return array('iconsEnter' => $result); 108 + return $result;
74 } 109 }
75 110
76 /** 111 /**
77 - * 单图片数据处理方法 112 + * 单广告图片数据处理方法
  113 + *
78 * @param array $data 单图片数据 114 * @param array $data 单图片数据
79 * @param $type 类型 默认1:男首页 2:女首页 3:kids 4:lifestyle 115 * @param $type 类型 默认1:男首页 2:女首页 3:kids 4:lifestyle
80 * @return array 处理之后的单图片数据 116 * @return array 处理之后的单图片数据
81 */ 117 */
82 private static function single_image($data, $type) 118 private static function single_image($data, $type)
83 { 119 {
84 - if (empty($data)) {  
85 - return array();  
86 - }  
87 - 120 + $result = array();
  121 +
88 foreach ($data as &$one) { 122 foreach ($data as &$one) {
89 - $one['img'] = Helpers::getImageUrl($one['src'], 750, 364, 1); 123 + $one['url'] = Helpers::getFilterUrl($one['url']);
  124 + $one['img'] = Helpers::getImageUrl($one['src'], 640, 200);
90 unset($one['src']); 125 unset($one['src']);
91 } 126 }
  127 + $result['banner'] = $data;
  128 +
  129 + return $result;
  130 + }
  131 +
  132 + /**
  133 + * 女生品类
  134 + */
  135 + private static function recommend_content_three($data, $type)
  136 + {
  137 + $result = array();
  138 +
  139 + $build = array();
  140 + if (!empty($data['big_image'][0])) {
  141 + $build['img'] = Helpers::getImageUrl($data['big_image'][0]['src'], 640, 198);
  142 + $build['url'] = Helpers::getFilterUrl($data['big_image'][0]['url']);
  143 + $result['hotCategory']['banner'] = $build;
  144 + }
  145 +
  146 + $build = array();
  147 + foreach ($data['list'] as $one) {
  148 + $build['url'] = Helpers::getFilterUrl($one['url']);
  149 + $build['img'] = Helpers::getImageUrl($one['src'], 140, 140);
  150 + $build['textCn'] = $one['title'];
  151 + $result['hotCategory']['list'][] = $build;
  152 + }
  153 +
  154 +
92 155
93 - return array('banner' => $data); 156 + return $result;
94 } 157 }
95 158
96 /** 159 /**
97 * 带标题的12个小图推荐数据处理方法 160 * 带标题的12个小图推荐数据处理方法
  161 + *
98 * @param array $data 带标题的12个小图推荐数据 162 * @param array $data 带标题的12个小图推荐数据
99 * @param $type 类型 默认1:男首页 2:女首页 3:kids 4:lifestyle 163 * @param $type 类型 默认1:男首页 2:女首页 3:kids 4:lifestyle
100 * @return array 处理之后的带标题的12个小图推荐数据 164 * @return array 处理之后的带标题的12个小图推荐数据
@@ -104,15 +168,20 @@ class FloorProcess @@ -104,15 +168,20 @@ class FloorProcess
104 $result = array(); 168 $result = array();
105 169
106 foreach ($data['list'] as &$one) { 170 foreach ($data['list'] as &$one) {
107 - $one['img'] = Helpers::getImageUrl($one['src'], 186, 203, 1); 171 + if (isset($one['url'])) {
  172 + $one['url'] = Helpers::getFilterUrl($one['url']);
  173 + }
  174 + $one['img'] = Helpers::getImageUrl($one['src'], 140, 140);
  175 + $one['textCn'] = $one['title'];
108 unset($one['src']); 176 unset($one['src']);
109 } 177 }
110 $data['is_show_name'] = $data['title']['is_show']; 178 $data['is_show_name'] = $data['title']['is_show'];
111 $data['name'] = $data['title']['title']; 179 $data['name'] = $data['title']['title'];
112 unset($data['title']); 180 unset($data['title']);
113 - $result = $data;  
114 181
115 - return array('hotCategory' => $result); 182 + $result['hotCategory'] = $data;
  183 +
  184 + return $result;
116 } 185 }
117 186
118 /** 187 /**
@@ -125,16 +194,20 @@ class FloorProcess @@ -125,16 +194,20 @@ class FloorProcess
125 { 194 {
126 $result = array(); 195 $result = array();
127 196
128 - $data['is_show_name'] = (isset($data['is_show_name']) && $data['is_show_name'] == 'Y') ? 1 : 0; 197 + $data['is_show_name'] = (isset($data['is_show_name']) && $data['is_show_name'] === 'Y') ? 1 : 0;
129 $data['name'] = $data['title']['title']; 198 $data['name'] = $data['title']['title'];
130 unset($data['title']); 199 unset($data['title']);
131 foreach ($data['list'] as &$one) { 200 foreach ($data['list'] as &$one) {
132 - $one['img'] = Helpers::getImageUrl($one['src'], 186, 203, 1); 201 + if (isset($one['url'])) {
  202 + $one['url'] = Helpers::getFilterUrl($one['url']);
  203 + }
  204 + $one['img'] = Helpers::getImageUrl($one['src'], 158, 174);
133 unset($one['src']); 205 unset($one['src']);
134 } 206 }
135 - $result = $data; 207 + $data['more'] = '/category/brand/index?channel=' . $type;
  208 + $result['hotBrands'] = $data;
136 209
137 - return array('hotBrands' => $result); 210 + return $result;
138 } 211 }
139 212
140 /** 213 /**
@@ -148,16 +221,22 @@ class FloorProcess @@ -148,16 +221,22 @@ class FloorProcess
148 $result = array(); 221 $result = array();
149 222
150 foreach ($data['article'] as &$one) { 223 foreach ($data['article'] as &$one) {
151 - $one['img'] = Helpers::getImageUrl($one['src'], 186, 203, 1); 224 + if (isset($one['url'])) {
  225 + $one['url'] = Helpers::getFilterUrl($one['url']);
  226 + }
  227 + $one['img'] = Helpers::getImageUrl($one['src'], 400, 400);
152 unset($one['src']); 228 unset($one['src']);
153 } 229 }
154 foreach ($data['recommend_collocation'] as &$one) { 230 foreach ($data['recommend_collocation'] as &$one) {
155 - $one['img'] = Helpers::getImageUrl($one['src'], 186, 203, 1); 231 + if (isset($one['url'])) {
  232 + $one['url'] = Helpers::getFilterUrl($one['url']);
  233 + }
  234 + $one['img'] = Helpers::getImageUrl($one['src'], 140, 140);
156 unset($one['src']); 235 unset($one['src']);
157 } 236 }
158 - $result = $data; 237 + $result['trendColloaction'] = $data;
159 238
160 - return array('trendColloaction' => $result); 239 + return $result;
161 } 240 }
162 241
163 /** 242 /**
@@ -171,12 +250,15 @@ class FloorProcess @@ -171,12 +250,15 @@ class FloorProcess
171 $result = array(); 250 $result = array();
172 251
173 foreach ($data['list'] as &$one) { 252 foreach ($data['list'] as &$one) {
174 - $one['img'] = Helpers::getImageUrl($one['src'], 186, 203, 1); 253 + if (isset($one['url'])) {
  254 + $one['url'] = Helpers::getFilterUrl($one['url']);
  255 + }
  256 + $one['img'] = Helpers::getImageUrl($one['src'], 580, 360);
175 unset($one['src']); 257 unset($one['src']);
176 } 258 }
177 - $result = $data; 259 + $result['trendTopics'] = $data;
178 260
179 - return array('trendTopics' => $result); 261 + return $result;
180 } 262 }
181 263
182 /** 264 /**
@@ -190,19 +272,33 @@ class FloorProcess @@ -190,19 +272,33 @@ class FloorProcess
190 $result = array(); 272 $result = array();
191 273
192 foreach ($data['big_image'] as &$one) { 274 foreach ($data['big_image'] as &$one) {
193 - $one['img'] = Helpers::getImageUrl($one['src'], 186, 203, 1); 275 + if (isset($one['url'])) {
  276 + $one['url'] = Helpers::getFilterUrl($one['url']);
  277 + }
  278 + $one['img'] = Helpers::getImageUrl($one['src'], 640, 403);
194 unset($one['src']); 279 unset($one['src']);
195 } 280 }
196 $data['banner']['list'] = $data['big_image']; 281 $data['banner']['list'] = $data['big_image'];
197 - unset($data['big_image']);  
198 282
199 - foreach ($data['list'] as &$one) {  
200 - $one['img'] = Helpers::getImageUrl($one['src'], 186, 203, 1); 283 + foreach ($data['list'] as $kk => &$one) {
  284 + if ($kk == 0) {
  285 + $one['img'] = Helpers::getImageUrl($one['src'], 253, 383);
  286 + } else {
  287 + $one['img'] = Helpers::getImageUrl($one['src'], 191, 191);
  288 + }
  289 + if (isset($one['url'])) {
  290 + $one['url'] = Helpers::getFilterUrl($one['url']);
  291 + }
  292 + $one['textCn'] = $one['title'];
  293 +
201 unset($one['src']); 294 unset($one['src']);
202 } 295 }
203 - $result = $data;  
204 296
205 - return array('goodsCategory' => $result); 297 + unset($data['big_image']);
  298 +
  299 + $result['goodsCategory'] = $data;
  300 +
  301 + return $result;
206 } 302 }
207 303
208 /** 304 /**
@@ -217,19 +313,25 @@ class FloorProcess @@ -217,19 +313,25 @@ class FloorProcess
217 313
218 $data['banner'] = array(); 314 $data['banner'] = array();
219 foreach ($data['big_image'] as &$one) { 315 foreach ($data['big_image'] as &$one) {
220 - $one['img'] = Helpers::getImageUrl($one['src'], 186, 203, 1); 316 + if (isset($one['url'])) {
  317 + $one['url'] = Helpers::getFilterUrl($one['url']);
  318 + }
  319 + $one['img'] = Helpers::getImageUrl($one['src'], 640, 400);
221 unset($one['src']); 320 unset($one['src']);
222 } 321 }
223 $data['banner'] = $data['big_image']; 322 $data['banner'] = $data['big_image'];
224 unset($data['big_image']); 323 unset($data['big_image']);
225 324
226 foreach ($data['list'] as &$one) { 325 foreach ($data['list'] as &$one) {
227 - $one['img'] = Helpers::getImageUrl($one['src'], 186, 203, 1); 326 + if (isset($one['url'])) {
  327 + $one['url'] = Helpers::getFilterUrl($one['url']);
  328 + }
  329 + $one['img'] = Helpers::getImageUrl($one['src'], 212, 192);
228 unset($one['src']); 330 unset($one['src']);
229 } 331 }
230 - $result = $data; 332 + $result['creativeLife'] = $data;
231 333
232 - return array('creativeLife' => $result); 334 + return $result;
233 } 335 }
234 336
235 /** 337 /**
@@ -240,15 +342,21 @@ class FloorProcess @@ -240,15 +342,21 @@ class FloorProcess
240 */ 342 */
241 private static function small_pic($data, $type) 343 private static function small_pic($data, $type)
242 { 344 {
  345 + // 按照以前业务操作,不显示
  346 + return array();
  347 +
243 $result = array(); 348 $result = array();
244 349
245 foreach ($data as &$one) { 350 foreach ($data as &$one) {
246 - $one['img'] = Helpers::getImageUrl($one['src'], 186, 203, 1); 351 + if (isset($one['url'])) {
  352 + $one['url'] = Helpers::getFilterUrl($one['url']);
  353 + }
  354 + $one['img'] = Helpers::getImageUrl($one['src'], 98, 98);
247 unset($one['src']); 355 unset($one['src']);
248 } 356 }
249 - $result = $data; 357 + $result['small_pic'] = $data;
250 358
251 - return array('small_pic' => $result); 359 + return $result;
252 } 360 }
253 361
254 /** 362 /**
@@ -264,9 +372,47 @@ class FloorProcess @@ -264,9 +372,47 @@ class FloorProcess
264 } 372 }
265 373
266 $data['name'] = $data['title']; 374 $data['name'] = $data['title'];
267 - $data['img'] = Helpers::getImageUrl($data['src'], 640, 198, 2); 375 + $data['img'] = Helpers::getImageUrl($data['src'], 640, 198);
  376 + if (isset($data['url'])) {
  377 + $data['url'] = Helpers::getFilterUrl($data['url']);
  378 + }
268 379
269 return array('plusStar' => $data); 380 return array('plusStar' => $data);
270 } 381 }
271 382
  383 + /**
  384 + * 自定义品牌
  385 + *
  386 + * @param unknown $data
  387 + * @param mixed $type
  388 + * @return multitype:
  389 + */
  390 + private static function custom_brands($data, $type)
  391 + {
  392 + // URL附加参数
  393 + $param = '';
  394 + if (isset(self::$channel[$type])) {
  395 + $param = '/?gender=' . self::$channel[$type];
  396 + }
  397 +
  398 + $result = array();
  399 + $result['hotBrandsScroll']['name'] = $data['title']['title'];
  400 + foreach ($data['list'] as &$one) {
  401 + if (isset($one['url'])) {
  402 + $one['url'] = Helpers::getFilterUrl($one['url']);
  403 + }
  404 + $one['img'] = Helpers::getImageUrl($one['src'], 140, 140);
  405 + $one['textCn'] = $one['name'];
  406 + if (isset($one['url'])) {
  407 + $one['url'] .= $param;
  408 + }
  409 + }
  410 + if (!empty($data['is_show_name']) && $data['is_show_name'] == 'Y') {
  411 + $result['hotBrandsScroll']['is_show_name'] = true;
  412 + }
  413 + $result['hotBrandsScroll']['list'] = $data['list'];
  414 +
  415 + return $result;
  416 + }
  417 +
272 } 418 }
1 <div class="floor-header"> 1 <div class="floor-header">
2 <h2>{{name}}</h2> 2 <h2>{{name}}</h2>
3 </div> 3 </div>
  4 +
1 <div class="hot-category"> 1 <div class="hot-category">
2 -  
3 {{> home/floor_header}} 2 {{> home/floor_header}}
4 - 3 +
  4 + {{# banner}}
  5 + <a class="banner" href="{{url}}">
  6 + <img class="lazy" data-original="{{img}}">
  7 + </a>
  8 + {{/ banner}}
5 <ul class="category-list clearfix"> 9 <ul class="category-list clearfix">
6 {{# list}} 10 {{# list}}
7 <li> 11 <li>