Showing
2 changed files
with
35 additions
and
41 deletions
@@ -32,13 +32,39 @@ if ($names.length > 0) { | @@ -32,13 +32,39 @@ if ($names.length > 0) { | ||
32 | //TIP:事件委托在.cart-goods,商品列表的容器统一需要有.cart-goods | 32 | //TIP:事件委托在.cart-goods,商品列表的容器统一需要有.cart-goods |
33 | $('.cart-goods').on('touchstart', '.checkbox', function() { | 33 | $('.cart-goods').on('touchstart', '.checkbox', function() { |
34 | var $this = $(this), | 34 | var $this = $(this), |
35 | - id = $(this).closest('.shopping-cart-good').data('id'); | 35 | + $good = $this.closest('.shopping-cart-good'), |
36 | + id = $good.data('id'); | ||
37 | + | ||
38 | + var goodsList = [], | ||
39 | + goodInfo = {}, | ||
40 | + isSelected = true; | ||
41 | + | ||
42 | + if ($this.hasClass('icon-cb-checked')) { | ||
43 | + isSelected = true; | ||
44 | + } else { | ||
45 | + isSelected = false; | ||
46 | + } | ||
47 | + | ||
48 | + function GoodInfo(properties) { | ||
49 | + this.goods_type = properties.goods_type; | ||
50 | + this.buy_number = properties.buy_number; | ||
51 | + this.product_sku = properties.product_sku; | ||
52 | + this.selected = properties.selected; | ||
53 | + } | ||
54 | + | ||
55 | + goodInfo.goods_type = getCartType(); | ||
56 | + goodInfo.selected = isSelected ? 'Y' : 'N'; | ||
57 | + goodInfo.product_sku = id; | ||
58 | + goodInfo.buy_number = $good.find('.count').eq(0).text().trim().replace('×', ''); | ||
59 | + | ||
60 | + goodsList.push(new GoodInfo(goodInfo)); | ||
61 | + | ||
36 | 62 | ||
37 | $.ajax({ | 63 | $.ajax({ |
38 | - type: 'GET', | ||
39 | - url: '/cart/index/select', | 64 | + type: 'post', |
65 | + url: 'select', | ||
40 | data: { | 66 | data: { |
41 | - id: id | 67 | + skuList: JSON.stringify(goodsList) |
42 | } | 68 | } |
43 | }).then(function(data) { | 69 | }).then(function(data) { |
44 | if (data.code === 200) { | 70 | if (data.code === 200) { |
@@ -49,9 +75,9 @@ $('.cart-goods').on('touchstart', '.checkbox', function() { | @@ -49,9 +75,9 @@ $('.cart-goods').on('touchstart', '.checkbox', function() { | ||
49 | } | 75 | } |
50 | $.ajax({ | 76 | $.ajax({ |
51 | type: 'GET', | 77 | type: 'GET', |
52 | - url: '/cart/index/getCartData', | 78 | + url: 'getCartData', |
53 | data: { | 79 | data: { |
54 | - skuList: JSON.stringfy(id) | 80 | + id: id |
55 | }, | 81 | }, |
56 | success: function(data) { | 82 | success: function(data) { |
57 | if (data) { | 83 | if (data) { |
@@ -64,7 +90,7 @@ $('.cart-goods').on('touchstart', '.checkbox', function() { | @@ -64,7 +90,7 @@ $('.cart-goods').on('touchstart', '.checkbox', function() { | ||
64 | tip.show('网络错误'); | 90 | tip.show('网络错误'); |
65 | } | 91 | } |
66 | }); | 92 | }); |
67 | - } else if (data.code === 200) { | 93 | + } else if (data.code === 400) { |
68 | tip.show('网络错误'); | 94 | tip.show('网络错误'); |
69 | } | 95 | } |
70 | }).fail(function() { | 96 | }).fail(function() { |
@@ -95,13 +121,6 @@ $('.cart-goods').on('touchstart', '.checkbox', function() { | @@ -95,13 +121,6 @@ $('.cart-goods').on('touchstart', '.checkbox', function() { | ||
95 | 121 | ||
96 | e.stopPropagation(); | 122 | e.stopPropagation(); |
97 | 123 | ||
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({ | 124 | dialog.showDialog({ |
106 | dialogText: '您确定要从购物车中删除吗?', | 125 | dialogText: '您确定要从购物车中删除吗?', |
107 | hasFooter: { | 126 | hasFooter: { |
@@ -136,30 +155,6 @@ $('.cart-goods').on('touchstart', '.checkbox', function() { | @@ -136,30 +155,6 @@ $('.cart-goods').on('touchstart', '.checkbox', function() { | ||
136 | 155 | ||
137 | }); | 156 | }); |
138 | 157 | ||
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) { | 158 | function requestUpdateAllGoodsCheckStatus(theGoods, successHandeler) { |
164 | if (requesting) { | 159 | if (requesting) { |
165 | return; | 160 | return; |
@@ -236,7 +231,6 @@ function bottomCheckBoxHandeler(isSelected, type, handlerAfterTouch) { | @@ -236,7 +231,6 @@ function bottomCheckBoxHandeler(isSelected, type, handlerAfterTouch) { | ||
236 | 231 | ||
237 | goodsList.push(new GoodInfo(goodInfo)); | 232 | goodsList.push(new GoodInfo(goodInfo)); |
238 | }); | 233 | }); |
239 | - console.log(goodsList); | ||
240 | 234 | ||
241 | requestUpdateAllGoodsCheckStatus(goodsList, handlerAfterTouch); | 235 | requestUpdateAllGoodsCheckStatus(goodsList, handlerAfterTouch); |
242 | } | 236 | } |
-
Please register or login to post a comment