Showing
6 changed files
with
65 additions
and
14 deletions
| 1 | <!-- | 1 | <!-- |
| 2 | * @Date: 2023-06-12 11:23:10 | 2 | * @Date: 2023-06-12 11:23:10 |
| 3 | * @LastEditors: hookehuyr hookehuyr@gmail.com | 3 | * @LastEditors: hookehuyr hookehuyr@gmail.com |
| 4 | - * @LastEditTime: 2023-06-12 14:51:13 | 4 | + * @LastEditTime: 2024-09-20 17:40:03 |
| 5 | * @FilePath: /map-demo/src/components/audioBackground.vue | 5 | * @FilePath: /map-demo/src/components/audioBackground.vue |
| 6 | * @Description: 文件描述 | 6 | * @Description: 文件描述 |
| 7 | --> | 7 | --> | ... | ... |
| 1 | /* | 1 | /* |
| 2 | * @Date: 2023-05-29 11:10:19 | 2 | * @Date: 2023-05-29 11:10:19 |
| 3 | * @LastEditors: hookehuyr hookehuyr@gmail.com | 3 | * @LastEditors: hookehuyr hookehuyr@gmail.com |
| 4 | - * @LastEditTime: 2024-09-18 09:38:42 | 4 | + * @LastEditTime: 2024-09-20 17:29:12 |
| 5 | * @FilePath: /map-demo/src/route.js | 5 | * @FilePath: /map-demo/src/route.js |
| 6 | * @Description: 文件描述 | 6 | * @Description: 文件描述 |
| 7 | */ | 7 | */ |
| ... | @@ -64,7 +64,7 @@ export default [ | ... | @@ -64,7 +64,7 @@ export default [ |
| 64 | }, | 64 | }, |
| 65 | { | 65 | { |
| 66 | path: '/bieyuan/info', | 66 | path: '/bieyuan/info', |
| 67 | - component: () => import('@/views/bieyuan/info.vue'), | 67 | + component: () => import('@/views/bieyuan/info_w.vue'), |
| 68 | meta: { | 68 | meta: { |
| 69 | title: '详情页', | 69 | title: '详情页', |
| 70 | }, | 70 | }, | ... | ... |
| 1 | <!-- | 1 | <!-- |
| 2 | * @Date: 2024-09-15 22:08:49 | 2 | * @Date: 2024-09-15 22:08:49 |
| 3 | * @LastEditors: hookehuyr hookehuyr@gmail.com | 3 | * @LastEditors: hookehuyr hookehuyr@gmail.com |
| 4 | - * @LastEditTime: 2024-09-20 15:56:20 | 4 | + * @LastEditTime: 2024-09-20 17:35:46 |
| 5 | * @FilePath: /map-demo/src/views/bieyuan/info.vue | 5 | * @FilePath: /map-demo/src/views/bieyuan/info.vue |
| 6 | * @Description: 文件描述 | 6 | * @Description: 文件描述 |
| 7 | --> | 7 | --> |
| ... | @@ -73,14 +73,14 @@ | ... | @@ -73,14 +73,14 @@ |
| 73 | </div> | 73 | </div> |
| 74 | <div class="van-hairline--bottom" style="margin: 0 1rem;"></div> | 74 | <div class="van-hairline--bottom" style="margin: 0 1rem;"></div> |
| 75 | </div> | 75 | </div> |
| 76 | - <div class="audio-wrapper"> | 76 | + <!--<div class="audio-wrapper"> |
| 77 | <div :class="['audio-item', play_audio_index === index ? 'click' : '']" v-for="(item, index) in audioList" :key="index"> | 77 | <div :class="['audio-item', play_audio_index === index ? 'click' : '']" v-for="(item, index) in audioList" :key="index"> |
| 78 | <div>{{ item.text }}</div> | 78 | <div>{{ item.text }}</div> |
| 79 | - <!-- <div :class="['audio-icon', play_audio_index === index ? 'click' : '']"></div> --> | 79 | + <!~~ <div :class="['audio-icon', play_audio_index === index ? 'click' : '']"></div> ~~> |
| 80 | <van-icon @click="stopAudio(item, index)" v-if="item.play" size="2rem" name="stop-circle-o" color="#DD7850" /> | 80 | <van-icon @click="stopAudio(item, index)" v-if="item.play" size="2rem" name="stop-circle-o" color="#DD7850" /> |
| 81 | <van-icon v-else @click="playAudio(item, index)" size="2rem" name="https://cdn.ipadbiz.cn/bieyuan/map/icon/audio_icon.png" /> | 81 | <van-icon v-else @click="playAudio(item, index)" size="2rem" name="https://cdn.ipadbiz.cn/bieyuan/map/icon/audio_icon.png" /> |
| 82 | </div> | 82 | </div> |
| 83 | - </div> | 83 | + </div>--> |
| 84 | <div style="padding: 0 1rem;"> | 84 | <div style="padding: 0 1rem;"> |
| 85 | <img src="https://cdn.ipadbiz.cn/bieyuan/map/xcx.png" style="width: 100%;"> | 85 | <img src="https://cdn.ipadbiz.cn/bieyuan/map/xcx.png" style="width: 100%;"> |
| 86 | </div> | 86 | </div> |
| ... | @@ -100,9 +100,15 @@ | ... | @@ -100,9 +100,15 @@ |
| 100 | </template> | 100 | </template> |
| 101 | 101 | ||
| 102 | <script setup> | 102 | <script setup> |
| 103 | -import { ref } from 'vue' | 103 | +import { ref, watch } from 'vue' |
| 104 | import { useRoute, useRouter } from 'vue-router' | 104 | import { useRoute, useRouter } from 'vue-router' |
| 105 | 105 | ||
| 106 | +import { storeToRefs } from 'pinia' | ||
| 107 | +import { mainStore } from '@/store'; | ||
| 108 | + | ||
| 109 | +const store = mainStore(); | ||
| 110 | +const { audio_status } = storeToRefs(store); | ||
| 111 | + | ||
| 106 | const $route = useRoute(); | 112 | const $route = useRoute(); |
| 107 | const $router = useRouter(); | 113 | const $router = useRouter(); |
| 108 | 114 | ||
| ... | @@ -121,15 +127,15 @@ const play_audio_index = ref(null); | ... | @@ -121,15 +127,15 @@ const play_audio_index = ref(null); |
| 121 | 127 | ||
| 122 | const audioList = ref([{ | 128 | const audioList = ref([{ |
| 123 | text: '5分钟观呼吸', | 129 | text: '5分钟观呼吸', |
| 124 | - src: 'https://cdn.ipadbiz.cn/bieyuan/map/1130958712.mp3', | 130 | + src: 'https://cdn.ipadbiz.cn/bieyuan/map/audio/%E6%AD%A3%E5%BF%B5%E5%91%BC%E5%90%B8%EF%BC%8810%E5%88%86%E9%92%9F%EF%BC%89.mp3', |
| 125 | play: false, | 131 | play: false, |
| 126 | }, { | 132 | }, { |
| 127 | text: '10分钟正念静坐', | 133 | text: '10分钟正念静坐', |
| 128 | - src: 'https://cdn.ipadbiz.cn/bieyuan/map/1130958712.mp3', | 134 | + src: 'https://cdn.ipadbiz.cn/bieyuan/map/audio/%E5%8D%81%E5%88%86%E9%92%9F%E6%AD%A3%E5%BF%B5%E9%9D%99%E5%9D%9020210510.mp3', |
| 129 | play: false, | 135 | play: false, |
| 130 | }, { | 136 | }, { |
| 131 | text: '15分钟正念静坐', | 137 | text: '15分钟正念静坐', |
| 132 | - src: 'https://cdn.ipadbiz.cn/bieyuan/map/1130958712.mp3', | 138 | + src: 'https://cdn.ipadbiz.cn/bieyuan/map/audio/%E5%8D%81%E5%88%86%E9%92%9F%E6%AD%A3%E5%BF%B5%E9%9D%99%E5%9D%9020210510.mp3', |
| 133 | play: false, | 139 | play: false, |
| 134 | }]) | 140 | }]) |
| 135 | 141 | ||
| ... | @@ -143,6 +149,9 @@ const playAudio = (item, index) => { | ... | @@ -143,6 +149,9 @@ const playAudio = (item, index) => { |
| 143 | play_status.then(() => { | 149 | play_status.then(() => { |
| 144 | console.warn('success'); | 150 | console.warn('success'); |
| 145 | item.play = true; | 151 | item.play = true; |
| 152 | + // 存放到pinia里面控制 | ||
| 153 | + store.changeAudioSrc(audio.value.src); | ||
| 154 | + store.changeAudioStatus('play'); | ||
| 146 | }).catch((e) => { | 155 | }).catch((e) => { |
| 147 | // 失败 | 156 | // 失败 |
| 148 | console.log('Operation is too fast, audio play fails') | 157 | console.log('Operation is too fast, audio play fails') |
| ... | @@ -157,6 +166,19 @@ const stopAudio = (item, index) => { | ... | @@ -157,6 +166,19 @@ const stopAudio = (item, index) => { |
| 157 | 166 | ||
| 158 | const audio = ref(new Audio()); | 167 | const audio = ref(new Audio()); |
| 159 | 168 | ||
| 169 | +onMounted(() => { | ||
| 170 | + // 存放到pinia里面控制 | ||
| 171 | + if (store.changeAudio(audio.value)){ | ||
| 172 | + store.changeAudio(audio.value); | ||
| 173 | + store.changeAudioStatus('pause'); | ||
| 174 | + } | ||
| 175 | +}) | ||
| 176 | + | ||
| 177 | +// onUnmounted(() => { | ||
| 178 | +// audio.value.pause(); | ||
| 179 | +// store.changeAudioStatus('pause'); | ||
| 180 | +// }) | ||
| 181 | + | ||
| 160 | const audio_play = (src, index) => { | 182 | const audio_play = (src, index) => { |
| 161 | audio.value.src = src; | 183 | audio.value.src = src; |
| 162 | } | 184 | } |
| ... | @@ -183,6 +205,22 @@ const goTo = () => { // 打开标记地图显示 | ... | @@ -183,6 +205,22 @@ const goTo = () => { // 打开标记地图显示 |
| 183 | } | 205 | } |
| 184 | } | 206 | } |
| 185 | 207 | ||
| 208 | +const voicePause = () => { | ||
| 209 | + audio.value.pause(); | ||
| 210 | + store.changeAudioStatus('pause'); | ||
| 211 | +} | ||
| 212 | + | ||
| 213 | +watch( | ||
| 214 | + () => audio_status.value, | ||
| 215 | + (v) => { | ||
| 216 | + if (v === 'pause') { | ||
| 217 | + voicePause(); | ||
| 218 | + audioList.value.forEach(item => item.play = false); | ||
| 219 | + } | ||
| 220 | + }, | ||
| 221 | + { immediate: true } | ||
| 222 | +); | ||
| 223 | + | ||
| 186 | defineExpose({ | 224 | defineExpose({ |
| 187 | outerStopAudio | 225 | outerStopAudio |
| 188 | }) | 226 | }) | ... | ... |
src/views/bieyuan/info_w.vue
0 → 100644
This diff is collapsed. Click to expand it.
| 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: 2024-09-20 16:14:21 | 4 | + * @LastEditTime: 2024-09-20 17:45:35 |
| 5 | * @FilePath: /map-demo/src/views/bieyuan/map.vue | 5 | * @FilePath: /map-demo/src/views/bieyuan/map.vue |
| 6 | * @Description: 公众地图主体页面 | 6 | * @Description: 公众地图主体页面 |
| 7 | --> | 7 | --> |
| ... | @@ -56,6 +56,8 @@ | ... | @@ -56,6 +56,8 @@ |
| 56 | <van-dialog v-model:show="dialog_show" title="温馨提示"> | 56 | <van-dialog v-model:show="dialog_show" title="温馨提示"> |
| 57 | <div style="padding: 1rem; text-align: center;">{{ dialog_text }}</div> | 57 | <div style="padding: 1rem; text-align: center;">{{ dialog_text }}</div> |
| 58 | </van-dialog> | 58 | </van-dialog> |
| 59 | + | ||
| 60 | + <!-- <audioBackground></audioBackground> --> | ||
| 59 | </div> | 61 | </div> |
| 60 | </template> | 62 | </template> |
| 61 | 63 | ||
| ... | @@ -70,6 +72,9 @@ import { useRect } from '@vant/use'; | ... | @@ -70,6 +72,9 @@ import { useRect } from '@vant/use'; |
| 70 | import { mapAPI } from '@/api/map.js' | 72 | import { mapAPI } from '@/api/map.js' |
| 71 | import wx from 'weixin-js-sdk' | 73 | import wx from 'weixin-js-sdk' |
| 72 | import pageInfo from '@/views/bieyuan/info.vue' | 74 | import pageInfo from '@/views/bieyuan/info.vue' |
| 75 | +import audioBackground from '@/components/audioBackground' | ||
| 76 | +import { mapState, mapActions } from 'pinia' | ||
| 77 | +import { mainStore } from '@/store' | ||
| 73 | 78 | ||
| 74 | const GPS = { | 79 | const GPS = { |
| 75 | PI: 3.14159265358979324, | 80 | PI: 3.14159265358979324, |
| ... | @@ -128,7 +133,7 @@ const GPS = { | ... | @@ -128,7 +133,7 @@ const GPS = { |
| 128 | }; | 133 | }; |
| 129 | 134 | ||
| 130 | export default { | 135 | export default { |
| 131 | - components: { pageInfo }, | 136 | + components: { pageInfo, audioBackground }, |
| 132 | data() { | 137 | data() { |
| 133 | return { | 138 | return { |
| 134 | map: '', | 139 | map: '', |
| ... | @@ -257,7 +262,11 @@ export default { | ... | @@ -257,7 +262,11 @@ export default { |
| 257 | // deep: true // 如果 query 是嵌套对象,可以设置 deep 监听深层变化 | 262 | // deep: true // 如果 query 是嵌套对象,可以设置 deep 监听深层变化 |
| 258 | // } | 263 | // } |
| 259 | }, | 264 | }, |
| 265 | + computed: { | ||
| 266 | + ...mapState(mainStore, ['audio_entity', 'audio_src', 'audio_status']) | ||
| 267 | + }, | ||
| 260 | methods: { | 268 | methods: { |
| 269 | + ...mapActions(mainStore, ['changeAudio', 'changeAudioSrc', 'changeAudioStatus']), | ||
| 261 | initMap() { | 270 | initMap() { |
| 262 | // 初始化地图 | 271 | // 初始化地图 |
| 263 | this.map = new AMap.Map('container', { | 272 | this.map = new AMap.Map('container', { |
| ... | @@ -609,6 +618,10 @@ export default { | ... | @@ -609,6 +618,10 @@ export default { |
| 609 | // // 浮动面板样式 | 618 | // // 浮动面板样式 |
| 610 | // $('.van-floating-panel__content').css('borderRadius', '0'); | 619 | // $('.van-floating-panel__content').css('borderRadius', '0'); |
| 611 | // this.showClose = true; | 620 | // this.showClose = true; |
| 621 | + // 清空设置 | ||
| 622 | + // this.changeAudio(''); | ||
| 623 | + // this.changeAudioStatus('pause'); | ||
| 624 | + // | ||
| 612 | this.$router.push({ | 625 | this.$router.push({ |
| 613 | path: '/bieyuan/info', | 626 | path: '/bieyuan/info', |
| 614 | query: { | 627 | query: { | ... | ... |
| 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: 2024-09-12 16:28:53 | 4 | + * @LastEditTime: 2024-09-20 16:30:49 |
| 5 | * @FilePath: /map-demo/src/views/index.vue | 5 | * @FilePath: /map-demo/src/views/index.vue |
| 6 | * @Description: 公众地图主体页面 | 6 | * @Description: 公众地图主体页面 |
| 7 | --> | 7 | --> | ... | ... |
-
Please register or login to post a comment