Authored by 郭成尧

discount-goods-detail-page-handle

... ... @@ -246,7 +246,9 @@ let getProductData = (data) => {
/* 量贩 */
if (bundleData && _.get(bundleData, 'bundleInfo.discountType', null) === 2) {
finalResult.discount = _.get(bundleData, 'bundleInfo.bundleCount', 1);
finalResult.discountBuy = {
num: _.get(bundleData, 'bundleInfo.bundleCount', 1)
};
}
Object.assign(finalResult.feedbacks, info[1]);
... ...
... ... @@ -118,12 +118,12 @@
<a class="store-link" href="{{url}}">进入店铺<span class="iconfont">&#xe604;</span></a>
</div>
{{/ enterStore}}
<!-- 套装 -->
{{# bundleData}}
{{> detail/bundle}}
{{/ bundleData}}
<!-- /套装 -->
{{# discountBuy}}
<input type="hidden" id="discount-buy" value="{{num}}">
{{/ discountBuy}}
<div id="productDesc" {{#if limit}}class="limit"{{/if}}> </div>
{{> detail/recommend-for-you}}
<div class="chose-panel"></div>
... ...
... ... @@ -58,6 +58,9 @@ var limitProductCode,
// 限购商品的skn。只有限购商品时才会设置。
skn;
// 量贩商品
var discountNum = $('#discount-buy').val() - 0;
// 禁用数字编辑
function disableNumEdit() {
var $numBtn = $('.chose-panel').find('.num .btn>.iconfont');
... ... @@ -422,7 +425,7 @@ $yohoPage.on('touchstart', '.color-list .block', function() {
$this.toggleClass('chosed');
}
$('#good-num').val(1);
$('#good-num').val(discountNum);
// 设置按钮的样式和文字
updateConformButtonClassAndText();
... ... @@ -489,7 +492,7 @@ $yohoPage.on('touchstart', '.color-list .block', function() {
// 颜色块切换勾选样式
$this.siblings('.chosed').removeClass('chosed');
$this.toggleClass('chosed');
$('#good-num').val(1);
$('#good-num').val(discountNum);
// 设置按钮的样式和文字
updateConformButtonClassAndText();
... ... @@ -504,10 +507,16 @@ $yohoPage.on('touchstart', '.btn-minus', function() {
return;
}
if (num <= discountNum) {
tip.show('量贩商品,' + discountNum + '件起购');
return;
}
if (num === 1 || leftNum - 0 === 0) {
tip.show('您选择的数量不能为零~');
return;
}
if (num < 0) {
tip.show('您选择的数量不能为负数~');
return;
... ... @@ -538,7 +547,6 @@ $yohoPage.on('touchstart', '.btn-minus', function() {
var productSku,
buyNumber = $('#good-num').val() - 0,
promotionId,
cartGoodData,
url,
... ... @@ -563,6 +571,12 @@ $yohoPage.on('touchstart', '.btn-minus', function() {
tip.show('您选择的数量小于一件~');
return;
}
if (num < discountNum) {
tip.show('量贩商品,' + discountNum + '件起购');
return;
}
$chosed = $('.block-list>ul>li.chosed');
if ($chosed.length === 2 && $chosed.closest('.zero-stock').length === 0) {
... ...
... ... @@ -67,8 +67,10 @@ function render(data) {
$chosePanel.removeClass(dbClass);
var cartInfo = data.cartInfo;
var thumbClone = $chosePanel.find('.thumb').remove();
for (var i = 0; i < cartInfo.thumbs.length; i++) {
var thumbEle = thumbClone.clone();
thumbEle.attr('src', cartInfo.thumbs[i].img);
if (i != 0) {
thumbEle.addClass('hide');
... ... @@ -88,9 +90,11 @@ function render(data) {
}
var colorsClone = $chosePanel.find('.color-list>.size-row').remove();
var colorClone = colorsClone.find('li').remove();
for (var i = 0; i < cartInfo.colors.length; i++) {
var colors = cartInfo.colors[i];
var colorsEle = colorsClone.clone();
colorsEle.attr('id', colors.id).attr('data-index', i);
if (i != 0) {
colorsEle.addClass('hide');
... ... @@ -98,6 +102,7 @@ function render(data) {
for (var o = 0; o < colors.color.length; o++) {
var color = colors.color[o];
var colorEle = colorClone.clone();
colorEle.attr('data-num', color.colorNum).text(color.name);
if (color.chosed) {
colorEle.addClass('chosed');
... ... @@ -111,15 +116,18 @@ function render(data) {
}
var sizesClone = $chosePanel.find('.size-list>.size-row').remove();
var sizeClone = sizesClone.find('li').remove();
for (var i = 0; i < cartInfo.sizes.length; i++) {
var sizes = cartInfo.sizes[i];
var sizesEle = sizesClone.clone();
if (i != 0) {
sizesEle.addClass('hide');
}
for (var o = 0; o < sizes.size.length; o++) {
var size = sizes.size[o];
var sizeEle = sizeClone.clone();
sizeEle.attr('data-num', size.sizeNum).attr('data-id', size.id).attr('data-skuid', size.skuId).text(size.name);
if (size.chosed) {
sizeEle.addClass('chosed');
... ... @@ -146,6 +154,9 @@ function render(data) {
if (data.cartInfo.promotionId) {
$('.btn-minus,.btn-plus').find('span').addClass('disabled');
}
/* tar modified 161205 量贩商品数量限制 */
$('#good-num').val($('#discount-buy').val());
$('#limitNum').val(data.limit);
$('#promotionId').val(data.cartInfo.promotionId);
$('#single').val(data.single);
... ...