index.vue 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  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" :studyFlag="studyFlag"></uniPointsVue>
  29. <!-- 填空 -->
  30. <FillItem :value="result" ref="popupRef" @blur="onBlur"></FillItem>
  31. </view>
  32. </template>
  33. <script setup>
  34. import FillItem from "@/components/question/FillItem.vue";
  35. import wSwiper from '@/components/wSwiper/wSwiper.vue';
  36. import danxuan from "@/components/question/danxuan.vue";
  37. import panduan from "@/components/question/panduan.vue";
  38. import tiankong from "@/components/question/tiankong.vue";
  39. import chengji from "@/components/chengji/chengji.vue";
  40. import uniPointsVue from '@/components/points/uni-points.vue';
  41. import * as httpUnit from "@/api/unitTest.js"
  42. import {
  43. catchError,
  44. } from "@/utils/common.js"
  45. import {
  46. useExam
  47. } from './useUnit';
  48. import {
  49. ref,
  50. } from "vue";
  51. import cacheManager from "@/utils/cacheManager";
  52. import {onLoad} from "@dcloudio/uni-app"
  53. const {
  54. count,
  55. total,
  56. current,
  57. list,
  58. rightAnswer,
  59. wrongAnswer,
  60. jifen,
  61. zhangId,
  62. jieId,
  63. nianji,
  64. studyFlag,
  65. xueke,
  66. showTishi,
  67. haveFlag,
  68. activeZhang,
  69. handleSubmit,
  70. initPage,
  71. handleCloseTishi
  72. } = useExam();
  73. const uniPointsRef = ref(null);
  74. const chengjiRef = ref(null);
  75. const popupRef= ref(null);
  76. const result = ref('');
  77. const curTiankong = ref(null);
  78. function getPopupRef() {
  79. return popupRef.value;
  80. }
  81. onLoad(() => {
  82. uni.$on('tiankong-fillItem',(val) => {
  83. const {index,question} = val;
  84. curTiankong.value = val;
  85. result.value = question.reply[index];
  86. const dom = getPopupRef();
  87. dom && dom.showPopup();
  88. })
  89. })
  90. function onBlur({result}) {
  91. if (curTiankong.value) {
  92. uni.$emit('tiankong-setResult', {index: curTiankong.value.index,stId:curTiankong.value.question.stId,result});
  93. }
  94. const dom = getPopupRef();
  95. dom && dom.handleClear();
  96. }
  97. // 查看答案
  98. function checkAnswer() {
  99. chengjiRef.value.showPopup();
  100. }
  101. // 继续学习
  102. async function goStudyContinue() {
  103. // 设置 从单元测试 到 岛 的路由参数
  104. activeZhang.value.nextZhang ? activeZhang.value.nextZhang.zhangId : null;
  105. cacheManager.updateObject('auth', {
  106. zhangId: activeZhang.value.nextZhang.zhangId,
  107. })
  108. uni.redirectTo({
  109. url: `/pages/study/index`
  110. })
  111. }
  112. function handleBack() {
  113. // 数学
  114. uni.redirectTo({
  115. url: `/pages/study/index`
  116. })
  117. }
  118. function onSwiperChange(index) {
  119. current.value = index;
  120. uni.$emit('swiper-change', index)
  121. }
  122. </script>
  123. <style lang="scss" scoped>
  124. .swiper-box {
  125. height: 200px;
  126. }
  127. .swiper-item {
  128. display: flex;
  129. flex-direction: column;
  130. justify-content: center;
  131. align-items: center;
  132. height: 200px;
  133. }
  134. </style>