index.vue 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  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" @back="handleBack"></chengji>
  27. <!-- 分数弹窗 -->
  28. <uniPointsVue ref="uniPointsRef" @checkAnswer="checkAnswer" @goStudy="goStudyContinue" :showContinue="zhangType== 'last'"></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. zhangType,
  63. handleSubmit,
  64. initPage,
  65. handleCloseTishi
  66. } = useExam();
  67. const uniPointsRef = ref(null);
  68. const chengjiRef = ref(null);
  69. // 查看答案
  70. function checkAnswer() {
  71. chengjiRef.value.showPopup();
  72. }
  73. // 继续学习
  74. async function goStudyContinue() {
  75. // 设置 从单元测试 到 岛 的路由参数
  76. const [err, data] = await catchError(httpUnit.getnextZhangInfo({
  77. nianji: nianji.value,
  78. cardId: xueke.value,
  79. zhangId: zhangId.value
  80. }))
  81. cacheManager.updateObject('auth', {
  82. zhangId: data.zhangId,
  83. })
  84. uni.redirectTo({
  85. url: `/pages/study/index`
  86. })
  87. }
  88. function handleBack() {
  89. // 数学
  90. uni.redirectTo({
  91. url: `/pages/study/index`
  92. })
  93. }
  94. function onSwiperChange(index) {
  95. current.value = 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>