update for re-orgnise the channel page code. code review by HongFei
Showing
3 changed files
with
62 additions
and
2 deletions
@@ -67,5 +67,17 @@ class IndexData | @@ -67,5 +67,17 @@ class IndexData | ||
67 | 67 | ||
68 | return Yohobuy::get(Yohobuy::SERVICE_URL . 'operations/api/v5/resource/home', $param); | 68 | return Yohobuy::get(Yohobuy::SERVICE_URL . 'operations/api/v5/resource/home', $param); |
69 | } | 69 | } |
70 | + | ||
71 | + /** | ||
72 | + * 获取频道选择页数据 | ||
73 | + * | ||
74 | + * @return array | ||
75 | + */ | ||
76 | + public static function channelData() | ||
77 | + { | ||
78 | + $param = Yohobuy::param(); | ||
79 | + $param['client_secret'] = Sign::getSign($param); | ||
80 | + return Yohobuy::get(Yohobuy::SERVICE_URL . 'operations/api/v5/entrance/getEntrance',$param,3600); | ||
81 | + } | ||
70 | 82 | ||
71 | } | 83 | } |
1 | <?php | 1 | <?php |
2 | 2 | ||
3 | use Action\AbstractAction; | 3 | use Action\AbstractAction; |
4 | -use Index\IndexModel; | ||
5 | use Plugin\Helpers; | 4 | use Plugin\Helpers; |
6 | 5 | ||
7 | /** | 6 | /** |
@@ -24,7 +23,7 @@ class IndexController extends AbstractAction | @@ -24,7 +23,7 @@ class IndexController extends AbstractAction | ||
24 | // 设置浏览器缓存5分钟 | 23 | // 设置浏览器缓存5分钟 |
25 | $this->setExpires(300); | 24 | $this->setExpires(300); |
26 | } | 25 | } |
27 | - $result = IndexModel::getChannel(); | 26 | + $result = Index\HomeModel::getChannel(); |
28 | $result['background'] = Index\HomeModel::getBgImage(); | 27 | $result['background'] = Index\HomeModel::getBgImage(); |
29 | $result['channelPage'] = true; | 28 | $result['channelPage'] = true; |
30 | $result['showDownloadApp'] = true; | 29 | $result['showDownloadApp'] = true; |
@@ -318,5 +318,54 @@ class HomeModel | @@ -318,5 +318,54 @@ class HomeModel | ||
318 | 318 | ||
319 | return $result; | 319 | return $result; |
320 | } | 320 | } |
321 | + | ||
322 | + /** | ||
323 | + * 获取频道选择页数据 | ||
324 | + * | ||
325 | + * @return array | ||
326 | + */ | ||
327 | + public static function getChannel(){ | ||
328 | + $result = array(); | ||
329 | + $result['showYohood'] = false; | ||
330 | + | ||
331 | + $data = IndexData::channelData(); | ||
332 | + | ||
333 | + $channelList = array(); | ||
334 | + if($data['code'] == 200 && isset($data['data']['list'])){ | ||
335 | + foreach($data['data']['list'] as $key => $value){ | ||
336 | + switch ($value['channel_id']) { | ||
337 | + case 5: | ||
338 | + $result['showYohood'] = true; | ||
339 | + $result['yohoodHref'] = '/yohood'; | ||
340 | + break; | ||
341 | + case 1: | ||
342 | + $channelList[$key]['href'] = '/boys'; | ||
343 | + $channelList[$key]['title'] = '男生'; | ||
344 | + $channelList[$key]['entitle'] = 'BOYS'; | ||
345 | + break; | ||
346 | + case 2: | ||
347 | + $channelList[$key]['href'] = '/girls'; | ||
348 | + $channelList[$key]['title'] = '女生'; | ||
349 | + $channelList[$key]['entitle'] = 'GIRLS'; | ||
350 | + break; | ||
351 | + case 3: | ||
352 | + $channelList[$key]['href'] = '/kids'; | ||
353 | + $channelList[$key]['title'] = '潮童'; | ||
354 | + $channelList[$key]['entitle'] = 'KIDS'; | ||
355 | + break; | ||
356 | + case 4: | ||
357 | + $channelList[$key]['href'] = '/lifestyle'; | ||
358 | + $channelList[$key]['title'] = '创意生活'; | ||
359 | + $channelList[$key]['entitle'] = 'LIFESTYLE'; | ||
360 | + break; | ||
361 | + default: | ||
362 | + break; | ||
363 | + } | ||
364 | + } | ||
365 | + $result['channelList'] = $channelList; | ||
366 | + } | ||
367 | + | ||
368 | + return $result; | ||
369 | + } | ||
321 | 370 | ||
322 | } | 371 | } |
-
Please register or login to post a comment