index.vue 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  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'" :placeholders="item.placeholders"></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" @back="handleBack"></chengji>
  27. <!-- 分数弹窗 -->
  28. <uniPointsVue ref="uniPointsRef" @checkAnswer="checkAnswer" @goStudy="goStudyContinue" :isLastZhang="!!haveFlag"></uniPointsVue>
  29. <!-- 填空题选项 -->
  30. <FillItem :value="tiankongValue" :ref="`popupRef`" :index="index" @blur="onBlur"></FillItem>
  31. </view>
  32. </template>
  33. <script setup>
  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. } from "@/utils/common.js"
  44. import {
  45. useExam,useTiankongItem
  46. } from './useUnit';
  47. import {
  48. ref,
  49. } from "vue";
  50. import cacheManager from "@/utils/cacheManager";
  51. import FillItem from "@/components/question/FillItem.vue";
  52. const {
  53. count,
  54. total,
  55. current,
  56. list,
  57. rightAnswer,
  58. wrongAnswer,
  59. jifen,
  60. zhangId,
  61. jieId,
  62. nianji,
  63. xueke,
  64. showTishi,
  65. haveFlag,
  66. handleSubmit,
  67. initPage,
  68. handleCloseTishi
  69. } = useExam();
  70. const uniPointsRef = ref(null);
  71. const chengjiRef = ref(null);
  72. const popupRef = ref(null);
  73. const {index,tiankongValue,onBlur} = useTiankongItem(popupRef)
  74. // 查看答案
  75. function checkAnswer() {
  76. chengjiRef.value.showPopup();
  77. }
  78. // 继续学习
  79. async function goStudyContinue() {
  80. // 设置 从单元测试 到 岛 的路由参数
  81. const [err, data] = await catchError(httpUnit.getnextZhangInfo({
  82. nianji: nianji.value,
  83. cardId: xueke.value,
  84. zhangId: zhangId.value
  85. }))
  86. cacheManager.updateObject('auth', {
  87. zhangId: data.zhangId,
  88. })
  89. uni.redirectTo({
  90. url: `/pages/study/index`
  91. })
  92. }
  93. function handleBack() {
  94. // 数学
  95. uni.redirectTo({
  96. url: `/pages/study/index`
  97. })
  98. }
  99. function onSwiperChange(index) {
  100. current.value = index;
  101. }
  102. </script>
  103. <style lang="scss" scoped>
  104. .swiper-box {
  105. height: 200px;
  106. }
  107. .swiper-item {
  108. display: flex;
  109. flex-direction: column;
  110. justify-content: center;
  111. align-items: center;
  112. height: 200px;
  113. }
  114. </style>