index.vue 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  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'"></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" :jieId="jieId" :zhangId="zhangId"
  27. :nianji="nianji" :xueqi="xueqi"></chengji>
  28. <!-- 分数弹窗 -->
  29. <uniPointsVue ref="uniPointsRef" @checkAnswer="checkAnswer" @goStudy="goStudyContinue"></uniPointsVue>
  30. </view>
  31. </template>
  32. <script setup>
  33. import questionJiexi from '@/components/questionJiexi/questionJiexi.vue';
  34. import wSwiper from '@/components/wSwiper/wSwiper.vue';
  35. import danxuan from "@/components/question/danxuan.vue";
  36. import panduan from "@/components/question/panduan.vue";
  37. import tiankong from "@/components/question/tiankong.vue";
  38. import chengji from "@/components/chengji/chengji.vue";
  39. import uniPointsVue from '@/components/points/uni-points.vue';
  40. import * as httpUnit from "@/api/unitTest.js"
  41. import {
  42. catchError,
  43. toast
  44. } from "@/utils/common.js"
  45. import {
  46. useStudyRouteParams
  47. } from "@/utils/emitEvents.js"
  48. import {
  49. useExam
  50. } from './useUnit';
  51. import {
  52. ref,
  53. onMounted
  54. } from "vue";
  55. const {setStudyStorage} = useStudyRouteParams();
  56. const showTishi = ref(true);
  57. const {
  58. count,
  59. total,
  60. current,
  61. list,
  62. rightAnswer,
  63. wrongAnswer,
  64. jifen,
  65. zhangId,
  66. jieId,
  67. nianji,
  68. xueqi,
  69. handleSubmit,
  70. initPage
  71. } = useExam();
  72. const uniPointsRef = ref(null);
  73. const chengjiRef = ref(null);
  74. // 查看答案
  75. function checkAnswer() {
  76. chengjiRef.value.showPopup();
  77. }
  78. // 继续学习
  79. async function goStudyContinue() {
  80. // 设置 从单元测试 到 岛 的路由参数
  81. const [err, data] = await catchError(httpUnit.getnextZhangInfo({
  82. nianji: nianji.value,
  83. xueqi: xueqi.value,
  84. zhangId: zhangId.value
  85. }))
  86. uni.navigateTo({
  87. url: `/pages/study/index?nianji=${nianji.value}&xueqi=${xueqi.value}&zhangId=${data.zhangId}&jieId=${jieId.value}`
  88. })
  89. }
  90. function handleBack() {
  91. uni.navigateTo({
  92. url: `/pages/study/index?nianji=${nianji.value}&xueqi=${xueqi.value}&zhangId=${zhangId.value}&jieId=${jieId.value}`
  93. })
  94. }
  95. function onSwiperChange(index) {
  96. current.value = index;
  97. }
  98. // 大鹅关闭追加缓存 --- 单独针对当前手机的缓存提示
  99. function handleCloseTishi() {
  100. uni.setStorageSync('isShowTishi','has');
  101. showTishi.value = false;
  102. }
  103. // 大鹅显示追加缓存 --- 单独针对当前手机的缓存提示
  104. function handleShowTishi() {
  105. const isNotShow = Boolean(uni.getStorageSync('isShowTishi'));
  106. showTishi.value = !isNotShow;
  107. }
  108. </script>
  109. <style lang="scss" scoped>
  110. .swiper-box {
  111. height: 200px;
  112. }
  113. .swiper-item {
  114. display: flex;
  115. flex-direction: column;
  116. justify-content: center;
  117. align-items: center;
  118. height: 200px;
  119. }
  120. </style>