Authored by hf

do brand search page

framework @ 75bbc3b0
1 -Subproject commit 119c247f5cf929aa1e059e40609bb16dd6b58f05 1 +Subproject commit 75bbc3b075de19f239532f60c5995d06c5f814e2
@@ -66,7 +66,7 @@ class BrandData @@ -66,7 +66,7 @@ class BrandData
66 } 66 }
67 $param['client_secret'] = Sign::getSign($param); 67 $param['client_secret'] = Sign::getSign($param);
68 68
69 - return Yohobuy::get(Yohobuy::API_URL, $param); 69 + return Yohobuy::get(Yohobuy::API_URL, $param, 3600); // 有缓存1小时
70 } 70 }
71 71
72 /** 72 /**
@@ -17,65 +17,203 @@ server @@ -17,65 +17,203 @@ server
17 allow 172.16.0.0/16; 17 allow 172.16.0.0/16;
18 deny all; 18 deny all;
19 19
20 - 20 + #账号相关
  21 + location = /reg.html {
  22 + root /Data/code/git/yohobuy/assets;
  23 + expires 7d;
  24 + }
  25 + location = /emailback.html {
  26 + root /Data/code/git/yohobuy/assets;
  27 + expires 7d;
  28 + }
  29 + location = /phoneback.html {
  30 + root /Data/code/git/yohobuy/assets;
  31 + expires 7d;
  32 + }
  33 + location = /error.html {
  34 + root /Data/code/git/yohobuy/assets;
  35 + expires 7d;
  36 + }
  37 + location ^~ /passport/back/ {
  38 + proxy_redirect off;
  39 + proxy_pass http://yohobuy;
  40 + proxy_set_header Host $host;
  41 + proxy_set_header X-Real-IP $remote_addr;
  42 + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  43 + proxy_set_header Accept-Encoding "gzip";
  44 + }
  45 + location ^~ /passport/reg/ {
  46 + proxy_redirect off;
  47 + proxy_pass http://yohobuy;
  48 + proxy_set_header Host $host;
  49 + proxy_set_header X-Real-IP $remote_addr;
  50 + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  51 + proxy_set_header Accept-Encoding "gzip";
  52 + }
21 53
  54 + #首页相关
  55 + location = / {
  56 + proxy_redirect off;
  57 + proxy_pass http://yohobuy;
  58 + proxy_set_header Host $host;
  59 + proxy_set_header X-Real-IP $remote_addr;
  60 + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  61 + proxy_set_header Accept-Encoding "gzip";
  62 + }
  63 + location = /boys {
  64 + proxy_redirect off;
  65 + proxy_pass http://yohobuy;
  66 + proxy_set_header Host $host;
  67 + proxy_set_header X-Real-IP $remote_addr;
  68 + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  69 + proxy_set_header Accept-Encoding "gzip";
  70 + }
  71 + location = /girls {
  72 + proxy_redirect off;
  73 + proxy_pass http://yohobuy;
  74 + proxy_set_header Host $host;
  75 + proxy_set_header X-Real-IP $remote_addr;
  76 + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  77 + proxy_set_header Accept-Encoding "gzip";
  78 + }
  79 + location = /kids {
  80 + proxy_redirect off;
  81 + proxy_pass http://yohobuy;
  82 + proxy_set_header Host $host;
  83 + proxy_set_header X-Real-IP $remote_addr;
  84 + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  85 + proxy_set_header Accept-Encoding "gzip";
  86 + }
  87 + location = /lifestyle {
  88 + proxy_redirect off;
  89 + proxy_pass http://yohobuy;
  90 + proxy_set_header Host $host;
  91 + proxy_set_header X-Real-IP $remote_addr;
  92 + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  93 + proxy_set_header Accept-Encoding "gzip";
  94 + }
  95 + location = /girl {
  96 + proxy_redirect off;
  97 + proxy_pass http://yohobuy;
  98 + proxy_set_header Host $host;
  99 + proxy_set_header X-Real-IP $remote_addr;
  100 + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  101 + proxy_set_header Accept-Encoding "gzip";
  102 + }
  103 +
  104 + # 商品相关
  105 + location = /cate {
  106 + proxy_redirect off;
  107 + proxy_pass http://yohobuy;
  108 + proxy_set_header Host $host;
  109 + proxy_set_header X-Real-IP $remote_addr;
  110 + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  111 + proxy_set_header Accept-Encoding "gzip";
  112 + }
  113 + location = /brands {
  114 + proxy_redirect off;
  115 + proxy_pass http://yohobuy;
  116 + proxy_set_header Host $host;
  117 + proxy_set_header X-Real-IP $remote_addr;
  118 + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  119 + proxy_set_header Accept-Encoding "gzip";
  120 + }
  121 + location = /sale {
  122 + proxy_redirect off;
  123 + proxy_pass http://yohobuy;
  124 + proxy_set_header Host $host;
  125 + proxy_set_header X-Real-IP $remote_addr;
  126 + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  127 + proxy_set_header Accept-Encoding "gzip";
  128 + }
  129 + location = /brands/search {
  130 + proxy_redirect off;
  131 + proxy_pass http://yohobuy;
  132 + proxy_set_header Host $host;
  133 + proxy_set_header X-Real-IP $remote_addr;
  134 + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  135 + proxy_set_header Accept-Encoding "gzip";
  136 + }
  137 + location = /product/new {
  138 + proxy_redirect off;
  139 + proxy_pass http://yohobuy;
  140 + proxy_set_header Host $host;
  141 + proxy_set_header X-Real-IP $remote_addr;
  142 + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  143 + proxy_set_header Accept-Encoding "gzip";
  144 + }
22 145
23 - # 子域名  
24 - if ($host = "sale.test.yoho.cn" ) { 146 + location ^~ /product/newsale/ {
  147 + proxy_redirect off;
  148 + proxy_pass http://yohobuy;
  149 + proxy_set_header Host $host;
  150 + proxy_set_header X-Real-IP $remote_addr;
  151 + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  152 + proxy_set_header Accept-Encoding "gzip";
  153 + }
  154 + location ^~ /product/opt/ {
25 proxy_redirect off; 155 proxy_redirect off;
26 - proxy_pass http://61.155.222.162;  
27 - proxy_set_header Host cuxiao.m.yohobuy.com; 156 + proxy_pass http://yohobuy;
  157 + proxy_set_header Host $host;
28 proxy_set_header X-Real-IP $remote_addr; 158 proxy_set_header X-Real-IP $remote_addr;
29 proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; 159 proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
30 proxy_set_header Accept-Encoding "gzip"; 160 proxy_set_header Accept-Encoding "gzip";
31 } 161 }
32 - if ($host = "cuxiao.test.yoho.cn" ) { 162 + location ^~ /product/recom/ {
33 proxy_redirect off; 163 proxy_redirect off;
34 - proxy_pass http://101.201.176.121;  
35 - proxy_set_header Host cuxiao.m.yohobuy.com; 164 + proxy_pass http://yohobuy;
  165 + proxy_set_header Host $host;
36 proxy_set_header X-Real-IP $remote_addr; 166 proxy_set_header X-Real-IP $remote_addr;
37 proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; 167 proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
38 proxy_set_header Accept-Encoding "gzip"; 168 proxy_set_header Accept-Encoding "gzip";
39 } 169 }
40 170
41 - # 账号相关  
42 - location =/signin.html { 171 + # 逛相关
  172 + location ^~ /guang/ {
43 proxy_redirect off; 173 proxy_redirect off;
44 - proxy_pass http://61.155.222.163;  
45 - proxy_set_header Host m.yohobuy.com; 174 + proxy_pass http://yohobuy;
  175 + proxy_set_header Host $host;
46 proxy_set_header X-Real-IP $remote_addr; 176 proxy_set_header X-Real-IP $remote_addr;
47 proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; 177 proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
48 proxy_set_header Accept-Encoding "gzip"; 178 proxy_set_header Accept-Encoding "gzip";
49 } 179 }
50 - location /passport/auth { 180 + location ^~ /tags/index {
51 proxy_redirect off; 181 proxy_redirect off;
52 - proxy_pass http://61.155.222.163;  
53 - proxy_set_header Host m.yohobuy.com; 182 + proxy_pass http://yohobuy;
  183 + proxy_set_header Host $host;
54 proxy_set_header X-Real-IP $remote_addr; 184 proxy_set_header X-Real-IP $remote_addr;
55 proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; 185 proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
56 proxy_set_header Accept-Encoding "gzip"; 186 proxy_set_header Accept-Encoding "gzip";
57 } 187 }
58 - location /passport/signin { 188 + location ^~ /author/index {
59 proxy_redirect off; 189 proxy_redirect off;
60 - proxy_pass http://61.155.222.163;  
61 - proxy_set_header Host m.yohobuy.com; 190 + proxy_pass http://yohobuy;
  191 + proxy_set_header Host $host;
  192 + proxy_set_header X-Real-IP $remote_addr;
  193 + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  194 + proxy_set_header Accept-Encoding "gzip";
  195 + }
  196 + location ^~ /info/index {
  197 + proxy_redirect off;
  198 + proxy_pass http://yohobuy;
  199 + proxy_set_header Host $host;
62 proxy_set_header X-Real-IP $remote_addr; 200 proxy_set_header X-Real-IP $remote_addr;
63 proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; 201 proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
64 proxy_set_header Accept-Encoding "gzip"; 202 proxy_set_header Accept-Encoding "gzip";
65 } 203 }
66 204
67 - # 个人中心  
68 - location /home { 205 + # 搜索相关
  206 + location ^~ /search {
69 proxy_redirect off; 207 proxy_redirect off;
70 - proxy_pass http://61.155.222.163;  
71 - proxy_set_header Host m.yohobuy.com; 208 + proxy_pass http://yohobuy;
  209 + proxy_set_header Host $host;
72 proxy_set_header X-Real-IP $remote_addr; 210 proxy_set_header X-Real-IP $remote_addr;
73 proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; 211 proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
74 proxy_set_header Accept-Encoding "gzip"; 212 proxy_set_header Accept-Encoding "gzip";
75 } 213 }
76 -  
77 - # 购物车  
78 - location /cart { 214 +
  215 + # 其它访问都跳到老版
  216 + location / {
79 proxy_redirect off; 217 proxy_redirect off;
80 proxy_pass http://61.155.222.163; 218 proxy_pass http://61.155.222.163;
81 proxy_set_header Host m.yohobuy.com; 219 proxy_set_header Host m.yohobuy.com;
@@ -83,14 +221,33 @@ server @@ -83,14 +221,33 @@ server
83 proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; 221 proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
84 proxy_set_header Accept-Encoding "gzip"; 222 proxy_set_header Accept-Encoding "gzip";
85 } 223 }
  224 +
  225 +# # 子域名
  226 +# if ($host = "sale.test.yoho.cn" ) {
  227 +# proxy_redirect off;
  228 +# proxy_pass http://61.155.222.162;
  229 +# proxy_set_header Host cuxiao.m.yohobuy.com;
  230 +# proxy_set_header X-Real-IP $remote_addr;
  231 +# proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  232 +# proxy_set_header Accept-Encoding "gzip";
  233 +# }
  234 +# if ($host = "cuxiao.test.yoho.cn" ) {
  235 +# proxy_redirect off;
  236 +# proxy_pass http://101.201.176.121;
  237 +# proxy_set_header Host cuxiao.m.yohobuy.com;
  238 +# proxy_set_header X-Real-IP $remote_addr;
  239 +# proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  240 +# proxy_set_header Accept-Encoding "gzip";
  241 +# }
86 242
87 - location ~* \.html$ {  
88 - root /Data/code/git/yohobuy/assets;  
89 - if (!-f $request_filename){  
90 - rewrite ^/(.*)$ http://m.yohobuy.com/$1 permanent;  
91 - }  
92 - expires 3m;  
93 - } 243 +
  244 + #location ~* \.html$ {
  245 +# root /Data/code/git/yohobuy/assets;
  246 +# if (!-f $request_filename){
  247 +# rewrite ^/(.*)$ http://m.yohobuy.com/$1 permanent;
  248 +# }
  249 +# expires 3m;
  250 +# }
94 251
95 location ~* \.(ico|woff|svg|eot|ttf|otf)$ { 252 location ~* \.(ico|woff|svg|eot|ttf|otf)$ {
96 expires 30d; 253 expires 30d;
@@ -15,5 +15,8 @@ @@ -15,5 +15,8 @@
15 <div class="search-result"> 15 <div class="search-result">
16 </div> 16 </div>
17 </div> 17 </div>
  18 +<script type="text/tmpl">
  19 + {{{brandList}}}
  20 +</script>
18 {{> layout/footer}} 21 {{> layout/footer}}
19 {{> layout/download_app}} 22 {{> layout/download_app}}
@@ -18,6 +18,7 @@ use Plugin\Helpers; @@ -18,6 +18,7 @@ use Plugin\Helpers;
18 class BrandModel 18 class BrandModel
19 { 19 {
20 /* 男生频道取品牌广告及热门品牌数据的位置码 */ 20 /* 男生频道取品牌广告及热门品牌数据的位置码 */
  21 +
21 const CODE_TOPPOS_BOYS = 'ce6ac059493ec26241a8cbe0bfa1b17a'; 22 const CODE_TOPPOS_BOYS = 'ce6ac059493ec26241a8cbe0bfa1b17a';
22 /* 女生频道取品牌广告及热门品牌数据的位置码 */ 23 /* 女生频道取品牌广告及热门品牌数据的位置码 */
23 const CODE_TOPPOS_GIRLS = 'dac99cdedc1f948e84c145aca561f7d2'; 24 const CODE_TOPPOS_GIRLS = 'dac99cdedc1f948e84c145aca561f7d2';
@@ -25,7 +26,7 @@ class BrandModel @@ -25,7 +26,7 @@ class BrandModel
25 const CODE_TOPPOS_KIDS = '713784f93f52bb1a7b93916b2bb15510'; 26 const CODE_TOPPOS_KIDS = '713784f93f52bb1a7b93916b2bb15510';
26 /* 创意生活频道取品牌广告及热门品牌数据的位置码 */ 27 /* 创意生活频道取品牌广告及热门品牌数据的位置码 */
27 const CODE_TOPPOS_LIFESTYLE = 'f1aa914fd23cbcda71a87de6f5416c75'; 28 const CODE_TOPPOS_LIFESTYLE = 'f1aa914fd23cbcda71a87de6f5416c75';
28 - 29 +
29 /** 30 /**
30 * 根据频道获取品牌一览数据 31 * 根据频道获取品牌一览数据
31 * 32 *
@@ -36,7 +37,7 @@ class BrandModel @@ -36,7 +37,7 @@ class BrandModel
36 { 37 {
37 $result = array(); 38 $result = array();
38 $brand = array(); 39 $brand = array();
39 - 40 +
40 /* 根据频道调用接口 */ 41 /* 根据频道调用接口 */
41 switch (intval($channel)) { 42 switch (intval($channel)) {
42 case 1: // 男生 43 case 1: // 男生
@@ -52,14 +53,14 @@ class BrandModel @@ -52,14 +53,14 @@ class BrandModel
52 $brand = BrandData::package(self::CODE_TOPPOS_LIFESTYLE, 4); 53 $brand = BrandData::package(self::CODE_TOPPOS_LIFESTYLE, 4);
53 break; 54 break;
54 } 55 }
55 - 56 +
56 // 模板中的使用JS标识 57 // 模板中的使用JS标识
57 $result['brandPage'] = true; 58 $result['brandPage'] = true;
58 // 是否显示app下载浮层标识 59 // 是否显示app下载浮层标识
59 $result['showDownloadApp'] = true; 60 $result['showDownloadApp'] = true;
60 // 搜索链接地址 61 // 搜索链接地址
61 - $result['searchUrl'] = Helpers::url('/search.html', null, 'search');  
62 - 62 + $result['searchUrl'] = Helpers::url('/brands/search', null);
  63 +
63 /* 顶部的轮翻广告列表 */ 64 /* 顶部的轮翻广告列表 */
64 if (!empty($brand['brandTop'][0]['data'])) { 65 if (!empty($brand['brandTop'][0]['data'])) {
65 $build = array(); 66 $build = array();
@@ -70,7 +71,7 @@ class BrandModel @@ -70,7 +71,7 @@ class BrandModel
70 $result['bannerTop']['list'][] = $build; 71 $result['bannerTop']['list'][] = $build;
71 } 72 }
72 } 73 }
73 - 74 +
74 /* 顶部的热门品牌列表 */ 75 /* 顶部的热门品牌列表 */
75 if (!empty($brand['brandTop'][1]['data']['list'])) { 76 if (!empty($brand['brandTop'][1]['data']['list'])) {
76 $build = array(); 77 $build = array();
@@ -81,7 +82,7 @@ class BrandModel @@ -81,7 +82,7 @@ class BrandModel
81 $result['hotBrand']['list'][] = $build; 82 $result['hotBrand']['list'][] = $build;
82 } 83 }
83 } 84 }
84 - 85 +
85 /* 按字母'A-Z'分组的品牌列表 */ 86 /* 按字母'A-Z'分组的品牌列表 */
86 if (!empty($brand['brandList']['brands'])) { 87 if (!empty($brand['brandList']['brands'])) {
87 $list = array(); 88 $list = array();
@@ -93,18 +94,48 @@ class BrandModel @@ -93,18 +94,48 @@ class BrandModel
93 $list['name'] = $row['brand_name']; 94 $list['name'] = $row['brand_name'];
94 $list['isHot'] = ($row['is_hot'] === 'Y') ? true : false; 95 $list['isHot'] = ($row['is_hot'] === 'Y') ? true : false;
95 $list['isNew'] = ($row['is_show_new'] === 'Y') ? true : false; 96 $list['isNew'] = ($row['is_show_new'] === 'Y') ? true : false;
96 - $list['url'] = 'http://' . $row['brand_domain'] . SUB_DOMAIN; 97 + $list['url'] = Helpers::url('', null, $row['brand_domain']);
97 $build['list'][] = $list; 98 $build['list'][] = $list;
98 } 99 }
99 $result['brandList'][] = $build; 100 $result['brandList'][] = $build;
100 } 101 }
101 } 102 }
102 - 103 +
103 $result['pageFooter'] = true; 104 $result['pageFooter'] = true;
104 - 105 +
105 $brand = array(); 106 $brand = array();
  107 +
  108 + return $result;
  109 + }
  110 +
  111 + /**
  112 + * 获取搜索的品牌列表
  113 + *
  114 + * @param int $channel 1表示男生频道, 2表示女生频道, 3表示潮童频道, 4表示创意生活频道
  115 + * @return array
  116 + */
  117 + public static function getBrandForSearch($channel)
  118 + {
  119 + $result = array();
106 120
  121 + $brand = BrandData::getBrandsData($channel);
  122 + if (!empty($brand['data']['brands'])) {
  123 + $list = array();
  124 + $build = array();
  125 + foreach ($brand['data']['brands'] as $char => $value) {
  126 + foreach ($value as $row) {
  127 + $list['name'] = $row['brand_name'];
  128 + $list['isHot'] = ($row['is_hot'] === 'Y') ? true : false;
  129 + $list['isNew'] = ($row['is_show_new'] === 'Y') ? true : false;
  130 + $list['url'] = Helpers::url('', null, $row['brand_domain']);
  131 + $build[] = $list;
  132 + }
  133 + $result[$char] = $build;
  134 + }
  135 + }
  136 + $result['brandList'] = json_encode($result);
  137 +
107 return $result; 138 return $result;
108 } 139 }
109 - 140 +
110 } 141 }
1 <?php 1 <?php
2 2
3 use Action\AbstractAction; 3 use Action\AbstractAction;
  4 +use Plugin\Helpers;
4 5
5 /** 6 /**
6 * 品牌相关的控制器 7 * 品牌相关的控制器
@@ -54,28 +55,10 @@ class BrandController extends AbstractAction @@ -54,28 +55,10 @@ class BrandController extends AbstractAction
54 $this->setTitle('品牌一览'); 55 $this->setTitle('品牌一览');
55 $this->setNavHeader('品牌一览'); 56 $this->setNavHeader('品牌一览');
56 57
57 - /* 判断参数是否有效 */  
58 - $channel = null;  
59 - $gender = $this->get('gender');  
60 - if (!empty($gender)) {  
61 - switch ($gender) {  
62 - case '1,3': // 男  
63 - $channel = 1;  
64 - break;  
65 - case '2,3': // 女  
66 - $channel = 2;  
67 - break;  
68 - }  
69 - }  
70 - if (!isset($channel)) {  
71 - $channel = $this->get('channel', 1);  
72 - if (!is_numeric($channel) || intval($channel) > 4) {  
73 - $channel = 1;  
74 - }  
75 - } 58 + $channel = Helpers::getChannelByCookie();
76 59
77 // 渲染模板 60 // 渲染模板
78 - $this->_view->display('search', Category\BrandModel::getBrandByChannel($channel)); 61 + $this->_view->display('search', Category\BrandModel::getBrandForSearch($channel));
79 } 62 }
80 63
81 } 64 }
@@ -178,6 +178,9 @@ class InfoController extends AbstractAction @@ -178,6 +178,9 @@ class InfoController extends AbstractAction
178 $data['shareImg'] = Helpers::getImageUrl($detail['getArticle']['cover_image'], 640, 320); 178 $data['shareImg'] = Helpers::getImageUrl($detail['getArticle']['cover_image'], 640, 320);
179 } 179 }
180 } 180 }
  181 +
  182 + // 标识有微信分享
  183 + $data['hasWxShare'] = true;
181 184
182 $this->_view->display('index', $data); 185 $this->_view->display('index', $data);
183 186
@@ -103,4 +103,11 @@ routes.goodsfilter.route.module = Index @@ -103,4 +103,11 @@ routes.goodsfilter.route.module = Index
103 routes.goodsfilter.route.controller = Search 103 routes.goodsfilter.route.controller = Search
104 routes.goodsfilter.route.action = Filter 104 routes.goodsfilter.route.action = Filter
105 105
  106 +; 品牌搜索
  107 +routes.productnew.type = "rewrite"
  108 +routes.productnew.match = "/brands/search$"
  109 +routes.productnew.route.module = Category
  110 +routes.productnew.route.controller = Brand
  111 +routes.productnew.route.action = Search
  112 +
106 113