xuePage.vue 4.6 KB

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