Showing
1 changed file
with
24 additions
and
30 deletions
@@ -118,6 +118,26 @@ function updateConformButtonClassAndText() { | @@ -118,6 +118,26 @@ function updateConformButtonClassAndText() { | ||
118 | } | 118 | } |
119 | } | 119 | } |
120 | 120 | ||
121 | +//显示剩余件数 | ||
122 | +function displayGoodNum(curGoodNum) { | ||
123 | + | ||
124 | + //数量大于0 | ||
125 | + if (curGoodNum > 0) { | ||
126 | + if ($soonSoldOut.length > 0) { | ||
127 | + $allChoseItems.find('.num .left-num').html('即将售罄'); | ||
128 | + } else { | ||
129 | + $allChoseItems.find('.num .left-num').html('剩余' + curGoodNum + '件'); | ||
130 | + } | ||
131 | + | ||
132 | + $leftNum.val(curGoodNum); | ||
133 | + | ||
134 | + //数量小于0 | ||
135 | + } else { | ||
136 | + $allChoseItems.find('.num .left-num').html(''); | ||
137 | + $leftNum.val(0); | ||
138 | + } | ||
139 | +} | ||
140 | + | ||
121 | init(); | 141 | init(); |
122 | 142 | ||
123 | $yohoPage.on('touchstart', '.chose-panel', function(e) { | 143 | $yohoPage.on('touchstart', '.chose-panel', function(e) { |
@@ -187,22 +207,10 @@ $yohoPage.on('touchstart', '.color-list .block', function() { | @@ -187,22 +207,10 @@ $yohoPage.on('touchstart', '.color-list .block', function() { | ||
187 | $curSizeBlock.addClass('chosed'); | 207 | $curSizeBlock.addClass('chosed'); |
188 | } | 208 | } |
189 | 209 | ||
190 | - //数量大于0 | ||
191 | - if (curGoodNum > 0) { | ||
192 | - if ($soonSoldOut.length > 0) { | ||
193 | - $allChoseItems.find('.num .left-num').html('即将售罄'); | ||
194 | - } else { | ||
195 | - $allChoseItems.find('.num .left-num').html('剩余' + curGoodNum + '件'); | ||
196 | } | 210 | } |
197 | 211 | ||
198 | - $leftNum.val(curGoodNum); | ||
199 | - | ||
200 | - //数量小于0 | ||
201 | - } else { | ||
202 | - $allChoseItems.find('.num .left-num').html(''); | ||
203 | - $leftNum.val(0); | ||
204 | - } | ||
205 | - } | 212 | + // 显示剩余数量 |
213 | + displayGoodNum(curGoodNum); | ||
206 | 214 | ||
207 | // 尺码行当前行隐藏 | 215 | // 尺码行当前行隐藏 |
208 | $sizeRowList.eq(curSizeIndex).removeClass('show').addClass('hide'); | 216 | $sizeRowList.eq(curSizeIndex).removeClass('show').addClass('hide'); |
@@ -271,29 +279,15 @@ $yohoPage.on('touchstart', '.color-list .block', function() { | @@ -271,29 +279,15 @@ $yohoPage.on('touchstart', '.color-list .block', function() { | ||
271 | // 之前选中的颜色去掉勾选样式,新颜色块勾选 | 279 | // 之前选中的颜色去掉勾选样式,新颜色块勾选 |
272 | if ($curColorBlock && $curColorBlock.length > 0) { | 280 | if ($curColorBlock && $curColorBlock.length > 0) { |
273 | $curColorBlock.removeClass('chosed'); | 281 | $curColorBlock.removeClass('chosed'); |
274 | - | ||
275 | - //curColorBlock = $colorRowList.eq(curColorIndex + 1).children().get(curSizeIndex - 1); | ||
276 | curColorBlock = $colorRowList.eq(index + 1).children().get(curSizeIndex - 1); | 282 | curColorBlock = $colorRowList.eq(index + 1).children().get(curSizeIndex - 1); |
277 | $curColorBlock = $(curColorBlock); | 283 | $curColorBlock = $(curColorBlock); |
278 | curGoodNum = $curColorBlock.data('num'); | 284 | curGoodNum = $curColorBlock.data('num'); |
279 | $curColorBlock.addClass('chosed'); | 285 | $curColorBlock.addClass('chosed'); |
280 | } | 286 | } |
281 | - | ||
282 | - //数量大于0 | ||
283 | - if (curGoodNum > 0) { | ||
284 | - if ($soonSoldOut.length > 0) { | ||
285 | - $allChoseItems.find('.num .left-num').html('即将售罄'); | ||
286 | - } else { | ||
287 | - $allChoseItems.find('.num .left-num').html('剩余' + curGoodNum + '件'); | ||
288 | } | 287 | } |
289 | - $leftNum.val(curGoodNum); | ||
290 | 288 | ||
291 | - //数量小于0 | ||
292 | - } else { | ||
293 | - $allChoseItems.find('.num .left-num').html(''); | ||
294 | - $leftNum.val(0); | ||
295 | - } | ||
296 | - } | 289 | + // 显示剩余数量 |
290 | + displayGoodNum(curGoodNum); | ||
297 | 291 | ||
298 | // 颜色当前行隐藏 | 292 | // 颜色当前行隐藏 |
299 | $colorRowList.eq(curColorIndex).removeClass('show').addClass('hide'); | 293 | $colorRowList.eq(curColorIndex).removeClass('show').addClass('hide'); |
-
Please register or login to post a comment