Authored by 周少峰

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

... ... @@ -3,9 +3,11 @@ namespace Product;
use Plugin\Helpers;
use LibModels\Web\Product\BrandData;
use LibModels\Wap\Product\SearchData;
use LibModels\Web\Product\SearchData as WebProduct;
/**
* Description of Brands
* 品牌首页模板数据模型
*
* @author Administrator
*/
... ... @@ -16,6 +18,47 @@ class BrandsModel
public static $shopName;
public static $home;
/**
* 搜索品牌数据
*
* @param $condition array
* 搜索数据的条件
* @param $options array
* @return array
*/
public static function getBrandSearchData($condition, $options,$domain,$uid,$brandId)
{
// 调用商品搜索接口
$data = SearchData::searchElasticByCondition($condition);
//导航名
$brandName = self::$shopName;
$option['brandName'] = $brandName;
//配置调用分类接口参数
$param = array();
$param['brand'] = $condition['brand'];
//获取分类列表数据
$classes = WebProduct::getClassesData($param);
//获取品牌系列数据
$adNav = self::getAdNav($condition['brand']);
//获取品牌数据
$banner = self::getBannerByDomain($domain, $brandId, $uid = '');
//开始组装数据
return $data;
}
/**
* 获取品牌首页banner条
* @string $domain 品牌域名
... ... @@ -24,18 +67,18 @@ class BrandsModel
*
* @return array 品牌banner条数据
*/
public static function getBannerByDomain($domain, $bannerId, $uid = '')
public static function getBannerByDomain($domain, $brandId, $uid = '')
{
// 构造品牌主页url
self::$home = Helpers::url('', '', $domain) . self::URL_BRAND_INDEX;
// 根据品牌Id获取品牌banner图
$bannerImg = BrandData::getBrandBanner($bannerId);
$bannerImg = BrandData::getBrandBanner($brandId);
if (isset($bannerImg['data'])) {
$bannerImg = Helpers::getImageUrl($bannerImg['data']['banner'], '', 150);
}
// 根据品牌Id获取品牌(简介)、收藏
if (isset($uid)) {
$intro = BrandData::getBrandIntro($bannerId, $uid);
$intro = BrandData::getBrandIntro($brandId, $uid);
}
$is_favorite = false;
$logo = false;
... ... @@ -84,22 +127,13 @@ class BrandsModel
);
}
/**
* 搜索品牌数据
*
* @param $condition array
* 搜索数据的条件
* @param $options array
* @return array
*/
public static function getBrandSearchData($condition, $options)
{
//配置调用分类接口参数
$classes = array();
$classes['brand'] = $condition['brand'];
// 调用商品搜索接口
$data = \Product\SearchModel::getSearchData($condition, $options,$classes);
$advNav = BrandData::getFolderByBrand($condition['brand'],1);
//获取品牌系列数据
public static function getAdNav($brandId,$status = 1)
{//$condition['brand']
//调用接口获得数据
$advNav = BrandData::getFolderByBrand($brandId,$status);
$result = array();
if (isset($advNav['data']) && $advNav['code'] === 200) {
foreach ($advNav['data'] as $key => $value) {
... ... @@ -107,24 +141,8 @@ class BrandsModel
$result['list'][$key]['src'] = $value['brand_sort_ico'];
}
}
$data['list']['advNav'] = $result;
$shopName = self::$shopName;
if(isset($data['list'])){
$arr = array_chunk($data['list']['pathNav'],1);
$arr[0][] = Array(
'name' => $shopName
);
}
$nav = array_merge_recursive($arr[0],$arr[1]);
$data['list']['pathNav'] = $nav;
//删除品牌列表
unset($data['list']['filters']['brand']);
//删除折扣分类
unset($data['list']['allDiscount']);
//删除新品分类
unset($data['list']['newSales']);
return $data;
return $result;
//$data['list']['advNav'] = $result;
}
}
... ...
... ... @@ -16,15 +16,14 @@ class IndexController extends WebAction
$this->go(SITE_MAIN);
}
$uid = $this->getUid();
//根据品牌域名获取品牌id
//根据品牌域名获取品牌id(同时判断品牌域名是否有效)
$brandInfo = BrandData::getBrandLogoByDomain($domain);
if(!empty($brandInfo['data']) && $brandInfo['code'] === 200){
$brandId = $brandInfo['data']['id'];
}else{
$this->go(SITE_MAIN);
}
//获取品牌banner
$brandBanner = BrandsModel::getBannerByDomain($domain, $brandId, $uid = '');
/* 过滤请求参数 */
$condition = array();
$condition = filter_input_array(INPUT_GET, array(
... ... @@ -93,11 +92,9 @@ class IndexController extends WebAction
$params = $condition + $_GET;
$params = array_filter($params);
$data = Product\BrandsModel::getBrandSearchData($params,$options);
$data = Product\BrandsModel::getBrandSearchData($params,$options,$domain,$uid,$brandId);
$cate = array('boys','girls','kids','lifestyle');
$this->setWebNavHeader($cate[$gender-1]);
//合并banner与搜索数据
$data = array_merge_recursive($data,$brandBanner);
//渲染模板
$this->_view->display('list',$data);
}
... ...