Index.php
7.72 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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
<?php
use Action\AbstractAction;
use Plugin\Helpers;
/**
* 商品列表相关的控制器
*
*/
class IndexController extends AbstractAction
{
/**
* 品类商品列表页
*
* @param string $gender "1,3"表示男, "2,3"表示女, "1,2,3"表示全部
* @param integer $brand 品牌Id
* @param integer $sort 品类查询sort参数
* @param integer $color 颜色Id
* @param integer $size 尺码Id
* @param string $price 价格
* @param string $p_d 折扣
*/
public function indexAction()
{
// 过滤请求参数
$condition = filter_input_array(INPUT_GET, array(
'brand' => FILTER_DEFAULT,
'sort' => FILTER_DEFAULT,
'msort' => FILTER_DEFAULT,
'misort' => FILTER_DEFAULT,
'color' => FILTER_DEFAULT,
'size' => FILTER_DEFAULT,
'style' => FILTER_DEFAULT,
'price' => FILTER_DEFAULT,
'discount' => FILTER_DEFAULT,
'gender' => FILTER_DEFAULT,
'p_d' => FILTER_DEFAULT,), false);
// 转义品牌
if (isset($condition['brand'])) {
$condition['brand'] = rawurldecode($condition['brand']);
}
// 转义分类
if (isset($condition['sort'])) {
$condition['sort'] = rawurldecode($condition['sort']);
}
// 转义一级分类
if (isset($condition['msort'])) {
$condition['msort'] = rawurldecode($condition['msort']);
}
// 转义二级分类
if (isset($condition['misort'])) {
$condition['misort'] = rawurldecode($condition['misort']);
}
// 转义颜色
if (isset($condition['color'])) {
$condition['color'] = rawurldecode($condition['color']);
}
// 转义尺码
if (isset($condition['size'])) {
$condition['size'] = rawurldecode($condition['size']);
}
// 转义风格
if (isset($condition['style'])) {
$condition['style'] = rawurldecode($condition['style']);
}
// 转义价格
if (isset($condition['price'])) {
$condition['price'] = rawurldecode($condition['price']);
}
// 转换折扣
if (isset($condition['discount'])) {
$condition['p_d'] = rawurldecode($condition['discount']);
}
// 为了兼容现在运营在用的p_d
if (isset($condition['p_d'])) {
$condition['discount'] = rawurldecode($condition['p_d']);
}
// 性别参数,不传则从COOKIE获取
if (!isset($condition['gender'])) {
$condition['gender'] = Helpers::getGenderByCookie();
} else {
$condition['gender'] = rawurldecode($condition['gender']);
}
// 品类名称参数, 不传则默认为全部
$name = $this->get('sort_name');
if (empty($name)) {
$name = $this->get('title', '全部');
}
$this->setTitle($name);
$this->setNavHeader($name, true, SITE_MAIN);
if (!$condition) {
$condition = array();
}
$goodList = $condition;
$goodList['cartUrl'] = Helpers::url('/cart/index/index', null);
$this->_view->display('index', array(
'goodListPage' => true,
'showDownloadApp' => true,
'goodList' => $goodList,
'pageFooter' => true,
));
}
/**
* 品牌商品列表页
*
* @param string $gender "1,3"表示男, "2,3"表示女, "1,2,3"表示全部
* @param integer $sort 品类查询sort参数
* @param integer $color 颜色Id
* @param integer $size 尺码Id
* @param string $price 价格
* @param string $p_d 折扣
*/
public function brandAction()
{
/* 品牌域名参数 @see Bootstrap.php */
$domain = $this->param('named');
if (empty($domain)) {
$this->go(SITE_MAIN);
}
// 存标题信息
$title = '';
$brandLogo = Product\ListModel::getBrandLogoByDomain($domain, $title);
$brandId = 0;
if ($brandLogo && isset($brandLogo['id'])) {
$brandId = $brandLogo['id'];
}
// 当前的登录用户UID
$uid = $this->getUid();
/* 搜索框相关 */
$from = $this->get('from');
$query = $this->get('query');
/* 过滤请求参数 */
$condition = filter_input_array(INPUT_GET, array(
'sort' => FILTER_DEFAULT,
'msort' => FILTER_DEFAULT,
'misort' => FILTER_DEFAULT,
'color' => FILTER_DEFAULT,
'size' => FILTER_DEFAULT,
'style' => FILTER_DEFAULT,
'price' => FILTER_DEFAULT,
'discount' => FILTER_DEFAULT,
'gender' => FILTER_DEFAULT,
'p_d' => FILTER_DEFAULT,), false);
$condition['brand'] = $brandId;
// 转义分类
if (isset($condition['sort'])) {
$condition['sort'] = rawurldecode($condition['sort']);
}
// 转义一级分类
if (isset($condition['msort'])) {
$condition['msort'] = rawurldecode($condition['msort']);
}
// 转义二级分类
if (isset($condition['misort'])) {
$condition['misort'] = rawurldecode($condition['misort']);
}
// 转义颜色
if (isset($condition['color'])) {
$condition['color'] = rawurldecode($condition['color']);
}
// 转义尺码
if (isset($condition['size'])) {
$condition['size'] = rawurldecode($condition['size']);
}
// 转义风格
if (isset($condition['style'])) {
$condition['style'] = rawurldecode($condition['style']);
}
// 转义价格
if (isset($condition['price'])) {
$condition['price'] = rawurldecode($condition['price']);
}
// 转换折扣
if (isset($condition['discount'])) {
$condition['p_d'] = rawurldecode($condition['discount']);
}
// 为了兼容现在运营在用的p_d
if (isset($condition['p_d'])) {
$condition['discount'] = rawurldecode($condition['p_d']);
}
if ($brandId === 0) {
$condition['query'] = $domain;
}
if (isset($condition['gender'])) {
$condition['gender'] = rawurldecode($condition['gender']);
}/* else {
$condition['gender'] = Helpers::getGenderByCookie();
}*/
$data = array();
$data['goodListPage'] = true;
$data['showDownloadApp'] = true;
// 从搜索页过来的,显示搜索框, 和进入品牌引导信息
if ($from === 'search') {
$data['goodList'] = array();
//$data['goodList']['brandWay'] = \Product\ListModel::getBrandLogoByIds($brandId, $title);
$data['goodList']['brandWay'] = $brandLogo;
$data['goodList']['search']['default'] = $query;
$data['goodList']['search']['url'] = Helpers::url('', null, 'search');
}
// 品牌一览过来的展示品牌介绍和LOGO
elseif ($brandId !== 0) {
$data['brandHome'] = \Product\ListModel::getBrandIntro($brandId, $uid, $title);
$data['goodList'] = array();
}
// 右下角的购物车链接
$data['goodList']['cartUrl'] = Helpers::url('/cart/index/index', null);
$data['goodList'] += $condition;
$data['pageFooter'] = true;
if (empty($title)) {
$title = $domain;
}
$this->setTitle($title);
$this->setNavHeader($title, true, SITE_MAIN);
$this->_view->display('index', $data);
}
}