mounted() {
if (localStorage.getItem('times') === null) {
localStorage.setItem('times', 0)
}
this.timesFn()
},
beforeDestroy() {
clearInterval(this.timer)
}
timesFn() {
clearInterval(this.timer)
this.timer = setInterval(() => {
this.timesFn()
}, 900)
if (parseInt(new Date() / (1000 * 3600 * 24)) - localStorage.getItem('times') <= 0) return
//clearInterval(this.timer)
//this.timer = null
document.querySelector('.v-modal')?.click() //关闭前一个弹窗
localStorage.setItem('times', parseInt(new Date() / (1000 * 3600 * 24)))
const h = this.$createElement
let message
message = h('div', null, [
h('p', { style: 'text-indent:2em' }, '为不影响您的后续操作,请您及时续订')
])
this.$confirm(message, '提示', {
confirmButtonText: '立即续订',
cancelButtonText: '取消',
type: 'warning'
})
.then(() => {
window.open(this.$config['buyLink'], '_blank')
})
.finally(() => {
this.timesFn()
})
}
vue项目 弹窗一天一次前端自己判断
于 2022-05-13 09:58:46 首次发布