beiPage.vue 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. <template>
  2. <view>
  3. <!-- 单词区 -->
  4. <selectWordsVue :active-words="activeWords" :activeWord="activeWord"></selectWordsVue>
  5. <!-- 显示区 -->
  6. <selectTypesVue activeSelect="5"></selectTypesVue>
  7. <!-- 输入区 -->
  8. <view>{{data.answer}}</view>
  9. <!-- 解释区 -->
  10. <view>
  11. {{activeWord.jianyi.join(';')}}
  12. </view>
  13. <!-- 音标区 -->
  14. <view></view>
  15. <!-- 清理区 -->
  16. <view @click="handleReset('all')">
  17. reset
  18. </view>
  19. <!-- 浮层输入区 -->
  20. <view>
  21. <view>
  22. <btnTxtVue @text-select="handleSelect('a')">a</btnTxtVue>
  23. <btnTxtVue @text-select="handleSelect('b')">b</btnTxtVue>
  24. <btnTxtVue @text-select="handleSelect('c')">c</btnTxtVue>
  25. <btnTxtVue @text-select="handleSelect('d')">d</btnTxtVue>
  26. <btnTxtVue @text-select="handleSelect('e')">e</btnTxtVue>
  27. <btnTxtVue @text-select="handleSelect('f')">f</btnTxtVue>
  28. <btnTxtVue @text-select="handleSelect('g')">g</btnTxtVue>
  29. <btnTxtVue @text-select="handleSelect('h')">h</btnTxtVue>
  30. <btnTxtVue @text-select="handleSelect('i')">i</btnTxtVue>
  31. </view>
  32. <view>
  33. <btnTxtVue @text-select="handleSelect('j')">j</btnTxtVue>
  34. <btnTxtVue @text-select="handleSelect('k')">k</btnTxtVue>
  35. <btnTxtVue @text-select="handleSelect('l')">l</btnTxtVue>
  36. <btnTxtVue @text-select="handleSelect('m')">m</btnTxtVue>
  37. <btnTxtVue @text-select="handleSelect('n')">n</btnTxtVue>
  38. <btnTxtVue @text-select="handleSelect('o')">o</btnTxtVue>
  39. <btnTxtVue @text-select="handleSelect('p')">p</btnTxtVue>
  40. <btnTxtVue @text-select="handleSelect('q')">q</btnTxtVue>
  41. <btnTxtVue @text-select="handleSelect('r')">r</btnTxtVue>
  42. </view>
  43. <view>
  44. <btnTxtVue @text-select="handleSelect('s')">s</btnTxtVue>
  45. <btnTxtVue @text-select="handleSelect('t')">t</btnTxtVue>
  46. <btnTxtVue @text-select="handleSelect('u')">u</btnTxtVue>
  47. <btnTxtVue @text-select="handleSelect('v')">v</btnTxtVue>
  48. <btnTxtVue @text-select="handleSelect('w')">w</btnTxtVue>
  49. <btnTxtVue @text-select="handleSelect('x')">x</btnTxtVue>
  50. <btnTxtVue @text-select="handleSelect('y')">y</btnTxtVue>
  51. <btnTxtVue @text-select="handleSelect('z')">z</btnTxtVue>
  52. <btnTxtVue @text-select="handleReset">x</btnTxtVue>
  53. </view>
  54. <view>确定</view>
  55. </view>
  56. </view>
  57. </template>
  58. <script setup>
  59. import selectWordsVue from './selectWords.vue';
  60. import selectTypesVue from './selectTypes.vue';
  61. import btnTxtVue from './btnTxt.vue';
  62. import {
  63. reactive,
  64. computed
  65. } from 'vue';
  66. import {
  67. getUserIdentity,
  68. } from "@/utils/common.js"
  69. const userCode = getUserIdentity();
  70. const props = defineProps({
  71. activeWord: { // 单词数据
  72. type: Object,
  73. },
  74. activeWords: {
  75. type: Array
  76. },
  77. })
  78. const data = reactive({
  79. answer: '',
  80. result: false, // 正确性
  81. })
  82. // 选择单词
  83. function checkIsRight() {
  84. if (data.answer == props.activeWord.value) {
  85. data.result = true;
  86. noticeBackDb()
  87. } else {
  88. data.result = false;
  89. }
  90. }
  91. function noticeBackDb() {
  92. // 通知后台已学完当前单词
  93. if (userCode == 'Visitor') {
  94. // 游客不更新后台
  95. return;
  96. }
  97. }
  98. function handleReset(code) {
  99. if (code == 'all') {
  100. // 全部清空
  101. data.answer = '';
  102. } else {
  103. // 单个清空
  104. data.answer = data.answer ? data.answer.slice(0, -1):''
  105. }
  106. }
  107. function handleSelect(word) {
  108. console.log('xxxx',word)
  109. data.answer+=word;
  110. }
  111. </script>
  112. <style>
  113. </style>