12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758 |
- <template>
- <text @click="handlePlay">
- {{YItem.cigen}}
- </text>
- </template>
- <script setup>
- // pindu
- import {
- reactive,
- computed,
- onUnmounted
- } from 'vue';
- import {
- onLoad
- } from "@dcloudio/uni-app"
- const props = defineProps({
- YItem: {
- type: Object,
- },
- })
- const emits = defineEmits(['play-audio'])
- const data = reactive({
- code: null
- })
- onLoad(() => {
- uni.$on('danci-audio-ended', (code) => {
- data.isPlaying = false;
- })
- uni.$on('danci-audio-play', (code) => {
- if (data.code == code) {
- data.isPlaying = true;
- } else {
- data.isPlaying = false;
- }
- })
- })
- onUnmounted(() => {
- uni.$off('danci-audio-ended')
- uni.$off('danci-audio-play')
- })
- function handlePlay() {
- data.code = new Date().getTime()
- emits('play-audio', {
- url: props.YItem.yinpin,
- code: data.code
- })
- }
- </script>
- <style>
- </style>
|