index.vue 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. <template>
  2. <view class="ezy-exam-page">
  3. <view class="ezy-navBar-box">
  4. {{haveFlag}}
  5. <view @click="handleBack" class="nav-bar-icon"></view>
  6. <text class="nav-bar-title">单元测试</text>
  7. <view class="nav-bar-other"><text class="key-note">{{count}}</text>/<text>{{total}}</text></view>
  8. </view>
  9. <view class="shiti-frame-box">
  10. <w-swiper :list="list" :current="current" class="ezy-exam-swiper" @change="onSwiperChange">
  11. <template v-slot:default="{item}">
  12. <view class="body" v-if="item.mta_show">
  13. <danxuan :question="item" v-if="item.type == '1'"></danxuan>
  14. <panduan :question="item" v-if="item.type == '2'"></panduan>
  15. <tiankong :question="item" v-if="item.type == '3'" :placeholders="item.placeholders"></tiankong>
  16. </view>
  17. </template>
  18. </w-swiper>
  19. <view class="exam-submit-btn" v-if="current === list.length-1"
  20. @click="handleSubmit(uniPointsRef)"></view>
  21. </view>
  22. <!-- 左右滑动 -->
  23. <view class="tip-mask-box" @click="handleCloseTishi" v-if="showTishi">
  24. <view class="exam-tip-box">左右滑动查看更多题目</view>
  25. </view>
  26. <!-- 答卷 -->
  27. <chengji ref="chengjiRef" :list="list" @back="handleBack"></chengji>
  28. <!-- 分数弹窗 -->
  29. <uniPointsVue ref="uniPointsRef" @checkAnswer="checkAnswer" @goStudy="goStudyContinue" :isLastZhang="!!haveFlag"></uniPointsVue>
  30. </view>
  31. </template>
  32. <script setup>
  33. import wSwiper from '@/components/wSwiper/wSwiper.vue';
  34. import danxuan from "@/components/question/danxuan.vue";
  35. import panduan from "@/components/question/panduan.vue";
  36. import tiankong from "@/components/question/tiankong.vue";
  37. import chengji from "@/components/chengji/chengji.vue";
  38. import uniPointsVue from '@/components/points/uni-points.vue';
  39. import * as httpUnit from "@/api/unitTest.js"
  40. import {
  41. catchError,
  42. } from "@/utils/common.js"
  43. import {
  44. useExam
  45. } from './useUnit';
  46. import {
  47. ref,
  48. } from "vue";
  49. import cacheManager from "@/utils/cacheManager";
  50. const {
  51. count,
  52. total,
  53. current,
  54. list,
  55. rightAnswer,
  56. wrongAnswer,
  57. jifen,
  58. zhangId,
  59. jieId,
  60. nianji,
  61. xueke,
  62. showTishi,
  63. haveFlag,
  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. const [err, data] = await catchError(httpUnit.getnextZhangInfo({
  79. nianji: nianji.value,
  80. cardId: xueke.value,
  81. zhangId: zhangId.value
  82. }))
  83. cacheManager.updateObject('auth', {
  84. zhangId: data.zhangId,
  85. })
  86. uni.redirectTo({
  87. url: `/pages/study/index`
  88. })
  89. }
  90. function handleBack() {
  91. // 数学
  92. uni.redirectTo({
  93. url: `/pages/study/index`
  94. })
  95. }
  96. function onSwiperChange(index) {
  97. current.value = index;
  98. uni.$emit('swiper-change', index)
  99. }
  100. </script>
  101. <style lang="scss" scoped>
  102. .swiper-box {
  103. height: 200px;
  104. }
  105. .swiper-item {
  106. display: flex;
  107. flex-direction: column;
  108. justify-content: center;
  109. align-items: center;
  110. height: 200px;
  111. }
  112. </style>