Showing
4 changed files
with
114 additions
and
0 deletions
@@ -18,6 +18,9 @@ class CacheConfig | @@ -18,6 +18,9 @@ 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 | + | ||
22 | + const KEY_ACTION_BOYS_BOTTOM_BANNER = 'key_action_boys_bottom_banner'; // 男生首页底部banner | ||
23 | + const KEY_ACTION_GRILS_BOTTOM_BANNER = 'key_action_girls_bottom_banner';// 女生首页底部banner | ||
21 | 24 | ||
22 | const KEY_ACTION_GUANG_PLUSSTAR_INDEX = 'key_action_guang_plusstar_index'; // 国际优选 | 25 | const KEY_ACTION_GUANG_PLUSSTAR_INDEX = 'key_action_guang_plusstar_index'; // 国际优选 |
23 | const KEY_ACTION_GUANG_PLUSSTAR_LIST = 'key_action_guang_plusstar_list'; // 明星原创 | 26 | const KEY_ACTION_GUANG_PLUSSTAR_LIST = 'key_action_guang_plusstar_list'; // 明星原创 |
1 | <?php | 1 | <?php |
2 | 2 | ||
3 | use Action\AbstractAction; | 3 | use Action\AbstractAction; |
4 | +use Plugin\Helpers; | ||
4 | 5 | ||
5 | /** | 6 | /** |
6 | * 男生首页 | 7 | * 男生首页 |
@@ -34,4 +35,31 @@ class BoysController extends AbstractAction | @@ -34,4 +35,31 @@ class BoysController extends AbstractAction | ||
34 | 35 | ||
35 | } | 36 | } |
36 | 37 | ||
38 | + | ||
39 | + /** | ||
40 | + * 异步获取男首底部banner数据 | ||
41 | + * @return string 底部Banner数据 | ||
42 | + */ | ||
43 | + public function bottomBannerAction() | ||
44 | + { | ||
45 | + do | ||
46 | + { | ||
47 | + if(!$this->isAjax()) | ||
48 | + { | ||
49 | + break; | ||
50 | + } | ||
51 | + | ||
52 | + $channel = Helpers::getChannelByCookie(); | ||
53 | + $bottomBanner = Index\HomeModel::getBottomBanner($channel); | ||
54 | + | ||
55 | + if($bottomBanner) | ||
56 | + { | ||
57 | + $this->echoJson($bottomBanner); | ||
58 | + } | ||
59 | + } | ||
60 | + while(false); | ||
61 | + | ||
62 | + echo ' '; | ||
63 | + } | ||
64 | + | ||
37 | } | 65 | } |
1 | <?php | 1 | <?php |
2 | 2 | ||
3 | use Action\AbstractAction; | 3 | use Action\AbstractAction; |
4 | +use Plugin\Helpers; | ||
4 | 5 | ||
5 | /** | 6 | /** |
6 | * 女生首页 | 7 | * 女生首页 |
@@ -33,4 +34,31 @@ class GirlsController extends AbstractAction | @@ -33,4 +34,31 @@ class GirlsController extends AbstractAction | ||
33 | )); | 34 | )); |
34 | } | 35 | } |
35 | 36 | ||
37 | + | ||
38 | + /** | ||
39 | + * 异步获取女首底部banner数据 | ||
40 | + * @return string 底部Banner数据 | ||
41 | + */ | ||
42 | + public function bottomBannerAction() | ||
43 | + { | ||
44 | + do | ||
45 | + { | ||
46 | + if(!$this->isAjax()) | ||
47 | + { | ||
48 | + break; | ||
49 | + } | ||
50 | + | ||
51 | + $channel = Helpers::getChannelByCookie(); | ||
52 | + $bottomBanner = Index\HomeModel::getBottomBanner($channel); | ||
53 | + | ||
54 | + if($bottomBanner) | ||
55 | + { | ||
56 | + $this->echoJson($bottomBanner); | ||
57 | + } | ||
58 | + } | ||
59 | + while(false); | ||
60 | + | ||
61 | + echo ' '; | ||
62 | + } | ||
63 | + | ||
36 | } | 64 | } |
@@ -45,6 +45,11 @@ class HomeModel | @@ -45,6 +45,11 @@ class HomeModel | ||
45 | /* COOKIE标识访问的是创意生活频道 */ | 45 | /* COOKIE标识访问的是创意生活频道 */ |
46 | const COOKIE_NAME_LIFESTYLE = 'lifestyle'; | 46 | const COOKIE_NAME_LIFESTYLE = 'lifestyle'; |
47 | 47 | ||
48 | + /* COOKIE标识访问的是男生频道底部Banner */ | ||
49 | + const COOKIE_NAME_BOYS_BOTTOM_BANNER = '8c48745a39373d621bf5fd80edf59b5e'; | ||
50 | + /* COOKIE标识访问的是女生频道频道底部Banner */ | ||
51 | + const COOKIE_NAME_GIRLS_BOTTOM_BANNER = 'c63939b2ad458e9cb51147940c1da2e5'; | ||
52 | + | ||
48 | /** | 53 | /** |
49 | * 选择频道 | 54 | * 选择频道 |
50 | * | 55 | * |
@@ -112,6 +117,56 @@ class HomeModel | @@ -112,6 +117,56 @@ class HomeModel | ||
112 | } | 117 | } |
113 | 118 | ||
114 | /** | 119 | /** |
120 | + * 获取男生,女生底部banner | ||
121 | + * | ||
122 | + * @return string | false | ||
123 | + */ | ||
124 | + public static function getBottomBanner($channel) | ||
125 | + { | ||
126 | + $result = false; | ||
127 | + if($channel == 2) { | ||
128 | + $resource = self::COOKIE_NAME_GIRLS_BOTTOM_BANNER; | ||
129 | + $cache = CacheConfig::KEY_ACTION_GRILS_BOTTOM_BANNER; | ||
130 | + } else { | ||
131 | + $resource = self::COOKIE_NAME_BOYS_BOTTOM_BANNER; | ||
132 | + $cache = CacheConfig::KEY_ACTION_BOYS_BOTTOM_BANNER; | ||
133 | + } | ||
134 | + | ||
135 | + if (USE_CACHE) { | ||
136 | + // 先尝试获取一级缓存(master), 有数据则直接返回. | ||
137 | + $result = Cache::get($cache, 'master'); | ||
138 | + if (!empty($result)) { | ||
139 | + return $result; | ||
140 | + } | ||
141 | + } | ||
142 | + | ||
143 | + // 调用接口获取数据 | ||
144 | + $banner = IndexData::getBannerStart($resource); | ||
145 | + if (isset($banner['code']) && $banner['code'] == 200) { | ||
146 | + // 构建数据 | ||
147 | + $data = array(); | ||
148 | + foreach ($banner['data'] as $val) { | ||
149 | + $data['list'][] = $val; | ||
150 | + } | ||
151 | + | ||
152 | + $result = FloorProcess::getContent($data, $channel); | ||
153 | + } | ||
154 | + | ||
155 | + if (USE_CACHE) { | ||
156 | + // 接口调用异常时, 不害怕,从我们的二级缓存(slave)里再取数据. | ||
157 | + if (empty($result)) { | ||
158 | + $result = Cache::get($cache, 'slave'); | ||
159 | + } | ||
160 | + // 接口调用正常,数据封装完成, 则设置一级(master)和二级(slave)数据缓存 | ||
161 | + else { | ||
162 | + Cache::set($cache, $result); | ||
163 | + } | ||
164 | + } | ||
165 | + | ||
166 | + return $result; | ||
167 | + } | ||
168 | + | ||
169 | + /** | ||
115 | * 获取男生首页的楼层数据 | 170 | * 获取男生首页的楼层数据 |
116 | * | 171 | * |
117 | * @return array | false | 172 | * @return array | false |
-
Please register or login to post a comment