index.vue 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  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. <yingyuDanxuan :question="item" v-if="item.type == '4'" :placeholders="item.placeholders">
  16. </yingyuDanxuan>
  17. </view>
  18. </template>
  19. </w-swiper>
  20. <view class="exam-submit-btn" v-if="current === list.length-1" @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" :cardId="cardId"></chengji>
  28. <!-- 分数弹窗 -->
  29. <uniPointsVue ref="uniPointsRef" @checkAnswer="checkAnswer" @goStudy="goStudyContinue" :isLastZhang="!!haveFlag"
  30. :studyFlag="studyFlag"></uniPointsVue>
  31. <!-- 填空 -->
  32. <FillItem :value="result" ref="popupRef" @blur="onBlur"></FillItem>
  33. </view>
  34. </template>
  35. <script setup>
  36. import mtaRadio from '@/components/question/yingyu/mtaRadio.vue'
  37. import FillItem from "@/components/question/FillItem.vue";
  38. import wSwiper from '@/components/wSwiper/wSwiper.vue';
  39. import danxuan from "@/components/question/danxuan.vue";
  40. import panduan from "@/components/question/panduan.vue";
  41. import tiankong from "@/components/question/tiankong.vue";
  42. import yingyuDanxuan from "@/components/question/yingyu/danxuan.vue";
  43. import chengji from "@/components/chengji/chengji.vue";
  44. import uniPointsVue from '@/components/points/uni-points.vue';
  45. import * as httpUnit from "@/api/unitTest.js"
  46. import {
  47. catchError,
  48. } from "@/utils/common.js"
  49. import {
  50. useExam
  51. } from './useUnit';
  52. import {
  53. ref,
  54. reactive
  55. } from "vue";
  56. import cacheManager from "@/utils/cacheManager";
  57. import {
  58. onLoad
  59. } from "@dcloudio/uni-app"
  60. const {
  61. count,
  62. total,
  63. current,
  64. list,
  65. rightAnswer,
  66. wrongAnswer,
  67. jifen,
  68. zhangId,
  69. jieId,
  70. nianji,
  71. studyFlag,
  72. xueke,
  73. showTishi,
  74. haveFlag,
  75. activeZhang,
  76. handleSubmit,
  77. initPage,
  78. handleCloseTishi
  79. } = useExam();
  80. const cardId = Number(cacheManager.get('auth').cardId);
  81. const uniPointsRef = ref(null);
  82. const chengjiRef = ref(null);
  83. const popupRef = ref(null);
  84. const result = ref('');
  85. const curTiankong = ref(null);
  86. function getPopupRef() {
  87. return popupRef.value;
  88. }
  89. onLoad(() => {
  90. uni.$on('tiankong-fillItem', (val) => {
  91. const {
  92. index,
  93. question
  94. } = val;
  95. curTiankong.value = val;
  96. result.value = question.reply[index];
  97. const dom = getPopupRef();
  98. dom && dom.showPopup();
  99. })
  100. })
  101. function onBlur({
  102. result
  103. }) {
  104. if (curTiankong.value) {
  105. uni.$emit('tiankong-setResult', {
  106. index: curTiankong.value.index,
  107. stId: curTiankong.value.question.stId,
  108. result
  109. });
  110. }
  111. const dom = getPopupRef();
  112. dom && dom.handleClear();
  113. }
  114. // 查看答案
  115. function checkAnswer() {
  116. chengjiRef.value.showPopup();
  117. }
  118. // 继续学习
  119. async function goStudyContinue() {
  120. const list = cacheManager.get('zhangInfo').zhangList;
  121. // 设置 从单元测试 到 岛 的路由参数
  122. activeZhang.value.nextZhang ? activeZhang.value.nextZhang.zhangId : null;
  123. cacheManager.updateObject('auth', {
  124. currentZhang: list.findIndex(item => item.zhangId == activeZhang.value.nextZhang.zhangId),
  125. zhangId: activeZhang.value.nextZhang.zhangId
  126. })
  127. uni.redirectTo({
  128. url: `/pages/study/index`
  129. })
  130. }
  131. function handleBack() {
  132. // 数学
  133. uni.redirectTo({
  134. url: `/pages/study/index`
  135. })
  136. uni.$emit('back-outpage')
  137. }
  138. function onSwiperChange(index) {
  139. current.value = index;
  140. uni.$emit('swiper-change', index)
  141. }
  142. function courseBjFun() {
  143. switch (cardId) {
  144. case 1:
  145. return 'static/images/course/couse-shuxue-bj.png'
  146. break;
  147. case 2:
  148. return 'static/images/course/course-yingyu-bj.png'
  149. break;
  150. default:
  151. break;
  152. }
  153. }
  154. </script>
  155. <style lang="scss" scoped>
  156. .swiper-box {
  157. height: 200px;
  158. }
  159. .swiper-item {
  160. display: flex;
  161. flex-direction: column;
  162. justify-content: center;
  163. align-items: center;
  164. height: 200px;
  165. }
  166. </style>