chengji.vue 2.8 KB

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