|
@@ -13,8 +13,7 @@ class HelperSearch |
|
@@ -13,8 +13,7 @@ class HelperSearch |
13
|
*/
|
13
|
*/
|
14
|
public static $params = array();
|
14
|
public static $params = array();
|
15
|
|
15
|
|
16
|
- private static $from = '';
|
|
|
17
|
-
|
16
|
+ public static $options = array();
|
18
|
//当前页
|
17
|
//当前页
|
19
|
public static $page = 1;
|
18
|
public static $page = 1;
|
20
|
|
19
|
|
|
@@ -29,19 +28,13 @@ class HelperSearch |
|
@@ -29,19 +28,13 @@ class HelperSearch |
29
|
*/
|
28
|
*/
|
30
|
public static $listnav = array();
|
29
|
public static $listnav = array();
|
31
|
|
30
|
|
32
|
-
|
|
|
33
|
- private static function setFrom($from = '')
|
|
|
34
|
- {
|
|
|
35
|
- if ($from) {
|
|
|
36
|
- self::$from = $from;
|
|
|
37
|
- }
|
|
|
38
|
- }
|
|
|
39
|
//设置导航
|
31
|
//设置导航
|
40
|
- private static function setListNav($option = array())
|
32
|
+ private static function setListNav()
|
41
|
{
|
33
|
{
|
|
|
34
|
+ $options = self::$options;
|
42
|
$cookieChannel = isset($_COOKIE['_Channel']) ? $_COOKIE['_Channel'] : 'boys';
|
35
|
$cookieChannel = isset($_COOKIE['_Channel']) ? $_COOKIE['_Channel'] : 'boys';
|
43
|
- if (isset($option['brandName']) && !empty($option['brandName'])) {
|
|
|
44
|
- $initNav = $option['brandName'];
|
36
|
+ if (isset($options['brandName']) && !empty($options['brandName'])) {
|
|
|
37
|
+ $initNav = $options['brandName'];
|
45
|
}else{
|
38
|
}else{
|
46
|
$initNav = '列表';
|
39
|
$initNav = '列表';
|
47
|
}
|
40
|
}
|
|
@@ -64,6 +57,7 @@ class HelperSearch |
|
@@ -64,6 +57,7 @@ class HelperSearch |
64
|
{
|
57
|
{
|
65
|
$result = array();
|
58
|
$result = array();
|
66
|
self::$params = $_GET;
|
59
|
self::$params = $_GET;
|
|
|
60
|
+ self::$options = $options;
|
67
|
unset(self::$params['/']);
|
61
|
unset(self::$params['/']);
|
68
|
unset(self::$params['page']);
|
62
|
unset(self::$params['page']);
|
69
|
unset(self::$params['/sale']);
|
63
|
unset(self::$params['/sale']);
|
|
@@ -80,10 +74,8 @@ class HelperSearch |
|
@@ -80,10 +74,8 @@ class HelperSearch |
80
|
$result['filters']['checkedConditions']['clearUrl'] = self::current();
|
74
|
$result['filters']['checkedConditions']['clearUrl'] = self::current();
|
81
|
//频道
|
75
|
//频道
|
82
|
$result['filters']['channel'] = self::gender($filter);
|
76
|
$result['filters']['channel'] = self::gender($filter);
|
83
|
- //分类
|
|
|
84
|
- $result['filters']['sort'] = array();
|
|
|
85
|
//品牌
|
77
|
//品牌
|
86
|
- $result['filters']['brand'] = self::brand($filter, $options);
|
78
|
+ $result['filters']['brand'] = self::brand($filter);
|
87
|
//价格
|
79
|
//价格
|
88
|
$result['filters']['price'] = self::price($filter);
|
80
|
$result['filters']['price'] = self::price($filter);
|
89
|
$result['filters']['customPrice'] = self::customPrice($filter);
|
81
|
$result['filters']['customPrice'] = self::customPrice($filter);
|
|
@@ -109,8 +101,10 @@ class HelperSearch |
|
@@ -109,8 +101,10 @@ class HelperSearch |
109
|
$result['opts']['pageCount'] = $data['data']['page_total'];
|
101
|
$result['opts']['pageCount'] = $data['data']['page_total'];
|
110
|
$result['opts']['nextHref'] = ($next = self::next($data['data']['page_total'],$data['data']['filter'])) ? $next['href'] : '';
|
102
|
$result['opts']['nextHref'] = ($next = self::next($data['data']['page_total'],$data['data']['filter'])) ? $next['href'] : '';
|
111
|
$result['hasNextPage'] = self::next($data['data']['page_total']);
|
103
|
$result['hasNextPage'] = self::next($data['data']['page_total']);
|
112
|
- //分类
|
|
|
113
|
- $result['leftContent'][]['allSort'] = isset($filter['group_sort']) ? self::groupSort($filter['group_sort'], $options) : array();
|
104
|
+ //分类条件
|
|
|
105
|
+ $result['filters']['sort'] = isset($filter['group_sort']) ? self::searchSort($filter['group_sort']) : array();
|
|
|
106
|
+ //左侧分类分类
|
|
|
107
|
+ $result['leftContent'][]['allSort'] = isset($filter['group_sort']) ? self::groupSort($filter['group_sort']) : array();
|
114
|
//一周新品上架
|
108
|
//一周新品上架
|
115
|
$result['leftContent'][]['newSales'] = isset($filter['recent']) ? self::recentShelve($filter['recent']) : array();
|
109
|
$result['leftContent'][]['newSales'] = isset($filter['recent']) ? self::recentShelve($filter['recent']) : array();
|
116
|
//全部折扣
|
110
|
//全部折扣
|
|
@@ -121,6 +115,9 @@ class HelperSearch |
|
@@ -121,6 +115,9 @@ class HelperSearch |
121
|
$result['pager'] = self::pager($result['totalCount'],$options['viewNum']);
|
115
|
$result['pager'] = self::pager($result['totalCount'],$options['viewNum']);
|
122
|
//选中条件
|
116
|
//选中条件
|
123
|
$result['filters']['checkedConditions']['conditions'] = self::getSelected();
|
117
|
$result['filters']['checkedConditions']['conditions'] = self::getSelected();
|
|
|
118
|
+ if (isset($options['controller']) && $options['controller'] == 'Search') {
|
|
|
119
|
+ self::setSearchNav($data['data']['total']);
|
|
|
120
|
+ }
|
124
|
$result['pathNav'] = self::$listnav;
|
121
|
$result['pathNav'] = self::$listnav;
|
125
|
return $result;
|
122
|
return $result;
|
126
|
}
|
123
|
}
|
|
@@ -193,6 +190,9 @@ class HelperSearch |
|
@@ -193,6 +190,9 @@ class HelperSearch |
193
|
'name' => $pval['standard_name'],
|
190
|
'name' => $pval['standard_name'],
|
194
|
'href' => self::buildUrl($tmpParams)
|
191
|
'href' => self::buildUrl($tmpParams)
|
195
|
);
|
192
|
);
|
|
|
193
|
+ if (self::checkSearch('parameter_' . $val['standard_id'])) {
|
|
|
194
|
+ return array();
|
|
|
195
|
+ }
|
196
|
}
|
196
|
}
|
197
|
$sub[] = array(
|
197
|
$sub[] = array(
|
198
|
'name' => $pval['standard_name'],
|
198
|
'name' => $pval['standard_name'],
|
|
@@ -232,6 +232,10 @@ class HelperSearch |
|
@@ -232,6 +232,10 @@ class HelperSearch |
232
|
'href' => self::buildUrl($params)
|
232
|
'href' => self::buildUrl($params)
|
233
|
);
|
233
|
);
|
234
|
}
|
234
|
}
|
|
|
235
|
+
|
|
|
236
|
+ if (self::checkSearch('gender')) {
|
|
|
237
|
+ return array();
|
|
|
238
|
+ }
|
235
|
$result = array();
|
239
|
$result = array();
|
236
|
foreach ($filter['gender'] as $key => $val) {
|
240
|
foreach ($filter['gender'] as $key => $val) {
|
237
|
$result[] = array(
|
241
|
$result[] = array(
|
|
@@ -247,14 +251,18 @@ class HelperSearch |
|
@@ -247,14 +251,18 @@ class HelperSearch |
247
|
/**
|
251
|
/**
|
248
|
* 组织搜索列表页面的左侧分类
|
252
|
* 组织搜索列表页面的左侧分类
|
249
|
* @param array $sort
|
253
|
* @param array $sort
|
250
|
- * @param array $option
|
|
|
251
|
* @return array
|
254
|
* @return array
|
252
|
*/
|
255
|
*/
|
253
|
|
256
|
|
254
|
- public static function groupSort($sort, $option = array())
|
257
|
+ public static function groupSort($sort)
|
255
|
{
|
258
|
{
|
|
|
259
|
+
|
|
|
260
|
+ $options = self::$options;
|
|
|
261
|
+ if (isset($options['controller']) && $options['controller'] != 'Search') {
|
|
|
262
|
+ return array();
|
|
|
263
|
+ }
|
256
|
//设置导航
|
264
|
//设置导航
|
257
|
- self::setListNav($option);
|
265
|
+ self::setListNav($options);
|
258
|
$params = self::$params;
|
266
|
$params = self::$params;
|
259
|
$result = array(
|
267
|
$result = array(
|
260
|
'all' => array(
|
268
|
'all' => array(
|
|
@@ -294,16 +302,48 @@ class HelperSearch |
|
@@ -294,16 +302,48 @@ class HelperSearch |
294
|
}
|
302
|
}
|
295
|
}
|
303
|
}
|
296
|
$result['list'] = $sortList;
|
304
|
$result['list'] = $sortList;
|
|
|
305
|
+
|
297
|
return $result;
|
306
|
return $result;
|
298
|
}
|
307
|
}
|
299
|
|
308
|
|
|
|
309
|
+ public static function searchSort($sort)
|
|
|
310
|
+ {
|
|
|
311
|
+ $result = array();
|
|
|
312
|
+ $options = self::$options;
|
|
|
313
|
+ if (!isset($options['controller']) || $options['controller'] != 'Search') {
|
|
|
314
|
+ return $result;
|
|
|
315
|
+ }
|
|
|
316
|
+ $params = self::$params;
|
|
|
317
|
+ foreach ($sort as $key => $val) {
|
|
|
318
|
+ $result[$key]['id'] = $val['sort_id'];
|
|
|
319
|
+ $result[$key]['name'] = $val['sort_name'];
|
|
|
320
|
+ if (isset($val['sub']) && !empty($val['sub'])) {
|
|
|
321
|
+ foreach ($val['sub'] as $k => $v) {
|
|
|
322
|
+ $result[$key]['sub'][$k]['href'] = self::buildUrl(array('msort' => $val['sort_id'], 'misort' => $v['sort_id']));
|
|
|
323
|
+ $result[$key]['sub'][$k]['name'] = $v['sort_name'];
|
|
|
324
|
+ if (isset($params['misort']) && $params['misort'] == $v['sort_id']) {
|
|
|
325
|
+ unset($params['misort']);
|
|
|
326
|
+ self::$selected['sort'] = array(
|
|
|
327
|
+ 'name' => $v['sort_name'],
|
|
|
328
|
+ 'href' => self::buildUrl()
|
|
|
329
|
+ );
|
|
|
330
|
+ }
|
|
|
331
|
+
|
|
|
332
|
+ }
|
|
|
333
|
+ }
|
|
|
334
|
+ }
|
|
|
335
|
+ if (self::checkSearch('msrot') || self::checkSearch('misort')) {
|
|
|
336
|
+ return array();
|
|
|
337
|
+ }
|
|
|
338
|
+ return $result;
|
|
|
339
|
+ }
|
300
|
/**
|
340
|
/**
|
301
|
* 品牌,可以多选
|
341
|
* 品牌,可以多选
|
302
|
* @param array $filter
|
342
|
* @param array $filter
|
303
|
- * @param array $options
|
|
|
304
|
* @return array
|
343
|
* @return array
|
305
|
*/
|
344
|
*/
|
306
|
- public static function brand($filter, $options = array()) {
|
345
|
+ public static function brand($filter) {
|
|
|
346
|
+ $options = self::$options;
|
307
|
//品牌列表返回空
|
347
|
//品牌列表返回空
|
308
|
if (isset($options['brandName'])) {
|
348
|
if (isset($options['brandName'])) {
|
309
|
return array();
|
349
|
return array();
|
|
@@ -311,11 +351,15 @@ class HelperSearch |
|
@@ -311,11 +351,15 @@ class HelperSearch |
311
|
$result = array(
|
351
|
$result = array(
|
312
|
'default' => array() ,
|
352
|
'default' => array() ,
|
313
|
'brandIndex' => array(
|
353
|
'brandIndex' => array(
|
314
|
- '0~9',
|
|
|
315
|
- 'A~G',
|
|
|
316
|
- 'H~N',
|
|
|
317
|
- 'O~T',
|
|
|
318
|
- 'U~Z') ,
|
354
|
+ array(
|
|
|
355
|
+ 'index' => 'all',
|
|
|
356
|
+ 'name' => '全部'
|
|
|
357
|
+ ),
|
|
|
358
|
+ array(
|
|
|
359
|
+ 'index' => '0-9',
|
|
|
360
|
+ 'name' => '0 ~ 9'
|
|
|
361
|
+ )
|
|
|
362
|
+ ),
|
319
|
'brandsShow' => array()
|
363
|
'brandsShow' => array()
|
320
|
);
|
364
|
);
|
321
|
$params = self::$params;
|
365
|
$params = self::$params;
|
|
@@ -341,12 +385,18 @@ class HelperSearch |
|
@@ -341,12 +385,18 @@ class HelperSearch |
341
|
)));
|
385
|
)));
|
342
|
}
|
386
|
}
|
343
|
$this_brand = array(
|
387
|
$this_brand = array(
|
344
|
- 'brand_id' => $v['id'],
|
|
|
345
|
- 'name' => $v['brand_name'],
|
|
|
346
|
- 'alif' => $v['brand_alif'],
|
388
|
+ 'id' => $v['id'],
|
347
|
'href' => $url,
|
389
|
'href' => $url,
|
|
|
390
|
+ 'name' => $v['brand_name'],
|
|
|
391
|
+ 'key' => $v['brand_name'],
|
348
|
'active' => in_array($v['id'], $brandIds) ? true : false
|
392
|
'active' => in_array($v['id'], $brandIds) ? true : false
|
349
|
);
|
393
|
);
|
|
|
394
|
+ if (is_numeric($v['brand_alif'])) {
|
|
|
395
|
+ $this_brand['index'] = '0-9';
|
|
|
396
|
+ }
|
|
|
397
|
+ else {
|
|
|
398
|
+ $this_brand['index'] = strtolower($v['brand_alif']);
|
|
|
399
|
+ }
|
350
|
//默认品牌
|
400
|
//默认品牌
|
351
|
if (count($result['default']) < 10) {
|
401
|
if (count($result['default']) < 10) {
|
352
|
$result['default'][] = $this_brand;
|
402
|
$result['default'][] = $this_brand;
|
|
@@ -367,9 +417,16 @@ class HelperSearch |
|
@@ -367,9 +417,16 @@ class HelperSearch |
367
|
'href' => self::buildUrl($params)
|
417
|
'href' => self::buildUrl($params)
|
368
|
);
|
418
|
);
|
369
|
}
|
419
|
}
|
370
|
- //品牌列表排序
|
|
|
371
|
ksort($brandList);
|
420
|
ksort($brandList);
|
|
|
421
|
+ //品牌列表排序, 添加品牌索引
|
|
|
422
|
+ $index_key = array();
|
372
|
foreach ($brandList as $key => $val) {
|
423
|
foreach ($brandList as $key => $val) {
|
|
|
424
|
+ if ($key && !in_array($key, $index_key)) {
|
|
|
425
|
+ $index['index'] = strtolower(($key));
|
|
|
426
|
+ $index['name'] = $key;
|
|
|
427
|
+ $result['brandIndex'][] = $index;
|
|
|
428
|
+ $index_key[] = $index;
|
|
|
429
|
+ }
|
373
|
if (is_array($val)) {
|
430
|
if (is_array($val)) {
|
374
|
foreach ($val as $v) {
|
431
|
foreach ($val as $v) {
|
375
|
$result['brandsShow'][] = $v;
|
432
|
$result['brandsShow'][] = $v;
|
|
@@ -378,6 +435,10 @@ class HelperSearch |
|
@@ -378,6 +435,10 @@ class HelperSearch |
378
|
}
|
435
|
}
|
379
|
unset($brandList);
|
436
|
unset($brandList);
|
380
|
}
|
437
|
}
|
|
|
438
|
+ //搜索页已选中,返回空
|
|
|
439
|
+ if (self::checkSearch('brand')) {
|
|
|
440
|
+ return array();
|
|
|
441
|
+ }
|
381
|
return $result;
|
442
|
return $result;
|
382
|
}
|
443
|
}
|
383
|
/**
|
444
|
/**
|
|
@@ -402,6 +463,7 @@ class HelperSearch |
|
@@ -402,6 +463,7 @@ class HelperSearch |
402
|
'href' => self::buildUrl($params)
|
463
|
'href' => self::buildUrl($params)
|
403
|
);
|
464
|
);
|
404
|
}
|
465
|
}
|
|
|
466
|
+
|
405
|
$result[] = array(
|
467
|
$result[] = array(
|
406
|
'name' => $v['size_name'],
|
468
|
'name' => $v['size_name'],
|
407
|
'href' => self::buildUrl(array_merge($params, array(
|
469
|
'href' => self::buildUrl(array_merge($params, array(
|
|
@@ -409,6 +471,9 @@ class HelperSearch |
|
@@ -409,6 +471,9 @@ class HelperSearch |
409
|
))) ,
|
471
|
))) ,
|
410
|
);
|
472
|
);
|
411
|
}
|
473
|
}
|
|
|
474
|
+ if (self::checkSearch('size')) {
|
|
|
475
|
+ return array();
|
|
|
476
|
+ }
|
412
|
}
|
477
|
}
|
413
|
return $result;
|
478
|
return $result;
|
414
|
}
|
479
|
}
|
|
@@ -443,6 +508,9 @@ class HelperSearch |
|
@@ -443,6 +508,9 @@ class HelperSearch |
443
|
))) ,
|
508
|
))) ,
|
444
|
);
|
509
|
);
|
445
|
}
|
510
|
}
|
|
|
511
|
+ if (self::checkSearch('color')) {
|
|
|
512
|
+ return array();
|
|
|
513
|
+ }
|
446
|
return $result;
|
514
|
return $result;
|
447
|
}
|
515
|
}
|
448
|
|
516
|
|
|
@@ -474,6 +542,9 @@ class HelperSearch |
|
@@ -474,6 +542,9 @@ class HelperSearch |
474
|
);
|
542
|
);
|
475
|
}
|
543
|
}
|
476
|
}
|
544
|
}
|
|
|
545
|
+ if (self::checkSearch('price')) {
|
|
|
546
|
+ return array();
|
|
|
547
|
+ }
|
477
|
//返回价格条件
|
548
|
//返回价格条件
|
478
|
foreach ($filter['price'] as $key => $val) {
|
549
|
foreach ($filter['price'] as $key => $val) {
|
479
|
$val = trim($val,'¥');
|
550
|
$val = trim($val,'¥');
|
|
@@ -556,6 +627,10 @@ class HelperSearch |
|
@@ -556,6 +627,10 @@ class HelperSearch |
556
|
'href' => $url,
|
627
|
'href' => $url,
|
557
|
);
|
628
|
);
|
558
|
}
|
629
|
}
|
|
|
630
|
+ //搜索页已选中,返回空
|
|
|
631
|
+ if (self::checkSearch('style')) {
|
|
|
632
|
+ return array();
|
|
|
633
|
+ }
|
559
|
$data[0] = array(
|
634
|
$data[0] = array(
|
560
|
'attr' => 'style',
|
635
|
'attr' => 'style',
|
561
|
'name' => '风格',
|
636
|
'name' => '风格',
|
|
@@ -942,7 +1017,13 @@ class HelperSearch |
|
@@ -942,7 +1017,13 @@ class HelperSearch |
942
|
}
|
1017
|
}
|
943
|
return $result;
|
1018
|
return $result;
|
944
|
}
|
1019
|
}
|
945
|
- //分页
|
1020
|
+
|
|
|
1021
|
+ /**
|
|
|
1022
|
+ * 分页
|
|
|
1023
|
+ * @param $total
|
|
|
1024
|
+ * @param $viewNum
|
|
|
1025
|
+ * @return mixed
|
|
|
1026
|
+ */
|
946
|
public static function pager($total,$viewNum){
|
1027
|
public static function pager($total,$viewNum){
|
947
|
$Paging = new Paging('Yoho');
|
1028
|
$Paging = new Paging('Yoho');
|
948
|
return $Paging->setTotal($total)->setSize($viewNum)->view(0);
|
1029
|
return $Paging->setTotal($total)->setSize($viewNum)->view(0);
|
|
@@ -968,4 +1049,67 @@ class HelperSearch |
|
@@ -968,4 +1049,67 @@ class HelperSearch |
968
|
return $result;
|
1049
|
return $result;
|
969
|
}
|
1050
|
}
|
970
|
}
|
1051
|
}
|
|
|
1052
|
+
|
|
|
1053
|
+ /**
|
|
|
1054
|
+ * 组织品牌店铺信息
|
|
|
1055
|
+ */
|
|
|
1056
|
+ public static function shop($shop)
|
|
|
1057
|
+ {
|
|
|
1058
|
+ $url = Helpers::url('','',$shop['brand_domain']);
|
|
|
1059
|
+ $shopEntry = array();
|
|
|
1060
|
+ $sort = array();
|
|
|
1061
|
+ foreach ($shop['sort'] as $msort) {
|
|
|
1062
|
+ if (!isset($msort['sub']) || empty($msort['sub'])) {
|
|
|
1063
|
+ continue;
|
|
|
1064
|
+ }
|
|
|
1065
|
+ foreach ($msort['sub'] as $mkey=>$misort) {
|
|
|
1066
|
+ if (count($sort) >= 10) {
|
|
|
1067
|
+ break 2;
|
|
|
1068
|
+ }
|
|
|
1069
|
+ $sortInfo['href'] = $url.'/?msort=' . $msort['sort_id'] . '&misort=' . $misort['sort_id'];
|
|
|
1070
|
+ $sortInfo['name'] = $misort['sort_name'];
|
|
|
1071
|
+ $sort[] = $sortInfo;
|
|
|
1072
|
+ }
|
|
|
1073
|
+
|
|
|
1074
|
+ }
|
|
|
1075
|
+ $shopEntry['home'] = $url;
|
|
|
1076
|
+ $shopEntry['logo'] = Images::getSourceUrl($shop['brand_ico'],'brandLogo');
|
|
|
1077
|
+ $shopEntry['shopName'] = $shop['brand_name'];
|
|
|
1078
|
+ $shopEntry['sort'] = $sort;
|
|
|
1079
|
+ return $shopEntry;
|
|
|
1080
|
+ }
|
|
|
1081
|
+
|
|
|
1082
|
+ public static function checkSearch($param)
|
|
|
1083
|
+ {
|
|
|
1084
|
+ if (isset(self::$params[$param]) && isset(self::$options['controller']) && self::$options['controller'] == 'Search') {
|
|
|
1085
|
+ return true;
|
|
|
1086
|
+ }
|
|
|
1087
|
+
|
|
|
1088
|
+ }
|
|
|
1089
|
+
|
|
|
1090
|
+ /**
|
|
|
1091
|
+ * 设置搜索页导航
|
|
|
1092
|
+ * @param $total
|
|
|
1093
|
+ */
|
|
|
1094
|
+ public static function setSearchNav($total)
|
|
|
1095
|
+ {
|
|
|
1096
|
+ self::$listnav[0] = array(
|
|
|
1097
|
+ 'href' => '/',
|
|
|
1098
|
+ 'name' => '首页'
|
|
|
1099
|
+ );
|
|
|
1100
|
+ $param = self::$params;
|
|
|
1101
|
+ $options = self::$options;
|
|
|
1102
|
+ if (isset($options['controller']) && $options['controller'] == 'Search' && isset($param['query'])) {
|
|
|
1103
|
+ self::$listnav[1] = array(
|
|
|
1104
|
+ 'href' => '',
|
|
|
1105
|
+ 'name' => "‘".$param['query']."’ 共".$total."个结果"
|
|
|
1106
|
+ );
|
|
|
1107
|
+ }else{
|
|
|
1108
|
+ self::$listnav[1] = array(
|
|
|
1109
|
+ 'href' => '',
|
|
|
1110
|
+ 'name' => '所有商品'
|
|
|
1111
|
+ );
|
|
|
1112
|
+ }
|
|
|
1113
|
+
|
|
|
1114
|
+ }
|
971
|
} |
1115
|
} |