Authored by yyq

Merge branch 'feature/shoppingCart' into release/5.4.1

@@ -75,6 +75,7 @@ @@ -75,6 +75,7 @@
75 </script> 75 </script>
76 76
77 <script id="invoice-chose-tpl" type="text/html"> 77 <script id="invoice-chose-tpl" type="text/html">
  78 + <div class="invoice-close"><i class="iconfont">&#xe60d;</i></div>
78 <p class="invoice-header">发票信息</p> 79 <p class="invoice-header">发票信息</p>
79 <ul class="invoice-type"> 80 <ul class="invoice-type">
80 <li class="el-invoice focus">电子发票</li> 81 <li class="el-invoice focus">电子发票</li>
@@ -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 }
@@ -100,6 +100,10 @@ function bindInvoiceEvent($el) { @@ -100,6 +100,10 @@ function bindInvoiceEvent($el) {
100 $goodsTypeWrap.find('.on').removeClass('on'); 100 $goodsTypeWrap.find('.on').removeClass('on');
101 $this.addClass('on'); 101 $this.addClass('on');
102 }); 102 });
  103 +
  104 + $el.on('click', '.invoice-close', function() {
  105 + $('.btn-close', $el).trigger('click');
  106 + });
103 } 107 }
104 108
105 function bindInvoiceInfo($el, info) { 109 function bindInvoiceInfo($el, info) {
@@ -713,7 +713,7 @@ @@ -713,7 +713,7 @@
713 b { 713 b {
714 display: inline-block; 714 display: inline-block;
715 vertical-align: bottom; 715 vertical-align: bottom;
716 - max-width: 120px; 716 + max-width: 110px;
717 margin-right: 10px; 717 margin-right: 10px;
718 overflow: hidden; 718 overflow: hidden;
719 text-overflow: ellipsis; 719 text-overflow: ellipsis;
@@ -1521,6 +1521,21 @@ @@ -1521,6 +1521,21 @@
1521 color: #444; 1521 color: #444;
1522 background-color: #fff; 1522 background-color: #fff;
1523 1523
  1524 + > .close {
  1525 + display: none;
  1526 + }
  1527 +
  1528 + .invoice-close {
  1529 + position: absolute;
  1530 + top: 10px;
  1531 + right: 12px;
  1532 + cursor: pointer;
  1533 +
  1534 + .iconfont {
  1535 + font-size: 32px;
  1536 + }
  1537 + }
  1538 +
1524 .radio-btn { 1539 .radio-btn {
1525 &:before { 1540 &:before {
1526 content: ''; 1541 content: '';
@@ -1540,15 +1555,6 @@ @@ -1540,15 +1555,6 @@
1540 } 1555 }
1541 } 1556 }
1542 1557
1543 - > .close {  
1544 - top: 10px;  
1545 - right: 12px;  
1546 -  
1547 - .iconfont {  
1548 - font-size: 32px;  
1549 - }  
1550 - }  
1551 -  
1552 > .content { 1558 > .content {
1553 text-align: left; 1559 text-align: left;
1554 } 1560 }