xuePage.vue 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  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></view>
  44. <view class="change-btn" :class="{active: data.isPindu}" @click="handleYinjie"><text>音节拆分</text></view>
  45. </view>
  46. <!-- 词根+实用口语 -->
  47. <view v-if="activeWord.cigenzhuji.length" class="details-content-box xue-details-content-box">
  48. <text class="details-title">词根助记</text>
  49. <scroll-view class="cg-item-list" scroll-x @touchmove.stop>
  50. <view class="cg-item-box" v-for="(item,index) in activeWord.cigenzhuji" :key="index">
  51. <view class="cg-item">
  52. <view
  53. :class="{isEven: index% 2 !== 0 && index!==activeWord.cigenzhuji.length-1,isOdd: index% 2 === 0 && index!==activeWord.cigenzhuji.length-1}">
  54. {{item.en}}</view>
  55. <view>{{item.zn}}</view>
  56. </view>
  57. <view class="cg-symbol" v-if="index<activeWord.cigenzhuji.length-2">+</view>
  58. <view class="cg-symbol" v-if="index == activeWord.cigenzhuji.length - 2">=</view>
  59. </view>
  60. </scroll-view>
  61. </view>
  62. <!-- 实用语句 -->
  63. <view class="details-content-box xue-details-content-box">
  64. <text class="details-title">实用口语</text>
  65. <view v-for="(item,index) in activeWord.kouyu" :key="index" class="syky-content">
  66. <view class="details-en-content">
  67. <rich-text :nodes="highlightWord(item.en)"></rich-text>
  68. </view>
  69. <view class="details-cn-content">{{item.zn}}</view>
  70. </view>
  71. </view>
  72. </view>
  73. </view>
  74. </view>
  75. </view>
  76. </template>
  77. <script setup>
  78. import selectTypesVue from './selectTypes.vue';
  79. import audioTwoVue from './audioTwo.vue';
  80. import audioThreeVue from './audioThree.vue';
  81. import audioFourVue from './audioFour.vue';
  82. import yinbiaoTxtVue from "./yinbiaoTxt.vue"
  83. import {
  84. reactive,
  85. computed,
  86. } from 'vue';
  87. import {
  88. getUserIdentity,
  89. } from "@/utils/common.js"
  90. import * as httpApi from "@/api/word.js"
  91. import {
  92. audioPlayer,
  93. useAudioCache
  94. } from './useAudio.js';
  95. const emits = defineEmits(['play-audio','goXiangjie'])
  96. const userCode = getUserIdentity();
  97. const {
  98. cacheAudio,
  99. clearAudioCache
  100. } = useAudioCache();
  101. const data = reactive({
  102. isPlaying: false,
  103. isPindu: true,
  104. })
  105. const props = defineProps({
  106. activeWord: { // 单词数据
  107. type: Object,
  108. },
  109. activeWords: {
  110. type: Array
  111. },
  112. pageData: {
  113. type: Object,
  114. },
  115. })
  116. const highlightWord = (text) => {
  117. if (!text || !props.activeWord.name) {
  118. return text
  119. }
  120. const word = props.activeWord.name;
  121. const regex = new RegExp(word, 'gi');
  122. return text.replace(regex, (match) => {
  123. return `<span style="color: #3a7fe9;">${match}</span>`;
  124. });
  125. }
  126. async function handlePlay(opt) {
  127. emits('play-audio', opt)
  128. }
  129. function handlePindu() {
  130. data.isPindu = true
  131. }
  132. function handleYinjie() {
  133. data.isPindu = false
  134. }
  135. function goXiangjie() {
  136. if (userCode !== 'Visitor') {
  137. uni.redirectTo({
  138. url: '/pages/newEnglish/components/xiangjie?jieId=' + props.pageData.jieId + '&wordId=' + props
  139. .pageData.activeId
  140. })
  141. } else {
  142. emits('goXiangjie')
  143. }
  144. }
  145. </script>
  146. <style>
  147. </style>