Showing
1 changed file
with
46 additions
and
21 deletions
| 1 | <!-- | 1 | <!-- |
| 2 | * @Date: 2024-04-10 15:08:08 | 2 | * @Date: 2024-04-10 15:08:08 |
| 3 | * @LastEditors: hookehuyr hookehuyr@gmail.com | 3 | * @LastEditors: hookehuyr hookehuyr@gmail.com |
| 4 | - * @LastEditTime: 2024-04-11 16:56:42 | 4 | + * @LastEditTime: 2024-04-12 13:13:50 |
| 5 | * @FilePath: /fxPark/src/views/fxPark/audio.vue | 5 | * @FilePath: /fxPark/src/views/fxPark/audio.vue |
| 6 | * @Description: 文件描述 | 6 | * @Description: 文件描述 |
| 7 | --> | 7 | --> |
| 8 | <template> | 8 | <template> |
| 9 | <div class="audio-page"> | 9 | <div class="audio-page"> |
| 10 | + <div style="position: absolute; top: 5rem;"> | ||
| 10 | <div class="audio-player"> | 11 | <div class="audio-player"> |
| 11 | - <van-row justify="center" align="center"> | 12 | + <van-row align="center"> |
| 12 | <van-col span="8"> | 13 | <van-col span="8"> |
| 13 | <div> | 14 | <div> |
| 14 | <div style="width: 5rem; height: 5rem; border-radius: 50%;"> | 15 | <div style="width: 5rem; height: 5rem; border-radius: 50%;"> |
| ... | @@ -18,7 +19,7 @@ | ... | @@ -18,7 +19,7 @@ |
| 18 | </van-col> | 19 | </van-col> |
| 19 | <van-col span="16"> | 20 | <van-col span="16"> |
| 20 | <div> | 21 | <div> |
| 21 | - <div class="van-ellipsis" style="margin-bottom: 1rem; color: #fff;">{{ audio_list[audioIndex]['audio_name'] }}</div> | 22 | + <div class="van-ellipsis" style="margin-bottom: 1rem; color: #fff;">{{ audio_list[audioIndex]?.audio_name }}</div> |
| 22 | <div style="display: flex; justify-content: space-between;"> | 23 | <div style="display: flex; justify-content: space-between;"> |
| 23 | <van-icon @click="audioPrev" name="arrow-left" size="1.5rem" /> | 24 | <van-icon @click="audioPrev" name="arrow-left" size="1.5rem" /> |
| 24 | <van-icon v-if="audioStatus === 'pause'" name="play" size="1.5rem" @click="handelPlay" /> | 25 | <van-icon v-if="audioStatus === 'pause'" name="play" size="1.5rem" @click="handelPlay" /> |
| ... | @@ -43,7 +44,11 @@ | ... | @@ -43,7 +44,11 @@ |
| 43 | </div> | 44 | </div> |
| 44 | </div> --> | 45 | </div> --> |
| 45 | <div> | 46 | <div> |
| 46 | - <audio ref="audioPlayer" loop="loop" id="audios" :src="audio_list[audioIndex]['audio_url']" preoload></audio> | 47 | + <audio ref="audioPlayer" loop="loop" id="audios" :src="audio_list[audioIndex]?.audio_url" preoload></audio> |
| 48 | + </div> | ||
| 49 | + </div> | ||
| 50 | + <div style="width: 75vw; height: 15rem; border: 1px solid #fff;"> | ||
| 51 | + <div @click="audioPlay(index)" v-for="(item, index) in audio_list" :key="index">{{ item.audio_name }}</div> | ||
| 47 | </div> | 52 | </div> |
| 48 | </div> | 53 | </div> |
| 49 | </div> | 54 | </div> |
| ... | @@ -57,10 +62,36 @@ import { Cookies, $, _, axios, storeToRefs, mainStore, Toast, useTitle } from '@ | ... | @@ -57,10 +62,36 @@ import { Cookies, $, _, axios, storeToRefs, mainStore, Toast, useTitle } from '@ |
| 57 | //import { } from '@/utils/generateModules.js' | 62 | //import { } from '@/utils/generateModules.js' |
| 58 | //import { } from '@/utils/generateIcons.js' | 63 | //import { } from '@/utils/generateIcons.js' |
| 59 | //import { } from '@/composables' | 64 | //import { } from '@/composables' |
| 65 | +import { getTreeAPI } from '@/api/carbon.js'; | ||
| 66 | + | ||
| 60 | const $route = useRoute(); | 67 | const $route = useRoute(); |
| 61 | const $router = useRouter(); | 68 | const $router = useRouter(); |
| 62 | useTitle($route.meta.title); | 69 | useTitle($route.meta.title); |
| 63 | 70 | ||
| 71 | +const audio_list = ref([]); | ||
| 72 | + | ||
| 73 | +onMounted(async () => { | ||
| 74 | + const { code, data } = await getTreeAPI(); | ||
| 75 | + if (code) { | ||
| 76 | + data.forEach(item => { | ||
| 77 | + if (item.is_tree === 1) { | ||
| 78 | + // audio_list.value.push({ | ||
| 79 | + // audio_url: item.audio_url, | ||
| 80 | + // audio_cover: item.audio_cover, | ||
| 81 | + // audio_name: item.audio_name, | ||
| 82 | + // audio_note: item.audio_note, | ||
| 83 | + // }); | ||
| 84 | + audio_list.value.push({ | ||
| 85 | + audio_url: 'http://downsc.chinaz.net/files/download/sound1/201206/1638.mp3', | ||
| 86 | + audio_cover: 'https://picsum.photos/50/50', | ||
| 87 | + audio_name: item.name + '123456789', | ||
| 88 | + audio_note: item.audio_note, | ||
| 89 | + }); | ||
| 90 | + } | ||
| 91 | + }) | ||
| 92 | + } | ||
| 93 | +}); | ||
| 94 | + | ||
| 64 | const audioPlayer = ref(null); | 95 | const audioPlayer = ref(null); |
| 65 | const audioStatus = ref('pause'); | 96 | const audioStatus = ref('pause'); |
| 66 | const audioIndex = ref(0); | 97 | const audioIndex = ref(0); |
| ... | @@ -75,24 +106,19 @@ const handlePause = () => { | ... | @@ -75,24 +106,19 @@ const handlePause = () => { |
| 75 | audioStatus.value = 'pause'; | 106 | audioStatus.value = 'pause'; |
| 76 | }; | 107 | }; |
| 77 | 108 | ||
| 78 | -const audio_list = ref([{ | ||
| 79 | - audio_url: 'http://downsc.chinaz.net/files/download/sound1/201206/1638.mp3', | ||
| 80 | - audio_cover: '', | ||
| 81 | - audio_name: '微风轻轻吹树叶的声音123467890', | ||
| 82 | - audio_note: '', | ||
| 83 | -}, { | ||
| 84 | - audio_url: 'http://downsc.chinaz.net/Files/DownLoad/sound1/201906/11582.mp3', | ||
| 85 | - audio_cover: '', | ||
| 86 | - audio_name: '微风轻轻吹树叶的声音', | ||
| 87 | - audio_note: '', | ||
| 88 | -}]); | ||
| 89 | - | ||
| 90 | const replay = () => { | 109 | const replay = () => { |
| 91 | audioPlayer.value.currentTime = 0; | 110 | audioPlayer.value.currentTime = 0; |
| 92 | audioPlayer.value.play(); | 111 | audioPlayer.value.play(); |
| 93 | audioStatus.value = 'play'; | 112 | audioStatus.value = 'play'; |
| 94 | } | 113 | } |
| 95 | 114 | ||
| 115 | +const audioPlay = (index) => { | ||
| 116 | + audioIndex.value = index; | ||
| 117 | + nextTick(() => { | ||
| 118 | + replay() | ||
| 119 | + }); | ||
| 120 | +} | ||
| 121 | + | ||
| 96 | const audioPrev = () => { | 122 | const audioPrev = () => { |
| 97 | if (audioIndex.value > 0) { | 123 | if (audioIndex.value > 0) { |
| 98 | audioIndex.value--; | 124 | audioIndex.value--; |
| ... | @@ -126,16 +152,15 @@ const audioNext = () => { | ... | @@ -126,16 +152,15 @@ const audioNext = () => { |
| 126 | background-color: #47A3E4; | 152 | background-color: #47A3E4; |
| 127 | display: flex; | 153 | display: flex; |
| 128 | justify-content: center; | 154 | justify-content: center; |
| 155 | + align-items: center; | ||
| 129 | .audio-player { | 156 | .audio-player { |
| 130 | width: 75vw; | 157 | width: 75vw; |
| 131 | border: 1px solid #fff; | 158 | border: 1px solid #fff; |
| 132 | border-radius: 10px; | 159 | border-radius: 10px; |
| 133 | padding: 1rem 1rem 1rem 1rem; | 160 | padding: 1rem 1rem 1rem 1rem; |
| 134 | - position: absolute; | 161 | + // display: flex; |
| 135 | - top: 5rem; | 162 | + // justify-content: center; |
| 136 | - display: flex; | 163 | + // align-items: center; |
| 137 | - justify-content: center; | ||
| 138 | - align-items: center; | ||
| 139 | .play { | 164 | .play { |
| 140 | animation: rotate 8s linear infinite; | 165 | animation: rotate 8s linear infinite; |
| 141 | } | 166 | } | ... | ... |
-
Please register or login to post a comment