index.vue 3.6 KB

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