Authored by Lynnic

购物车逻辑修改

@@ -17,14 +17,15 @@ var $num, @@ -17,14 +17,15 @@ var $num,
17 leftNum, 17 leftNum,
18 $colorList = $('.color-list ul>li'), 18 $colorList = $('.color-list ul>li'),
19 $sizeList = $('.size-list ul>li'), 19 $sizeList = $('.size-list ul>li'),
20 - firstColorId = $colorList.eq(0).data('id'); 20 + firstColorId = $colorList.eq(0).data('id'),
  21 + colorIndex;
21 22
22 //初始化购物车面板显示 23 //初始化购物车面板显示
23 $sizeList.each(function() { 24 $sizeList.each(function() {
24 - var id = $(this).data('colorid'); 25 + colorIndex = $(this).data('colorid');
25 26
26 27
27 - if (id === firstColorId) { 28 + if (colorIndex === firstColorId) {
28 $(this).removeClass('hide'); 29 $(this).removeClass('hide');
29 } 30 }
30 }); 31 });
@@ -149,6 +150,19 @@ $('.yoho-page').on('touchstart', '.chose-panel', function(e) { @@ -149,6 +150,19 @@ $('.yoho-page').on('touchstart', '.chose-panel', function(e) {
149 } 150 }
150 }); 151 });
151 } else if ($chosed.length === 1 && $this.hasClass('chosed')) { 152 } else if ($chosed.length === 1 && $this.hasClass('chosed')) {
  153 + if ($this.closest('.block-list').hasClass('color-list')) {
  154 +
  155 + $sizeList.addClass('hide');
  156 +
  157 + //切换尺码信息
  158 + $sizeList.each(function() {
  159 + colorIndex = $(this).data('colorid');
  160 + if (colorIndex === $this.data('id')) {
  161 + $(this).removeClass('hide');
  162 + }
  163 + });
  164 + }
  165 +
152 numArray = $chosed.data('numstr').split('/'); 166 numArray = $chosed.data('numstr').split('/');
153 $siblingBlock.find('.block').removeClass('zero-stock'); 167 $siblingBlock.find('.block').removeClass('zero-stock');
154 for (i = 0; i < numArray.length; i++) { 168 for (i = 0; i < numArray.length; i++) {