Authored by hf

Merge branch 'develop' of http://git.dev.yoho.cn/web/yohobuy into develop

@@ -18,9 +18,9 @@ var panelTmpl, @@ -18,9 +18,9 @@ var panelTmpl,
18 $chosePanel = $('#chose-panel'), 18 $chosePanel = $('#chose-panel'),
19 $num, 19 $num,
20 $chosed, 20 $chosed,
21 - re = /\d+/, 21 +
  22 + // re = /\d+/,
22 leftNum, 23 leftNum,
23 - $sizeList,  
24 confirming, 24 confirming,
25 hasChooseColor = false, 25 hasChooseColor = false,
26 hasChooseSize = false, 26 hasChooseSize = false,
@@ -61,6 +61,20 @@ function init() { @@ -61,6 +61,20 @@ function init() {
61 $curSizeRow = $firstRow; 61 $curSizeRow = $firstRow;
62 } 62 }
63 63
  64 +function checkColorSizeNum() {
  65 + if (!hasChooseColor && !hasChooseSize) {
  66 + tip.show('请选择颜色和尺码~');
  67 + return false;
  68 + } else if (!hasChooseColor) {
  69 + tip.show('请选择颜色~');
  70 + return false;
  71 + } else if (!hasChooseSize) {
  72 + tip.show('请选择尺码~');
  73 + return false;
  74 + }
  75 + return true;
  76 +}
  77 +
64 init(); 78 init();
65 79
66 function show(data) { 80 function show(data) {
@@ -118,6 +132,7 @@ $('.color-list').on('touchstart', '.block', function(e) { @@ -118,6 +132,7 @@ $('.color-list').on('touchstart', '.block', function(e) {
118 132
119 //颜色原来已经是勾选时,要清空剩余件数的提示 133 //颜色原来已经是勾选时,要清空剩余件数的提示
120 $that.find('.num .left-num').html(''); 134 $that.find('.num .left-num').html('');
  135 + $('#left-num').val(0);
121 hasChooseColor = false; 136 hasChooseColor = false;
122 137
123 // 当前颜色不是选中状态,选中时 138 // 当前颜色不是选中状态,选中时
@@ -131,15 +146,15 @@ $('.color-list').on('touchstart', '.block', function(e) { @@ -131,15 +146,15 @@ $('.color-list').on('touchstart', '.block', function(e) {
131 146
132 //把当前选中颜色对应的尺码那一行显示出来 147 //把当前选中颜色对应的尺码那一行显示出来
133 $sizeRowList.addClass('hide'); 148 $sizeRowList.addClass('hide');
134 - $curSizeRow.toggleClass('hide'); 149 + $curSizeRow.removeClass('hide').addClass('show');
135 150
136 // 之前选中的尺码去掉勾选样式 151 // 之前选中的尺码去掉勾选样式
137 - if ($sizeChosed) { 152 + if ($sizeChosed.length > 0) {
138 $sizeChosed.removeClass('chosed'); 153 $sizeChosed.removeClass('chosed');
  154 + curSelectedSizeBlock = $curSizeRow.children().get(scindex);
139 } 155 }
140 156
141 // 当前选中颜色对应的尺码行,其对应的尺码加上勾选样式 (前提是要判断下这个尺码是否存在) 157 // 当前选中颜色对应的尺码行,其对应的尺码加上勾选样式 (前提是要判断下这个尺码是否存在)
142 - curSelectedSizeBlock = $curSizeRow.children().get(scindex);  
143 if (curSelectedSizeBlock) { 158 if (curSelectedSizeBlock) {
144 curGoodNum = $(curSelectedSizeBlock).data('num'); 159 curGoodNum = $(curSelectedSizeBlock).data('num');
145 $(curSelectedSizeBlock).addClass('chosed'); 160 $(curSelectedSizeBlock).addClass('chosed');
@@ -147,9 +162,11 @@ $('.color-list').on('touchstart', '.block', function(e) { @@ -147,9 +162,11 @@ $('.color-list').on('touchstart', '.block', function(e) {
147 //如果当前有尺码被选中,且数量等于0,则颜色块添加数量为0的样式 162 //如果当前有尺码被选中,且数量等于0,则颜色块添加数量为0的样式
148 if (curGoodNum > 0) { 163 if (curGoodNum > 0) {
149 $that.find('.num .left-num').html('剩余' + curGoodNum + '件'); 164 $that.find('.num .left-num').html('剩余' + curGoodNum + '件');
  165 + $('#left-num').val(curGoodNum);
150 } else { 166 } else {
151 $(curSelectedSizeBlock).removeClass('zero-stock').addClass('zero-stock'); 167 $(curSelectedSizeBlock).removeClass('zero-stock').addClass('zero-stock');
152 $that.find('.num .left-num').html(''); 168 $that.find('.num .left-num').html('');
  169 + $('#left-num').val(0);
153 } 170 }
154 } 171 }
155 } 172 }
@@ -236,7 +253,6 @@ $('.size-list').on('touchstart', '.block', function(e) { @@ -236,7 +253,6 @@ $('.size-list').on('touchstart', '.block', function(e) {
236 $that = $(e.target).closest('.chose-items'), 253 $that = $(e.target).closest('.chose-items'),
237 index, 254 index,
238 $colorChosed, 255 $colorChosed,
239 - selectedColorindex,  
240 curGoodNum; 256 curGoodNum;
241 257
242 var $siblingBlock = $this.closest('.block-list').siblings(':first'); 258 var $siblingBlock = $this.closest('.block-list').siblings(':first');
@@ -245,7 +261,6 @@ $('.size-list').on('touchstart', '.block', function(e) { @@ -245,7 +261,6 @@ $('.size-list').on('touchstart', '.block', function(e) {
245 index = $this.index(); 261 index = $this.index();
246 262
247 $colorChosed = $siblingBlock.find('.chosed'); 263 $colorChosed = $siblingBlock.find('.chosed');
248 - selectedColorindex = $colorChosed.index();  
249 $curSizeRow = $sizeRowList.eq(index); 264 $curSizeRow = $sizeRowList.eq(index);
250 265
251 // 当前尺码已经是选中状态,再点击时 266 // 当前尺码已经是选中状态,再点击时
@@ -253,10 +268,11 @@ $('.size-list').on('touchstart', '.block', function(e) { @@ -253,10 +268,11 @@ $('.size-list').on('touchstart', '.block', function(e) {
253 268
254 //尺码原来已经是勾选时,要清空剩余件数的提示 269 //尺码原来已经是勾选时,要清空剩余件数的提示
255 $that.find('.num .left-num').html(''); 270 $that.find('.num .left-num').html('');
  271 + $('#left-num').val(0);
256 hasChooseSize = false; 272 hasChooseSize = false;
257 273
258 // 去掉已经选中颜色的 数量为0的样式 274 // 去掉已经选中颜色的 数量为0的样式
259 - if ($colorChosed) { 275 + if ($colorChosed.length > 0) {
260 $colorChosed.removeClass('zero-stock').addClass('zero-stock'); 276 $colorChosed.removeClass('zero-stock').addClass('zero-stock');
261 } 277 }
262 278
@@ -272,11 +288,13 @@ $('.size-list').on('touchstart', '.block', function(e) { @@ -272,11 +288,13 @@ $('.size-list').on('touchstart', '.block', function(e) {
272 } 288 }
273 289
274 // 如果当前有尺码被选中,且数量等于0,则颜色块添加数量为0的样式, 否则显示剩余件数 290 // 如果当前有尺码被选中,且数量等于0,则颜色块添加数量为0的样式, 否则显示剩余件数
275 - if (curGoodNum > 0) { 291 + if (curGoodNum > 0 && hasChooseColor) {
276 $that.find('.num .left-num').html('剩余' + curGoodNum + '件'); 292 $that.find('.num .left-num').html('剩余' + curGoodNum + '件');
  293 + $('#left-num').val(curGoodNum);
277 } else { 294 } else {
278 $colorChosed.removeClass('zero-stock').addClass('zero-stock'); 295 $colorChosed.removeClass('zero-stock').addClass('zero-stock');
279 $that.find('.num .left-num').html(''); 296 $that.find('.num .left-num').html('');
  297 + $('#left-num').val(0);
280 } 298 }
281 } 299 }
282 300
@@ -361,12 +379,11 @@ $('.size-list').on('touchstart', '.block', function(e) { @@ -361,12 +379,11 @@ $('.size-list').on('touchstart', '.block', function(e) {
361 }); 379 });
362 380
363 $('.btn-minus').on('touchstart', function() { 381 $('.btn-minus').on('touchstart', function() {
364 - var num = $num.val(),  
365 - $chosed = $('.block-list>ul>li.chosed'),  
366 - leftNum = re.exec($('.num .left-num').html()); 382 + var num = $num.val();
  383 +
  384 + leftNum = $('#left-num').val();
367 385
368 - //若颜色和尺码没有被同时选中,则不能点击  
369 - if ($chosed.length < 2) { 386 + if (!checkColorSizeNum()) {
370 return; 387 return;
371 } 388 }
372 389
@@ -380,13 +397,14 @@ $('.btn-minus').on('touchstart', function() { @@ -380,13 +397,14 @@ $('.btn-minus').on('touchstart', function() {
380 $('.btn-plus').on('touchstart', function() { 397 $('.btn-plus').on('touchstart', function() {
381 var num = $num.val(); 398 var num = $num.val();
382 399
383 - //若颜色和尺码没有被同时选中,则不能点击  
384 - if ($('.block-list>ul>li.chosed').length < 2) {  
385 - tip.show('请选择颜色和尺码~'); 400 + leftNum = $('#left-num').val();
  401 +
  402 + if (!checkColorSizeNum()) {
386 return; 403 return;
387 } 404 }
388 - leftNum = re.exec($('.num .left-num').html());  
389 - if (num - 0 === leftNum - 0 || 0 === leftNum - 0) { 405 +
  406 +
  407 + if (num - 0 === leftNum || 0 === leftNum) {
390 return; 408 return;
391 } 409 }
392 410
@@ -394,22 +412,35 @@ $('.btn-plus').on('touchstart', function() { @@ -394,22 +412,35 @@ $('.btn-plus').on('touchstart', function() {
394 $num.val(num + 1); 412 $num.val(num + 1);
395 }); 413 });
396 414
397 -$('#chose-btn-sure').on('touchend', function() { 415 +$('#chose-btn-sure').on('touchstart', function() {
398 416
399 var productSku, 417 var productSku,
400 buyNumber = $('#good-num').val() - 0, 418 buyNumber = $('#good-num').val() - 0,
401 419
402 promotionId, 420 promotionId,
403 isEdit = 0, 421 isEdit = 0,
404 - numInCart = $('.num-tag').html() - 0; 422 + numInCart = $('.num-tag').html() - 0,
  423 + num = $num.val();
  424 +
  425 + if (!checkColorSizeNum()) {
  426 + return;
  427 + }
  428 +
  429 + if ($('#chose-btn-sure').html() === '已售罄') {
  430 + return;
  431 + }
  432 +
  433 + leftNum = $('#left-num').val();
405 434
406 - // goodsType,  
407 - // isEdit; 435 + if (num > leftNum) {
  436 + tip.show('您选择的数量超过了最大库存量~');
  437 + return;
  438 + }
408 439
409 $chosed = $('.block-list>ul>li.chosed'); 440 $chosed = $('.block-list>ul>li.chosed');
410 441
411 if (2 === $chosed.length && 0 === $chosed.closest('.zero-stock').length) { 442 if (2 === $chosed.length && 0 === $chosed.closest('.zero-stock').length) {
412 - productSku = $sizeList.closest('.chosed').data('skuid'); 443 + productSku = $curSizeBlock.data('skuid');
413 promotionId = $('[data-id="' + productSku + '"]').closest('.advance-block').data('promotion-id'); 444 promotionId = $('[data-id="' + productSku + '"]').closest('.advance-block').data('promotion-id');
414 if (confirming) { 445 if (confirming) {
415 return false; 446 return false;
@@ -116,11 +116,26 @@ @@ -116,11 +116,26 @@
116 color: #8f8f8f; 116 color: #8f8f8f;
117 } 117 }
118 } 118 }
119 -  
120 - .price-compute { 119 + .activity{
121 padding: 20rem / $pxConvertRem; 120 padding: 20rem / $pxConvertRem;
122 - border-bottom: 1px solid #e0e0e0;  
123 font-size: 26rem / $pxConvertRem; 121 font-size: 26rem / $pxConvertRem;
  122 + h1{
  123 + font-size: 32rem / $pxConvertRem;
  124 + }
  125 + li:before {
  126 + content: "";
  127 + display: inline-block;
  128 + width: 4px;
  129 + height: 4px;
  130 + background-color: #000;
  131 + border-radius: 50%;
  132 + margin-right: 8rem / $pxConvertRem;
  133 + }
  134 + }
  135 + .price-compute {
  136 + padding: 20rem / $pxConvertRem;
  137 + border-top: 1px solid #e0e0e0;
  138 + font-size: 28rem / $pxConvertRem;
124 139
125 .title { 140 .title {
126 display: inline-block; 141 display: inline-block;
@@ -33,18 +33,21 @@ @@ -33,18 +33,21 @@
33 {{/if}} 33 {{/if}}
34 </ul> 34 </ul>
35 {{/if}} 35 {{/if}}
36 - 36 +<div class="activity">
  37 + <h1>以参与活动</h1>
  38 + <ul>
  39 + {{# promotionInfo}}
  40 + <li>{{name}}</li>
  41 + {{/ promotionInfo}}
  42 + </ul>
  43 +</div>
37 <div class="price-compute"> 44 <div class="price-compute">
38 - <p class="sum-price">  
39 - <span class="title">总价</span>  
40 - <span id="good-totalprice">¥{{price}}</span> 45 + <p>
  46 + <span>总价(¥{{price}})<i>-</i></span>
  47 + <span>活动价(¥{{activityPrice}})</span>
41 </p> 48 </p>
42 - <p class="activity-price">  
43 - <span class="title">  
44 - 活动价  
45 - <i class="minus">-</i>  
46 - </span>  
47 - <span id="good-activityPrice">¥{{activityPrice}}</span> 49 + <p>
  50 + <span><i>=</i>商品总计金额 (¥{{sumPrice}})</span>
48 </p> 51 </p>
49 </div> 52 </div>
50 53