do add models to package template data clear controller
Showing
11 changed files
with
249 additions
and
207 deletions
@@ -33,7 +33,7 @@ class Cache | @@ -33,7 +33,7 @@ class Cache | ||
33 | * @param int $expire 缓存有效期(单位秒, 0表示永久) | 33 | * @param int $expire 缓存有效期(单位秒, 0表示永久) |
34 | * @return void | 34 | * @return void |
35 | */ | 35 | */ |
36 | - public static function set($key, $value, $expire = 3600) | 36 | + public static function set($key, $value, $expire = 0) |
37 | { | 37 | { |
38 | try { | 38 | try { |
39 | // WINDOWS | 39 | // WINDOWS |
1 | <?php | 1 | <?php |
2 | 2 | ||
3 | use Action\AbstractAction; | 3 | use Action\AbstractAction; |
4 | -use LibModels\Wap\Home\IndexData; | ||
5 | -use Plugin\DataProcess\FloorProcess; | ||
6 | -use Configs\CacheConfig; | ||
7 | 4 | ||
8 | /** | 5 | /** |
9 | * 男生首页 | 6 | * 男生首页 |
@@ -11,13 +8,6 @@ use Configs\CacheConfig; | @@ -11,13 +8,6 @@ use Configs\CacheConfig; | ||
11 | class BoysController extends AbstractAction | 8 | class BoysController extends AbstractAction |
12 | { | 9 | { |
13 | 10 | ||
14 | - // 数据缓存时间 | ||
15 | - const DATA_EXPIRE = 3600; | ||
16 | - // 楼层资源的位置码 | ||
17 | - const CODE_FLOOR = '8512bf0755cc549ac323f852c9fd945d'; | ||
18 | - // 底部广告的位置码 | ||
19 | - const CODE_BOTTOM_BANNER = 'a2ec977c027d0cd9cdccb356ddf16b08'; | ||
20 | - | ||
21 | /** | 11 | /** |
22 | * 男生首页 | 12 | * 男生首页 |
23 | */ | 13 | */ |
@@ -30,35 +20,13 @@ class BoysController extends AbstractAction | @@ -30,35 +20,13 @@ class BoysController extends AbstractAction | ||
30 | // 设置顶部信息(搜索) | 20 | // 设置顶部信息(搜索) |
31 | $this->setHomeChannelHeader(); | 21 | $this->setHomeChannelHeader(); |
32 | 22 | ||
33 | - $data = array(); | ||
34 | - $data['boysHomePage'] = true; | ||
35 | - $data['maybeLike'] = true; | ||
36 | - | ||
37 | - do { | ||
38 | - // 先尝试获取一级缓存(master), 有数据则直接返回. | ||
39 | - $data['content'] = $this->getCache(CacheConfig::KEY_ACTION_BOYS_INDEX, true); | ||
40 | - if (!empty($data['content'])) { | ||
41 | - break; | ||
42 | - } | ||
43 | - | ||
44 | - // 调用接口获取楼层数据, 并封装成模板渲染需要的数据格式 | ||
45 | - $channelData = IndexData::getResourceData('1,3', self::CODE_FLOOR); | ||
46 | - if (isset($channelData['code']) && $channelData['code'] == 200) { | ||
47 | - $data['content'] = FloorProcess::getContent($channelData['data']); | ||
48 | - } | ||
49 | - | ||
50 | - // 接口调用正常,数据封装完成, 则设置一级(master)和二级(slave)数据缓存 | ||
51 | - if (!empty($data['content'])) { | ||
52 | - $this->setCache(CacheConfig::KEY_ACTION_BOYS_INDEX, $data['content'], self::DATA_EXPIRE); // 缓存1小时 | ||
53 | - break; | ||
54 | - } | ||
55 | - | ||
56 | - // 接口调用异常时, 不害怕,从我们的二级缓存(slave)里再取数据. | ||
57 | - $data['content'] = $this->getCache(CacheConfig::KEY_ACTION_BOYS_INDEX, false); | ||
58 | - | ||
59 | - } while (false); | ||
60 | - | ||
61 | - $this->_view->display('index', $data); | 23 | + // 渲染模板并输出 |
24 | + $this->_view->display('index', array( | ||
25 | + 'boysHomePage' => true, | ||
26 | + 'maybeLike' => true, | ||
27 | + 'content' => Index\HomeModel::getBoysFloor() | ||
28 | + )); | ||
29 | + | ||
62 | } | 30 | } |
63 | 31 | ||
64 | } | 32 | } |
1 | <?php | 1 | <?php |
2 | 2 | ||
3 | use Action\AbstractAction; | 3 | use Action\AbstractAction; |
4 | -use LibModels\Wap\Home\IndexData; | ||
5 | -use Plugin\DataProcess\FloorProcess; | ||
6 | -use Configs\CacheConfig; | ||
7 | 4 | ||
8 | /** | 5 | /** |
9 | * 女生首页 | 6 | * 女生首页 |
@@ -11,13 +8,6 @@ use Configs\CacheConfig; | @@ -11,13 +8,6 @@ use Configs\CacheConfig; | ||
11 | class GirlsController extends AbstractAction | 8 | class GirlsController extends AbstractAction |
12 | { | 9 | { |
13 | 10 | ||
14 | - // 数据缓存时间 | ||
15 | - const DATA_EXPIRE = 3600; | ||
16 | - // 楼层资源的位置码 | ||
17 | - const CODE_FLOOR = '189b6686065dbd6755dd6906cf03c002'; | ||
18 | - // 底部广告的位置码 | ||
19 | - const CODE_BOTTOM_BANNER = '8c8bd1b89a22e5895f05882e0825b493'; | ||
20 | - | ||
21 | /** | 11 | /** |
22 | * 女生首页 | 12 | * 女生首页 |
23 | */ | 13 | */ |
@@ -30,35 +20,13 @@ class GirlsController extends AbstractAction | @@ -30,35 +20,13 @@ class GirlsController extends AbstractAction | ||
30 | // 设置顶部信息(搜索) | 20 | // 设置顶部信息(搜索) |
31 | $this->setHomeChannelHeader(); | 21 | $this->setHomeChannelHeader(); |
32 | 22 | ||
33 | - $data = array(); | ||
34 | - $data['grilsHomePage'] = true; | ||
35 | - $data['maybeLike'] = true; | ||
36 | - | ||
37 | - do { | ||
38 | - // 先尝试获取一级缓存(master), 有数据则直接返回. | ||
39 | - $data['content'] = $this->getCache(CacheConfig::KEY_ACTION_GIRLS_INDEX, true); | ||
40 | - if (!empty($data['content'])) { | ||
41 | - break; | ||
42 | - } | ||
43 | - | ||
44 | - // 调用接口获取楼层数据, 并封装成模板渲染需要的数据格式 | ||
45 | - $channelData = IndexData::getResourceData('2,3', self::CODE_FLOOR); | ||
46 | - if (isset($channelData['code']) && $channelData['code'] == 200) { | ||
47 | - $data['content'] = FloorProcess::getContent($channelData['data']); | ||
48 | - } | ||
49 | - | ||
50 | - // 接口调用正常,数据封装完成, 则设置一级(master)和二级(slave)数据缓存 | ||
51 | - if (!empty($data['content'])) { | ||
52 | - $this->setCache(CacheConfig::KEY_ACTION_GIRLS_INDEX, $data['content'], self::DATA_EXPIRE); // 缓存1小时 | ||
53 | - break; | ||
54 | - } | ||
55 | - | ||
56 | - // 接口调用异常时, 不害怕,从我们的二级缓存(slave)里再取数据. | ||
57 | - $data['content'] = $this->getCache(CacheConfig::KEY_ACTION_GIRLS_INDEX, false); | ||
58 | - | ||
59 | - } while (false); | ||
60 | - | ||
61 | - $this->_view->display('index', $data); | 23 | + // 渲染模板并输出 |
24 | + $this->_view->display('index', array( | ||
25 | + 'grilsHomePage' => true, | ||
26 | + 'maybeLike' => true, | ||
27 | + 'content' => Index\HomeModel::getGirlsFloor() | ||
28 | + )); | ||
29 | + | ||
62 | } | 30 | } |
63 | 31 | ||
64 | } | 32 | } |
1 | <?php | 1 | <?php |
2 | 2 | ||
3 | use Action\AbstractAction; | 3 | use Action\AbstractAction; |
4 | -use LibModels\Wap\Home\IndexData; | ||
5 | -use Plugin\Helpers; | ||
6 | 4 | ||
7 | /** | 5 | /** |
8 | * 频道选择 | 6 | * 频道选择 |
9 | */ | 7 | */ |
10 | class IndexController extends AbstractAction | 8 | class IndexController extends AbstractAction |
11 | { | 9 | { |
12 | - const CODE_BANNER = '7ba9118028f9b22090b57341487567eb'; | ||
13 | - | 10 | + |
14 | /** | 11 | /** |
15 | - * 启动首页频道选择 | 12 | + * 频道选择页 |
16 | */ | 13 | */ |
17 | public function indexAction() | 14 | public function indexAction() |
18 | { | 15 | { |
19 | - $data = array( | ||
20 | - 'background' => '', | ||
21 | - ); | ||
22 | - | ||
23 | - // 背景图获取 | ||
24 | - $banner = IndexData::getBannerStart(self::CODE_BANNER); | ||
25 | - if (isset($banner['data'][0]['data']['list'][0]['src'])) { | ||
26 | - $data['background'] = Helpers::getImageUrl($banner['data'][0]['data']['list'][0]['src'], 640, 800, 1); | ||
27 | - } | ||
28 | - $banner = array(); | ||
29 | - | ||
30 | - // 渲染模板 | ||
31 | - $this->_view->display('index', $data); | 16 | + $this->_view->display('index', array( |
17 | + 'background' => Index\HomeModel::getBgImage() | ||
18 | + )); | ||
32 | } | 19 | } |
33 | 20 | ||
34 | } | 21 | } |
1 | <?php | 1 | <?php |
2 | 2 | ||
3 | use Action\AbstractAction; | 3 | use Action\AbstractAction; |
4 | -use LibModels\Wap\Home\IndexData; | ||
5 | -use Plugin\DataProcess\FloorProcess; | ||
6 | -use Configs\CacheConfig; | ||
7 | 4 | ||
8 | /** | 5 | /** |
9 | * 儿童首页 | 6 | * 儿童首页 |
10 | */ | 7 | */ |
11 | class KidsController extends AbstractAction | 8 | class KidsController extends AbstractAction |
12 | { | 9 | { |
13 | - // 数据缓存时间 | ||
14 | - const DATA_EXPIRE = 3600; | ||
15 | - // 楼层资源的位置码 | ||
16 | - const CODE_FLOOR = 'b8c1bff53d4ea60f978926d538620636'; // '66cad79d93e055ad6fc5c8744086066d'; | ||
17 | 10 | ||
18 | /** | 11 | /** |
19 | * 潮童首页 | 12 | * 潮童首页 |
@@ -27,35 +20,13 @@ class KidsController extends AbstractAction | @@ -27,35 +20,13 @@ class KidsController extends AbstractAction | ||
27 | // 设置顶部信息(搜索) | 20 | // 设置顶部信息(搜索) |
28 | $this->setHomeChannelHeader(); | 21 | $this->setHomeChannelHeader(); |
29 | 22 | ||
30 | - $data = array(); | ||
31 | - $data['kidsHomePage'] = true; | ||
32 | - $data['maybeLike'] = true; | ||
33 | - | ||
34 | - do { | ||
35 | - // 先尝试获取一级缓存(master), 有数据则直接返回. | ||
36 | - $data['content'] = $this->getCache(CacheConfig::KEY_ACTION_KIDS_INDEX, true); | ||
37 | - if (!empty($data['content'])) { | ||
38 | - break; | ||
39 | - } | ||
40 | - | ||
41 | - // 调用接口获取楼层数据, 并封装成模板渲染需要的数据格式 | ||
42 | - $channelData = IndexData::getResourceData('', self::CODE_FLOOR); | ||
43 | - if (isset($channelData['code']) && $channelData['code'] == 200) { | ||
44 | - $data['content'] = FloorProcess::getContent($channelData['data'], 3); | ||
45 | - } | ||
46 | - | ||
47 | - // 接口调用正常,数据封装完成, 则设置一级(master)和二级(slave)数据缓存 | ||
48 | - if (!empty($data['content'])) { | ||
49 | - $this->setCache(CacheConfig::KEY_ACTION_KIDS_INDEX, $data['content'], self::DATA_EXPIRE); // 缓存1小时 | ||
50 | - break; | ||
51 | - } | ||
52 | - | ||
53 | - // 接口调用异常时, 不害怕,从我们的二级缓存(slave)里再取数据. | ||
54 | - $data['content'] = $this->getCache(CacheConfig::KEY_ACTION_KIDS_INDEX, false); | ||
55 | - | ||
56 | - } while (false); | ||
57 | - | ||
58 | - $this->_view->display('index', $data); | 23 | + // 渲染模板并输出 |
24 | + $this->_view->display('index', array( | ||
25 | + 'kidsHomePage' => true, | ||
26 | + 'maybeLike' => true, | ||
27 | + 'content' => Index\HomeModel::getKidsFloor() | ||
28 | + )); | ||
29 | + | ||
59 | } | 30 | } |
60 | 31 | ||
61 | } | 32 | } |
1 | <?php | 1 | <?php |
2 | 2 | ||
3 | use Action\AbstractAction; | 3 | use Action\AbstractAction; |
4 | -use LibModels\Wap\Home\IndexData; | ||
5 | -use Plugin\DataProcess\FloorProcess; | ||
6 | -use Configs\CacheConfig; | ||
7 | 4 | ||
8 | /** | 5 | /** |
9 | * 创意生活首页 | 6 | * 创意生活首页 |
@@ -11,11 +8,6 @@ use Configs\CacheConfig; | @@ -11,11 +8,6 @@ use Configs\CacheConfig; | ||
11 | class LifestyleController extends AbstractAction | 8 | class LifestyleController extends AbstractAction |
12 | { | 9 | { |
13 | 10 | ||
14 | - // 数据缓存时间 | ||
15 | - const DATA_EXPIRE = 3600; | ||
16 | - // 楼层资源的位置码 | ||
17 | - const CODE_FLOOR = '61cd852c6afcf60660196154f66a3a62'; | ||
18 | - | ||
19 | /** | 11 | /** |
20 | * 创意生活首页 | 12 | * 创意生活首页 |
21 | */ | 13 | */ |
@@ -28,35 +20,13 @@ class LifestyleController extends AbstractAction | @@ -28,35 +20,13 @@ class LifestyleController extends AbstractAction | ||
28 | // 设置顶部信息(搜索) | 20 | // 设置顶部信息(搜索) |
29 | $this->setHomeChannelHeader(); | 21 | $this->setHomeChannelHeader(); |
30 | 22 | ||
31 | - $data = array(); | ||
32 | - $data['lifestyleHomePage'] = true; | ||
33 | - $data['maybeLike'] = true; | ||
34 | - | ||
35 | - do { | ||
36 | - // 先尝试获取一级缓存(master), 有数据则直接返回. | ||
37 | - $data['content'] = $this->getCache(CacheConfig::KEY_ACTION_LIFESTYLE_INDEX, true); | ||
38 | - if (!empty($data['content'])) { | ||
39 | - break; | ||
40 | - } | ||
41 | - | ||
42 | - // 调用接口获取楼层数据, 并封装成模板渲染需要的数据格式 | ||
43 | - $channelData = IndexData::getResourceData('', '61cd852c6afcf60660196154f66a3a62'); | ||
44 | - if (isset($channelData['code']) && $channelData['code'] == 200) { | ||
45 | - $data['content'] = FloorProcess::getContent($channelData['data'], 4); | ||
46 | - } | ||
47 | - | ||
48 | - // 接口调用正常,数据封装完成, 则设置一级(master)和二级(slave)数据缓存 | ||
49 | - if (!empty($data['content'])) { | ||
50 | - $this->setCache(CacheConfig::KEY_ACTION_LIFESTYLE_INDEX, $data['content'], self::DATA_EXPIRE); // 缓存1小时 | ||
51 | - break; | ||
52 | - } | ||
53 | - | ||
54 | - // 接口调用异常时, 不害怕,从我们的二级缓存(slave)里再取数据. | ||
55 | - $data['content'] = $this->getCache(CacheConfig::KEY_ACTION_LIFESTYLE_INDEX, false); | ||
56 | - | ||
57 | - } while (false); | ||
58 | - | ||
59 | - $this->_view->display('index', $data); | 23 | + // 渲染模板并输出 |
24 | + $this->_view->display('index', array( | ||
25 | + 'lifestyleHomePage' => true, | ||
26 | + 'maybeLike' => true, | ||
27 | + 'content' => Index\HomeModel::getLifestyleFloor() | ||
28 | + )); | ||
29 | + | ||
60 | } | 30 | } |
61 | 31 | ||
62 | } | 32 | } |
1 | +<?php | ||
2 | + | ||
3 | +namespace Index; | ||
4 | + | ||
5 | +use LibModels\Wap\Home\IndexData; | ||
6 | +use Plugin\Helpers; | ||
7 | +use Plugin\Cache; | ||
8 | +use Plugin\DataProcess\FloorProcess; | ||
9 | +use Configs\CacheConfig; | ||
10 | + | ||
11 | +/** | ||
12 | + * 首页相关的模板数据模型 | ||
13 | + * | ||
14 | + * @name HomeModel | ||
15 | + * @package models | ||
16 | + * @copyright yoho.inc | ||
17 | + * @version 1.0 (2015-10-21 11:08:21) | ||
18 | + * @author fei.hong <fei.hong@yoho.cn> | ||
19 | + */ | ||
20 | +class HomeModel | ||
21 | +{ | ||
22 | + | ||
23 | + /* 频道选择页取背景图片的位置码 */ | ||
24 | + const CODE_BG = '7ba9118028f9b22090b57341487567eb'; | ||
25 | + | ||
26 | + /* 男生楼层资源的位置码 */ | ||
27 | + const CODE_FLOOR_BOYS = '8512bf0755cc549ac323f852c9fd945d'; | ||
28 | + /* 女生楼层资源的位置码 */ | ||
29 | + const CODE_FLOOR_GIRLS = '189b6686065dbd6755dd6906cf03c002'; | ||
30 | + /* 潮童楼层资源的位置码 */ | ||
31 | + const CODE_FLOOR_KIDS = '66cad79d93e055ad6fc5c8744086066d'; // 'b8c1bff53d4ea60f978926d538620636'; | ||
32 | + /* 创意生活楼层资源的位置码 */ | ||
33 | + const CODE_FLOOR_LIFESTYLE = '61cd852c6afcf60660196154f66a3a62'; | ||
34 | + | ||
35 | + /* 男生底部广告的位置码 */ | ||
36 | + const CODE_BANNER_BOTTOM_BOYS = 'a2ec977c027d0cd9cdccb356ddf16b08'; | ||
37 | + /* 女生底部广告的位置码 */ | ||
38 | + const CODE_BANNER_BOTTOM_GIRLS = '8c8bd1b89a22e5895f05882e0825b493'; | ||
39 | + | ||
40 | + /** | ||
41 | + * 获取频道选择页的背景图片 | ||
42 | + * | ||
43 | + * @return string | false | ||
44 | + */ | ||
45 | + public static function getBgImage() | ||
46 | + { | ||
47 | + if (USE_CACHE) { | ||
48 | + // 先尝试获取一级缓存(master), 有数据则直接返回. | ||
49 | + $result = Cache::get(CacheConfig::KEY_ACTION_INDEX_INDEX, 'master'); | ||
50 | + if (!empty($result)) { | ||
51 | + return $result; | ||
52 | + } | ||
53 | + } | ||
54 | + | ||
55 | + // 调用接口获取数据 | ||
56 | + $banner = IndexData::getBannerStart(self::CODE_BG); | ||
57 | + if (isset($banner['data'][0]['data']['list'][0]['src'])) { | ||
58 | + $result = Helpers::getImageUrl($banner['data'][0]['data']['list'][0]['src'], 640, 800, 1); | ||
59 | + } else { | ||
60 | + $result = false; | ||
61 | + } | ||
62 | + | ||
63 | + if (USE_CACHE) { | ||
64 | + // 接口调用异常时, 不害怕,从我们的二级缓存(slave)里再取数据. | ||
65 | + if (empty($result)) { | ||
66 | + $result = Cache::get(CacheConfig::KEY_ACTION_INDEX_INDEX, 'slave'); | ||
67 | + } | ||
68 | + // 接口调用正常,数据封装完成, 则设置一级(master)和二级(slave)数据缓存 | ||
69 | + else { | ||
70 | + Cache::set(CacheConfig::KEY_ACTION_INDEX_INDEX, $result); | ||
71 | + } | ||
72 | + } | ||
73 | + | ||
74 | + return $result; | ||
75 | + } | ||
76 | + | ||
77 | + /** | ||
78 | + * 获取男生首页的楼层数据 | ||
79 | + */ | ||
80 | + public static function getBoysFloor() | ||
81 | + { | ||
82 | + if (USE_CACHE) { | ||
83 | + // 先尝试获取一级缓存(master), 有数据则直接返回. | ||
84 | + $result = Cache::get(CacheConfig::KEY_ACTION_BOYS_INDEX, 'master'); | ||
85 | + if (!empty($result)) { | ||
86 | + return $result; | ||
87 | + } | ||
88 | + } | ||
89 | + | ||
90 | + // 调用接口获取楼层数据, 并封装成模板渲染需要的数据格式 | ||
91 | + $channelData = IndexData::getResourceData('1,3', self::CODE_FLOOR_BOYS); | ||
92 | + if (isset($channelData['code']) && $channelData['code'] == 200) { | ||
93 | + $result = FloorProcess::getContent($channelData['data']); | ||
94 | + } | ||
95 | + | ||
96 | + if (USE_CACHE) { | ||
97 | + // 接口调用异常时, 不害怕,从我们的二级缓存(slave)里再取数据. | ||
98 | + if (empty($result)) { | ||
99 | + $result = Cache::get(CacheConfig::KEY_ACTION_BOYS_INDEX, 'slave'); | ||
100 | + } | ||
101 | + // 接口调用正常,数据封装完成, 则设置一级(master)和二级(slave)数据缓存 | ||
102 | + else { | ||
103 | + Cache::set(CacheConfig::KEY_ACTION_BOYS_INDEX, $result); | ||
104 | + } | ||
105 | + } | ||
106 | + | ||
107 | + return $result; | ||
108 | + } | ||
109 | + | ||
110 | + /** | ||
111 | + * 获取女生首页的楼层数据 | ||
112 | + */ | ||
113 | + public static function getGirlsFloor() | ||
114 | + { | ||
115 | + if (USE_CACHE) { | ||
116 | + // 先尝试获取一级缓存(master), 有数据则直接返回. | ||
117 | + $result = Cache::get(CacheConfig::KEY_ACTION_GIRLS_INDEX, 'master'); | ||
118 | + if (!empty($result)) { | ||
119 | + return $result; | ||
120 | + } | ||
121 | + } | ||
122 | + | ||
123 | + // 调用接口获取楼层数据, 并封装成模板渲染需要的数据格式 | ||
124 | + $channelData = IndexData::getResourceData('2,3', self::CODE_FLOOR_GIRLS); | ||
125 | + if (isset($channelData['code']) && $channelData['code'] == 200) { | ||
126 | + $result = FloorProcess::getContent($channelData['data']); | ||
127 | + } | ||
128 | + | ||
129 | + if (USE_CACHE) { | ||
130 | + // 接口调用异常时, 不害怕,从我们的二级缓存(slave)里再取数据. | ||
131 | + if (empty($result)) { | ||
132 | + $result = Cache::get(CacheConfig::KEY_ACTION_GIRLS_INDEX, 'slave'); | ||
133 | + } | ||
134 | + // 接口调用正常,数据封装完成, 则设置一级(master)和二级(slave)数据缓存 | ||
135 | + else { | ||
136 | + Cache::set(CacheConfig::KEY_ACTION_GIRLS_INDEX, $result); | ||
137 | + } | ||
138 | + } | ||
139 | + | ||
140 | + return $result; | ||
141 | + } | ||
142 | + | ||
143 | + /** | ||
144 | + * 获取潮童首页的楼层数据 | ||
145 | + */ | ||
146 | + public static function getKidsFloor() | ||
147 | + { | ||
148 | + if (USE_CACHE) { | ||
149 | + // 先尝试获取一级缓存(master), 有数据则直接返回. | ||
150 | + $result = Cache::get(CacheConfig::KEY_ACTION_KIDS_INDEX, 'master'); | ||
151 | + if (!empty($result)) { | ||
152 | + return $result; | ||
153 | + } | ||
154 | + } | ||
155 | + | ||
156 | + // 调用接口获取楼层数据, 并封装成模板渲染需要的数据格式 | ||
157 | + $channelData = IndexData::getResourceData('', self::CODE_FLOOR_KIDS); | ||
158 | + if (isset($channelData['code']) && $channelData['code'] == 200) { | ||
159 | + $result = FloorProcess::getContent($channelData['data'], 3); | ||
160 | + } | ||
161 | + | ||
162 | + if (USE_CACHE) { | ||
163 | + // 接口调用异常时, 不害怕,从我们的二级缓存(slave)里再取数据. | ||
164 | + if (empty($result)) { | ||
165 | + $result = Cache::get(CacheConfig::KEY_ACTION_KIDS_INDEX, 'slave'); | ||
166 | + } | ||
167 | + // 接口调用正常,数据封装完成, 则设置一级(master)和二级(slave)数据缓存 | ||
168 | + else { | ||
169 | + Cache::set(CacheConfig::KEY_ACTION_KIDS_INDEX, $result); | ||
170 | + } | ||
171 | + } | ||
172 | + | ||
173 | + return $result; | ||
174 | + } | ||
175 | + | ||
176 | + /** | ||
177 | + * 获取创意生活首页的楼层数据 | ||
178 | + */ | ||
179 | + public static function getLifestyleFloor() | ||
180 | + { | ||
181 | + if (USE_CACHE) { | ||
182 | + // 先尝试获取一级缓存(master), 有数据则直接返回. | ||
183 | + $result = Cache::get(CacheConfig::KEY_ACTION_LIFESTYLE_INDEX, 'master'); | ||
184 | + if (!empty($result)) { | ||
185 | + return $result; | ||
186 | + } | ||
187 | + } | ||
188 | + | ||
189 | + // 调用接口获取楼层数据, 并封装成模板渲染需要的数据格式 | ||
190 | + $channelData = IndexData::getResourceData('', self::CODE_FLOOR_LIFESTYLE); | ||
191 | + if (isset($channelData['code']) && $channelData['code'] == 200) { | ||
192 | + $result = FloorProcess::getContent($channelData['data'], 4); | ||
193 | + } | ||
194 | + | ||
195 | + if (USE_CACHE) { | ||
196 | + // 接口调用异常时, 不害怕,从我们的二级缓存(slave)里再取数据. | ||
197 | + if (empty($result)) { | ||
198 | + $result = Cache::get(CacheConfig::KEY_ACTION_LIFESTYLE_INDEX, 'slave'); | ||
199 | + } | ||
200 | + // 接口调用正常,数据封装完成, 则设置一级(master)和二级(slave)数据缓存 | ||
201 | + else { | ||
202 | + Cache::set(CacheConfig::KEY_ACTION_LIFESTYLE_INDEX, $result); | ||
203 | + } | ||
204 | + } | ||
205 | + | ||
206 | + return $result; | ||
207 | + } | ||
208 | + | ||
209 | +} |
1 | -<?php | ||
2 | - | ||
3 | -use LibModels\Wap\Home\IndexData; | ||
4 | -use Plugin\Helpers; | ||
5 | - | ||
6 | -/** | ||
7 | - * 首页相关的模板数据模型 | ||
8 | - * | ||
9 | - * @author fei.hong | ||
10 | - */ | ||
11 | -class IndexModel | ||
12 | -{ | ||
13 | - | ||
14 | - /* 频道选择页取背景图片的位置码 */ | ||
15 | - const CODE_BG = '7ba9118028f9b22090b57341487567eb'; | ||
16 | - | ||
17 | - /** | ||
18 | - * 获取频道选择页的背景图片 | ||
19 | - * | ||
20 | - * @return string | false | ||
21 | - */ | ||
22 | - public static function getBgImage() | ||
23 | - { | ||
24 | - $banner = IndexData::getBannerStart(self::CODE_BG); | ||
25 | - if (isset($banner['data'][0]['data']['list'][0]['src'])) { | ||
26 | - $result = Helpers::getImageUrl($banner['data'][0]['data']['list'][0]['src'], 640, 800, 1); | ||
27 | - } else { | ||
28 | - $result = false; | ||
29 | - } | ||
30 | - | ||
31 | - return $result; | ||
32 | - } | ||
33 | - | ||
34 | -} |
1 | <?php | 1 | <?php |
2 | use Yaf\Application; | 2 | use Yaf\Application; |
3 | 3 | ||
4 | -define('DOMAIN', 'm.dev.yohobuy.com'); | 4 | +define('SITE_DOMAIN', 'm.dev.yohobuy.com'); // 网站主域名 |
5 | +define('USE_CACHE', false); // 缓存的开关 | ||
5 | define('APPLICATION_PATH', dirname(__DIR__)); | 6 | define('APPLICATION_PATH', dirname(__DIR__)); |
6 | define('ROOT_PATH', dirname(dirname(APPLICATION_PATH))); | 7 | define('ROOT_PATH', dirname(dirname(APPLICATION_PATH))); |
7 | defined('APPLICATION_ENV') || define('APPLICATION_ENV', 'developer'); | 8 | defined('APPLICATION_ENV') || define('APPLICATION_ENV', 'developer'); |
1 | <?php | 1 | <?php |
2 | use Yaf\Application; | 2 | use Yaf\Application; |
3 | 3 | ||
4 | -define('DOMAIN', 'buy.test.yoho.cn'); | 4 | +define('SITE_DOMAIN', 'buy.test.yoho.cn'); // 网站主域名 |
5 | +define('USE_CACHE', true); // 缓存的开关 | ||
5 | define('APPLICATION_PATH', dirname(__DIR__)); | 6 | define('APPLICATION_PATH', dirname(__DIR__)); |
6 | define('ROOT_PATH', dirname(dirname(APPLICATION_PATH))); | 7 | define('ROOT_PATH', dirname(dirname(APPLICATION_PATH))); |
7 | defined('APPLICATION_ENV') || define('APPLICATION_ENV', 'testing'); | 8 | defined('APPLICATION_ENV') || define('APPLICATION_ENV', 'testing'); |
1 | <?php | 1 | <?php |
2 | use Yaf\Application; | 2 | use Yaf\Application; |
3 | 3 | ||
4 | -define('DOMAIN', 'wap.yohobuy.com'); | 4 | +define('SITE_DOMAIN', 'wap.yohobuy.com'); // 网站主域名 |
5 | +define('USE_CACHE', true); // 缓存的开关 | ||
5 | define('APPLICATION_PATH', dirname(__DIR__)); | 6 | define('APPLICATION_PATH', dirname(__DIR__)); |
6 | define('ROOT_PATH', dirname(dirname(APPLICATION_PATH))); | 7 | define('ROOT_PATH', dirname(dirname(APPLICATION_PATH))); |
7 | defined('APPLICATION_ENV') || define('APPLICATION_ENV', 'production'); | 8 | defined('APPLICATION_ENV') || define('APPLICATION_ENV', 'production'); |
-
Please register or login to post a comment