index.vue 4.5 KB

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