beiPage.vue 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. <template>
  2. <view class="words-bei-box">
  3. <!-- 显示区 -->
  4. <selectTypesVue activeSelect="5"></selectTypesVue>
  5. <!-- 输入区 -->
  6. <input class="words-answer-box" placeholder="请输入答案" v-model.trim="data.answer" readonly/>
  7. <!-- 清空按钮 -->
  8. <view class="clean-btn" @click="handleReset('all')" v-if="data.answer.length"></view>
  9. <view class="bei-body-box">
  10. <!-- 提示 -->
  11. <!-- <view class="pin-tip">提示:请点击页面下方键盘,输入正确字母。</view> -->
  12. <!-- 解释区 需要分成多行 大哥看这里-->
  13. <view class="pin-words-explain-box">
  14. <view class="words-explain-item" v-for="item in activeWord.jianyi" :key="item">{{item}}</view>
  15. </view>
  16. <!-- 播放和待播放需要写个切换 大哥看这里 -->
  17. <!-- 待播放 -->
  18. <view class="audio-play-btn"></view>
  19. <!-- 播放中 -->
  20. <view class="audio-playing-btn" v-if="false"></view>
  21. </view>
  22. <!-- 浮层输入区 -->
  23. <view class="words-keyboard-box">
  24. <view class="keyboard-row">
  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. </view>
  35. <view class="keyboard-row">
  36. <btnTxtVue @text-select="handleSelect('j')">j</btnTxtVue>
  37. <btnTxtVue @text-select="handleSelect('k')">k</btnTxtVue>
  38. <btnTxtVue @text-select="handleSelect('l')">l</btnTxtVue>
  39. <btnTxtVue @text-select="handleSelect('m')">m</btnTxtVue>
  40. <btnTxtVue @text-select="handleSelect('n')">n</btnTxtVue>
  41. <btnTxtVue @text-select="handleSelect('o')">o</btnTxtVue>
  42. <btnTxtVue @text-select="handleSelect('p')">p</btnTxtVue>
  43. <btnTxtVue @text-select="handleSelect('q')">q</btnTxtVue>
  44. <btnTxtVue @text-select="handleSelect('r')">r</btnTxtVue>
  45. </view>
  46. <view class="keyboard-row">
  47. <btnTxtVue @text-select="handleSelect('s')">s</btnTxtVue>
  48. <btnTxtVue @text-select="handleSelect('t')">t</btnTxtVue>
  49. <btnTxtVue @text-select="handleSelect('u')">u</btnTxtVue>
  50. <btnTxtVue @text-select="handleSelect('v')">v</btnTxtVue>
  51. <btnTxtVue @text-select="handleSelect('w')">w</btnTxtVue>
  52. <btnTxtVue @text-select="handleSelect('x')">x</btnTxtVue>
  53. <btnTxtVue @text-select="handleSelect('y')">y</btnTxtVue>
  54. <btnTxtVue @text-select="handleSelect('z')">z</btnTxtVue>
  55. <btnTxtVue @text-select="handleReset" class="del-btn"></btnTxtVue>
  56. </view>
  57. <view class="bei-confirm-btn"></view>
  58. </view>
  59. </view>
  60. </template>
  61. <script setup>
  62. import selectWordsVue from './selectWords.vue';
  63. import selectTypesVue from './selectTypes.vue';
  64. import btnTxtVue from './btnTxt.vue';
  65. import {
  66. reactive,
  67. computed
  68. } from 'vue';
  69. import {
  70. getUserIdentity,
  71. } from "@/utils/common.js"
  72. import * as httpApi from "@/api/word.js"
  73. const userCode = getUserIdentity();
  74. const props = defineProps({
  75. activeWord: { // 单词数据
  76. type: Object,
  77. },
  78. activeWords: {
  79. type: Array
  80. },
  81. })
  82. const data = reactive({
  83. answer: '',
  84. result: false, // 正确性
  85. })
  86. // 选择单词
  87. function checkIsRight() {
  88. if (data.answer == props.activeWord.value) {
  89. data.result = true;
  90. noticeBackDb()
  91. } else {
  92. data.result = false;
  93. }
  94. }
  95. function noticeBackDb() {
  96. // 通知后台已学完当前单词
  97. if (userCode == 'Visitor') {
  98. // 游客不更新后台
  99. return;
  100. }
  101. httpApi.getWordZhangwo({
  102. type: 3,
  103. wordId: props.activeWord.id
  104. })
  105. }
  106. function handleReset(code) {
  107. if (code == 'all') {
  108. // 全部清空
  109. data.answer = '';
  110. } else {
  111. // 单个清空
  112. data.answer = data.answer ? data.answer.slice(0, -1):''
  113. }
  114. }
  115. function handleSelect(word) {
  116. data.answer+=word;
  117. }
  118. </script>
  119. <style>
  120. </style>