...
|
...
|
@@ -20,6 +20,7 @@ use Configs\CacheConfig; |
|
|
class HomeModel
|
|
|
{
|
|
|
/* 频道选择页取背景图片的位置码 */
|
|
|
|
|
|
const CODE_BG = '7ba9118028f9b22090b57341487567eb';
|
|
|
|
|
|
/* 男生楼层资源的位置码 */
|
...
|
...
|
@@ -70,6 +71,7 @@ class HomeModel |
|
|
|
|
|
/**
|
|
|
* 设置选择的频道保存到浏览器COOKIE
|
|
|
* (已废弃,改成JS设置)
|
|
|
*
|
|
|
* @param string $cookie
|
|
|
* @return void
|
...
|
...
|
@@ -128,7 +130,7 @@ class HomeModel |
|
|
public static function getBottomBanner($channel)
|
|
|
{
|
|
|
$result = false;
|
|
|
if($channel == 2) {
|
|
|
if ($channel == 2) {
|
|
|
$resource = self::CODE_NAME_GIRLS_BOTTOM_BANNER;
|
|
|
$cache = CacheConfig::KEY_ACTION_GRILS_BOTTOM_BANNER;
|
|
|
} else {
|
...
|
...
|
@@ -324,45 +326,65 @@ class HomeModel |
|
|
*
|
|
|
* @return array
|
|
|
*/
|
|
|
public static function getChannel(){
|
|
|
public static function getChannel()
|
|
|
{
|
|
|
$result = array();
|
|
|
$result['showYohood'] = false;
|
|
|
|
|
|
$data = IndexData::channelData();
|
|
|
if (USE_CACHE) {
|
|
|
$key = CacheConfig::KEY_ACTION_INDEX_CONFIG;
|
|
|
// 先尝试获取一级缓存(master), 有数据则直接返回.
|
|
|
$result = Cache::get($key, 'master');
|
|
|
if (!empty($result)) {
|
|
|
return $result;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
$channelList = array();
|
|
|
if(isset($data['data']['list'])){
|
|
|
foreach($data['data']['list'] as $key => $value){
|
|
|
switch ($value['channel_id']) {
|
|
|
case 5:
|
|
|
$result['showYohood'] = true;
|
|
|
$result['yohoodHref'] = '/yohood';
|
|
|
break;
|
|
|
$data = IndexData::channelData();
|
|
|
if (!empty($data['data']['list'])) {
|
|
|
$build = array();
|
|
|
foreach ($data['data']['list'] as $value) {
|
|
|
$build = array();
|
|
|
switch (intval($value['channel_id'])) {
|
|
|
case 1:
|
|
|
$channelList[$key]['href'] = '/boys';
|
|
|
$channelList[$key]['title'] = '男生';
|
|
|
$channelList[$key]['entitle'] = 'BOYS';
|
|
|
$build['href'] = '/boys';
|
|
|
$build['title'] = '男生';
|
|
|
$build['entitle'] = 'BOYS';
|
|
|
break;
|
|
|
case 2:
|
|
|
$channelList[$key]['href'] = '/girls';
|
|
|
$channelList[$key]['title'] = '女生';
|
|
|
$channelList[$key]['entitle'] = 'GIRLS';
|
|
|
$build['href'] = '/girls';
|
|
|
$build['title'] = '女生';
|
|
|
$build['entitle'] = 'GIRLS';
|
|
|
break;
|
|
|
case 3:
|
|
|
$channelList[$key]['href'] = '/kids';
|
|
|
$channelList[$key]['title'] = '潮童';
|
|
|
$channelList[$key]['entitle'] = 'KIDS';
|
|
|
$build['href'] = '/kids';
|
|
|
$build['title'] = '潮童';
|
|
|
$build['entitle'] = 'KIDS';
|
|
|
break;
|
|
|
case 4:
|
|
|
$channelList[$key]['href'] = '/lifestyle';
|
|
|
$channelList[$key]['title'] = '创意生活';
|
|
|
$channelList[$key]['entitle'] = 'LIFESTYLE';
|
|
|
$build['href'] = '/lifestyle';
|
|
|
$build['title'] = '创意生活';
|
|
|
$build['entitle'] = 'LIFESTYLE';
|
|
|
break;
|
|
|
default:
|
|
|
case 5:
|
|
|
$result['showYohood'] = true;
|
|
|
$result['yohoodHref'] = 'http://yohood.cn';
|
|
|
break;
|
|
|
default:
|
|
|
continue;
|
|
|
}
|
|
|
$result['channelList'][] = $build;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
if (USE_CACHE) {
|
|
|
// 接口调用异常时, 不害怕,从我们的二级缓存(slave)里再取数据.
|
|
|
if (empty($result)) {
|
|
|
$result = Cache::get($key, 'slave');
|
|
|
}
|
|
|
// 接口调用正常,数据封装完成, 则设置一级(master)和二级(slave)数据缓存
|
|
|
else {
|
|
|
Cache::set($key, $result);
|
|
|
}
|
|
|
$result['channelList'] = $channelList;
|
|
|
}
|
|
|
|
|
|
return $result;
|
...
|
...
|
|