Authored by 周少峰

Merge branch 'feature/web-list' of git.dev.yoho.cn:web/yohobuy into feature/web-list

@@ -3,9 +3,11 @@ namespace Product; @@ -3,9 +3,11 @@ namespace Product;
3 3
4 use Plugin\Helpers; 4 use Plugin\Helpers;
5 use LibModels\Web\Product\BrandData; 5 use LibModels\Web\Product\BrandData;
  6 +use LibModels\Wap\Product\SearchData;
  7 +use LibModels\Web\Product\SearchData as WebProduct;
6 8
7 /** 9 /**
8 - * Description of Brands 10 + * 品牌首页模板数据模型
9 * 11 *
10 * @author Administrator 12 * @author Administrator
11 */ 13 */
@@ -16,6 +18,47 @@ class BrandsModel @@ -16,6 +18,47 @@ class BrandsModel
16 18
17 public static $shopName; 19 public static $shopName;
18 public static $home; 20 public static $home;
  21 +
  22 + /**
  23 + * 搜索品牌数据
  24 + *
  25 + * @param $condition array
  26 + * 搜索数据的条件
  27 + * @param $options array
  28 + * @return array
  29 + */
  30 + public static function getBrandSearchData($condition, $options,$domain,$uid,$brandId)
  31 + {
  32 +
  33 + // 调用商品搜索接口
  34 + $data = SearchData::searchElasticByCondition($condition);
  35 +
  36 + //导航名
  37 + $brandName = self::$shopName;
  38 + $option['brandName'] = $brandName;
  39 +
  40 + //配置调用分类接口参数
  41 + $param = array();
  42 + $param['brand'] = $condition['brand'];
  43 + //获取分类列表数据
  44 + $classes = WebProduct::getClassesData($param);
  45 +
  46 +
  47 + //获取品牌系列数据
  48 + $adNav = self::getAdNav($condition['brand']);
  49 +
  50 +
  51 + //获取品牌数据
  52 + $banner = self::getBannerByDomain($domain, $brandId, $uid = '');
  53 +
  54 +
  55 + //开始组装数据
  56 +
  57 +
  58 + return $data;
  59 + }
  60 +
  61 +
19 /** 62 /**
20 * 获取品牌首页banner条 63 * 获取品牌首页banner条
21 * @string $domain 品牌域名 64 * @string $domain 品牌域名
@@ -24,18 +67,18 @@ class BrandsModel @@ -24,18 +67,18 @@ class BrandsModel
24 * 67 *
25 * @return array 品牌banner条数据 68 * @return array 品牌banner条数据
26 */ 69 */
27 - public static function getBannerByDomain($domain, $bannerId, $uid = '') 70 + public static function getBannerByDomain($domain, $brandId, $uid = '')
28 { 71 {
29 // 构造品牌主页url 72 // 构造品牌主页url
30 self::$home = Helpers::url('', '', $domain) . self::URL_BRAND_INDEX; 73 self::$home = Helpers::url('', '', $domain) . self::URL_BRAND_INDEX;
31 // 根据品牌Id获取品牌banner图 74 // 根据品牌Id获取品牌banner图
32 - $bannerImg = BrandData::getBrandBanner($bannerId); 75 + $bannerImg = BrandData::getBrandBanner($brandId);
33 if (isset($bannerImg['data'])) { 76 if (isset($bannerImg['data'])) {
34 $bannerImg = Helpers::getImageUrl($bannerImg['data']['banner'], '', 150); 77 $bannerImg = Helpers::getImageUrl($bannerImg['data']['banner'], '', 150);
35 } 78 }
36 // 根据品牌Id获取品牌(简介)、收藏 79 // 根据品牌Id获取品牌(简介)、收藏
37 if (isset($uid)) { 80 if (isset($uid)) {
38 - $intro = BrandData::getBrandIntro($bannerId, $uid); 81 + $intro = BrandData::getBrandIntro($brandId, $uid);
39 } 82 }
40 $is_favorite = false; 83 $is_favorite = false;
41 $logo = false; 84 $logo = false;
@@ -84,22 +127,13 @@ class BrandsModel @@ -84,22 +127,13 @@ class BrandsModel
84 ); 127 );
85 } 128 }
86 129
87 - /**  
88 - * 搜索品牌数据  
89 - *  
90 - * @param $condition array  
91 - * 搜索数据的条件  
92 - * @param $options array  
93 - * @return array  
94 - */  
95 - public static function getBrandSearchData($condition, $options)  
96 - {  
97 - //配置调用分类接口参数  
98 - $classes = array();  
99 - $classes['brand'] = $condition['brand'];  
100 - // 调用商品搜索接口  
101 - $data = \Product\SearchModel::getSearchData($condition, $options,$classes);  
102 - $advNav = BrandData::getFolderByBrand($condition['brand'],1); 130 +
  131 +
  132 + //获取品牌系列数据
  133 + public static function getAdNav($brandId,$status = 1)
  134 + {//$condition['brand']
  135 + //调用接口获得数据
  136 + $advNav = BrandData::getFolderByBrand($brandId,$status);
103 $result = array(); 137 $result = array();
104 if (isset($advNav['data']) && $advNav['code'] === 200) { 138 if (isset($advNav['data']) && $advNav['code'] === 200) {
105 foreach ($advNav['data'] as $key => $value) { 139 foreach ($advNav['data'] as $key => $value) {
@@ -107,24 +141,8 @@ class BrandsModel @@ -107,24 +141,8 @@ class BrandsModel
107 $result['list'][$key]['src'] = $value['brand_sort_ico']; 141 $result['list'][$key]['src'] = $value['brand_sort_ico'];
108 } 142 }
109 } 143 }
110 - $data['list']['advNav'] = $result;  
111 - $shopName = self::$shopName;  
112 - if(isset($data['list'])){  
113 - $arr = array_chunk($data['list']['pathNav'],1);  
114 - $arr[0][] = Array(  
115 - 'name' => $shopName  
116 - );  
117 - }  
118 - $nav = array_merge_recursive($arr[0],$arr[1]);  
119 -  
120 - $data['list']['pathNav'] = $nav;  
121 - //删除品牌列表  
122 - unset($data['list']['filters']['brand']);  
123 - //删除折扣分类  
124 - unset($data['list']['allDiscount']);  
125 - //删除新品分类  
126 - unset($data['list']['newSales']);  
127 - return $data; 144 + return $result;
  145 + //$data['list']['advNav'] = $result;
128 } 146 }
129 147
130 } 148 }
@@ -16,15 +16,14 @@ class IndexController extends WebAction @@ -16,15 +16,14 @@ class IndexController extends WebAction
16 $this->go(SITE_MAIN); 16 $this->go(SITE_MAIN);
17 } 17 }
18 $uid = $this->getUid(); 18 $uid = $this->getUid();
19 - //根据品牌域名获取品牌id 19 + //根据品牌域名获取品牌id(同时判断品牌域名是否有效)
20 $brandInfo = BrandData::getBrandLogoByDomain($domain); 20 $brandInfo = BrandData::getBrandLogoByDomain($domain);
21 if(!empty($brandInfo['data']) && $brandInfo['code'] === 200){ 21 if(!empty($brandInfo['data']) && $brandInfo['code'] === 200){
22 $brandId = $brandInfo['data']['id']; 22 $brandId = $brandInfo['data']['id'];
23 }else{ 23 }else{
24 $this->go(SITE_MAIN); 24 $this->go(SITE_MAIN);
25 } 25 }
26 - //获取品牌banner  
27 - $brandBanner = BrandsModel::getBannerByDomain($domain, $brandId, $uid = ''); 26 +
28 /* 过滤请求参数 */ 27 /* 过滤请求参数 */
29 $condition = array(); 28 $condition = array();
30 $condition = filter_input_array(INPUT_GET, array( 29 $condition = filter_input_array(INPUT_GET, array(
@@ -93,11 +92,9 @@ class IndexController extends WebAction @@ -93,11 +92,9 @@ class IndexController extends WebAction
93 92
94 $params = $condition + $_GET; 93 $params = $condition + $_GET;
95 $params = array_filter($params); 94 $params = array_filter($params);
96 - $data = Product\BrandsModel::getBrandSearchData($params,$options); 95 + $data = Product\BrandsModel::getBrandSearchData($params,$options,$domain,$uid,$brandId);
97 $cate = array('boys','girls','kids','lifestyle'); 96 $cate = array('boys','girls','kids','lifestyle');
98 $this->setWebNavHeader($cate[$gender-1]); 97 $this->setWebNavHeader($cate[$gender-1]);
99 - //合并banner与搜索数据  
100 - $data = array_merge_recursive($data,$brandBanner);  
101 //渲染模板 98 //渲染模板
102 $this->_view->display('list',$data); 99 $this->_view->display('list',$data);
103 } 100 }