index.vue 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. <template>
  2. <view>
  3. <view>
  4. <uni-icons type="left" size="30" @click=""></uni-icons>
  5. <text>单元测试</text>
  6. <view><text>{{count}}</text>/<text>{{total}}</text></view>
  7. </view>
  8. <w-swiper :list="list" :swiperHeight="300" :positionIndex="current">
  9. <template v-slot:default="{item}">
  10. <view class="body" v-if="item.mta_show">
  11. <danxuan :question="item" v-if="item.type == '1'"></danxuan>
  12. <panduan :question="item" v-if="item.type == '2'"></panduan>
  13. <tiankong :question="item" v-if="item.type == '3'"></tiankong>
  14. </view>
  15. </template>
  16. </w-swiper>
  17. <button class="transition-button" v-if="isLast" type="primary"
  18. @click="handleSubmit(uniPointsRef)">submit</button>
  19. <!-- 答卷 -->
  20. <chengji ref="chengjiRef" :list="list" :jieId="jieId" :zhangId="zhangId" :nextZhangId="nextZhangId"
  21. :nianji="nianji" :xueqi="xueqi"></chengji>
  22. <!-- 分数弹窗 -->
  23. <uniPointsVue ref="uniPointsRef" @checkAnswer="checkAnswer" @goStudy="goStudyContinue"></uniPointsVue>
  24. </view>
  25. </template>
  26. <script setup>
  27. import questionJiexi from '@/components/questionJiexi/questionJiexi.vue';
  28. import wSwiper from '@/components/wSwiper/wSwiper.vue';
  29. import danxuan from "@/components/question/danxuan.vue";
  30. import panduan from "@/components/question/panduan.vue";
  31. import tiankong from "@/components/question/tiankong.vue";
  32. import chengji from "@/components/chengji/chengji.vue";
  33. import uniPointsVue from '@/components/points/uni-points.vue';
  34. import {
  35. useStudyRouteParams
  36. } from "@/utils/emitEvents.js"
  37. import {
  38. useExam
  39. } from './useUnit';
  40. import {
  41. ref,
  42. onMounted
  43. } from "vue";
  44. const {setStudyStorage} = useStudyRouteParams();
  45. const {
  46. isFirst,
  47. isLast,
  48. count,
  49. total,
  50. current,
  51. list,
  52. rightAnswer,
  53. wrongAnswer,
  54. jifen,
  55. zhangId,
  56. jieId,
  57. nextZhangId,
  58. nianji,
  59. nextQuestion,
  60. prevQuestion,
  61. handleSubmit,
  62. initPage
  63. } = useExam();
  64. const uniPointsRef = ref(null);
  65. const chengjiRef = ref(null);
  66. function sendDataToStudyPage() {
  67. // 设置 从单元测试 到 岛 的路由参数
  68. setStudyStorage({
  69. nianji: nianji.value,
  70. xueqi: xueqi.value,
  71. zhangId: zhangId.value,
  72. jieId: jieId.value,
  73. nextZhangId: nextZhangId.value,
  74. });
  75. }
  76. // 查看答案
  77. function checkAnswer() {
  78. chengjiRef.value.showPopup();
  79. }
  80. // 继续学习
  81. function goStudyContinue() {
  82. sendDataToStudyPage();
  83. uni.switchTab({
  84. url: `/pages/study/index?zhangId`
  85. })
  86. }
  87. </script>
  88. <style lang="scss" scoped>
  89. .swiper-box {
  90. height: 200px;
  91. }
  92. .swiper-item {
  93. display: flex;
  94. flex-direction: column;
  95. justify-content: center;
  96. align-items: center;
  97. height: 200px;
  98. }
  99. </style>