index.vue 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  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. handleSubmit,
  64. initPage,
  65. handleCloseTishi
  66. } = useExam();
  67. const uniPointsRef = ref(null);
  68. const chengjiRef = ref(null);
  69. const popupRef = ref(null);
  70. // 查看答案
  71. function checkAnswer() {
  72. chengjiRef.value.showPopup();
  73. }
  74. // 继续学习
  75. async function goStudyContinue() {
  76. // 设置 从单元测试 到 岛 的路由参数
  77. const [err, data] = await catchError(httpUnit.getnextZhangInfo({
  78. nianji: nianji.value,
  79. cardId: xueke.value,
  80. zhangId: zhangId.value
  81. }))
  82. cacheManager.updateObject('auth', {
  83. zhangId: data.zhangId,
  84. })
  85. uni.redirectTo({
  86. url: `/pages/study/index`
  87. })
  88. }
  89. function handleBack() {
  90. // 数学
  91. uni.redirectTo({
  92. url: `/pages/study/index`
  93. })
  94. }
  95. function onSwiperChange(index) {
  96. current.value = index;
  97. uni.$emit('swiper-change', index)
  98. }
  99. </script>
  100. <style lang="scss" scoped>
  101. .swiper-box {
  102. height: 200px;
  103. }
  104. .swiper-item {
  105. display: flex;
  106. flex-direction: column;
  107. justify-content: center;
  108. align-items: center;
  109. height: 200px;
  110. }
  111. </style>