mainCard.vue 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. <template>
  2. <swiper class="word-view-swiper-box" :indicator-dots="false" :autoplay="false" :circular="false"
  3. @change="handleSwiperChange" :disable-touch="isPlaying">
  4. <swiper-item>
  5. <view class="swiper-item uni-bg-red">
  6. <xuePage :active-word="activeWord" :active-words="activeWords" @goXiangjie="goXiangjie"
  7. @play-audio="handlePlayAudio" :pageData="pageData"></xuePage>
  8. </view>
  9. </swiper-item>
  10. <swiper-item>
  11. <view class="swiper-item uni-bg-red">
  12. <pinPageVue :active-word="activeWord" :active-words="activeWords" @play-audio="handlePlayAudio">
  13. </pinPageVue>
  14. </view>
  15. </swiper-item>
  16. <swiper-item>
  17. <view class="swiper-item uni-bg-blue">
  18. <readContent :active-word="activeWord" :pageData="pageData" @play-audio="handlePlayAudio"
  19. @luyinSuccess="luyinSuccess" :active-words="activeWords"></readContent>
  20. </view>
  21. </swiper-item>
  22. <swiper-item>
  23. <view class="swiper-item uni-bg-blue">
  24. <selectPageVue :active-word="activeWord" :active-words="activeWords" @play-audio="handlePlayAudio">
  25. </selectPageVue>
  26. </view>
  27. </swiper-item>
  28. <swiper-item>
  29. <view class="swiper-item uni-bg-blue">
  30. <beiPageVue :active-word="activeWord" :pageData="pageData" :active-words="activeWords"
  31. @play-audio="handlePlayAudio"></beiPageVue>
  32. </view>
  33. </swiper-item>
  34. </swiper>
  35. <uni-popup ref="statusPopup" :animation="false" :is-mask-click="false"
  36. mask-background-color="rgba(51, 137, 217, 0.95);">
  37. <view class="ezy-image-dialog luyin">
  38. </view>
  39. </uni-popup>
  40. </template>
  41. <script setup>
  42. import pinPageVue from './pinPage.vue';
  43. import selectPageVue from './selectPage.vue';
  44. import beiPageVue from './beiPage.vue';
  45. import readContent from './readContent.vue';
  46. import xuePage from './xuePage.vue';
  47. import {
  48. ref,
  49. onMounted,
  50. onUnmounted
  51. } from 'vue';
  52. const props = defineProps({
  53. activeWord: {
  54. type: Object,
  55. },
  56. pageData: {
  57. type: Object,
  58. },
  59. activeWords: {
  60. type: Array
  61. },
  62. isPlaying: Boolean // 新增 isPlaying prop
  63. })
  64. const statusPopup = ref(null)
  65. const popupImage = ref('')
  66. const statusAudio = uni.createInnerAudioContext()
  67. const emits = defineEmits(['play-audio', 'goXiangjie', 'swiper-change'])
  68. const luyinSuccess = (imagePath, text, audioPath) => {
  69. console.log('111111');
  70. showStatusPopup('', '录音成功!', '/static/mp3/newYingyu/right-tip.mp3')
  71. }
  72. const showStatusPopup = (imagePath, text, audioPath) => {
  73. console.log('audioPath', audioPath);
  74. // 播放音效
  75. statusAudio.stop()
  76. statusAudio.src = audioPath
  77. statusAudio.play()
  78. // 显示弹窗
  79. statusPopup.value.open()
  80. }
  81. function handleSwiperChange(e) {
  82. emits('swiper-change', e.detail.current)
  83. }
  84. function handlePlayAudio({
  85. url,
  86. code
  87. }) {
  88. emits('play-audio', {
  89. url,
  90. code
  91. })
  92. }
  93. function goXiangjie() {
  94. emits('goXiangjie')
  95. }
  96. onMounted(() => {
  97. statusAudio.autoplay = false
  98. statusAudio.onEnded(() => {
  99. statusPopup.value.close()
  100. })
  101. })
  102. onUnmounted(() => {
  103. statusAudio.destroy()
  104. })
  105. </script>
  106. <style lang="scss" scoped>
  107. </style>