Authored by yangyang

修改品牌控制器结构

@@ -71,7 +71,7 @@ class Bootstrap extends Bootstrap_Abstract @@ -71,7 +71,7 @@ class Bootstrap extends Bootstrap_Abstract
71 $controller = 'Index'; 71 $controller = 'Index';
72 $action = 'Index'; 72 $action = 'Index';
73 // 二级域名 73 // 二级域名
74 - if (2 === $level) { 74 + if (3 === $level) {
75 $url = strtolower($dispatcher->getRequest()->getRequestUri()); 75 $url = strtolower($dispatcher->getRequest()->getRequestUri());
76 if(empty($url) || $url == '/index' || $url == '/') { 76 if(empty($url) || $url == '/index' || $url == '/') {
77 $urlAction = '/index'; 77 $urlAction = '/index';
@@ -76,8 +76,23 @@ class BrandsModel @@ -76,8 +76,23 @@ class BrandsModel
76 ); 76 );
77 } 77 }
78 78
79 -  
80 - 79 + //根据品牌域名处理相关品牌参数
  80 + public static function getBrandByDomain($domain, $fields)
  81 + {
  82 + $brandInfo = BrandData::getBrandLogoByDomain($domain, $fields);
  83 + $result = array();
  84 + if (!empty($brandInfo['data']) && $brandInfo['code'] == 200) {
  85 + $result['brandId'] = isset($brandInfo['data']['id']) ? $brandInfo['data']['id'] : '';
  86 + $result['node'] = isset($brandInfo['data']['static_content_code']) ? $brandInfo['data']['static_content_code'] : false;
  87 + $result['brandBanner'] = isset($brandInfo['data']['brand_banner']) ? $brandInfo['data']['brand_banner']: '';
  88 + $result['brandNameEn'] = isset($brandInfo['data']['brand_name_en']) ? $brandInfo['data']['brand_name_en'] : '';
  89 + $result['brandNameCn'] = isset($brandInfo['data']['brand_name_cn']) ? $brandInfo['data']['brand_name_cn'] : '';
  90 + $result['brandAbout'] = isset($brandInfo['data']['brand_intro']) ? $brandInfo['data']['brand_intro'] : '';
  91 + } else {
  92 + return false;
  93 + }
  94 + return $result;
  95 + }
81 96
82 97
83 98
@@ -2,6 +2,7 @@ @@ -2,6 +2,7 @@
2 use Action\WebAction; 2 use Action\WebAction;
3 use LibModels\Web\Product\BrandData; 3 use LibModels\Web\Product\BrandData;
4 use LibModels\Web\Product\FavoriteData; 4 use LibModels\Web\Product\FavoriteData;
  5 +use Product\BrandsModel;
5 6
6 use LibModels\Web\Product\HotrankData; 7 use LibModels\Web\Product\HotrankData;
7 use product\HotrankModel; 8 use product\HotrankModel;
@@ -13,29 +14,24 @@ class IndexController extends WebAction @@ -13,29 +14,24 @@ class IndexController extends WebAction
13 */ 14 */
14 public function brandAction() 15 public function brandAction()
15 { 16 {
16 - //品牌域名 17 + //品牌域名,没有获取到品牌域名的跳转首页
17 $domain = $this->param('named'); 18 $domain = $this->param('named');
18 if (empty($domain)) { 19 if (empty($domain)) {
19 $this->go(SITE_MAIN); 20 $this->go(SITE_MAIN);
20 } 21 }
21 - $uid = $this->getUid();  
22 - //根据品牌域名获取品牌id(同时判断品牌域名是否有效) 22 + //根据品牌域名获取品牌id(同时判断品牌域名是否有效),无效跳转首页
23 $fields = 'id,brand_name,brand_name_cn,brand_name_en,brand_domain,brand_alif,brand_banner,brand_ico,static_content_code'; 23 $fields = 'id,brand_name,brand_name_cn,brand_name_en,brand_domain,brand_alif,brand_banner,brand_ico,static_content_code';
24 - $brandInfo = BrandData::getBrandLogoByDomain($domain, $fields);  
25 -  
26 - if (!empty($brandInfo['data']) && $brandInfo['code'] == 200) {  
27 - $brandId = $brandInfo['data']['id'];  
28 - $node = isset($brandInfo['data']['static_content_code']) ? $brandInfo['data']['static_content_code'] : false;  
29 - $brandBanner = $brandInfo['data']['brand_banner'];  
30 - $brandNameEn = $brandInfo['data']['brand_name_en'];  
31 - $brandNameCn = $brandInfo['data']['brand_name_cn'];  
32 - } else { 24 + $result = BrandsModel::getBrandByDomain($domain, $fields);
  25 + if (!$result) {
33 $this->go(SITE_MAIN); 26 $this->go(SITE_MAIN);
34 } 27 }
35 28
36 - //品牌ID参数 29 + //获取uid
  30 + $uid = $this->getUid();
  31 +
  32 + //传品牌ID参数
37 $condition = array(); 33 $condition = array();
38 - $condition['brand'] = $brandId; 34 + $condition['brand'] = isset($result['brandId']) ? $result['brandId'] : '';
39 35
40 //品牌系列参数 36 //品牌系列参数
41 $folderId = $this->get('folder_id'); 37 $folderId = $this->get('folder_id');
@@ -45,15 +41,15 @@ class IndexController extends WebAction @@ -45,15 +41,15 @@ class IndexController extends WebAction
45 $options = array(); 41 $options = array();
46 $options['brandName'] = $domain; 42 $options['brandName'] = $domain;
47 $options['uid'] = $uid; 43 $options['uid'] = $uid;
48 - $options['brandId'] = $brandId;  
49 - $options['node'] = $node;  
50 - $options['brandBanner'] = $brandBanner;  
51 - $options['brandNameEn'] = $brandNameEn;  
52 - $options['brandNameCn'] = $brandNameCn; 44 + $options['brandId'] = isset($result['brandId']) ? $result['brandId'] : '';
  45 + $options['node'] = isset($result['node']) ? $result['node'] : '';
  46 + $options['brandBanner'] = isset($result['brandBanner']) ? $result['brandBanner'] : '';
  47 + $options['brandNameEn'] = isset($result['brandNameEn']) ? $result['brandNameEn'] : '';
  48 + $options['brandNameCn'] = isset($result['brandNameCn']) ? $result['brandNameCn'] : '';
53 $options['reviewNum'] = 6; 49 $options['reviewNum'] = 6;
54 50
55 //调用模型获得数据 51 //调用模型获得数据
56 - $data = Product\BrandsModel::getBrandSearchData($condition, $options); 52 + $data = BrandsModel::getBrandSearchData($condition, $options);
57 53
58 $data = array( 54 $data = array(
59 //初始化js 55 //初始化js
@@ -75,29 +71,26 @@ class IndexController extends WebAction @@ -75,29 +71,26 @@ class IndexController extends WebAction
75 $this->go(SITE_MAIN); 71 $this->go(SITE_MAIN);
76 } 72 }
77 $uid = $this->getUid(); 73 $uid = $this->getUid();
78 - //根据品牌域名获取品牌id(同时判断品牌域名是否有效)  
79 - $fields = 'id,brand_name,brand_name_cn,brand_banner,brand_ico,brand_intro';  
80 - $brandInfo = BrandData::getBrandLogoByDomain($domain, $fields);  
81 74
82 - if (!empty($brandInfo['data']) && $brandInfo['code'] == 200) {  
83 - $brandId = $brandInfo['data']['id'];  
84 - $brandBanner = $brandInfo['data']['brand_banner'];  
85 - $brandAbout = $brandInfo['data']['brand_intro'];  
86 - } else { 75 +
  76 + //根据品牌域名获取品牌id(同时判断品牌域名是否有效),无效跳转首页
  77 + $fields = 'id,brand_name,brand_name_cn,brand_banner,brand_ico,brand_intro';
  78 + $result = BrandsModel::getBrandByDomain($domain, $fields);
  79 + if (!$result) {
87 $this->go(SITE_MAIN); 80 $this->go(SITE_MAIN);
88 } 81 }
89 82
90 //品牌ID参数 83 //品牌ID参数
91 $condition = array(); 84 $condition = array();
92 - $condition['brand'] = $brandId; 85 + $condition['brand'] = isset($result['brandId']) ? $result['brandId'] : '';
93 86
94 //$options参数数组 87 //$options参数数组
95 $options = array(); 88 $options = array();
96 $options['brandName'] = $domain; 89 $options['brandName'] = $domain;
97 $options['uid'] = $uid; 90 $options['uid'] = $uid;
98 - $options['brandId'] = $brandId;  
99 - $options['brandBanner'] = $brandBanner;  
100 - $options['brandAbout'] = $brandAbout; 91 + $options['brandId'] = isset($result['brandId']) ? $result['brandId'] : '';
  92 + $options['brandBanner'] = isset($result['brandBanner']) ? $result['brandBanner'] : '';
  93 + $options['brandAbout'] = isset($result['brandAbout']) ? $result['brandAbout'] : '';
101 //调用模型获得数据 94 //调用模型获得数据
102 $data = Product\BrandsModel::getBrandIntro($condition, $options); 95 $data = Product\BrandsModel::getBrandIntro($condition, $options);
103 96