Authored by 周少峰

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

... ... @@ -105,14 +105,13 @@ class HelperSearch
//分类
$result['leftContent'][]['allSort'] = isset($filter['group_sort']) ? self::groupSort($filter['group_sort'], $options) : array();
//一周新品上架
$result['leftContent'][]['newSales'] = self::recentShelve($filter['recent']);
$result['leftContent'][]['newSales'] = isset($filter['recent']) ? self::recentShelve($filter['recent']) : array();
//全部折扣
$result['leftContent'][]['allDiscount'] = self::getDiscount($filter['discount']);
$result['leftContent'][]['allDiscount'] = isset($filter['discount']) ? self::getDiscount($filter['discount']) : array();
//总记录数
$result['totalCount'] = $data['data']['total'];
//分页
$result['pager'] = self::pager($result['totalCount'],$options['viewNum']);
//echo $result['pager']; exit;
//选中条件
$result['filters']['checkedConditions']['conditions'] = self::getSelected();
$result['pathNav'] = self::$listnav;
... ...
<?php
namespace Product;
use Plugin\Helpers;
use Plugin\HelperSearch;
use LibModels\Web\Product\BrandData;
use LibModels\Wap\Product\SearchData;
use LibModels\Web\Product\SearchData as WebProduct;
... ... @@ -11,15 +13,14 @@ use LibModels\Web\Product\SearchData as WebProduct;
*
* @author Administrator
*/
class BrandsModel
{
class BrandsModel {
const URL_BRAND_INDEX = '/product/index/brand';
public static $shopName;
public static $home;
/**
/**
* 搜索品牌数据
*
* @param $condition array
... ... @@ -27,38 +28,59 @@ class BrandsModel
* @param $options array
* @return array
*/
public static function getBrandSearchData($condition, $options,$domain,$uid,$brandId)
{
public static function getBrandSearchData($condition, $options, $domain, $uid, $brandId) {
// 调用商品搜索接口
$data = SearchData::searchElasticByCondition($condition);
//获取品牌banner数据
$banner = self::getBannerByDomain($domain, $brandId, $uid = '');
//导航名
$brandName = self::$shopName;
$option['brandName'] = $brandName;
//配置调用分类接口参数
$param = array();
$param['brand'] = $condition['brand'];
//获取分类列表数据
$classes = WebProduct::getClassesData($param);
if (isset($data['code']) && $data['code'] === 200) {
//获取分类列表数据
$param = array();
$param['brand'] = $condition['brand'];
$classes = WebProduct::getClassesData($param);
if (isset($classes['code']) && $classes['code'] === 200) {
$data['data']['filter']['group_sort'] = $classes['data']['sort'];
}
$brandName = self::$shopName;
$options['brandName'] = $brandName;
//用户浏览记录
// 组织模板数据
$list = HelperSearch::getList($data, $options);
//合并商品搜索数据与品牌banner数据
$data = array_merge_recursive($data, $banner);
$data = array(
//初始化js
'productListPage' => true,
'list' => $list
);
} else {
$data = array();
}
//获取品牌系列数据
$adNav = self::getAdNav($condition['brand']);
//获取品牌数据
$banner = self::getBannerByDomain($domain, $brandId, $uid = '');
//开始组装数据
$data['list']['leftContent'][] = array('picLink' => $adNav);
return $data;
}
/**
* 获取品牌首页banner条
* @string $domain 品牌域名
... ... @@ -67,8 +89,7 @@ class BrandsModel
*
* @return array 品牌banner条数据
*/
public static function getBannerByDomain($domain, $brandId, $uid = '')
{
public static function getBannerByDomain($domain, $brandId, $uid = '') {
// 构造品牌主页url
self::$home = Helpers::url('', '', $domain) . self::URL_BRAND_INDEX;
// 根据品牌Id获取品牌banner图
... ... @@ -83,9 +104,9 @@ class BrandsModel
$is_favorite = false;
$logo = false;
$shopName = false;
do {
if (! isset($intro['data'])) {
if (!isset($intro['data'])) {
break;
}
// 获取是否收藏
... ... @@ -99,7 +120,7 @@ class BrandsModel
// 获取品牌名
self::$shopName = $intro['data']['brand_name'];
} while (false);
// 返回banner数据
return array(
'list' => array(
... ... @@ -127,22 +148,18 @@ class BrandsModel
);
}
//获取品牌系列数据
public static function getAdNav($brandId,$status = 1)
{//$condition['brand']
public static function getAdNav($brandId, $status = 1) {
//调用接口获得数据
$advNav = BrandData::getFolderByBrand($brandId,$status);
$advNav = BrandData::getFolderByBrand($brandId, $status);
$result = array();
if (isset($advNav['data']) && $advNav['code'] === 200) {
foreach ($advNav['data'] as $key => $value) {
$result['list'][$key]['href'] = self::$home . '?folder=' . $value['id'];
$result['list'][$key]['href'] = self::$home . '?folder_id=' . $value['id'];
$result['list'][$key]['src'] = $value['brand_sort_ico'];
}
}
return $result;
//$data['list']['advNav'] = $result;
}
}
... ...
<?php
namespace Product;
use Configs\CacheConfig;
use Plugin\Images;
use Plugin\Cache;
use Plugin\HelperSearch;
use \LibModels\Web\Product\SearchData;
... ...