Authored by 梁志锋

购物车尺码颜色选择

@@ -98,7 +98,7 @@ function hide() { @@ -98,7 +98,7 @@ function hide() {
98 $('body').css('overflow', 'auto'); 98 $('body').css('overflow', 'auto');
99 } 99 }
100 100
101 -$('.yoho-page').on('touchstart', '.infos', function(e) { 101 +$('.yoho-page').on('touchstart', '.chose-panel', function(e) {
102 var $cur = $(e.target); 102 var $cur = $(e.target);
103 103
104 if ($cur.closest('.main').length > 0) { 104 if ($cur.closest('.main').length > 0) {
@@ -132,6 +132,7 @@ $('.color-list').on('touchstart', '.block', function(e) { @@ -132,6 +132,7 @@ $('.color-list').on('touchstart', '.block', function(e) {
132 132
133 //颜色原来已经是勾选时,要清空剩余件数的提示 133 //颜色原来已经是勾选时,要清空剩余件数的提示
134 $that.find('.num .left-num').html(''); 134 $that.find('.num .left-num').html('');
  135 + $('#left-num').val(0);
135 hasChooseColor = false; 136 hasChooseColor = false;
136 137
137 // 当前颜色不是选中状态,选中时 138 // 当前颜色不是选中状态,选中时
@@ -161,9 +162,11 @@ $('.color-list').on('touchstart', '.block', function(e) { @@ -161,9 +162,11 @@ $('.color-list').on('touchstart', '.block', function(e) {
161 //如果当前有尺码被选中,且数量等于0,则颜色块添加数量为0的样式 162 //如果当前有尺码被选中,且数量等于0,则颜色块添加数量为0的样式
162 if (curGoodNum > 0) { 163 if (curGoodNum > 0) {
163 $that.find('.num .left-num').html('剩余' + curGoodNum + '件'); 164 $that.find('.num .left-num').html('剩余' + curGoodNum + '件');
  165 + $('#left-num').val(curGoodNum);
164 } else { 166 } else {
165 $(curSelectedSizeBlock).removeClass('zero-stock').addClass('zero-stock'); 167 $(curSelectedSizeBlock).removeClass('zero-stock').addClass('zero-stock');
166 $that.find('.num .left-num').html(''); 168 $that.find('.num .left-num').html('');
  169 + $('#left-num').val(0);
167 } 170 }
168 } 171 }
169 } 172 }
@@ -250,7 +253,6 @@ $('.size-list').on('touchstart', '.block', function(e) { @@ -250,7 +253,6 @@ $('.size-list').on('touchstart', '.block', function(e) {
250 $that = $(e.target).closest('.chose-items'), 253 $that = $(e.target).closest('.chose-items'),
251 index, 254 index,
252 $colorChosed, 255 $colorChosed,
253 - selectedColorindex,  
254 curGoodNum; 256 curGoodNum;
255 257
256 var $siblingBlock = $this.closest('.block-list').siblings(':first'); 258 var $siblingBlock = $this.closest('.block-list').siblings(':first');
@@ -259,7 +261,6 @@ $('.size-list').on('touchstart', '.block', function(e) { @@ -259,7 +261,6 @@ $('.size-list').on('touchstart', '.block', function(e) {
259 index = $this.index(); 261 index = $this.index();
260 262
261 $colorChosed = $siblingBlock.find('.chosed'); 263 $colorChosed = $siblingBlock.find('.chosed');
262 - selectedColorindex = $colorChosed.index();  
263 $curSizeRow = $sizeRowList.eq(index); 264 $curSizeRow = $sizeRowList.eq(index);
264 265
265 // 当前尺码已经是选中状态,再点击时 266 // 当前尺码已经是选中状态,再点击时
@@ -267,6 +268,7 @@ $('.size-list').on('touchstart', '.block', function(e) { @@ -267,6 +268,7 @@ $('.size-list').on('touchstart', '.block', function(e) {
267 268
268 //尺码原来已经是勾选时,要清空剩余件数的提示 269 //尺码原来已经是勾选时,要清空剩余件数的提示
269 $that.find('.num .left-num').html(''); 270 $that.find('.num .left-num').html('');
  271 + $('#left-num').val(0);
270 hasChooseSize = false; 272 hasChooseSize = false;
271 273
272 // 去掉已经选中颜色的 数量为0的样式 274 // 去掉已经选中颜色的 数量为0的样式
@@ -288,9 +290,11 @@ $('.size-list').on('touchstart', '.block', function(e) { @@ -288,9 +290,11 @@ $('.size-list').on('touchstart', '.block', function(e) {
288 // 如果当前有尺码被选中,且数量等于0,则颜色块添加数量为0的样式, 否则显示剩余件数 290 // 如果当前有尺码被选中,且数量等于0,则颜色块添加数量为0的样式, 否则显示剩余件数
289 if (curGoodNum > 0 && hasChooseColor) { 291 if (curGoodNum > 0 && hasChooseColor) {
290 $that.find('.num .left-num').html('剩余' + curGoodNum + '件'); 292 $that.find('.num .left-num').html('剩余' + curGoodNum + '件');
  293 + $('#left-num').val(curGoodNum);
291 } else { 294 } else {
292 $colorChosed.removeClass('zero-stock').addClass('zero-stock'); 295 $colorChosed.removeClass('zero-stock').addClass('zero-stock');
293 $that.find('.num .left-num').html(''); 296 $that.find('.num .left-num').html('');
  297 + $('#left-num').val(0);
294 } 298 }
295 } 299 }
296 300
@@ -375,8 +379,9 @@ $('.size-list').on('touchstart', '.block', function(e) { @@ -375,8 +379,9 @@ $('.size-list').on('touchstart', '.block', function(e) {
375 }); 379 });
376 380
377 $('.btn-minus').on('touchstart', function() { 381 $('.btn-minus').on('touchstart', function() {
378 - var num = $num.val(),  
379 - leftNum = re.exec($('.num .left-num').html()); 382 + var num = $num.val();
  383 +
  384 + leftNum = $('#left-num').val();
380 385
381 if (!checkColorSizeNum()) { 386 if (!checkColorSizeNum()) {
382 return; 387 return;
@@ -392,12 +397,14 @@ $('.btn-minus').on('touchstart', function() { @@ -392,12 +397,14 @@ $('.btn-minus').on('touchstart', function() {
392 $('.btn-plus').on('touchstart', function() { 397 $('.btn-plus').on('touchstart', function() {
393 var num = $num.val(); 398 var num = $num.val();
394 399
  400 + leftNum = $('#left-num').val();
  401 +
395 if (!checkColorSizeNum()) { 402 if (!checkColorSizeNum()) {
396 return; 403 return;
397 } 404 }
398 405
399 - leftNum = re.exec($('.num .left-num').html());  
400 - if (num - 0 === leftNum - 0 || 0 === leftNum - 0) { 406 +
  407 + if (num - 0 === leftNum || 0 === leftNum) {
401 return; 408 return;
402 } 409 }
403 410
@@ -405,7 +412,7 @@ $('.btn-plus').on('touchstart', function() { @@ -405,7 +412,7 @@ $('.btn-plus').on('touchstart', function() {
405 $num.val(num + 1); 412 $num.val(num + 1);
406 }); 413 });
407 414
408 -$('#chose-btn-sure').on('touchend', function() { 415 +$('#chose-btn-sure').on('touchstart', function() {
409 416
410 var productSku, 417 var productSku,
411 buyNumber = $('#good-num').val() - 0, 418 buyNumber = $('#good-num').val() - 0,
@@ -419,7 +426,11 @@ $('#chose-btn-sure').on('touchend', function() { @@ -419,7 +426,11 @@ $('#chose-btn-sure').on('touchend', function() {
419 return; 426 return;
420 } 427 }
421 428
422 - leftNum = re.exec($('.num .left-num').html()); 429 + if ($('#chose-btn-sure').html() === '已售罄') {
  430 + return;
  431 + }
  432 +
  433 + leftNum = $('#left-num').val();;
423 434
424 if (num > leftNum) { 435 if (num > leftNum) {
425 tip.show('您选择的数量超过了最大库存量~'); 436 tip.show('您选择的数量超过了最大库存量~');
@@ -429,7 +440,7 @@ $('#chose-btn-sure').on('touchend', function() { @@ -429,7 +440,7 @@ $('#chose-btn-sure').on('touchend', function() {
429 $chosed = $('.block-list>ul>li.chosed'); 440 $chosed = $('.block-list>ul>li.chosed');
430 441
431 if (2 === $chosed.length && 0 === $chosed.closest('.zero-stock').length) { 442 if (2 === $chosed.length && 0 === $chosed.closest('.zero-stock').length) {
432 - productSku = $sizeList.closest('.chosed').data('skuid'); 443 + productSku = $curSizeBlock.data('skuid');
433 promotionId = $('[data-id="' + productSku + '"]').closest('.advance-block').data('promotion-id'); 444 promotionId = $('[data-id="' + productSku + '"]').closest('.advance-block').data('promotion-id');
434 if (confirming) { 445 if (confirming) {
435 return false; 446 return false;