unitTest.vue 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. <template>
  2. <view class="ezy-exam-page">
  3. <view class="icon-title-navBar-box">
  4. <view @click="handleBack" class="nav-bar-icon"></view>
  5. <text class="nav-bar-title">单元测试</text>
  6. </view>
  7. <view>
  8. <view>
  9. <view>当前学习进度</view>
  10. <view>{{data.current+1}}/{{data.total}}</view>
  11. </view>
  12. <progress :percent="data.current/data.total * 100" :border-radius="30" stroke-width="10" />
  13. </view>
  14. <view class="shiti-frame-box">
  15. <w-swiper :list="data.list" :current="data.current" class="ezy-exam-swiper" @change="onSwiperChange">
  16. <template v-slot:default="{item}">
  17. <view>
  18. <text v-if="item.type == '1'">单选题</text>
  19. <text v-if="item.type == '2'">判断题</text>
  20. <text v-if="item.type == '3'">填空题</text>
  21. </view>
  22. <view class="body" v-if="item.mta_show">
  23. <danxuan :question="item" v-if="item.type == '1'"></danxuan>
  24. <panduan :question="item" v-if="item.type == '2'"></panduan>
  25. <tiankong :question="item" v-if="item.type == '3'" :placeholders="item.placeholders"></tiankong>
  26. </view>
  27. </template>
  28. </w-swiper>
  29. </view>
  30. <!-- 左右滑动提示 -->
  31. <view>
  32. <view>
  33. < <text>左右滑动查看更多题目</text>>
  34. </view>
  35. </view>
  36. <!-- 填空 -->
  37. <FillItem :value="result" ref="popupRef" @blur="onBlur"></FillItem>
  38. </view>
  39. </template>
  40. <script setup>
  41. import mtaRadio from '@/components/question/yingyu/mtaRadio.vue'
  42. import FillItem from "@/components/question/FillItem.vue";
  43. import wSwiper from '@/components/wSwiper/wSwiper.vue';
  44. import danxuan from "@/components/question/danxuan.vue";
  45. import panduan from "@/components/question/panduan.vue";
  46. import tiankong from "@/components/question/tiankong.vue";
  47. import * as httpApi from "@/api/chanpinShuxue.js"
  48. import {
  49. reactive,
  50. ref
  51. } from "vue"
  52. import {
  53. onLoad
  54. } from "@dcloudio/uni-app"
  55. import {
  56. useShuxueTest
  57. } from "./components/useShuxueUnitTest.js"
  58. const {
  59. data
  60. } = useShuxueTest()
  61. const curTiankong = ref(null);
  62. const result = ref('');
  63. const popupRef = ref(null);
  64. onLoad(() => {
  65. uni.$on('tiankong-fillItem', (val) => {
  66. const {
  67. index,
  68. question
  69. } = val;
  70. curTiankong.value = val;
  71. result.value = question.reply[index];
  72. const dom = getPopupRef();
  73. dom && dom.showPopup();
  74. })
  75. })
  76. function getPopupRef() {
  77. return popupRef.value;
  78. }
  79. function onBlur({
  80. result
  81. }) {
  82. if (curTiankong.value) {
  83. uni.$emit('tiankong-setResult', {
  84. index: curTiankong.value.index,
  85. stId: curTiankong.value.question.stId,
  86. result
  87. });
  88. }
  89. const dom = getPopupRef();
  90. dom && dom.handleClear();
  91. }
  92. function handleBack() {}
  93. function onSwiperChange(index) {
  94. current.value = index;
  95. uni.$emit('swiper-change', index)
  96. }
  97. </script>
  98. <style lang="scss" scoped>
  99. .swiper-box {
  100. height: 200px;
  101. }
  102. .swiper-item {
  103. display: flex;
  104. flex-direction: column;
  105. justify-content: center;
  106. align-items: center;
  107. height: 200px;
  108. }
  109. </style>