Merge branch 'feature/channel' into release/4.5
Showing
9 changed files
with
164 additions
and
7 deletions
@@ -18,6 +18,7 @@ class CacheConfig | @@ -18,6 +18,7 @@ class CacheConfig | ||
18 | const KEY_ACTION_GIRLS_INDEX = 'key_action_girls_index'; // 女生首页 | 18 | const KEY_ACTION_GIRLS_INDEX = 'key_action_girls_index'; // 女生首页 |
19 | const KEY_ACTION_KIDS_INDEX = 'key_action_kids_index'; // 潮童首页 | 19 | const KEY_ACTION_KIDS_INDEX = 'key_action_kids_index'; // 潮童首页 |
20 | const KEY_ACTION_LIFESTYLE_INDEX = 'key_action_lifestyle_index'; // 创意生活首页 | 20 | const KEY_ACTION_LIFESTYLE_INDEX = 'key_action_lifestyle_index'; // 创意生活首页 |
21 | + const KEY_ACTION_CHANNEL_INDEX = 'key_action_channel_index';//日韩馆 | ||
21 | 22 | ||
22 | const KEY_ACTION_INDEX_CONFIG = 'key_action_index_config'; // 频道配置 | 23 | const KEY_ACTION_INDEX_CONFIG = 'key_action_index_config'; // 频道配置 |
23 | 24 |
library/LibModels/Wap/Home/ChannelData.php
0 → 100644
1 | +<?php | ||
2 | +/** | ||
3 | + * Created by PhpStorm. | ||
4 | + * User: Administrator | ||
5 | + * Date: 2016-5-3 | ||
6 | + * Time: 10:41 | ||
7 | + */ | ||
8 | + | ||
9 | +namespace LibModels\Wap\Home; | ||
10 | + | ||
11 | +use Api\Yohobuy; | ||
12 | +use Api\Sign; | ||
13 | + | ||
14 | + | ||
15 | +class ChannelData | ||
16 | +{ | ||
17 | + //日韩馆调取资源位 | ||
18 | + public static function getChannelData($contentCode) | ||
19 | + { | ||
20 | + $param = Yohobuy::param(); | ||
21 | + $param['content_code'] = $contentCode; | ||
22 | + $param['client_secret'] = Sign::getSign($param); | ||
23 | + | ||
24 | + return Yohobuy::get(Yohobuy::SERVICE_URL . 'operations/api/v5/resource/get', $param); | ||
25 | + | ||
26 | + } | ||
27 | + | ||
28 | +} |
@@ -213,7 +213,20 @@ class FloorProcess | @@ -213,7 +213,20 @@ class FloorProcess | ||
213 | $one['img'] = Helpers::getImageUrl($one['src'], 158, 174); | 213 | $one['img'] = Helpers::getImageUrl($one['src'], 158, 174); |
214 | unset($one['src']); | 214 | unset($one['src']); |
215 | } | 215 | } |
216 | - $data['more'] = '/brands?channel=' . $type; | 216 | + |
217 | + $data['moreImg'] = array( | ||
218 | + 'alt' => '', | ||
219 | + 'src' => 'http://cdn.yoho.cn/myohobuy/assets/img/more-brand.png', | ||
220 | + 'url' => '/brands?channel=' . $type, | ||
221 | + ); | ||
222 | + if (isset($data['image'])) { | ||
223 | + $data['moreImg'] = array( | ||
224 | + 'alt' => $data['image']['alt'], | ||
225 | + 'src' => Helpers::getImageUrl($data['image']['src'], 320, 172), | ||
226 | + 'url' =>$data['image']['url'], | ||
227 | + ); | ||
228 | + } | ||
229 | + | ||
217 | $result['hotBrands'] = $data; | 230 | $result['hotBrands'] = $data; |
218 | 231 | ||
219 | return $result; | 232 | return $result; |
@@ -67,14 +67,12 @@ | @@ -67,14 +67,12 @@ | ||
67 | width: 317px; | 67 | width: 317px; |
68 | height: 174px; | 68 | height: 174px; |
69 | border-top: 1px solid #e0e0e0; | 69 | border-top: 1px solid #e0e0e0; |
70 | - | 70 | + overflow: hidden; |
71 | 71 | ||
72 | a { | 72 | a { |
73 | display: block; | 73 | display: block; |
74 | width: 100%; | 74 | width: 100%; |
75 | height: 100%; | 75 | height: 100%; |
76 | - background: resolve("more-brand.png") no-repeat; | ||
77 | - background-size: 100% 100%; | ||
78 | } | 76 | } |
79 | } | 77 | } |
80 | } | 78 | } |
1 | +{{> layout/header}} | ||
2 | +<div class="mobile-wrap boys-wrap yoho-page"> | ||
3 | + {{! 首页header}} | ||
4 | + {{# homeHeader}} | ||
5 | + {{> home/home_header}} | ||
6 | + {{/ homeHeader}} | ||
7 | + | ||
8 | + {{> home/content}} | ||
9 | + | ||
10 | + {{! 商品列表}} | ||
11 | + {{# twoColumnGoods}} | ||
12 | + {{> home/two_column_goods}} | ||
13 | + {{/ twoColumnGoods}} | ||
14 | +</div> | ||
15 | +{{> layout/footer}} |
@@ -10,7 +10,9 @@ | @@ -10,7 +10,9 @@ | ||
10 | </a> | 10 | </a> |
11 | </li> | 11 | </li> |
12 | {{/ list}} | 12 | {{/ list}} |
13 | - <li class="more"> | ||
14 | - <a href="{{more}}"></a> | ||
15 | - </li> | 13 | + {{# moreImg}} |
14 | + <li class="more"> | ||
15 | + <a href="{{url}}"><img src="{{src}}" alt="{{alt}}"></a> | ||
16 | + </li> | ||
17 | + {{/ moreImg}} | ||
16 | </ul> | 18 | </ul> |
@@ -150,6 +150,13 @@ | @@ -150,6 +150,13 @@ | ||
150 | seajs.use('js/index/footer'); | 150 | seajs.use('js/index/footer'); |
151 | </script> | 151 | </script> |
152 | {{/if}} | 152 | {{/if}} |
153 | +{{!-- 二级频道 --}} | ||
154 | +{{#if secondChannelPage}} | ||
155 | +<script> | ||
156 | + seajs.use('js/home/home'); | ||
157 | + seajs.use('js/index/footer'); | ||
158 | +</script> | ||
159 | +{{/if}} | ||
153 | {{!-- 新品到着 --}} | 160 | {{!-- 新品到着 --}} |
154 | {{#if newArrivalPage}} | 161 | {{#if newArrivalPage}} |
155 | <script> | 162 | <script> |
1 | +<?php | ||
2 | + | ||
3 | +use Action\AbstractAction; | ||
4 | +use Index\ChannelModel; | ||
5 | +use Plugin\Helpers; | ||
6 | + | ||
7 | +class ChannelController extends AbstractAction | ||
8 | +{ | ||
9 | + /** | ||
10 | + * 日韩馆 | ||
11 | + */ | ||
12 | + public function indexAction() | ||
13 | + { | ||
14 | + // 设置网站标题 | ||
15 | + $this->setTitle('日韩馆'); // 需求是标题可以自定义 | ||
16 | + $this->setNavHeader('日韩馆', true, false); // 需求是标题可以自定义 | ||
17 | + | ||
18 | + $content = ChannelModel::getChannelFloor(); | ||
19 | + | ||
20 | + // 渲染模板并输出 | ||
21 | + $this->_view->display('index', array( | ||
22 | + 'secondChannelPage' => true, | ||
23 | + 'maybeLike' => true, | ||
24 | + 'content' => $content, | ||
25 | + 'pageFooter' => true, | ||
26 | + )); | ||
27 | + } | ||
28 | + | ||
29 | +} |
1 | +<?php | ||
2 | +/** | ||
3 | + * Created by PhpStorm. | ||
4 | + * User: Administrator | ||
5 | + * Date: 2016-5-3 | ||
6 | + * Time: 10:34 | ||
7 | + */ | ||
8 | + | ||
9 | +namespace Index; | ||
10 | + | ||
11 | +use LibModels\Wap\Home\ChannelData; | ||
12 | +use LibModels\Wap\Home\IndexData; | ||
13 | +use Plugin\Helpers; | ||
14 | +use Plugin\Cache; | ||
15 | +use Plugin\DataProcess\FloorProcess; | ||
16 | +use Configs\CacheConfig; | ||
17 | + | ||
18 | + | ||
19 | +class ChannelModel | ||
20 | +{ | ||
21 | + | ||
22 | + const CODE_FLOOR_JCSHOP = 'cdcc581da92a13c74e3bf1826f1806d1'; | ||
23 | + | ||
24 | + /** | ||
25 | + * 获取男生首页的楼层数据 | ||
26 | + * | ||
27 | + * @return array | false | ||
28 | + */ | ||
29 | + public static function getChannelFloor() | ||
30 | + { | ||
31 | + $result = array(); | ||
32 | + | ||
33 | + if (USE_CACHE) { | ||
34 | + // 先尝试获取一级缓存(master), 有数据则直接返回. | ||
35 | + $result = Cache::get(CacheConfig::KEY_ACTION_CHANNEL_INDEX, 'master'); | ||
36 | + if (!empty($result)) { | ||
37 | + return $result; | ||
38 | + } | ||
39 | + } | ||
40 | + | ||
41 | + // 调用接口获取楼层数据, 并封装成模板渲染需要的数据格式 | ||
42 | + $channelData = ChannelData::getChannelData(self::CODE_FLOOR_JCSHOP); | ||
43 | + | ||
44 | + if (isset($channelData['code']) && $channelData['code'] == 200) { | ||
45 | + $channelData = array( | ||
46 | + 'list'=>$channelData['data'] | ||
47 | + ); | ||
48 | + $result = FloorProcess::getContent($channelData); | ||
49 | + } | ||
50 | + | ||
51 | + if (USE_CACHE) { | ||
52 | + // 接口调用异常时, 不害怕,从我们的二级缓存(slave)里再取数据. | ||
53 | + if (empty($result)) { | ||
54 | + $result = Cache::get(CacheConfig::KEY_ACTION_CHANNEL_INDEX, 'slave'); | ||
55 | + } | ||
56 | + // 接口调用正常,数据封装完成, 则设置一级(master)和二级(slave)数据缓存 | ||
57 | + else { | ||
58 | + Cache::set(CacheConfig::KEY_ACTION_CHANNEL_INDEX, $result); | ||
59 | + } | ||
60 | + } | ||
61 | + | ||
62 | + return $result; | ||
63 | + } | ||
64 | +} |
-
Please register or login to post a comment