Authored by yangyang

Merge branch 'feature/web-list' of http://git.dev.yoho.cn/web/yohobuy into feature/web-list

@@ -13,6 +13,8 @@ class HelperSearch @@ -13,6 +13,8 @@ class HelperSearch
13 */ 13 */
14 public static $params = array(); 14 public static $params = array();
15 15
  16 + private static $from = '';
  17 +
16 //当前页 18 //当前页
17 public static $page = 1; 19 public static $page = 1;
18 20
@@ -28,6 +30,12 @@ class HelperSearch @@ -28,6 +30,12 @@ class HelperSearch
28 public static $listnav = array(); 30 public static $listnav = array();
29 31
30 32
  33 + private static function setFrom($from = '')
  34 + {
  35 + if ($from) {
  36 + self::$from = $from;
  37 + }
  38 + }
31 //设置导航 39 //设置导航
32 private static function setListNav($option = array()) 40 private static function setListNav($option = array())
33 { 41 {
@@ -78,6 +86,7 @@ class HelperSearch @@ -78,6 +86,7 @@ class HelperSearch
78 $result['filters']['brand'] = self::brand($filter, $options); 86 $result['filters']['brand'] = self::brand($filter, $options);
79 //价格 87 //价格
80 $result['filters']['price'] = self::price($filter); 88 $result['filters']['price'] = self::price($filter);
  89 + $result['filters']['customPrice'] = self::customPrice($filter);
81 //颜色 90 //颜色
82 $result['filters']['color'] = self::color($filter); 91 $result['filters']['color'] = self::color($filter);
83 //尺寸 92 //尺寸
@@ -153,7 +162,9 @@ class HelperSearch @@ -153,7 +162,9 @@ class HelperSearch
153 'salePrice' => $val['sales_price'], 162 'salePrice' => $val['sales_price'],
154 'marketPrice' => $val['market_price'], 163 'marketPrice' => $val['market_price'],
155 'isFew' => $isFew, 164 'isFew' => $isFew,
156 - 'skn' => $val['product_skn'] 165 + 'skn' => $val['product_skn'],
  166 + 'showColBtn' => true,
  167 + 'coled' => true
157 ); 168 );
158 } 169 }
159 return $goods; 170 return $goods;
@@ -453,6 +464,15 @@ class HelperSearch @@ -453,6 +464,15 @@ class HelperSearch
453 'name' => $filter['price'][$priceId], 464 'name' => $filter['price'][$priceId],
454 'href' => self::buildUrl($params) 465 'href' => self::buildUrl($params)
455 ); 466 );
  467 + }else{
  468 + $price = explode(',', $priceId);
  469 + if (count($price) == 2) {
  470 +
  471 + self::$selected['price'] = array(
  472 + 'name' => self::$params['price'] == '2000,99999' ? '¥2000以上' : '¥' . (int)$price[0] . '-' . (int)$price[1],
  473 + 'href' => self::buildurl($params)
  474 + );
  475 + }
456 } 476 }
457 //返回价格条件 477 //返回价格条件
458 foreach ($filter['price'] as $key => $val) { 478 foreach ($filter['price'] as $key => $val) {
@@ -468,6 +488,27 @@ class HelperSearch @@ -468,6 +488,27 @@ class HelperSearch
468 } 488 }
469 489
470 /** 490 /**
  491 + * 获取自定义价格要提交的地址
  492 + */
  493 + public static function customPrice($filter) {
  494 + $params = self::$params;
  495 + $result = array(
  496 + 'min' => '',
  497 + 'max' => ''
  498 + );
  499 + $priceId = isset($params['price']) && !empty(self::$params['price']) ? self::$params['price'] : '';
  500 + if (isset($params['price']) && !isset($filter['price'][$priceId]) ) {
  501 + $price = explode(',', $params['price']);
  502 + unset($params['price']);
  503 + $result = array(
  504 + 'min' => $price[0],
  505 + 'max' => $price[1]
  506 + );
  507 + }
  508 + return $result;
  509 + }
  510 +
  511 + /**
471 * 风格,可以多选 512 * 风格,可以多选
472 * @param array $filter 513 * @param array $filter
473 * @return array 514 * @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}}
@@ -60,6 +60,42 @@ class SearchModel @@ -60,6 +60,42 @@ class SearchModel
60 } 60 }
61 61
62 /** 62 /**
  63 + * 搜索页面获取搜索数据
  64 + * @param $condition
  65 + * @param $options
  66 + * @return array
  67 + */
  68 + public static function searchData($condition, $options){
  69 + $data = self::getSearchData($condition, $options);
  70 + //过滤频道
  71 + if (isset($condition['gender'])) {
  72 + unset($data['list']['filters']['channel']);
  73 + }
  74 + //过滤品牌
  75 + if (isset($condition['brand'])) {
  76 + unset($data['list']['filters']['brand']);
  77 + }
  78 + //过滤价格
  79 + if (isset($condition['price'])) {
  80 + unset($data['list']['filters']['price']);
  81 + unset($data['list']['filters']['customPrice']);
  82 + }
  83 + //过滤颜色
  84 + if (isset($condition['color'])) {
  85 + unset($data['list']['filters']['color']);
  86 + }
  87 + //过滤风格
  88 + if (isset($condition['style'])) {
  89 + unset($data['list']['filters']['seniorChose']);
  90 + }
  91 + //过滤尺码
  92 + if (isset($condition['size'])) {
  93 + unset($data['list']['filters']['size']);
  94 + }
  95 + return $data;
  96 +
  97 + }
  98 + /**
63 * 根据product_sn查询产品图片信息 99 * 根据product_sn查询产品图片信息
64 * @param $product_sn 100 * @param $product_sn
65 * @param $options 101 * @param $options
  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'] = '鞋';
  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 + if (isset($condition['price']) || !empty($condition['price'])) {
  61 + $price = explode(',', $condition['price']);
  62 + if (!$price[0]) {
  63 + $price[0] = 0;
  64 + }
  65 + if ($price[1]) {
  66 + $price[1] = 99999;
  67 + }
  68 + $condition['price'] = implode(',', $price);
  69 + }
  70 +
  71 + //返回搜索条件
  72 + $condition['needFilter'] = 1;
  73 + //过滤赠品
  74 + $condition['attribute_not'] = 2;
  75 + /*sale*/
  76 + //默认排序
  77 + if (!isset($condition['order']) || empty($condition['order'])) {
  78 + $condition['order'] = 's_n_desc';
  79 + }
  80 + if (!isset($condition['p_d']) || empty($condition['p_d'])) {
  81 + $condition['p_d'] = '0,0.9';
  82 + }
  83 + $options = array(
  84 + 'imgSize' => $imgSize,
  85 + 'minImgSize' => $minImgSize,
  86 + 'rowNum' =>$condition['rowNum'],
  87 + 'viewNum' =>$condition['viewNum'],
  88 + );
  89 + $params = $condition + $_GET;
  90 + $params = array_filter($params);
  91 + //每页记录数减1,下一页占位
  92 + $params['viewNum'] = $params['viewNum'] - 1;
  93 + $searchData = SearchModel::searchData($params,$options);
  94 + $cate = array('boys','girls','kids','lifestyle');
  95 + $this->setWebNavHeader($cate[$gender-1]);
  96 + $data = array(
  97 + 'searchListPage' => true,
  98 + );
  99 + $data['search'] = $searchData['list'];
  100 + $this->_view->display('search', $data);
  101 + }
  102 +}