Authored by whb

Merge branch 'develop' of http://git.dev.yoho.cn/web/yohobuy.git into develop

@@ -112,8 +112,6 @@ class HelperSearch @@ -112,8 +112,6 @@ class HelperSearch
112 $result['leftContent'][]['allSort'] = isset($data['sort']) ? self::groupSort($data['sort']['sort']) : array(); 112 $result['leftContent'][]['allSort'] = isset($data['sort']) ? self::groupSort($data['sort']['sort']) : array();
113 //一周新品上架 113 //一周新品上架
114 $result['leftContent'][]['newSales'] = isset($data['recent']) ? self::recentShelve($data['recent']['recent']) : array(); 114 $result['leftContent'][]['newSales'] = isset($data['recent']) ? self::recentShelve($data['recent']['recent']) : array();
115 - //全部折扣  
116 - $result['leftContent'][]['allDiscount'] = isset($data['discount']) ? self::getDiscount($data['discount']['discount']) : array();  
117 //品牌banner 115 //品牌banner
118 $result['brandBanner'] = isset($data['banner']) && isset($data['brand']) ? self::getBannerFormat($data['banner'],$data['brand']) : array(); 116 $result['brandBanner'] = isset($data['banner']) && isset($data['brand']) ? self::getBannerFormat($data['banner'],$data['brand']) : array();
119 //总记录数 117 //总记录数
@@ -133,7 +131,7 @@ class HelperSearch @@ -133,7 +131,7 @@ class HelperSearch
133 if (isset($options['controller']) && $options['controller'] == 'Search') { 131 if (isset($options['controller']) && $options['controller'] == 'Search') {
134 self::setSearchNav($data['product']['total']); 132 self::setSearchNav($data['product']['total']);
135 } 133 }
136 - $result['pathNav'] = self::$listnav; 134 + $result['pathNav'] = isset($options['controller']) && $options['controller'] == 'Sale' ? array() : self::$listnav;
137 return $result; 135 return $result;
138 } 136 }
139 137
@@ -558,7 +556,12 @@ class HelperSearch @@ -558,7 +556,12 @@ class HelperSearch
558 }else{ 556 }else{
559 $price = explode(',', $priceId); 557 $price = explode(',', $priceId);
560 if (count($price) == 2) { 558 if (count($price) == 2) {
561 - 559 + if (!$price[0]) {
  560 + $price[0] = 0;
  561 + }
  562 + if (!$price[1]) {
  563 + $price[1] = 99999;
  564 + }
562 self::$selected['price'] = array( 565 self::$selected['price'] = array(
563 'name' => self::$params['price'] == '2000,99999' ? '¥2000以上' : '¥' . (int)$price[0] . '-' . (int)$price[1], 566 'name' => self::$params['price'] == '2000,99999' ? '¥2000以上' : '¥' . (int)$price[0] . '-' . (int)$price[1],
564 'href' => self::buildurl($params) 567 'href' => self::buildurl($params)
@@ -595,6 +598,12 @@ class HelperSearch @@ -595,6 +598,12 @@ class HelperSearch
595 if (isset($params['price']) && !isset($filter['price'][$priceId]) ) { 598 if (isset($params['price']) && !isset($filter['price'][$priceId]) ) {
596 $price = explode(',', $params['price']); 599 $price = explode(',', $params['price']);
597 unset($params['price']); 600 unset($params['price']);
  601 + if (!$price[0]) {
  602 + $price[0] = 0;
  603 + }
  604 + if (!$price[1]) {
  605 + $price[1] = 99999;
  606 + }
598 $result = array( 607 $result = array(
599 'min' => $price[0], 608 'min' => $price[0],
600 'max' => $price[1] 609 'max' => $price[1]
@@ -21,7 +21,7 @@ @@ -21,7 +21,7 @@
21 </span> 21 </span>
22 {{/ comments}} 22 {{/ comments}}
23 </div> 23 </div>
24 - <a class="comment-content-footer tap-hightlight" href="{{commentsUrl}}"> 24 + <a class="comment-content-footer tap-hightlight" href="{{commentsUrl}}">
25 查看更多 25 查看更多
26 <span class="iconfont">&#xe604;</span> 26 <span class="iconfont">&#xe604;</span>
27 </a> 27 </a>
@@ -37,7 +37,7 @@ @@ -37,7 +37,7 @@
37 <div class="consult-content-main content-main"> 37 <div class="consult-content-main content-main">
38 {{# consults}} 38 {{# consults}}
39 <div class="question"> 39 <div class="question">
40 - <span class="iconfont">&#xe639;</span> 40 + <span class="iconfont">&#xe644;</span>
41 <p> 41 <p>
42 {{question}}<br> 42 {{question}}<br>
43 <span class="time">{{time}}</span> 43 <span class="time">{{time}}</span>
@@ -45,7 +45,7 @@ @@ -45,7 +45,7 @@
45 </div> 45 </div>
46 46
47 <div class="answer"> 47 <div class="answer">
48 - <span class="iconfont">&#xe63f;</span> 48 + <span class="iconfont">&#xe642;</span>
49 <p>{{answer}}</p> 49 <p>{{answer}}</p>
50 </div> 50 </div>
51 {{/ consults}} 51 {{/ consults}}
@@ -2,11 +2,10 @@ @@ -2,11 +2,10 @@
2 2
3 namespace Product; 3 namespace Product;
4 4
5 -use LibModels\Wap\Product\SearchData;  
6 -use LibModels\Web\Product\SearchData as WebProduct;  
7 use Plugin\HelperSearch; 5 use Plugin\HelperSearch;
8 -use \LibModels\Web\Product\SearchData as Search;  
9 -use Plugin\Images; 6 +use Product\SearchModel;
  7 +use Api\Yohobuy;
  8 +
10 /** 9 /**
11 * sale首页模板数据模型 10 * sale首页模板数据模型
12 * 11 *
@@ -14,33 +13,24 @@ use Plugin\Images; @@ -14,33 +13,24 @@ use Plugin\Images;
14 class NewModel 13 class NewModel
15 { 14 {
16 15
17 - public static function getNewSearchData($params, $options) 16 + public static function getNewSearchData($customCondition, $customOptions)
18 { 17 {
19 - $data = array();  
20 - // 调用接口查询商品数据  
21 - $result = SearchData::searchElasticByCondition($params);  
22 - if (isset($result['code']) && $result['code'] === 200) {  
23 - // 调用分类信息  
24 - $category = Search::getClassesData();  
25 - if (isset($category['code']) && $category['code'] === 200) {  
26 - $result['data']['filter']['group_sort'] = $category['data']['sort'];  
27 - }  
28 - // 调用折扣区间  
29 - $discount = Search::getDiscount();  
30 - if (isset($discount['code']) && $discount['code'] === 200) {  
31 - $result['data']['filter']['discount'] = $discount['data']['discount'];  
32 - }  
33 - // 调用最新上架  
34 - $recent = Search::recentShelve();  
35 - if (isset($discount['code']) && $discount['code'] === 200) {  
36 - $result['data']['filter']['recent'] = $recent['data']['recent'];  
37 - }  
38 - //用户浏览记录  
39 - $result['data']['filter']['review'] = Search::getRecentReview();  
40 - // 组织模板数据  
41 - $data = HelperSearch::getList($result, $options);  
42 -  
43 - //new页面模拟数据 18 + $urlList = array();
  19 + $searchCondition = SearchModel::searchCondition($customCondition, $customOptions);
  20 + // 组合搜索商品url
  21 + $urlList['product'] = HelperSearch::getProductUrl($searchCondition['condition']);
  22 + // 组合搜索分类url
  23 + $urlList['sort'] = HelperSearch::getClassesUrl($searchCondition['condition']);
  24 + // 组合搜索最新上架url
  25 + $urlList['recent'] = HelperSearch::getRecentShelveUrl($searchCondition['condition']);
  26 + //用户浏览记录
  27 + //$urlList['reviewUrl'] = HelperSearch::getReviewUrl($searchCondition['condition']);
  28 +
  29 + $result = Yohobuy::getMulti($urlList, array(), true);
  30 + // 组织模板数据
  31 + $data = HelperSearch::getList($result, $searchCondition['options']);
  32 +
  33 + //new页面模拟数据
44 $data['newMain'] = array( 34 $data['newMain'] = array(
45 'banner' => 'http://img11.static.yhbimg.com/yhb-img01/2015/11/23/07/010a459d41b99a839cba9377532f1c19b2.jpg?imageView/3/w/970/h/200', 35 'banner' => 'http://img11.static.yhbimg.com/yhb-img01/2015/11/23/07/010a459d41b99a839cba9377532f1c19b2.jpg?imageView/3/w/970/h/200',
46 'date' => '12月16日', 36 'date' => '12月16日',
@@ -72,12 +62,8 @@ class NewModel @@ -72,12 +62,8 @@ class NewModel
72 ) 62 )
73 ) 63 )
74 ); 64 );
75 - }  
76 -  
77 - return array(  
78 - 'productListPage' => true,  
79 - 'newSale' => $data  
80 - ); 65 +
  66 + return $data;
81 } 67 }
82 - 68 +
83 } 69 }
@@ -2,8 +2,7 @@ @@ -2,8 +2,7 @@
2 2
3 namespace Product; 3 namespace Product;
4 4
5 -use LibModels\Wap\Product\SearchData;  
6 -use LibModels\Web\Product\SearchData as WebProduct; 5 +use Api\Yohobuy;
7 use Plugin\HelperSearch; 6 use Plugin\HelperSearch;
8 use Plugin\Images; 7 use Plugin\Images;
9 /** 8 /**
@@ -13,33 +12,27 @@ use Plugin\Images; @@ -13,33 +12,27 @@ use Plugin\Images;
13 class SaleModel 12 class SaleModel
14 { 13 {
15 14
16 - public static function getSaleSearchData($params, $options, $specialInfo) 15 + public static function getSaleSearchData($customCondition, $customOptions, $specialInfo)
17 { 16 {
18 - $data = SearchData::searchElasticByCondition($params); 17 + $urlList = array();
19 18
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 - } 19 + //获取$condition和$option 筛选条件和排序条件
  20 + $searchCondition = SearchModel::searchCondition($customCondition, $customOptions);
  21 +
  22 + // 组合搜索商品url
  23 + $urlList['product'] = HelperSearch::getProductUrl($searchCondition['condition']);
  24 +
  25 + // 组合搜索分类url
  26 + $urlList['sort'] = HelperSearch::getClassesUrl($searchCondition['condition']);
  27 +
  28 + //组合用户浏览记录url
  29 + //$urlList['reviewUrl'] = HelperSearch::getReviewUrl($searchCondition['condition']);
  30 +
  31 + //批量调接口
  32 + $result = Yohobuy::getMulti($urlList, array(), true);
  33 +
  34 + //组织模板数据格式
  35 + $data = HelperSearch::getList($result, $searchCondition['options']);
43 36
44 //组织sale数据 37 //组织sale数据
45 if (isset($specialInfo['data']) && !empty($specialInfo['data']['banner_img'])) { 38 if (isset($specialInfo['data']) && !empty($specialInfo['data']['banner_img'])) {
@@ -52,15 +45,14 @@ class SaleModel @@ -52,15 +45,14 @@ class SaleModel
52 } 45 }
53 46
54 //Sale首页 banner数据 47 //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 - 48 + $data['saleBanner']['bannerHeight'] = $special['banner'][0]['height'];
  49 + $data['saleBanner']['img'] = $special['banner'][0]['img'];
  50 + $data['saleTitle']['name'] = '全部商品';
  51 + $data['saleTitle']['count'] = $data['totalCount'];
60 52
61 //获取广告位数据 53 //获取广告位数据
62 $nodeContent = HelperSearch::formatNodeContent($special['left_ad_code']); 54 $nodeContent = HelperSearch::formatNodeContent($special['left_ad_code']);
63 - $data['newSale']['leftContent'][]['picLink']['list'] = $nodeContent; 55 + $data['leftContent'][]['picLink']['list'] = $nodeContent;
64 56
65 return $data; 57 return $data;
66 } 58 }
  1 +<?php
  2 +
  3 +use Action\WebAction;
  4 +
  5 +/**
  6 + * new页
  7 + *
  8 + */
  9 +class NewController extends WebAction
  10 +{
  11 +
  12 + public function indexAction()
  13 + {
  14 + $condition = array(
  15 + 'order' => 's_t_desc'
  16 + );
  17 + $options = array(
  18 + 'specialsale_id' => 'Y',
  19 + 'needDay' => 'Y'
  20 + );
  21 +
  22 + $newData = Product\NewModel::getNewSearchData($condition, $options);
  23 + $data = array(
  24 + 'productListPage' => true,
  25 + 'newSale' => $newData
  26 + );
  27 + $this->setWebNavHeader();
  28 + //渲染模板
  29 + $this->_view->display('new-sale', $data);
  30 + }
  31 +
  32 +}
@@ -27,39 +27,11 @@ class SaleController extends WebAction @@ -27,39 +27,11 @@ class SaleController extends WebAction
27 $this->go(SITE_MAIN); 27 $this->go(SITE_MAIN);
28 } 28 }
29 29
30 - /* 过滤请求参数 */  
31 $condition = array(); 30 $condition = array();
32 - $condition = filter_input_array(INPUT_GET, array(  
33 - //'query' => FILTER_SANITIZE_STRING,  
34 - 'sort' => FILTER_VALIDATE_INT,  
35 - 'msort' => FILTER_VALIDATE_INT,  
36 - 'misort' => FILTER_VALIDATE_INT,  
37 - 'color' => FILTER_VALIDATE_INT,  
38 - 'size' => FILTER_VALIDATE_INT,  
39 - 'style' => FILTER_DEFAULT,  
40 - 'price' => FILTER_DEFAULT,  
41 - 'gender' => FILTER_DEFAULT,  
42 - 'p_d' => FILTER_DEFAULT,  
43 - 'shelve_time' => FILTER_DEFAULT,  
44 - 'isNew' => FILTER_DEFAULT,  
45 - 'specialoffer' => FILTER_DEFAULT,  
46 - 'limited' => FILTER_DEFAULT,  
47 - 'order' => FILTER_DEFAULT,  
48 - 'viewNum' => FILTER_VALIDATE_INT,  
49 - 'rowNum' => FILTER_VALIDATE_INT,  
50 - 'page' => FILTER_VALIDATE_INT,), false);  
51 -  
52 - //字符转码  
53 - if (!empty($condition)) {  
54 - foreach ($condition as &$value) {  
55 - $value = rawurldecode($value);  
56 - }  
57 - }  
58 //传品牌ID参数 31 //传品牌ID参数
59 if(!empty($special['brand_id'])){ 32 if(!empty($special['brand_id'])){
60 $condition['brand'] = $special['brand_id']; 33 $condition['brand'] = $special['brand_id'];
61 } 34 }
62 -  
63 //传促销id 35 //传促销id
64 if(!empty($special['ispromotion'])){ 36 if(!empty($special['ispromotion'])){
65 $condition['promotion'] = $special['ispromotion']; 37 $condition['promotion'] = $special['ispromotion'];
@@ -67,52 +39,18 @@ class SaleController extends WebAction @@ -67,52 +39,18 @@ class SaleController extends WebAction
67 $condition['promotion'] = $promotion; 39 $condition['promotion'] = $promotion;
68 } 40 }
69 41
70 - //获取性别数据  
71 - $gender = $this->get('gender') ? ($this->get('gender') == '2,3' ? 2 : 1) : (!isset($_COOKIE['_Gender']) ? '3' : ($_COOKIE['_Gender'] == '2,3' ? 2 : 1));  
72 - $condition['gender'] = $gender;  
73 -  
74 - //每页显示商品数  
75 - if (!isset($condition['viewNum']) || empty($condition['viewNum'])) {  
76 - $condition['viewNum'] = 60;  
77 - }  
78 - $view_num_arr = array(60, 100, 200);  
79 - if (!in_array($condition['viewNum'], $view_num_arr)) {  
80 - $condition['viewNum'] = 60;  
81 - }  
82 - //每行显示的商品数量  
83 - if (!isset($condition['rowNum']) || empty($condition['rowNum'])) {  
84 - $condition['rowNum'] = 5;  
85 - }  
86 - if ($condition['rowNum'] == 6) {  
87 - $imgSize = array(195, 260);  
88 - $minImgSize = array(50, 67);  
89 - } else {  
90 - $condition['rowNum'] = 5;  
91 - $imgSize = array(235, 314);  
92 - $minImgSize = array(60, 80);  
93 - }  
94 - //搜索词  
95 - //$query = $this->get('query');  
96 - $condition['needFilter'] = 1;  
97 $options = array( 42 $options = array(
98 - 'imgSize' => $imgSize,  
99 - 'minImgSize' => $minImgSize,  
100 - 'gender' => $gender,  
101 - 'needPd' => 'Y',  
102 - 'rowNum' => $condition['rowNum'],  
103 - 'viewNum' => $condition['viewNum'],  
104 - 'specialsale_id' => 'Y' 43 + 'specialsale_id' => 'Y',
  44 + 'controller' => $this->_request->controller
105 ); 45 );
106 46
107 - $params = $condition + $_GET;  
108 - $params['attribute_not'] = 2;  
109 - $params = array_filter($params);  
110 - //每页记录数减1,下一页占位  
111 - $params['viewNum'] = $params['viewNum'] - 1;  
112 -  
113 - $data = Product\SaleModel::getSaleSearchData($params, $options, $specialInfo);  
114 - $cate = array('boys', 'girls', 'kids', 'lifestyle');  
115 - $this->setWebNavHeader($cate[$gender - 1]); 47 + $saleData = Product\SaleModel::getSaleSearchData($condition, $options, $specialInfo);
  48 + $data = array(
  49 + //初始化js
  50 + 'productListPage' => true,
  51 + 'newSale' => $saleData
  52 + );
  53 + $this->setWebNavHeader();
116 //渲染模板 54 //渲染模板
117 $this->_view->display('new-sale', $data); 55 $this->_view->display('new-sale', $data);
118 } 56 }
1 -<?php  
2 -  
3 -use Action\WebAction;  
4 -use LibModels\Web\Product\SaleData;  
5 -  
6 -/**  
7 - * new页  
8 - *  
9 - */  
10 -class NewController extends WebAction  
11 -{  
12 -  
13 - public function indexAction()  
14 - {  
15 - /* 过滤请求参数 */  
16 - $condition = array();  
17 - $condition = filter_input_array(INPUT_GET, array(  
18 - //'query' => FILTER_SANITIZE_STRING,  
19 - 'sort' => FILTER_VALIDATE_INT,  
20 - 'msort' => FILTER_VALIDATE_INT,  
21 - 'misort' => FILTER_VALIDATE_INT,  
22 - 'color' => FILTER_VALIDATE_INT,  
23 - 'size' => FILTER_VALIDATE_INT,  
24 - 'style' => FILTER_DEFAULT,  
25 - 'price' => FILTER_DEFAULT,  
26 - 'gender' => FILTER_DEFAULT,  
27 - 'p_d' => FILTER_DEFAULT,  
28 - 'shelve_time' => FILTER_DEFAULT,  
29 - 'isNew' => FILTER_DEFAULT,  
30 - 'specialoffer' => FILTER_DEFAULT,  
31 - 'limited' => FILTER_DEFAULT,  
32 - 'order' => FILTER_DEFAULT,  
33 - 'viewNum' => FILTER_VALIDATE_INT,  
34 - 'rowNum' => FILTER_VALIDATE_INT,  
35 - 'page' => FILTER_VALIDATE_INT,), false);  
36 -  
37 - //字符转码  
38 - if (!empty($condition)) {  
39 - foreach ($condition as &$value) {  
40 - $value = rawurldecode($value);  
41 - }  
42 - }  
43 -  
44 - //获取性别数据  
45 - $gender = $this->get('gender') ? ($this->get('gender') == '2,3' ? 2 : 1) : (!isset($_COOKIE['_Gender']) ? '3' : ($_COOKIE['_Gender'] == '2,3' ? 2 : 1));  
46 - $condition['gender'] = $gender;  
47 -  
48 - //每页显示商品数  
49 - if (!isset($condition['viewNum']) || empty($condition['viewNum'])) {  
50 - $condition['viewNum'] = 60;  
51 - }  
52 - $view_num_arr = array(60, 100, 200);  
53 - if (!in_array($condition['viewNum'], $view_num_arr)) {  
54 - $condition['viewNum'] = 60;  
55 - }  
56 - //每行显示的商品数量  
57 - if (!isset($condition['rowNum']) || empty($condition['rowNum'])) {  
58 - $condition['rowNum'] = 5;  
59 - }  
60 - if ($condition['rowNum'] == 6) {  
61 - $imgSize = array(195, 260);  
62 - $minImgSize = array(50, 67);  
63 - } else {  
64 - $condition['rowNum'] = 5;  
65 - $imgSize = array(235, 314);  
66 - $minImgSize = array(60, 80);  
67 - }  
68 - //搜索词  
69 - //$query = $this->get('query');  
70 - $condition['needFilter'] = 1;  
71 - $options = array(  
72 - 'imgSize' => $imgSize,  
73 - 'minImgSize' => $minImgSize,  
74 - 'gender' => $gender,  
75 - 'needPd' => 'Y',  
76 - 'rowNum' => $condition['rowNum'],  
77 - 'viewNum' => $condition['viewNum'],  
78 - 'specialsale_id' => 'Y'  
79 - );  
80 -  
81 - $params = $condition + $_GET;  
82 - $params['attribute_not'] = 2;  
83 - $params = array_filter($params);  
84 - //每页记录数减1,下一页占位  
85 - $params['viewNum'] = $params['viewNum'] - 1;  
86 -  
87 - $data = Product\NewModel::getNewSearchData($params, $options);  
88 - $cate = array('boys', 'girls', 'kids', 'lifestyle');  
89 - $this->setWebNavHeader($cate[$gender - 1]);  
90 - //渲染模板  
91 - $this->_view->display('new-sale', $data);  
92 - }  
93 -  
94 -}