xiugai
This commit is contained in:
@ -146,6 +146,39 @@ getcode(){
|
||||
console.error('请求失败', err);
|
||||
}
|
||||
});
|
||||
this.startCountdown();
|
||||
},
|
||||
startCountdown() {
|
||||
this.setData({
|
||||
isCountingDown: true,
|
||||
countdown: 60
|
||||
});
|
||||
|
||||
this.data.timer = setInterval(() => {
|
||||
let count = this.data.countdown;
|
||||
if (count <= 1) {
|
||||
clearInterval(this.data.timer);
|
||||
this.setData({
|
||||
isCountingDown: false,
|
||||
countdown: 60
|
||||
});
|
||||
} else {
|
||||
this.setData({
|
||||
countdown: count - 1
|
||||
});
|
||||
}
|
||||
}, 1000);
|
||||
},
|
||||
onUnload() {
|
||||
// 页面卸载时清除定时器
|
||||
if (this.data.timer) {
|
||||
clearInterval(this.data.timer);
|
||||
}
|
||||
},
|
||||
back(){
|
||||
wx.navigateTo({
|
||||
url: '/pages/logain/logain',
|
||||
})
|
||||
}
|
||||
|
||||
})
|
Reference in New Issue
Block a user