beiPage.vue 4.0 KB

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