|
@@ -97,11 +97,8 @@ class HelperSearch |
|
@@ -97,11 +97,8 @@ class HelperSearch |
97
|
$result['opts']['pageCounts'] = self::viewNum();
|
97
|
$result['opts']['pageCounts'] = self::viewNum();
|
98
|
$result['opts']['curPage'] = self::$page;
|
98
|
$result['opts']['curPage'] = self::$page;
|
99
|
$result['opts']['pageCount'] = $data['data']['page_total'];
|
99
|
$result['opts']['pageCount'] = $data['data']['page_total'];
|
100
|
- $result['opts']['nextHref'] = self::next($data['data']['page_total'],$data['data']['filter']);
|
|
|
101
|
- $result['hasNextPage'] = array(
|
|
|
102
|
- 'href' => self::next($data['data']['page_total'],$data['data']['filter']),
|
|
|
103
|
- 'src' => 'http://img10.static.yhbimg.com/product/2014/01/15/11/01fa01614784f6239760f1b749663016f1.jpg?imageMogr2/thumbnail/235x314/extent/235x314/background/d2hpdGU=/position/center/quality/90'
|
|
|
104
|
- );
|
100
|
+ $result['opts']['nextHref'] = ($next = self::next($data['data']['page_total'],$data['data']['filter'])) ? $next['href'] : '';
|
|
|
101
|
+ $result['hasNextPage'] = self::next($data['data']['page_total']);
|
105
|
//分类
|
102
|
//分类
|
106
|
$result['leftContent'][]['allSort'] = isset($filter['group_sort']) ? self::groupSort($filter['group_sort'], $options) : array();
|
103
|
$result['leftContent'][]['allSort'] = isset($filter['group_sort']) ? self::groupSort($filter['group_sort'], $options) : array();
|
107
|
//一周新品上架
|
104
|
//一周新品上架
|
|
@@ -168,12 +165,6 @@ class HelperSearch |
|
@@ -168,12 +165,6 @@ class HelperSearch |
168
|
public static function standard($filter) {
|
165
|
public static function standard($filter) {
|
169
|
$params = self::$params;
|
166
|
$params = self::$params;
|
170
|
$result = array();
|
167
|
$result = array();
|
171
|
- if (empty(self::$params)) {
|
|
|
172
|
- return $result;
|
|
|
173
|
- }
|
|
|
174
|
- if (empty($filter) || !is_array($filter)) {
|
|
|
175
|
- return array();
|
|
|
176
|
- }
|
|
|
177
|
foreach ($filter as $key => $val) {
|
168
|
foreach ($filter as $key => $val) {
|
178
|
if (substr_compare($key, 'parameter', 0, 9) != 0) {
|
169
|
if (substr_compare($key, 'parameter', 0, 9) != 0) {
|
179
|
continue;
|
170
|
continue;
|
|
@@ -181,7 +172,6 @@ class HelperSearch |
|
@@ -181,7 +172,6 @@ class HelperSearch |
181
|
if (!isset($val['sub']) || empty($val['sub'])) {
|
172
|
if (!isset($val['sub']) || empty($val['sub'])) {
|
182
|
continue;
|
173
|
continue;
|
183
|
}
|
174
|
}
|
184
|
-
|
|
|
185
|
$sub = array();
|
175
|
$sub = array();
|
186
|
foreach ($val['sub'] as $pval) {
|
176
|
foreach ($val['sub'] as $pval) {
|
187
|
if (isset(self::$params['parameter_' . $val['standard_id']]) && self::$params['parameter_' . $val['standard_id']] == $pval['standard_id']) {
|
177
|
if (isset(self::$params['parameter_' . $val['standard_id']]) && self::$params['parameter_' . $val['standard_id']] == $pval['standard_id']) {
|
|
@@ -189,12 +179,12 @@ class HelperSearch |
|
@@ -189,12 +179,12 @@ class HelperSearch |
189
|
unset($tmpParams['parameter_' . $val['standard_id']]);
|
179
|
unset($tmpParams['parameter_' . $val['standard_id']]);
|
190
|
self::$selected['parameter_' . $val['standard_id']] = array(
|
180
|
self::$selected['parameter_' . $val['standard_id']] = array(
|
191
|
'name' => $pval['standard_name'],
|
181
|
'name' => $pval['standard_name'],
|
192
|
- 'href' => self::buildurl($tmpParams)
|
182
|
+ 'href' => self::buildUrl($tmpParams)
|
193
|
);
|
183
|
);
|
194
|
}
|
184
|
}
|
195
|
$sub[] = array(
|
185
|
$sub[] = array(
|
196
|
'name' => $pval['standard_name'],
|
186
|
'name' => $pval['standard_name'],
|
197
|
- 'href' => self::buildurl(array_merge($params, array(
|
187
|
+ 'href' => self::buildUrl(array_merge($params, array(
|
198
|
'parameter_' . $val['standard_id'] => $pval['standard_id']
|
188
|
'parameter_' . $val['standard_id'] => $pval['standard_id']
|
199
|
))) ,
|
189
|
))) ,
|
200
|
'selected' => isset(self::$params['parameter_' . $val['standard_id']]) && self::$params['parameter_' . $val['standard_id']] == $pval['standard_id'] ? true : false
|
190
|
'selected' => isset(self::$params['parameter_' . $val['standard_id']]) && self::$params['parameter_' . $val['standard_id']] == $pval['standard_id'] ? true : false
|
|
@@ -223,21 +213,20 @@ class HelperSearch |
|
@@ -223,21 +213,20 @@ class HelperSearch |
223
|
if (isset($params['gender'])) {
|
213
|
if (isset($params['gender'])) {
|
224
|
unset($params['gender']);
|
214
|
unset($params['gender']);
|
225
|
}
|
215
|
}
|
226
|
-
|
216
|
+ //设置选中
|
227
|
if ($gender == '1,3' || $gender == '2,3') {
|
217
|
if ($gender == '1,3' || $gender == '2,3') {
|
228
|
self::$selected['gender'] = array(
|
218
|
self::$selected['gender'] = array(
|
229
|
'name' => $gender == '1,3' ? 'BOYS' : 'GIRLS',
|
219
|
'name' => $gender == '1,3' ? 'BOYS' : 'GIRLS',
|
230
|
- 'href' => self::buildurl($params)
|
220
|
+ 'href' => self::buildUrl($params)
|
231
|
);
|
221
|
);
|
232
|
}
|
222
|
}
|
233
|
$result = array();
|
223
|
$result = array();
|
234
|
foreach ($filter['gender'] as $key => $val) {
|
224
|
foreach ($filter['gender'] as $key => $val) {
|
235
|
$result[] = array(
|
225
|
$result[] = array(
|
236
|
'name' => $val,
|
226
|
'name' => $val,
|
237
|
- 'href' => self::buildurl(array_merge($params, array(
|
227
|
+ 'href' => self::buildUrl(array_merge($params, array(
|
238
|
'gender' => $key
|
228
|
'gender' => $key
|
239
|
))) ,
|
229
|
))) ,
|
240
|
- 'selected' => $gender == $key ? true : false
|
|
|
241
|
);
|
230
|
);
|
242
|
}
|
231
|
}
|
243
|
return $result;
|
232
|
return $result;
|
|
@@ -249,105 +238,50 @@ class HelperSearch |
|
@@ -249,105 +238,50 @@ class HelperSearch |
249
|
* @param array $option
|
238
|
* @param array $option
|
250
|
* @return array
|
239
|
* @return array
|
251
|
*/
|
240
|
*/
|
252
|
- public static function groupSort($sort, $option = array()) {
|
241
|
+
|
|
|
242
|
+ public static function groupSort($sort, $option = array())
|
|
|
243
|
+ {
|
|
|
244
|
+ //设置导航
|
253
|
self::setListNav($option);
|
245
|
self::setListNav($option);
|
254
|
$params = self::$params;
|
246
|
$params = self::$params;
|
255
|
- $gender = isset($params['gender']) ? $params['gender'] : '';
|
|
|
256
|
-
|
|
|
257
|
- $query = array();
|
|
|
258
|
- if (isset($option['needKeyword']) && $option['needKeyword'] == 'Y') {
|
|
|
259
|
- if (isset($params['query']) && !empty($params['query'])) {
|
|
|
260
|
- $query['query'] = $params['query'];
|
|
|
261
|
- }
|
|
|
262
|
-
|
|
|
263
|
- if (isset($params['keyword']) && !empty($params['keyword'])) {
|
|
|
264
|
- $query['keyword'] = $params['keyword'];
|
|
|
265
|
- }
|
|
|
266
|
- }
|
|
|
267
|
-
|
|
|
268
|
- if (isset($params['gender']) && !empty($params['gender'])) {
|
|
|
269
|
- $query['gender'] = $params['gender'];
|
|
|
270
|
- }
|
|
|
271
|
- if (isset($option['needDay']) && !empty($option['needDay']) && isset($params['day']) && !empty($params['day'])) {
|
|
|
272
|
- $query['day'] = $params['day'];
|
|
|
273
|
- }
|
|
|
274
|
- if (isset($option['needPd']) && !empty($option['needPd']) && isset($params['p_d']) && !empty($params['p_d'])) {
|
|
|
275
|
- $query['p_d'] = $params['p_d'];
|
|
|
276
|
- }
|
|
|
277
|
- if (isset($option['specialsale_id']) && !empty($option['specialsale_id']) && isset($params['specialsale_id']) && !empty($params['specialsale_id'])) {
|
|
|
278
|
- $query['specialsale_id'] = $params['specialsale_id'];
|
|
|
279
|
- }
|
|
|
280
|
-
|
|
|
281
|
$result = array(
|
247
|
$result = array(
|
282
|
'all' => array(
|
248
|
'all' => array(
|
283
|
- 'sort_id' => 0,
|
|
|
284
|
'name' => '全部品类',
|
249
|
'name' => '全部品类',
|
285
|
- 'href' => self::buildurl($query) ,
|
|
|
286
|
-// 'num' => 0,
|
|
|
287
|
- 'active' => ''
|
250
|
+ 'href' => self::buildUrl() ,
|
|
|
251
|
+ 'active' => isset($params['msort']) ? false : true,
|
288
|
) ,
|
252
|
) ,
|
289
|
'list' => array()
|
253
|
'list' => array()
|
290
|
);
|
254
|
);
|
291
|
- foreach ($sort as $val) {
|
255
|
+ $sortList = array();
|
|
|
256
|
+ foreach ($sort as $key => $val) {
|
|
|
257
|
+ //若参数有分类,设置导航
|
292
|
if (isset($params['msort']) && $params['msort'] == $val['sort_id']) {
|
258
|
if (isset($params['msort']) && $params['msort'] == $val['sort_id']) {
|
293
|
- $nav_index = isset($option['brandName']) && $option['brandName'] ? 2 : 1;
|
|
|
294
|
- self::$listnav[$nav_index] = array(
|
|
|
295
|
- 'sort_id' => $val['sort_id'],
|
259
|
+ //是否有品牌
|
|
|
260
|
+ $navIndex = isset($option['brandName']) && $option['brandName'] ? 2 : 1;
|
|
|
261
|
+ self::$listnav[$navIndex] = array(
|
296
|
'name' => $val['sort_name'],
|
262
|
'name' => $val['sort_name'],
|
297
|
- 'href' => self::buildurl(array(
|
263
|
+ 'href' => self::buildUrl(array(
|
298
|
'msort' => $val['sort_id'],
|
264
|
'msort' => $val['sort_id'],
|
299
|
- 'gender' => $gender
|
|
|
300
|
))
|
265
|
))
|
301
|
);
|
266
|
);
|
302
|
}
|
267
|
}
|
303
|
- //$result['all']['num']+= $val['count'];
|
|
|
304
|
- $msort = array(
|
|
|
305
|
- 'sort_id' => $val['sort_id'],
|
|
|
306
|
- 'name' => $val['sort_name'],
|
|
|
307
|
-// 'num' => $val['count'],
|
|
|
308
|
- 'active' => isset($params['msort']) && $params['msort'] == $val['sort_id'] ? true : false,
|
|
|
309
|
- 'href' => self::buildurl(array_merge($query, array(
|
|
|
310
|
- 'msort' => $val['sort_id']
|
|
|
311
|
- ))) ,
|
|
|
312
|
- 'childList' => array()
|
268
|
+ unset($params['msort']);
|
|
|
269
|
+ unset($params['misort']);
|
|
|
270
|
+ $sortList[$key]['name'] = $val['sort_name'];
|
|
|
271
|
+ $sortList[$key]['active'] = isset(self::$params['msort']) && self::$params['msort'] == $val['sort_id'] ? true : false;
|
|
|
272
|
+ $sortList[$key]['childList'][] = array(
|
|
|
273
|
+ 'name' => '全部分类',
|
|
|
274
|
+ 'href' => self::buildUrl(array_merge($params, array('msort'=>$val['sort_id'])))
|
313
|
);
|
275
|
);
|
314
|
- $sub = array();
|
|
|
315
|
- if (!empty($val['sub'])) {
|
|
|
316
|
-
|
|
|
317
|
- $sub[] = array(
|
|
|
318
|
- 'sort_id' => $val['sort_id'],
|
|
|
319
|
- 'name' => '全部' . $val['sort_name'],
|
|
|
320
|
-// 'num' => $val['count'],
|
|
|
321
|
- 'childActive' => !isset($params['misort']) && isset($params['msort']) && $params['msort'] == $val['sort_id'] ? true : false,
|
|
|
322
|
- 'href' => self::buildurl(array_merge($query, array(
|
|
|
323
|
- 'msort' => $val['sort_id']
|
|
|
324
|
- ))) ,
|
|
|
325
|
- );
|
|
|
326
|
- foreach ($val['sub'] as $mval) {
|
|
|
327
|
- if (isset($params['misort']) && $params['misort'] == $mval['sort_id']) {
|
|
|
328
|
- $nav_index = isset($option['brandName']) && $option['brandName'] ? 3 : 2;
|
|
|
329
|
- self::$listnav[$nav_index] = array(
|
|
|
330
|
- 'sort_id' => $mval['sort_id'],
|
|
|
331
|
- 'name' => $mval['sort_name'],
|
|
|
332
|
- 'href' => ''
|
|
|
333
|
- );
|
|
|
334
|
- }
|
|
|
335
|
-
|
|
|
336
|
- $sub[] = array(
|
|
|
337
|
- 'sort_id' => $mval['sort_id'],
|
|
|
338
|
- 'name' => $mval['sort_name'],
|
|
|
339
|
-// 'num' => $mval['count'],
|
|
|
340
|
- 'childActive' => isset($params['misort']) && $params['misort'] == $mval['sort_id'] ? true : false,
|
|
|
341
|
- 'href' => self::buildurl(array_merge($query, array(
|
|
|
342
|
- 'msort' => $val['sort_id'],
|
|
|
343
|
- 'misort' => $mval['sort_id']
|
|
|
344
|
- ))) ,
|
|
|
345
|
- );
|
276
|
+ if (isset($val['sub']) && !empty($val['sub'])) {
|
|
|
277
|
+ foreach ($val['sub'] as $k => $v) {
|
|
|
278
|
+ $sortList[$key]['childList'][$k+1]['name'] = $v['sort_name'];
|
|
|
279
|
+ $sortList[$key]['childList'][$k+1]['href'] = self::buildUrl(array_merge($params, array('msort' => $val['sort_id'], 'misort' => $v['sort_id'])));
|
|
|
280
|
+ $sortList[$key]['childList'][$k+1]['childActive'] = isset(self::$params['misort']) && self::$params['misort'] == $v['sort_id'] ? true : false;
|
346
|
}
|
281
|
}
|
347
|
- $msort['childList'] = $sub;
|
|
|
348
|
}
|
282
|
}
|
349
|
- $result['list'][] = $msort;
|
|
|
350
|
}
|
283
|
}
|
|
|
284
|
+ $result['list'] = $sortList;
|
351
|
return $result;
|
285
|
return $result;
|
352
|
}
|
286
|
}
|
353
|
|
287
|
|
|
@@ -358,14 +292,10 @@ class HelperSearch |
|
@@ -358,14 +292,10 @@ class HelperSearch |
358
|
* @return array
|
292
|
* @return array
|
359
|
*/
|
293
|
*/
|
360
|
public static function brand($filter, $options = array()) {
|
294
|
public static function brand($filter, $options = array()) {
|
|
|
295
|
+ //品牌列表返回空
|
361
|
if (isset($options['brandName'])) {
|
296
|
if (isset($options['brandName'])) {
|
362
|
return array();
|
297
|
return array();
|
363
|
}
|
298
|
}
|
364
|
- $params = self::$params;
|
|
|
365
|
- $brand_ids = isset($params['brand']) && !empty($params['brand']) ? explode(',', $params['brand']) : array();
|
|
|
366
|
- if (isset($params['brand'])) {
|
|
|
367
|
- unset($params['brand']);
|
|
|
368
|
- }
|
|
|
369
|
$result = array(
|
299
|
$result = array(
|
370
|
'default' => array() ,
|
300
|
'default' => array() ,
|
371
|
'brandIndex' => array(
|
301
|
'brandIndex' => array(
|
|
@@ -374,58 +304,28 @@ class HelperSearch |
|
@@ -374,58 +304,28 @@ class HelperSearch |
374
|
'H~N',
|
304
|
'H~N',
|
375
|
'O~T',
|
305
|
'O~T',
|
376
|
'U~Z') ,
|
306
|
'U~Z') ,
|
377
|
- 'brandsShow' => array() ,
|
|
|
378
|
- 'list' => array(
|
|
|
379
|
- '0~9' => array() ,
|
|
|
380
|
- 'A~G' => array() ,
|
|
|
381
|
- 'H~N' => array() ,
|
|
|
382
|
- 'O~T' => array() ,
|
|
|
383
|
- 'U~Z' => array() ,
|
|
|
384
|
- )
|
307
|
+ 'brandsShow' => array()
|
385
|
);
|
308
|
);
|
386
|
- $brand_keys = array_reverse(array_keys($result['list']));
|
309
|
+ $params = self::$params;
|
|
|
310
|
+ //url中的品牌ids
|
|
|
311
|
+ $brandIds = isset($params['brand']) && !empty($params['brand']) ? explode(',', $params['brand']) : array();
|
387
|
if (isset($filter['brand']) && !empty($filter['brand'])) {
|
312
|
if (isset($filter['brand']) && !empty($filter['brand'])) {
|
388
|
- //有商品结果时
|
|
|
389
|
$brand = $filter['brand'];
|
313
|
$brand = $filter['brand'];
|
390
|
- foreach ($brand as $v) {
|
|
|
391
|
- if (!isset($v['brand_alif']) && isset($v['brand_name_en'])) {
|
|
|
392
|
- $v['brand_alif'] = substr($v['brand_name_en'], 0, 1);
|
|
|
393
|
- }
|
|
|
394
|
- else if (!isset($v['brand_alif'])) {
|
|
|
395
|
- $v['brand_alif'] = '';
|
|
|
396
|
- }
|
|
|
397
|
- if (!isset($v['brand_domain'])) {
|
|
|
398
|
- $v['brand_domain'] = '';
|
|
|
399
|
- }
|
|
|
400
|
- //选中的筛选条件
|
|
|
401
|
- if (in_array($v['id'], $brand_ids)) {
|
|
|
402
|
- $selected_brand = explode(',', self::$params['brand']);
|
|
|
403
|
- $selected_key = array_search($v['id'], $selected_brand);
|
|
|
404
|
- unset($selected_brand[$selected_key]);
|
|
|
405
|
- $selected_params = $params;
|
|
|
406
|
- $selected_params['brand'] = implode(',', $selected_brand);
|
|
|
407
|
- self::$selected['brand'][] = array(
|
|
|
408
|
- 'name' => $v['brand_name'],
|
|
|
409
|
- 'href' => self::buildurl($selected_params)
|
|
|
410
|
- );
|
|
|
411
|
- }
|
|
|
412
|
- $selected_brand = isset(self::$params['brand']) && !empty(self::$params['brand']) ? explode(',', self::$params['brand']) : array();
|
|
|
413
|
- if (empty($selected_brand)) {
|
|
|
414
|
- $url = self::buildurl(array_merge($params, array(
|
|
|
415
|
- 'brand' => $v['id']
|
|
|
416
|
- )));
|
|
|
417
|
- }
|
|
|
418
|
- else if (in_array($v['id'], $brand_ids)) {
|
|
|
419
|
- $tk = array_search($v['id'], $selected_brand);
|
|
|
420
|
- unset($selected_brand[$tk]);
|
|
|
421
|
- $url = self::buildurl(array_merge($params, array(
|
|
|
422
|
- 'brand' => implode(',', $selected_brand)
|
314
|
+ foreach ($brand as $key => $v) {
|
|
|
315
|
+ $selectBrandIds = $brandIds;
|
|
|
316
|
+ //品牌id在提交的参数中,构造url参数去除该品牌id
|
|
|
317
|
+ if (in_array($v['id'], $brandIds)) {
|
|
|
318
|
+ $filterKey = array_search($v['id'], $selectBrandIds);
|
|
|
319
|
+ unset($selectBrandIds[$filterKey]);
|
|
|
320
|
+ $url = self::buildUrl(array_merge($params, array(
|
|
|
321
|
+ 'brand' => implode(',', $selectBrandIds)
|
423
|
)));
|
322
|
)));
|
424
|
}
|
323
|
}
|
|
|
324
|
+ //该品牌url参数中添加该品牌的id
|
425
|
else {
|
325
|
else {
|
426
|
- $selected_brand[] = $v['id'];
|
|
|
427
|
- $url = self::buildurl(array_merge($params, array(
|
|
|
428
|
- 'brand' => implode(',', $selected_brand)
|
326
|
+ $selectBrandIds[] = $v['id'];
|
|
|
327
|
+ $url = self::buildUrl(array_merge($params, array(
|
|
|
328
|
+ 'brand' => implode(',', $selectBrandIds)
|
429
|
)));
|
329
|
)));
|
430
|
}
|
330
|
}
|
431
|
$this_brand = array(
|
331
|
$this_brand = array(
|
|
@@ -433,53 +333,41 @@ class HelperSearch |
|
@@ -433,53 +333,41 @@ class HelperSearch |
433
|
'name' => $v['brand_name'],
|
333
|
'name' => $v['brand_name'],
|
434
|
'alif' => $v['brand_alif'],
|
334
|
'alif' => $v['brand_alif'],
|
435
|
'href' => $url,
|
335
|
'href' => $url,
|
436
|
- 'active' => in_array($v['id'], $brand_ids) ? true : false
|
336
|
+ 'active' => in_array($v['id'], $brandIds) ? true : false
|
437
|
);
|
337
|
);
|
|
|
338
|
+ //默认品牌
|
438
|
if (count($result['default']) < 10) {
|
339
|
if (count($result['default']) < 10) {
|
439
|
$result['default'][] = $this_brand;
|
340
|
$result['default'][] = $this_brand;
|
440
|
}
|
341
|
}
|
441
|
- $result['brandsShow'][] = $this_brand;
|
|
|
442
|
- foreach ($brand_keys as $range) {
|
|
|
443
|
- if (ord($v['brand_alif']) >= ord($range)) {
|
|
|
444
|
- $_order_key = $v['brand_alif'] . $v['brand_name'];
|
|
|
445
|
- $result['list'][$range][$_order_key] = $this_brand;
|
|
|
446
|
- break;
|
|
|
447
|
- }
|
|
|
448
|
- }
|
342
|
+ //品牌列表
|
|
|
343
|
+ $brandList[$v['brand_alif']][] = $this_brand;
|
|
|
344
|
+ $brandAll[$v['id']] = $v['brand_name'];
|
449
|
}
|
345
|
}
|
450
|
- foreach ($result['list'] as $key => $value) {
|
|
|
451
|
- ksort($result['list'][$key]);
|
|
|
452
|
- $result['list'][$key] = array_values($result['list'][$key]);
|
|
|
453
|
- if (empty($value)) {
|
|
|
454
|
- unset($result['list'][$key]);
|
|
|
455
|
- }
|
346
|
+ //清空品牌参数
|
|
|
347
|
+ unset($params['brand']);
|
|
|
348
|
+ //设置已选中的品牌
|
|
|
349
|
+ foreach ($brandIds as $key => $val) {
|
|
|
350
|
+ $brandParam = $brandIds;
|
|
|
351
|
+ unset($brandParam[$key]);
|
|
|
352
|
+ $params['brand'] = implode(',', $brandParam);
|
|
|
353
|
+ self::$selected['brand'][] = array(
|
|
|
354
|
+ 'name' => $brandAll[$val],
|
|
|
355
|
+ 'href' => self::buildUrl($params)
|
|
|
356
|
+ );
|
456
|
}
|
357
|
}
|
457
|
- }
|
|
|
458
|
- else if (isset($filter['paramNames']) && isset($filter['paramNames']['brand'])) {
|
|
|
459
|
- //无商品结果时且选择了品牌
|
|
|
460
|
- $brand = $filter['paramNames']['brand'];
|
|
|
461
|
- foreach ($brand as $v) {
|
|
|
462
|
- //选中的筛选条件
|
|
|
463
|
- if (in_array($v['id'], $brand_ids)) {
|
|
|
464
|
- $selected_brand = explode(',', self::$params['brand']);
|
|
|
465
|
- $selected_key = array_search($v['id'], $selected_brand);
|
|
|
466
|
- unset($selected_brand[$selected_key]);
|
|
|
467
|
- $selected_params = $params;
|
|
|
468
|
- $selected_params['brand'] = implode(',', $selected_brand);
|
|
|
469
|
- self::$selected['brand'][] = array(
|
|
|
470
|
- 'name' => $v['name'],
|
|
|
471
|
- 'href' => self::buildurl($selected_params)
|
|
|
472
|
- );
|
358
|
+ //品牌列表排序
|
|
|
359
|
+ ksort($brandList);
|
|
|
360
|
+ foreach ($brandList as $key => $val) {
|
|
|
361
|
+ if (is_array($val)) {
|
|
|
362
|
+ foreach ($val as $v) {
|
|
|
363
|
+ $result['brandsShow'][] = $v;
|
|
|
364
|
+ }
|
473
|
}
|
365
|
}
|
474
|
}
|
366
|
}
|
475
|
- $result['list'] = array();
|
|
|
476
|
- }
|
|
|
477
|
- else {
|
|
|
478
|
- $result['list'] = array();
|
367
|
+ unset($brandList);
|
479
|
}
|
368
|
}
|
480
|
return $result;
|
369
|
return $result;
|
481
|
}
|
370
|
}
|
482
|
-
|
|
|
483
|
/**
|
371
|
/**
|
484
|
* 尺码的链接,不能多选
|
372
|
* 尺码的链接,不能多选
|
485
|
* @param array $filter
|
373
|
* @param array $filter
|
|
@@ -487,7 +375,7 @@ class HelperSearch |
|
@@ -487,7 +375,7 @@ class HelperSearch |
487
|
*/
|
375
|
*/
|
488
|
public static function size($filter) {
|
376
|
public static function size($filter) {
|
489
|
$params = self::$params;
|
377
|
$params = self::$params;
|
490
|
- $size_id = isset($params['size']) && !empty($params['size']) ? $params['size'] : '';
|
378
|
+ $sizeId = isset($params['size']) && !empty($params['size']) ? $params['size'] : '';
|
491
|
if (isset($params['size'])) {
|
379
|
if (isset($params['size'])) {
|
492
|
unset($params['size']);
|
380
|
unset($params['size']);
|
493
|
}
|
381
|
}
|
|
@@ -495,32 +383,21 @@ class HelperSearch |
|
@@ -495,32 +383,21 @@ class HelperSearch |
495
|
if (isset($filter['size']) && !empty($filter['size'])) {
|
383
|
if (isset($filter['size']) && !empty($filter['size'])) {
|
496
|
$size = $filter['size'];
|
384
|
$size = $filter['size'];
|
497
|
foreach ($size as $v) {
|
385
|
foreach ($size as $v) {
|
498
|
- if ($v['size_id'] == $size_id) {
|
386
|
+ //设置选中
|
|
|
387
|
+ if ($v['size_id'] == $sizeId) {
|
499
|
self::$selected['size'] = array(
|
388
|
self::$selected['size'] = array(
|
500
|
'name' => $v['size_name'],
|
389
|
'name' => $v['size_name'],
|
501
|
- 'href' => self::buildurl($params)
|
390
|
+ 'href' => self::buildUrl($params)
|
502
|
);
|
391
|
);
|
503
|
}
|
392
|
}
|
504
|
$result[] = array(
|
393
|
$result[] = array(
|
505
|
- 'size_id' => $v['size_id'],
|
|
|
506
|
'name' => $v['size_name'],
|
394
|
'name' => $v['size_name'],
|
507
|
- 'href' => self::buildurl(array_merge($params, array(
|
395
|
+ 'href' => self::buildUrl(array_merge($params, array(
|
508
|
'size' => $v['size_id']
|
396
|
'size' => $v['size_id']
|
509
|
))) ,
|
397
|
))) ,
|
510
|
- 'selected' => $size_id == $v['size_id'] ? true : false
|
|
|
511
|
- );
|
|
|
512
|
- }
|
|
|
513
|
- }
|
|
|
514
|
- else if (isset($filter['paramNames']) && isset($filter['paramNames']['size'])) {
|
|
|
515
|
- $size = $filter['paramNames']['size'];
|
|
|
516
|
- foreach ($size as $val) {
|
|
|
517
|
- self::$selected['size'] = array(
|
|
|
518
|
- 'name' => $val['name'],
|
|
|
519
|
- 'href' => self::buildurl($params)
|
|
|
520
|
);
|
398
|
);
|
521
|
}
|
399
|
}
|
522
|
}
|
400
|
}
|
523
|
-
|
|
|
524
|
return $result;
|
401
|
return $result;
|
525
|
}
|
402
|
}
|
526
|
|
403
|
|
|
@@ -531,51 +408,29 @@ class HelperSearch |
|
@@ -531,51 +408,29 @@ class HelperSearch |
531
|
*/
|
408
|
*/
|
532
|
public static function color($filter) {
|
409
|
public static function color($filter) {
|
533
|
$params = self::$params;
|
410
|
$params = self::$params;
|
534
|
- $color_id = isset($params['color']) && !empty(self::$params['color']) ? self::$params['color'] : '';
|
411
|
+ $colorId = isset($params['color']) && !empty(self::$params['color']) ? self::$params['color'] : '';
|
535
|
if (isset($params['color'])) {
|
412
|
if (isset($params['color'])) {
|
536
|
unset($params['color']);
|
413
|
unset($params['color']);
|
537
|
}
|
414
|
}
|
538
|
-
|
|
|
539
|
$result = array();
|
415
|
$result = array();
|
540
|
- if (isset($filter['color']) && !empty($filter['color'])) {
|
|
|
541
|
-
|
|
|
542
|
- //有商品结果时的颜色
|
|
|
543
|
- $color = $filter['color'];
|
|
|
544
|
- foreach ($color as $v) {
|
|
|
545
|
- if ($v['color_id'] == $color_id) {
|
|
|
546
|
- $background = empty($v['color_value']) ? '#' . $v['color_code'] : "url(" . $v['color_value'] . ")";
|
|
|
547
|
- self::$selected['color'] = array(
|
|
|
548
|
- 'color' => $background,
|
|
|
549
|
- 'href' => self::buildurl($params)
|
|
|
550
|
- );
|
|
|
551
|
- }
|
|
|
552
|
-
|
|
|
553
|
- $result[] = array(
|
|
|
554
|
- 'color_id' => $v['color_id'],
|
|
|
555
|
- 'name' => $v['color_name'],
|
|
|
556
|
- 'rgb' => empty($v['color_value']) ? '#' . $v['color_code'] : "url({$v['color_value']})",
|
|
|
557
|
- 'href' => self::buildurl(array_merge($params, array(
|
|
|
558
|
- 'color' => $v['color_id']
|
|
|
559
|
- ))) ,
|
|
|
560
|
- 'selected' => $color_id == $v['color_id'] ? true : false
|
416
|
+ $color = $filter['color'];
|
|
|
417
|
+ foreach ($color as $v) {
|
|
|
418
|
+ //设置已选中
|
|
|
419
|
+ if ($v['color_id'] == $colorId) {
|
|
|
420
|
+ $background = empty($v['color_value']) ? '#' . $v['color_code'] : "url(" . $v['color_value'] . ")";
|
|
|
421
|
+ self::$selected['color'] = array(
|
|
|
422
|
+ 'color' => $background,
|
|
|
423
|
+ 'href' => self::buildUrl($params)
|
561
|
);
|
424
|
);
|
562
|
}
|
425
|
}
|
|
|
426
|
+ $result[] = array(
|
|
|
427
|
+ 'name' => $v['color_name'],
|
|
|
428
|
+ 'rgb' => empty($v['color_value']) ? '#' . $v['color_code'] : "url({$v['color_value']})",
|
|
|
429
|
+ 'href' => self::buildUrl(array_merge($params, array(
|
|
|
430
|
+ 'color' => $v['color_id']
|
|
|
431
|
+ ))) ,
|
|
|
432
|
+ );
|
563
|
}
|
433
|
}
|
564
|
- else if (isset($filter['paramNames']) && isset($filter['paramNames']['color'])) {
|
|
|
565
|
-
|
|
|
566
|
- //无商品结果时的颜色
|
|
|
567
|
- $color = $filter['paramNames']['color'];
|
|
|
568
|
- foreach ($color as $v) {
|
|
|
569
|
- if ($v['id'] == $color_id) {
|
|
|
570
|
- $background = empty($v['value']) ? '#' . $v['code'] : "url(" . $v['value'] . ")";
|
|
|
571
|
- self::$selected['color'] = array(
|
|
|
572
|
- 'name' => '<em style="background:' . $background . ';"> </em>',
|
|
|
573
|
- 'href' => self::buildurl($params)
|
|
|
574
|
- );
|
|
|
575
|
- }
|
|
|
576
|
- }
|
|
|
577
|
- }
|
|
|
578
|
-
|
|
|
579
|
return $result;
|
434
|
return $result;
|
580
|
}
|
435
|
}
|
581
|
|
436
|
|
|
@@ -586,53 +441,27 @@ class HelperSearch |
|
@@ -586,53 +441,27 @@ class HelperSearch |
586
|
*/
|
441
|
*/
|
587
|
public static function price($filter) {
|
442
|
public static function price($filter) {
|
588
|
$params = self::$params;
|
443
|
$params = self::$params;
|
589
|
- $price_id = isset($params['price']) && !empty(self::$params['price']) ? self::$params['price'] : '';
|
444
|
+ $priceId = isset($params['price']) && !empty(self::$params['price']) ? self::$params['price'] : '';
|
590
|
if (isset($params['price'])) {
|
445
|
if (isset($params['price'])) {
|
591
|
unset($params['price']);
|
446
|
unset($params['price']);
|
592
|
}
|
447
|
}
|
593
|
-
|
|
|
594
|
$result = array();
|
448
|
$result = array();
|
595
|
-
|
|
|
596
|
- if (isset($filter['price']) && !empty($filter['price'])) {
|
|
|
597
|
-
|
|
|
598
|
- //有商品时
|
|
|
599
|
- if (!empty($price_id) && isset($filter['price'][$price_id])) {
|
|
|
600
|
- self::$selected['price'] = array(
|
|
|
601
|
- 'name' => $filter['price'][$price_id],
|
|
|
602
|
- 'href' => self::buildurl($params)
|
|
|
603
|
- );
|
|
|
604
|
- }
|
|
|
605
|
- else if (!empty($price_id)) {
|
|
|
606
|
- $_price = explode(',', $price_id);
|
|
|
607
|
- if (count($_price) == 2) {
|
|
|
608
|
- self::$selected['price'] = array(
|
|
|
609
|
- 'name' => self::$params['price'] == '2000,99999' ? '¥2000以上' : '¥' . (int)$_price[0] . '-' . (int)$_price[1],
|
|
|
610
|
- 'href' => self::buildurl($params)
|
|
|
611
|
- );
|
|
|
612
|
- }
|
|
|
613
|
- }
|
|
|
614
|
-
|
|
|
615
|
- foreach ($filter['price'] as $key => $val) {
|
|
|
616
|
- $val = trim($val,'¥');
|
|
|
617
|
- $result[] = array(
|
|
|
618
|
- 'name' => $val,
|
|
|
619
|
- 'href' => self::buildurl(array_merge($params, array(
|
|
|
620
|
- 'price' => $key
|
|
|
621
|
- ))) ,
|
|
|
622
|
- 'selected' => isset(self::$params['price']) && $key == self::$params['price'] ? true : false
|
|
|
623
|
- );
|
|
|
624
|
- }
|
449
|
+ //设置已选中价格
|
|
|
450
|
+ if (!empty($priceId) && isset($filter['price'][$priceId])) {
|
|
|
451
|
+ self::$selected['price'] = array(
|
|
|
452
|
+ 'name' => $filter['price'][$priceId],
|
|
|
453
|
+ 'href' => self::buildUrl($params)
|
|
|
454
|
+ );
|
625
|
}
|
455
|
}
|
626
|
- else if (!empty($price_id)) {
|
|
|
627
|
-
|
|
|
628
|
- //无商品结果时
|
|
|
629
|
- $_price = explode(',', $price_id);
|
|
|
630
|
- if (count($_price) == 2) {
|
|
|
631
|
- self::$selected['price'] = array(
|
|
|
632
|
- 'name' => self::$params['price'] == '2000,99999' ? '¥2000以上' : '¥' . (int)$_price[0] . '-' . (int)$_price[1],
|
|
|
633
|
- 'href' => self::buildurl($params)
|
|
|
634
|
- );
|
|
|
635
|
- }
|
456
|
+ //返回价格条件
|
|
|
457
|
+ foreach ($filter['price'] as $key => $val) {
|
|
|
458
|
+ $val = trim($val,'¥');
|
|
|
459
|
+ $result[] = array(
|
|
|
460
|
+ 'name' => $val,
|
|
|
461
|
+ 'href' => self::buildUrl(array_merge($params, array(
|
|
|
462
|
+ 'price' => $key
|
|
|
463
|
+ ))) ,
|
|
|
464
|
+ );
|
636
|
}
|
465
|
}
|
637
|
return $result;
|
466
|
return $result;
|
638
|
}
|
467
|
}
|
|
@@ -644,75 +473,46 @@ class HelperSearch |
|
@@ -644,75 +473,46 @@ class HelperSearch |
644
|
*/
|
473
|
*/
|
645
|
public static function style($filter) {
|
474
|
public static function style($filter) {
|
646
|
$params = self::$params;
|
475
|
$params = self::$params;
|
647
|
- $style_ids = isset($params['style']) && !empty($params['style']) ? explode(',', $params['style']) : array();
|
476
|
+ $styleIds = isset($params['style']) && !empty($params['style']) ? explode(',', $params['style']) : array();
|
648
|
if (isset($params['style'])) {
|
477
|
if (isset($params['style'])) {
|
649
|
unset($params['style']);
|
478
|
unset($params['style']);
|
650
|
}
|
479
|
}
|
651
|
$result = array();
|
480
|
$result = array();
|
652
|
- if (isset($filter['style']) && !empty($filter['style'])) {
|
|
|
653
|
- //有商品结果时
|
|
|
654
|
- $style = $filter['style'];
|
|
|
655
|
- foreach ($style as $v) {
|
|
|
656
|
- //选中的筛选条件
|
|
|
657
|
- if (in_array($v['style_id'], $style_ids)) {
|
|
|
658
|
- $selected_style = explode(',', self::$params['style']);
|
|
|
659
|
- $selected_key = array_search($v['style_id'], $selected_style);
|
|
|
660
|
- unset($selected_style[$selected_key]);
|
|
|
661
|
- $selected_params = $params;
|
|
|
662
|
- $selected_params['style'] = implode(',', $selected_style);
|
|
|
663
|
- self::$selected['style'][] = array(
|
|
|
664
|
- 'name' => $v['style_name'],
|
|
|
665
|
- 'href' => self::buildurl($selected_params)
|
|
|
666
|
- );
|
|
|
667
|
- }
|
|
|
668
|
-
|
|
|
669
|
- $selected_style = isset(self::$params['style']) && !empty(self::$params['style']) ? explode(',', self::$params['style']) : array();
|
|
|
670
|
-
|
|
|
671
|
- if (empty($selected_style)) {
|
|
|
672
|
- $url = self::buildurl(array_merge($params, array(
|
|
|
673
|
- 'style' => $v['style_id']
|
|
|
674
|
- )));
|
|
|
675
|
- }
|
|
|
676
|
- else if (in_array($v['style_id'], $selected_style)) {
|
|
|
677
|
- $tk = array_search($v['style_id'], $selected_style);
|
|
|
678
|
- unset($selected_style[$tk]);
|
|
|
679
|
- $url = self::buildurl(array_merge($params, array(
|
|
|
680
|
- 'style' => implode(',', $selected_style)
|
|
|
681
|
- )));
|
|
|
682
|
- }
|
|
|
683
|
- else {
|
|
|
684
|
- $selected_style[] = $v['style_id'];
|
|
|
685
|
- $url = self::buildurl($params + array(
|
|
|
686
|
- 'style' => implode(',', $selected_style)
|
|
|
687
|
- ));
|
|
|
688
|
- }
|
|
|
689
|
- $result[] = array(
|
|
|
690
|
- 'style_id' => $v['style_id'],
|
481
|
+ $style = $filter['style'];
|
|
|
482
|
+ foreach ($style as $v) {
|
|
|
483
|
+ //选中的筛选条件
|
|
|
484
|
+ if (in_array($v['style_id'], $styleIds)) {
|
|
|
485
|
+ $selectedStyle = explode(',', self::$params['style']);
|
|
|
486
|
+ $selectedKey = array_search($v['style_id'], $selectedStyle);
|
|
|
487
|
+ unset($selectedStyle[$selectedKey]);
|
|
|
488
|
+ $selectedParams = $params;
|
|
|
489
|
+ $selectedParams['style'] = implode(',', $selectedStyle);
|
|
|
490
|
+ self::$selected['style'][] = array(
|
691
|
'name' => $v['style_name'],
|
491
|
'name' => $v['style_name'],
|
692
|
- 'href' => $url,
|
|
|
693
|
- 'selected' => in_array($v['style_id'], $style_ids) ? true : false
|
492
|
+ 'href' => self::buildUrl($selectedParams)
|
694
|
);
|
493
|
);
|
695
|
}
|
494
|
}
|
696
|
- }
|
|
|
697
|
- else if (isset($filter['paramNames']) && isset($filter['paramNames']['style'])) {
|
|
|
698
|
-
|
|
|
699
|
- //无商品结果时
|
|
|
700
|
- $style = $filter['paramNames']['style'];
|
|
|
701
|
- foreach ($style as $v) {
|
|
|
702
|
-
|
|
|
703
|
- //选中的筛选条件
|
|
|
704
|
- if (in_array($v['id'], $style_ids)) {
|
|
|
705
|
- $selected_style = explode(',', self::$params['style']);
|
|
|
706
|
- $selected_key = array_search($v['id'], $selected_style);
|
|
|
707
|
- unset($selected_style[$selected_key]);
|
|
|
708
|
- $selected_params = $params;
|
|
|
709
|
- $selected_params['style'] = implode(',', $selected_style);
|
|
|
710
|
- self::$selected['style'][] = array(
|
|
|
711
|
- 'name' => $v['name'],
|
|
|
712
|
- 'href' => self::buildurl($selected_params)
|
|
|
713
|
- );
|
|
|
714
|
- }
|
495
|
+ $selectedStyle = isset(self::$params['style']) && !empty(self::$params['style']) ? explode(',', self::$params['style']) : array();
|
|
|
496
|
+ //风格id在提交的参数中,构造url参数去除该风格id
|
|
|
497
|
+ if (in_array($v['style_id'], $selectedStyle)) {
|
|
|
498
|
+ $filterKey = array_search($v['style_id'], $selectedStyle);
|
|
|
499
|
+ unset($selectedStyle[$filterKey]);
|
|
|
500
|
+ $url = self::buildUrl(array_merge($params, array(
|
|
|
501
|
+ 'style' => implode(',', $selectedStyle)
|
|
|
502
|
+ )));
|
715
|
}
|
503
|
}
|
|
|
504
|
+ //该风格url参数中添加该风格的id
|
|
|
505
|
+ else {
|
|
|
506
|
+ $selectedStyle[] = $v['style_id'];
|
|
|
507
|
+ $url = self::buildUrl(array_merge($params, array(
|
|
|
508
|
+ 'style' => implode(',', $selectedStyle)
|
|
|
509
|
+ )));
|
|
|
510
|
+ }
|
|
|
511
|
+ $result[] = array(
|
|
|
512
|
+ 'id' => $v['style_id'],
|
|
|
513
|
+ 'name' => $v['style_name'],
|
|
|
514
|
+ 'href' => $url,
|
|
|
515
|
+ );
|
716
|
}
|
516
|
}
|
717
|
$data[0] = array(
|
517
|
$data[0] = array(
|
718
|
'attr' => 'style',
|
518
|
'attr' => 'style',
|
|
@@ -739,18 +539,14 @@ class HelperSearch |
|
@@ -739,18 +539,14 @@ class HelperSearch |
739
|
public static function viewNum()
|
539
|
public static function viewNum()
|
740
|
{
|
540
|
{
|
741
|
$params = self::$params;
|
541
|
$params = self::$params;
|
742
|
- $view_num = array(
|
|
|
743
|
- 60,
|
|
|
744
|
- 100,
|
|
|
745
|
- 200
|
|
|
746
|
- );
|
542
|
+ $viewNum = array(60, 100, 200);
|
747
|
$result = array();
|
543
|
$result = array();
|
748
|
- foreach ($view_num as $value) {
|
544
|
+ foreach ($viewNum as $value) {
|
749
|
$params['viewNum'] = $value;
|
545
|
$params['viewNum'] = $value;
|
750
|
$params['page'] = 1;
|
546
|
$params['page'] = 1;
|
751
|
$result[] = array(
|
547
|
$result[] = array(
|
752
|
'count' => $value,
|
548
|
'count' => $value,
|
753
|
- 'href' => self::buildurl($params)
|
549
|
+ 'href' => self::buildUrl($params)
|
754
|
);
|
550
|
);
|
755
|
}
|
551
|
}
|
756
|
return $result;
|
552
|
return $result;
|
|
@@ -762,10 +558,8 @@ class HelperSearch |
|
@@ -762,10 +558,8 @@ class HelperSearch |
762
|
public static function rowNum($num = 5)
|
558
|
public static function rowNum($num = 5)
|
763
|
{
|
559
|
{
|
764
|
$params = self::$params;
|
560
|
$params = self::$params;
|
765
|
-
|
|
|
766
|
$params['rowNum'] = $num;
|
561
|
$params['rowNum'] = $num;
|
767
|
-
|
|
|
768
|
- return self::buildurl($params);
|
562
|
+ return self::buildUrl($params);
|
769
|
}
|
563
|
}
|
770
|
|
564
|
|
771
|
/**
|
565
|
/**
|
|
@@ -773,6 +567,7 @@ class HelperSearch |
|
@@ -773,6 +567,7 @@ class HelperSearch |
773
|
*/
|
567
|
*/
|
774
|
public static function specialoffer()
|
568
|
public static function specialoffer()
|
775
|
{
|
569
|
{
|
|
|
570
|
+ $selected = '';
|
776
|
$params = self::$params;
|
571
|
$params = self::$params;
|
777
|
if (isset($params['specialoffer']) && !empty($params['specialoffer'])) {
|
572
|
if (isset($params['specialoffer']) && !empty($params['specialoffer'])) {
|
778
|
unset($params['specialoffer']);
|
573
|
unset($params['specialoffer']);
|
|
@@ -780,12 +575,10 @@ class HelperSearch |
|
@@ -780,12 +575,10 @@ class HelperSearch |
780
|
}
|
575
|
}
|
781
|
else {
|
576
|
else {
|
782
|
$params['specialoffer'] = 1;
|
577
|
$params['specialoffer'] = 1;
|
783
|
- $selected = '';
|
|
|
784
|
}
|
578
|
}
|
785
|
-
|
|
|
786
|
return array(
|
579
|
return array(
|
787
|
'name' => '打折',
|
580
|
'name' => '打折',
|
788
|
- 'href' => self::buildurl($params) ,
|
581
|
+ 'href' => self::buildUrl($params) ,
|
789
|
'checked' => $selected
|
582
|
'checked' => $selected
|
790
|
);
|
583
|
);
|
791
|
}
|
584
|
}
|
|
@@ -795,6 +588,7 @@ class HelperSearch |
|
@@ -795,6 +588,7 @@ class HelperSearch |
795
|
*/
|
588
|
*/
|
796
|
public static function limited()
|
589
|
public static function limited()
|
797
|
{
|
590
|
{
|
|
|
591
|
+ $selected = '';
|
798
|
$params = self::$params;
|
592
|
$params = self::$params;
|
799
|
if (isset($params['limited']) && !empty($params['limited'])) {
|
593
|
if (isset($params['limited']) && !empty($params['limited'])) {
|
800
|
unset($params['limited']);
|
594
|
unset($params['limited']);
|
|
@@ -802,11 +596,10 @@ class HelperSearch |
|
@@ -802,11 +596,10 @@ class HelperSearch |
802
|
}
|
596
|
}
|
803
|
else {
|
597
|
else {
|
804
|
$params['limited'] = 'Y';
|
598
|
$params['limited'] = 'Y';
|
805
|
- $selected = '';
|
|
|
806
|
}
|
599
|
}
|
807
|
return array(
|
600
|
return array(
|
808
|
'name' => '限量',
|
601
|
'name' => '限量',
|
809
|
- 'href' => self::buildurl($params) ,
|
602
|
+ 'href' => self::buildUrl($params) ,
|
810
|
'checked' => $selected
|
603
|
'checked' => $selected
|
811
|
);
|
604
|
);
|
812
|
}
|
605
|
}
|
|
@@ -817,18 +610,17 @@ class HelperSearch |
|
@@ -817,18 +610,17 @@ class HelperSearch |
817
|
public static function isnew()
|
610
|
public static function isnew()
|
818
|
{
|
611
|
{
|
819
|
$params = self::$params;
|
612
|
$params = self::$params;
|
820
|
-
|
613
|
+ $selected = '';
|
821
|
if (isset($params['isNew']) && !empty($params['isNew'])) {
|
614
|
if (isset($params['isNew']) && !empty($params['isNew'])) {
|
822
|
unset($params['isNew']);
|
615
|
unset($params['isNew']);
|
823
|
$selected = true;
|
616
|
$selected = true;
|
824
|
}
|
617
|
}
|
825
|
else {
|
618
|
else {
|
826
|
$params['isNew'] = 'Y';
|
619
|
$params['isNew'] = 'Y';
|
827
|
- $selected = false;
|
|
|
828
|
}
|
620
|
}
|
829
|
return array(
|
621
|
return array(
|
830
|
'name' => '新品',
|
622
|
'name' => '新品',
|
831
|
- 'href' => self::buildurl($params) ,
|
623
|
+ 'href' => self::buildUrl($params) ,
|
832
|
'checked' => $selected
|
624
|
'checked' => $selected
|
833
|
);
|
625
|
);
|
834
|
}
|
626
|
}
|
|
@@ -844,10 +636,10 @@ class HelperSearch |
|
@@ -844,10 +636,10 @@ class HelperSearch |
844
|
}
|
636
|
}
|
845
|
$result = array(
|
637
|
$result = array(
|
846
|
'name' => '最新',
|
638
|
'name' => '最新',
|
847
|
- 'href' => isset(self::$params['order']) && self::$params['order'] == 's_t_desc' ? self::buildurl($params) : self::buildurl(array_merge($params, array(
|
|
|
848
|
- 'order' => 's_t_desc'
|
639
|
+ 'href' => isset(self::$params['order']) && self::$params['order'] == 's_t_desc' ? self::buildUrl($params) : self::buildUrl(array_merge($params, array(
|
|
|
640
|
+ 'order' => 's_t_asc'
|
849
|
))) ,
|
641
|
))) ,
|
850
|
- 'selected' => isset(self::$params['order']) && self::$params['order'] == 's_t_desc' ? true : ''
|
642
|
+ 'active' => isset(self::$params['order']) && self::$params['order'] == 's_t_asc' ? true : ''
|
851
|
);
|
643
|
);
|
852
|
return $result;
|
644
|
return $result;
|
853
|
}
|
645
|
}
|
|
@@ -863,8 +655,8 @@ class HelperSearch |
|
@@ -863,8 +655,8 @@ class HelperSearch |
863
|
}
|
655
|
}
|
864
|
$result = array(
|
656
|
$result = array(
|
865
|
'name' => '默认',
|
657
|
'name' => '默认',
|
866
|
- 'href' => self::buildurl($params) ,
|
|
|
867
|
- 'selected' => !isset(self::$params['order']) || empty(self::$params['order']) ? true : ''
|
658
|
+ 'href' => self::buildUrl($params) ,
|
|
|
659
|
+ 'active' => !isset(self::$params['order']) || empty(self::$params['order']) ? true : ''
|
868
|
);
|
660
|
);
|
869
|
return $result;
|
661
|
return $result;
|
870
|
}
|
662
|
}
|
|
@@ -882,33 +674,34 @@ class HelperSearch |
|
@@ -882,33 +674,34 @@ class HelperSearch |
882
|
's_p_asc',
|
674
|
's_p_asc',
|
883
|
's_p_desc'
|
675
|
's_p_desc'
|
884
|
))) {
|
676
|
))) {
|
885
|
- $url = self::buildurl(array_merge($params, array(
|
677
|
+ $url = self::buildUrl(array_merge($params, array(
|
886
|
'order' => 's_p_asc'
|
678
|
'order' => 's_p_asc'
|
887
|
)));
|
679
|
)));
|
888
|
- $asc = '';
|
|
|
889
|
- $desc = '';
|
680
|
+ $active = '';
|
|
|
681
|
+ $desc = true;
|
890
|
}
|
682
|
}
|
891
|
else if (self::$params['order'] == 's_p_asc') {
|
683
|
else if (self::$params['order'] == 's_p_asc') {
|
892
|
- $url = self::buildurl(array_merge($params, array(
|
684
|
+ $url = self::buildUrl(array_merge($params, array(
|
893
|
'order' => 's_p_desc'
|
685
|
'order' => 's_p_desc'
|
894
|
)));
|
686
|
)));
|
895
|
- $asc = true;
|
|
|
896
|
- $desc = '';
|
687
|
+ $active = true;
|
|
|
688
|
+ $desc = true;
|
|
|
689
|
+
|
897
|
}
|
690
|
}
|
898
|
else {
|
691
|
else {
|
899
|
- $url = self::buildurl(array_merge($params, array(
|
692
|
+ $url = self::buildUrl(array_merge($params, array(
|
900
|
'order' => 's_p_asc'
|
693
|
'order' => 's_p_asc'
|
901
|
)));
|
694
|
)));
|
902
|
- $asc = '';
|
|
|
903
|
- $desc = true;
|
695
|
+ $desc = '';
|
|
|
696
|
+ $active = '';
|
904
|
}
|
697
|
}
|
905
|
$result = array(
|
698
|
$result = array(
|
906
|
'name' => '价格',
|
699
|
'name' => '价格',
|
907
|
'href' => $url,
|
700
|
'href' => $url,
|
908
|
- 'asc' => $asc,
|
701
|
+ 'hasSortOrient' => true,
|
|
|
702
|
+ 'active' => $active,
|
909
|
'desc' => $desc
|
703
|
'desc' => $desc
|
910
|
);
|
704
|
);
|
911
|
-
|
|
|
912
|
return $result;
|
705
|
return $result;
|
913
|
}
|
706
|
}
|
914
|
|
707
|
|
|
@@ -925,21 +718,21 @@ class HelperSearch |
|
@@ -925,21 +718,21 @@ class HelperSearch |
925
|
'p_d_asc',
|
718
|
'p_d_asc',
|
926
|
'p_d_desc'
|
719
|
'p_d_desc'
|
927
|
))) {
|
720
|
))) {
|
928
|
- $url = self::buildurl(array_merge($params, array(
|
721
|
+ $url = self::buildUrl(array_merge($params, array(
|
929
|
'order' => 'p_d_asc'
|
722
|
'order' => 'p_d_asc'
|
930
|
)));
|
723
|
)));
|
931
|
$asc = '';
|
724
|
$asc = '';
|
932
|
$desc = '';
|
725
|
$desc = '';
|
933
|
}
|
726
|
}
|
934
|
else if (self::$params['order'] == 'p_d_asc') {
|
727
|
else if (self::$params['order'] == 'p_d_asc') {
|
935
|
- $url = self::buildurl(array_merge($params, array(
|
728
|
+ $url = self::buildUrl(array_merge($params, array(
|
936
|
'order' => 'p_d_desc'
|
729
|
'order' => 'p_d_desc'
|
937
|
)));
|
730
|
)));
|
938
|
$asc = true;
|
731
|
$asc = true;
|
939
|
$desc = '';
|
732
|
$desc = '';
|
940
|
}
|
733
|
}
|
941
|
else {
|
734
|
else {
|
942
|
- $url = self::buildurl(array_merge($params, array(
|
735
|
+ $url = self::buildUrl(array_merge($params, array(
|
943
|
'order' => 'p_d_asc'
|
736
|
'order' => 'p_d_asc'
|
944
|
)));
|
737
|
)));
|
945
|
$asc = '';
|
738
|
$asc = '';
|
|
@@ -947,6 +740,7 @@ class HelperSearch |
|
@@ -947,6 +740,7 @@ class HelperSearch |
947
|
}
|
740
|
}
|
948
|
$result = array(
|
741
|
$result = array(
|
949
|
'name' => '折扣',
|
742
|
'name' => '折扣',
|
|
|
743
|
+ 'hasSortOrient' => true,
|
950
|
'href' => $url,
|
744
|
'href' => $url,
|
951
|
'asc' => $asc,
|
745
|
'asc' => $asc,
|
952
|
'desc' => $desc
|
746
|
'desc' => $desc
|
|
@@ -956,58 +750,16 @@ class HelperSearch |
|
@@ -956,58 +750,16 @@ class HelperSearch |
956
|
}
|
750
|
}
|
957
|
|
751
|
|
958
|
/**
|
752
|
/**
|
959
|
- * 获取自定义价格要提交的地址
|
|
|
960
|
- */
|
|
|
961
|
- public static function priceSubmit()
|
|
|
962
|
- {
|
|
|
963
|
- $params = self::$params;
|
|
|
964
|
- $price = array();
|
|
|
965
|
- if (isset($params['price'])) {
|
|
|
966
|
- $price = explode(',', $params['price']);
|
|
|
967
|
- unset($params['price']);
|
|
|
968
|
- }
|
|
|
969
|
-
|
|
|
970
|
- $result = array();
|
|
|
971
|
- foreach ($params as $key => $value) {
|
|
|
972
|
- $result[] = '<input type="hidden" name="' . $key . '" value="' . $value . '">';
|
|
|
973
|
- }
|
|
|
974
|
-
|
|
|
975
|
- if (count($price) == 2 && !in_array(self::$params['price'], array(
|
|
|
976
|
- '0,300',
|
|
|
977
|
- '300,600',
|
|
|
978
|
- '600,1000',
|
|
|
979
|
- '1000,2000',
|
|
|
980
|
- '2000,99999'
|
|
|
981
|
- ))) {
|
|
|
982
|
- return array(
|
|
|
983
|
- 'start' => $price[0],
|
|
|
984
|
- 'end' => $price[1],
|
|
|
985
|
- 'selected' => true,
|
|
|
986
|
- 'form' => implode('', $result)
|
|
|
987
|
- );
|
|
|
988
|
- }
|
|
|
989
|
- else {
|
|
|
990
|
- return array(
|
|
|
991
|
- 'start' => '',
|
|
|
992
|
- 'end' => '',
|
|
|
993
|
- 'selected' => false,
|
|
|
994
|
- 'form' => implode('', $result)
|
|
|
995
|
- );
|
|
|
996
|
- }
|
|
|
997
|
- }
|
|
|
998
|
-
|
|
|
999
|
- /**
|
|
|
1000
|
* 组织参数
|
753
|
* 组织参数
|
1001
|
* @param array $params
|
754
|
* @param array $params
|
1002
|
* @return string
|
755
|
* @return string
|
1003
|
*/
|
756
|
*/
|
1004
|
- private static function buildurl($params)
|
757
|
+ private static function buildUrl($params = array())
|
1005
|
{
|
758
|
{
|
1006
|
if (empty($params)) {
|
759
|
if (empty($params)) {
|
1007
|
return self::current();
|
760
|
return self::current();
|
1008
|
}
|
761
|
}
|
1009
|
$queryPath = explode('?', $_SERVER['REQUEST_URI']);
|
762
|
$queryPath = explode('?', $_SERVER['REQUEST_URI']);
|
1010
|
-
|
|
|
1011
|
$params_arr = array();
|
763
|
$params_arr = array();
|
1012
|
foreach ($params as $key => $val) {
|
764
|
foreach ($params as $key => $val) {
|
1013
|
if (is_array($val) || $val === '') {
|
765
|
if (is_array($val) || $val === '') {
|
|
@@ -1054,31 +806,18 @@ class HelperSearch |
|
@@ -1054,31 +806,18 @@ class HelperSearch |
1054
|
public static function getDiscount(array $list = array())
|
806
|
public static function getDiscount(array $list = array())
|
1055
|
{
|
807
|
{
|
1056
|
$params = self::$params;
|
808
|
$params = self::$params;
|
1057
|
-
|
|
|
1058
|
if (empty($list)) {
|
809
|
if (empty($list)) {
|
1059
|
return array();
|
810
|
return array();
|
1060
|
}
|
811
|
}
|
1061
|
- $params = $_GET;
|
|
|
1062
|
$query = array();
|
812
|
$query = array();
|
1063
|
- if (isset($params['gender'])) {
|
|
|
1064
|
- $query['gender'] = $params['gender'];
|
|
|
1065
|
- }
|
|
|
1066
|
- if (isset($params['msort'])) {
|
|
|
1067
|
- $query['msort'] = $params['msort'];
|
|
|
1068
|
- }
|
|
|
1069
|
- if (isset($params['misort'])) {
|
|
|
1070
|
- $query['misort'] = $params['misort'];
|
|
|
1071
|
- }
|
|
|
1072
|
$total = 0;
|
813
|
$total = 0;
|
1073
|
foreach ($list as $k => $v) {
|
814
|
foreach ($list as $k => $v) {
|
1074
|
- $total+= $v['count'];
|
815
|
+ $total += $v['count'];
|
1075
|
$query['p_d'] = $k;
|
816
|
$query['p_d'] = $k;
|
1076
|
- $list[$k]['href'] = self::buildurl($query);
|
|
|
1077
|
- //$list[$k]['num'] = $total;
|
817
|
+ $list[$k]['href'] = self::buildUrl($query);
|
1078
|
$list[$k]['active'] = isset($params['p_d']) && $params['p_d'] == $k ? true : false;
|
818
|
$list[$k]['active'] = isset($params['p_d']) && $params['p_d'] == $k ? true : false;
|
1079
|
}
|
819
|
}
|
1080
|
$result = array(
|
820
|
$result = array(
|
1081
|
- //'updateNum' => $total,
|
|
|
1082
|
'list' => array_values($list)
|
821
|
'list' => array_values($list)
|
1083
|
);
|
822
|
);
|
1084
|
return $result;
|
823
|
return $result;
|
|
@@ -1094,15 +833,6 @@ class HelperSearch |
|
@@ -1094,15 +833,6 @@ class HelperSearch |
1094
|
}
|
833
|
}
|
1095
|
$params = self::$params;
|
834
|
$params = self::$params;
|
1096
|
$query = array();
|
835
|
$query = array();
|
1097
|
- if (isset($params['gender'])) {
|
|
|
1098
|
- $query['gender'] = $params['gender'];
|
|
|
1099
|
- }
|
|
|
1100
|
- if (isset($params['msort'])) {
|
|
|
1101
|
- $query['msort'] = $params['msort'];
|
|
|
1102
|
- }
|
|
|
1103
|
- if (isset($params['misort'])) {
|
|
|
1104
|
- $query['misort'] = $params['misort'];
|
|
|
1105
|
- }
|
|
|
1106
|
$data = array();
|
836
|
$data = array();
|
1107
|
$i = 0;
|
837
|
$i = 0;
|
1108
|
foreach ($list as $k => $v) {
|
838
|
foreach ($list as $k => $v) {
|
|
@@ -1113,7 +843,7 @@ class HelperSearch |
|
@@ -1113,7 +843,7 @@ class HelperSearch |
1113
|
if (isset($params['shelve_time']) && $query['shelve_time'] == $params['shelve_time']) {
|
843
|
if (isset($params['shelve_time']) && $query['shelve_time'] == $params['shelve_time']) {
|
1114
|
$data[$i]['active'] = true;
|
844
|
$data[$i]['active'] = true;
|
1115
|
}
|
845
|
}
|
1116
|
- @$data[$i]['href'] = self::buildurl($query);
|
846
|
+ $data[$i]['href'] = self::buildUrl($query);
|
1117
|
$data[$i]['name'] = $k;
|
847
|
$data[$i]['name'] = $k;
|
1118
|
$i++;
|
848
|
$i++;
|
1119
|
}
|
849
|
}
|
|
@@ -1121,6 +851,8 @@ class HelperSearch |
|
@@ -1121,6 +851,8 @@ class HelperSearch |
1121
|
//'updateNum' => $total,
|
851
|
//'updateNum' => $total,
|
1122
|
'list' => $data
|
852
|
'list' => $data
|
1123
|
);
|
853
|
);
|
|
|
854
|
+ unset($data);
|
|
|
855
|
+ unset($query);
|
1124
|
return $result;
|
856
|
return $result;
|
1125
|
}
|
857
|
}
|
1126
|
/**
|
858
|
/**
|
|
@@ -1132,17 +864,22 @@ class HelperSearch |
|
@@ -1132,17 +864,22 @@ class HelperSearch |
1132
|
return $url[0];
|
864
|
return $url[0];
|
1133
|
}
|
865
|
}
|
1134
|
/**
|
866
|
/**
|
1135
|
- * 下一页地址
|
867
|
+ * 下一页
|
1136
|
*/
|
868
|
*/
|
1137
|
- public static function next($total,$filter){
|
|
|
1138
|
- $page = 1;
|
869
|
+ public static function next($total){
|
1139
|
$param = self::$params;
|
870
|
$param = self::$params;
|
1140
|
$page = self::$page;
|
871
|
$page = self::$page;
|
1141
|
- if($page < $total){
|
872
|
+ $next = array();
|
|
|
873
|
+ if ($page < $total) {
|
1142
|
$page ++;
|
874
|
$page ++;
|
1143
|
$param['page'] = $page;
|
875
|
$param['page'] = $page;
|
|
|
876
|
+ $nextUrl = self::buildUrl($param);
|
|
|
877
|
+ $next = array(
|
|
|
878
|
+ 'href' => $nextUrl,
|
|
|
879
|
+ 'src' => 'http://img10.static.yhbimg.com/product/2014/01/15/11/01fa01614784f6239760f1b749663016f1.jpg?imageMogr2/thumbnail/235x314/extent/235x314/background/d2hpdGU=/position/center/quality/90'
|
|
|
880
|
+ );
|
1144
|
}
|
881
|
}
|
1145
|
- return self::buildurl($param);
|
882
|
+ return $next;
|
1146
|
}
|
883
|
}
|
1147
|
|
884
|
|
1148
|
/**
|
885
|
/**
|
|
@@ -1164,8 +901,8 @@ class HelperSearch |
|
@@ -1164,8 +901,8 @@ class HelperSearch |
1164
|
return $result;
|
901
|
return $result;
|
1165
|
}
|
902
|
}
|
1166
|
//分页
|
903
|
//分页
|
1167
|
- public static function pager($total,$view_num){
|
904
|
+ public static function pager($total,$viewNum){
|
1168
|
$Paging = new Paging('Yoho');
|
905
|
$Paging = new Paging('Yoho');
|
1169
|
- return $Paging->setTotal($total)->setSize($view_num)->view(0);
|
906
|
+ return $Paging->setTotal($total)->setSize($viewNum)->view(0);
|
1170
|
}
|
907
|
}
|
1171
|
} |
908
|
} |