//支付倒计时 ComputetTime(data) { let st = data.currentTime.replace(/\-/g, "/"),//当前服务器时间 ct = data.formatCreateTime.replace(/\-/g, "/");//创建订单时间 let ts = new Date(st).getTime(), tc = new Date(ct).getTime(); let cm = 15 * 60 * 1000 - (ts - tc); this.runBack(cm); },
runBack(cm) { if (cm > 0) { cm > 60000 ? (this.rocallTime = (new Date(cm).getMinutes() < 10 ? "0" + new Date(cm).getMinutes() : new Date(cm).getMinutes()) + ":" + (new Date(cm).getSeconds() < 10 ? "0" + new Date(cm).getSeconds() : new Date(cm).getSeconds())) : (this.rocallTime = "00:" + (new Date(cm).getSeconds() < 10 ? "0" + new Date(cm).getSeconds() : new Date(cm).getSeconds())); let _msThis = this; setTimeout(function() { cm -= 1000; _msThis.runBack(cm); }, 1000); } else { this.changeOrderState();//调用改变订单状态接口 } },
模板template:
<div id="recomTime" v-show="orderinfo.orderState==‘1‘">剩余支付时间 {{rocallTime}}</div>
当 this.orderinfo.orderState==‘1‘ 调 this.ComputetTime(data) 即可