Showing
5 changed files
with
48 additions
and
43 deletions
@@ -109,7 +109,7 @@ class HelperSearch | @@ -109,7 +109,7 @@ class HelperSearch | ||
109 | 109 | ||
110 | /** | 110 | /** |
111 | * 将接口返回的数据($data)组合成模板需要的格式 | 111 | * 将接口返回的数据($data)组合成模板需要的格式 |
112 | - * | 112 | + * |
113 | * @param array $data array( | 113 | * @param array $data array( |
114 | * 'product' => array (接口得到的商品数据) | 114 | * 'product' => array (接口得到的商品数据) |
115 | * 'sort' => array (接口返回的分类数据) | 115 | * 'sort' => array (接口返回的分类数据) |
@@ -131,11 +131,11 @@ class HelperSearch | @@ -131,11 +131,11 @@ class HelperSearch | ||
131 | self::$options = $options; | 131 | self::$options = $options; |
132 | $result = array(); | 132 | $result = array(); |
133 | self::$filter = isset($data['product']['filter']) ? $data['product']['filter'] : array(); | 133 | self::$filter = isset($data['product']['filter']) ? $data['product']['filter'] : array(); |
134 | - | 134 | + |
135 | //当前页 | 135 | //当前页 |
136 | $result['page'] = isset($data['product']['page']) ? $data['product']['page'] : ''; | 136 | $result['page'] = isset($data['product']['page']) ? $data['product']['page'] : ''; |
137 | self::$page = $result['page']; | 137 | self::$page = $result['page']; |
138 | - | 138 | + |
139 | //产品列表 | 139 | //产品列表 |
140 | $result['goods'] = isset($data['product']['product_list']) ? self::getProductList($data['product']['product_list'], $options) : array(); | 140 | $result['goods'] = isset($data['product']['product_list']) ? self::getProductList($data['product']['product_list'], $options) : array(); |
141 | //总页数 | 141 | //总页数 |
@@ -184,7 +184,7 @@ class HelperSearch | @@ -184,7 +184,7 @@ class HelperSearch | ||
184 | if (empty($shopSort)) { | 184 | if (empty($shopSort)) { |
185 | continue; | 185 | continue; |
186 | } | 186 | } |
187 | - $result['shopEntry'][] = $shopSort; | 187 | + $result['shopEntry'][] = $shopSort; |
188 | } | 188 | } |
189 | } | 189 | } |
190 | //分页 | 190 | //分页 |
@@ -314,7 +314,7 @@ class HelperSearch | @@ -314,7 +314,7 @@ class HelperSearch | ||
314 | $isNew = false; | 314 | $isNew = false; |
315 | $isSale = false; | 315 | $isSale = false; |
316 | } | 316 | } |
317 | - | 317 | + |
318 | if (isset($options['isNew']) && $options['isNew']) { | 318 | if (isset($options['isNew']) && $options['isNew']) { |
319 | $isNew = true; | 319 | $isNew = true; |
320 | } | 320 | } |
@@ -1449,7 +1449,7 @@ class HelperSearch | @@ -1449,7 +1449,7 @@ class HelperSearch | ||
1449 | if (self::$total == 0) { | 1449 | if (self::$total == 0) { |
1450 | return $shopEntry; | 1450 | return $shopEntry; |
1451 | } | 1451 | } |
1452 | - | 1452 | + |
1453 | if (empty($shopSort)) { | 1453 | if (empty($shopSort)) { |
1454 | $shopSort = array(); | 1454 | $shopSort = array(); |
1455 | } | 1455 | } |
@@ -1921,4 +1921,3 @@ class HelperSearch | @@ -1921,4 +1921,3 @@ class HelperSearch | ||
1921 | return array(); | 1921 | return array(); |
1922 | } | 1922 | } |
1923 | } | 1923 | } |
1924 | - |
@@ -28,39 +28,45 @@ exports.init = function(num) { | @@ -28,39 +28,45 @@ exports.init = function(num) { | ||
28 | $shopEntryArea = $('.shop-entry-area'), | 28 | $shopEntryArea = $('.shop-entry-area'), |
29 | shopEntryLen = $shopEntry.length; | 29 | shopEntryLen = $shopEntry.length; |
30 | 30 | ||
31 | - if (shopEntryLen > 0) { | ||
32 | - if (shopEntryLen % 3 === 1) { | ||
33 | - $shopEntry.eq(shopEntryLen - 1).css({ | ||
34 | - width: '100%' | ||
35 | - }); | ||
36 | - | ||
37 | - $shopEntry.eq(shopEntryLen - 1).find('.name').css({ | ||
38 | - width: '600px' | ||
39 | - }); | ||
40 | - } else if (shopEntryLen % 3 === 2) { | ||
41 | - $shopEntry.eq(shopEntryLen - 1).css({ | ||
42 | - width: '49%' | ||
43 | - }); | ||
44 | - | ||
45 | - $shopEntry.eq(shopEntryLen - 2).css({ | ||
46 | - width: '49%' | ||
47 | - }); | ||
48 | - | ||
49 | - $shopEntry.eq(shopEntryLen - 1).find('.name').css({ | ||
50 | - width: '230px' | ||
51 | - }); | ||
52 | - | ||
53 | - $shopEntry.eq(shopEntryLen - 2).find('.name').css({ | ||
54 | - width: '230px' | ||
55 | - }); | ||
56 | - } | ||
57 | - | ||
58 | - $('.shop-entry:nth-child(3n+1)').css({ | ||
59 | - marginLeft: 0 | ||
60 | - }); | ||
61 | - | ||
62 | - $shopEntryArea.show(); | ||
63 | - } | 31 | + if (shopEntryLen > 1) { |
32 | + | ||
33 | + if (shopEntryLen === 3) { | ||
34 | + $shopEntry.css({ | ||
35 | + width: '32%' | ||
36 | + }); | ||
37 | + } else if (shopEntryLen % 2) { | ||
38 | + | ||
39 | + // 大于 2 ,并且是基数 | ||
40 | + $('.shop-entry:gt(' + (shopEntryLen - 4) + ')').css({ | ||
41 | + width: '32%' | ||
42 | + }); | ||
43 | + } | ||
44 | + | ||
45 | + $('.shop-entry:nth-child(2n+1)').css({ | ||
46 | + marginLeft: 0 | ||
47 | + }); | ||
48 | + | ||
49 | + $shopEntry.last().css({ | ||
50 | + marginLeft: '2%' | ||
51 | + }); | ||
52 | + | ||
53 | + if (shopEntryLen % 2 === 0) { | ||
54 | + $shopEntry.find('.name').css({ | ||
55 | + width: '50%' | ||
56 | + }); | ||
57 | + } else if (shopEntryLen % 3 === 0) { | ||
58 | + $shopEntry.find('.name').css({ | ||
59 | + width: '26%' | ||
60 | + }); | ||
61 | + } | ||
62 | + | ||
63 | + } else { | ||
64 | + $shopEntry.css({ | ||
65 | + width: '100%' | ||
66 | + }); | ||
67 | + } | ||
68 | + | ||
69 | + $shopEntryArea.slideDown(); | ||
64 | 70 | ||
65 | productList = null; | 71 | productList = null; |
66 | 72 | ||
@@ -266,4 +272,4 @@ $productListNav.find('h3').click(function(event) { | @@ -266,4 +272,4 @@ $productListNav.find('h3').click(function(event) { | ||
266 | } | 272 | } |
267 | }); | 273 | }); |
268 | } | 274 | } |
269 | -}()); | ||
275 | +}()); |
@@ -14,7 +14,7 @@ | @@ -14,7 +14,7 @@ | ||
14 | background: #f5f7f6; | 14 | background: #f5f7f6; |
15 | border: 1px solid #eaeceb; | 15 | border: 1px solid #eaeceb; |
16 | padding: 12px 15px; | 16 | padding: 12px 15px; |
17 | - width: 32%; | 17 | + width: 49%; |
18 | box-sizing: border-box; | 18 | box-sizing: border-box; |
19 | float: left; | 19 | float: left; |
20 | margin: 0 0 10px 2%; | 20 | margin: 0 0 10px 2%; |
@@ -26,7 +26,7 @@ | @@ -26,7 +26,7 @@ | ||
26 | 26 | ||
27 | .name { | 27 | .name { |
28 | margin-left: 10px; | 28 | margin-left: 10px; |
29 | - width: 75px; | 29 | + width: 70%; |
30 | } | 30 | } |
31 | 31 | ||
32 | .shop-name { | 32 | .shop-name { |
-
Please register or login to post a comment