From a808b2d42789b87f4ed6060b29d8340884ac3490 Mon Sep 17 00:00:00 2001
From: hf <fei.hong@yoho.cn>
Date: Tue, 27 Oct 2015 21:20:37 +0800
Subject: [PATCH] compact with the old station url access rule, and configure the sub domain eg guang,list,search,brands...

---
 library/LibModels/Wap/Category/BrandData.php                             |   2 +-
 yohobuy/m.yohobuy.com/application/models/Category/Brand.php              |   3 +++
 yohobuy/m.yohobuy.com/application/modules/Category/controllers/Brand.php | 262 +++++++++++++++++++++++-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
 yohobuy/m.yohobuy.com/configs/routes.index.ini                           |  17 ++++++++++++-----
 4 files changed, 39 insertions(+), 245 deletions(-)

diff --git a/library/LibModels/Wap/Category/BrandData.php b/library/LibModels/Wap/Category/BrandData.php
index 07675fb..ed80bd9 100644
--- a/library/LibModels/Wap/Category/BrandData.php
+++ b/library/LibModels/Wap/Category/BrandData.php
@@ -44,7 +44,7 @@ class BrandData
         $param['method'] = 'app.brand.brandlist';
         $param['yh_channel'] = $channel;
         $param['client_secret'] = Sign::getSign($param);
-        $urlList['brandList'] = Yohobuy::httpBuildQuery(Yohobuy::API_URL, $param);
+        $urlList['brandList'] = Yohobuy::httpBuildQuery(Yohobuy::API_URL, $param, 3600); // 有缓存1小时
 
         return Yohobuy::getMulti($urlList);
     }
diff --git a/yohobuy/m.yohobuy.com/application/models/Category/Brand.php b/yohobuy/m.yohobuy.com/application/models/Category/Brand.php
index e079236..3b9c306 100644
--- a/yohobuy/m.yohobuy.com/application/models/Category/Brand.php
+++ b/yohobuy/m.yohobuy.com/application/models/Category/Brand.php
@@ -53,6 +53,9 @@ class BrandModel
                 break;
         }
         
+        // 模板中的使用JS标识
+        $result['brandPage'] = true;
+        
         /* 顶部的轮翻广告列表 */
         if (!empty($brand['brandTop'][0]['data'])) {
             $build = array();
diff --git a/yohobuy/m.yohobuy.com/application/modules/Category/controllers/Brand.php b/yohobuy/m.yohobuy.com/application/modules/Category/controllers/Brand.php
index 39b7c3b..4c6315b 100644
--- a/yohobuy/m.yohobuy.com/application/modules/Category/controllers/Brand.php
+++ b/yohobuy/m.yohobuy.com/application/modules/Category/controllers/Brand.php
@@ -1,4 +1,5 @@
 <?php
+
 use Action\AbstractAction;
 
 /**
@@ -6,257 +7,40 @@ use Action\AbstractAction;
  */
 class BrandController extends AbstractAction
 {
+
     /**
      * 品牌一览
      * 
+     * @param string gender 老版本中使用的参数, 做兼容判断
      * @param int channel 1表示男生频道, 2表示女生频道, 3表示潮童频道, 4表示创意生活频道
      */
     public function indexAction()
     {
         $this->setTitle('品牌一览');
         $this->setNavHeader('品牌一览');
-        
+
         /* 判断参数是否有效 */
-        $channel = $this->get('channel', 1);
-        if (!is_numeric($channel) || intval($channel) > 4) {
-            $channel = 1;
+        $channel = null;
+        $gender = $this->get('gender');
+        if (!empty($gender)) {
+            switch ($gender) {
+                case '1,3': // 男
+                    $channel = 1;
+                    break;
+                case '2,3': // 女
+                    $channel = 2;
+                    break;
+            }
         }
-        
-        /* 获取渲染模板需要的数据 */
-        /*$data = Category\BrandModel::getBrandByChannel($channel);
-        if (!is_array($data)) {
-            $data = array();
+        if (!isset($channel)) {
+            $channel = $this->get('channel', 1);
+            if (!is_numeric($channel) || intval($channel) > 4) {
+                $channel = 1;
+            }
         }
-        $data['brandPage'] = true;
- 
-    	$brandTop = array();
-    	if($brandTopData['code'] == 200)
-    	{
-    		$brandTop = $brandTopData['data'];
-    	}
-    	$brands = array();
-    	if($brandsData['code'] == 200)
-    	{
-    		$brands =  $brandsData['data'];
-    	}
-
-    	/*echo '<pre>';
-    	var_dump($brandTop, $brands);exit;*/
- 
-        $data = array (
-            'brandPage' => true,
-            'pageHeader' => array (
-                'navBack' => 'sss ',
-                'navHome' => 'sss ',
-                'navTitle' => 'sss '
-            ),
-            'bannerTop' => array (
-                'list' => array (
-                        array (
-                            'url' => '',
-                            'img' => 'http://img10.static.yhbimg.com/adpic/2015/10/15/10/01c161398d3baec2868abe85e26ba1a71d.jpg?imageMogr2/thumbnail/640x300/extent/640x300/background/d2hpdGU=/position/center/quality/90'
-                        ),
-                        array (
-                            'url' => '',
-                            'img' => 'http://img13.static.yhbimg.com/adpic/2015/10/15/10/027c45cdc03e23c367ec0ff3d29b7c3f79.jpg?imageMogr2/thumbnail/640x300/extent/640x300/background/d2hpdGU=/position/center/quality/90'
-                        ),
-                        array (
-                            'url' => '',
-                            'img' => 'http://img13.static.yhbimg.com/adpic/2015/10/15/10/022e2ac6daa33fc3cb8a0f04025a35994f.jpg?imageMogr2/thumbnail/640x300/extent/640x300/background/d2hpdGU=/position/center/quality/90'
-                        )
-                )
-            ),
-            'hotBrand' => array (
-                'list' => array (
-                        array (
-                            'url' => '',
-                            'img' => 'http://img13.static.yhbimg.com/brandLogo/2014/08/12/17/0233d54f34d2534c08271a8fc27090a6af.jpg?imageMogr2/thumbnail/144x144/extent/144x144/background/d2hpdGU=/position/center/quality/90'
-                        ),
-                        array (
-                            'url' => '',
-                            'img' => 'http://img12.static.yhbimg.com/brandLogo/2014/01/27/11/020b17265b2103b49005c57395b8b154a9.jpg?imageMogr2/thumbnail/144x144/extent/144x144/background/d2hpdGU=/position/center/quality/90'
-                        ),
-                        array (
-                            'url' => '',
-                            'img' => 'http://img13.static.yhbimg.com/brandLogo/2014/11/27/09/02b403bdcbfb965bdc632fea5c29816746.png?imageMogr2/thumbnail/144x144/extent/144x144/background/d2hpdGU=/position/center/quality/90'
-                        ),
-                        array (
-                            'url' => '',
-                            'img' => 'http://img13.static.yhbimg.com/brandLogo/2013/11/01/14/027e68260ba30c01b165c17fe043f2ce2c.jpg?imageMogr2/thumbnail/144x144/extent/144x144/background/d2hpdGU=/position/center/quality/90'
-                        ),
-                        array (
-                            'url' => '',
-                            'img' => 'http://img11.static.yhbimg.com/brandLogo/2014/04/25/14/0179fa8eacf51fd1a89ec6f7fdeab88fc2.jpg?imageMogr2/thumbnail/144x144/extent/144x144/background/d2hpdGU=/position/center/quality/90'
-                        ),
-                        array (
-                            'url' => '',
-                            'img' => 'http://img12.static.yhbimg.com/brandLogo/2014/01/27/11/02608437f8d8b6b7b15786214b0a5ef502.jpg?imageMogr2/thumbnail/144x144/extent/144x144/background/d2hpdGU=/position/center/quality/90'
-                        ),
-                        array (
-                            'url' => '',
-                            'img' => 'http://img12.static.yhbimg.com/brandLogo/2013/02/28/17/020aae69720d683a7962c9b7fd3a92c801.jpg?imageMogr2/thumbnail/144x144/extent/144x144/background/d2hpdGU=/position/center/quality/90'
-                        ),
-                        array (
-                            'url' => '',
-                            'img' => 'http://img13.static.yhbimg.com/brandLogo/2014/01/27/11/02bca7ac6414c7475b4a337e28a0365590.jpg?imageMogr2/thumbnail/144x144/extent/144x144/background/d2hpdGU=/position/center/quality/90'
-                        )
-                )
-            ),
-           'brandList' => array (
-                array (
-                    'title' => '0~9',
-                    'list' => array(
-                         array (
-                            'name' => '004',
-                            'isHot' => true
-                         ),
-                         array (
-                            'name' => '10*1',
-                            'isNew' => true
-                         ),
-                         array (
-                            'name' => '2%'
-                        )
-                     ) 
-                ),
-                array (
-                    'title' => 'A',
-                    'list' => array(
-                         array (
-                            'name' => 'Aape',
-                            'isHot' => true
-                         ),
-                         array (
-                            'name' => 'Adfdfd',
-                            'isNew' => true
-                         ),
-                         array (
-                            'name' => 'Acrwewwe'
-                        )
-                     ) 
-                ),
-                array (
-                    'title' => 'B',
-                    'list' => array(
-                         array (
-                            'name' => 'Bape'
-                         ),
-                         array (
-                            'name' => 'Bdfdfd'
-                         ),
-                         array (
-                            'name' => 'Bcrwewwe'
-                        )
-                     ) 
-                ),
-                array (
-                    'title' => 'B',
-                    'list' => array(
-                         array (
-                            'name' => 'Bape'
-                         ),
-                         array (
-                            'name' => 'Bdfdfd'
-                         ),
-                         array (
-                            'name' => 'Bcrwewwe'
-                        )
-                     ) 
-                ),
-                array (
-                    'title' => 'B',
-                    'list' => array(
-                         array (
-                            'name' => 'Bape'
-                         ),
-                         array (
-                            'name' => 'Bdfdfd'
-                         ),
-                         array (
-                            'name' => 'Bcrwewwe'
-                        )
-                     ) 
-                ),
-                array (
-                    'title' => 'B',
-                    'list' => array(
-                         array (
-                            'name' => 'Bape'
-                         ),
-                         array (
-                            'name' => 'Bdfdfd'
-                         ),
-                         array (
-                            'name' => 'Bcrwewwe'
-                        )
-                     ) 
-                ),
-                array (
-                    'title' => 'B',
-                    'list' => array(
-                         array (
-                            'name' => 'Bape'
-                         ),
-                         array (
-                            'name' => 'Bdfdfd'
-                         ),
-                         array (
-                            'name' => 'Bcrwewwe'
-                        )
-                     ) 
-                ),
-                array (
-                    'title' => 'B',
-                    'list' => array(
-                         array (
-                            'name' => 'Bape'
-                         ),
-                         array (
-                            'name' => 'Bdfdfd'
-                         ),
-                         array (
-                            'name' => 'Bcrwewwe'
-                        )
-                     ) 
-                ),
-                array (
-                    'title' => 'B',
-                    'list' => array(
-                         array (
-                            'name' => 'Bape'
-                         ),
-                         array (
-                            'name' => 'Bdfdfd'
-                         ),
-                         array (
-                            'name' => 'Bcrwewwe'
-                        )
-                     ) 
-                ),
-                array (
-                    'title' => 'B',
-                    'list' => array(
-                         array (
-                            'name' => 'Bape'
-                         ),
-                         array (
-                            'name' => 'Bdfdfd'
-                         ),
-                         array (
-                            'name' => 'Bcrwewwe'
-                        )
-                     ) 
-                )
-            )
-
-
-        );
-
-            
-		$this->_view->assign('title', 'YOHO!有货');
-    	//$this->_view->display('brand', compact('brands'));
 
         // 渲染模板
-        $this->_view->display('index', $data);
+        $this->_view->display('index', Category\BrandModel::getBrandByChannel($channel));
     }
-}
\ No newline at end of file
+
+}
diff --git a/yohobuy/m.yohobuy.com/configs/routes.index.ini b/yohobuy/m.yohobuy.com/configs/routes.index.ini
index da328b9..b746d9a 100644
--- a/yohobuy/m.yohobuy.com/configs/routes.index.ini
+++ b/yohobuy/m.yohobuy.com/configs/routes.index.ini
@@ -55,10 +55,17 @@ routes.emailback.route.controller = Back
 routes.emailback.route.action = Email
 
 ; 所有品类
-routes.reg.type = "rewrite"
-routes.reg.match = "/cate"
-routes.reg.route.module = Category
-routes.reg.route.controller = Class
-routes.reg.route.action = Index
+routes.cate.type = "rewrite"
+routes.cate.match = "/cate"
+routes.cate.route.module = Category
+routes.cate.route.controller = Class
+routes.cate.route.action = Index
+
+; 品牌一览
+routes.brands.type = "rewrite"
+routes.brands.match = "/brands"
+routes.brands.route.module = Category
+routes.brands.route.controller = Brand
+routes.brands.route.action = Index
 
 
--
libgit2 0.24.0