audioBackground1.vue
1.66 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
74
75
76
77
78
<!--
* @Date: 2023-06-12 11:23:10
* @LastEditors: hookehuyr hookehuyr@gmail.com
* @LastEditTime: 2024-09-21 10:57:29
* @FilePath: /map-demo/src/components/audioBackground1.vue
* @Description: 文件描述
-->
<template>
<div v-if="audio_src" class="audio-background-page">
<div @click="handleAudio" :class="['icon', audio_status === 'pause' ? 'play' : 'pause']"></div>
</div>
</template>
<script>
import { mapState, mapActions } from 'pinia'
import { mainStore } from '@/store'
import $ from 'jquery';
export default {
data () {
return {
}
},
mounted () {
},
computed: {
...mapState(mainStore, ['audio_entity', 'audio_src', 'audio_status'])
},
methods: {
...mapActions(mainStore, ['changeAudio', 'changeAudioSrc', 'changeAudioStatus']),
handleAudio () {
if (this.audio_status === 'play') {
this.audio_entity.pause();
this.changeAudioStatus('pause');
} else {
this.audio_entity.play();
this.changeAudioStatus('play');
}
}
}
}
</script>
<style lang="less" scoped>
.audio-background-page {
position: fixed;
right: 1.25rem;
bottom: 17rem;
.icon {
width: 2.5rem;
height: 2.5rem;
border-radius: 50%;
background-size: contain;
}
.play {
background-image: url('https://cdn.ipadbiz.cn/xys/map/%E6%92%AD%E6%94%BE%E6%9A%82%E5%81%9C@2x.png');
}
.pause {
background-image: url('https://cdn.ipadbiz.cn/xys/map/%E6%92%AD%E6%94%BE@2x.png');
animation: rotate 4s linear infinite;
}
@keyframes rotate {
0% {
transform: rotate(0deg);
}
100% {
transform: rotate(360deg);
}
}
.paused {
animation-play-state: paused;
}
}
</style>