chengji.vue 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  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. useQuestionTools
  35. } from "@/components/question/useQuestionTools.js";
  36. const {
  37. getLetterByIndex
  38. } = useQuestionTools();
  39. import {
  40. ref
  41. } from "vue";
  42. const props = defineProps({
  43. list: {
  44. type: Array,
  45. },
  46. jieId: {
  47. type: [String, Number]
  48. },
  49. zhangId: {
  50. type: [String, Number]
  51. },
  52. nianji: {
  53. type: [String, Number]
  54. },
  55. xueqi: {
  56. type: [String,Number]
  57. }
  58. })
  59. const current = ref(0)
  60. const popupRef = ref(null)
  61. const jiexiRef = ref(null);
  62. // 切换成绩
  63. function showPopup() {
  64. popupRef.value.open()
  65. }
  66. // 展示
  67. function showJiexiPopup(data) {
  68. jiexiRef.value.showPopup(data);
  69. }
  70. function handleBack() {
  71. // 从 单元测试 到 岛 的路由参数
  72. uni.navigateTo({
  73. url: `/pages/study/index?nianji=${props.nianji}&xueqi=${props.xueqi}&zhangId=${props.zhangId}&jieId=${props.jieId}`
  74. })
  75. }
  76. function showAnswerResult(item) {
  77. if (item.type == 1) {
  78. // 单选题
  79. return getLetterByIndex(item.result)
  80. } else if (item.type == 3){
  81. if (item.result == 1) {
  82. return '正确'
  83. } else {
  84. return '错误'
  85. }
  86. } else {
  87. return item.result
  88. }
  89. }
  90. function showAnswerReply(item) {
  91. if (item.type == 1) {
  92. // 单选题
  93. return getLetterByIndex(item.reply)
  94. } else if (item.type == 3){
  95. if (item.reply == 1) {
  96. return '正确'
  97. } else {
  98. return '错误'
  99. }
  100. } else {
  101. return item.reply
  102. }
  103. }
  104. defineExpose({
  105. showPopup
  106. })
  107. </script>
  108. <style lang="scss">
  109. .popup-container {
  110. ::v-deep .uni-popup__wrapper.left {
  111. width: 100vw;
  112. }
  113. }
  114. </style>