Authored by htoooth

增加定单时间

@@ -13,7 +13,7 @@ @@ -13,7 +13,7 @@
13 <h2>您的订单已成功,现在就去付款吧~</h2> 13 <h2>您的订单已成功,现在就去付款吧~</h2>
14 <h3>您的订单号:<strong class="order-num">{{order_code}}</strong> 应付金额:<strong>{{payment_amount}}</strong>&nbsp; &nbsp; 14 <h3>您的订单号:<strong class="order-num">{{order_code}}</strong> 应付金额:<strong>{{payment_amount}}</strong>&nbsp; &nbsp;
15 支付方式:在线支付 &nbsp; &nbsp; &nbsp; 送货时间:{{deliveryTimes}}</h3> 15 支付方式:在线支付 &nbsp; &nbsp; &nbsp; 送货时间:{{deliveryTimes}}</h3>
16 - <h4>{{{htmlEncode ../username}}},如果2小时内您无法完成付款,系统会将您的订单取消。</h4> 16 + <h4 class="js-time" data-time="{{pay_lefttime}}">{{{htmlEncode ../username}}},如果在 <strong class="js-timer" style="color: #e8044f;"></strong> 内您无法完成付款,系统会将您的订单取消。</h4>
17 </div> 17 </div>
18 {{/order}} 18 {{/order}}
19 19
@@ -10,6 +10,8 @@ var $btnby = $('input.btnby'), @@ -10,6 +10,8 @@ var $btnby = $('input.btnby'),
10 amount = $btnby.data('amount'), 10 amount = $btnby.data('amount'),
11 $formGo = $('.form-go'), 11 $formGo = $('.form-go'),
12 Alert = dialog.Alert, 12 Alert = dialog.Alert,
  13 + time = $('.js-time').data('time'),
  14 + $timer = $('.js-timer'),
13 C_ID; 15 C_ID;
14 16
15 require('../simple-header'); 17 require('../simple-header');
@@ -21,6 +23,8 @@ payPage = { @@ -21,6 +23,8 @@ payPage = {
21 this.goPay(); 23 this.goPay();
22 }, 24 },
23 setEvent: function() { 25 setEvent: function() {
  26 + var self = this;
  27 +
24 // tab切 事件 28 // tab切 事件
25 $('ul.tabs').on('click', function(e) { 29 $('ul.tabs').on('click', function(e) {
26 var $li = $(e.target).closest('li'); 30 var $li = $(e.target).closest('li');
@@ -55,6 +59,11 @@ payPage = { @@ -55,6 +59,11 @@ payPage = {
55 document.location.href = '//www.yohobuy.com/home/orders'; 59 document.location.href = '//www.yohobuy.com/home/orders';
56 }); 60 });
57 }); 61 });
  62 +
  63 + this.setTimer();
  64 + setInterval(function() {
  65 + self.setTimer();
  66 + }, 1000);
58 }, 67 },
59 goPay: function() { 68 goPay: function() {
60 var payType; 69 var payType;
@@ -128,6 +137,21 @@ payPage = { @@ -128,6 +137,21 @@ payPage = {
128 } 137 }
129 }); 138 });
130 }); 139 });
  140 + },
  141 + setTimer: function() {
  142 + var hour = Math.floor(time / 3600);
  143 + var minus = Math.floor((time % 3600) / 60);
  144 + var second = time % 60;
  145 + var text = '';
  146 +
  147 + if (hour > 0) {
  148 + text += hour + '小时';
  149 + }
  150 +
  151 + text += minus + '分' + second + '秒';
  152 +
  153 + $timer.text(text);
  154 + time--;
131 } 155 }
132 }; 156 };
133 157