Merge branch 'feature/cart' into develop
Showing
2 changed files
with
49 additions
and
53 deletions
@@ -29,16 +29,56 @@ if ($names.length > 0) { | @@ -29,16 +29,56 @@ if ($names.length > 0) { | ||
29 | $names[0].mlellipsis(2); | 29 | $names[0].mlellipsis(2); |
30 | } | 30 | } |
31 | 31 | ||
32 | +//获取当前购物车类型 | ||
33 | +function getCartType() { | ||
34 | + var $navItem = $('.cart-nav ').find('li'), | ||
35 | + type = 'ordinary'; | ||
36 | + | ||
37 | + if ($navItem.eq(0).hasClass('active')) { | ||
38 | + type = 'ordinary'; | ||
39 | + } else { | ||
40 | + type = 'advance'; | ||
41 | + } | ||
42 | + | ||
43 | + return type; | ||
44 | +} | ||
45 | + | ||
32 | //TIP:事件委托在.cart-goods,商品列表的容器统一需要有.cart-goods | 46 | //TIP:事件委托在.cart-goods,商品列表的容器统一需要有.cart-goods |
33 | $('.cart-goods').on('touchstart', '.checkbox', function() { | 47 | $('.cart-goods').on('touchstart', '.checkbox', function() { |
34 | var $this = $(this), | 48 | var $this = $(this), |
35 | - id = $(this).closest('.shopping-cart-good').data('id'); | 49 | + $good = $this.closest('.shopping-cart-good'), |
50 | + id = $good.data('id'); | ||
51 | + | ||
52 | + var goodsList = [], | ||
53 | + goodInfo = {}, | ||
54 | + isSelected = true; | ||
55 | + | ||
56 | + if ($this.hasClass('icon-cb-checked')) { | ||
57 | + isSelected = true; | ||
58 | + } else { | ||
59 | + isSelected = false; | ||
60 | + } | ||
61 | + | ||
62 | + function GoodInfo(properties) { | ||
63 | + this.goods_type = properties.goods_type; | ||
64 | + this.buy_number = properties.buy_number; | ||
65 | + this.product_sku = properties.product_sku; | ||
66 | + this.selected = properties.selected; | ||
67 | + } | ||
68 | + | ||
69 | + goodInfo.goods_type = getCartType(); | ||
70 | + goodInfo.selected = isSelected ? 'Y' : 'N'; | ||
71 | + goodInfo.product_sku = id; | ||
72 | + goodInfo.buy_number = $good.find('.count').eq(0).text().trim().replace('×', ''); | ||
73 | + | ||
74 | + goodsList.push(new GoodInfo(goodInfo)); | ||
75 | + | ||
36 | 76 | ||
37 | $.ajax({ | 77 | $.ajax({ |
38 | - type: 'GET', | ||
39 | - url: '/cart/index/select', | 78 | + type: 'post', |
79 | + url: 'select', | ||
40 | data: { | 80 | data: { |
41 | - id: id | 81 | + skuList: JSON.stringify(goodsList) |
42 | } | 82 | } |
43 | }).then(function(data) { | 83 | }).then(function(data) { |
44 | if (data.code === 200) { | 84 | if (data.code === 200) { |
@@ -49,9 +89,9 @@ $('.cart-goods').on('touchstart', '.checkbox', function() { | @@ -49,9 +89,9 @@ $('.cart-goods').on('touchstart', '.checkbox', function() { | ||
49 | } | 89 | } |
50 | $.ajax({ | 90 | $.ajax({ |
51 | type: 'GET', | 91 | type: 'GET', |
52 | - url: '/cart/index/getCartData', | 92 | + url: 'getCartData', |
53 | data: { | 93 | data: { |
54 | - skuList: JSON.stringfy(id) | 94 | + id: id |
55 | }, | 95 | }, |
56 | success: function(data) { | 96 | success: function(data) { |
57 | if (data) { | 97 | if (data) { |
@@ -64,7 +104,7 @@ $('.cart-goods').on('touchstart', '.checkbox', function() { | @@ -64,7 +104,7 @@ $('.cart-goods').on('touchstart', '.checkbox', function() { | ||
64 | tip.show('网络错误'); | 104 | tip.show('网络错误'); |
65 | } | 105 | } |
66 | }); | 106 | }); |
67 | - } else if (data.code === 200) { | 107 | + } else if (data.code === 400) { |
68 | tip.show('网络错误'); | 108 | tip.show('网络错误'); |
69 | } | 109 | } |
70 | }).fail(function() { | 110 | }).fail(function() { |
@@ -95,13 +135,6 @@ $('.cart-goods').on('touchstart', '.checkbox', function() { | @@ -95,13 +135,6 @@ $('.cart-goods').on('touchstart', '.checkbox', function() { | ||
95 | 135 | ||
96 | e.stopPropagation(); | 136 | e.stopPropagation(); |
97 | 137 | ||
98 | - //手动触发docTouchEvt清除因点击到del按钮上而被阻止冒泡到doc上的事件从而清除已打开的删除面板 | ||
99 | - //docTouchEvt(); | ||
100 | - // | ||
101 | - //$curDelPanel = $(this).closest('.shopping-cart-good').children('.opt-panel').removeClass('hide'); | ||
102 | - // | ||
103 | - //$(document).on('touchstart', docTouchEvt); | ||
104 | - | ||
105 | dialog.showDialog({ | 138 | dialog.showDialog({ |
106 | dialogText: '您确定要从购物车中删除吗?', | 139 | dialogText: '您确定要从购物车中删除吗?', |
107 | hasFooter: { | 140 | hasFooter: { |
@@ -136,30 +169,6 @@ $('.cart-goods').on('touchstart', '.checkbox', function() { | @@ -136,30 +169,6 @@ $('.cart-goods').on('touchstart', '.checkbox', function() { | ||
136 | 169 | ||
137 | }); | 170 | }); |
138 | 171 | ||
139 | -// .on('touchstart', '.opt-panel', function() { | ||
140 | -// var $this = $(this), | ||
141 | -// id = $this.closest('.shopping-cart-good').data('id'), | ||
142 | -// url; | ||
143 | -// | ||
144 | -// if ($this.closest('.put-in-favorite').length > 0) { | ||
145 | -// | ||
146 | -// //移入收藏夹 | ||
147 | -// url = '/shoppingCart/col'; | ||
148 | -// } else { | ||
149 | -// | ||
150 | -// //删除 | ||
151 | -// url = '/shoppingCart/del'; | ||
152 | -// } | ||
153 | -// | ||
154 | -// $.ajax({ | ||
155 | -// type: 'POST', | ||
156 | -// url: url, | ||
157 | -// data: { | ||
158 | -// id: id | ||
159 | -// } | ||
160 | -// }); | ||
161 | -//}) | ||
162 | - | ||
163 | function requestUpdateAllGoodsCheckStatus(theGoods, successHandeler) { | 172 | function requestUpdateAllGoodsCheckStatus(theGoods, successHandeler) { |
164 | if (requesting) { | 173 | if (requesting) { |
165 | return; | 174 | return; |
@@ -236,24 +245,11 @@ function bottomCheckBoxHandeler(isSelected, type, handlerAfterTouch) { | @@ -236,24 +245,11 @@ function bottomCheckBoxHandeler(isSelected, type, handlerAfterTouch) { | ||
236 | 245 | ||
237 | goodsList.push(new GoodInfo(goodInfo)); | 246 | goodsList.push(new GoodInfo(goodInfo)); |
238 | }); | 247 | }); |
239 | - console.log(goodsList); | ||
240 | 248 | ||
241 | requestUpdateAllGoodsCheckStatus(goodsList, handlerAfterTouch); | 249 | requestUpdateAllGoodsCheckStatus(goodsList, handlerAfterTouch); |
242 | } | 250 | } |
243 | 251 | ||
244 | -//获取当前购物车类型 | ||
245 | -function getCartType() { | ||
246 | - var $navItem = $('.cart-nav ').find('li'), | ||
247 | - type = 'ordinary'; | ||
248 | - | ||
249 | - if ($navItem.eq(0).hasClass('active')) { | ||
250 | - type = 'ordinary'; | ||
251 | - } else { | ||
252 | - type = 'advance'; | ||
253 | - } | ||
254 | 252 | ||
255 | - return type; | ||
256 | -} | ||
257 | 253 | ||
258 | //是否要全选 | 254 | //是否要全选 |
259 | function willBeSelected() { | 255 | function willBeSelected() { |
-
Please register or login to post a comment