...
|
...
|
@@ -500,7 +500,6 @@ coupon = { |
|
|
}).then(function(data) {
|
|
|
if (data.code === 200) {
|
|
|
$('.coupon-list-wrap', that.$couponWrap).html(that.couponsTpl(data.data));
|
|
|
that.$radios = that.$couponWrap.find('.coupon-radio');
|
|
|
}
|
|
|
});
|
|
|
},
|
...
|
...
|
@@ -553,38 +552,47 @@ coupon = { |
|
|
}
|
|
|
}).on('click', '.coupon-radio', function() {
|
|
|
var $this = $(this),
|
|
|
data, couponId;
|
|
|
$par = $this.parent();
|
|
|
|
|
|
if ($this.hasClass('on')) {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
if (that.$radios) {
|
|
|
that.$radios.filter('.on').removeClass('on');
|
|
|
}
|
|
|
$par.siblings('.red').removeClass('red').children('.coupon-radio').removeClass('on');
|
|
|
$this.addClass('on');
|
|
|
$this.parent().siblings('.red').removeClass('red');
|
|
|
$this.parent().addClass('red');
|
|
|
data = $this.data();
|
|
|
$par.addClass('red');
|
|
|
|
|
|
if (data) {
|
|
|
that.$ticketUseTip.find('.price').text('- ¥' + data.price);
|
|
|
that.$ticketUseTip.removeClass('hide');
|
|
|
couponId = data.id;
|
|
|
}
|
|
|
// 改变优惠券使用搭配,重新计算订单价格
|
|
|
that.changeTicketsUse();
|
|
|
});
|
|
|
},
|
|
|
changeTicketsUse: function() {
|
|
|
var coupons = [],
|
|
|
price = 0;
|
|
|
|
|
|
if (couponId) {
|
|
|
order.couponCode = couponId;
|
|
|
this.$couponWrap.find('.coupon-radio.on').each(function() {
|
|
|
var data = $(this).data();
|
|
|
|
|
|
// 重新计算订单价格
|
|
|
compute();
|
|
|
if (data) {
|
|
|
coupons.push(data.id);
|
|
|
price += +data.price;
|
|
|
}
|
|
|
});
|
|
|
|
|
|
if (coupons.length) {
|
|
|
this.$ticketUseTip.find('.num').text(coupons.length);
|
|
|
this.$ticketUseTip.find('.price').text('- ¥' + price.toFixed(2));
|
|
|
this.$ticketUseTip.removeClass('hide');
|
|
|
order.couponCode = coupons.join(',');
|
|
|
|
|
|
// 重新计算订单价格
|
|
|
compute();
|
|
|
}
|
|
|
},
|
|
|
cancelTicketUse: function() {
|
|
|
if (order.couponCode) {
|
|
|
this.$ticketUseTip.addClass('hide');
|
|
|
this.$radios.filter('.on').removeClass('on');
|
|
|
this.$couponWrap.find('li.red').removeClass('red').find('.on').removeClass('on');
|
|
|
|
|
|
delete order.couponCode;
|
|
|
compute(); // 重新计算订单价格
|
...
|
...
|
|