xuePage.vue 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. <template>
  2. <view class="words-xue-box">
  3. <selectTypesVue activeSelect="1"></selectTypesVue>
  4. <view class="words-xue-body">
  5. <!-- 单词区 -->
  6. <view class="word-circle-box">
  7. <text v-for="(item,index) in activeWord.chaifen" :key="index">{{item}}</text>
  8. </view>
  9. <view class="word-block-box">
  10. <text v-for="(item,index) in activeWord.chaifen" :key="index">{{item}}</text>
  11. </view>
  12. <!-- 音标区 -->
  13. <view class="yb-play-box xue-yb-play-box">
  14. <yinbiaoTxtVue :yinbiao="activeWord.yinbiao"></yinbiaoTxtVue>
  15. <!-- 音频播放 -->
  16. <audioTwoVue :active-word="activeWord" @play-audio="handlePlay"></audioTwoVue>
  17. </view>
  18. <!-- 注释区 -->
  19. <view class="pin-words-explain-box xue-words-explain-box">
  20. <view class="words-explain-item" v-for="item in activeWord.jianyi" :key="item">{{item}}</view>
  21. </view>
  22. <!-- 详解触发 -->
  23. <view @click="goXiangjie" class="details-btn">详解 ></view>
  24. <!-- 音标拆分区 -->
  25. <view v-if="data.isPindu" class="word-block-box yb-block-box">
  26. <!-- pindu -->
  27. <audioThreeVue v-for="(item,index) in activeWord.pindu" :key="index" :YItem="item" @play-audio="handlePlay"></audioThreeVue>
  28. </view>
  29. <view v-else class="yj-block-box">
  30. <!-- yinjie -->
  31. <audioFourVue v-for="(item,index) in activeWord.yinjie" :key="index" :YItem="item" @play-audio="handlePlay"></audioFourVue>
  32. </view>
  33. <!-- 音标按钮 -->
  34. <view class="xue-change-btn-box">
  35. <view class="change-btn" :class="{active: data.isPindu}" @click="handlePindu"><text>自然拼读</text></view>
  36. <view class="change-btn" :class="{active: !data.isPindu}" @click="handleYinjie"><text>音节拆分</text></view>
  37. </view>
  38. <!-- 词根+实用口语 -->
  39. <view v-if="activeWord.cigenzhuji.length" class="details-content-box xue-details-content-box">
  40. <text class="details-title">词根助记</text>
  41. <scroll-view class="cg-item-list" scroll-x @touchmove.stop >
  42. <view class="cg-item-box" v-for="(item,index) in activeWord.cigenzhuji" :key="index" >
  43. <view class="cg-item">
  44. <view>{{item.en}}</view>
  45. <view>{{item.zn}}</view>
  46. </view>
  47. <view class="cg-symbol" v-if="index<activeWord.cigenzhuji.length-2">+</view>
  48. <view class="cg-symbol" v-if="index == activeWord.cigenzhuji.length - 2">=</view>
  49. </view>
  50. </scroll-view>
  51. </view>
  52. <!-- 实用语句 -->
  53. <view class="details-content-box xue-details-content-box">
  54. <text class="details-title">实用口语</text>
  55. <view v-for="(item,index) in activeWord.kouyu" :key="index" class="syky-content">
  56. <view class="details-en-content">
  57. <rich-text :nodes="highlightWord(item.en)"></rich-text>
  58. </view>
  59. <view class="details-cn-content">{{item.zn}}</view>
  60. </view>
  61. </view>
  62. </view>
  63. </view>
  64. </template>
  65. <script setup>
  66. import selectTypesVue from './selectTypes.vue';
  67. import audioTwoVue from './audioTwo.vue';
  68. import audioThreeVue from './audioThree.vue';
  69. import audioFourVue from './audioFour.vue';
  70. import yinbiaoTxtVue from "./yinbiaoTxt.vue"
  71. import {
  72. reactive,
  73. computed,
  74. } from 'vue';
  75. import {
  76. getUserIdentity,
  77. } from "@/utils/common.js"
  78. import * as httpApi from "@/api/word.js"
  79. import {
  80. audioPlayer,
  81. useAudioCache
  82. } from './useAudio.js';
  83. const emits = defineEmits(['play-audio'])
  84. const {
  85. cacheAudio,
  86. clearAudioCache
  87. } = useAudioCache();
  88. const data = reactive({
  89. isPlaying:false,
  90. isPindu:true,
  91. })
  92. const userCode = getUserIdentity();
  93. const props = defineProps({
  94. activeWord: { // 单词数据
  95. type: Object,
  96. },
  97. activeWords: {
  98. type: Array
  99. },
  100. pageData: {
  101. type: Object,
  102. },
  103. })
  104. const highlightWord = (text) => {
  105. if (!text || !props.activeWord.name){return text}
  106. const word = props.activeWord.name;
  107. const regex = new RegExp(word, 'gi');
  108. return text.replace(regex, (match) => {
  109. return `<span style="color: #3a7fe9;">${match}</span>`;
  110. });
  111. }
  112. async function handlePlay(opt) {
  113. emits('play-audio', opt)
  114. }
  115. function handlePindu() {
  116. data.isPindu = true
  117. }
  118. function handleYinjie() {
  119. data.isPindu = false
  120. }
  121. function goXiangjie() {
  122. uni.redirectTo({
  123. url: '/pages/newEnglish/components/xiangjie?jieId='+props.pageData.jieId+'&wordId='+props.pageData.activeId
  124. })
  125. }
  126. </script>
  127. <style>
  128. </style>