discount-goods-detail-page-handle
Showing
4 changed files
with
34 additions
and
7 deletions
@@ -246,7 +246,9 @@ let getProductData = (data) => { | @@ -246,7 +246,9 @@ let getProductData = (data) => { | ||
246 | 246 | ||
247 | /* 量贩 */ | 247 | /* 量贩 */ |
248 | if (bundleData && _.get(bundleData, 'bundleInfo.discountType', null) === 2) { | 248 | if (bundleData && _.get(bundleData, 'bundleInfo.discountType', null) === 2) { |
249 | - finalResult.discount = _.get(bundleData, 'bundleInfo.bundleCount', 1); | 249 | + finalResult.discountBuy = { |
250 | + num: _.get(bundleData, 'bundleInfo.bundleCount', 1) | ||
251 | + }; | ||
250 | } | 252 | } |
251 | 253 | ||
252 | Object.assign(finalResult.feedbacks, info[1]); | 254 | Object.assign(finalResult.feedbacks, info[1]); |
@@ -118,12 +118,12 @@ | @@ -118,12 +118,12 @@ | ||
118 | <a class="store-link" href="{{url}}">进入店铺<span class="iconfont"></span></a> | 118 | <a class="store-link" href="{{url}}">进入店铺<span class="iconfont"></span></a> |
119 | </div> | 119 | </div> |
120 | {{/ enterStore}} | 120 | {{/ enterStore}} |
121 | - | ||
122 | - <!-- 套装 --> | ||
123 | {{# bundleData}} | 121 | {{# bundleData}} |
124 | {{> detail/bundle}} | 122 | {{> detail/bundle}} |
125 | {{/ bundleData}} | 123 | {{/ bundleData}} |
126 | - <!-- /套装 --> | 124 | + {{# discountBuy}} |
125 | + <input type="hidden" id="discount-buy" value="{{num}}"> | ||
126 | + {{/ discountBuy}} | ||
127 | <div id="productDesc" {{#if limit}}class="limit"{{/if}}> </div> | 127 | <div id="productDesc" {{#if limit}}class="limit"{{/if}}> </div> |
128 | {{> detail/recommend-for-you}} | 128 | {{> detail/recommend-for-you}} |
129 | <div class="chose-panel"></div> | 129 | <div class="chose-panel"></div> |
@@ -58,6 +58,9 @@ var limitProductCode, | @@ -58,6 +58,9 @@ var limitProductCode, | ||
58 | // 限购商品的skn。只有限购商品时才会设置。 | 58 | // 限购商品的skn。只有限购商品时才会设置。 |
59 | skn; | 59 | skn; |
60 | 60 | ||
61 | +// 量贩商品 | ||
62 | +var discountNum = $('#discount-buy').val() - 0; | ||
63 | + | ||
61 | // 禁用数字编辑 | 64 | // 禁用数字编辑 |
62 | function disableNumEdit() { | 65 | function disableNumEdit() { |
63 | var $numBtn = $('.chose-panel').find('.num .btn>.iconfont'); | 66 | var $numBtn = $('.chose-panel').find('.num .btn>.iconfont'); |
@@ -422,7 +425,7 @@ $yohoPage.on('touchstart', '.color-list .block', function() { | @@ -422,7 +425,7 @@ $yohoPage.on('touchstart', '.color-list .block', function() { | ||
422 | $this.toggleClass('chosed'); | 425 | $this.toggleClass('chosed'); |
423 | } | 426 | } |
424 | 427 | ||
425 | - $('#good-num').val(1); | 428 | + $('#good-num').val(discountNum); |
426 | 429 | ||
427 | // 设置按钮的样式和文字 | 430 | // 设置按钮的样式和文字 |
428 | updateConformButtonClassAndText(); | 431 | updateConformButtonClassAndText(); |
@@ -489,7 +492,7 @@ $yohoPage.on('touchstart', '.color-list .block', function() { | @@ -489,7 +492,7 @@ $yohoPage.on('touchstart', '.color-list .block', function() { | ||
489 | // 颜色块切换勾选样式 | 492 | // 颜色块切换勾选样式 |
490 | $this.siblings('.chosed').removeClass('chosed'); | 493 | $this.siblings('.chosed').removeClass('chosed'); |
491 | $this.toggleClass('chosed'); | 494 | $this.toggleClass('chosed'); |
492 | - $('#good-num').val(1); | 495 | + $('#good-num').val(discountNum); |
493 | 496 | ||
494 | // 设置按钮的样式和文字 | 497 | // 设置按钮的样式和文字 |
495 | updateConformButtonClassAndText(); | 498 | updateConformButtonClassAndText(); |
@@ -504,10 +507,16 @@ $yohoPage.on('touchstart', '.btn-minus', function() { | @@ -504,10 +507,16 @@ $yohoPage.on('touchstart', '.btn-minus', function() { | ||
504 | return; | 507 | return; |
505 | } | 508 | } |
506 | 509 | ||
510 | + if (num <= discountNum) { | ||
511 | + tip.show('量贩商品,' + discountNum + '件起购'); | ||
512 | + return; | ||
513 | + } | ||
514 | + | ||
507 | if (num === 1 || leftNum - 0 === 0) { | 515 | if (num === 1 || leftNum - 0 === 0) { |
508 | tip.show('您选择的数量不能为零~'); | 516 | tip.show('您选择的数量不能为零~'); |
509 | return; | 517 | return; |
510 | } | 518 | } |
519 | + | ||
511 | if (num < 0) { | 520 | if (num < 0) { |
512 | tip.show('您选择的数量不能为负数~'); | 521 | tip.show('您选择的数量不能为负数~'); |
513 | return; | 522 | return; |
@@ -538,7 +547,6 @@ $yohoPage.on('touchstart', '.btn-minus', function() { | @@ -538,7 +547,6 @@ $yohoPage.on('touchstart', '.btn-minus', function() { | ||
538 | 547 | ||
539 | var productSku, | 548 | var productSku, |
540 | buyNumber = $('#good-num').val() - 0, | 549 | buyNumber = $('#good-num').val() - 0, |
541 | - | ||
542 | promotionId, | 550 | promotionId, |
543 | cartGoodData, | 551 | cartGoodData, |
544 | url, | 552 | url, |
@@ -563,6 +571,12 @@ $yohoPage.on('touchstart', '.btn-minus', function() { | @@ -563,6 +571,12 @@ $yohoPage.on('touchstart', '.btn-minus', function() { | ||
563 | tip.show('您选择的数量小于一件~'); | 571 | tip.show('您选择的数量小于一件~'); |
564 | return; | 572 | return; |
565 | } | 573 | } |
574 | + | ||
575 | + if (num < discountNum) { | ||
576 | + tip.show('量贩商品,' + discountNum + '件起购'); | ||
577 | + return; | ||
578 | + } | ||
579 | + | ||
566 | $chosed = $('.block-list>ul>li.chosed'); | 580 | $chosed = $('.block-list>ul>li.chosed'); |
567 | 581 | ||
568 | if ($chosed.length === 2 && $chosed.closest('.zero-stock').length === 0) { | 582 | if ($chosed.length === 2 && $chosed.closest('.zero-stock').length === 0) { |
@@ -67,8 +67,10 @@ function render(data) { | @@ -67,8 +67,10 @@ function render(data) { | ||
67 | $chosePanel.removeClass(dbClass); | 67 | $chosePanel.removeClass(dbClass); |
68 | var cartInfo = data.cartInfo; | 68 | var cartInfo = data.cartInfo; |
69 | var thumbClone = $chosePanel.find('.thumb').remove(); | 69 | var thumbClone = $chosePanel.find('.thumb').remove(); |
70 | + | ||
70 | for (var i = 0; i < cartInfo.thumbs.length; i++) { | 71 | for (var i = 0; i < cartInfo.thumbs.length; i++) { |
71 | var thumbEle = thumbClone.clone(); | 72 | var thumbEle = thumbClone.clone(); |
73 | + | ||
72 | thumbEle.attr('src', cartInfo.thumbs[i].img); | 74 | thumbEle.attr('src', cartInfo.thumbs[i].img); |
73 | if (i != 0) { | 75 | if (i != 0) { |
74 | thumbEle.addClass('hide'); | 76 | thumbEle.addClass('hide'); |
@@ -88,9 +90,11 @@ function render(data) { | @@ -88,9 +90,11 @@ function render(data) { | ||
88 | } | 90 | } |
89 | var colorsClone = $chosePanel.find('.color-list>.size-row').remove(); | 91 | var colorsClone = $chosePanel.find('.color-list>.size-row').remove(); |
90 | var colorClone = colorsClone.find('li').remove(); | 92 | var colorClone = colorsClone.find('li').remove(); |
93 | + | ||
91 | for (var i = 0; i < cartInfo.colors.length; i++) { | 94 | for (var i = 0; i < cartInfo.colors.length; i++) { |
92 | var colors = cartInfo.colors[i]; | 95 | var colors = cartInfo.colors[i]; |
93 | var colorsEle = colorsClone.clone(); | 96 | var colorsEle = colorsClone.clone(); |
97 | + | ||
94 | colorsEle.attr('id', colors.id).attr('data-index', i); | 98 | colorsEle.attr('id', colors.id).attr('data-index', i); |
95 | if (i != 0) { | 99 | if (i != 0) { |
96 | colorsEle.addClass('hide'); | 100 | colorsEle.addClass('hide'); |
@@ -98,6 +102,7 @@ function render(data) { | @@ -98,6 +102,7 @@ function render(data) { | ||
98 | for (var o = 0; o < colors.color.length; o++) { | 102 | for (var o = 0; o < colors.color.length; o++) { |
99 | var color = colors.color[o]; | 103 | var color = colors.color[o]; |
100 | var colorEle = colorClone.clone(); | 104 | var colorEle = colorClone.clone(); |
105 | + | ||
101 | colorEle.attr('data-num', color.colorNum).text(color.name); | 106 | colorEle.attr('data-num', color.colorNum).text(color.name); |
102 | if (color.chosed) { | 107 | if (color.chosed) { |
103 | colorEle.addClass('chosed'); | 108 | colorEle.addClass('chosed'); |
@@ -111,15 +116,18 @@ function render(data) { | @@ -111,15 +116,18 @@ function render(data) { | ||
111 | } | 116 | } |
112 | var sizesClone = $chosePanel.find('.size-list>.size-row').remove(); | 117 | var sizesClone = $chosePanel.find('.size-list>.size-row').remove(); |
113 | var sizeClone = sizesClone.find('li').remove(); | 118 | var sizeClone = sizesClone.find('li').remove(); |
119 | + | ||
114 | for (var i = 0; i < cartInfo.sizes.length; i++) { | 120 | for (var i = 0; i < cartInfo.sizes.length; i++) { |
115 | var sizes = cartInfo.sizes[i]; | 121 | var sizes = cartInfo.sizes[i]; |
116 | var sizesEle = sizesClone.clone(); | 122 | var sizesEle = sizesClone.clone(); |
123 | + | ||
117 | if (i != 0) { | 124 | if (i != 0) { |
118 | sizesEle.addClass('hide'); | 125 | sizesEle.addClass('hide'); |
119 | } | 126 | } |
120 | for (var o = 0; o < sizes.size.length; o++) { | 127 | for (var o = 0; o < sizes.size.length; o++) { |
121 | var size = sizes.size[o]; | 128 | var size = sizes.size[o]; |
122 | var sizeEle = sizeClone.clone(); | 129 | var sizeEle = sizeClone.clone(); |
130 | + | ||
123 | sizeEle.attr('data-num', size.sizeNum).attr('data-id', size.id).attr('data-skuid', size.skuId).text(size.name); | 131 | sizeEle.attr('data-num', size.sizeNum).attr('data-id', size.id).attr('data-skuid', size.skuId).text(size.name); |
124 | if (size.chosed) { | 132 | if (size.chosed) { |
125 | sizeEle.addClass('chosed'); | 133 | sizeEle.addClass('chosed'); |
@@ -146,6 +154,9 @@ function render(data) { | @@ -146,6 +154,9 @@ function render(data) { | ||
146 | if (data.cartInfo.promotionId) { | 154 | if (data.cartInfo.promotionId) { |
147 | $('.btn-minus,.btn-plus').find('span').addClass('disabled'); | 155 | $('.btn-minus,.btn-plus').find('span').addClass('disabled'); |
148 | } | 156 | } |
157 | + | ||
158 | + /* tar modified 161205 量贩商品数量限制 */ | ||
159 | + $('#good-num').val($('#discount-buy').val()); | ||
149 | $('#limitNum').val(data.limit); | 160 | $('#limitNum').val(data.limit); |
150 | $('#promotionId').val(data.cartInfo.promotionId); | 161 | $('#promotionId').val(data.cartInfo.promotionId); |
151 | $('#single').val(data.single); | 162 | $('#single').val(data.single); |
-
Please register or login to post a comment