data: function () {
return {
countdown: 1800,
payTimeout: '30:00 后超时',
};
},
// 二维码30分钟失效倒计时
payTimeoutCount() {
let _this = this;
if(this.countdown >= 0){
let minutes = Math.floor(this.countdown/60);
let seconds = Math.floor(this.countdown%60);
if(minutes < 10){
minutes = '0' + minutes;
}
if(seconds < 10){
seconds = '0' + seconds;
}
this.payTimeout = minutes + ":" + seconds + ' 后超时';
if(this.countdown == 0){
this.payTimeout = '支付超时';
}
--this.countdown;
}else{
window.clearInterval(_this.paytimerout);
this.payTimeout = '支付超时';
}
},
//开始倒计时
goPay() {
let _this = this;
_this.paytimerout = window.setInterval(function(){
_this.payTimeoutCount();
},1000);
},
// 清空计时器
closeCodeMask(){
let _this = this;
window.clearInterval(_this.paytimerout);
},