beiPage.vue 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215
  1. <!-- 单词区 && 音标区:最多15位,超过隐藏-->
  2. <!-- 单音节最长:swimming 多音节最长:transportation -->
  3. <template>
  4. <!-- 显示区 -->
  5. <!-- <selectTypesVue activeSelect="5"></selectTypesVue>-->
  6. <view class="ezy-border-body">
  7. <view class="words-bei-box">
  8. <!-- 输入区 -->
  9. <input class="words-answer-box" placeholder="请输入答案" v-model.trim="data.answer" readonly
  10. :class="{'words-answer-right-box': data.result&&data.result!=null, 'words-answer-error-box': !data.result&&data.result!=null}" />
  11. <!-- 清空按钮 -->
  12. <view class="clean-btn" @click="handleReset('all')" v-if="data.answer.length"></view>
  13. <view class="bei-body-box">
  14. <!-- 解释区 -->
  15. <view class="pin-words-explain-box">
  16. <view class="words-explain-item" v-for="item in activeWord.jianyi" :key="item">{{item}}</view>
  17. </view>
  18. <!-- 播放和待播 -->
  19. <audioOneVue :active-word="activeWord" @play-audio="handlePlay"></audioOneVue>
  20. </view>
  21. <!-- 浮层输入区 -->
  22. <view class="words-keyboard-box">
  23. <view class="keyboard-row">
  24. <template v-if="!isDaxie">
  25. <btnTxtVue @text-select="handleSelect('a')">a</btnTxtVue>
  26. <btnTxtVue @text-select="handleSelect('b')">b</btnTxtVue>
  27. <btnTxtVue @text-select="handleSelect('c')">c</btnTxtVue>
  28. <btnTxtVue @text-select="handleSelect('d')">d</btnTxtVue>
  29. <btnTxtVue @text-select="handleSelect('e')">e</btnTxtVue>
  30. <btnTxtVue @text-select="handleSelect('f')">f</btnTxtVue>
  31. <btnTxtVue @text-select="handleSelect('g')">g</btnTxtVue>
  32. <btnTxtVue @text-select="handleSelect('h')">h</btnTxtVue>
  33. <btnTxtVue @text-select="handleSelect('i')">i</btnTxtVue>
  34. </template>
  35. <template v-else>
  36. <btnTxtVue @text-select="handleSelect('A')">A</btnTxtVue>
  37. <btnTxtVue @text-select="handleSelect('B')">B</btnTxtVue>
  38. <btnTxtVue @text-select="handleSelect('C')">C</btnTxtVue>
  39. <btnTxtVue @text-select="handleSelect('D')">D</btnTxtVue>
  40. <btnTxtVue @text-select="handleSelect('E')">E</btnTxtVue>
  41. <btnTxtVue @text-select="handleSelect('F')">F</btnTxtVue>
  42. <btnTxtVue @text-select="handleSelect('G')">G</btnTxtVue>
  43. <btnTxtVue @text-select="handleSelect('H')">H</btnTxtVue>
  44. <btnTxtVue @text-select="handleSelect('I')">I</btnTxtVue>
  45. </template>
  46. </view>
  47. <view class="keyboard-row">
  48. <template v-if="!isDaxie">
  49. <btnTxtVue @text-select="handleSelect('j')">j</btnTxtVue>
  50. <btnTxtVue @text-select="handleSelect('k')">k</btnTxtVue>
  51. <btnTxtVue @text-select="handleSelect('l')">l</btnTxtVue>
  52. <btnTxtVue @text-select="handleSelect('m')">m</btnTxtVue>
  53. <btnTxtVue @text-select="handleSelect('n')">n</btnTxtVue>
  54. <btnTxtVue @text-select="handleSelect('o')">o</btnTxtVue>
  55. <btnTxtVue @text-select="handleSelect('p')">p</btnTxtVue>
  56. <btnTxtVue @text-select="handleSelect('q')">q</btnTxtVue>
  57. <btnTxtVue @text-select="handleSelect('r')">r</btnTxtVue>
  58. </template>
  59. <template v-else>
  60. <btnTxtVue @text-select="handleSelect('J')">J</btnTxtVue>
  61. <btnTxtVue @text-select="handleSelect('K')">K</btnTxtVue>
  62. <btnTxtVue @text-select="handleSelect('L')">L</btnTxtVue>
  63. <btnTxtVue @text-select="handleSelect('M')">M</btnTxtVue>
  64. <btnTxtVue @text-select="handleSelect('N')">N</btnTxtVue>
  65. <btnTxtVue @text-select="handleSelect('O')">O</btnTxtVue>
  66. <btnTxtVue @text-select="handleSelect('P')">P</btnTxtVue>
  67. <btnTxtVue @text-select="handleSelect('Q')">Q</btnTxtVue>
  68. <btnTxtVue @text-select="handleSelect('R')">R</btnTxtVue>
  69. </template>
  70. </view>
  71. <view class="keyboard-row">
  72. <template v-if="!isDaxie">
  73. <btnTxtVue @text-select="handleSelect('s')">s</btnTxtVue>
  74. <btnTxtVue @text-select="handleSelect('t')">t</btnTxtVue>
  75. <btnTxtVue @text-select="handleSelect('u')">u</btnTxtVue>
  76. <btnTxtVue @text-select="handleSelect('v')">v</btnTxtVue>
  77. <btnTxtVue @text-select="handleSelect('w')">w</btnTxtVue>
  78. <btnTxtVue @text-select="handleSelect('x')">x</btnTxtVue>
  79. <btnTxtVue @text-select="handleSelect('y')">y</btnTxtVue>
  80. <btnTxtVue @text-select="handleSelect('z')">z</btnTxtVue>
  81. <btnTxtVue @text-select="handleReset" class="del-btn"></btnTxtVue>
  82. </template>
  83. <template v-else>
  84. <btnTxtVue @text-select="handleSelect('S')">S</btnTxtVue>
  85. <btnTxtVue @text-select="handleSelect('T')">T</btnTxtVue>
  86. <btnTxtVue @text-select="handleSelect('U')">U</btnTxtVue>
  87. <btnTxtVue @text-select="handleSelect('V')">V</btnTxtVue>
  88. <btnTxtVue @text-select="handleSelect('W')">W</btnTxtVue>
  89. <btnTxtVue @text-select="handleSelect('X')">X</btnTxtVue>
  90. <btnTxtVue @text-select="handleSelect('Y')">Y</btnTxtVue>
  91. <btnTxtVue @text-select="handleSelect('Z')">Z</btnTxtVue>
  92. <btnTxtVue @text-select="handleReset" class="del-btn"></btnTxtVue>
  93. </template>
  94. </view>
  95. <view class="bei-confirm-btn-box">
  96. <!-- active -->
  97. <ezyActiveVue class="ezy-btn-active big-btn" :class="{active: isDaxie}" @click="handleChangeDaxie">大写</ezyActiveVue>
  98. <ezyActiveVue class="ezy-btn-active bei-confirm-btn" @click="checkIsRight">确定</ezyActiveVue>
  99. </view>
  100. </view>
  101. </view>
  102. </view>
  103. </template>
  104. <script setup>
  105. import selectWordsVue from './selectWords.vue';
  106. import selectTypesVue from './selectTypes.vue';
  107. import btnTxtVue from './btnTxt.vue';
  108. import audioOneVue from './audioOne.vue';
  109. import {
  110. reactive,
  111. nextTick,
  112. ref
  113. } from 'vue';
  114. import * as httpApi from "@/api/chaojidanci.js"
  115. import cacheManager from '@/utils/cacheManager';
  116. import {
  117. resultAudioPlayer
  118. } from "./useAudioRightWrong"
  119. import ezyActiveVue from "@/components/ezyActive/ezyActive.vue";
  120. const resultAudioPlayerD = new resultAudioPlayer();
  121. const isDaxie = ref(false)
  122. const emits = defineEmits(['play-audio'])
  123. const props = defineProps({
  124. activeWord: { // 单词数据
  125. type: Object,
  126. },
  127. activeWords: {
  128. type: Array
  129. },
  130. pageData: {
  131. type: Object
  132. }
  133. })
  134. const data = reactive({
  135. answer: '',
  136. result: null, // 正确性
  137. isPlaying: false,
  138. code: null
  139. })
  140. function handleChangeDaxie() {
  141. isDaxie.value = !isDaxie.value;
  142. }
  143. function handlePlay(opt) {
  144. emits('play-audio', opt)
  145. }
  146. // 选择单词
  147. function checkIsRight() {
  148. let ans1 = props.activeWord.name;
  149. if (data.answer == ans1) {
  150. data.result = true;
  151. resultAudioPlayerD.play('right', 'bei')
  152. // noticeBackDb()
  153. } else {
  154. data.result = false;
  155. resultAudioPlayerD.play('wrong', 'bei')
  156. }
  157. noticeBackComplete()
  158. }
  159. function noticeBackComplete() {
  160. if (props.pageData.danyuanId == 0) {
  161. // 已掌握不需要调用接口通知完成
  162. return;
  163. }
  164. httpApi.getWordWancheng({
  165. danyuanId: props.pageData.danyuanId,
  166. wordId: props.activeWord.id
  167. }).then((res) => {
  168. const {
  169. wanchengFlag
  170. } = res.data;
  171. cacheManager.updateDanciWanchengStatus(props.pageData.danyuanId)
  172. if (wanchengFlag == 1) {
  173. // 更新当前岛小节完成状态
  174. cacheManager.updateDanciWanchengStatus(props.pageData.danyuanId)
  175. }
  176. })
  177. }
  178. function handleReset(code) {
  179. if (code == 'all') {
  180. // 全部清空
  181. data.answer = '';
  182. } else {
  183. // 单个清空
  184. data.answer = data.answer ? data.answer.slice(0, -1) : '';
  185. }
  186. // 重置错误状态
  187. if (!data.answer.length) {
  188. nextTick(() => {
  189. data.result = null;
  190. })
  191. }
  192. }
  193. function handleSelect(word) {
  194. data.answer += word;
  195. isDaxie.value = false;
  196. }
  197. </script>
  198. <style>
  199. </style>