|
@@ -203,20 +203,9 @@ class SearchController extends AbstractAction |
|
@@ -203,20 +203,9 @@ class SearchController extends AbstractAction |
203
|
|
203
|
|
204
|
// 转换排序方式
|
204
|
// 转换排序方式
|
205
|
$page = $this->get('page', 1);
|
205
|
$page = $this->get('page', 1);
|
206
|
- $order = $this->get('order', 0);
|
206
|
+ $orderVal = $this->get('order', 0);
|
207
|
$type = $this->get('type', '');
|
207
|
$type = $this->get('type', '');
|
208
|
- switch ($type) {
|
|
|
209
|
- case 'price':
|
|
|
210
|
- $order = ($order == 0) ? 's_p_desc' : 's_p_asc';
|
|
|
211
|
- break;
|
|
|
212
|
- case 'discount':
|
|
|
213
|
- $order = ($order == 0) ? 'p_d_desc' : 'p_d_asc';
|
|
|
214
|
- break;
|
|
|
215
|
- case 'newest':
|
|
|
216
|
- default:
|
|
|
217
|
- $order = ($order == 0) ? 's_t_desc' : 's_t_asc';
|
|
|
218
|
- break;
|
|
|
219
|
- }
|
208
|
+ $order = Helpers::transOrder($orderVal, $type);
|
220
|
|
209
|
|
221
|
$data = array();
|
210
|
$data = array();
|
222
|
// 查询品类或品牌数据
|
211
|
// 查询品类或品牌数据
|
|
@@ -258,6 +247,56 @@ class SearchController extends AbstractAction |
|
@@ -258,6 +247,56 @@ class SearchController extends AbstractAction |
258
|
}
|
247
|
}
|
259
|
|
248
|
|
260
|
/**
|
249
|
/**
|
|
|
250
|
+ * Ajax异步获取筛选数据
|
|
|
251
|
+ * @return array 筛选数据
|
|
|
252
|
+ */
|
|
|
253
|
+ public function filterAction()
|
|
|
254
|
+ {
|
|
|
255
|
+ if ($this->isAjax()) {
|
|
|
256
|
+ // 过滤请求参数
|
|
|
257
|
+ $condition = filter_input_array(INPUT_GET, array(
|
|
|
258
|
+ 'query' => FILTER_DEFAULT,
|
|
|
259
|
+ 'brand' => FILTER_VALIDATE_INT,
|
|
|
260
|
+ 'sort' => FILTER_DEFAULT,
|
|
|
261
|
+ 'msort' => FILTER_VALIDATE_INT,
|
|
|
262
|
+ 'misort' => FILTER_VALIDATE_INT,
|
|
|
263
|
+ 'color' => FILTER_VALIDATE_INT,
|
|
|
264
|
+ 'size' => FILTER_VALIDATE_INT,
|
|
|
265
|
+ 'price' => FILTER_VALIDATE_INT,
|
|
|
266
|
+ 'discount' => FILTER_DEFAULT,
|
|
|
267
|
+ 'gender' => FILTER_DEFAULT,
|
|
|
268
|
+ 'p_d' => FILTER_DEFAULT,), false);
|
|
|
269
|
+
|
|
|
270
|
+ if (isset($condition['sort'])) {
|
|
|
271
|
+ $condition['sort'] = rawurldecode($condition['sort']);
|
|
|
272
|
+ }
|
|
|
273
|
+ if (isset($condition['discount'])) {
|
|
|
274
|
+ $condition['p_d'] = rawurldecode($condition['discount']);
|
|
|
275
|
+ unset($condition['discount']);
|
|
|
276
|
+ }
|
|
|
277
|
+ if (isset($condition['gender'])) {
|
|
|
278
|
+ $condition['gender'] = rawurldecode($condition['gender']);
|
|
|
279
|
+ }
|
|
|
280
|
+
|
|
|
281
|
+ $data = array();
|
|
|
282
|
+ $listData = SearchData::searchByCondition($condition);
|
|
|
283
|
+ // 处理返回的数据
|
|
|
284
|
+ if (isset($listData['data']) && isset($listData['data']['filter'])) {
|
|
|
285
|
+ $data['filter'] = ListProcess::getFilterData($listData['data']['filter']);
|
|
|
286
|
+ }
|
|
|
287
|
+ $listData = array();
|
|
|
288
|
+
|
|
|
289
|
+ if (empty($data)) {
|
|
|
290
|
+ echo ' ';
|
|
|
291
|
+ } else {
|
|
|
292
|
+ $this->_view->display('filter', $data);
|
|
|
293
|
+ }
|
|
|
294
|
+ } else {
|
|
|
295
|
+ echo ' ';
|
|
|
296
|
+ }
|
|
|
297
|
+ }
|
|
|
298
|
+
|
|
|
299
|
+ /**
|
261
|
* 模糊搜索指定字符
|
300
|
* 模糊搜索指定字符
|
262
|
*
|
301
|
*
|
263
|
* @return array 模糊搜索的结果
|
302
|
* @return array 模糊搜索的结果
|