|
@@ -0,0 +1,145 @@
|
|
1
|
+<template>
|
|
2
|
+ <div class="bell-box" @click="toggle">
|
|
3
|
+ <div>
|
|
4
|
+ <div class="center circle abs">
|
|
5
|
+ <div class="inner" :class="{'circle-ani': animate}" />
|
|
6
|
+ </div>
|
|
7
|
+ <div class="center circle abs">
|
|
8
|
+ <div class="outer" :class="{'circle-ani': animate}" />
|
|
9
|
+ </div>
|
|
10
|
+ <div class="center bell-img">
|
|
11
|
+ <img :class="{'bell-ani': animate}" src="/images/pg1/bell.png" alt="">
|
|
12
|
+ </div>
|
|
13
|
+ </div>
|
|
14
|
+ <audio ref="el" src="/audio/audio2.mp3" style="max-width: 0" loop preload="auto"></audio>
|
|
15
|
+ </div>
|
|
16
|
+</template>
|
|
17
|
+
|
|
18
|
+<script setup>
|
|
19
|
+ import { computed, onMounted, ref } from 'vue';
|
|
20
|
+ import { useModel } from '@zjxpcyc/vue-tiny-store';
|
|
21
|
+
|
|
22
|
+ const { pause } = useModel('audio');
|
|
23
|
+ const animate = ref(false);
|
|
24
|
+
|
|
25
|
+ const el = ref();
|
|
26
|
+
|
|
27
|
+ const toggle = () => {
|
|
28
|
+ if (el.value.paused) {
|
|
29
|
+ el.value.play();
|
|
30
|
+ animate.value = true;
|
|
31
|
+ } else {
|
|
32
|
+ el.value.pause();
|
|
33
|
+ animate.value = false;
|
|
34
|
+ }
|
|
35
|
+ }
|
|
36
|
+
|
|
37
|
+ onMounted(() => {
|
|
38
|
+ // 停掉原来的
|
|
39
|
+ pause();
|
|
40
|
+
|
|
41
|
+ //
|
|
42
|
+ el.value.play();
|
|
43
|
+ });
|
|
44
|
+
|
|
45
|
+</script>
|
|
46
|
+
|
|
47
|
+<style lang="less" scoped>
|
|
48
|
+.bell-box {
|
|
49
|
+ @size: 10vw;
|
|
50
|
+
|
|
51
|
+ width: @size;
|
|
52
|
+ height: @size;
|
|
53
|
+
|
|
54
|
+ & > div {
|
|
55
|
+ width: 100%;
|
|
56
|
+ height: 100%;
|
|
57
|
+ position: relative;
|
|
58
|
+ }
|
|
59
|
+
|
|
60
|
+ .center {
|
|
61
|
+ width: 100%;
|
|
62
|
+ height: 100%;
|
|
63
|
+ display: flex;
|
|
64
|
+ justify-content: center;
|
|
65
|
+ align-items: center;
|
|
66
|
+ }
|
|
67
|
+
|
|
68
|
+ .circle {
|
|
69
|
+ top: 2vw;
|
|
70
|
+ left: 0;
|
|
71
|
+ z-index: 0;
|
|
72
|
+
|
|
73
|
+ & > div {
|
|
74
|
+ flex: none;
|
|
75
|
+ width: 50%;
|
|
76
|
+ height: 50%;
|
|
77
|
+ border-radius: 50%;
|
|
78
|
+ opacity: 0;
|
|
79
|
+ }
|
|
80
|
+
|
|
81
|
+ .circle-ani {
|
|
82
|
+ animation-name: bell-circle-show;
|
|
83
|
+ }
|
|
84
|
+
|
|
85
|
+ .inner {
|
|
86
|
+ border: 2px solid #fff;
|
|
87
|
+ animation-duration: 3s;
|
|
88
|
+ animation-timing-function: linear;
|
|
89
|
+ animation-iteration-count: infinite;
|
|
90
|
+ }
|
|
91
|
+
|
|
92
|
+ .outer {
|
|
93
|
+ border: 2px solid #fff;
|
|
94
|
+ animation-duration: 1.5s;
|
|
95
|
+ animation-timing-function: linear;
|
|
96
|
+ animation-iteration-count: infinite;
|
|
97
|
+ }
|
|
98
|
+
|
|
99
|
+ @keyframes bell-circle-show {
|
|
100
|
+ 0% {
|
|
101
|
+ opacity: 0;
|
|
102
|
+ transform: scale(1);
|
|
103
|
+ }
|
|
104
|
+
|
|
105
|
+ 50% {
|
|
106
|
+ opacity: 1;
|
|
107
|
+ }
|
|
108
|
+
|
|
109
|
+ 100% {
|
|
110
|
+ opacity: 0;
|
|
111
|
+ transform: scale(2.4);
|
|
112
|
+ }
|
|
113
|
+ }
|
|
114
|
+ }
|
|
115
|
+
|
|
116
|
+ .bell-img {
|
|
117
|
+ position: relative;
|
|
118
|
+ z-index: 2;
|
|
119
|
+
|
|
120
|
+ .bell-ani {
|
|
121
|
+ animation-name: bell-shake;
|
|
122
|
+ }
|
|
123
|
+
|
|
124
|
+ img {
|
|
125
|
+ flex: none;
|
|
126
|
+ width: 80%;
|
|
127
|
+
|
|
128
|
+ transform-origin: top center;
|
|
129
|
+ animation-duration: 1.4s;
|
|
130
|
+ animation-timing-function: ease-in-out;
|
|
131
|
+ animation-iteration-count: infinite;
|
|
132
|
+ animation-direction: alternate;
|
|
133
|
+ }
|
|
134
|
+ }
|
|
135
|
+
|
|
136
|
+ @keyframes bell-shake {
|
|
137
|
+ from {
|
|
138
|
+ transform: rotate(15deg);
|
|
139
|
+ }
|
|
140
|
+ to {
|
|
141
|
+ transform: rotate(-15deg);
|
|
142
|
+ }
|
|
143
|
+ }
|
|
144
|
+}
|
|
145
|
+</style>
|