...
|
...
|
@@ -16,16 +16,7 @@ var couponsTpl = Hbs.compile($('#coupons-tpl').html()); |
|
|
var promotionTpl = Hbs.compile($('#promotion-list-tpl').html());
|
|
|
|
|
|
var $coin = $('#coin-used');
|
|
|
var $coinTip = $('#coin-tip');
|
|
|
var $coinSure = $('#coin-sure');
|
|
|
var coinMax = +$coin.data('max');
|
|
|
var coinStatus = {
|
|
|
err: '请输入一个正整数',
|
|
|
max: '您的有货币不足',
|
|
|
success: '抵扣',
|
|
|
maxUse: '您最多使用',
|
|
|
muPostfix: '个有货币'
|
|
|
};
|
|
|
|
|
|
var queryInfo;
|
|
|
var pkgCache = {};
|
...
|
...
|
@@ -178,63 +169,35 @@ if ($('#use-coupons').length) { |
|
|
}
|
|
|
|
|
|
// 有货币
|
|
|
if ($coin) {
|
|
|
$coin.data($coin.data()); // 防止人为更改有货币使用数量
|
|
|
}
|
|
|
|
|
|
$('#use-coin, #coin-sure, #coin-cancel').click(function() {
|
|
|
$('.coin-trigger').toggleClass('hide');
|
|
|
});
|
|
|
|
|
|
$coin.on('propertychange input', function() {
|
|
|
var c = $.trim($coin.val());
|
|
|
var err = true;
|
|
|
|
|
|
if (c === '') {
|
|
|
$coinSure.click(function() {
|
|
|
var data = $coin.data();
|
|
|
|
|
|
// 输入框为空,确定按钮不可点
|
|
|
$coinTip.addClass('vhide');
|
|
|
$coinTip.text(coinStatus.err);
|
|
|
if ($coinSure.hasClass('disable') ||
|
|
|
data.coin === data.max) {
|
|
|
return;
|
|
|
} else if (!/^[1-9]\d*$/.test(c)) {
|
|
|
|
|
|
// 验证输入不为正整数
|
|
|
$coinTip.text(coinStatus.err);
|
|
|
} else if (+c > coinMax) {
|
|
|
|
|
|
// 有货币不足
|
|
|
$coinTip.text(coinStatus.max);
|
|
|
} else if (+c > $('#sum-row').data('amount') * 100) {
|
|
|
|
|
|
// 输入的有货币大于订单额度
|
|
|
$coinTip.text(coinStatus.maxUse + ($('#sum-row').data('amount') * 100) + coinStatus.muPostfix);
|
|
|
} else {
|
|
|
err = false;
|
|
|
$coinTip.text(coinStatus.success + (c / 100).toFixed(2) + '元');
|
|
|
|
|
|
// 已使用面板的数据显示更新
|
|
|
// $coinUsed.html(c);
|
|
|
// $coinDeduction.html((c / 100).toFixed(2));
|
|
|
}
|
|
|
|
|
|
if (err) {
|
|
|
$coinSure.addClass('disable');
|
|
|
$coinTip.removeClass('vhide');
|
|
|
} else {
|
|
|
$coinSure.removeClass('disable');
|
|
|
$coinTip.addClass('vhide');
|
|
|
}
|
|
|
});
|
|
|
|
|
|
$coinSure.click(function() {
|
|
|
if ($coinSure.hasClass('disable')) {
|
|
|
return;
|
|
|
}
|
|
|
$coin.data('coin', $.trim($coin.val()));
|
|
|
$coin.data('coin', data.max);
|
|
|
|
|
|
// coin change trigger compute
|
|
|
compute();
|
|
|
});
|
|
|
|
|
|
$('#coin-cancel').click(function() {
|
|
|
$coin.val('').data('coin', '');
|
|
|
$coinTip.addClass('vhide').text('');
|
|
|
var data = $coin.data();
|
|
|
|
|
|
if (data.coin * 1 === 0) {
|
|
|
return;
|
|
|
}
|
|
|
$coin.data('coin', 0);
|
|
|
|
|
|
// coin cancel trigger compute
|
|
|
compute();
|
...
|
...
|
|