mainCard.vue 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  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. <audioRightWrongVue></audioRightWrongVue>
  41. </template>
  42. <script setup>
  43. import pinPageVue from './pinPage.vue';
  44. import selectPageVue from './selectPage.vue';
  45. import beiPageVue from './beiPage.vue';
  46. import readContent from './readContent.vue';
  47. import xuePage from './xuePage.vue';
  48. import audioRightWrongVue from "../components/audioRightWrong.vue";
  49. import {
  50. ref,
  51. onMounted,
  52. onUnmounted
  53. } from 'vue';
  54. const props = defineProps({
  55. activeWord: {
  56. type: Object,
  57. },
  58. pageData: {
  59. type: Object,
  60. },
  61. activeWords: {
  62. type: Array
  63. },
  64. isPlaying: Boolean // 新增 isPlaying prop
  65. })
  66. const statusPopup = ref(null)
  67. const popupImage = ref('')
  68. const statusAudio = uni.createInnerAudioContext()
  69. const emits = defineEmits(['play-audio', 'goXiangjie', 'swiper-change'])
  70. const luyinSuccess = (imagePath, text, audioPath) => {
  71. console.log('111111');
  72. showStatusPopup('', '录音成功!', '/static/mp3/newYingyu/right-tip.mp3')
  73. }
  74. const showStatusPopup = (imagePath, text, audioPath) => {
  75. console.log('audioPath', audioPath);
  76. // 播放音效
  77. statusAudio.stop()
  78. statusAudio.src = audioPath
  79. statusAudio.play()
  80. // 显示弹窗
  81. statusPopup.value.open()
  82. }
  83. function handleSwiperChange(e) {
  84. emits('swiper-change', e.detail.current)
  85. }
  86. function handlePlayAudio({
  87. url,
  88. code
  89. }) {
  90. emits('play-audio', {
  91. url,
  92. code
  93. })
  94. }
  95. function goXiangjie() {
  96. emits('goXiangjie')
  97. }
  98. onMounted(() => {
  99. statusAudio.autoplay = false
  100. statusAudio.onEnded(() => {
  101. statusPopup.value.close()
  102. })
  103. })
  104. onUnmounted(() => {
  105. statusAudio.destroy()
  106. })
  107. </script>
  108. <style lang="scss" scoped>
  109. </style>