index.vue 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  1. <template>
  2. <view class="ezy-exam-page" :style="{backgroundImage: 'url(' + courseBjFun() + ')'}">
  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">{{current+1}}</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" :cardId="cardId"></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 cardId = Number(cacheManager.get('auth').cardId);
  74. const uniPointsRef = ref(null);
  75. const chengjiRef = ref(null);
  76. const popupRef= ref(null);
  77. const result = ref('');
  78. const curTiankong = ref(null);
  79. function getPopupRef() {
  80. return popupRef.value;
  81. }
  82. onLoad(() => {
  83. uni.$on('tiankong-fillItem',(val) => {
  84. const {index,question} = val;
  85. curTiankong.value = val;
  86. result.value = question.reply[index];
  87. const dom = getPopupRef();
  88. dom && dom.showPopup();
  89. })
  90. })
  91. function onBlur({result}) {
  92. if (curTiankong.value) {
  93. uni.$emit('tiankong-setResult', {index: curTiankong.value.index,stId:curTiankong.value.question.stId,result});
  94. }
  95. const dom = getPopupRef();
  96. dom && dom.handleClear();
  97. }
  98. // 查看答案
  99. function checkAnswer() {
  100. chengjiRef.value.showPopup();
  101. }
  102. // 继续学习
  103. async function goStudyContinue() {
  104. // 设置 从单元测试 到 岛 的路由参数
  105. activeZhang.value.nextZhang ? activeZhang.value.nextZhang.zhangId : null;
  106. cacheManager.updateObject('auth', {
  107. zhangId: activeZhang.value.nextZhang.zhangId,
  108. })
  109. uni.redirectTo({
  110. url: `/pages/study/index`
  111. })
  112. }
  113. function handleBack() {
  114. // 数学
  115. uni.redirectTo({
  116. url: `/pages/study/index`
  117. })
  118. }
  119. function onSwiperChange(index) {
  120. current.value = index;
  121. uni.$emit('swiper-change', index)
  122. }
  123. function courseBjFun() {
  124. switch (cardId) {
  125. case 1:
  126. return 'static/images/course/couse-shuxue-bj.png'
  127. break;
  128. case 2:
  129. return 'static/images/course/course-yingyu-bj.png'
  130. break;
  131. default:
  132. break;
  133. }
  134. }
  135. </script>
  136. <style lang="scss" scoped>
  137. .swiper-box {
  138. height: 200px;
  139. }
  140. .swiper-item {
  141. display: flex;
  142. flex-direction: column;
  143. justify-content: center;
  144. align-items: center;
  145. height: 200px;
  146. }
  147. </style>