Authored by 毕凯

Merge branch 'feature/channel' into release/4.5

... ... @@ -18,6 +18,7 @@ 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_CHANNEL_INDEX = 'key_action_channel_index';//日韩馆
const KEY_ACTION_INDEX_CONFIG = 'key_action_index_config'; // 频道配置
... ...
<?php
/**
* Created by PhpStorm.
* User: Administrator
* Date: 2016-5-3
* Time: 10:41
*/
namespace LibModels\Wap\Home;
use Api\Yohobuy;
use Api\Sign;
class ChannelData
{
//日韩馆调取资源位
public static function getChannelData($contentCode)
{
$param = Yohobuy::param();
$param['content_code'] = $contentCode;
$param['client_secret'] = Sign::getSign($param);
return Yohobuy::get(Yohobuy::SERVICE_URL . 'operations/api/v5/resource/get', $param);
}
}
\ No newline at end of file
... ...
... ... @@ -213,7 +213,20 @@ class FloorProcess
$one['img'] = Helpers::getImageUrl($one['src'], 158, 174);
unset($one['src']);
}
$data['more'] = '/brands?channel=' . $type;
$data['moreImg'] = array(
'alt' => '',
'src' => 'http://cdn.yoho.cn/myohobuy/assets/img/more-brand.png',
'url' => '/brands?channel=' . $type,
);
if (isset($data['image'])) {
$data['moreImg'] = array(
'alt' => $data['image']['alt'],
'src' => Helpers::getImageUrl($data['image']['src'], 320, 172),
'url' =>$data['image']['url'],
);
}
$result['hotBrands'] = $data;
return $result;
... ...
... ... @@ -67,14 +67,12 @@
width: 317px;
height: 174px;
border-top: 1px solid #e0e0e0;
overflow: hidden;
a {
display: block;
width: 100%;
height: 100%;
background: resolve("more-brand.png") no-repeat;
background-size: 100% 100%;
}
}
}
... ...
{{> layout/header}}
<div class="mobile-wrap boys-wrap yoho-page">
{{! 首页header}}
{{# homeHeader}}
{{> home/home_header}}
{{/ homeHeader}}
{{> home/content}}
{{! 商品列表}}
{{# twoColumnGoods}}
{{> home/two_column_goods}}
{{/ twoColumnGoods}}
</div>
{{> layout/footer}}
... ...
... ... @@ -10,7 +10,9 @@
</a>
</li>
{{/ list}}
<li class="more">
<a href="{{more}}"></a>
</li>
{{# moreImg}}
<li class="more">
<a href="{{url}}"><img src="{{src}}" alt="{{alt}}"></a>
</li>
{{/ moreImg}}
</ul>
\ No newline at end of file
... ...
... ... @@ -150,6 +150,13 @@
seajs.use('js/index/footer');
</script>
{{/if}}
{{!-- 二级频道 --}}
{{#if secondChannelPage}}
<script>
seajs.use('js/home/home');
seajs.use('js/index/footer');
</script>
{{/if}}
{{!-- 新品到着 --}}
{{#if newArrivalPage}}
<script>
... ...
<?php
use Action\AbstractAction;
use Index\ChannelModel;
use Plugin\Helpers;
class ChannelController extends AbstractAction
{
/**
* 日韩馆
*/
public function indexAction()
{
// 设置网站标题
$this->setTitle('日韩馆'); // 需求是标题可以自定义
$this->setNavHeader('日韩馆', true, false); // 需求是标题可以自定义
$content = ChannelModel::getChannelFloor();
// 渲染模板并输出
$this->_view->display('index', array(
'secondChannelPage' => true,
'maybeLike' => true,
'content' => $content,
'pageFooter' => true,
));
}
}
... ...
<?php
/**
* Created by PhpStorm.
* User: Administrator
* Date: 2016-5-3
* Time: 10:34
*/
namespace Index;
use LibModels\Wap\Home\ChannelData;
use LibModels\Wap\Home\IndexData;
use Plugin\Helpers;
use Plugin\Cache;
use Plugin\DataProcess\FloorProcess;
use Configs\CacheConfig;
class ChannelModel
{
const CODE_FLOOR_JCSHOP = 'cdcc581da92a13c74e3bf1826f1806d1';
/**
* 获取男生首页的楼层数据
*
* @return array | false
*/
public static function getChannelFloor()
{
$result = array();
if (USE_CACHE) {
// 先尝试获取一级缓存(master), 有数据则直接返回.
$result = Cache::get(CacheConfig::KEY_ACTION_CHANNEL_INDEX, 'master');
if (!empty($result)) {
return $result;
}
}
// 调用接口获取楼层数据, 并封装成模板渲染需要的数据格式
$channelData = ChannelData::getChannelData(self::CODE_FLOOR_JCSHOP);
if (isset($channelData['code']) && $channelData['code'] == 200) {
$channelData = array(
'list'=>$channelData['data']
);
$result = FloorProcess::getContent($channelData);
}
if (USE_CACHE) {
// 接口调用异常时, 不害怕,从我们的二级缓存(slave)里再取数据.
if (empty($result)) {
$result = Cache::get(CacheConfig::KEY_ACTION_CHANNEL_INDEX, 'slave');
}
// 接口调用正常,数据封装完成, 则设置一级(master)和二级(slave)数据缓存
else {
Cache::set(CacheConfig::KEY_ACTION_CHANNEL_INDEX, $result);
}
}
return $result;
}
}
\ No newline at end of file
... ...