Authored by Rock Zhang

添加男首女首底部Banner

... ... @@ -18,6 +18,9 @@ class CacheConfig
const KEY_ACTION_GIRLS_INDEX = 'key_action_girls_index'; // 女生首页
const KEY_ACTION_KIDS_INDEX = 'key_action_kids_index'; // 潮童首页
const KEY_ACTION_LIFESTYLE_INDEX = 'key_action_lifestyle_index'; // 创意生活首页
const KEY_ACTION_BOYS_BOTTOM_BANNER = 'key_action_boys_bottom_banner'; // 男生首页底部banner
const KEY_ACTION_GRILS_BOTTOM_BANNER = 'key_action_girls_bottom_banner';// 女生首页底部banner
const KEY_ACTION_GUANG_PLUSSTAR_INDEX = 'key_action_guang_plusstar_index'; // 国际优选
const KEY_ACTION_GUANG_PLUSSTAR_LIST = 'key_action_guang_plusstar_list'; // 明星原创
... ...
<?php
use Action\AbstractAction;
use Plugin\Helpers;
/**
* 男生首页
... ... @@ -34,4 +35,31 @@ class BoysController extends AbstractAction
}
/**
* 异步获取男首底部banner数据
* @return string 底部Banner数据
*/
public function bottomBannerAction()
{
do
{
if(!$this->isAjax())
{
break;
}
$channel = Helpers::getChannelByCookie();
$bottomBanner = Index\HomeModel::getBottomBanner($channel);
if($bottomBanner)
{
$this->echoJson($bottomBanner);
}
}
while(false);
echo ' ';
}
}
... ...
<?php
use Action\AbstractAction;
use Plugin\Helpers;
/**
* 女生首页
... ... @@ -33,4 +34,31 @@ class GirlsController extends AbstractAction
));
}
/**
* 异步获取女首底部banner数据
* @return string 底部Banner数据
*/
public function bottomBannerAction()
{
do
{
if(!$this->isAjax())
{
break;
}
$channel = Helpers::getChannelByCookie();
$bottomBanner = Index\HomeModel::getBottomBanner($channel);
if($bottomBanner)
{
$this->echoJson($bottomBanner);
}
}
while(false);
echo ' ';
}
}
... ...
... ... @@ -45,6 +45,11 @@ class HomeModel
/* COOKIE标识访问的是创意生活频道 */
const COOKIE_NAME_LIFESTYLE = 'lifestyle';
/* COOKIE标识访问的是男生频道底部Banner */
const COOKIE_NAME_BOYS_BOTTOM_BANNER = '8c48745a39373d621bf5fd80edf59b5e';
/* COOKIE标识访问的是女生频道频道底部Banner */
const COOKIE_NAME_GIRLS_BOTTOM_BANNER = 'c63939b2ad458e9cb51147940c1da2e5';
/**
* 选择频道
*
... ... @@ -112,6 +117,56 @@ class HomeModel
}
/**
* 获取男生,女生底部banner
*
* @return string | false
*/
public static function getBottomBanner($channel)
{
$result = false;
if($channel == 2) {
$resource = self::COOKIE_NAME_GIRLS_BOTTOM_BANNER;
$cache = CacheConfig::KEY_ACTION_GRILS_BOTTOM_BANNER;
} else {
$resource = self::COOKIE_NAME_BOYS_BOTTOM_BANNER;
$cache = CacheConfig::KEY_ACTION_BOYS_BOTTOM_BANNER;
}
if (USE_CACHE) {
// 先尝试获取一级缓存(master), 有数据则直接返回.
$result = Cache::get($cache, 'master');
if (!empty($result)) {
return $result;
}
}
// 调用接口获取数据
$banner = IndexData::getBannerStart($resource);
if (isset($banner['code']) && $banner['code'] == 200) {
// 构建数据
$data = array();
foreach ($banner['data'] as $val) {
$data['list'][] = $val;
}
$result = FloorProcess::getContent($data, $channel);
}
if (USE_CACHE) {
// 接口调用异常时, 不害怕,从我们的二级缓存(slave)里再取数据.
if (empty($result)) {
$result = Cache::get($cache, 'slave');
}
// 接口调用正常,数据封装完成, 则设置一级(master)和二级(slave)数据缓存
else {
Cache::set($cache, $result);
}
}
return $result;
}
/**
* 获取男生首页的楼层数据
*
* @return array | false
... ...