Brands.php
3.55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
<?php
namespace Product;
use Plugin\Helpers;
use LibModels\Web\Product\BrandData;
use Product\SearchModel;
/**
* Description of Brands
*
* @author Administrator
*/
class BrandsModel
{
const URL_BRAND_INDEX = '/product/brands/index';
public static $shopName;
/**
* 获取品牌首页banner条
* @string $domain 品牌域名
* @int $brandId 品牌id
* @int $uid 用户id
*
* @return array 品牌banner条数据
*/
public static function getBannerByDomain($domain, $bannerId, $uid = '')
{
// 构造品牌主页url
$home = Helpers::url('', '', $domain) . self::URL_BRAND_INDEX;
// 根据品牌Id获取品牌banner图
$bannerImg = BrandData::getBrandBanner($bannerId);
if (isset($bannerImg['data'])) {
$bannerImg = Helpers::getImageUrl($bannerImg['data']['banner'], '', 150);
}
// 根据品牌Id获取品牌(简介)、收藏
if (isset($uid)) {
$intro = BrandData::getBrandIntro($bannerId, $uid);
}
$is_favorite = false;
$logo = false;
$shopName = false;
do {
if (! isset($intro['data'])) {
break;
}
// 获取是否收藏
if ($intro['data']['is_favorite'] == 'Y') {
$is_favorite = true;
} elseif ($intro['data']['is_favorite'] == 'N') {
$is_favorite = false;
}
// 获取品牌logo
$logo = Helpers::getImageUrl($intro['data']['brand_ico'], 80, 50);
// 获取品牌名
self::$shopName = $intro['data']['brand_name'];
} while (false);
// 返回banner数据
return array(
'list' => array(
'brandBanner' => array(
'bannerHeight' => '150',
'coled' => $is_favorite,
'banner' => $bannerImg
),
'shopEntry' => array(
'home' => $home,
'logo' => $logo,
'shopName' => self::$shopName,
'sort' => array(
array(
'href' => '',
'name' => 'T恤'
),
array(
'href' => '',
'name' => '卫衣'
)
)
)
)
);
}
/**
* 搜索品牌数据
*
* @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);
$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;
}
}