Index.php
3.99 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
<?php
use Action\WebAction;
use Product\BrandsModel;
use LibModels\Web\Product\BrandData;
class IndexController extends WebAction
{
/**
* 品牌首页
*/
public function brandAction()
{
//品牌域名
$domain = $this->param('named');
if (empty($domain)) {
$this->go(SITE_MAIN);
}
$uid = $this->getUid();
//根据品牌域名获取品牌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 = filter_input_array(INPUT_GET, array(
//'query' => FILTER_SANITIZE_STRING,
'sort' => FILTER_VALIDATE_INT,
'msort' => FILTER_VALIDATE_INT,
'misort' => FILTER_VALIDATE_INT,
'color' => FILTER_VALIDATE_INT,
'size' => FILTER_VALIDATE_INT,
'style' => FILTER_DEFAULT,
'price' => FILTER_DEFAULT,
'gender' => FILTER_DEFAULT,
'p_d' => FILTER_DEFAULT,
'shelve_time' => FILTER_DEFAULT,
'parameter_790' => FILTER_DEFAULT,
'parameter_824' => FILTER_DEFAULT,
'parameter_825' => FILTER_DEFAULT,
'parameter_787' => FILTER_DEFAULT,
'isNew' => FILTER_DEFAULT,
'specialoffer' => FILTER_DEFAULT,
'limited' => FILTER_DEFAULT,
'order' => FILTER_DEFAULT,
'viewNum' => FILTER_VALIDATE_INT,
'rowNum' => FILTER_VALIDATE_INT,
'page' => FILTER_VALIDATE_INT,), false);
if(!empty($condition)) {
//字符转码
foreach ($condition as &$value) {
$value = rawurldecode($value);
}
}
//传品牌ID参数
$condition['brand'] = $brandId;
//获取性别数据
$gender_cookie = !isset($_COOKIE['_Gender']) ? '3' : ($_COOKIE['_Gender']=='2,3' ? 2 : 1);
$gender = $this->get('gender') ? ($this->get('gender') == '2,3' ? 2 : 1) : $gender_cookie;
$condition['gender'] = $gender;
//每页显示商品数
if(!isset($condition['viewNum']) || empty($condition['viewNum'])){
$condition['viewNum'] = 60;
}
$view_num_arr = array(60, 100, 200);
if (!in_array($condition['viewNum'], $view_num_arr)) {
$condition['viewNum'] = 60;
}
//每行显示的商品数量
if(!isset($condition['rowNum']) || empty($condition['rowNum'])){
$condition['rowNum'] = 5;
}
if ($condition['rowNum'] == 6) {
$imgSize = array(195, 260);
$minImgSize = array(50, 67);
} else {
$condition['rowNum'] = 5;
$imgSize = array(235, 314);
$minImgSize = array(60, 80);
}
//搜索词
//$query = $this->get('query');
$condition['needFilter'] = 1;
$options = array(
'imgSize' => $imgSize,
'minImgSize' => $minImgSize,
'gender' => $gender,
'needPd' => 'Y',
'rowNum' => $condition['rowNum'],
'viewNum' => $condition['viewNum'],
);
$params = $condition + $_GET;
$params = array_filter($params);
$data = Product\BrandsModel::getBrandSearchData($params,$options);
$cate = array('boys','girls','kids','lifestyle');
$this->setWebNavHeader($cate[$gender-1]);
//合并banner与搜索数据
$data = array_merge_recursive($data,$brandBanner);
//删除搜索参数中的品牌选项
//渲染模板
$this->_view->display('list',$data);
}
}
?>