Showing
1 changed file
with
26 additions
and
24 deletions
1 | <?php | 1 | <?php |
2 | 2 | ||
3 | namespace Plugin\DataProcess; | 3 | namespace Plugin\DataProcess; |
4 | - | ||
5 | use Plugin\Helpers; | 4 | use Plugin\Helpers; |
6 | 5 | ||
7 | /** | 6 | /** |
@@ -18,16 +17,19 @@ class ListProcess | @@ -18,16 +17,19 @@ class ListProcess | ||
18 | */ | 17 | */ |
19 | public static function getListData($data) | 18 | public static function getListData($data) |
20 | { | 19 | { |
21 | - $result = array('new' => array(), 'filter' => array()); | 20 | + $result = array('new'=>array(), 'filter'=>array()); |
22 | 21 | ||
23 | - if (isset($data['product_list'])) { | 22 | + if(isset($data['product_list'])) |
23 | + { | ||
24 | $result['new'] = self::getProductData($data['product_list']); | 24 | $result['new'] = self::getProductData($data['product_list']); |
25 | } | 25 | } |
26 | - if (isset($data['filter'])) { | 26 | + if(isset($data['filter'])) |
27 | + { | ||
27 | $result['filter'] = self::getFilterData($data['filter']); | 28 | $result['filter'] = self::getFilterData($data['filter']); |
28 | } | 29 | } |
29 | 30 | ||
30 | return $result; | 31 | return $result; |
32 | + | ||
31 | } | 33 | } |
32 | 34 | ||
33 | /** | 35 | /** |
@@ -46,6 +48,7 @@ class ListProcess | @@ -46,6 +48,7 @@ class ListProcess | ||
46 | } | 48 | } |
47 | 49 | ||
48 | return $products; | 50 | return $products; |
51 | + | ||
49 | } | 52 | } |
50 | 53 | ||
51 | /** | 54 | /** |
@@ -58,12 +61,12 @@ class ListProcess | @@ -58,12 +61,12 @@ class ListProcess | ||
58 | public static function getFilterData($data, $gender = 0) | 61 | public static function getFilterData($data, $gender = 0) |
59 | { | 62 | { |
60 | // 过滤条件数据 | 63 | // 过滤条件数据 |
61 | - $filters = array('classify' => array()); | 64 | + $filters = array('classify'=>array()); |
62 | 65 | ||
63 | $num = 1; | 66 | $num = 1; |
64 | - $build = array(); | ||
65 | foreach ($data as $key => $val) { | 67 | foreach ($data as $key => $val) { |
66 | - if (empty($val)) { | 68 | + if(empty($val)) |
69 | + { | ||
67 | continue; | 70 | continue; |
68 | } | 71 | } |
69 | if (!is_callable("self::$key")) { | 72 | if (!is_callable("self::$key")) { |
@@ -75,7 +78,7 @@ class ListProcess | @@ -75,7 +78,7 @@ class ListProcess | ||
75 | $build['active'] = true; | 78 | $build['active'] = true; |
76 | } | 79 | } |
77 | 80 | ||
78 | - $num ++; | 81 | + $num++; |
79 | $filters['classify'][] = $build; | 82 | $filters['classify'][] = $build; |
80 | } | 83 | } |
81 | 84 | ||
@@ -83,6 +86,7 @@ class ListProcess | @@ -83,6 +86,7 @@ class ListProcess | ||
83 | self::sortArrByField($filters['classify'], 'sort_col'); | 86 | self::sortArrByField($filters['classify'], 'sort_col'); |
84 | 87 | ||
85 | return $filters; | 88 | return $filters; |
89 | + | ||
86 | } | 90 | } |
87 | 91 | ||
88 | private static function brand($data) | 92 | private static function brand($data) |
@@ -161,7 +165,7 @@ class ListProcess | @@ -161,7 +165,7 @@ class ListProcess | ||
161 | foreach ($data as $key => $one) { | 165 | foreach ($data as $key => $one) { |
162 | $discount = array(); | 166 | $discount = array(); |
163 | $discount['dataId'] = $key; | 167 | $discount['dataId'] = $key; |
164 | - $discount['name'] = $one['name'] . '折商品'; | 168 | + $discount['name'] = $one['name'] .'折商品'; |
165 | 169 | ||
166 | $result['subs'][] = $discount; | 170 | $result['subs'][] = $discount; |
167 | } | 171 | } |
@@ -221,18 +225,18 @@ class ListProcess | @@ -221,18 +225,18 @@ class ListProcess | ||
221 | $category['dataId'] = isset($one['relation_parameter']) ? $one['relation_parameter']['sort'] : 0; | 225 | $category['dataId'] = isset($one['relation_parameter']) ? $one['relation_parameter']['sort'] : 0; |
222 | $category['name'] = $one['category_name']; | 226 | $category['name'] = $one['category_name']; |
223 | 227 | ||
224 | - /* // 子品类(目前h5不支持二级) | ||
225 | - if(isset($one['sub'])) | ||
226 | - { | ||
227 | - $category['subs'] = array(); | ||
228 | - foreach ($one['sub'] as $single) { | ||
229 | - $subitem = array(); | ||
230 | - $subitem['dataId'] = $single['category_id']; | ||
231 | - $subitem['name'] = $single['category_name']; | 228 | + /*// 子品类(目前h5不支持二级) |
229 | + if(isset($one['sub'])) | ||
230 | + { | ||
231 | + $category['subs'] = array(); | ||
232 | + foreach ($one['sub'] as $single) { | ||
233 | + $subitem = array(); | ||
234 | + $subitem['dataId'] = $single['category_id']; | ||
235 | + $subitem['name'] = $single['category_name']; | ||
232 | 236 | ||
233 | - $category['subs'][] = $subitem; | ||
234 | - } | ||
235 | - } */ | 237 | + $category['subs'][] = $subitem; |
238 | + } | ||
239 | + }*/ | ||
236 | 240 | ||
237 | $result['subs'][] = $category; | 241 | $result['subs'][] = $category; |
238 | } | 242 | } |
@@ -285,7 +289,7 @@ class ListProcess | @@ -285,7 +289,7 @@ class ListProcess | ||
285 | 289 | ||
286 | foreach ($data as $one) { | 290 | foreach ($data as $one) { |
287 | $size = array(); | 291 | $size = array(); |
288 | - $size['dataId'] = $one['size_id']; | 292 | + $size['dataId'] = $one['size_id']; |
289 | $size['name'] = $one['size_name']; | 293 | $size['name'] = $one['size_name']; |
290 | 294 | ||
291 | $result['subs'][] = $size; | 295 | $result['subs'][] = $size; |
@@ -301,8 +305,7 @@ class ListProcess | @@ -301,8 +305,7 @@ class ListProcess | ||
301 | * @param string $field 字段名称 | 305 | * @param string $field 字段名称 |
302 | * @param boolean $desc 时候降序排列,默认为false | 306 | * @param boolean $desc 时候降序排列,默认为false |
303 | */ | 307 | */ |
304 | - private static function sortArrByField(&$array, $field, $desc = false) | ||
305 | - { | 308 | + private static function sortArrByField(&$array, $field, $desc = false){ |
306 | $fieldArr = array(); | 309 | $fieldArr = array(); |
307 | foreach ($array as $k => $v) { | 310 | foreach ($array as $k => $v) { |
308 | $fieldArr[$k] = $v[$field]; | 311 | $fieldArr[$k] = $v[$field]; |
@@ -310,5 +313,4 @@ class ListProcess | @@ -310,5 +313,4 @@ class ListProcess | ||
310 | $sort = $desc == false ? SORT_ASC : SORT_DESC; | 313 | $sort = $desc == false ? SORT_ASC : SORT_DESC; |
311 | array_multisort($fieldArr, $sort, $array); | 314 | array_multisort($fieldArr, $sort, $array); |
312 | } | 315 | } |
313 | - | ||
314 | } | 316 | } |
-
Please register or login to post a comment