Authored by yyq

量贩购物车限制

... ... @@ -727,6 +727,9 @@ class Helpers
if ($value['buy_number'] > $value['storage_number']) {
$oneGoods['isTipNoStore'] = true; // 是否在结算时候显示库存不足
$oneGoods['tipMessage'] = '库存不足';
} elseif ($value['min_buy_number'] > 1) {
$oneGoods['minBuyNum'] = $value['min_buy_number'];
$oneGoods['tipMessage'] = $value['min_buy_number'] . '件起购';
} elseif ($value['storage_number'] <= 2) {
$oneGoods['tipMessage'] = '余量有限';
}
... ...
... ... @@ -116,7 +116,7 @@
{{#if isPriceGift}}
<div>{{productNum}}</div>
{{^}}
<span class="minus"></span>
<span class="minus"{{#if minBuyNum}} data-min="{{minBuyNum}}"{{/if}}></span>
<input type="text" value="{{productNum}}" readonly="readonly"/>
<span class="plus"></span>
<p class="tip-message {{#isTipNoStore}}tipNoStore{{/isTipNoStore}}">{{tipMessage}}</p>
... ... @@ -175,7 +175,7 @@
{{#if isPriceGift}}
<div>{{productNum}}</div>
{{^}}
<span class="minus"></span>
<span class="minus"{{#if minBuyNum}} data-min="{{minBuyNum}}"{{/if}}></span>
<input type="text" value="{{productNum}}" readonly="readonly"/>
<span class="plus"></span>
<p class="tip-message {{#isTipNoStore}}tipNoStore{{/isTipNoStore}}">{{tipMessage}}</p>
... ...
... ... @@ -639,17 +639,32 @@ function countAJAX(data) {
});
}
$('.minus').each(function() {
var data = $(this).data();
$(this).data(data);
});
$payWapper.on('click', '.minus, .plus', function() {
var $this = $(this),
minNum = 1;
countJSON = {};
count = $(this).hasClass('minus') ? 'decreaseNum' : 'increaseNum';
count = 'increaseNum';
if ($this.hasClass('minus')) {
count = 'decreaseNum';
minNum = $this.data('min') ? $this.data('min') * 1 : 1;
}
countJSON['' + count] = 1;
if (countBusy || ($(this).siblings('input').val() === '1' && $(this).hasClass('minus'))) {
if (countBusy || ($this.hasClass('minus') && $this.siblings('input').val() * 1 <= minNum)) {
return false;
}
countAJAX($.extend(countJSON,
{
sku: $(this).parents('tr').data('id')
sku: $this.parents('tr').data('id')
}
));
});
... ...