...
|
...
|
@@ -60,7 +60,7 @@ Hbs.registerHelper('round', function(num, precision) { |
|
|
|
|
|
// 订单计算
|
|
|
// 传有货币数量则使用有货币,否者不使用,更改订单总价有货币使用数量重置为0
|
|
|
function compute(coin) {
|
|
|
function compute(coin, cb) {
|
|
|
var reqData = {
|
|
|
cartType: order.cartType,
|
|
|
coin: coin ? coin : 0
|
...
|
...
|
@@ -112,6 +112,11 @@ function compute(coin) { |
|
|
|
|
|
// update promotion formula list
|
|
|
$balanceDetail.html(promotionTpl(res));
|
|
|
|
|
|
// callback
|
|
|
if (cb && typeof cb === 'function') {
|
|
|
return cb();
|
|
|
}
|
|
|
} else if (data.code === 317) {
|
|
|
if (coupon.$errorTip) {
|
|
|
coupon.$errorTip.text(data.message);
|
...
|
...
|
@@ -479,30 +484,25 @@ coupon = { |
|
|
that.cancelTicketUse();
|
|
|
}).on('change', '.coupon-code', function() {
|
|
|
that.$errorTip.empty();
|
|
|
}).on('click', '.opt-area > label', function() {
|
|
|
}).on('click', '.sure-use-ticket', function() {
|
|
|
that.close();
|
|
|
}).on('click', '.sure-use-code', function() {
|
|
|
var $this = $(this);
|
|
|
var couponId, data;
|
|
|
var couponId;
|
|
|
|
|
|
if ($this.hasClass('sure-use-ticket')) {
|
|
|
data = that.$radios.filter('.on').data();
|
|
|
|
|
|
if (data) {
|
|
|
that.$ticketUseTip.find('.price').text('- ¥' + data.price);
|
|
|
that.$ticketUseTip.removeClass('hide');
|
|
|
couponId = data.id;
|
|
|
}
|
|
|
} else {
|
|
|
couponId = $this.siblings('.coupon-code').val();
|
|
|
}
|
|
|
couponId = $this.siblings('.coupon-code').val();
|
|
|
|
|
|
if (couponId) {
|
|
|
order.couponCode = couponId;
|
|
|
|
|
|
// 重新计算订单价格
|
|
|
compute();
|
|
|
compute(0, function() {
|
|
|
that.close();
|
|
|
});
|
|
|
}
|
|
|
}).on('click', '.coupon-radio', function() {
|
|
|
var $this = $(this);
|
|
|
var $this = $(this),
|
|
|
data, couponId;
|
|
|
|
|
|
if ($this.hasClass('on')) {
|
|
|
return;
|
...
|
...
|
@@ -512,6 +512,20 @@ coupon = { |
|
|
that.$radios.filter('.on').removeClass('on');
|
|
|
}
|
|
|
$this.addClass('on');
|
|
|
data = $this.data();
|
|
|
|
|
|
if (data) {
|
|
|
that.$ticketUseTip.find('.price').text('- ¥' + data.price);
|
|
|
that.$ticketUseTip.removeClass('hide');
|
|
|
couponId = data.id;
|
|
|
}
|
|
|
|
|
|
if (couponId) {
|
|
|
order.couponCode = couponId;
|
|
|
|
|
|
// 重新计算订单价格
|
|
|
compute();
|
|
|
}
|
|
|
});
|
|
|
},
|
|
|
cancelTicketUse: function() {
|
...
|
...
|
@@ -531,6 +545,9 @@ coupon = { |
|
|
delete order.couponCode;
|
|
|
compute(); // 重新计算订单价格
|
|
|
}
|
|
|
},
|
|
|
close: function() {
|
|
|
this.$el.children('.locker-switch').trigger('click');
|
|
|
}
|
|
|
};
|
|
|
|
...
|
...
|
@@ -584,6 +601,7 @@ $('.locker-switch').click(function() { |
|
|
|
|
|
(function() {
|
|
|
var $redSureBtn = $('#red-packet-sure');
|
|
|
var $redPacketBox = $('#red-packet-box');
|
|
|
var used;
|
|
|
|
|
|
if (!$redSureBtn.length) {
|
...
|
...
|
@@ -598,12 +616,15 @@ $('.locker-switch').click(function() { |
|
|
$redSureBtn.siblings('.radio-btn').addClass('on');
|
|
|
}
|
|
|
|
|
|
$('#red-packet-box').on('click', '.radio-btn', function() {
|
|
|
$redPacketBox.on('click', '.radio-btn', function() {
|
|
|
$(this).toggleClass('on');
|
|
|
}).on('click', '.sure-btn', function() {
|
|
|
var $this = $(this),
|
|
|
num = $this.data('num');
|
|
|
|
|
|
// 触发关闭事件
|
|
|
$redPacketBox.prev().children('.locker-switch').trigger('click');
|
|
|
|
|
|
if (!num) {
|
|
|
return;
|
|
|
}
|
...
|
...
|
|