This commit is contained in:
Ling53666
2025-05-15 21:01:14 +08:00
parent 9b8553930b
commit 7c371623eb
35 changed files with 620 additions and 401 deletions

View File

@ -5,7 +5,8 @@ Page({
* 页面的初始数据
*/
data: {
countdown: 60, // 设置倒计时时长(秒)
timer: null, // 存储计时器
},
name(e){
@ -76,6 +77,34 @@ Page({
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);
}
},
// 注册
submit(){
@ -161,6 +190,7 @@ Page({
icon: 'error',
duration: 2000
});
}
},
fail(err) {