pdf 倒计时优化

This commit is contained in:
binbin_pan 2024-09-11 14:03:54 +08:00
parent f51b72051e
commit 4faff9db61
2 changed files with 10 additions and 4 deletions

View File

@ -497,7 +497,10 @@ See https://github.com/adobe-type-tools/cmap-resources
let second = params % 60; let second = params % 60;
let time = minute + ':' + second; let time = minute + ':' + second;
let interval = setInterval(() => { let interval = setInterval(() => {
if (time == 0) { params -= 1;
console.log('params:',params)
if (params <= 0) {
clearInterval(interval); clearInterval(interval);
document.getElementById('tip').innerText = '已完成学习'; document.getElementById('tip').innerText = '已完成学习';
} else { } else {
@ -508,12 +511,15 @@ See https://github.com/adobe-type-tools/cmap-resources
minute -= 1; minute -= 1;
second = 59; second = 59;
if (minute < 10) { if (minute < 10) {
minute = '0' + minute; minute = String(minute).padStart(2, '0');
} }
} else { } else {
second -= 1; second -= 1;
if (minute < 10) {
minute = String(minute).padStart(2, '0');
}
if (second < 10) { if (second < 10) {
second = '0' + second; second = String(second).padStart(2, '0');
} }
} }
time = minute + ':' + second; time = minute + ':' + second;

View File

@ -33,7 +33,7 @@ export default {
console.log('🚀 ~ onLoad ~ surplusTime:', this.surplusTime) console.log('🚀 ~ onLoad ~ surplusTime:', this.surplusTime)
setTimeout(() => { setTimeout(() => {
this.countDown() this.countDown()
}, 1300) }, 1000)
} else { } else {
this.surplusTime = 0 this.surplusTime = 0
// - // -