Authored by whb

Merge branch 'feature/web-list' into develop

@@ -34,7 +34,7 @@ class BrandData @@ -34,7 +34,7 @@ class BrandData
34 // 构建必传参数 34 // 构建必传参数
35 $param = Yohobuy::param(); 35 $param = Yohobuy::param();
36 $param['brand_id'] = $brandId; 36 $param['brand_id'] = $brandId;
37 - $param['uid'] = '10267443'; 37 + $param['uid'] = $uid;
38 $param['method'] = 'app.brand.getBrandIntro'; 38 $param['method'] = 'app.brand.getBrandIntro';
39 $param['client_secret'] = Sign::getSign($param); 39 $param['client_secret'] = Sign::getSign($param);
40 40
  1 +<?php
  2 +namespace LibModels\Web\Product;
  3 +
  4 +use Api\Yohobuy;
  5 +
  6 +/**
  7 + * sale操作类
  8 + * @name SaleData
  9 + * @package
  10 + * @copyright yoho.inc
  11 + * @version 1.0 (2016-01-07)
  12 + * @author
  13 + */
  14 +class SaleData
  15 +{
  16 + const URL_SALE_SPECIAL = '/operating/service/v1/special';
  17 +
  18 + /**
  19 + * 获取专区信息
  20 + * @param $specialId 专区ID
  21 + */
  22 + public static function getSpecial($specialsaleId) {
  23 +
  24 + return Yohobuy::yarClient(Yohobuy::SERVICE_URL . self::URL_SALE_SPECIAL, 'getOneSpecial', array($specialsaleId));
  25 + }
  26 +
  27 +}
@@ -2,6 +2,7 @@ @@ -2,6 +2,7 @@
2 2
3 namespace Plugin; 3 namespace Plugin;
4 use Plugin\Paging; 4 use Plugin\Paging;
  5 +use LibModels\Web\Product\BrandData;
5 /** 6 /**
6 * 搜索辅助类 7 * 搜索辅助类
7 */ 8 */
@@ -12,6 +13,8 @@ class HelperSearch @@ -12,6 +13,8 @@ class HelperSearch
12 */ 13 */
13 public static $params = array(); 14 public static $params = array();
14 15
  16 + private static $from = '';
  17 +
15 //当前页 18 //当前页
16 public static $page = 1; 19 public static $page = 1;
17 20
@@ -27,6 +30,12 @@ class HelperSearch @@ -27,6 +30,12 @@ class HelperSearch
27 public static $listnav = array(); 30 public static $listnav = array();
28 31
29 32
  33 + private static function setFrom($from = '')
  34 + {
  35 + if ($from) {
  36 + self::$from = $from;
  37 + }
  38 + }
30 //设置导航 39 //设置导航
31 private static function setListNav($option = array()) 40 private static function setListNav($option = array())
32 { 41 {
@@ -77,6 +86,7 @@ class HelperSearch @@ -77,6 +86,7 @@ class HelperSearch
77 $result['filters']['brand'] = self::brand($filter, $options); 86 $result['filters']['brand'] = self::brand($filter, $options);
78 //价格 87 //价格
79 $result['filters']['price'] = self::price($filter); 88 $result['filters']['price'] = self::price($filter);
  89 + $result['filters']['customPrice'] = self::customPrice($filter);
80 //颜色 90 //颜色
81 $result['filters']['color'] = self::color($filter); 91 $result['filters']['color'] = self::color($filter);
82 //尺寸 92 //尺寸
@@ -152,7 +162,9 @@ class HelperSearch @@ -152,7 +162,9 @@ class HelperSearch
152 'salePrice' => $val['sales_price'], 162 'salePrice' => $val['sales_price'],
153 'marketPrice' => $val['market_price'], 163 'marketPrice' => $val['market_price'],
154 'isFew' => $isFew, 164 'isFew' => $isFew,
155 - 'skn' => $val['product_skn'] 165 + 'skn' => $val['product_skn'],
  166 + 'showColBtn' => true,
  167 + 'coled' => true
156 ); 168 );
157 } 169 }
158 return $goods; 170 return $goods;
@@ -452,6 +464,15 @@ class HelperSearch @@ -452,6 +464,15 @@ class HelperSearch
452 'name' => $filter['price'][$priceId], 464 'name' => $filter['price'][$priceId],
453 'href' => self::buildUrl($params) 465 'href' => self::buildUrl($params)
454 ); 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 + }
455 } 476 }
456 //返回价格条件 477 //返回价格条件
457 foreach ($filter['price'] as $key => $val) { 478 foreach ($filter['price'] as $key => $val) {
@@ -467,6 +488,27 @@ class HelperSearch @@ -467,6 +488,27 @@ class HelperSearch
467 } 488 }
468 489
469 /** 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 + /**
470 * 风格,可以多选 512 * 风格,可以多选
471 * @param array $filter 513 * @param array $filter
472 * @return array 514 * @return array
@@ -905,4 +947,25 @@ class HelperSearch @@ -905,4 +947,25 @@ class HelperSearch
905 $Paging = new Paging('Yoho'); 947 $Paging = new Paging('Yoho');
906 return $Paging->setTotal($total)->setSize($viewNum)->view(0); 948 return $Paging->setTotal($total)->setSize($viewNum)->view(0);
907 } 949 }
  950 +
  951 + //组织静态资源数据格式
  952 + public static function formatNodeContent($code){
  953 + $nodeContent = BrandData::getByNodeContent($code);
  954 + if (isset($nodeContent['code']) && $nodeContent['code'] === 200) {
  955 + $result = array();
  956 +
  957 + $string = $nodeContent['data'];
  958 + $hrefPatten="/<a href=[\'\"]?([^\'\" ]+).*?>/";
  959 + preg_match_all($hrefPatten, $string, $href);
  960 +
  961 + $pattern = "/[img|IMG].*?src=['|\"](.*?(?:[.gif|.jpg]))['|\"].*?[\/]?>/";
  962 + preg_match_all($pattern,$string,$img);
  963 +
  964 + foreach($href[1] as $key=>$vo){
  965 + $result[$key]['href'] = $vo;
  966 + $result[$key]['src'] = $img[1][$key];
  967 + }
  968 + return $result;
  969 + }
  970 + }
908 } 971 }
  1 +{{> layout/header}}
  2 +<div class="new-sale-page product-page yoho-page">
  3 + {{# newSale}}
  4 + {{# saleBanner}}
  5 + <div class="banner-img" style="height: {{bannerHeight}}px;background:url({{img}}) no-repeat top center;"></div>
  6 + {{/ saleBanner}}
  7 +
  8 + <div class="center-content clearfix">
  9 + {{> layout/path-nav}}
  10 +
  11 + {{# saleTitle}}
  12 + <div class="header-title">
  13 + {{name}}
  14 + <p class="line-through"></p>
  15 + <p class="count-wrap">
  16 + <span class="count">共{{count}}个结果</span>
  17 + </p>
  18 + </div>
  19 + {{/ saleTitle}}
  20 +
  21 + <div class="list-left pull-left">
  22 + {{> product/left-content}}
  23 + </div>
  24 +
  25 + <div class="list-right pull-right">
  26 + {{# newMain}}
  27 + <div class="new-banner">
  28 + <a href="{{bannerHref}}">
  29 + <img src="{{banner}}">
  30 + </a>
  31 + </div>
  32 + <div class="new-brands clearfix">
  33 + <span class="iconfont pre">&#xe607;</span>
  34 + <div class="brands-wrap">
  35 + <ul class="brands">
  36 + {{# brands}}
  37 + <li>
  38 + <a href="{{href}}">
  39 + <img src="{{logo}}">
  40 + </a>
  41 + </li>
  42 + {{/ brands}}
  43 + </ul>
  44 + </div>
  45 + <span class="iconfont next">&#xe608;</span>
  46 + </div>
  47 + <div class="new-floor-title">
  48 + <span class="date">{{date}}</span>
  49 + <span class="title">{{title}}</span>
  50 + </div>
  51 + {{/ newMain}}
  52 +
  53 + {{> product/standard-content}}
  54 + </div>
  55 + </div>
  56 + {{/ newSale}}
  57 +</div>
  58 +{{> layout/footer}}
  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}}
@@ -73,7 +73,7 @@ class Bootstrap extends Bootstrap_Abstract @@ -73,7 +73,7 @@ class Bootstrap extends Bootstrap_Abstract
73 $action = 'Index'; 73 $action = 'Index';
74 74
75 // 二级域名 75 // 二级域名
76 - if (2 === $level) { 76 + if (3 === $level) {
77 $subDomain = strval($hostParts[0]); 77 $subDomain = strval($hostParts[0]);
78 switch (strtolower($subDomain)) { 78 switch (strtolower($subDomain)) {
79 case 'www': // 主站 79 case 'www': // 主站
@@ -28,8 +28,7 @@ class BrandsModel { @@ -28,8 +28,7 @@ class BrandsModel {
28 * @param $options array 28 * @param $options array
29 * @return array 29 * @return array
30 */ 30 */
31 - public static function getBrandSearchData($condition, $options, $domain, $uid, $brandId) {  
32 - 31 + public static function getBrandSearchData($condition, $options, $domain, $uid, $brandId,$node) {
33 // 调用商品搜索接口 32 // 调用商品搜索接口
34 $data = SearchData::searchElasticByCondition($condition); 33 $data = SearchData::searchElasticByCondition($condition);
35 34
@@ -69,9 +68,16 @@ class BrandsModel { @@ -69,9 +68,16 @@ class BrandsModel {
69 $adNav = self::getAdNav($condition['brand']); 68 $adNav = self::getAdNav($condition['brand']);
70 $data['list']['leftContent'][] = array('picLink' => $adNav); 69 $data['list']['leftContent'][] = array('picLink' => $adNav);
71 70
  71 + //获取静态内容(20141219-100447)
  72 + if($node){
  73 + $nodeContent = HelperSearch::formatNodeContent($node);
  74 + $data['list']['leftContent'][]['picLink']['list'] = $nodeContent;
  75 + }
  76 +
72 return $data; 77 return $data;
73 } 78 }
74 79
  80 +
75 /** 81 /**
76 * 获取品牌首页banner条 82 * 获取品牌首页banner条
77 * @string $domain 品牌域名 83 * @string $domain 品牌域名
@@ -89,28 +95,20 @@ class BrandsModel { @@ -89,28 +95,20 @@ class BrandsModel {
89 $bannerImg = Helpers::getImageUrl($bannerImg['data']['banner'], '', 150); 95 $bannerImg = Helpers::getImageUrl($bannerImg['data']['banner'], '', 150);
90 } 96 }
91 // 根据品牌Id获取品牌(简介)、收藏 97 // 根据品牌Id获取品牌(简介)、收藏
92 - if (isset($uid)) {  
93 $intro = BrandData::getBrandIntro($brandId, $uid); 98 $intro = BrandData::getBrandIntro($brandId, $uid);
94 - } 99 +
95 $is_favorite = false; 100 $is_favorite = false;
96 - $logo = false;  
97 $shopName = false; 101 $shopName = false;
98 -  
99 - do {  
100 - if (!isset($intro['data'])) {  
101 - break;  
102 - } 102 + if(isset($intro['data'])){
103 // 获取是否收藏 103 // 获取是否收藏
104 if ($intro['data']['is_favorite'] == 'Y') { 104 if ($intro['data']['is_favorite'] == 'Y') {
105 $is_favorite = true; 105 $is_favorite = true;
106 } elseif ($intro['data']['is_favorite'] == 'N') { 106 } elseif ($intro['data']['is_favorite'] == 'N') {
107 $is_favorite = false; 107 $is_favorite = false;
108 } 108 }
109 - // 获取品牌logo  
110 - $logo = Helpers::getImageUrl($intro['data']['brand_ico'], 80, 50);  
111 // 获取品牌名 109 // 获取品牌名
112 self::$shopName = $intro['data']['brand_name']; 110 self::$shopName = $intro['data']['brand_name'];
113 - } while (false); 111 + }
114 112
115 // 返回banner数据 113 // 返回banner数据
116 return array( 114 return array(
@@ -118,21 +116,6 @@ class BrandsModel { @@ -118,21 +116,6 @@ class BrandsModel {
118 'bannerHeight' => '150', 116 'bannerHeight' => '150',
119 'coled' => $is_favorite, 117 'coled' => $is_favorite,
120 'banner' => $bannerImg 118 'banner' => $bannerImg
121 - ),  
122 - 'shopEntry' => array(  
123 - 'home' => self::$home,  
124 - 'logo' => $logo,  
125 - 'shopName' => self::$shopName,  
126 - 'sort' => array(  
127 - array(  
128 - 'href' => '',  
129 - 'name' => 'T恤'  
130 - ),  
131 - array(  
132 - 'href' => '',  
133 - 'name' => '卫衣'  
134 - )  
135 - )  
136 ) 119 )
137 ); 120 );
138 } 121 }
@@ -148,6 +131,8 @@ class BrandsModel { @@ -148,6 +131,8 @@ class BrandsModel {
148 $result['list'][$key]['src'] = $value['brand_sort_ico']; 131 $result['list'][$key]['src'] = $value['brand_sort_ico'];
149 } 132 }
150 } 133 }
  134 + $result['picTitle'] = '经典系列';
  135 +
151 return $result; 136 return $result;
152 } 137 }
153 138
  1 +<?php
  2 +
  3 +namespace Product;
  4 +
  5 +use LibModels\Wap\Product\SearchData;
  6 +use LibModels\Web\Product\SearchData as WebProduct;
  7 +use Plugin\HelperSearch;
  8 +use Plugin\Images;
  9 +/**
  10 + * sale首页模板数据模型
  11 + *
  12 + */
  13 +class SaleModel
  14 +{
  15 +
  16 + public static function getSaleSearchData($params, $options, $specialInfo)
  17 + {
  18 + $data = SearchData::searchElasticByCondition($params);
  19 +
  20 + if (isset($data['code']) && $data['code'] === 200) {
  21 + //获取分类列表数据
  22 + $classes = WebProduct::getClassesData();
  23 + if (isset($classes['code']) && $classes['code'] === 200) {
  24 + $data['data']['filter']['group_sort'] = $classes['data']['sort'];
  25 + }
  26 +
  27 + //用户浏览记录
  28 +
  29 + // 组织模板数据
  30 + $list = HelperSearch::getList($data, $options);
  31 +
  32 + //删除面包屑导航数据
  33 + unset($list['pathNav']);
  34 +
  35 + $data = array(
  36 + //初始化js
  37 + 'productListPage' => true,
  38 + 'newSale' => $list
  39 + );
  40 + } else {
  41 + $data = array();
  42 + }
  43 +
  44 + //组织sale数据
  45 + if (isset($specialInfo['data']) && !empty($specialInfo['data']['banner_img'])) {
  46 + $banner = json_decode($specialInfo['data']['banner_img'], true);
  47 + foreach ($banner as $k => $v) {
  48 + $v['img'] = Images::getSourceUrl($v['img'], 'couponImg');
  49 + $specialInfo['data']['banner'][] = $v;
  50 + }
  51 + $special = $specialInfo['data'];
  52 + }
  53 +
  54 + //Sale首页 banner数据
  55 + $data['newSale']['saleBanner']['bannerHeight'] = $special['banner'][0]['height'];
  56 + $data['newSale']['saleBanner']['img'] = $special['banner'][0]['img'];
  57 + $data['newSale']['saleTitle']['name'] = '全部商品';
  58 + $data['newSale']['saleTitle']['count'] = $data['newSale']['totalCount'];
  59 +
  60 +
  61 + //获取广告位数据
  62 + $nodeContent = HelperSearch::formatNodeContent($special['left_ad_code']);
  63 + $data['newSale']['leftContent'][]['picLink']['list'] = $nodeContent;
  64 +
  65 + return $data;
  66 + }
  67 +
  68 +}
@@ -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 1 <?php
2 use Action\WebAction; 2 use Action\WebAction;
3 -use Product\BrandsModel;  
4 use LibModels\Web\Product\BrandData; 3 use LibModels\Web\Product\BrandData;
5 class IndexController extends WebAction 4 class IndexController extends WebAction
6 { 5 {
@@ -20,6 +19,7 @@ class IndexController extends WebAction @@ -20,6 +19,7 @@ class IndexController extends WebAction
20 $brandInfo = BrandData::getBrandLogoByDomain($domain); 19 $brandInfo = BrandData::getBrandLogoByDomain($domain);
21 if(!empty($brandInfo['data']) && $brandInfo['code'] === 200){ 20 if(!empty($brandInfo['data']) && $brandInfo['code'] === 200){
22 $brandId = $brandInfo['data']['id']; 21 $brandId = $brandInfo['data']['id'];
  22 + $node = isset($brandInfo['static_content_code']) ? $brandInfo['static_content_code'] : false;
23 }else{ 23 }else{
24 $this->go(SITE_MAIN); 24 $this->go(SITE_MAIN);
25 } 25 }
@@ -54,6 +54,7 @@ class IndexController extends WebAction @@ -54,6 +54,7 @@ class IndexController extends WebAction
54 } 54 }
55 //传品牌ID参数 55 //传品牌ID参数
56 $condition['brand'] = $brandId; 56 $condition['brand'] = $brandId;
  57 +
57 //获取性别数据 58 //获取性别数据
58 $gender = $this->get('gender') ? ($this->get('gender') == '2,3' ? 2 : 1) : (!isset($_COOKIE['_Gender']) ? '3' : ($_COOKIE['_Gender']=='2,3' ? 2 : 1)); 59 $gender = $this->get('gender') ? ($this->get('gender') == '2,3' ? 2 : 1) : (!isset($_COOKIE['_Gender']) ? '3' : ($_COOKIE['_Gender']=='2,3' ? 2 : 1));
59 $condition['gender'] = $gender; 60 $condition['gender'] = $gender;
@@ -92,7 +93,7 @@ class IndexController extends WebAction @@ -92,7 +93,7 @@ class IndexController extends WebAction
92 93
93 $params = $condition + $_GET; 94 $params = $condition + $_GET;
94 $params = array_filter($params); 95 $params = array_filter($params);
95 - $data = Product\BrandsModel::getBrandSearchData($params,$options,$domain,$uid,$brandId); 96 + $data = Product\BrandsModel::getBrandSearchData($params,$options,$domain,$uid,$brandId,$node);
96 $cate = array('boys','girls','kids','lifestyle'); 97 $cate = array('boys','girls','kids','lifestyle');
97 $this->setWebNavHeader($cate[$gender-1]); 98 $this->setWebNavHeader($cate[$gender-1]);
98 //渲染模板 99 //渲染模板
@@ -858,6 +858,7 @@ class Index1Controller extends AbstractAction @@ -858,6 +858,7 @@ class Index1Controller extends AbstractAction
858 ), 858 ),
859 array( 859 array(
860 'picLink' => array( 860 'picLink' => array(
  861 + array(
861 'title' => 'AAAA', 862 'title' => 'AAAA',
862 'list' => array( 863 'list' => array(
863 array( 864 array(
@@ -869,6 +870,17 @@ class Index1Controller extends AbstractAction @@ -869,6 +870,17 @@ class Index1Controller extends AbstractAction
869 'src' => 'http://img12.static.yhbimg.com/brandBanner/2015/02/04/06/0216e9a4c1c1edb0c8fe6b4347cc5a8035.jpg' 870 'src' => 'http://img12.static.yhbimg.com/brandBanner/2015/02/04/06/0216e9a4c1c1edb0c8fe6b4347cc5a8035.jpg'
870 ) 871 )
871 ) 872 )
  873 + ),
  874 + array(
  875 + array(
  876 + 'href' => 'http://adidas.yohobuy.com/?folder=1366',
  877 + 'src' => 'http://img12.static.yhbimg.com/brandBanner/2015/02/04/06/0216e9a4c1c1edb0c8fe6b4347cc5a8035.jpg'
  878 + ),
  879 + array(
  880 + 'href' => 'http://adidas.yohobuy.com/?folder=1366',
  881 + 'src' => 'http://img12.static.yhbimg.com/brandBanner/2015/02/04/06/0216e9a4c1c1edb0c8fe6b4347cc5a8035.jpg'
  882 + )
  883 + )
872 ) 884 )
873 ), 885 ),
874 array( 886 array(
  1 +<?php
  2 +
  3 +use Action\WebAction;
  4 +use LibModels\Web\Product\SaleData;
  5 +
  6 +/**
  7 + * sale页
  8 + *
  9 + */
  10 +class SaleController extends WebAction
  11 +{
  12 +
  13 + public function indexAction()
  14 + {
  15 + //获取专区ID
  16 + $specialsaleId = $this->param('specialsaleId');
  17 + $specialInfo = SaleData::getSpecial($specialsaleId);
  18 + $special = $specialInfo['data'];
  19 +
  20 + //获取促销ID
  21 + $promotion = $this->param('promotion');
  22 +
  23 + //专区ID和促销ID都为空时,跳转到主页
  24 + if (empty($specialsaleId) && empty($promotion)) {
  25 + $this->go(SITE_MAIN);
  26 + }
  27 +
  28 + /* 过滤请求参数 */
  29 + $condition = array();
  30 + $condition = filter_input_array(INPUT_GET, array(
  31 + //'query' => FILTER_SANITIZE_STRING,
  32 + 'sort' => FILTER_VALIDATE_INT,
  33 + 'msort' => FILTER_VALIDATE_INT,
  34 + 'misort' => FILTER_VALIDATE_INT,
  35 + 'color' => FILTER_VALIDATE_INT,
  36 + 'size' => FILTER_VALIDATE_INT,
  37 + 'style' => FILTER_DEFAULT,
  38 + 'price' => FILTER_DEFAULT,
  39 + 'gender' => FILTER_DEFAULT,
  40 + 'p_d' => FILTER_DEFAULT,
  41 + 'shelve_time' => FILTER_DEFAULT,
  42 + 'isNew' => FILTER_DEFAULT,
  43 + 'specialoffer' => FILTER_DEFAULT,
  44 + 'limited' => FILTER_DEFAULT,
  45 + 'order' => FILTER_DEFAULT,
  46 + 'viewNum' => FILTER_VALIDATE_INT,
  47 + 'rowNum' => FILTER_VALIDATE_INT,
  48 + 'page' => FILTER_VALIDATE_INT,), false);
  49 +
  50 + //字符转码
  51 + if (!empty($condition)) {
  52 + foreach ($condition as &$value) {
  53 + $value = rawurldecode($value);
  54 + }
  55 + }
  56 + //传品牌ID参数
  57 + if(!empty($special['brand_id'])){
  58 + $condition['brand'] = $special['brand_id'];
  59 + }
  60 +
  61 + //传促销id
  62 + if(!empty($special['ispromotion'])){
  63 + $condition['promotion'] = $special['ispromotion'];
  64 + }else{
  65 + $condition['promotion'] = $promotion;
  66 + }
  67 +
  68 + //获取性别数据
  69 + $gender = $this->get('gender') ? ($this->get('gender') == '2,3' ? 2 : 1) : (!isset($_COOKIE['_Gender']) ? '3' : ($_COOKIE['_Gender'] == '2,3' ? 2 : 1));
  70 + $condition['gender'] = $gender;
  71 +
  72 + //每页显示商品数
  73 + if (!isset($condition['viewNum']) || empty($condition['viewNum'])) {
  74 + $condition['viewNum'] = 59;
  75 + }
  76 + $view_num_arr = array(60, 100, 200);
  77 + if (!in_array($condition['viewNum'], $view_num_arr)) {
  78 + $condition['viewNum'] = 59;
  79 + }
  80 + //每行显示的商品数量
  81 + if (!isset($condition['rowNum']) || empty($condition['rowNum'])) {
  82 + $condition['rowNum'] = 5;
  83 + }
  84 + if ($condition['rowNum'] == 6) {
  85 + $imgSize = array(195, 260);
  86 + $minImgSize = array(50, 67);
  87 + } else {
  88 + $condition['rowNum'] = 5;
  89 + $imgSize = array(235, 314);
  90 + $minImgSize = array(60, 80);
  91 + }
  92 + //搜索词
  93 + //$query = $this->get('query');
  94 + $condition['needFilter'] = 1;
  95 + $options = array(
  96 + 'imgSize' => $imgSize,
  97 + 'minImgSize' => $minImgSize,
  98 + 'gender' => $gender,
  99 + 'needPd' => 'Y',
  100 + 'rowNum' => $condition['rowNum'],
  101 + 'viewNum' => $condition['viewNum'] - 1,
  102 + 'specialsale_id' => 'Y'
  103 + );
  104 +
  105 + $params = $condition + $_GET;
  106 + $params['attribute_not'] = 2;
  107 + $params = array_filter($params);
  108 +
  109 + $data = Product\SaleModel::getSaleSearchData($params, $options, $specialInfo);
  110 + $cate = array('boys', 'girls', 'kids', 'lifestyle');
  111 + $this->setWebNavHeader($cate[$gender - 1]);
  112 + //渲染模板
  113 + $this->_view->display('new-sale', $data);
  114 + }
  115 +
  116 +}
  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 +}