JS前端处理每天弹窗只弹一次
作者:互联网
function isNotSameDay() {
try {
let startTime = localStorage.getItem("discoverTime");
if (startTime && startTime !== " ") {
startTime = Number(startTime);
} else {
localStorage.setItem("discoverTime", +new Date());
return Promise.resolve(true);
}
const startTimeMs = new Date(startTime).setHours(0, 0, 0, 0);
const endTimeMs = new Date().setHours(0, 0, 0, 0);
localStorage.setItem("discoverTime", +new Date());
const result = startTimeMs === endTimeMs ? false : true;
console.log("resultresultresult", result);
if (result) {
return Promise.resolve(result);
} else {
return Promise.resolve(result);
}
} catch (err) {
console.log("err", err);
return Promise.resolve(false);
}
},
标签:resolve,return,只弹,JS,result,startTime,Date,new,弹窗 来源: https://www.cnblogs.com/zerofan/p/16365214.html