chengji.vue 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. <template>
  2. <uni-popup ref="popupRef" background-color="#fff" type="left" class="popup-container">
  3. <view>
  4. <uni-icons type="left" size="30" @click="handleBack"></uni-icons>
  5. <text>成绩</text>
  6. </view>
  7. <w-swiper :list="list" :swiperHeight="300" :positionIndex="current">
  8. <template v-slot:default="{item,index}">
  9. <view class="body" v-if="item.mta_show">
  10. {{item}}
  11. <danxuan :question="item" showError v-if="item.type == '1'"></danxuan>
  12. <panduan :question="item" showError v-if="item.type == '2'"></panduan>
  13. <tiankong :question="item" showError v-if="item.type == '3'"></tiankong>
  14. <!-- 答案解析 -->
  15. <button @click="showJiexiPopup(item)">show</button>
  16. <!-- 答案 -->
  17. <view>答案{{showAnswerResult(item)}}</view>
  18. <!-- 你的答案 -->
  19. <view>您的答案:{{showAnswerReply(item)}}</view>
  20. </view>
  21. </template>
  22. </w-swiper>
  23. <!-- 解析浮层数据 -->
  24. <questionJiexi ref="jiexiRef"></questionJiexi>
  25. </uni-popup>
  26. </template>
  27. <script setup>
  28. import questionJiexi from '@/components/questionJiexi/questionJiexi.vue';
  29. import wSwiper from '@/components/wSwiper/wSwiper.vue';
  30. import danxuan from "@/components/question/danxuan.vue";
  31. import panduan from "@/components/question/panduan.vue";
  32. import tiankong from "@/components/question/tiankong.vue";
  33. import {
  34. useStudyRouteParams
  35. } from "@/utils/emitEvents.js";
  36. import {
  37. useQuestionTools
  38. } from "@/components/question/useQuestionTools.js";
  39. const {
  40. getLetterByIndex
  41. } = useQuestionTools();
  42. import {
  43. ref
  44. } from "vue";
  45. const {
  46. setStudyStorage
  47. } = useStudyRouteParams();
  48. const props = defineProps({
  49. list: {
  50. type: Array,
  51. },
  52. jieId: {
  53. type: [String, Number]
  54. },
  55. zhangId: {
  56. type: [String, Number]
  57. },
  58. nextZhangId: {
  59. type: [String, Number]
  60. },
  61. nianji: {
  62. type: [String, Number]
  63. },
  64. xueqi: {
  65. type: [String,Number]
  66. }
  67. })
  68. const current = ref(0)
  69. const popupRef = ref(null)
  70. const jiexiRef = ref(null);
  71. // 切换成绩
  72. function showPopup() {
  73. popupRef.value.open()
  74. }
  75. // 展示
  76. function showJiexiPopup(data) {
  77. jiexiRef.value.showPopup(data);
  78. }
  79. function handleBack() {
  80. // 从 单元测试 到 岛 的路由参数
  81. setStudyStorage({
  82. nianji: props.nianji,
  83. xueqi:props.xueqi,
  84. zhangId: props.zhangId,
  85. jieId: props.jieId,
  86. nextZhangId: props.nextZhangId,
  87. });
  88. uni.switchTab({
  89. url: `/pages/study/index`
  90. })
  91. }
  92. function showAnswerResult(item) {
  93. if (item.type == 1) {
  94. // 单选题
  95. return getLetterByIndex(item.result)
  96. } else if (item.type == 3){
  97. if (item.result == 1) {
  98. return '正确'
  99. } else {
  100. return '错误'
  101. }
  102. } else {
  103. return item.result
  104. }
  105. }
  106. function showAnswerReply(item) {
  107. if (item.type == 1) {
  108. // 单选题
  109. return getLetterByIndex(item.reply)
  110. } else if (item.type == 3){
  111. if (item.reply == 1) {
  112. return '正确'
  113. } else {
  114. return '错误'
  115. }
  116. } else {
  117. return item.reply
  118. }
  119. }
  120. defineExpose({
  121. showPopup
  122. })
  123. </script>
  124. <style lang="scss">
  125. .popup-container {
  126. ::v-deep .uni-popup__wrapper.left {
  127. width: 100vw;
  128. }
  129. }
  130. </style>