Authored by 陈峰

fix weixin pay lefttime

@@ -14,7 +14,7 @@ @@ -14,7 +14,7 @@
14 <h3>请您及时付款,以便订单尽快处理!订单号:{{order_code}}</h3> 14 <h3>请您及时付款,以便订单尽快处理!订单号:{{order_code}}</h3>
15 <p> 15 <p>
16 请您提交订单 16 请您提交订单
17 - <span>2小时</span> 17 + <span class="js-time js-timer" data-time="{{pay_lefttime}}"></span>
18 内完成,否则订单会自动取消。 18 内完成,否则订单会自动取消。
19 </p> 19 </p>
20 </div> 20 </div>
1 { 1 {
2 "name": "yohobuy-node", 2 "name": "yohobuy-node",
3 - "version": "6.8.21", 3 + "version": "6.8.22",
4 "private": true, 4 "private": true,
5 "description": "A New Yohobuy Project With Express", 5 "description": "A New Yohobuy Project With Express",
6 "repository": { 6 "repository": {
@@ -6,6 +6,9 @@ var $wOdetail = $('.w-odetail'), @@ -6,6 +6,9 @@ var $wOdetail = $('.w-odetail'),
6 $wPayment = $('.w-payment'), 6 $wPayment = $('.w-payment'),
7 $wAddrinfo = $('.w-addrinfo'), 7 $wAddrinfo = $('.w-addrinfo'),
8 $wPerm = $('.w-p-erm'), 8 $wPerm = $('.w-p-erm'),
  9 + time = $('.js-time').data('time'),
  10 + timeInterval,
  11 + $timer = $('.js-timer'),
9 orderCode = $wPayment.data('order'); 12 orderCode = $wPayment.data('order');
10 13
11 require('../simple-header'); 14 require('../simple-header');
@@ -20,6 +23,10 @@ wxPage = { @@ -20,6 +23,10 @@ wxPage = {
20 }); 23 });
21 this.setEvent(); 24 this.setEvent();
22 inter = setInterval(this.checkPayStatus, 3000); 25 inter = setInterval(this.checkPayStatus, 3000);
  26 + this.setTimer();
  27 + timeInterval = setInterval(() => {
  28 + this.setTimer();
  29 + }, 1000);
23 }, 30 },
24 setEvent: function() { 31 setEvent: function() {
25 $wOdetail.on('click', function() { 32 $wOdetail.on('click', function() {
@@ -61,6 +68,25 @@ wxPage = { @@ -61,6 +68,25 @@ wxPage = {
61 } 68 }
62 } 69 }
63 }); 70 });
  71 + },
  72 + setTimer: function() {
  73 + if (time < 0) {
  74 + return clearInterval(timeInterval);
  75 + }
  76 +
  77 + let hour = Math.floor(time / 3600);
  78 + let minus = Math.floor((time % 3600) / 60);
  79 + let second = time % 60;
  80 + let text = '';
  81 +
  82 + if (hour > 0) {
  83 + text += hour + '小时';
  84 + }
  85 +
  86 + text += minus + '分' + second + '秒';
  87 +
  88 + $timer.text(text);
  89 + time--;
64 } 90 }
65 }; 91 };
66 92