index.vue 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. <template>
  2. <view class="ezy-exam-page">
  3. <view class="ezy-navBar-box">
  4. <view @click="handleBack" class="nav-bar-icon"></view>
  5. <text class="nav-bar-title">单元测试</text>
  6. <view class="nav-bar-other"><text class="key-note">{{count}}</text>/<text>{{total}}</text></view>
  7. </view>
  8. <view class="shiti-frame-box">
  9. <w-swiper :list="list" :current="current" class="ezy-exam-swiper" @change="onSwiperChange">
  10. <template v-slot:default="{item}">
  11. <view class="body" v-if="item.mta_show">
  12. <danxuan :question="item" v-if="item.type == '1'"></danxuan>
  13. <panduan :question="item" v-if="item.type == '2'"></panduan>
  14. <tiankong :question="item" v-if="item.type == '3'"></tiankong>
  15. </view>
  16. </template>
  17. </w-swiper>
  18. <view class="exam-submit-btn" v-if="current === list.length-1"
  19. @click="handleSubmit(uniPointsRef)"></view>
  20. </view>
  21. <!-- 左右滑动 -->
  22. <view class="tip-mask-box" @click="handleCloseTishi" v-if="showTishi">
  23. <view class="exam-tip-box">左右滑动查看更多题目</view>
  24. </view>
  25. <!-- 答卷 -->
  26. <chengji ref="chengjiRef" :list="list" :jieId="jieId" :zhangId="zhangId" @back="handleBack"
  27. :nianji="nianji" :xueke="xueke"></chengji>
  28. <!-- 分数弹窗 -->
  29. <uniPointsVue ref="uniPointsRef" @checkAnswer="checkAnswer" @goStudy="goStudyContinue" :showContinue="zhangType== 'last'"></uniPointsVue>
  30. </view>
  31. </template>
  32. <script setup>
  33. import questionJiexi from '@/components/questionJiexi/questionJiexi.vue';
  34. import wSwiper from '@/components/wSwiper/wSwiper.vue';
  35. import danxuan from "@/components/question/danxuan.vue";
  36. import panduan from "@/components/question/panduan.vue";
  37. import tiankong from "@/components/question/tiankong.vue";
  38. import chengji from "@/components/chengji/chengji.vue";
  39. import uniPointsVue from '@/components/points/uni-points.vue';
  40. import * as httpUnit from "@/api/unitTest.js"
  41. import {
  42. catchError,
  43. toast
  44. } from "@/utils/common.js"
  45. import {
  46. useExam
  47. } from './useUnit';
  48. import {
  49. ref,
  50. onMounted
  51. } from "vue";
  52. import {
  53. getAuth
  54. } from '@/utils/auth.js';
  55. import { SHUXUE,YINGYU } from "@/utils/constant.js"
  56. const {
  57. count,
  58. total,
  59. current,
  60. list,
  61. rightAnswer,
  62. wrongAnswer,
  63. jifen,
  64. zhangId,
  65. jieId,
  66. nianji,
  67. xueke,
  68. showTishi,
  69. zhangType,
  70. handleSubmit,
  71. initPage,
  72. handleCloseTishi
  73. } = useExam();
  74. const uniPointsRef = ref(null);
  75. const chengjiRef = ref(null);
  76. // 查看答案
  77. function checkAnswer() {
  78. chengjiRef.value.showPopup();
  79. }
  80. // 继续学习
  81. async function goStudyContinue() {
  82. // 设置 从单元测试 到 岛 的路由参数
  83. const [err, data] = await catchError(httpUnit.getnextZhangInfo({
  84. nianji: nianji.value,
  85. cardId: xueke.value,
  86. zhangId: zhangId.value
  87. }))
  88. // 数学
  89. xueke.value == SHUXUE && uni.redirectTo({
  90. url: `/pages/study/index?nianji=${nianji.value}&xueke=${xueke.value}&zhangId=${data.zhangId}`
  91. })
  92. // 英语
  93. xueke.value == YINGYU && uni.redirectTo({
  94. url: `/pages/study/index?nianji=${nianji.value}&xueke=${xueke.value}&zhangId=${data.zhangId}`
  95. })
  96. }
  97. function handleBack() {
  98. // 数学
  99. xueke.value == SHUXUE && uni.redirectTo({
  100. url: `/pages/study/index?nianji=${nianji.value}&xueke=${xueke.value}&zhangId=${zhangId.value}`
  101. })
  102. // 英语
  103. xueke.value == YINGYU && uni.redirectTo({
  104. url: `/pages/study/index?nianji=${nianji.value}&xueke=${xueke.value}&zhangId=${zhangId.value}`
  105. })
  106. }
  107. function onSwiperChange(index) {
  108. current.value = index;
  109. }
  110. </script>
  111. <style lang="scss" scoped>
  112. .swiper-box {
  113. height: 200px;
  114. }
  115. .swiper-item {
  116. display: flex;
  117. flex-direction: column;
  118. justify-content: center;
  119. align-items: center;
  120. height: 200px;
  121. }
  122. </style>