Showing
1 changed file
with
30 additions
and
25 deletions
@@ -22,14 +22,13 @@ var panelTmpl, | @@ -22,14 +22,13 @@ var panelTmpl, | ||
22 | // re = /\d+/, | 22 | // re = /\d+/, |
23 | leftNum, | 23 | leftNum, |
24 | confirming, | 24 | confirming, |
25 | - hasChooseColor = false, | ||
26 | - hasChooseSize = false, | 25 | + hasChooseColor, |
26 | + hasChooseSize, | ||
27 | curColorIndex, | 27 | curColorIndex, |
28 | curSizeIndex, | 28 | curSizeIndex, |
29 | $curSizeRow, | 29 | $curSizeRow, |
30 | - $curSizeBlock = null, | ||
31 | - firstColorId, | ||
32 | - $sizeRowList = $('.size-list ul'); | 30 | + $curSizeBlock, |
31 | + $sizeRowList; | ||
33 | 32 | ||
34 | // 读取模板 | 33 | // 读取模板 |
35 | $.get('/cart/index/giftinfoTpl', function(html) { | 34 | $.get('/cart/index/giftinfoTpl', function(html) { |
@@ -46,6 +45,11 @@ $.get('/cart/index/giftinfoTpl', function(html) { | @@ -46,6 +45,11 @@ $.get('/cart/index/giftinfoTpl', function(html) { | ||
46 | function init() { | 45 | function init() { |
47 | var $firstRow = $sizeRowList.eq(0); | 46 | var $firstRow = $sizeRowList.eq(0); |
48 | 47 | ||
48 | + $sizeRowList = $('.size-list ul'); | ||
49 | + $curSizeBlock = null, | ||
50 | + | ||
51 | + hasChooseSize = false, | ||
52 | + hasChooseColor = false, | ||
49 | $firstRow.toggleClass('hide'); | 53 | $firstRow.toggleClass('hide'); |
50 | $curSizeRow = $firstRow; | 54 | $curSizeRow = $firstRow; |
51 | } | 55 | } |
@@ -76,7 +80,7 @@ function show(data) { | @@ -76,7 +80,7 @@ function show(data) { | ||
76 | $('body').css('overflow', 'hidden'); | 80 | $('body').css('overflow', 'hidden'); |
77 | $num = $('#good-num'); | 81 | $num = $('#good-num'); |
78 | } | 82 | } |
79 | - | 83 | + |
80 | //隐藏当前Panel | 84 | //隐藏当前Panel |
81 | function hide() { | 85 | function hide() { |
82 | $('.chose-panel').hide(); | 86 | $('.chose-panel').hide(); |
@@ -97,23 +101,24 @@ function updateConformButtonClassAndText() { | @@ -97,23 +101,24 @@ function updateConformButtonClassAndText() { | ||
97 | 101 | ||
98 | //重置颜色块的库存为0的样式 | 102 | //重置颜色块的库存为0的样式 |
99 | function resetColorZeroStock($siblingBlock) { | 103 | function resetColorZeroStock($siblingBlock) { |
100 | - | ||
101 | - var numArray = ($curSizeBlock.data('numstr') + '').split('/'); | ||
102 | - if (!hasChooseSize) { | ||
103 | - $siblingBlock.find('ul>li').each(function() { | ||
104 | - $(this).removeClass('zero-stock'); | ||
105 | - if ('0' === $(this).data('num')) { | ||
106 | - $(this).addClass('zero-stock'); | ||
107 | - } | ||
108 | - }); | ||
109 | - | ||
110 | - } else { | ||
111 | - for (var i = 0; i < numArray.length; i++) { | ||
112 | - if ('0' === numArray[i]) { | ||
113 | - $siblingBlock.find('.block').eq(i).addClass('zero-stock'); | ||
114 | - } | ||
115 | - } | 104 | + var numArray = ($curSizeBlock.data('numstr') + '').split('/'), |
105 | + i; | ||
106 | + | ||
107 | + if (!hasChooseSize) { | ||
108 | + $siblingBlock.find('ul>li').each(function() { | ||
109 | + $(this).removeClass('zero-stock'); | ||
110 | + if ('0' === $(this).data('num')) { | ||
111 | + $(this).addClass('zero-stock'); | ||
116 | } | 112 | } |
113 | + }); | ||
114 | + | ||
115 | + } else { | ||
116 | + for (i = 0; i < numArray.length; i++) { | ||
117 | + if ('0' === numArray[i]) { | ||
118 | + $siblingBlock.find('.block').eq(i).addClass('zero-stock'); | ||
119 | + } | ||
120 | + } | ||
121 | + } | ||
117 | } | 122 | } |
118 | 123 | ||
119 | // 选择了颜色切换商品图片 | 124 | // 选择了颜色切换商品图片 |
@@ -198,21 +203,21 @@ $('.color-list').on('touchstart', '.block', function(e) { | @@ -198,21 +203,21 @@ $('.color-list').on('touchstart', '.block', function(e) { | ||
198 | // 设置按钮的样式和文字 | 203 | // 设置按钮的样式和文字 |
199 | updateConformButtonClassAndText(); | 204 | updateConformButtonClassAndText(); |
200 | 205 | ||
206 | + // 修改颜色时修改商品图片 | ||
207 | + changeGoodImgWhenClickColor(); | ||
208 | + | ||
201 | }); | 209 | }); |
202 | 210 | ||
203 | $('.size-list').on('touchstart', '.block', function(e) { | 211 | $('.size-list').on('touchstart', '.block', function(e) { |
204 | var $this = $(this), | 212 | var $this = $(this), |
205 | $that = $(e.target).closest('.chose-items'), | 213 | $that = $(e.target).closest('.chose-items'), |
206 | index, | 214 | index, |
207 | - $colorChosed, | ||
208 | curGoodNum; | 215 | curGoodNum; |
209 | 216 | ||
210 | var $siblingBlock = $this.closest('.block-list').siblings(':first'); | 217 | var $siblingBlock = $this.closest('.block-list').siblings(':first'); |
211 | 218 | ||
212 | $this.siblings('.chosed').removeClass('chosed'); | 219 | $this.siblings('.chosed').removeClass('chosed'); |
213 | index = $this.index(); | 220 | index = $this.index(); |
214 | - | ||
215 | - //$colorChosed = $siblingBlock.find('.chosed'); | ||
216 | $curSizeRow = $sizeRowList.eq(index); | 221 | $curSizeRow = $sizeRowList.eq(index); |
217 | 222 | ||
218 | // 当前尺码已经是选中状态,再点击时 | 223 | // 当前尺码已经是选中状态,再点击时 |
-
Please register or login to post a comment