unitAnswer.vue 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  1. <template>
  2. <uni-popup ref="popupRef" :animation="false" :is-mask-click="false"
  3. mask-background-color="rgba(255, 255, 255, 0.6);" class="ezy-popup-width-all">
  4. <view class="ezy-result-page">
  5. <view class="icon-title-navBar-box">
  6. <view @click="handleBack" class="nav-bar-icon"></view>
  7. <view class="nav-bar-title">成绩</view>
  8. </view>
  9. <view class="shiti-frame-box">
  10. <w-swiper :list="myList" :positionIndex="current" class="result-exam-swiper" @change="onSwiperChange">
  11. <template v-slot:default="{item,index}">
  12. <view class="body" v-if="item.mta_show">
  13. <danxuan :question="item" showError v-if="item.type == '1'"></danxuan>
  14. <panduan :question="item" showError v-if="item.type == '2'"></panduan>
  15. <tiankong :question="item" showError v-if="item.type == '3'"
  16. :placeholders="item.placeholders"></tiankong>
  17. <view class="answer-content-box">
  18. <view class="answer-dtjx-row">
  19. <view class="answer-title"></view>
  20. <!-- 答案解析 -->
  21. <view @click="showJiexiPopup(item)" class="answer-btn"></view>
  22. </view>
  23. <view class="answer-btn-box" v-if="item.type!=3">
  24. <!-- 你的答案 -->
  25. <view class="answer-item-left">
  26. <text class="answer-item-title">您的答案</text>
  27. <text class="answer-item-error">{{showAnswerReply(item)}}</text>
  28. <view class="answer-line"></view>
  29. </view>
  30. <!-- 答案 -->
  31. <view class="answer-item-right">
  32. <text class="answer-item-title">正确答案</text>
  33. <text class="answer-item-correct">{{showAnswerResult(item)}}</text>
  34. </view>
  35. </view>
  36. <view v-else>
  37. <!-- 答案 -->
  38. <view class="tiankong-answer-content-box">
  39. <view v-for="(ict,cindex) in showAnswerResult(item)" :key="cindex"
  40. class="tiankong-answer-row">
  41. <text>{{cindex+1}}. </text>
  42. <text v-for="(xItem,xindex) in ict" :key="xindex">
  43. <text> {{xItem}} </text>
  44. <text v-if="xindex != ict.length-1">/</text>
  45. </text>
  46. </view>
  47. </view>
  48. </view>
  49. </view>
  50. </view>
  51. </template>
  52. </w-swiper>
  53. </view>
  54. </view>
  55. <!-- 解析浮层数据 -->
  56. <questionJiexi ref="jiexiRef"></questionJiexi>
  57. </uni-popup>
  58. </template>
  59. <script setup>
  60. import questionJiexi from './questionJiexi.vue';
  61. import wSwiper from '@/components/wSwiper/wSwiper.vue';
  62. import danxuan from "@/components/question/danxuan.vue";
  63. import panduan from "@/components/question/panduan.vue";
  64. import tiankong from "@/components/question/tiankong.vue";
  65. import {
  66. useQuestionTools
  67. } from "@/components/question/useQuestionTools.js";
  68. import {
  69. computed
  70. } from "vue";
  71. const {
  72. getLetterByIndex
  73. } = useQuestionTools();
  74. import {
  75. ref
  76. } from "vue";
  77. const props = defineProps({
  78. list: {
  79. type: Array,
  80. },
  81. code: {
  82. type: String,
  83. default: 'cj'
  84. }
  85. })
  86. const myList = computed(() => {
  87. return props.list.map(item => {
  88. return {
  89. ...item,
  90. code: 'cj'
  91. }
  92. })
  93. })
  94. const emits = defineEmits(['back'])
  95. const current = ref(0)
  96. const popupRef = ref(null)
  97. const jiexiRef = ref(null);
  98. function onSwiperChange(index) {
  99. uni.$emit('swiper-change', index)
  100. }
  101. // 切换成绩
  102. function showPopup() {
  103. popupRef.value.open()
  104. }
  105. function closePopup() {
  106. popupRef.value.close()
  107. }
  108. // 展示
  109. function showJiexiPopup(data) {
  110. jiexiRef.value.showPopup(data);
  111. }
  112. function handleBack() {
  113. // 从 单元测试 到 岛 的路由参数
  114. emits('back')
  115. }
  116. function showAnswerResult(item) {
  117. if (item.type == 1) {
  118. // 单选题
  119. return getLetterByIndex(item.result)
  120. } else if (item.type == 2) {
  121. if (item.result == 1) {
  122. return '正确'
  123. } else {
  124. return '错误'
  125. }
  126. } else if (item.type == 4) {
  127. return getLetterByIndex(item.result)
  128. } else {
  129. return item.result
  130. }
  131. }
  132. function showAnswerReply(item) {
  133. if (item.type == 1) {
  134. if (item.reply == null) {
  135. return '未答'
  136. }
  137. // 单选题
  138. return getLetterByIndex(item.reply)
  139. } else if (item.type == 2) {
  140. if (item.reply == null) {
  141. return '未答'
  142. }
  143. if (item.reply == 1) {
  144. return '正确'
  145. } else {
  146. return '错误'
  147. }
  148. } else if (item.type == 4) {
  149. if (item.reply == null) {
  150. return '未答'
  151. }
  152. // 单选题
  153. return getLetterByIndex(item.reply)
  154. } else {
  155. return item.reply
  156. }
  157. }
  158. defineExpose({
  159. showPopup,
  160. closePopup
  161. })
  162. </script>