beiPage.vue 4.1 KB

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