生成xxxx-xxxx-xxxx-xxxx形式的随机数
function randomString(n) {
let chars = 'ABCDEFGHJKMNPQRSTWXYZabcdefhijkmnprstwxyz1234567890'
let pwd = ''
for (let i = 0; i < n; i++) {
i != 0 && i % 4 == 0 ? (pwd += '-') : ''
pwd += chars.charAt(Math.floor(Math.random() * chars.length))
}
return pwd
}
js倒计时函数
let utime = Math.floor(+new Date(obj.time) / 1000)
let nowtime = Math.floor(+new Date() / 1000)
clearInterval(timer)
t = utime - nowtime
countdown()
function countdown() {
if (t >= 0) {
t--
} else {
clearInterval(timer)
}
}
timer = setInterval(countdown, 1000)