|
@@ -60,7 +60,7 @@ Hbs.registerHelper('round', function(num, precision) { |
|
@@ -60,7 +60,7 @@ Hbs.registerHelper('round', function(num, precision) { |
60
|
|
60
|
|
61
|
// 订单计算
|
61
|
// 订单计算
|
62
|
// 传有货币数量则使用有货币,否者不使用,更改订单总价有货币使用数量重置为0
|
62
|
// 传有货币数量则使用有货币,否者不使用,更改订单总价有货币使用数量重置为0
|
63
|
-function compute(coin) {
|
63
|
+function compute(coin, cb) {
|
64
|
var reqData = {
|
64
|
var reqData = {
|
65
|
cartType: order.cartType,
|
65
|
cartType: order.cartType,
|
66
|
coin: coin ? coin : 0
|
66
|
coin: coin ? coin : 0
|
|
@@ -112,6 +112,11 @@ function compute(coin) { |
|
@@ -112,6 +112,11 @@ function compute(coin) { |
112
|
|
112
|
|
113
|
// update promotion formula list
|
113
|
// update promotion formula list
|
114
|
$balanceDetail.html(promotionTpl(res));
|
114
|
$balanceDetail.html(promotionTpl(res));
|
|
|
115
|
+
|
|
|
116
|
+ // callback
|
|
|
117
|
+ if (cb && typeof cb === 'function') {
|
|
|
118
|
+ return cb();
|
|
|
119
|
+ }
|
115
|
} else if (data.code === 317) {
|
120
|
} else if (data.code === 317) {
|
116
|
if (coupon.$errorTip) {
|
121
|
if (coupon.$errorTip) {
|
117
|
coupon.$errorTip.text(data.message);
|
122
|
coupon.$errorTip.text(data.message);
|
|
@@ -479,30 +484,25 @@ coupon = { |
|
@@ -479,30 +484,25 @@ coupon = { |
479
|
that.cancelTicketUse();
|
484
|
that.cancelTicketUse();
|
480
|
}).on('change', '.coupon-code', function() {
|
485
|
}).on('change', '.coupon-code', function() {
|
481
|
that.$errorTip.empty();
|
486
|
that.$errorTip.empty();
|
482
|
- }).on('click', '.opt-area > label', function() {
|
487
|
+ }).on('click', '.sure-use-ticket', function() {
|
|
|
488
|
+ that.close();
|
|
|
489
|
+ }).on('click', '.sure-use-code', function() {
|
483
|
var $this = $(this);
|
490
|
var $this = $(this);
|
484
|
- var couponId, data;
|
491
|
+ var couponId;
|
485
|
|
492
|
|
486
|
- if ($this.hasClass('sure-use-ticket')) {
|
|
|
487
|
- data = that.$radios.filter('.on').data();
|
|
|
488
|
-
|
|
|
489
|
- if (data) {
|
|
|
490
|
- that.$ticketUseTip.find('.price').text('- ¥' + data.price);
|
|
|
491
|
- that.$ticketUseTip.removeClass('hide');
|
|
|
492
|
- couponId = data.id;
|
|
|
493
|
- }
|
|
|
494
|
- } else {
|
|
|
495
|
- couponId = $this.siblings('.coupon-code').val();
|
|
|
496
|
- }
|
493
|
+ couponId = $this.siblings('.coupon-code').val();
|
497
|
|
494
|
|
498
|
if (couponId) {
|
495
|
if (couponId) {
|
499
|
order.couponCode = couponId;
|
496
|
order.couponCode = couponId;
|
500
|
|
497
|
|
501
|
// 重新计算订单价格
|
498
|
// 重新计算订单价格
|
502
|
- compute();
|
499
|
+ compute(0, function() {
|
|
|
500
|
+ that.close();
|
|
|
501
|
+ });
|
503
|
}
|
502
|
}
|
504
|
}).on('click', '.coupon-radio', function() {
|
503
|
}).on('click', '.coupon-radio', function() {
|
505
|
- var $this = $(this);
|
504
|
+ var $this = $(this),
|
|
|
505
|
+ data, couponId;
|
506
|
|
506
|
|
507
|
if ($this.hasClass('on')) {
|
507
|
if ($this.hasClass('on')) {
|
508
|
return;
|
508
|
return;
|
|
@@ -512,6 +512,20 @@ coupon = { |
|
@@ -512,6 +512,20 @@ coupon = { |
512
|
that.$radios.filter('.on').removeClass('on');
|
512
|
that.$radios.filter('.on').removeClass('on');
|
513
|
}
|
513
|
}
|
514
|
$this.addClass('on');
|
514
|
$this.addClass('on');
|
|
|
515
|
+ data = $this.data();
|
|
|
516
|
+
|
|
|
517
|
+ if (data) {
|
|
|
518
|
+ that.$ticketUseTip.find('.price').text('- ¥' + data.price);
|
|
|
519
|
+ that.$ticketUseTip.removeClass('hide');
|
|
|
520
|
+ couponId = data.id;
|
|
|
521
|
+ }
|
|
|
522
|
+
|
|
|
523
|
+ if (couponId) {
|
|
|
524
|
+ order.couponCode = couponId;
|
|
|
525
|
+
|
|
|
526
|
+ // 重新计算订单价格
|
|
|
527
|
+ compute();
|
|
|
528
|
+ }
|
515
|
});
|
529
|
});
|
516
|
},
|
530
|
},
|
517
|
cancelTicketUse: function() {
|
531
|
cancelTicketUse: function() {
|
|
@@ -531,6 +545,9 @@ coupon = { |
|
@@ -531,6 +545,9 @@ coupon = { |
531
|
delete order.couponCode;
|
545
|
delete order.couponCode;
|
532
|
compute(); // 重新计算订单价格
|
546
|
compute(); // 重新计算订单价格
|
533
|
}
|
547
|
}
|
|
|
548
|
+ },
|
|
|
549
|
+ close: function() {
|
|
|
550
|
+ this.$el.children('.locker-switch').trigger('click');
|
534
|
}
|
551
|
}
|
535
|
};
|
552
|
};
|
536
|
|
553
|
|
|
@@ -584,6 +601,7 @@ $('.locker-switch').click(function() { |
|
@@ -584,6 +601,7 @@ $('.locker-switch').click(function() { |
584
|
|
601
|
|
585
|
(function() {
|
602
|
(function() {
|
586
|
var $redSureBtn = $('#red-packet-sure');
|
603
|
var $redSureBtn = $('#red-packet-sure');
|
|
|
604
|
+ var $redPacketBox = $('#red-packet-box');
|
587
|
var used;
|
605
|
var used;
|
588
|
|
606
|
|
589
|
if (!$redSureBtn.length) {
|
607
|
if (!$redSureBtn.length) {
|
|
@@ -598,12 +616,15 @@ $('.locker-switch').click(function() { |
|
@@ -598,12 +616,15 @@ $('.locker-switch').click(function() { |
598
|
$redSureBtn.siblings('.radio-btn').addClass('on');
|
616
|
$redSureBtn.siblings('.radio-btn').addClass('on');
|
599
|
}
|
617
|
}
|
600
|
|
618
|
|
601
|
- $('#red-packet-box').on('click', '.radio-btn', function() {
|
619
|
+ $redPacketBox.on('click', '.radio-btn', function() {
|
602
|
$(this).toggleClass('on');
|
620
|
$(this).toggleClass('on');
|
603
|
}).on('click', '.sure-btn', function() {
|
621
|
}).on('click', '.sure-btn', function() {
|
604
|
var $this = $(this),
|
622
|
var $this = $(this),
|
605
|
num = $this.data('num');
|
623
|
num = $this.data('num');
|
606
|
|
624
|
|
|
|
625
|
+ // 触发关闭事件
|
|
|
626
|
+ $redPacketBox.prev().children('.locker-switch').trigger('click');
|
|
|
627
|
+
|
607
|
if (!num) {
|
628
|
if (!num) {
|
608
|
return;
|
629
|
return;
|
609
|
}
|
630
|
}
|