index.vue 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  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. </view>
  30. </template>
  31. <script setup>
  32. import wSwiper from '@/components/wSwiper/wSwiper.vue';
  33. import danxuan from "@/components/question/danxuan.vue";
  34. import panduan from "@/components/question/panduan.vue";
  35. import tiankong from "@/components/question/tiankong.vue";
  36. import chengji from "@/components/chengji/chengji.vue";
  37. import uniPointsVue from '@/components/points/uni-points.vue';
  38. import * as httpUnit from "@/api/unitTest.js"
  39. import {
  40. catchError,
  41. } from "@/utils/common.js"
  42. import {
  43. useExam
  44. } from './useUnit';
  45. import {
  46. ref,
  47. } from "vue";
  48. import cacheManager from "@/utils/cacheManager";
  49. const {
  50. count,
  51. total,
  52. current,
  53. list,
  54. rightAnswer,
  55. wrongAnswer,
  56. jifen,
  57. zhangId,
  58. jieId,
  59. nianji,
  60. xueke,
  61. showTishi,
  62. haveFlag,
  63. activeZhang,
  64. handleSubmit,
  65. initPage,
  66. handleCloseTishi
  67. } = useExam();
  68. const uniPointsRef = ref(null);
  69. const chengjiRef = ref(null);
  70. const popupRef = ref(null);
  71. // 查看答案
  72. function checkAnswer() {
  73. chengjiRef.value.showPopup();
  74. }
  75. // 继续学习
  76. async function goStudyContinue() {
  77. // 设置 从单元测试 到 岛 的路由参数
  78. console.log(activeZhang)
  79. activeZhang.value.nextZhang ? activeZhang.value.nextZhang.zhangId : null;
  80. cacheManager.updateObject('auth', {
  81. zhangId: activeZhang.value.nextZhang.zhangId,
  82. })
  83. uni.redirectTo({
  84. url: `/pages/study/index`
  85. })
  86. }
  87. function handleBack() {
  88. // 数学
  89. uni.redirectTo({
  90. url: `/pages/study/index`
  91. })
  92. }
  93. function onSwiperChange(index) {
  94. current.value = index;
  95. uni.$emit('swiper-change', index)
  96. }
  97. </script>
  98. <style lang="scss" scoped>
  99. .swiper-box {
  100. height: 200px;
  101. }
  102. .swiper-item {
  103. display: flex;
  104. flex-direction: column;
  105. justify-content: center;
  106. align-items: center;
  107. height: 200px;
  108. }
  109. </style>