Showing
5 changed files
with
121 additions
and
6 deletions
| ... | @@ -9,13 +9,18 @@ export {} | ... | @@ -9,13 +9,18 @@ export {} |
| 9 | 9 | ||
| 10 | declare module '@vue/runtime-core' { | 10 | declare module '@vue/runtime-core' { |
| 11 | export interface GlobalComponents { | 11 | export interface GlobalComponents { |
| 12 | + AudioBackground: typeof import('./src/components/audioBackground.vue')['default'] | ||
| 12 | InfoWindow: typeof import('./src/components/InfoWindow.vue')['default'] | 13 | InfoWindow: typeof import('./src/components/InfoWindow.vue')['default'] |
| 13 | InfoWindowLite: typeof import('./src/components/InfoWindowLite.vue')['default'] | 14 | InfoWindowLite: typeof import('./src/components/InfoWindowLite.vue')['default'] |
| 14 | InfoWindowWarn: typeof import('./src/components/InfoWindowWarn.vue')['default'] | 15 | InfoWindowWarn: typeof import('./src/components/InfoWindowWarn.vue')['default'] |
| 15 | RouterLink: typeof import('vue-router')['RouterLink'] | 16 | RouterLink: typeof import('vue-router')['RouterLink'] |
| 16 | RouterView: typeof import('vue-router')['RouterView'] | 17 | RouterView: typeof import('vue-router')['RouterView'] |
| 18 | + VanCol: typeof import('vant/es')['Col'] | ||
| 17 | VanDialog: typeof import('vant/es')['Dialog'] | 19 | VanDialog: typeof import('vant/es')['Dialog'] |
| 18 | VanIcon: typeof import('vant/es')['Icon'] | 20 | VanIcon: typeof import('vant/es')['Icon'] |
| 19 | VanPopup: typeof import('vant/es')['Popup'] | 21 | VanPopup: typeof import('vant/es')['Popup'] |
| 22 | + VanRow: typeof import('vant/es')['Row'] | ||
| 23 | + VanTab: typeof import('vant/es')['Tab'] | ||
| 24 | + VanTabs: typeof import('vant/es')['Tabs'] | ||
| 20 | } | 25 | } |
| 21 | } | 26 | } | ... | ... |
| ... | @@ -64,6 +64,8 @@ | ... | @@ -64,6 +64,8 @@ |
| 64 | 64 | ||
| 65 | <script> | 65 | <script> |
| 66 | import $ from 'jquery' | 66 | import $ from 'jquery' |
| 67 | +import { mapState, mapActions } from 'pinia' | ||
| 68 | +import { mainStore } from '@/store' | ||
| 67 | 69 | ||
| 68 | export default { | 70 | export default { |
| 69 | props: { | 71 | props: { |
| ... | @@ -82,12 +84,17 @@ export default { | ... | @@ -82,12 +84,17 @@ export default { |
| 82 | }, | 84 | }, |
| 83 | mounted() { | 85 | mounted() { |
| 84 | }, | 86 | }, |
| 87 | + computed: { | ||
| 88 | + ...mapState(mainStore, ['audio_entity', 'audio_src', 'audio_status']) | ||
| 89 | + }, | ||
| 85 | watch: { | 90 | watch: { |
| 86 | rect(val) { | 91 | rect(val) { |
| 87 | this.widow_info = val; | 92 | this.widow_info = val; |
| 88 | }, | 93 | }, |
| 89 | infoWindow(val) { | 94 | infoWindow(val) { |
| 90 | if (val) { | 95 | if (val) { |
| 96 | + // 存放到pinia里面控制 | ||
| 97 | + this.changeAudio(this.audio); | ||
| 91 | // 加载录音 | 98 | // 加载录音 |
| 92 | this.audio.src = this.info?.details[this.isActive]['audio']; | 99 | this.audio.src = this.info?.details[this.isActive]['audio']; |
| 93 | let play_status = this.audio.play() // 播放 | 100 | let play_status = this.audio.play() // 播放 |
| ... | @@ -102,6 +109,11 @@ export default { | ... | @@ -102,6 +109,11 @@ export default { |
| 102 | }) | 109 | }) |
| 103 | } | 110 | } |
| 104 | } | 111 | } |
| 112 | + }, | ||
| 113 | + audio_status (v) { | ||
| 114 | + if (v === 'pause') { | ||
| 115 | + this.voice_pause() | ||
| 116 | + } | ||
| 105 | } | 117 | } |
| 106 | }, | 118 | }, |
| 107 | data() { | 119 | data() { |
| ... | @@ -120,6 +132,7 @@ export default { | ... | @@ -120,6 +132,7 @@ export default { |
| 120 | } | 132 | } |
| 121 | }, | 133 | }, |
| 122 | methods: { | 134 | methods: { |
| 135 | + ...mapActions(mainStore, ['changeAudio', 'changeAudioSrc', 'changeAudioStatus']), | ||
| 123 | getAudioTime(audio) { | 136 | getAudioTime(audio) { |
| 124 | let time = Math.floor(audio); | 137 | let time = Math.floor(audio); |
| 125 | var minute = time / 60; | 138 | var minute = time / 60; |
| ... | @@ -149,8 +162,9 @@ export default { | ... | @@ -149,8 +162,9 @@ export default { |
| 149 | // 高德地图信息窗关闭的api | 162 | // 高德地图信息窗关闭的api |
| 150 | this.infoWindow.close() | 163 | this.infoWindow.close() |
| 151 | // 处理音频 | 164 | // 处理音频 |
| 152 | - this.voice_pause(); | 165 | + // TAG:临时屏蔽关闭窗口暂停音频播放测试 |
| 153 | - this.audio.currentTime = 0 | 166 | + // this.voice_pause(); |
| 167 | + // this.audio.currentTime = 0 | ||
| 154 | // 默认选中项 | 168 | // 默认选中项 |
| 155 | this.isActive = 0; | 169 | this.isActive = 0; |
| 156 | // 滚动状态 | 170 | // 滚动状态 |
| ... | @@ -164,9 +178,12 @@ export default { | ... | @@ -164,9 +178,12 @@ export default { |
| 164 | }, | 178 | }, |
| 165 | play() { | 179 | play() { |
| 166 | this.voice_play(this.info.details[this.isActive]['audio'], 0) | 180 | this.voice_play(this.info.details[this.isActive]['audio'], 0) |
| 181 | + this.changeAudioSrc(this.audio.src); | ||
| 182 | + this.changeAudioStatus('play'); | ||
| 167 | }, | 183 | }, |
| 168 | pause() { | 184 | pause() { |
| 169 | - this.voice_pause() | 185 | + this.voice_pause(); |
| 186 | + this.changeAudioStatus('pause'); | ||
| 170 | }, | 187 | }, |
| 171 | // 声音播放 | 188 | // 声音播放 |
| 172 | voice_play(src, index) { | 189 | voice_play(src, index) { | ... | ... |
src/components/audioBackground.vue
0 → 100644
| 1 | +<!-- | ||
| 2 | + * @Date: 2023-06-12 11:23:10 | ||
| 3 | + * @LastEditors: hookehuyr hookehuyr@gmail.com | ||
| 4 | + * @LastEditTime: 2023-06-12 14:51:13 | ||
| 5 | + * @FilePath: /map-demo/src/components/audioBackground.vue | ||
| 6 | + * @Description: 文件描述 | ||
| 7 | +--> | ||
| 8 | +<template> | ||
| 9 | + <div v-if="audio_src" class="audio-background-page"> | ||
| 10 | + <div @click="handleAudio" :class="['icon', audio_status === 'pause' ? 'play' : 'pause']"></div> | ||
| 11 | + </div> | ||
| 12 | +</template> | ||
| 13 | + | ||
| 14 | +<script> | ||
| 15 | +import { mapState, mapActions } from 'pinia' | ||
| 16 | +import { mainStore } from '@/store' | ||
| 17 | +import $ from 'jquery'; | ||
| 18 | + | ||
| 19 | +export default { | ||
| 20 | + data () { | ||
| 21 | + return { | ||
| 22 | + } | ||
| 23 | + }, | ||
| 24 | + mounted () { | ||
| 25 | + | ||
| 26 | + }, | ||
| 27 | + computed: { | ||
| 28 | + ...mapState(mainStore, ['audio_entity', 'audio_src', 'audio_status']) | ||
| 29 | + }, | ||
| 30 | + methods: { | ||
| 31 | + ...mapActions(mainStore, ['changeAudio', 'changeAudioSrc', 'changeAudioStatus']), | ||
| 32 | + handleAudio () { | ||
| 33 | + if (this.audio_status === 'play') { | ||
| 34 | + this.audio_entity.pause(); | ||
| 35 | + this.changeAudioStatus('pause'); | ||
| 36 | + } else { | ||
| 37 | + this.audio_entity.play(); | ||
| 38 | + this.changeAudioStatus('play'); | ||
| 39 | + } | ||
| 40 | + } | ||
| 41 | + } | ||
| 42 | +} | ||
| 43 | +</script> | ||
| 44 | + | ||
| 45 | +<style lang="less" scoped> | ||
| 46 | +.audio-background-page { | ||
| 47 | + position: fixed; | ||
| 48 | + right: 1.25rem; | ||
| 49 | + bottom: 7rem; | ||
| 50 | + .icon { | ||
| 51 | + width: 2.5rem; | ||
| 52 | + height: 2.5rem; | ||
| 53 | + border-radius: 50%; | ||
| 54 | + background-size: contain; | ||
| 55 | + } | ||
| 56 | + | ||
| 57 | + .play { | ||
| 58 | + background-image: url('https://cdn.ipadbiz.cn/xys/map/%E6%92%AD%E6%94%BE%E6%9A%82%E5%81%9C@2x.png'); | ||
| 59 | + } | ||
| 60 | + .pause { | ||
| 61 | + background-image: url('https://cdn.ipadbiz.cn/xys/map/%E6%92%AD%E6%94%BE@2x.png'); | ||
| 62 | + animation: rotate 4s linear infinite; | ||
| 63 | + } | ||
| 64 | + | ||
| 65 | + @keyframes rotate { | ||
| 66 | + 0% { | ||
| 67 | + transform: rotate(0deg); | ||
| 68 | + } | ||
| 69 | + 100% { | ||
| 70 | + transform: rotate(360deg); | ||
| 71 | + } | ||
| 72 | + } | ||
| 73 | + | ||
| 74 | + .paused { | ||
| 75 | + animation-play-state: paused; | ||
| 76 | + } | ||
| 77 | +} | ||
| 78 | +</style> |
| 1 | /* | 1 | /* |
| 2 | * @Date: 2022-04-18 15:59:42 | 2 | * @Date: 2022-04-18 15:59:42 |
| 3 | * @LastEditors: hookehuyr hookehuyr@gmail.com | 3 | * @LastEditors: hookehuyr hookehuyr@gmail.com |
| 4 | - * @LastEditTime: 2022-06-13 11:30:40 | 4 | + * @LastEditTime: 2023-06-12 14:50:57 |
| 5 | - * @FilePath: /tswj/src/store/index.js | 5 | + * @FilePath: /map-demo/src/store/index.js |
| 6 | * @Description: 文件描述 | 6 | * @Description: 文件描述 |
| 7 | */ | 7 | */ |
| 8 | import { defineStore } from 'pinia'; | 8 | import { defineStore } from 'pinia'; |
| ... | @@ -23,6 +23,9 @@ export const mainStore = defineStore('main', { | ... | @@ -23,6 +23,9 @@ export const mainStore = defineStore('main', { |
| 23 | scrollTopLike: 0, | 23 | scrollTopLike: 0, |
| 24 | scrollTopPerson: 0, | 24 | scrollTopPerson: 0, |
| 25 | keepPages: ['default'], // 很坑爹,空值全部都缓存 | 25 | keepPages: ['default'], // 很坑爹,空值全部都缓存 |
| 26 | + audio_entity: '', | ||
| 27 | + audio_src: '', | ||
| 28 | + audio_status: 'pause', | ||
| 26 | }; | 29 | }; |
| 27 | }, | 30 | }, |
| 28 | getters: { | 31 | getters: { |
| ... | @@ -67,6 +70,15 @@ export const mainStore = defineStore('main', { | ... | @@ -67,6 +70,15 @@ export const mainStore = defineStore('main', { |
| 67 | const $router = useRouter(); | 70 | const $router = useRouter(); |
| 68 | const page = $router.currentRoute.value.meta.name; | 71 | const page = $router.currentRoute.value.meta.name; |
| 69 | _.remove(this.keepPages, item => item === page) | 72 | _.remove(this.keepPages, item => item === page) |
| 73 | + }, | ||
| 74 | + changeAudio (v) { | ||
| 75 | + this.audio_entity = v; | ||
| 76 | + }, | ||
| 77 | + changeAudioSrc (v) { | ||
| 78 | + this.audio_src = v | ||
| 79 | + }, | ||
| 80 | + changeAudioStatus (v) { | ||
| 81 | + this.audio_status = v; | ||
| 70 | } | 82 | } |
| 71 | }, | 83 | }, |
| 72 | }); | 84 | }); | ... | ... |
| 1 | <!-- | 1 | <!-- |
| 2 | * @Date: 2023-05-19 14:54:27 | 2 | * @Date: 2023-05-19 14:54:27 |
| 3 | * @LastEditors: hookehuyr hookehuyr@gmail.com | 3 | * @LastEditors: hookehuyr hookehuyr@gmail.com |
| 4 | - * @LastEditTime: 2023-06-12 10:38:39 | 4 | + * @LastEditTime: 2023-06-12 14:04:04 |
| 5 | * @FilePath: /map-demo/src/views/index.vue | 5 | * @FilePath: /map-demo/src/views/index.vue |
| 6 | * @Description: 地图主体页面 | 6 | * @Description: 地图主体页面 |
| 7 | --> | 7 | --> |
| ... | @@ -80,6 +80,8 @@ | ... | @@ -80,6 +80,8 @@ |
| 80 | :rect="rect"></InfoWindowLite> | 80 | :rect="rect"></InfoWindowLite> |
| 81 | <InfoWindowWarn v-show="showInfoWindowWarn" ref="infoWindowWarn" :info-window="infoWindowWarn" :info="itemInfo" | 81 | <InfoWindowWarn v-show="showInfoWindowWarn" ref="infoWindowWarn" :info-window="infoWindowWarn" :info="itemInfo" |
| 82 | :rect="rect"></InfoWindowWarn> | 82 | :rect="rect"></InfoWindowWarn> |
| 83 | + | ||
| 84 | + <audioBackground></audioBackground> | ||
| 83 | </div> | 85 | </div> |
| 84 | </template> | 86 | </template> |
| 85 | 87 | ||
| ... | @@ -92,6 +94,7 @@ import $ from 'jquery'; | ... | @@ -92,6 +94,7 @@ import $ from 'jquery'; |
| 92 | import InfoWindow from '@/components/InfoWindow' | 94 | import InfoWindow from '@/components/InfoWindow' |
| 93 | import InfoWindowLite from '@/components/InfoWindowLite' | 95 | import InfoWindowLite from '@/components/InfoWindowLite' |
| 94 | import InfoWindowWarn from '@/components/InfoWindowWarn' | 96 | import InfoWindowWarn from '@/components/InfoWindowWarn' |
| 97 | +import audioBackground from '@/components/audioBackground' | ||
| 95 | import { useRect } from '@vant/use'; | 98 | import { useRect } from '@vant/use'; |
| 96 | 99 | ||
| 97 | const GPS = { | 100 | const GPS = { | ... | ... |
-
Please register or login to post a comment