unitAnswer.vue 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  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. <!-- 试题解析 -->
  50. <view>
  51. <view>试题解析:</view>
  52. <rich-text :nodes="item.answer"></rich-text>
  53. </view>
  54. <!-- 试题视频 -->
  55. <view>
  56. <view>视频讲解:</view>
  57. <view>
  58. <image :src="item.cover"></image>
  59. </view>
  60. </view>
  61. </view>
  62. </view>
  63. </template>
  64. </w-swiper>
  65. </view>
  66. </view>
  67. <!-- 解析浮层数据 -->
  68. <questionJiexi ref="jiexiRef"></questionJiexi>
  69. </uni-popup>
  70. </template>
  71. <script setup>
  72. import questionJiexi from './questionJiexi.vue';
  73. import wSwiper from '@/components/wSwiper/wSwiper.vue';
  74. import danxuan from "@/components/question/danxuan.vue";
  75. import panduan from "@/components/question/panduan.vue";
  76. import tiankong from "@/components/question/tiankong.vue";
  77. import {
  78. useQuestionTools
  79. } from "@/components/question/useQuestionTools.js";
  80. import {
  81. computed
  82. } from "vue";
  83. const {
  84. getLetterByIndex
  85. } = useQuestionTools();
  86. import {
  87. ref
  88. } from "vue";
  89. const props = defineProps({
  90. list: {
  91. type: Array,
  92. },
  93. code: {
  94. type: String,
  95. default: 'cj'
  96. }
  97. })
  98. const myList = computed(() => {
  99. return props.list.map(item => {
  100. return {
  101. ...item,
  102. code: 'cj'
  103. }
  104. })
  105. })
  106. const emits = defineEmits(['back'])
  107. const current = ref(0)
  108. const popupRef = ref(null)
  109. const jiexiRef = ref(null);
  110. function onSwiperChange(index) {
  111. uni.$emit('swiper-change', index)
  112. }
  113. // 切换成绩
  114. function showPopup() {
  115. popupRef.value.open()
  116. }
  117. function closePopup() {
  118. popupRef.value.close()
  119. }
  120. // 展示
  121. function showJiexiPopup(data) {
  122. jiexiRef.value.showPopup(data);
  123. }
  124. function handleBack() {
  125. // 从 单元测试 到 岛 的路由参数
  126. emits('back')
  127. }
  128. function showAnswerResult(item) {
  129. if (item.type == 1) {
  130. // 单选题
  131. return getLetterByIndex(item.result)
  132. } else if (item.type == 2) {
  133. if (item.result == 1) {
  134. return '正确'
  135. } else {
  136. return '错误'
  137. }
  138. } else if (item.type == 4) {
  139. return getLetterByIndex(item.result)
  140. } else {
  141. return item.result
  142. }
  143. }
  144. function showAnswerReply(item) {
  145. if (item.type == 1) {
  146. if (item.reply == null) {
  147. return '未答'
  148. }
  149. // 单选题
  150. return getLetterByIndex(item.reply)
  151. } else if (item.type == 2) {
  152. if (item.reply == null) {
  153. return '未答'
  154. }
  155. if (item.reply == 1) {
  156. return '正确'
  157. } else {
  158. return '错误'
  159. }
  160. } else if (item.type == 4) {
  161. if (item.reply == null) {
  162. return '未答'
  163. }
  164. // 单选题
  165. return getLetterByIndex(item.reply)
  166. } else {
  167. return item.reply
  168. }
  169. }
  170. defineExpose({
  171. showPopup,
  172. closePopup
  173. })
  174. </script>