Showing
4 changed files
with
53 additions
and
115 deletions
@@ -107,15 +107,23 @@ class HelperSearch | @@ -107,15 +107,23 @@ class HelperSearch | ||
107 | //左侧分类分类 | 107 | //左侧分类分类 |
108 | $result['leftContent'][]['allSort'] = isset($data['sort']) ? self::groupSort($data['sort']['sort']) : array(); | 108 | $result['leftContent'][]['allSort'] = isset($data['sort']) ? self::groupSort($data['sort']['sort']) : array(); |
109 | //一周新品上架 | 109 | //一周新品上架 |
110 | - $result['leftContent'][]['newSales'] = isset($data['recent']) ? self::recentShelve($data['recent']) : array(); | 110 | + $result['leftContent'][]['newSales'] = isset($data['recent']) ? self::recentShelve($data['recent']['recent']) : array(); |
111 | //全部折扣 | 111 | //全部折扣 |
112 | $result['leftContent'][]['allDiscount'] = isset($data['discount']) ? self::getDiscount($data['discount']['discount']) : array(); | 112 | $result['leftContent'][]['allDiscount'] = isset($data['discount']) ? self::getDiscount($data['discount']['discount']) : array(); |
113 | //总记录数 | 113 | //总记录数 |
114 | $result['totalCount'] = $data['product']['total']; | 114 | $result['totalCount'] = $data['product']['total']; |
115 | + //品牌店铺信息 | ||
116 | + $result['shopEntry'] = isset($data['shop']) && !empty($data['shop']) ? self::shop($data['shop'], $data['sort']['sort']) : array(); | ||
115 | //分页 | 117 | //分页 |
116 | $result['pager'] = self::pager($result['totalCount'],$options['viewNum']); | 118 | $result['pager'] = self::pager($result['totalCount'],$options['viewNum']); |
117 | //选中条件 | 119 | //选中条件 |
120 | + if (self::getSelected()) { | ||
118 | $result['filters']['checkedConditions']['conditions'] = self::getSelected(); | 121 | $result['filters']['checkedConditions']['conditions'] = self::getSelected(); |
122 | + } | ||
123 | + //没有选中 | ||
124 | + else{ | ||
125 | + $result['filters']['checkedConditions'] = array(); | ||
126 | + } | ||
119 | if (isset($options['controller']) && $options['controller'] == 'Search') { | 127 | if (isset($options['controller']) && $options['controller'] == 'Search') { |
120 | self::setSearchNav($data['product']['total']); | 128 | self::setSearchNav($data['product']['total']); |
121 | } | 129 | } |
@@ -202,7 +210,7 @@ class HelperSearch | @@ -202,7 +210,7 @@ class HelperSearch | ||
202 | 'href' => self::buildUrl(array_merge($params, array( | 210 | 'href' => self::buildUrl(array_merge($params, array( |
203 | 'parameter_' . $val['standard_id'] => $pval['standard_id'] | 211 | 'parameter_' . $val['standard_id'] => $pval['standard_id'] |
204 | ))) , | 212 | ))) , |
205 | - 'selected' => isset(self::$params['parameter_' . $val['standard_id']]) && self::$params['parameter_' . $val['standard_id']] == $pval['standard_id'] ? true : false | 213 | + 'checked' => isset(self::$params['parameter_' . $val['standard_id']]) && self::$params['parameter_' . $val['standard_id']] == $pval['standard_id'] ? true : false |
206 | ); | 214 | ); |
207 | } | 215 | } |
208 | if (!empty($sub) && count($sub) > 1) { | 216 | if (!empty($sub) && count($sub) > 1) { |
@@ -245,8 +253,9 @@ class HelperSearch | @@ -245,8 +253,9 @@ class HelperSearch | ||
245 | $result[] = array( | 253 | $result[] = array( |
246 | 'name' => $val, | 254 | 'name' => $val, |
247 | 'href' => self::buildUrl(array_merge($params, array( | 255 | 'href' => self::buildUrl(array_merge($params, array( |
248 | - 'gender' => $key | 256 | + 'gender' => $key, |
249 | ))) , | 257 | ))) , |
258 | + 'checked' => isset(self::$params['gender']) && self::$params['gender'] == $key ? true : false | ||
250 | ); | 259 | ); |
251 | } | 260 | } |
252 | return $result; | 261 | return $result; |
@@ -394,7 +403,7 @@ class HelperSearch | @@ -394,7 +403,7 @@ class HelperSearch | ||
394 | 'href' => $url, | 403 | 'href' => $url, |
395 | 'name' => $v['brand_name'], | 404 | 'name' => $v['brand_name'], |
396 | 'key' => strtolower($v['brand_name']), | 405 | 'key' => strtolower($v['brand_name']), |
397 | - 'active' => in_array($v['id'], $brandIds) ? true : false | 406 | + 'checked' => in_array($v['id'], $brandIds) ? true : false |
398 | ); | 407 | ); |
399 | if (is_numeric($v['brand_alif'])) { | 408 | if (is_numeric($v['brand_alif'])) { |
400 | $this_brand['index'] = '0-9'; | 409 | $this_brand['index'] = '0-9'; |
@@ -1065,13 +1074,16 @@ class HelperSearch | @@ -1065,13 +1074,16 @@ class HelperSearch | ||
1065 | 1074 | ||
1066 | /** | 1075 | /** |
1067 | * 组织品牌店铺信息 | 1076 | * 组织品牌店铺信息 |
1077 | + * @param $shop | ||
1078 | + * @param $shopSort | ||
1079 | + * @return array | ||
1068 | */ | 1080 | */ |
1069 | - public static function shop($shop) | 1081 | + public static function shop($shop, $shopSort) |
1070 | { | 1082 | { |
1071 | $url = Helpers::url('','',$shop['brand_domain']); | 1083 | $url = Helpers::url('','',$shop['brand_domain']); |
1072 | $shopEntry = array(); | 1084 | $shopEntry = array(); |
1073 | $sort = array(); | 1085 | $sort = array(); |
1074 | - foreach ($shop['sort'] as $msort) { | 1086 | + foreach ($shopSort as $msort) { |
1075 | if (!isset($msort['sub']) || empty($msort['sub'])) { | 1087 | if (!isset($msort['sub']) || empty($msort['sub'])) { |
1076 | continue; | 1088 | continue; |
1077 | } | 1089 | } |
@@ -1221,7 +1233,15 @@ class HelperSearch | @@ -1221,7 +1233,15 @@ class HelperSearch | ||
1221 | // } | 1233 | // } |
1222 | 1234 | ||
1223 | 1235 | ||
1224 | - | 1236 | + /** |
1237 | + * 获取品牌店铺接口地址 | ||
1238 | + * @param $param | ||
1239 | + * @return string | ||
1240 | + */ | ||
1241 | + public static function getShopUrl($param) | ||
1242 | + { | ||
1243 | + return Yohobuy::httpBuildQuery(self::getUrl('shop'), $param); | ||
1244 | + } | ||
1225 | /** | 1245 | /** |
1226 | * 获取搜索的服务地址 | 1246 | * 获取搜索的服务地址 |
1227 | * | 1247 | * |
@@ -24,12 +24,12 @@ class SearchModel | @@ -24,12 +24,12 @@ class SearchModel | ||
24 | * @param $option | 24 | * @param $option |
25 | * @return mixed | 25 | * @return mixed |
26 | */ | 26 | */ |
27 | - public static function SearchCondition($param, $option) | 27 | + public static function searchCondition($param, $option) |
28 | { | 28 | { |
29 | /* 过滤请求参数 */ | 29 | /* 过滤请求参数 */ |
30 | $condition = filter_input_array(INPUT_GET, array( | 30 | $condition = filter_input_array(INPUT_GET, array( |
31 | 'query' => FILTER_SANITIZE_STRING, | 31 | 'query' => FILTER_SANITIZE_STRING, |
32 | - 'brand' => FILTER_VALIDATE_INT, | 32 | + 'brand' => FILTER_SANITIZE_STRING, |
33 | 'sort' => FILTER_VALIDATE_INT, | 33 | 'sort' => FILTER_VALIDATE_INT, |
34 | 'msort' => FILTER_VALIDATE_INT, | 34 | 'msort' => FILTER_VALIDATE_INT, |
35 | 'misort' => FILTER_VALIDATE_INT, | 35 | 'misort' => FILTER_VALIDATE_INT, |
@@ -51,6 +51,10 @@ class SearchModel | @@ -51,6 +51,10 @@ class SearchModel | ||
51 | if (isset($condition['query']) && !empty($condition['query'])) { | 51 | if (isset($condition['query']) && !empty($condition['query'])) { |
52 | $condition['query'] = rawurldecode($condition['query']); | 52 | $condition['query'] = rawurldecode($condition['query']); |
53 | } | 53 | } |
54 | + //品牌 | ||
55 | + if (isset($condition['brand']) && !empty($condition['brand'])) { | ||
56 | + $condition['brand'] = rawurldecode($condition['brand']); | ||
57 | + } | ||
54 | //性别 | 58 | //性别 |
55 | if (isset($condition['gender']) && !empty($condition['gender'])) { | 59 | if (isset($condition['gender']) && !empty($condition['gender'])) { |
56 | $condition['gender'] = rawurldecode($condition['gender']); | 60 | $condition['gender'] = rawurldecode($condition['gender']); |
@@ -128,7 +132,7 @@ class SearchModel | @@ -128,7 +132,7 @@ class SearchModel | ||
128 | * @param array $customOptions | 132 | * @param array $customOptions |
129 | * @return array | 133 | * @return array |
130 | */ | 134 | */ |
131 | - public static function getSearchData($customCondition = array(), $customOptions = array()) | 135 | + public static function getListData($customCondition = array(), $customOptions = array()) |
132 | { | 136 | { |
133 | $urlList = array(); | 137 | $urlList = array(); |
134 | $searchCondition = self::searchCondition($customCondition, $customOptions); | 138 | $searchCondition = self::searchCondition($customCondition, $customOptions); |
@@ -144,14 +148,6 @@ class SearchModel | @@ -144,14 +148,6 @@ class SearchModel | ||
144 | //$urlList['reviewUrl'] = HelperSearch::getReviewUrl($searchCondition['condition']); | 148 | //$urlList['reviewUrl'] = HelperSearch::getReviewUrl($searchCondition['condition']); |
145 | 149 | ||
146 | $result = Yohobuy::getMulti($urlList, array(), true); | 150 | $result = Yohobuy::getMulti($urlList, array(), true); |
147 | -// print_r($result['product']); | ||
148 | -// print_r($result['sort']); | ||
149 | -// print_r($result['discount']); | ||
150 | -// print_r($result['recent']); | ||
151 | -// exit; | ||
152 | - | ||
153 | - | ||
154 | - | ||
155 | // 组织模板数据 | 151 | // 组织模板数据 |
156 | $data = HelperSearch::getList($result, $searchCondition['options']); | 152 | $data = HelperSearch::getList($result, $searchCondition['options']); |
157 | return $data; | 153 | return $data; |
@@ -159,30 +155,27 @@ class SearchModel | @@ -159,30 +155,27 @@ class SearchModel | ||
159 | 155 | ||
160 | /** | 156 | /** |
161 | * 搜索页面获取搜索数据 | 157 | * 搜索页面获取搜索数据 |
162 | - * @param $condition | ||
163 | - * @param $options | 158 | + * @param $customCondition |
159 | + * @param $customOptions | ||
164 | * @return array | 160 | * @return array |
165 | */ | 161 | */ |
166 | - public static function searchData($condition, $options) | 162 | + public static function searchData($customCondition, $customOptions) |
167 | { | 163 | { |
168 | - $data = self::getSearchData($condition, $options); | ||
169 | - //获取品牌店铺信息 | ||
170 | - if (isset($condition['query'])) { | ||
171 | - $param['keyword'] = $condition['query']; | ||
172 | - $result = SearchData::getShop($param); | ||
173 | - if (isset($result['code']) && $result['code'] === 200 && isset($result['data']) && !empty($result['data'])) { | ||
174 | - //调用品牌分类 | ||
175 | - $class['brand'] = $result['data']['id']; | ||
176 | - $brandSort = SearchData::getClassesData($class); | ||
177 | - $shop = $result['data']; | ||
178 | - if (isset($brandSort['data']['sort']) && !empty($brandSort['data']['sort'])) | ||
179 | - $shop['sort'] = $brandSort['data']['sort']; | ||
180 | - $shopEntry = HelperSearch::shop($shop); | ||
181 | - } | ||
182 | - } | ||
183 | - $data['shopEntry'] = isset($shopEntry) ? $shopEntry : array(); | 164 | + $urlList = array(); |
165 | + $searchCondition = self::searchCondition($customCondition, $customOptions); | ||
166 | + // 组合搜索商品url | ||
167 | + $urlList['product'] = HelperSearch::getProductUrl($searchCondition['condition']); | ||
168 | + // 组合搜索分类url | ||
169 | + $urlList['sort'] = HelperSearch::getClassesUrl($searchCondition['condition']); | ||
170 | + // 组合搜索店铺url | ||
171 | + $param['keyword'] = $searchCondition['condition']['query']; | ||
172 | + $urlList['shop'] = HelperSearch::getShopUrl($param); | ||
173 | + //用户浏览记录 | ||
174 | + //$urlList['reviewUrl'] = HelperSearch::getReviewUrl($searchCondition['condition']); | ||
175 | + $result = Yohobuy::getMulti($urlList, array(), true); | ||
176 | + // 组织模板数据 | ||
177 | + $data = HelperSearch::getList($result, $searchCondition['options']); | ||
184 | return $data; | 178 | return $data; |
185 | - | ||
186 | } | 179 | } |
187 | /** | 180 | /** |
188 | * 根据product_sn查询产品图片信息 | 181 | * 根据product_sn查询产品图片信息 |
@@ -17,87 +17,12 @@ class ListController extends WebAction | @@ -17,87 +17,12 @@ class ListController extends WebAction | ||
17 | */ | 17 | */ |
18 | public function saleAction() | 18 | public function saleAction() |
19 | { | 19 | { |
20 | - /* 过滤请求参数 */ | ||
21 | - $condition = filter_input_array(INPUT_GET, array( | ||
22 | - //'query' => FILTER_SANITIZE_STRING, | ||
23 | - 'brand' => FILTER_VALIDATE_INT, | ||
24 | - 'sort' => FILTER_VALIDATE_INT, | ||
25 | - 'msort' => FILTER_VALIDATE_INT, | ||
26 | - 'misort' => FILTER_VALIDATE_INT, | ||
27 | - 'color' => FILTER_VALIDATE_INT, | ||
28 | - 'size' => FILTER_DEFAULT, | ||
29 | - 'style' => FILTER_DEFAULT, | ||
30 | - 'price' => FILTER_DEFAULT, | ||
31 | - 'gender' => FILTER_DEFAULT, | ||
32 | - 'p_d' => FILTER_DEFAULT, | ||
33 | - 'shelve_time' => FILTER_DEFAULT, | ||
34 | - 'isNew' => FILTER_DEFAULT, | ||
35 | - 'specialoffer' => FILTER_DEFAULT, | ||
36 | - 'limited' => FILTER_DEFAULT, | ||
37 | - 'order' => FILTER_DEFAULT, | ||
38 | - 'viewNum' => FILTER_VALIDATE_INT, | ||
39 | - 'rowNum' => FILTER_VALIDATE_INT, | ||
40 | - 'page' => FILTER_VALIDATE_INT), false); | ||
41 | - //字符转码 | ||
42 | - if (!empty($condition)) { | ||
43 | - foreach ($condition as $key => $val) { | ||
44 | - $condition[$key] = rawurldecode($val); | ||
45 | - } | ||
46 | - } | ||
47 | - //性別(频道) | ||
48 | - $gender_cookie = !isset($_COOKIE['_Gender']) ? '3' : ($_COOKIE['_Gender']=='2,3' ? 2 : 1); | ||
49 | - $gender = $this->get('gender') ? ($this->get('gender') == '2,3' ? 2 : 1) : $gender_cookie ; | ||
50 | - $condition['gender'] = $gender; | ||
51 | - //每页显示商品数 | ||
52 | - if(!isset($condition['viewNum']) || empty($condition['viewNum'])){ | ||
53 | - $condition['viewNum'] =60; | ||
54 | - } | ||
55 | - $view_num_arr = array(60, 100, 200); | ||
56 | - if (!in_array($condition['viewNum'], $view_num_arr)) { | ||
57 | - $condition['viewNum'] = 60; | ||
58 | - } | ||
59 | - //每行显示的商品数量 | ||
60 | - if(!isset($condition['rowNum']) || empty($condition['rowNum'])){ | ||
61 | - $condition['rowNum'] =5; | ||
62 | - } | ||
63 | - if ($condition['rowNum'] == 6) { | ||
64 | - $imgSize = array(195, 260); | ||
65 | - $minImgSize = array(50, 67); | ||
66 | - } else { | ||
67 | - $condition['rowNum'] = 5; | ||
68 | - $imgSize = array(235, 314); | ||
69 | - $minImgSize = array(60, 80); | ||
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 | - $list = SearchModel::getSearchData($params,$options); | 20 | + $list = SearchModel::getListData(); |
94 | $data = array( | 21 | $data = array( |
95 | //初始化js | 22 | //初始化js |
96 | 'productListPage' => true, | 23 | 'productListPage' => true, |
97 | 'list' => $list | 24 | 'list' => $list |
98 | ); | 25 | ); |
99 | - $cate = array('boys','girls','kids','lifestyle'); | ||
100 | - $this->setWebNavHeader($cate[$gender-1]); | ||
101 | $this->_view->display('list', $data); | 26 | $this->_view->display('list', $data); |
102 | } | 27 | } |
103 | 28 |
@@ -7,12 +7,12 @@ class SearchController extends WebAction | @@ -7,12 +7,12 @@ class SearchController extends WebAction | ||
7 | { | 7 | { |
8 | $options['controller'] = $this->_request->controller; | 8 | $options['controller'] = $this->_request->controller; |
9 | $searchData = SearchModel::searchData(array(),$options); | 9 | $searchData = SearchModel::searchData(array(),$options); |
10 | - $this->setWebNavHeader(); | ||
11 | $data = array( | 10 | $data = array( |
12 | //初始化js | 11 | //初始化js |
13 | 'searchListPage' => true, | 12 | 'searchListPage' => true, |
14 | 'search' => $searchData | 13 | 'search' => $searchData |
15 | ); | 14 | ); |
15 | + $this->setWebNavHeader(); | ||
16 | $this->_view->display('search', $data); | 16 | $this->_view->display('search', $data); |
17 | } | 17 | } |
18 | } | 18 | } |
-
Please register or login to post a comment