selectPage.vue 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. <!-- 单词区 && 音标区:最多16位,超过换行 选项最多两行超出省略-->
  2. <!-- 单音节最长:swimming 多音节最长:transportation -->
  3. <template>
  4. <!-- 显示区 -->
  5. <!-- <selectTypesVue activeSelect="4"></selectTypesVue>-->
  6. <view class="ezy-border-body">
  7. <view class="words-xuan-box">
  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. <yinbiaoTxtVue :yinbiao="activeWord.yinbiao"></yinbiaoTxtVue>
  15. <!-- active -->
  16. <audioTwoVue @play-audio="handlePlay" :active-word="activeWord"></audioTwoVue>
  17. </view>
  18. </view>
  19. <!-- 选择区 -->
  20. <view class="select-change-box">
  21. <view class="select-item"
  22. :class="{active: data.answer == 'A', 'select-error': data.answer =='A' && !data.result, 'select-right':data.answer =='A' && data.result}"
  23. @click="handleSelect('A')"><text>{{data.opa}}</text></view>
  24. <view class="select-item"
  25. :class="{active: data.answer == 'B', 'select-error': data.answer =='B' && !data.result, 'select-right':data.answer =='B' && data.result}"
  26. @click="handleSelect('B')"><text>{{data.opb}}</text></view>
  27. <view class="select-item"
  28. :class="{active: data.answer == 'C', 'select-error': data.answer =='C' && !data.result, 'select-right':data.answer =='C' && data.result}"
  29. @click="handleSelect('C')"><text>{{data.opc}}</text></view>
  30. <view class="select-item"
  31. :class="{active: data.answer == 'D', 'select-error': data.answer =='D' && !data.result, 'select-right':data.answer =='D' && data.result}"
  32. @click="handleSelect('D')"><text>{{data.opd}}</text></view>
  33. </view>
  34. </view>
  35. </view>
  36. </template>
  37. <script setup>
  38. import selectWordsVue from './selectWords.vue';
  39. import selectTypesVue from './selectTypes.vue';
  40. import audioTwoVue from './audioTwo.vue';
  41. import * as httpApi from "@/api/chaojidanci.js"
  42. import yinbiaoTxtVue from "./yinbiaoTxt.vue"
  43. import {
  44. onLoad
  45. } from "@dcloudio/uni-app"
  46. import {
  47. reactive,
  48. } from 'vue';
  49. import {resultAudioPlayer} from "./useAudioRightWrong"
  50. const resultAudioPlayerD = new resultAudioPlayer();
  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. resultAudioPlayerD.play('right','select')
  91. noticeBackDb()
  92. } else {
  93. data.result = false;
  94. resultAudioPlayerD.play('wrong','select')
  95. }
  96. }
  97. function noticeBackDb() {
  98. httpApi.getWordZhangwo({
  99. type: 2,
  100. wordId: props.activeWord.id
  101. })
  102. }
  103. </script>