index.vue 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. <template>
  2. <view>
  3. <view>
  4. <uni-icons type="left" size="30" @click="handleBack"></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. xueqi,
  60. nextQuestion,
  61. prevQuestion,
  62. handleSubmit,
  63. initPage
  64. } = useExam();
  65. const uniPointsRef = ref(null);
  66. const chengjiRef = ref(null);
  67. // 查看答案
  68. function checkAnswer() {
  69. chengjiRef.value.showPopup();
  70. }
  71. // 继续学习
  72. function goStudyContinue() {
  73. // 设置 从单元测试 到 岛 的路由参数
  74. setStudyStorage({
  75. nianji: nianji.value,
  76. xueqi: xueqi.value,
  77. zhangId: nextZhangId.value,
  78. jieId: jieId.value,
  79. nextZhangId: null,
  80. });
  81. uni.switchTab({
  82. url: `/pages/study/index`
  83. })
  84. }
  85. function handleBack() {
  86. // 设置 从单元测试 到 岛 的路由参数
  87. setStudyStorage({
  88. nianji: nianji.value,
  89. xueqi: xueqi.value,
  90. zhangId: zhangId.value,
  91. jieId: jieId.value,
  92. nextZhangId: nextZhangId.value,
  93. });
  94. uni.switchTab({
  95. url: `/pages/study/index`
  96. })
  97. }
  98. </script>
  99. <style lang="scss" scoped>
  100. .swiper-box {
  101. height: 200px;
  102. }
  103. .swiper-item {
  104. display: flex;
  105. flex-direction: column;
  106. justify-content: center;
  107. align-items: center;
  108. height: 200px;
  109. }
  110. </style>