Authored by 梁志锋

购物车修改

@@ -124,6 +124,11 @@ function changeGoodImgWhenClickColor() { @@ -124,6 +124,11 @@ function changeGoodImgWhenClickColor() {
124 } 124 }
125 } 125 }
126 126
  127 +function resetHasSelectedNum() {
  128 + $allChoseItems.find('.num .left-num').html('剩余' + 1 + '件');
  129 + $leftNum.val(1);
  130 +}
  131 +
127 init(); 132 init();
128 133
129 $yohoPage.on('touchstart', '.chose-panel', function(e) { 134 $yohoPage.on('touchstart', '.chose-panel', function(e) {
@@ -212,6 +217,9 @@ $yohoPage.on('touchstart', '.color-list .block', function() { @@ -212,6 +217,9 @@ $yohoPage.on('touchstart', '.color-list .block', function() {
212 217
213 // 修改颜色时修改商品图片 218 // 修改颜色时修改商品图片
214 changeGoodImgWhenClickColor(); 219 changeGoodImgWhenClickColor();
  220 +
  221 + // 颜色切换时, 重置已经选择的商品数量
  222 + //resetHasSelectedNum();
215 }).on('touchstart', '.size-list .block', function() { 223 }).on('touchstart', '.size-list .block', function() {
216 var $this = $(this), 224 var $this = $(this),
217 index, 225 index,
@@ -263,6 +271,9 @@ $yohoPage.on('touchstart', '.color-list .block', function() { @@ -263,6 +271,9 @@ $yohoPage.on('touchstart', '.color-list .block', function() {
263 271
264 // 重置颜色块的样式 272 // 重置颜色块的样式
265 resetColorZeroStock($siblingBlock); 273 resetColorZeroStock($siblingBlock);
  274 +
  275 + // 颜色尺码时, 重置已经选择的商品数量
  276 + //resetHasSelectedNum();
266 }); 277 });
267 278
268 $yohoPage.on('touchstart', '.btn-minus', function() { 279 $yohoPage.on('touchstart', '.btn-minus', function() {
@@ -41,25 +41,14 @@ $('.cart-goods').on('touchstart', '.checkbox', function() { @@ -41,25 +41,14 @@ $('.cart-goods').on('touchstart', '.checkbox', function() {
41 id = $good.data('id'); 41 id = $good.data('id');
42 42
43 var goodsList = [], 43 var goodsList = [],
44 - goodInfo = {},  
45 - isSelected = true;  
46 -  
47 - if ($this.hasClass('icon-cb-checked')) {  
48 - isSelected = true;  
49 - } else {  
50 - isSelected = false;  
51 - }  
52 -  
53 - 44 + goodInfo = {};
54 45
55 goodInfo.goods_type = cartType; 46 goodInfo.goods_type = cartType;
56 - goodInfo.selected = isSelected ? 'N' : 'Y'; 47 + goodInfo.selected = $this.hasClass('icon-cb-checked') ? 'N' : 'Y';
57 goodInfo.product_sku = id; 48 goodInfo.product_sku = id;
58 goodInfo.buy_number = $good.find('.count').eq(0).text().trim().replace('×', ''); 49 goodInfo.buy_number = $good.find('.count').eq(0).text().trim().replace('×', '');
59 -  
60 goodsList.push(new GoodInfo(goodInfo)); 50 goodsList.push(new GoodInfo(goodInfo));
61 51
62 -  
63 $.ajax({ 52 $.ajax({
64 type: 'post', 53 type: 'post',
65 url: 'select', 54 url: 'select',
@@ -92,8 +81,8 @@ $('.cart-goods').on('touchstart', '.checkbox', function() { @@ -92,8 +81,8 @@ $('.cart-goods').on('touchstart', '.checkbox', function() {
92 rightBtnText: '确定' 81 rightBtnText: '确定'
93 } 82 }
94 }, function() { 83 }, function() {
95 - var id = $this.closest('.shopping-cart-good').data('id');  
96 - var count = $this.data('count'); 84 + var id = $this.closest('.shopping-cart-good').data('id'),
  85 + count = $this.data('count');
97 86
98 $.ajax({ 87 $.ajax({
99 method: 'post', 88 method: 'post',
@@ -119,7 +108,6 @@ $('.cart-goods').on('touchstart', '.checkbox', function() { @@ -119,7 +108,6 @@ $('.cart-goods').on('touchstart', '.checkbox', function() {
119 tip.show('网络异常'); 108 tip.show('网络异常');
120 }); 109 });
121 }); 110 });
122 -  
123 }); 111 });
124 112
125 function requestUpdateAllGoodsCheckStatus(theGoods, successHandeler) { 113 function requestUpdateAllGoodsCheckStatus(theGoods, successHandeler) {
@@ -140,7 +128,7 @@ function requestUpdateAllGoodsCheckStatus(theGoods, successHandeler) { @@ -140,7 +128,7 @@ function requestUpdateAllGoodsCheckStatus(theGoods, successHandeler) {
140 tip.show(res.message); 128 tip.show(res.message);
141 } 129 }
142 }, 130 },
143 - error: function(err) { 131 + error: function() {
144 tip.show('网络异常'); 132 tip.show('网络异常');
145 }, 133 },
146 complete: function() { 134 complete: function() {
@@ -196,26 +184,9 @@ function bottomCheckBoxHandeler(isSelected, type, handlerAfterTouch) { @@ -196,26 +184,9 @@ function bottomCheckBoxHandeler(isSelected, type, handlerAfterTouch) {
196 requestUpdateAllGoodsCheckStatus(goodsList, handlerAfterTouch); 184 requestUpdateAllGoodsCheckStatus(goodsList, handlerAfterTouch);
197 } 185 }
198 186
199 -  
200 -  
201 -//是否要全选  
202 -function willBeSelected($this) {  
203 - var isSelected = true;  
204 -  
205 - if ($this.hasClass('icon-cb-checked')) {  
206 - isSelected = true;  
207 - } else {  
208 - isSelected = false;  
209 - }  
210 -  
211 - return isSelected;  
212 -}  
213 -  
214 //全选按钮点击事件 187 //全选按钮点击事件
215 $selectAllBtn.on('touchend', function() { 188 $selectAllBtn.on('touchend', function() {
216 - var $this = $(this);  
217 -  
218 - bottomCheckBoxHandeler(willBeSelected($this), cartType, didUpdateAllGoodsCheckStatus); 189 + bottomCheckBoxHandeler($(this).hasClass('icon-cb-checked'), cartType, didUpdateAllGoodsCheckStatus);
219 }); 190 });
220 191
221 $('.down').on('touchend', function() { 192 $('.down').on('touchend', function() {