xuePage.vue 4.9 KB

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