Authored by 周少峰

数据分页不一致,添加搜索提示

@@ -19,12 +19,9 @@ class SearchData extends \LibModels\Wap\Product\SearchData @@ -19,12 +19,9 @@ class SearchData extends \LibModels\Wap\Product\SearchData
19 case 'release': 19 case 'release':
20 if($type == 'sort'){ 20 if($type == 'sort'){
21 return 'http://100.98.132.63/yohosearch/sortgroup.json'; 21 return 'http://100.98.132.63/yohosearch/sortgroup.json';
22 - }elseif($type == 'discount'){  
23 - return 'http://100.98.132.63/yohosearch/discount.json';  
24 - }elseif($type == 'recent'){  
25 - return 'http://100.98.132.63/yohosearch/recent.json';  
26 - }elseif($type == 'review'){  
27 - 22 + }
  23 + elseif($type == 'suggest'){
  24 + return 'http://100.98.132.63/yohosearch/suggest.json';
28 } 25 }
29 return 'http://100.98.132.63/yohosearch/search.json'; 26 return 'http://100.98.132.63/yohosearch/search.json';
30 case 'test': 27 case 'test':
@@ -34,14 +31,10 @@ class SearchData extends \LibModels\Wap\Product\SearchData @@ -34,14 +31,10 @@ class SearchData extends \LibModels\Wap\Product\SearchData
34 if($type == 'sort'){ 31 if($type == 'sort'){
35 return 'http://101.200.31.165/yohosearch/sortgroup.json'; 32 return 'http://101.200.31.165/yohosearch/sortgroup.json';
36 } 33 }
37 - elseif($type == 'discount'){  
38 - return 'http://101.200.31.165/yohosearch/discount.json';  
39 - }  
40 - elseif($type == 'recent'){  
41 - return 'http://101.200.31.165/yohosearch/recent.json';  
42 - }elseif($type == 'review'){  
43 - return 'http://itemapi.yohobuy.com/item/item/recentreview'; 34 + elseif($type == 'suggest'){
  35 + return 'http://101.200.31.165/yohosearch/suggest.json';
44 } 36 }
  37 +
45 return 'http://101.200.31.165/yohosearch/search.json'; 38 return 'http://101.200.31.165/yohosearch/search.json';
46 } 39 }
47 } 40 }
@@ -116,36 +109,19 @@ class SearchData extends \LibModels\Wap\Product\SearchData @@ -116,36 +109,19 @@ class SearchData extends \LibModels\Wap\Product\SearchData
116 } 109 }
117 110
118 /** 111 /**
119 - * 获取折扣区间  
120 - */  
121 - public static function getDiscount(){  
122 - return Yohobuy::get(self::getUrl('discount'));  
123 - }  
124 -  
125 - /**  
126 - * 获取最新上架  
127 - */  
128 - public static function recentShelve(){  
129 - return Yohobuy::get(self::getUrl('recent'));  
130 - }  
131 -  
132 - /**  
133 - * 搜索品牌店铺信息  
134 - * @param array $params 参数 112 + * 获取搜索提示
  113 + * @param $param
  114 + * @param $cache
135 * @return array 115 * @return array
136 */ 116 */
137 - public static function getShop(array $params)  
138 - {  
139 - return Yohobuy::get(self::$shopsUrl,$params);  
140 - }  
141 -  
142 - /**  
143 - * 获取最近浏览记录  
144 - * @param int $limit  
145 - * @return json  
146 - */  
147 - public static function getRecentReview($limit = 0) 117 + public static function getSuggest($param, $cache = false)
148 { 118 {
149 - 119 + if (empty($param['query'])) {
  120 + return array();
  121 + }
  122 + if (empty($param['size'])) {
  123 + $param['size'] = 10;
  124 + }
  125 + return Yohobuy::get(self::getUrl('suggest'),$param, $cache);
150 } 126 }
151 } 127 }
@@ -115,7 +115,7 @@ class HelperSearch @@ -115,7 +115,7 @@ class HelperSearch
115 //品牌店铺信息 115 //品牌店铺信息
116 $result['shopEntry'] = isset($data['shop']) && !empty($data['shop']) ? self::shop($data['shop'], $data['sort']['sort']) : array(); 116 $result['shopEntry'] = isset($data['shop']) && !empty($data['shop']) ? self::shop($data['shop'], $data['sort']['sort']) : array();
117 //分页 117 //分页
118 - $result['pager'] = self::pager($result['totalCount'],$options['viewNum']); 118 + $result['pager'] = self::pager($result['totalCount'],$options['viewNum']-1);
119 //选中条件 119 //选中条件
120 if (self::getSelected()) { 120 if (self::getSelected()) {
121 $result['filters']['checkedConditions']['conditions'] = self::getSelected(); 121 $result['filters']['checkedConditions']['conditions'] = self::getSelected();
@@ -196,4 +196,14 @@ class SearchModel @@ -196,4 +196,14 @@ class SearchModel
196 } 196 }
197 echo json_encode($data); 197 echo json_encode($data);
198 } 198 }
  199 +
  200 + /**
  201 + * 查询搜索提示
  202 + * @param $query
  203 + */
  204 + public static function getSuggest($query)
  205 + {
  206 + $result = SearchData::getSuggest();
  207 + return $result;
  208 + }
199 } 209 }
@@ -27,6 +27,7 @@ class ListController extends WebAction @@ -27,6 +27,7 @@ class ListController extends WebAction
27 'productListPage' => true, 27 'productListPage' => true,
28 'list' => $list 28 'list' => $list
29 ); 29 );
  30 + $this->setWebNavHeader();
30 $this->_view->display('list', $data); 31 $this->_view->display('list', $data);
31 } 32 }
32 33
@@ -15,4 +15,13 @@ class SearchController extends WebAction @@ -15,4 +15,13 @@ class SearchController extends WebAction
15 $this->setWebNavHeader(); 15 $this->setWebNavHeader();
16 $this->_view->display('search', $data); 16 $this->_view->display('search', $data);
17 } 17 }
  18 +
  19 + public function suggest()
  20 + {
  21 + $query = rawurldecode($this->get('query'));
  22 + if ($query) {
  23 + $param['query'] = $query;
  24 + $result = SearchModel::getSuggest($param);
  25 + }
  26 + }
18 } 27 }