Authored by 周少峰

添加搜索页面

@@ -12,6 +12,8 @@ class HelperSearch @@ -12,6 +12,8 @@ class HelperSearch
12 */ 12 */
13 public static $params = array(); 13 public static $params = array();
14 14
  15 + private static $from = '';
  16 +
15 //当前页 17 //当前页
16 public static $page = 1; 18 public static $page = 1;
17 19
@@ -27,6 +29,12 @@ class HelperSearch @@ -27,6 +29,12 @@ class HelperSearch
27 public static $listnav = array(); 29 public static $listnav = array();
28 30
29 31
  32 + private static function setFrom($from = '')
  33 + {
  34 + if ($from) {
  35 + self::$from = $from;
  36 + }
  37 + }
30 //设置导航 38 //设置导航
31 private static function setListNav($option = array()) 39 private static function setListNav($option = array())
32 { 40 {
@@ -77,6 +85,7 @@ class HelperSearch @@ -77,6 +85,7 @@ class HelperSearch
77 $result['filters']['brand'] = self::brand($filter, $options); 85 $result['filters']['brand'] = self::brand($filter, $options);
78 //价格 86 //价格
79 $result['filters']['price'] = self::price($filter); 87 $result['filters']['price'] = self::price($filter);
  88 + $result['filter']['customPrice'] = self::customPrice($filter);
80 //颜色 89 //颜色
81 $result['filters']['color'] = self::color($filter); 90 $result['filters']['color'] = self::color($filter);
82 //尺寸 91 //尺寸
@@ -152,7 +161,9 @@ class HelperSearch @@ -152,7 +161,9 @@ class HelperSearch
152 'salePrice' => $val['sales_price'], 161 'salePrice' => $val['sales_price'],
153 'marketPrice' => $val['market_price'], 162 'marketPrice' => $val['market_price'],
154 'isFew' => $isFew, 163 'isFew' => $isFew,
155 - 'skn' => $val['product_skn'] 164 + 'skn' => $val['product_skn'],
  165 + 'showColBtn' => true,
  166 + 'coled' => true
156 ); 167 );
157 } 168 }
158 return $goods; 169 return $goods;
@@ -452,6 +463,14 @@ class HelperSearch @@ -452,6 +463,14 @@ class HelperSearch
452 'name' => $filter['price'][$priceId], 463 'name' => $filter['price'][$priceId],
453 'href' => self::buildUrl($params) 464 'href' => self::buildUrl($params)
454 ); 465 );
  466 + }else{
  467 + $price = explode(',', $priceId);
  468 + if (count($price) == 2) {
  469 + self::$selected['price'] = array(
  470 + 'name' => self::$params['price'] == '2000,99999' ? '¥2000以上' : '¥' . (int)$price[0] . '-' . (int)$price[1],
  471 + 'url' => self::buildurl($params)
  472 + );
  473 + }
455 } 474 }
456 //返回价格条件 475 //返回价格条件
457 foreach ($filter['price'] as $key => $val) { 476 foreach ($filter['price'] as $key => $val) {
@@ -467,6 +486,28 @@ class HelperSearch @@ -467,6 +486,28 @@ class HelperSearch
467 } 486 }
468 487
469 /** 488 /**
  489 + * 获取自定义价格要提交的地址
  490 + */
  491 + public static function customPrice($filter) {
  492 + $params = self::$params;
  493 + $result = array(
  494 + 'customMin' => '',
  495 + 'customMax' => ''
  496 + );
  497 + $priceId = isset($params['price']) && !empty(self::$params['price']) ? self::$params['price'] : '';
  498 + if (isset($params['price']) && !isset($filter['price'][$priceId]) ) {
  499 + $price = explode(',', $params['price']);
  500 + unset($params['price']);
  501 + $result = array(
  502 + 'customMin' => $price[0],
  503 + 'customMax' => $price[1]
  504 + );
  505 + }
  506 + print_r($result);
  507 + return $result;
  508 + }
  509 +
  510 + /**
470 * 风格,可以多选 511 * 风格,可以多选
471 * @param array $filter 512 * @param array $filter
472 * @return array 513 * @return array
  1 +{{> layout/header}}
  2 +<div class="product-search-page product-page yoho-page center-content">
  3 + {{# search}}
  4 + {{> layout/path-nav}}
  5 +
  6 + {{> product/standard-content}}
  7 +
  8 + {{> product/latest-walk}}
  9 + {{/ search}}
  10 +</div>
  11 +{{> layout/footer}}
  1 +<?php
  2 +use Action\WebAction;
  3 +use Product\SearchModel;
  4 +class SearchController extends WebAction
  5 +{
  6 + public function indexAction()
  7 + {
  8 + /* 过滤请求参数 */
  9 + $condition = filter_input_array(INPUT_GET, array(
  10 + 'query' => FILTER_SANITIZE_STRING,
  11 + 'brand' => FILTER_VALIDATE_INT,
  12 + 'sort' => FILTER_VALIDATE_INT,
  13 + 'msort' => FILTER_VALIDATE_INT,
  14 + 'misort' => FILTER_VALIDATE_INT,
  15 + 'color' => FILTER_VALIDATE_INT,
  16 + 'size' => FILTER_DEFAULT,
  17 + 'style' => FILTER_DEFAULT,
  18 + 'price' => FILTER_DEFAULT,
  19 + 'gender' => FILTER_DEFAULT,
  20 + 'p_d' => FILTER_DEFAULT,
  21 + 'shelve_time' => FILTER_DEFAULT,
  22 + 'isNew' => FILTER_DEFAULT,
  23 + 'specialoffer' => FILTER_DEFAULT,
  24 + 'limited' => FILTER_DEFAULT,
  25 + 'order' => FILTER_DEFAULT,
  26 + 'viewNum' => FILTER_VALIDATE_INT,
  27 + 'rowNum' => FILTER_VALIDATE_INT,
  28 + 'page' => FILTER_VALIDATE_INT), false);
  29 + //字符转码
  30 + foreach($condition as $key => $val){
  31 + $condition[$key] = rawurldecode($val);
  32 + }
  33 + //关键词
  34 + $condition['query'] = 'vans';
  35 + //性別(频道)
  36 + $gender_cookie = !isset($_COOKIE['_Gender']) ? '3' : ($_COOKIE['_Gender']=='2,3' ? 2 : 1);
  37 + $gender = $this->get('gender') ? ($this->get('gender') == '2,3' ? 2 : 1) : $gender_cookie ;
  38 + $condition['gender'] = $gender;
  39 + //每页显示商品数
  40 + if(!isset($condition['viewNum']) || empty($condition['viewNum'])){
  41 + $condition['viewNum'] =60;
  42 + }
  43 + $view_num_arr = array(60, 100, 200);
  44 + if (!in_array($condition['viewNum'], $view_num_arr)) {
  45 + $condition['viewNum'] = 60;
  46 + }
  47 + //每行显示的商品数量
  48 + if(!isset($condition['rowNum']) || empty($condition['rowNum'])){
  49 + $condition['rowNum'] =5;
  50 + }
  51 + if ($condition['rowNum'] == 6) {
  52 + $imgSize = array(195, 260);
  53 + $minImgSize = array(50, 67);
  54 + } else {
  55 + $condition['rowNum'] = 5;
  56 + $imgSize = array(235, 314);
  57 + $minImgSize = array(60, 80);
  58 + }
  59 + //返回搜索条件
  60 + $condition['needFilter'] = 1;
  61 + //过滤赠品
  62 + $condition['attribute_not'] = 2;
  63 + /*sale*/
  64 + //默认排序
  65 + if (!isset($condition['order']) || empty($condition['order'])) {
  66 + $condition['order'] = 's_n_desc';
  67 + }
  68 + if (!isset($condition['p_d']) || empty($condition['p_d'])) {
  69 + $condition['p_d'] = '0,0.9';
  70 + }
  71 + $options = array(
  72 + 'imgSize' => $imgSize,
  73 + 'minImgSize' => $minImgSize,
  74 + 'rowNum' =>$condition['rowNum'],
  75 + 'viewNum' =>$condition['viewNum'],
  76 + );
  77 + $params = $condition + $_GET;
  78 + $params = array_filter($params);
  79 + //每页记录数减1,下一页占位
  80 + $params['viewNum'] = $params['viewNum'] - 1;
  81 + $searchData = SearchModel::getSearchData($params,$options);
  82 + $cate = array('boys','girls','kids','lifestyle');
  83 + $this->setWebNavHeader($cate[$gender-1]);
  84 + $data = array(
  85 + 'searchListPage' => true,
  86 + );
  87 + $data['search'] = $searchData['list'];
  88 + $this->_view->display('search', $data);
  89 + }
  90 +}