Screen.vue
1.32 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
<template>
<div class="screen" v-if="showTime">
<img src="@/assets/service/screen.png" alt="">
<span @click="skip">跳过 {{time}}</span>
</div>
</template>
<script>
export default {
props: {
reload: {
type: Boolean,
default: true
}
},
data () {
return {
time: 3,
showTime: true,
timeInterval: ''
}
},
mounted () {
let timeAlreadyShown = localStorage.getItem('timeAlreadyShown');
if (timeAlreadyShown && !this.reload) {
this.showTime = false
return;
}
this.timeInterval = setInterval(() => {
this.time--
if (this.time <= 0) {
this.skip()
}
}, 1000)
},
methods: {
skip () {
this.showTime = false
clearInterval(this.timeInterval)
localStorage.setItem('timeAlreadyShown', true)
}
}
}
</script>
<style lang="scss" scoped>
.screen {
width: 100%;
height: 100%;
background: #fff;
position: fixed;
top: 0;
left: 0;
z-index: 999;
img {
height: 100%;
position: absolute;
top: 0;
left: 50%;
transform: translateX(-50%);
}
span {
font-size: 22px;
color: #fff;
position: absolute;
top: 30px;
right: 30px;
width: 116px;
line-height: 48px;
background: rgba(0, 0, 0, 0.16);
border-radius: 10px;
text-align: center;
}
}
</style>