xuePage.vue 4.9 KB

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