123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116 |
- <!-- 单词区 && 音标区:最多16位,超过换行 选项最多两行超出省略-->
- <!-- 单音节最长:swimming 多音节最长:transportation -->
- <template>
- <view class="words-xuan-box">
- <!-- 显示区 -->
- <selectTypesVue activeSelect="4"></selectTypesVue>
- <view class="xuan-body-box">
- <!-- 单词区 -->
- <view class="show-words-box"> {{data.name}} </view>
- <!-- 音标区 -->
- <view class="yb-play-box">
- <!-- <text>{{activeWord.yinbiao}}</text> -->
- <yinbiaoTxtVue :yinbiao="activeWord.yinbiao"></yinbiaoTxtVue>
- <!-- active -->
- <audioTwoVue @play-audio="handlePlay" :active-word="activeWord"></audioTwoVue>
- </view>
- </view>
- <!-- 选择区 -->
- <view class="select-change-box">
- <view class="select-item"
- :class="{active: data.answer == 'A', 'select-error': data.answer =='A' && !data.result, 'select-right':data.answer =='A' && data.result}"
- @click="handleSelect('A')"><text>{{data.opa}}</text></view>
- <view class="select-item"
- :class="{active: data.answer == 'B', 'select-error': data.answer =='B' && !data.result, 'select-right':data.answer =='B' && data.result}"
- @click="handleSelect('B')"><text>{{data.opb}}</text></view>
- <view class="select-item"
- :class="{active: data.answer == 'C', 'select-error': data.answer =='C' && !data.result, 'select-right':data.answer =='C' && data.result}"
- @click="handleSelect('C')"><text>{{data.opc}}</text></view>
- <view class="select-item"
- :class="{active: data.answer == 'D', 'select-error': data.answer =='D' && !data.result, 'select-right':data.answer =='D' && data.result}"
- @click="handleSelect('D')"><text>{{data.opd}}</text></view>
- </view>
- </view>
- </template>
- <script setup>
- import selectWordsVue from './selectWords.vue';
- import selectTypesVue from './selectTypes.vue';
- import audioTwoVue from './audioTwo.vue';
- import * as httpApi from "@/api/word.js"
- import yinbiaoTxtVue from "./yinbiaoTxt.vue"
- import {
- onLoad
- } from "@dcloudio/uni-app"
- import {
- reactive,
- computed,
- } from 'vue';
- import {
- getUserIdentity,
- } from "@/utils/common.js"
- const userCode = getUserIdentity();
-
- const emits = defineEmits(['play-audio'])
- const props = defineProps({
- activeWord: { // 单词数据
- type: Object,
- },
- activeWords: {
- type: Array
- },
- })
- const data = reactive({
- name: [],
- opa: null,
- opb: null,
- opc: null,
- opd: null,
- answer: null, // 已选项
- result: false, // 正确性
- })
- onLoad(() => {
- initItem()
- })
- function handlePlay(opt) {
- emits('play-audio', opt)
- }
- function initItem() {
- data.name = props.activeWord.name;
- data.opa = props.activeWord.opa;
- data.opb = props.activeWord.opb;
- data.opc = props.activeWord.opc;
- data.opd = props.activeWord.opd;
- }
- function handleSelect(d1) {
- data.answer = d1;
- checkIsRight();
- }
- function checkIsRight() {
- if (data.answer == props.activeWord.daan) {
- // 正确
- data.result = true;
- noticeBackDb()
- } else {
- data.result = false;
- }
- }
- function noticeBackDb() {
- if (userCode == 'Visitor') {
- // 游客不更新后台
- return;
- }
- httpApi.getWordZhangwo({
- type: 2,
- wordId: props.activeWord.id
- })
- }
- </script>
|