Authored by hf

do brand search page

framework @ 75bbc3b0
Subproject commit 119c247f5cf929aa1e059e40609bb16dd6b58f05
Subproject commit 75bbc3b075de19f239532f60c5995d06c5f814e2
... ...
... ... @@ -66,7 +66,7 @@ class BrandData
}
$param['client_secret'] = Sign::getSign($param);
return Yohobuy::get(Yohobuy::API_URL, $param);
return Yohobuy::get(Yohobuy::API_URL, $param, 3600); // 有缓存1小时
}
/**
... ...
... ... @@ -17,65 +17,203 @@ server
allow 172.16.0.0/16;
deny all;
#账号相关
location = /reg.html {
root /Data/code/git/yohobuy/assets;
expires 7d;
}
location = /emailback.html {
root /Data/code/git/yohobuy/assets;
expires 7d;
}
location = /phoneback.html {
root /Data/code/git/yohobuy/assets;
expires 7d;
}
location = /error.html {
root /Data/code/git/yohobuy/assets;
expires 7d;
}
location ^~ /passport/back/ {
proxy_redirect off;
proxy_pass http://yohobuy;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Accept-Encoding "gzip";
}
location ^~ /passport/reg/ {
proxy_redirect off;
proxy_pass http://yohobuy;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Accept-Encoding "gzip";
}
#首页相关
location = / {
proxy_redirect off;
proxy_pass http://yohobuy;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Accept-Encoding "gzip";
}
location = /boys {
proxy_redirect off;
proxy_pass http://yohobuy;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Accept-Encoding "gzip";
}
location = /girls {
proxy_redirect off;
proxy_pass http://yohobuy;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Accept-Encoding "gzip";
}
location = /kids {
proxy_redirect off;
proxy_pass http://yohobuy;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Accept-Encoding "gzip";
}
location = /lifestyle {
proxy_redirect off;
proxy_pass http://yohobuy;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Accept-Encoding "gzip";
}
location = /girl {
proxy_redirect off;
proxy_pass http://yohobuy;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Accept-Encoding "gzip";
}
# 商品相关
location = /cate {
proxy_redirect off;
proxy_pass http://yohobuy;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Accept-Encoding "gzip";
}
location = /brands {
proxy_redirect off;
proxy_pass http://yohobuy;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Accept-Encoding "gzip";
}
location = /sale {
proxy_redirect off;
proxy_pass http://yohobuy;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Accept-Encoding "gzip";
}
location = /brands/search {
proxy_redirect off;
proxy_pass http://yohobuy;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Accept-Encoding "gzip";
}
location = /product/new {
proxy_redirect off;
proxy_pass http://yohobuy;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Accept-Encoding "gzip";
}
# 子域名
if ($host = "sale.test.yoho.cn" ) {
location ^~ /product/newsale/ {
proxy_redirect off;
proxy_pass http://61.155.222.162;
proxy_set_header Host cuxiao.m.yohobuy.com;
proxy_pass http://yohobuy;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Accept-Encoding "gzip";
}
if ($host = "cuxiao.test.yoho.cn" ) {
location ^~ /product/opt/ {
proxy_redirect off;
proxy_pass http://101.201.176.121;
proxy_set_header Host cuxiao.m.yohobuy.com;
proxy_pass http://yohobuy;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Accept-Encoding "gzip";
}
location ^~ /product/recom/ {
proxy_redirect off;
proxy_pass http://yohobuy;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Accept-Encoding "gzip";
}
# 账号相关
location =/signin.html {
# 逛相关
location ^~ /guang/ {
proxy_redirect off;
proxy_pass http://61.155.222.163;
proxy_set_header Host m.yohobuy.com;
proxy_pass http://yohobuy;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Accept-Encoding "gzip";
}
location /passport/auth {
location ^~ /tags/index {
proxy_redirect off;
proxy_pass http://61.155.222.163;
proxy_set_header Host m.yohobuy.com;
proxy_pass http://yohobuy;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Accept-Encoding "gzip";
}
location /passport/signin {
location ^~ /author/index {
proxy_redirect off;
proxy_pass http://61.155.222.163;
proxy_set_header Host m.yohobuy.com;
proxy_pass http://yohobuy;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Accept-Encoding "gzip";
}
location ^~ /info/index {
proxy_redirect off;
proxy_pass http://yohobuy;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Accept-Encoding "gzip";
}
# 个人中心
location /home {
# 搜索相关
location ^~ /search {
proxy_redirect off;
proxy_pass http://61.155.222.163;
proxy_set_header Host m.yohobuy.com;
proxy_pass http://yohobuy;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Accept-Encoding "gzip";
}
# 购物车
location /cart {
# 其它访问都跳到老版
location / {
proxy_redirect off;
proxy_pass http://61.155.222.163;
proxy_set_header Host m.yohobuy.com;
... ... @@ -84,13 +222,32 @@ server
proxy_set_header Accept-Encoding "gzip";
}
location ~* \.html$ {
root /Data/code/git/yohobuy/assets;
if (!-f $request_filename){
rewrite ^/(.*)$ http://m.yohobuy.com/$1 permanent;
}
expires 3m;
}
# # 子域名
# if ($host = "sale.test.yoho.cn" ) {
# proxy_redirect off;
# proxy_pass http://61.155.222.162;
# proxy_set_header Host cuxiao.m.yohobuy.com;
# proxy_set_header X-Real-IP $remote_addr;
# proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
# proxy_set_header Accept-Encoding "gzip";
# }
# if ($host = "cuxiao.test.yoho.cn" ) {
# proxy_redirect off;
# proxy_pass http://101.201.176.121;
# proxy_set_header Host cuxiao.m.yohobuy.com;
# proxy_set_header X-Real-IP $remote_addr;
# proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
# proxy_set_header Accept-Encoding "gzip";
# }
#location ~* \.html$ {
# root /Data/code/git/yohobuy/assets;
# if (!-f $request_filename){
# rewrite ^/(.*)$ http://m.yohobuy.com/$1 permanent;
# }
# expires 3m;
# }
location ~* \.(ico|woff|svg|eot|ttf|otf)$ {
expires 30d;
... ...
... ... @@ -15,5 +15,8 @@
<div class="search-result">
</div>
</div>
<script type="text/tmpl">
{{{brandList}}}
</script>
{{> layout/footer}}
{{> layout/download_app}}
... ...
... ... @@ -18,6 +18,7 @@ use Plugin\Helpers;
class BrandModel
{
/* 男生频道取品牌广告及热门品牌数据的位置码 */
const CODE_TOPPOS_BOYS = 'ce6ac059493ec26241a8cbe0bfa1b17a';
/* 女生频道取品牌广告及热门品牌数据的位置码 */
const CODE_TOPPOS_GIRLS = 'dac99cdedc1f948e84c145aca561f7d2';
... ... @@ -58,7 +59,7 @@ class BrandModel
// 是否显示app下载浮层标识
$result['showDownloadApp'] = true;
// 搜索链接地址
$result['searchUrl'] = Helpers::url('/search.html', null, 'search');
$result['searchUrl'] = Helpers::url('/brands/search', null);
/* 顶部的轮翻广告列表 */
if (!empty($brand['brandTop'][0]['data'])) {
... ... @@ -93,7 +94,7 @@ class BrandModel
$list['name'] = $row['brand_name'];
$list['isHot'] = ($row['is_hot'] === 'Y') ? true : false;
$list['isNew'] = ($row['is_show_new'] === 'Y') ? true : false;
$list['url'] = 'http://' . $row['brand_domain'] . SUB_DOMAIN;
$list['url'] = Helpers::url('', null, $row['brand_domain']);
$build['list'][] = $list;
}
$result['brandList'][] = $build;
... ... @@ -107,4 +108,34 @@ class BrandModel
return $result;
}
/**
* 获取搜索的品牌列表
*
* @param int $channel 1表示男生频道, 2表示女生频道, 3表示潮童频道, 4表示创意生活频道
* @return array
*/
public static function getBrandForSearch($channel)
{
$result = array();
$brand = BrandData::getBrandsData($channel);
if (!empty($brand['data']['brands'])) {
$list = array();
$build = array();
foreach ($brand['data']['brands'] as $char => $value) {
foreach ($value as $row) {
$list['name'] = $row['brand_name'];
$list['isHot'] = ($row['is_hot'] === 'Y') ? true : false;
$list['isNew'] = ($row['is_show_new'] === 'Y') ? true : false;
$list['url'] = Helpers::url('', null, $row['brand_domain']);
$build[] = $list;
}
$result[$char] = $build;
}
}
$result['brandList'] = json_encode($result);
return $result;
}
}
... ...
<?php
use Action\AbstractAction;
use Plugin\Helpers;
/**
* 品牌相关的控制器
... ... @@ -54,28 +55,10 @@ class BrandController extends AbstractAction
$this->setTitle('品牌一览');
$this->setNavHeader('品牌一览');
/* 判断参数是否有效 */
$channel = null;
$gender = $this->get('gender');
if (!empty($gender)) {
switch ($gender) {
case '1,3': // 男
$channel = 1;
break;
case '2,3': // 女
$channel = 2;
break;
}
}
if (!isset($channel)) {
$channel = $this->get('channel', 1);
if (!is_numeric($channel) || intval($channel) > 4) {
$channel = 1;
}
}
$channel = Helpers::getChannelByCookie();
// 渲染模板
$this->_view->display('search', Category\BrandModel::getBrandByChannel($channel));
$this->_view->display('search', Category\BrandModel::getBrandForSearch($channel));
}
}
... ...
... ... @@ -179,6 +179,9 @@ class InfoController extends AbstractAction
}
}
// 标识有微信分享
$data['hasWxShare'] = true;
$this->_view->display('index', $data);
$detail = array();
... ...
... ... @@ -103,4 +103,11 @@ routes.goodsfilter.route.module = Index
routes.goodsfilter.route.controller = Search
routes.goodsfilter.route.action = Filter
; 品牌搜索
routes.productnew.type = "rewrite"
routes.productnew.match = "/brands/search$"
routes.productnew.route.module = Category
routes.productnew.route.controller = Brand
routes.productnew.route.action = Search
... ...