selectPage.vue 3.0 KB

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