selectPage.vue 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. <template>
  2. <!-- 单词最多16个字母 选项最多两行 tx---不要删除 -->
  3. <view class="words-xuan-box">
  4. <!-- 单词区 -->
  5. <!-- <selectWordsVue :active-words="activeWords" :activeWord="activeWord"></selectWordsVue> -->
  6. <!-- 显示区 -->
  7. <selectTypesVue activeSelect="4"></selectTypesVue>
  8. <view class="xuan-body-box">
  9. <!-- 单词区 -->
  10. <view class="show-words-box"> {{data.name}} </view>
  11. <!-- 音标区 -->
  12. <view class="yb-play-box">
  13. <text>{{activeWord.yinbiao}}</text>
  14. <!-- active -->
  15. <!-- 播放未播放互斥控制 大哥看这里-->
  16. <icon class="yb-play-btn"></icon>
  17. <icon class="yb-playing-btn" v-if="false"></icon>
  18. </view>
  19. </view>
  20. <!-- 图片区 -->
  21. <!-- <view>
  22. {{ data.result ?'正确':'错误' }}
  23. </view> -->
  24. <!-- 选择区 -->
  25. <!-- 选中选项正确class select-right 选中选项错误 class select-error 大哥看这里-->
  26. <view class="select-change-box">
  27. <view class="select-item" :class="{active: data.answer == 'A'}" @click="handleSelect('A')"><text>{{data.opa}}</text></view>
  28. <view class="select-item" :class="{active: data.answer == 'B'}" @click="handleSelect('B')"><text>{{data.opb}}</text></view>
  29. <view class="select-item" :class="{active: data.answer == 'C'}" @click="handleSelect('C')"><text>{{data.opc}}</text></view>
  30. <view class="select-item" :class="{active: data.answer == 'D'}" @click="handleSelect('D')"><text>{{data.opd}}</text></view>
  31. </view>
  32. </view>
  33. </template>
  34. <script setup>
  35. import selectWordsVue from './selectWords.vue';
  36. import selectTypesVue from './selectTypes.vue';
  37. import * as httpApi from "@/api/word.js"
  38. import {
  39. onLoad
  40. } from "@dcloudio/uni-app"
  41. import {
  42. reactive,
  43. computed
  44. } from 'vue';
  45. import {
  46. getUserIdentity,
  47. } from "@/utils/common.js"
  48. const userCode = getUserIdentity();
  49. const props = defineProps({
  50. activeWord: { // 单词数据
  51. type: Object,
  52. },
  53. activeWords: {
  54. type: Array
  55. },
  56. })
  57. const data = reactive({
  58. name: [],
  59. opa: null,
  60. opb: null,
  61. opc: null,
  62. opd: null,
  63. answer: null, // 已选项
  64. result: false, // 正确性
  65. })
  66. onLoad(() => {
  67. initItem()
  68. })
  69. function initItem() {
  70. data.name = props.activeWord.name;
  71. data.opa = props.activeWord.opa;
  72. data.opb = props.activeWord.opb;
  73. data.opc = props.activeWord.opc;
  74. data.opd = props.activeWord.opd;
  75. }
  76. function handleSelect(d1) {
  77. data.answer = d1;
  78. checkIsRight();
  79. }
  80. function checkIsRight() {
  81. if (data.answer == props.activeWord.daan) {
  82. // 正确
  83. data.result = true;
  84. noticeBackDb()
  85. } else {
  86. data.result = false;
  87. }
  88. }
  89. function noticeBackDb() {
  90. if (userCode == 'Visitor') {
  91. // 游客不更新后台
  92. return;
  93. }
  94. httpApi.getWordZhangwo({
  95. type: 2,
  96. wordId: props.activeWord.id
  97. })
  98. }
  99. </script>