|
@@ -21,26 +21,33 @@
|
|
|
<div class="divider" />
|
|
|
<!-- 题目模块 -->
|
|
|
<!-- 题目预加载 -->
|
|
|
- <m-empty v-if="!currentAnswer" />
|
|
|
+ <m-empty v-if="!currentSubject" />
|
|
|
<!-- 题目预加载end -->
|
|
|
<div class="problem-box" v-else>
|
|
|
<!-- 题目内容 -->
|
|
|
<div class="problem">
|
|
|
- <span class="type">{{ topicType(currentAnswer.type) }}</span>
|
|
|
- <span class="text">{{ currentAnswer.explain }}</span>
|
|
|
- <img v-if="currentAnswer.image" :src="currentAnswer.image" class="img"/>
|
|
|
+ <span class="type">{{ currentSubject.type }}</span>
|
|
|
+ <span class="text">{{ currentSubject.explain }}</span>
|
|
|
+ <van-image
|
|
|
+ v-if="currentSubject.image"
|
|
|
+ :src="currentSubject.image"
|
|
|
+ class="img"
|
|
|
+ >
|
|
|
+ <template v-slot:loading>
|
|
|
+ <van-loading type="spinner" size="20" />
|
|
|
+ </template>
|
|
|
+ </van-image>
|
|
|
</div>
|
|
|
<!-- 选择内容 -->
|
|
|
<div v-if="true">
|
|
|
<!-- 单选 -->
|
|
|
<van-radio-group
|
|
|
- v-model="currentAnswer.userAnswer"
|
|
|
- v-if="currentAnswer.type < 2"
|
|
|
- @change="userAnswerChange"
|
|
|
+ v-model="currentSubject.userAnswer"
|
|
|
+ v-if="currentSubject.type != '多选题'"
|
|
|
icon-size="35px"
|
|
|
>
|
|
|
<van-radio
|
|
|
- v-for="(item, index) in currentAnswer.opts"
|
|
|
+ v-for="(item, index) in currentSubject.opts"
|
|
|
:key="Number(index)"
|
|
|
:name="item"
|
|
|
class="answer"
|
|
@@ -54,9 +61,12 @@
|
|
|
</van-radio-group>
|
|
|
<!-- 多选 -->
|
|
|
<div v-else>
|
|
|
- <van-checkbox-group v-model="currentAnswer.userAnswer" icon-size="35px">
|
|
|
+ <van-checkbox-group
|
|
|
+ v-model="currentSubject.userAnswer"
|
|
|
+ icon-size="35px"
|
|
|
+ >
|
|
|
<van-checkbox
|
|
|
- v-for="(item, index) in currentAnswer.opts"
|
|
|
+ v-for="(item, index) in currentSubject.opts"
|
|
|
:key="Number(index)"
|
|
|
:name="item"
|
|
|
class="answer"
|
|
@@ -68,21 +78,13 @@
|
|
|
</template>
|
|
|
</van-checkbox>
|
|
|
</van-checkbox-group>
|
|
|
- <van-button
|
|
|
- round
|
|
|
- type="primary"
|
|
|
- class="checkbox-btn"
|
|
|
- :disabled="currentAnswer.userAnswer.length == 0"
|
|
|
- @click="userAnswerChange"
|
|
|
- >确定</van-button
|
|
|
- >
|
|
|
</div>
|
|
|
</div>
|
|
|
<!-- 展示答题后选择内容 -->
|
|
|
<div v-else-if="false">
|
|
|
<div>
|
|
|
<div
|
|
|
- v-for="(item, index) in currentAnswer.optsBack"
|
|
|
+ v-for="(item, index) in currentSubject.optsBack"
|
|
|
:key="Number(index)"
|
|
|
class="answer-box"
|
|
|
>
|
|
@@ -114,7 +116,7 @@
|
|
|
</div>
|
|
|
</div>
|
|
|
<div class="checkbox-answer">
|
|
|
- 答案: {{ currentAnswer.answer.toString() }}
|
|
|
+ 答案: {{ currentSubject.answer.toString() }}
|
|
|
</div>
|
|
|
</div>
|
|
|
<!-- 展示答题后选择内容end -->
|
|
@@ -132,7 +134,7 @@
|
|
|
<m-icon type="a-dtda" size="25px" />
|
|
|
<span>读题+答案</span>
|
|
|
</div> -->
|
|
|
- <div class="function-item" @click="issueAudioPlay">
|
|
|
+ <div class="function-item" @click="subjectAudioPlay('读题')">
|
|
|
<m-icon type="duti" size="25px" />
|
|
|
<span>读题</span>
|
|
|
</div>
|
|
@@ -150,52 +152,9 @@
|
|
|
</div> -->
|
|
|
</div>
|
|
|
<!-- 功能选择列表End -->
|
|
|
- <!-- 技巧讲解 -->
|
|
|
- <van-overlay :show="skillsShow" @click="skillsShow = false" z-index="10">
|
|
|
- <div class="skills-box" @click.stop>
|
|
|
- <div class="skills">
|
|
|
- <div class="title">技巧讲解</div>
|
|
|
- <img
|
|
|
- src="https://t1-1305573081.file.myqcloud.com/gif/2.gif"
|
|
|
- class="img"
|
|
|
- />
|
|
|
- <van-divider class="divider">本题速记口诀</van-divider>
|
|
|
- <div class="text">题目以“拘役”结尾.答对;以“徒刑”结尾.答错</div>
|
|
|
- <div class="btn">
|
|
|
- <span @click="skillsShow = false">关闭</span>
|
|
|
- <span @click="JQexplainAudioPlay">语音重播</span>
|
|
|
- </div>
|
|
|
- </div>
|
|
|
- </div>
|
|
|
- </van-overlay>
|
|
|
- <!-- 技巧讲解end -->
|
|
|
- <!-- 官方解释 -->
|
|
|
- <van-overlay :show="officialShow" @click="officialShow = false" z-index="10">
|
|
|
- <div class="skills-box" @click.stop>
|
|
|
- <div class="skills">
|
|
|
- <div class="title">官方解释</div>
|
|
|
- <div class="text">
|
|
|
- 1、申请城市公交车、大型货车、无轨电车或者有轨电车准驾车型的,在20周岁以上,50周岁以下;2、申请大型客车准驾车型的,在26周岁以上,50周岁以下;3、申请中型客车准驾车型的,在21周岁以上,50周岁以下;4、申请牵引车准驾车型的,在24周岁以上,50周岁以下。
|
|
|
- </div>
|
|
|
- <div class="btn">
|
|
|
- <span @click="officialShow = false">关闭</span>
|
|
|
- <span @click="explainAudioPlay">语音重播</span>
|
|
|
- </div>
|
|
|
- </div>
|
|
|
- </div>
|
|
|
- </van-overlay>
|
|
|
- <!-- 官方解释end -->
|
|
|
- <!-- 音频模块 -->
|
|
|
- <audio ref="audio"></audio>
|
|
|
- <!-- 音频模块end -->
|
|
|
<!-- 题目模块end -->
|
|
|
<!-- 设置操作栏 -->
|
|
|
<van-popup v-model:show="setShow" position="bottom">
|
|
|
- <van-cell center title="答对跳转下一题">
|
|
|
- <template #right-icon>
|
|
|
- <van-switch v-model="isJump" size="24" />
|
|
|
- </template>
|
|
|
- </van-cell>
|
|
|
<van-cell center title="答题音效提示">
|
|
|
<template #right-icon>
|
|
|
<van-switch v-model="isSoundEffect" size="24" />
|
|
@@ -207,14 +166,14 @@
|
|
|
<!-- <div style="height: 40px"></div> -->
|
|
|
<!-- <m-button class="submitButton" text="交卷" /> -->
|
|
|
<van-tabbar placeholder route>
|
|
|
- <van-tabbar-item @click="currentAnswerIndexBack"
|
|
|
+ <van-tabbar-item @click="lastSubject"
|
|
|
>上一题
|
|
|
<template #icon>
|
|
|
<m-icon type="shangyiti" />
|
|
|
</template>
|
|
|
</van-tabbar-item>
|
|
|
<van-tabbar-item
|
|
|
- >{{ idIndex }}/{{ total }}
|
|
|
+ >{{ currentSubjectIndex + 1 }}/{{ subjectTotal }}
|
|
|
<template #icon>
|
|
|
<m-icon type="zongtishu" />
|
|
|
</template>
|
|
@@ -225,7 +184,7 @@
|
|
|
<m-icon type="jiaojuan" />
|
|
|
</template>
|
|
|
</van-tabbar-item>
|
|
|
- <van-tabbar-item @click="currentAnswerIndexGo"
|
|
|
+ <van-tabbar-item @click="nextSubject"
|
|
|
>下一题
|
|
|
<template #icon>
|
|
|
<m-icon type="xiayiti" />
|
|
@@ -236,18 +195,10 @@
|
|
|
</template>
|
|
|
|
|
|
<script lang="ts" setup>
|
|
|
-import * as Api from "@/api";
|
|
|
import { useRoute, useRouter } from "vue-router";
|
|
|
-import {
|
|
|
- ref,
|
|
|
- watch,
|
|
|
- computed,
|
|
|
- reactive,
|
|
|
- onBeforeMount,
|
|
|
- nextTick,
|
|
|
- defineEmits,
|
|
|
-} from "vue";
|
|
|
+import { ref, defineEmits } from "vue";
|
|
|
import { Dialog } from "vant";
|
|
|
+import { useSubjectShowLogic, useTopicMode, useAudioSet } from "./hooks";
|
|
|
const router = useRouter();
|
|
|
const route = useRoute();
|
|
|
const onClickLeft = () => {
|
|
@@ -266,198 +217,27 @@ const gotoTest = () => {
|
|
|
.catch(() => {});
|
|
|
};
|
|
|
|
|
|
-//答题模式选择逻辑
|
|
|
-const answerTypeList = ref([
|
|
|
- { name: "顺序练习" },
|
|
|
- { name: "随机练习" },
|
|
|
- { name: "背题模式" },
|
|
|
-]);
|
|
|
-const currentType = ref(0);
|
|
|
-const typeParams = ref({
|
|
|
- order: true, //顺序练习
|
|
|
- answerShow: false, //背题模式
|
|
|
-});
|
|
|
-watch(currentType, (currentVal) => {
|
|
|
- switch (currentVal) {
|
|
|
- case 0:
|
|
|
- typeParams.value.order = true;
|
|
|
- typeParams.value.answerShow = false;
|
|
|
- break;
|
|
|
- case 1:
|
|
|
- typeParams.value.order = false;
|
|
|
- typeParams.value.answerShow = false;
|
|
|
- break;
|
|
|
- case 2:
|
|
|
- typeParams.value.order = true;
|
|
|
- typeParams.value.answerShow = true;
|
|
|
- break;
|
|
|
- }
|
|
|
-});
|
|
|
-
|
|
|
-//自动读题
|
|
|
-const aotuPlayFlag = ref(false);
|
|
|
-const aotuPlaySet = () => {
|
|
|
- aotuPlayFlag.value = !aotuPlayFlag.value;
|
|
|
- if (aotuPlayFlag.value) issueAudioPlay();
|
|
|
- if (!aotuPlayFlag.value) audioPause();
|
|
|
-};
|
|
|
-onBeforeMount(() => {
|
|
|
- watch(currentAnswerIndex, () => {
|
|
|
- if (aotuPlayFlag.value) issueAudioPlay(); //自动读题
|
|
|
- });
|
|
|
-});
|
|
|
-//答题模式选择逻辑end
|
|
|
-
|
|
|
//题目展示逻辑
|
|
|
-const topicList = ref([]);
|
|
|
-console.log(topicList);
|
|
|
-
|
|
|
-//API请求接口数据
|
|
|
-onBeforeMount(async () => {
|
|
|
- const topicListApiRes = await Api.getTopicList({
|
|
|
- ...route.query,
|
|
|
- pageNum: 1,
|
|
|
- pageSize: 100,
|
|
|
- isRand: true,
|
|
|
- });
|
|
|
- topicList.value = topicListApiRes.list;
|
|
|
- idIndex.value = currentAnswerIndex.value;
|
|
|
- total.value = 100;
|
|
|
-});
|
|
|
-
|
|
|
-//当前题目数据
|
|
|
-const currentAnswerIndex = ref(0);
|
|
|
-const currentAnswer: any = computed(() => {
|
|
|
- return topicList.value[currentAnswerIndex.value];
|
|
|
-});
|
|
|
-
|
|
|
-//上一题,下一题
|
|
|
-const currentAnswerIndexBack = () => {
|
|
|
- if (topicList.value.length == 0) return;
|
|
|
- currentAnswerIndex.value =
|
|
|
- (currentAnswerIndex.value - 1 + topicList.value.length) %
|
|
|
- topicList.value.length;
|
|
|
-};
|
|
|
-const currentAnswerIndexGo = () => {
|
|
|
- if (topicList.value.length == 0) return;
|
|
|
- currentAnswerIndex.value =
|
|
|
- (currentAnswerIndex.value + 1) % topicList.value.length;
|
|
|
-};
|
|
|
-
|
|
|
-//选择答案后
|
|
|
-const userAnswerChange = () => {
|
|
|
- currentAnswer.value.optsBack = currentAnswer.value.opts.map((val: String) => {
|
|
|
- let status;
|
|
|
- if (currentAnswer.value.answer.includes(val)) {
|
|
|
- status = 1;
|
|
|
- } else {
|
|
|
- status = 0;
|
|
|
- }
|
|
|
- if (currentAnswer.value.userAnswer.includes(val)) {
|
|
|
- status += 2;
|
|
|
- }
|
|
|
- return { opt: val, status };
|
|
|
- });
|
|
|
- if (
|
|
|
- JSON.stringify(currentAnswer.value.answer) ==
|
|
|
- JSON.stringify(currentAnswer.value.userAnswer)
|
|
|
- ) {
|
|
|
- console.log("答案正确");
|
|
|
- currentAnswer.value.isTrue = true;
|
|
|
- trueNum.value++;
|
|
|
- if (isJump.value)
|
|
|
- setTimeout(() => {
|
|
|
- currentAnswerIndexGo();
|
|
|
- }, 200);
|
|
|
- } else {
|
|
|
- console.log("错误");
|
|
|
- currentAnswer.value.isTrue = false;
|
|
|
- falseNum.value++;
|
|
|
- }
|
|
|
-};
|
|
|
-const topicType = (type: Number) => {
|
|
|
- switch (type) {
|
|
|
- case 0:
|
|
|
- return "判断题";
|
|
|
- case 1:
|
|
|
- return "单选题";
|
|
|
- case 2:
|
|
|
- return "多选题";
|
|
|
- }
|
|
|
-};
|
|
|
-//题目展示逻辑end
|
|
|
-
|
|
|
-//技巧讲解
|
|
|
-const skillsShow = ref(false); //显示技巧讲解
|
|
|
-//技巧讲解end
|
|
|
-
|
|
|
-//官方解释
|
|
|
-const officialShow = ref(false); //显示官方解释
|
|
|
-//官方解释end
|
|
|
+const {
|
|
|
+ currentSubject,
|
|
|
+ currentSubjectIndex,
|
|
|
+ subjectTotal,
|
|
|
+ nextSubject,
|
|
|
+ lastSubject,
|
|
|
+ trueNum,
|
|
|
+ falseNum,
|
|
|
+ isJumpNext,
|
|
|
+ userAnswerChange,
|
|
|
+} = useSubjectShowLogic();
|
|
|
|
|
|
//设置操作栏
|
|
|
const setShow = ref(false); //显示设置栏
|
|
|
-const isJump = ref(false); //答对跳转下一题
|
|
|
const isSoundEffect = ref(true); //答题音效
|
|
|
//设置操作栏end
|
|
|
|
|
|
//音频模块
|
|
|
-const audio = ref();
|
|
|
-
|
|
|
-/**
|
|
|
- * 读题
|
|
|
- */
|
|
|
-const issueAudioPlay = () => {
|
|
|
- audio.value.src = "https://t1-1305573081.file.myqcloud.com/issue/issue1.mp3";
|
|
|
- audio.value.play();
|
|
|
-};
|
|
|
-
|
|
|
-/**
|
|
|
- * 读答案
|
|
|
- */
|
|
|
-const answerAudioPlay = () => {
|
|
|
- audio.value.src =
|
|
|
- "https://t1-1305573081.file.myqcloud.com/answer/answer1.mp3";
|
|
|
- audio.value.play();
|
|
|
-};
|
|
|
-
|
|
|
-/**
|
|
|
- * 读官方解释
|
|
|
- */
|
|
|
-const explainAudioPlay = () => {
|
|
|
- audio.value.src =
|
|
|
- "https://t1-1305573081.file.myqcloud.com/explainjs/explainJS1.mp3";
|
|
|
- audio.value.play();
|
|
|
-};
|
|
|
-
|
|
|
-/**
|
|
|
- * 读技巧解释
|
|
|
- */
|
|
|
-const JQexplainAudioPlay = () => {
|
|
|
- audio.value.src = "https://t1-1305573081.file.myqcloud.com/mp3/explain1.mp3";
|
|
|
- audio.value.play();
|
|
|
-};
|
|
|
-
|
|
|
-/**
|
|
|
- * 停止播放
|
|
|
- */
|
|
|
-const audioPause = () => {
|
|
|
- audio.value.pause();
|
|
|
-};
|
|
|
-
|
|
|
+const { subjectAudioPlay } = useAudioSet(currentSubject);
|
|
|
//音频模块end
|
|
|
-
|
|
|
-//记录模块
|
|
|
-const trueNum = ref(0); //答对数量
|
|
|
-const falseNum = ref(0); //答错数量
|
|
|
-const idIndex = ref(0); //当前题目标志位
|
|
|
-const total = ref(0); //题目总数量
|
|
|
-onBeforeMount(() => {
|
|
|
- watch(currentAnswerIndex, () => {
|
|
|
- idIndex.value = currentAnswerIndex.value;
|
|
|
- });
|
|
|
-});
|
|
|
-//记录模块end
|
|
|
</script>
|
|
|
|
|
|
<style lang="scss" scoped>
|