Commit 2fa5b83a by haojie

1

parent d1e97cb0
No preview for this file type
......@@ -31,11 +31,20 @@ import { tgUrl } from '@/utils/open';
// 是否展示广告
const hasOpen = ref(false);
// 存入sessionStorage---广告如果被关闭,下次打开浏览器继续弹出
// 获取当前时间
const getCurTime = () => {
// 获取当前时间
let date = new Date();
return date.valueOf();
};
onMounted(() => {
let open = window.sessionStorage.getItem('openAnn');
if (!open) {
hasOpen.value = true;
let open = JSON.parse(window.localStorage.getItem('openAnn'));
if (open && Object.keys(open).length) {
// 获取当前时间
let curTime = getCurTime();
if (curTime - open.last >= 86400000) {
hasOpen.value = true;
}
}
});
const JoinUs = (url: string) => {
......@@ -44,7 +53,14 @@ const JoinUs = (url: string) => {
// 关闭广告
const closeAnn = () => {
hasOpen.value = false;
window.sessionStorage.setItem('openAnn', 'close');
// 每天只弹出一次
window.localStorage.setItem(
'openAnn',
JSON.stringify({
last: getCurTime(),
value: 'close',
})
);
};
</script>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment