Merge branch 'feature/web-list' into develop
Showing
6 changed files
with
367 additions
and
249 deletions
@@ -4,7 +4,7 @@ namespace LibModels\Web\Product; | @@ -4,7 +4,7 @@ namespace LibModels\Web\Product; | ||
4 | use Api\Yohobuy; | 4 | use Api\Yohobuy; |
5 | class SearchData extends \LibModels\Wap\Product\SearchData | 5 | class SearchData extends \LibModels\Wap\Product\SearchData |
6 | { | 6 | { |
7 | - public static $shops_url = 'http://101.200.31.165/yohosearch/shops.json'; | 7 | + public static $shopsUrl = 'http://101.200.31.165/yohosearch/shops.json'; |
8 | /** | 8 | /** |
9 | * 获取搜索的服务地址 | 9 | * 获取搜索的服务地址 |
10 | * | 10 | * |
@@ -136,7 +136,7 @@ class SearchData extends \LibModels\Wap\Product\SearchData | @@ -136,7 +136,7 @@ class SearchData extends \LibModels\Wap\Product\SearchData | ||
136 | */ | 136 | */ |
137 | public static function getShop(array $params) | 137 | public static function getShop(array $params) |
138 | { | 138 | { |
139 | - return Yohobuy::get(self::$shops_url,$params); | 139 | + return Yohobuy::get(self::$shopsUrl,$params); |
140 | } | 140 | } |
141 | 141 | ||
142 | /** | 142 | /** |
@@ -3,6 +3,7 @@ | @@ -3,6 +3,7 @@ | ||
3 | namespace Plugin; | 3 | namespace Plugin; |
4 | use Plugin\Paging; | 4 | use Plugin\Paging; |
5 | use LibModels\Web\Product\BrandData; | 5 | use LibModels\Web\Product\BrandData; |
6 | +use Api\Yohobuy; | ||
6 | /** | 7 | /** |
7 | * 搜索辅助类 | 8 | * 搜索辅助类 |
8 | */ | 9 | */ |
@@ -62,13 +63,13 @@ class HelperSearch | @@ -62,13 +63,13 @@ class HelperSearch | ||
62 | unset(self::$params['page']); | 63 | unset(self::$params['page']); |
63 | unset(self::$params['/sale']); | 64 | unset(self::$params['/sale']); |
64 | unset(self::$params['sale']); | 65 | unset(self::$params['sale']); |
65 | - $filter = $data['data']['filter']; | 66 | + $filter = $data['product']['filter']; |
66 | //产品列表 | 67 | //产品列表 |
67 | - $result['goods'] = self::getProductList($data['data']['product_list'], $options['imgSize']); | 68 | + $result['goods'] = self::getProductList($data['product']['product_list'], $options['imgSize']); |
68 | //总页数 | 69 | //总页数 |
69 | - $result['page_total'] = $data['data']['page_total']; | 70 | + $result['page_total'] = $data['product']['page_total']; |
70 | //当前页 | 71 | //当前页 |
71 | - $result['page'] = $data['data']['page']; | 72 | + $result['page'] = $data['product']['page']; |
72 | self::$page = $result['page']; | 73 | self::$page = $result['page']; |
73 | //清除选中 | 74 | //清除选中 |
74 | $result['filters']['checkedConditions']['clearUrl'] = self::current(); | 75 | $result['filters']['checkedConditions']['clearUrl'] = self::current(); |
@@ -98,25 +99,33 @@ class HelperSearch | @@ -98,25 +99,33 @@ class HelperSearch | ||
98 | //可选每页显示数量 | 99 | //可选每页显示数量 |
99 | $result['opts']['pageCounts'] = self::viewNum(); | 100 | $result['opts']['pageCounts'] = self::viewNum(); |
100 | $result['opts']['curPage'] = self::$page; | 101 | $result['opts']['curPage'] = self::$page; |
101 | - $result['opts']['pageCount'] = $data['data']['page_total']; | ||
102 | - $result['opts']['nextHref'] = ($next = self::next($data['data']['page_total'],$data['data']['filter'])) ? $next['href'] : ''; | ||
103 | - $result['hasNextPage'] = self::next($data['data']['page_total']); | 102 | + $result['opts']['pageCount'] = $data['product']['page_total']; |
103 | + $result['opts']['nextHref'] = ($next = self::next($data['product']['page_total'],$data['product']['filter'])) ? $next['href'] : ''; | ||
104 | + $result['hasNextPage'] = self::next($data['product']['page_total']); | ||
104 | //分类条件 | 105 | //分类条件 |
105 | - $result['filters']['sort'] = isset($filter['group_sort']) ? self::searchSort($filter['group_sort']) : array(); | 106 | + $result['filters']['sort'] = isset($data['sort']) ? self::searchSort($data['sort']['sort']) : array(); |
106 | //左侧分类分类 | 107 | //左侧分类分类 |
107 | - $result['leftContent'][]['allSort'] = isset($filter['group_sort']) ? self::groupSort($filter['group_sort']) : array(); | 108 | + $result['leftContent'][]['allSort'] = isset($data['sort']) ? self::groupSort($data['sort']['sort']) : array(); |
108 | //一周新品上架 | 109 | //一周新品上架 |
109 | - $result['leftContent'][]['newSales'] = isset($filter['recent']) ? self::recentShelve($filter['recent']) : array(); | 110 | + $result['leftContent'][]['newSales'] = isset($data['recent']) ? self::recentShelve($data['recent']['recent']) : array(); |
110 | //全部折扣 | 111 | //全部折扣 |
111 | - $result['leftContent'][]['allDiscount'] = isset($filter['discount']) ? self::getDiscount($filter['discount']) : array(); | 112 | + $result['leftContent'][]['allDiscount'] = isset($data['discount']) ? self::getDiscount($data['discount']['discount']) : array(); |
112 | //总记录数 | 113 | //总记录数 |
113 | - $result['totalCount'] = $data['data']['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(); | ||
114 | //分页 | 117 | //分页 |
115 | $result['pager'] = self::pager($result['totalCount'],$options['viewNum']); | 118 | $result['pager'] = self::pager($result['totalCount'],$options['viewNum']); |
116 | //选中条件 | 119 | //选中条件 |
120 | + if (self::getSelected()) { | ||
117 | $result['filters']['checkedConditions']['conditions'] = self::getSelected(); | 121 | $result['filters']['checkedConditions']['conditions'] = self::getSelected(); |
122 | + } | ||
123 | + //没有选中 | ||
124 | + else{ | ||
125 | + $result['filters']['checkedConditions'] = array(); | ||
126 | + } | ||
118 | if (isset($options['controller']) && $options['controller'] == 'Search') { | 127 | if (isset($options['controller']) && $options['controller'] == 'Search') { |
119 | - self::setSearchNav($data['data']['total']); | 128 | + self::setSearchNav($data['product']['total']); |
120 | } | 129 | } |
121 | $result['pathNav'] = self::$listnav; | 130 | $result['pathNav'] = self::$listnav; |
122 | return $result; | 131 | return $result; |
@@ -128,7 +137,8 @@ class HelperSearch | @@ -128,7 +137,8 @@ class HelperSearch | ||
128 | * @author sefon 2015-12-21 17:24:04 | 137 | * @author sefon 2015-12-21 17:24:04 |
129 | * @return array | 138 | * @return array |
130 | */ | 139 | */ |
131 | - public static function getProductList($product,$imgSize){ | 140 | + public static function getProductList($product,$imgSize) |
141 | + { | ||
132 | $goods = array(); | 142 | $goods = array(); |
133 | foreach($product as $key => $val){ | 143 | foreach($product as $key => $val){ |
134 | //NEW | 144 | //NEW |
@@ -171,7 +181,8 @@ class HelperSearch | @@ -171,7 +181,8 @@ class HelperSearch | ||
171 | * @param $filter | 181 | * @param $filter |
172 | * @return array | 182 | * @return array |
173 | */ | 183 | */ |
174 | - public static function standard($filter) { | 184 | + public static function standard($filter) |
185 | + { | ||
175 | $params = self::$params; | 186 | $params = self::$params; |
176 | $result = array(); | 187 | $result = array(); |
177 | foreach ($filter as $key => $val) { | 188 | foreach ($filter as $key => $val) { |
@@ -199,7 +210,7 @@ class HelperSearch | @@ -199,7 +210,7 @@ class HelperSearch | ||
199 | 'href' => self::buildUrl(array_merge($params, array( | 210 | 'href' => self::buildUrl(array_merge($params, array( |
200 | 'parameter_' . $val['standard_id'] => $pval['standard_id'] | 211 | 'parameter_' . $val['standard_id'] => $pval['standard_id'] |
201 | ))) , | 212 | ))) , |
202 | - '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 |
203 | ); | 214 | ); |
204 | } | 215 | } |
205 | if (!empty($sub) && count($sub) > 1) { | 216 | if (!empty($sub) && count($sub) > 1) { |
@@ -216,7 +227,8 @@ class HelperSearch | @@ -216,7 +227,8 @@ class HelperSearch | ||
216 | * 性别 | 227 | * 性别 |
217 | * @return array | 228 | * @return array |
218 | */ | 229 | */ |
219 | - public static function gender($filter) { | 230 | + public static function gender($filter) |
231 | + { | ||
220 | if (empty($filter) || !isset($filter['gender']) || empty($filter['gender'])) { | 232 | if (empty($filter) || !isset($filter['gender']) || empty($filter['gender'])) { |
221 | return array(); | 233 | return array(); |
222 | } | 234 | } |
@@ -241,8 +253,9 @@ class HelperSearch | @@ -241,8 +253,9 @@ class HelperSearch | ||
241 | $result[] = array( | 253 | $result[] = array( |
242 | 'name' => $val, | 254 | 'name' => $val, |
243 | 'href' => self::buildUrl(array_merge($params, array( | 255 | 'href' => self::buildUrl(array_merge($params, array( |
244 | - 'gender' => $key | 256 | + 'gender' => $key, |
245 | ))) , | 257 | ))) , |
258 | + 'checked' => isset(self::$params['gender']) && self::$params['gender'] == $key ? true : false | ||
246 | ); | 259 | ); |
247 | } | 260 | } |
248 | return $result; | 261 | return $result; |
@@ -342,7 +355,8 @@ class HelperSearch | @@ -342,7 +355,8 @@ class HelperSearch | ||
342 | * @param array $filter | 355 | * @param array $filter |
343 | * @return array | 356 | * @return array |
344 | */ | 357 | */ |
345 | - public static function brand($filter) { | 358 | + public static function brand($filter) |
359 | + { | ||
346 | $options = self::$options; | 360 | $options = self::$options; |
347 | //品牌列表返回空 | 361 | //品牌列表返回空 |
348 | if (isset($options['brandName'])) { | 362 | if (isset($options['brandName'])) { |
@@ -388,8 +402,8 @@ class HelperSearch | @@ -388,8 +402,8 @@ class HelperSearch | ||
388 | 'id' => $v['id'], | 402 | 'id' => $v['id'], |
389 | 'href' => $url, | 403 | 'href' => $url, |
390 | 'name' => $v['brand_name'], | 404 | 'name' => $v['brand_name'], |
391 | - 'key' => $v['brand_name'], | ||
392 | - 'active' => in_array($v['id'], $brandIds) ? true : false | 405 | + 'key' => strtolower($v['brand_name']), |
406 | + 'checked' => in_array($v['id'], $brandIds) ? true : false | ||
393 | ); | 407 | ); |
394 | if (is_numeric($v['brand_alif'])) { | 408 | if (is_numeric($v['brand_alif'])) { |
395 | $this_brand['index'] = '0-9'; | 409 | $this_brand['index'] = '0-9'; |
@@ -421,7 +435,7 @@ class HelperSearch | @@ -421,7 +435,7 @@ class HelperSearch | ||
421 | //品牌列表排序, 添加品牌索引 | 435 | //品牌列表排序, 添加品牌索引 |
422 | $index_key = array(); | 436 | $index_key = array(); |
423 | foreach ($brandList as $key => $val) { | 437 | foreach ($brandList as $key => $val) { |
424 | - if ($key && !in_array($key, $index_key)) { | 438 | + if ($key && !in_array($key, $index_key) && !is_numeric($key)) { |
425 | $index['index'] = strtolower(($key)); | 439 | $index['index'] = strtolower(($key)); |
426 | $index['name'] = $key; | 440 | $index['name'] = $key; |
427 | $result['brandIndex'][] = $index; | 441 | $result['brandIndex'][] = $index; |
@@ -446,7 +460,8 @@ class HelperSearch | @@ -446,7 +460,8 @@ class HelperSearch | ||
446 | * @param array $filter | 460 | * @param array $filter |
447 | * @return array | 461 | * @return array |
448 | */ | 462 | */ |
449 | - public static function size($filter) { | 463 | + public static function size($filter) |
464 | + { | ||
450 | $params = self::$params; | 465 | $params = self::$params; |
451 | $sizeId = isset($params['size']) && !empty($params['size']) ? $params['size'] : ''; | 466 | $sizeId = isset($params['size']) && !empty($params['size']) ? $params['size'] : ''; |
452 | if (isset($params['size'])) { | 467 | if (isset($params['size'])) { |
@@ -483,7 +498,8 @@ class HelperSearch | @@ -483,7 +498,8 @@ class HelperSearch | ||
483 | * @param array $filter | 498 | * @param array $filter |
484 | * @return array | 499 | * @return array |
485 | */ | 500 | */ |
486 | - public static function color($filter) { | 501 | + public static function color($filter) |
502 | + { | ||
487 | $params = self::$params; | 503 | $params = self::$params; |
488 | $colorId = isset($params['color']) && !empty(self::$params['color']) ? self::$params['color'] : ''; | 504 | $colorId = isset($params['color']) && !empty(self::$params['color']) ? self::$params['color'] : ''; |
489 | if (isset($params['color'])) { | 505 | if (isset($params['color'])) { |
@@ -519,7 +535,8 @@ class HelperSearch | @@ -519,7 +535,8 @@ class HelperSearch | ||
519 | * @param array $filter | 535 | * @param array $filter |
520 | * @return array | 536 | * @return array |
521 | */ | 537 | */ |
522 | - public static function price($filter) { | 538 | + public static function price($filter) |
539 | + { | ||
523 | $params = self::$params; | 540 | $params = self::$params; |
524 | $priceId = isset($params['price']) && !empty(self::$params['price']) ? self::$params['price'] : ''; | 541 | $priceId = isset($params['price']) && !empty(self::$params['price']) ? self::$params['price'] : ''; |
525 | if (isset($params['price'])) { | 542 | if (isset($params['price'])) { |
@@ -561,7 +578,8 @@ class HelperSearch | @@ -561,7 +578,8 @@ class HelperSearch | ||
561 | /** | 578 | /** |
562 | * 获取自定义价格要提交的地址 | 579 | * 获取自定义价格要提交的地址 |
563 | */ | 580 | */ |
564 | - public static function customPrice($filter) { | 581 | + public static function customPrice($filter) |
582 | + { | ||
565 | $params = self::$params; | 583 | $params = self::$params; |
566 | $result = array( | 584 | $result = array( |
567 | 'min' => '', | 585 | 'min' => '', |
@@ -584,7 +602,8 @@ class HelperSearch | @@ -584,7 +602,8 @@ class HelperSearch | ||
584 | * @param array $filter | 602 | * @param array $filter |
585 | * @return array | 603 | * @return array |
586 | */ | 604 | */ |
587 | - public static function style($filter) { | 605 | + public static function style($filter) |
606 | + { | ||
588 | $params = self::$params; | 607 | $params = self::$params; |
589 | $styleIds = isset($params['style']) && !empty($params['style']) ? explode(',', $params['style']) : array(); | 608 | $styleIds = isset($params['style']) && !empty($params['style']) ? explode(',', $params['style']) : array(); |
590 | if (isset($params['style'])) { | 609 | if (isset($params['style'])) { |
@@ -975,7 +994,8 @@ class HelperSearch | @@ -975,7 +994,8 @@ class HelperSearch | ||
975 | /** | 994 | /** |
976 | * 当前页地址 | 995 | * 当前页地址 |
977 | */ | 996 | */ |
978 | - public static function current(){ | 997 | + public static function current() |
998 | + { | ||
979 | $url = explode('?', $_SERVER['REQUEST_URI']); | 999 | $url = explode('?', $_SERVER['REQUEST_URI']); |
980 | self::$listnav[0]['href'] = $url[0]; | 1000 | self::$listnav[0]['href'] = $url[0]; |
981 | return $url[0]; | 1001 | return $url[0]; |
@@ -983,7 +1003,8 @@ class HelperSearch | @@ -983,7 +1003,8 @@ class HelperSearch | ||
983 | /** | 1003 | /** |
984 | * 下一页 | 1004 | * 下一页 |
985 | */ | 1005 | */ |
986 | - public static function next($total){ | 1006 | + public static function next($total) |
1007 | + { | ||
987 | $param = self::$params; | 1008 | $param = self::$params; |
988 | $page = self::$page; | 1009 | $page = self::$page; |
989 | $next = array(); | 1010 | $next = array(); |
@@ -1024,13 +1045,14 @@ class HelperSearch | @@ -1024,13 +1045,14 @@ class HelperSearch | ||
1024 | * @param $viewNum | 1045 | * @param $viewNum |
1025 | * @return mixed | 1046 | * @return mixed |
1026 | */ | 1047 | */ |
1027 | - public static function pager($total,$viewNum){ | 1048 | + public static function pager($total, $viewNum){ |
1028 | $Paging = new Paging('Yoho'); | 1049 | $Paging = new Paging('Yoho'); |
1029 | return $Paging->setTotal($total)->setSize($viewNum)->view(0); | 1050 | return $Paging->setTotal($total)->setSize($viewNum)->view(0); |
1030 | } | 1051 | } |
1031 | 1052 | ||
1032 | //组织静态资源数据格式 | 1053 | //组织静态资源数据格式 |
1033 | - public static function formatNodeContent($code){ | 1054 | + public static function formatNodeContent($code) |
1055 | + { | ||
1034 | $nodeContent = BrandData::getByNodeContent($code); | 1056 | $nodeContent = BrandData::getByNodeContent($code); |
1035 | if (isset($nodeContent['code']) && $nodeContent['code'] === 200) { | 1057 | if (isset($nodeContent['code']) && $nodeContent['code'] === 200) { |
1036 | $result = array(); | 1058 | $result = array(); |
@@ -1052,13 +1074,16 @@ class HelperSearch | @@ -1052,13 +1074,16 @@ class HelperSearch | ||
1052 | 1074 | ||
1053 | /** | 1075 | /** |
1054 | * 组织品牌店铺信息 | 1076 | * 组织品牌店铺信息 |
1077 | + * @param $shop | ||
1078 | + * @param $shopSort | ||
1079 | + * @return array | ||
1055 | */ | 1080 | */ |
1056 | - public static function shop($shop) | 1081 | + public static function shop($shop, $shopSort) |
1057 | { | 1082 | { |
1058 | $url = Helpers::url('','',$shop['brand_domain']); | 1083 | $url = Helpers::url('','',$shop['brand_domain']); |
1059 | $shopEntry = array(); | 1084 | $shopEntry = array(); |
1060 | $sort = array(); | 1085 | $sort = array(); |
1061 | - foreach ($shop['sort'] as $msort) { | 1086 | + foreach ($shopSort as $msort) { |
1062 | if (!isset($msort['sub']) || empty($msort['sub'])) { | 1087 | if (!isset($msort['sub']) || empty($msort['sub'])) { |
1063 | continue; | 1088 | continue; |
1064 | } | 1089 | } |
@@ -1112,4 +1137,159 @@ class HelperSearch | @@ -1112,4 +1137,159 @@ class HelperSearch | ||
1112 | } | 1137 | } |
1113 | 1138 | ||
1114 | } | 1139 | } |
1140 | + | ||
1141 | + /** | ||
1142 | + * 并行调接口url获取(搜索产品数据) | ||
1143 | + * @param | ||
1144 | + */ | ||
1145 | + public static function getProductUrl($condition) | ||
1146 | + { | ||
1147 | + // 排序数据映射表 | ||
1148 | + $orderMaps = array( | ||
1149 | + 's_t_desc' => 'shelve_time:desc', | ||
1150 | + 's_t_asc' => 'shelve_time:asc', | ||
1151 | + 's_p_asc' => 'sales_price:asc', | ||
1152 | + 's_p_desc' => 'sales_price:desc', | ||
1153 | + 'p_d_desc' => 'discount:desc', | ||
1154 | + 'p_d_asc' => 'discount:asc', | ||
1155 | + 'skn_desc' => 'product_skn:desc', | ||
1156 | + 'skn_asc' => 'product_skn:asc', | ||
1157 | + 'activities_desc' => 'activities.order_by:desc', | ||
1158 | + 'activities_asc' => 'activities.order_by:asc', | ||
1159 | + 's_n_asc' => 'sales_num:asc', | ||
1160 | + 's_n_desc' => 'sales_num:desc', | ||
1161 | + 'activities_id_desc' => 'activities.activity_id:desc', | ||
1162 | + 'activities_id_asc' => 'activities.activity_id:asc', | ||
1163 | + ); | ||
1164 | + | ||
1165 | + $param = array(); | ||
1166 | + $param['status'] = 1; // 是否上架,1表示在架,2表示不在 | ||
1167 | + $param['sales'] = 'Y'; // 只搜索销售的产品 | ||
1168 | + $param['stocknumber'] = 1; // 过滤掉已售罄的商品 | ||
1169 | + // $param['needFilter'] = 1; // 是否需要返回筛选条件 | ||
1170 | + if (!isset($condition['order'])) { | ||
1171 | + $param['order'] = $orderMaps['s_t_desc']; | ||
1172 | + } else { | ||
1173 | + $param['order'] = $orderMaps[$condition['order']]; | ||
1174 | + } | ||
1175 | + if (!isset($condition['page'])) { | ||
1176 | + $param['page'] = 1; | ||
1177 | + } | ||
1178 | + | ||
1179 | + if(isset($condition['viewNum'])) { | ||
1180 | + $param['viewNum'] = $condition['viewNum']; | ||
1181 | + } else if (!isset($condition['limit'])) { | ||
1182 | + $param['viewNum'] = 60; | ||
1183 | + } else { | ||
1184 | + $param['viewNum'] = $condition['limit']; | ||
1185 | + unset($condition['limit']); | ||
1186 | + } | ||
1187 | + if (!empty($condition)) { | ||
1188 | + $param += $condition; | ||
1189 | + } | ||
1190 | + | ||
1191 | + return Yohobuy::httpBuildQuery(self::getUrl(), $param); | ||
1192 | + } | ||
1193 | + | ||
1194 | + /** | ||
1195 | + * 并行调接口url获取(产品分类) | ||
1196 | + * @param | ||
1197 | + */ | ||
1198 | + | ||
1199 | + public static function getClassesUrl($condition) | ||
1200 | + { | ||
1201 | + | ||
1202 | + $condition['sales'] = 'Y'; //在销售商品分类 | ||
1203 | + $condition['status'] = 1; //上架商品分类 | ||
1204 | + $condition['stocknumber'] = 1; //过滤掉已售罄 | ||
1205 | + | ||
1206 | + return Yohobuy::httpBuildQuery(self::getUrl('sort'), $condition); | ||
1207 | + } | ||
1208 | + | ||
1209 | + /** | ||
1210 | + * 并行调接口url获取(获取折扣区间) | ||
1211 | + * @param | ||
1212 | + */ | ||
1213 | + | ||
1214 | + public static function getDiscountUrl($param = array()) | ||
1215 | + { | ||
1216 | + return Yohobuy::httpBuildQuery(self::getUrl('discount'), $param); | ||
1217 | + } | ||
1218 | + | ||
1219 | + /** | ||
1220 | + * 并行调接口url获取(获取最新上架) | ||
1221 | + */ | ||
1222 | + public static function getRecentShelveUrl($param = array()) | ||
1223 | + { | ||
1224 | + return Yohobuy::httpBuildQuery(self::getUrl('recent'), $param); | ||
1225 | + } | ||
1226 | + | ||
1227 | + /** | ||
1228 | + * 并行调接口url获取(获取用户浏览记录) | ||
1229 | + */ | ||
1230 | +// public static function getReviewUrl($param = array()) | ||
1231 | +// { | ||
1232 | +// return Yohobuy::httpBuildQuery(self::getUrl('review'), $param); | ||
1233 | +// } | ||
1234 | + | ||
1235 | + | ||
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 | + } | ||
1245 | + /** | ||
1246 | + * 获取搜索的服务地址 | ||
1247 | + * | ||
1248 | + * 备注:此处是根据环境来确定使用阿里云内网还是外网的URL | ||
1249 | + * | ||
1250 | + * @return string | ||
1251 | + */ | ||
1252 | + private static function getUrl($type = 'search') | ||
1253 | + { | ||
1254 | + defined('APPLICATION_ENV') || define('APPLICATION_ENV', 'developer'); | ||
1255 | + switch (APPLICATION_ENV) { | ||
1256 | + case 'release': | ||
1257 | + if ($type == 'sort') { | ||
1258 | + return 'http://100.98.132.63/yohosearch/sortgroup.json'; | ||
1259 | + } | ||
1260 | + elseif ($type == 'discount') { | ||
1261 | + return 'http://100.98.132.63/yohosearch/discount.json'; | ||
1262 | + } | ||
1263 | + elseif ($type == 'recent') { | ||
1264 | + return 'http://100.98.132.63/yohosearch/recent.json'; | ||
1265 | + } | ||
1266 | +// elseif ($type == 'review') { | ||
1267 | +// | ||
1268 | +// } | ||
1269 | + elseif ($type == 'shop') { | ||
1270 | + return 'http://100.98.132.63/yohosearch/shops.json'; | ||
1271 | + } | ||
1272 | + return 'http://100.98.132.63/yohosearch/search.json'; | ||
1273 | + case 'test': | ||
1274 | + case 'preview': | ||
1275 | + case 'developer': | ||
1276 | + default: | ||
1277 | + if ($type == 'sort') { | ||
1278 | + return 'http://101.200.31.165/yohosearch/sortgroup.json'; | ||
1279 | + } | ||
1280 | + elseif ($type == 'discount') { | ||
1281 | + return 'http://101.200.31.165/yohosearch/discount.json'; | ||
1282 | + } | ||
1283 | + elseif ($type == 'recent') { | ||
1284 | + return 'http://101.200.31.165/yohosearch/recent.json'; | ||
1285 | + } | ||
1286 | +// elseif ($type == 'review') { | ||
1287 | +// | ||
1288 | +// } | ||
1289 | + elseif ($type == 'shop') { | ||
1290 | + return 'http://101.200.31.165/yohosearch/shops.json'; | ||
1291 | + } | ||
1292 | + return 'http://101.200.31.165/yohosearch/search.json'; | ||
1293 | + } | ||
1294 | + } | ||
1115 | } | 1295 | } |
1 | <?php | 1 | <?php |
2 | namespace Product; | 2 | namespace Product; |
3 | 3 | ||
4 | +use Api\Yohobuy; | ||
5 | +use Plugin\Helpers; | ||
4 | use Plugin\HelperSearch; | 6 | use Plugin\HelperSearch; |
5 | use \LibModels\Web\Product\SearchData; | 7 | use \LibModels\Web\Product\SearchData; |
6 | 8 | ||
@@ -17,68 +19,163 @@ class SearchModel | @@ -17,68 +19,163 @@ class SearchModel | ||
17 | { | 19 | { |
18 | 20 | ||
19 | /** | 21 | /** |
22 | + * 搜索相关页面公共条件处理 | ||
23 | + * @param $param | ||
24 | + * @param $option | ||
25 | + * @return mixed | ||
26 | + */ | ||
27 | + public static function searchCondition($param, $option) | ||
28 | + { | ||
29 | + /* 过滤请求参数 */ | ||
30 | + $condition = filter_input_array(INPUT_GET, array( | ||
31 | + 'query' => FILTER_SANITIZE_STRING, | ||
32 | + 'brand' => FILTER_SANITIZE_STRING, | ||
33 | + 'sort' => FILTER_VALIDATE_INT, | ||
34 | + 'msort' => FILTER_VALIDATE_INT, | ||
35 | + 'misort' => FILTER_VALIDATE_INT, | ||
36 | + 'color' => FILTER_VALIDATE_INT, | ||
37 | + 'size' => FILTER_DEFAULT, | ||
38 | + 'style' => FILTER_DEFAULT, | ||
39 | + 'price' => FILTER_DEFAULT, | ||
40 | + 'gender' => FILTER_SANITIZE_STRING, | ||
41 | + 'p_d' => FILTER_DEFAULT, | ||
42 | + 'shelve_time' => FILTER_DEFAULT, | ||
43 | + 'isNew' => FILTER_DEFAULT, | ||
44 | + 'specialoffer' => FILTER_DEFAULT, | ||
45 | + 'limited' => FILTER_DEFAULT, | ||
46 | + 'order' => FILTER_DEFAULT, | ||
47 | + 'viewNum' => FILTER_VALIDATE_INT, | ||
48 | + 'rowNum' => FILTER_VALIDATE_INT, | ||
49 | + 'page' => FILTER_VALIDATE_INT), false); | ||
50 | + //关键字 | ||
51 | + if (isset($condition['query']) && !empty($condition['query'])) { | ||
52 | + $condition['query'] = rawurldecode($condition['query']); | ||
53 | + } | ||
54 | + //品牌 | ||
55 | + if (isset($condition['brand']) && !empty($condition['brand'])) { | ||
56 | + $condition['brand'] = rawurldecode($condition['brand']); | ||
57 | + } | ||
58 | + //性别 | ||
59 | + if (isset($condition['gender']) && !empty($condition['gender'])) { | ||
60 | + $condition['gender'] = rawurldecode($condition['gender']); | ||
61 | + } | ||
62 | + else { | ||
63 | + $condition['gender'] = Helpers::getGenderByCookie(); | ||
64 | + } | ||
65 | + //每页显示商品数 | ||
66 | + $viewNumArray = array(60, 100, 200); | ||
67 | + if(!isset($condition['viewNum']) || empty($condition['viewNum'])){ | ||
68 | + $condition['viewNum'] =60; | ||
69 | + } | ||
70 | + if (!in_array($condition['viewNum'], $viewNumArray)) { | ||
71 | + $condition['viewNum'] = 60; | ||
72 | + } | ||
73 | + //每行显示的商品数量 | ||
74 | + if(!isset($condition['rowNum']) || empty($condition['rowNum'])){ | ||
75 | + $condition['rowNum'] =5; | ||
76 | + } | ||
77 | + if ($condition['rowNum'] == 6) { | ||
78 | + $imgSize = array(195, 260); | ||
79 | + $minImgSize = array(50, 67); | ||
80 | + } | ||
81 | + else { | ||
82 | + $condition['rowNum'] = 5; | ||
83 | + $imgSize = array(235, 314); | ||
84 | + $minImgSize = array(60, 80); | ||
85 | + } | ||
86 | + //自定义搜索价格 | ||
87 | + if (isset($condition['price']) && !empty($condition['price'])) { | ||
88 | + $price = explode(',', $condition['price']); | ||
89 | + if (!$price[0]) { | ||
90 | + $price[0] = 0; | ||
91 | + } | ||
92 | + if (!$price[1]) { | ||
93 | + $price[1] = 99999; | ||
94 | + } | ||
95 | + $condition['price'] = implode(',', $price); | ||
96 | + } | ||
97 | + //返回搜索条件 | ||
98 | + $condition['needFilter'] = 1; | ||
99 | + //过滤赠品 | ||
100 | + $condition['attribute_not'] = 2; | ||
101 | + //默认排序 | ||
102 | + if (!isset($condition['order']) || empty($condition['order'])) { | ||
103 | + $condition['order'] = 's_n_desc'; | ||
104 | + } | ||
105 | + if (!isset($condition['p_d']) || empty($condition['p_d'])) { | ||
106 | + $condition['p_d'] = '0,0.9'; | ||
107 | + } | ||
108 | + $options = array( | ||
109 | + 'imgSize' => $imgSize, | ||
110 | + 'minImgSize' => $minImgSize, | ||
111 | + 'rowNum' =>$condition['rowNum'], | ||
112 | + 'viewNum' =>$condition['viewNum'], | ||
113 | + ); | ||
114 | + //接收高级选项 | ||
115 | + foreach ($_GET as $key =>$val) { | ||
116 | + if (strpos('parameter_',$key) !== false) { | ||
117 | + $condition[$key] = (int) $val; | ||
118 | + } | ||
119 | + } | ||
120 | + //每页记录数减1,下一页占位 | ||
121 | + $condition['viewNum'] = $condition['viewNum'] - 1; | ||
122 | + $condition = array_merge($condition, $param); | ||
123 | + $options = array_merge($options, $option); | ||
124 | + $data['condition'] = $condition; | ||
125 | + $data['options'] = $options; | ||
126 | + return $data; | ||
127 | + } | ||
128 | + | ||
129 | + /** | ||
20 | * 根据条件获取搜索数据 | 130 | * 根据条件获取搜索数据 |
21 | - * | ||
22 | - * @param $condition 搜索数据的条件 | ||
23 | - * @param $options Array([imgSize] | ||
24 | - * => Array([0] => 235[1] => 314)[minImgSize] => Array([0] => 60[1] => 80)[gender] => 1[needPd] => Y[rowNum] => 5[viewNum] => 60) | ||
25 | - * @author sefon 2015-12-17 16:12:18 | 131 | + * @param array $customCondition |
132 | + * @param array $customOptions | ||
26 | * @return array | 133 | * @return array |
27 | */ | 134 | */ |
28 | - public static function getSearchData($condition, $options) | 135 | + public static function getListData($customCondition = array(), $customOptions = array()) |
29 | { | 136 | { |
30 | - $data = array(); | ||
31 | - // 调用接口查询商品数据 | ||
32 | - $result = SearchData::searchElasticByCondition($condition); | ||
33 | - if (isset($result['code']) && $result['code'] === 200) { | ||
34 | - // 调用分类信息 | ||
35 | - $category = SearchData::getClassesData($condition); | ||
36 | - if (isset($category['code']) && $category['code'] === 200) { | ||
37 | - $result['data']['filter']['group_sort'] = $category['data']['sort']; | ||
38 | - } | ||
39 | - // 调用折扣区间 | ||
40 | - $discount = SearchData::getDiscount(); | ||
41 | - if (isset($discount['code']) && $discount['code'] === 200) { | ||
42 | - $result['data']['filter']['discount'] = $discount['data']['discount']; | ||
43 | - } | ||
44 | - // 调用最新上架 | ||
45 | - $recent = SearchData::recentShelve(); | ||
46 | - if (isset($discount['code']) && $discount['code'] === 200) { | ||
47 | - $result['data']['filter']['recent'] = $recent['data']['recent']; | ||
48 | - } | 137 | + $urlList = array(); |
138 | + $searchCondition = self::searchCondition($customCondition, $customOptions); | ||
139 | + // 组合搜索商品url | ||
140 | + $urlList['product'] = HelperSearch::getProductUrl($searchCondition['condition']); | ||
141 | + // 组合搜索分类url | ||
142 | + $urlList['sort'] = HelperSearch::getClassesUrl($searchCondition['condition']); | ||
143 | + // 组合搜索折扣区间url | ||
144 | + $urlList['discount'] = HelperSearch::getDiscountUrl($searchCondition['condition']); | ||
145 | + // 组合搜索最新上架url | ||
146 | + $urlList['recent'] = HelperSearch::getRecentShelveUrl($searchCondition['condition']); | ||
49 | //用户浏览记录 | 147 | //用户浏览记录 |
50 | - $result['data']['filter']['review'] = SearchData::getRecentReview(); | 148 | + //$urlList['reviewUrl'] = HelperSearch::getReviewUrl($searchCondition['condition']); |
149 | + | ||
150 | + $result = Yohobuy::getMulti($urlList, array(), true); | ||
51 | // 组织模板数据 | 151 | // 组织模板数据 |
52 | - $data = HelperSearch::getList($result, $options); | ||
53 | - } | 152 | + $data = HelperSearch::getList($result, $searchCondition['options']); |
54 | return $data; | 153 | return $data; |
55 | } | 154 | } |
56 | 155 | ||
57 | /** | 156 | /** |
58 | * 搜索页面获取搜索数据 | 157 | * 搜索页面获取搜索数据 |
59 | - * @param $condition | ||
60 | - * @param $options | 158 | + * @param $customCondition |
159 | + * @param $customOptions | ||
61 | * @return array | 160 | * @return array |
62 | */ | 161 | */ |
63 | - public static function searchData($condition, $options){ | ||
64 | - $data = self::getSearchData($condition, $options); | ||
65 | - //获取品牌店铺信息 | ||
66 | - if (isset($condition['query'])) { | ||
67 | - $param['keyword'] = $condition['query']; | ||
68 | - $result = SearchData::getShop($param); | ||
69 | - if (isset($result['code']) && $result['code'] === 200 && isset($result['data']) && !empty($result['data'])) { | ||
70 | - //调用品牌分类 | ||
71 | - $class['brand'] = $result['data']['id']; | ||
72 | - $brandSort = SearchData::getClassesData($class); | ||
73 | - $shop = $result['data']; | ||
74 | - if (isset($brandSort['data']['sort']) && !empty($brandSort['data']['sort'])) | ||
75 | - $shop['sort'] = $brandSort['data']['sort']; | ||
76 | - $shopEntry = HelperSearch::shop($shop); | ||
77 | - } | ||
78 | - } | ||
79 | - $data['shopEntry'] = isset($shopEntry) ? $shopEntry : array(); | 162 | + public static function searchData($customCondition, $customOptions) |
163 | + { | ||
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']); | ||
80 | return $data; | 178 | return $data; |
81 | - | ||
82 | } | 179 | } |
83 | /** | 180 | /** |
84 | * 根据product_sn查询产品图片信息 | 181 | * 根据product_sn查询产品图片信息 |
@@ -17,10 +17,10 @@ class IndexController extends WebAction | @@ -17,10 +17,10 @@ class IndexController extends WebAction | ||
17 | $uid = $this->getUid(); | 17 | $uid = $this->getUid(); |
18 | //根据品牌域名获取品牌id(同时判断品牌域名是否有效) | 18 | //根据品牌域名获取品牌id(同时判断品牌域名是否有效) |
19 | $brandInfo = BrandData::getBrandLogoByDomain($domain); | 19 | $brandInfo = BrandData::getBrandLogoByDomain($domain); |
20 | - if(!empty($brandInfo['data']) && $brandInfo['code'] === 200){ | 20 | + if (!empty($brandInfo['data']) && $brandInfo['code'] === 200) { |
21 | $brandId = $brandInfo['data']['id']; | 21 | $brandId = $brandInfo['data']['id']; |
22 | $node = isset($brandInfo['static_content_code']) ? $brandInfo['static_content_code'] : false; | 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 | } |
26 | 26 | ||
@@ -60,7 +60,7 @@ class IndexController extends WebAction | @@ -60,7 +60,7 @@ class IndexController extends WebAction | ||
60 | $condition['gender'] = $gender; | 60 | $condition['gender'] = $gender; |
61 | 61 | ||
62 | //每页显示商品数 | 62 | //每页显示商品数 |
63 | - if(!isset($condition['viewNum']) || empty($condition['viewNum'])){ | 63 | + if (!isset($condition['viewNum']) || empty($condition['viewNum'])) { |
64 | $condition['viewNum'] =60; | 64 | $condition['viewNum'] =60; |
65 | } | 65 | } |
66 | $view_num_arr = array(60, 100, 200); | 66 | $view_num_arr = array(60, 100, 200); |
@@ -68,7 +68,7 @@ class IndexController extends WebAction | @@ -68,7 +68,7 @@ class IndexController extends WebAction | ||
68 | $condition['viewNum'] = 60; | 68 | $condition['viewNum'] = 60; |
69 | } | 69 | } |
70 | //每行显示的商品数量 | 70 | //每行显示的商品数量 |
71 | - if(!isset($condition['rowNum']) || empty($condition['rowNum'])){ | 71 | + if (!isset($condition['rowNum']) || empty($condition['rowNum'])) { |
72 | $condition['rowNum'] =5; | 72 | $condition['rowNum'] =5; |
73 | } | 73 | } |
74 | if ($condition['rowNum'] == 6) { | 74 | if ($condition['rowNum'] == 6) { |
@@ -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 |
@@ -5,98 +5,14 @@ class SearchController extends WebAction | @@ -5,98 +5,14 @@ class SearchController extends WebAction | ||
5 | { | 5 | { |
6 | public function indexAction() | 6 | public function indexAction() |
7 | { | 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 | - $gender_cookie = !isset($_COOKIE['_Gender']) ? '3' : ($_COOKIE['_Gender']=='2,3' ? 2 : 1); | ||
35 | - $gender = $this->get('gender') ? ($this->get('gender') == '2,3' ? 2 : 1) : $gender_cookie ; | ||
36 | - $condition['gender'] = $gender; | ||
37 | - //每页显示商品数 | ||
38 | - if(!isset($condition['viewNum']) || empty($condition['viewNum'])){ | ||
39 | - $condition['viewNum'] =60; | ||
40 | - } | ||
41 | - $view_num_arr = array(60, 100, 200); | ||
42 | - if (!in_array($condition['viewNum'], $view_num_arr)) { | ||
43 | - $condition['viewNum'] = 60; | ||
44 | - } | ||
45 | - //每行显示的商品数量 | ||
46 | - if(!isset($condition['rowNum']) || empty($condition['rowNum'])){ | ||
47 | - $condition['rowNum'] =5; | ||
48 | - } | ||
49 | - if ($condition['rowNum'] == 6) { | ||
50 | - $imgSize = array(195, 260); | ||
51 | - $minImgSize = array(50, 67); | ||
52 | - } else { | ||
53 | - $condition['rowNum'] = 5; | ||
54 | - $imgSize = array(235, 314); | ||
55 | - $minImgSize = array(60, 80); | ||
56 | - } | ||
57 | - //自定义搜索价格 | ||
58 | - if (isset($condition['price']) && !empty($condition['price'])) { | ||
59 | - $price = explode(',', $condition['price']); | ||
60 | - if (!$price[0]) { | ||
61 | - $price[0] = 0; | ||
62 | - } | ||
63 | - if (!$price[1]) { | ||
64 | - $price[1] = 99999; | ||
65 | - } | ||
66 | - $condition['price'] = implode(',', $price); | ||
67 | - } | ||
68 | - | ||
69 | - //返回搜索条件 | ||
70 | - $condition['needFilter'] = 1; | ||
71 | - //过滤赠品 | ||
72 | - $condition['attribute_not'] = 2; | ||
73 | - /*sale*/ | ||
74 | - //默认排序 | ||
75 | - if (!isset($condition['order']) || empty($condition['order'])) { | ||
76 | - $condition['order'] = 's_n_desc'; | ||
77 | - } | ||
78 | - if (!isset($condition['p_d']) || empty($condition['p_d'])) { | ||
79 | - $condition['p_d'] = '0,0.9'; | ||
80 | - } | ||
81 | - $options = array( | ||
82 | - 'imgSize' => $imgSize, | ||
83 | - 'minImgSize' => $minImgSize, | ||
84 | - 'rowNum' =>$condition['rowNum'], | ||
85 | - 'viewNum' =>$condition['viewNum'], | ||
86 | - ); | ||
87 | - $params = $condition + $_GET; | ||
88 | - $params = array_filter($params); | ||
89 | - //每页记录数减1,下一页占位 | ||
90 | - $params['viewNum'] = $params['viewNum'] - 1; | ||
91 | $options['controller'] = $this->_request->controller; | 8 | $options['controller'] = $this->_request->controller; |
92 | - $searchData = SearchModel::searchData($params,$options); | ||
93 | - $cate = array('boys','girls','kids','lifestyle'); | ||
94 | - $this->setWebNavHeader($cate[$gender-1]); | 9 | + $searchData = SearchModel::searchData(array(),$options); |
95 | $data = array( | 10 | $data = array( |
96 | //初始化js | 11 | //初始化js |
97 | 'searchListPage' => true, | 12 | 'searchListPage' => true, |
98 | 'search' => $searchData | 13 | 'search' => $searchData |
99 | ); | 14 | ); |
15 | + $this->setWebNavHeader(); | ||
100 | $this->_view->display('search', $data); | 16 | $this->_view->display('search', $data); |
101 | } | 17 | } |
102 | } | 18 | } |
-
Please register or login to post a comment