购物车功能修改 code review by bikai
Showing
1 changed file
with
8 additions
and
8 deletions
@@ -20,9 +20,7 @@ var panelTmpl, | @@ -20,9 +20,7 @@ var panelTmpl, | ||
20 | $chosed, | 20 | $chosed, |
21 | re = /\d+/, | 21 | re = /\d+/, |
22 | leftNum, | 22 | leftNum, |
23 | - $colorList, | ||
24 | $sizeList, | 23 | $sizeList, |
25 | - firstColorId, | ||
26 | colorIndex, | 24 | colorIndex, |
27 | confirming, | 25 | confirming, |
28 | hasChooseColor = false, | 26 | hasChooseColor = false, |
@@ -45,6 +43,7 @@ $.get('/cart/index/giftinfoTpl', function(html) { | @@ -45,6 +43,7 @@ $.get('/cart/index/giftinfoTpl', function(html) { | ||
45 | 43 | ||
46 | //初始化购物车面板显示 | 44 | //初始化购物车面板显示 |
47 | function init() { | 45 | function init() { |
46 | + | ||
48 | //$colorList = $('.chose-panel .color-list ul>li'); | 47 | //$colorList = $('.chose-panel .color-list ul>li'); |
49 | //$sizeList = $('.chose-panel .size-list ul>li'); | 48 | //$sizeList = $('.chose-panel .size-list ul>li'); |
50 | //firstColorId = $colorList.eq(0).data('id'); | 49 | //firstColorId = $colorList.eq(0).data('id'); |
@@ -55,8 +54,10 @@ function init() { | @@ -55,8 +54,10 @@ function init() { | ||
55 | // $(this).removeClass('hide'); | 54 | // $(this).removeClass('hide'); |
56 | // } | 55 | // } |
57 | //}); | 56 | //}); |
57 | + | ||
58 | var $firstRow = $sizeRowList.eq(0); | 58 | var $firstRow = $sizeRowList.eq(0); |
59 | - //$firstRow.toggleClass('hide'); | 59 | + |
60 | + $firstRow.toggleClass('hide'); | ||
60 | $curSizeRow = $firstRow; | 61 | $curSizeRow = $firstRow; |
61 | } | 62 | } |
62 | 63 | ||
@@ -100,6 +101,8 @@ $('.color-list').on('touchstart', '.block', function(e) { | @@ -100,6 +101,8 @@ $('.color-list').on('touchstart', '.block', function(e) { | ||
100 | numArray, | 101 | numArray, |
101 | index, | 102 | index, |
102 | curSelectedSizeBlock, | 103 | curSelectedSizeBlock, |
104 | + $sizeChosed, | ||
105 | + scindex, | ||
103 | i; | 106 | i; |
104 | 107 | ||
105 | var $siblingBlock = $this.closest('.block-list').siblings(':first'), | 108 | var $siblingBlock = $this.closest('.block-list').siblings(':first'), |
@@ -108,8 +111,8 @@ $('.color-list').on('touchstart', '.block', function(e) { | @@ -108,8 +111,8 @@ $('.color-list').on('touchstart', '.block', function(e) { | ||
108 | $this.siblings('.chosed').removeClass('chosed'); | 111 | $this.siblings('.chosed').removeClass('chosed'); |
109 | index = $this.index(); | 112 | index = $this.index(); |
110 | 113 | ||
111 | - var $sizeChosed = $siblingBlock.find('.chosed'); | ||
112 | - var scindex = $sizeChosed.index(); | 114 | + $sizeChosed = $siblingBlock.find('.chosed'); |
115 | + scindex = $sizeChosed.index(); | ||
113 | $curSizeRow = $sizeRowList.eq(index); | 116 | $curSizeRow = $sizeRowList.eq(index); |
114 | 117 | ||
115 | // 当前颜色已经是选中状态,再点击时 | 118 | // 当前颜色已经是选中状态,再点击时 |
@@ -163,8 +166,6 @@ $('.color-list').on('touchstart', '.block', function(e) { | @@ -163,8 +166,6 @@ $('.color-list').on('touchstart', '.block', function(e) { | ||
163 | } | 166 | } |
164 | }); | 167 | }); |
165 | } else if ($chosed.length === 1 && $this.hasClass('chosed')) { | 168 | } else if ($chosed.length === 1 && $this.hasClass('chosed')) { |
166 | - //if ($this.closest('.block-list').hasClass('color-list')) { | ||
167 | - | ||
168 | $sizeList.addClass('hide'); | 169 | $sizeList.addClass('hide'); |
169 | 170 | ||
170 | //切换尺码信息 | 171 | //切换尺码信息 |
@@ -174,7 +175,6 @@ $('.color-list').on('touchstart', '.block', function(e) { | @@ -174,7 +175,6 @@ $('.color-list').on('touchstart', '.block', function(e) { | ||
174 | $(this).removeClass('hide'); | 175 | $(this).removeClass('hide'); |
175 | } | 176 | } |
176 | }); | 177 | }); |
177 | - //} | ||
178 | 178 | ||
179 | numArray = ($chosed.data('numstr') + '').split('/'); | 179 | numArray = ($chosed.data('numstr') + '').split('/'); |
180 | $siblingBlock.find('.block').removeClass('zero-stock'); | 180 | $siblingBlock.find('.block').removeClass('zero-stock'); |
-
Please register or login to post a comment