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
*/
public static $params = array();
private static $from = '';
//当前页
public static $page = 1;
... ... @@ -28,6 +30,12 @@ class HelperSearch
public static $listnav = array();
private static function setFrom($from = '')
{
if ($from) {
self::$from = $from;
}
}
//设置导航
private static function setListNav($option = array())
{
... ... @@ -78,6 +86,7 @@ class HelperSearch
$result['filters']['brand'] = self::brand($filter, $options);
//价格
$result['filters']['price'] = self::price($filter);
$result['filters']['customPrice'] = self::customPrice($filter);
//颜色
$result['filters']['color'] = self::color($filter);
//尺寸
... ... @@ -153,7 +162,9 @@ class HelperSearch
'salePrice' => $val['sales_price'],
'marketPrice' => $val['market_price'],
'isFew' => $isFew,
'skn' => $val['product_skn']
'skn' => $val['product_skn'],
'showColBtn' => true,
'coled' => true
);
}
return $goods;
... ... @@ -453,6 +464,15 @@ class HelperSearch
'name' => $filter['price'][$priceId],
'href' => self::buildUrl($params)
);
}else{
$price = explode(',', $priceId);
if (count($price) == 2) {
self::$selected['price'] = array(
'name' => self::$params['price'] == '2000,99999' ? '¥2000以上' : '¥' . (int)$price[0] . '-' . (int)$price[1],
'href' => self::buildurl($params)
);
}
}
//返回价格条件
foreach ($filter['price'] as $key => $val) {
... ... @@ -468,6 +488,27 @@ class HelperSearch
}
/**
* 获取自定义价格要提交的地址
*/
public static function customPrice($filter) {
$params = self::$params;
$result = array(
'min' => '',
'max' => ''
);
$priceId = isset($params['price']) && !empty(self::$params['price']) ? self::$params['price'] : '';
if (isset($params['price']) && !isset($filter['price'][$priceId]) ) {
$price = explode(',', $params['price']);
unset($params['price']);
$result = array(
'min' => $price[0],
'max' => $price[1]
);
}
return $result;
}
/**
* 风格,可以多选
* @param array $filter
* @return array
... ...
{{> layout/header}}
<div class="product-search-page product-page yoho-page center-content">
{{# search}}
{{> layout/path-nav}}
{{> product/standard-content}}
{{> product/latest-walk}}
{{/ search}}
</div>
{{> layout/footer}}
\ No newline at end of file
... ...
... ... @@ -60,6 +60,42 @@ class SearchModel
}
/**
* 搜索页面获取搜索数据
* @param $condition
* @param $options
* @return array
*/
public static function searchData($condition, $options){
$data = self::getSearchData($condition, $options);
//过滤频道
if (isset($condition['gender'])) {
unset($data['list']['filters']['channel']);
}
//过滤品牌
if (isset($condition['brand'])) {
unset($data['list']['filters']['brand']);
}
//过滤价格
if (isset($condition['price'])) {
unset($data['list']['filters']['price']);
unset($data['list']['filters']['customPrice']);
}
//过滤颜色
if (isset($condition['color'])) {
unset($data['list']['filters']['color']);
}
//过滤风格
if (isset($condition['style'])) {
unset($data['list']['filters']['seniorChose']);
}
//过滤尺码
if (isset($condition['size'])) {
unset($data['list']['filters']['size']);
}
return $data;
}
/**
* 根据product_sn查询产品图片信息
* @param $product_sn
* @param $options
... ...
<?php
use Action\WebAction;
use Product\SearchModel;
class SearchController extends WebAction
{
public function indexAction()
{
/* 过滤请求参数 */
$condition = filter_input_array(INPUT_GET, array(
'query' => FILTER_SANITIZE_STRING,
'brand' => FILTER_VALIDATE_INT,
'sort' => FILTER_VALIDATE_INT,
'msort' => FILTER_VALIDATE_INT,
'misort' => FILTER_VALIDATE_INT,
'color' => FILTER_VALIDATE_INT,
'size' => FILTER_DEFAULT,
'style' => FILTER_DEFAULT,
'price' => FILTER_DEFAULT,
'gender' => FILTER_DEFAULT,
'p_d' => FILTER_DEFAULT,
'shelve_time' => FILTER_DEFAULT,
'isNew' => FILTER_DEFAULT,
'specialoffer' => FILTER_DEFAULT,
'limited' => FILTER_DEFAULT,
'order' => FILTER_DEFAULT,
'viewNum' => FILTER_VALIDATE_INT,
'rowNum' => FILTER_VALIDATE_INT,
'page' => FILTER_VALIDATE_INT), false);
//字符转码
foreach($condition as $key => $val){
$condition[$key] = rawurldecode($val);
}
//关键词
$condition['query'] = '鞋';
//性別(频道)
$gender_cookie = !isset($_COOKIE['_Gender']) ? '3' : ($_COOKIE['_Gender']=='2,3' ? 2 : 1);
$gender = $this->get('gender') ? ($this->get('gender') == '2,3' ? 2 : 1) : $gender_cookie ;
$condition['gender'] = $gender;
//每页显示商品数
if(!isset($condition['viewNum']) || empty($condition['viewNum'])){
$condition['viewNum'] =60;
}
$view_num_arr = array(60, 100, 200);
if (!in_array($condition['viewNum'], $view_num_arr)) {
$condition['viewNum'] = 60;
}
//每行显示的商品数量
if(!isset($condition['rowNum']) || empty($condition['rowNum'])){
$condition['rowNum'] =5;
}
if ($condition['rowNum'] == 6) {
$imgSize = array(195, 260);
$minImgSize = array(50, 67);
} else {
$condition['rowNum'] = 5;
$imgSize = array(235, 314);
$minImgSize = array(60, 80);
}
//自定义搜索价格
if (isset($condition['price']) || !empty($condition['price'])) {
$price = explode(',', $condition['price']);
if (!$price[0]) {
$price[0] = 0;
}
if ($price[1]) {
$price[1] = 99999;
}
$condition['price'] = implode(',', $price);
}
//返回搜索条件
$condition['needFilter'] = 1;
//过滤赠品
$condition['attribute_not'] = 2;
/*sale*/
//默认排序
if (!isset($condition['order']) || empty($condition['order'])) {
$condition['order'] = 's_n_desc';
}
if (!isset($condition['p_d']) || empty($condition['p_d'])) {
$condition['p_d'] = '0,0.9';
}
$options = array(
'imgSize' => $imgSize,
'minImgSize' => $minImgSize,
'rowNum' =>$condition['rowNum'],
'viewNum' =>$condition['viewNum'],
);
$params = $condition + $_GET;
$params = array_filter($params);
//每页记录数减1,下一页占位
$params['viewNum'] = $params['viewNum'] - 1;
$searchData = SearchModel::searchData($params,$options);
$cate = array('boys','girls','kids','lifestyle');
$this->setWebNavHeader($cate[$gender-1]);
$data = array(
'searchListPage' => true,
);
$data['search'] = $searchData['list'];
$this->_view->display('search', $data);
}
}
\ No newline at end of file
... ...