knowledge-practice-detail.vue 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. <template>
  2. <ie-page bg-color="#F6F8FA" :fix-height="true">
  3. <ie-navbar :title="pageTitle" />
  4. <view v-if="examineeData" class="relative z-3 pt-30 pb-20 mx-30">
  5. <view class="bg-white rounded-15 px-20 pb-1">
  6. <rate-chart :value="rightRate" />
  7. <view class="h-1 bg-[#E6E6E6] my-20"></view>
  8. <view>
  9. <view v-if="prevData.directed" class="my-20 flex items-center justify-between text-24">
  10. <ie-image src="/pagesStudy/static/image/icon-house.png" custom-class="w-24 h-24" mode="aspectFill" />
  11. <text class="ml-10 text-fore-light flex-1">练习科目</text>
  12. <text class="text-fore-title">{{ examineeData.collegeName }}-{{ examineeData.majorName }}</text>
  13. </view>
  14. <view class="my-20 flex items-center justify-between text-24">
  15. <ie-image src="/pagesStudy/static/image/icon-group.png" custom-class="w-24 h-24" mode="aspectFill" />
  16. <text class="ml-10 text-fore-light flex-1">练习知识点</text>
  17. <text class="text-fore-title">{{ prevData.name || '-' }}</text>
  18. </view>
  19. <view class="my-20 flex items-center justify-between text-24">
  20. <ie-image src="/pagesStudy/static/image/icon-clock.png" custom-class="w-24 h-24" mode="aspectFill" />
  21. <text class="ml-10 text-fore-light flex-1">练习时长</text>
  22. <text class="text-fore-title">{{ formatTime(examineeData.duration) || '-' }}</text>
  23. </view>
  24. </view>
  25. </view>
  26. <exam-stat :data="examineeData" :show-stats="false" @detail="handleQuestionDetail" />
  27. </view>
  28. <ie-safe-toolbar :height="84" :shadow="false">
  29. <view class="h-[84px] px-46 bg-white flex items-center justify-between gap-x-40">
  30. <view class="text-30 text-primary bg-back flex-1 py-22 rounded-full text-center" @click="handleStartPractice">
  31. 继续刷题
  32. </view>
  33. <view class="text-30 text-white bg-primary flex-1 py-22 rounded-full text-center" @click="handleViewAnalysis">
  34. 查看解析
  35. </view>
  36. </view>
  37. </ie-safe-toolbar>
  38. </ie-page>
  39. </template>
  40. <script lang="ts" setup>
  41. import RateChart from '@/pagesStudy/pages/simulation-analysis/components/rate-chart.vue';
  42. import ExamStat from '@/pagesStudy/pages/simulation-analysis/components/exam-stat.vue';
  43. import { useTransferPage } from '@/hooks/useTransferPage';
  44. import { Study, Transfer } from '@/types';
  45. import { getExamineeResult } from '@/api/modules/study';
  46. import { EnumPaperType } from '@/common/enum';
  47. const { prevData, transferTo } = useTransferPage<Transfer.PracticeResultPageOptions, Transfer.ExamAnalysisPageOptions>();
  48. const rightRate = computed(() => {
  49. const { totalCount = 0, wrongCount = 0 } = examineeData.value || {};
  50. const rate = (totalCount - wrongCount) / totalCount * 100;
  51. return Number(rate.toFixed(1));
  52. });
  53. const paperName = computed(() => {
  54. return '知识点练习-' + prevData.value.name;
  55. });
  56. const examineeData = ref<Study.Examinee>();
  57. const pageTitle = computed(() => {
  58. return '练习结果';
  59. });
  60. const formatTime = (time: number) => {
  61. if (!time) {
  62. return '';
  63. }
  64. const hours = Math.floor(time / 3600);
  65. const minutes = Math.floor((time % 3600) / 60);
  66. const seconds = time % 60;
  67. if (hours >= 1) {
  68. return `${hours}时${minutes}分${seconds}秒`;
  69. } else {
  70. return `${minutes}分${seconds}秒`;
  71. }
  72. };
  73. const handleQuestionDetail = (item: Study.Question) => {
  74. console.log(item, examineeData)
  75. if (!examineeData.value) {
  76. return;
  77. }
  78. transferTo('/pagesStudy/pages/exam-start/exam-start', {
  79. data: {
  80. name: paperName.value,
  81. paperType: prevData.value.paperType || EnumPaperType.PRACTICE,
  82. readonly: true,
  83. questionId: item.id,
  84. practiceInfo: {
  85. name: prevData.value.name,
  86. relateId: examineeData.value.knowledgeId,
  87. directed: prevData.value.directed,
  88. examineeId: examineeData.value.examineeId
  89. },
  90. }
  91. });
  92. }
  93. const handleStartPractice = () => {
  94. const { knowledgeId } = examineeData.value || {};
  95. if (!knowledgeId) {
  96. console.error('knowledgeId is null');
  97. return;
  98. }
  99. transferTo('/pagesStudy/pages/exam-start/exam-start', {
  100. data: {
  101. name: paperName.value,
  102. paperType: prevData.value.paperType || EnumPaperType.PRACTICE,
  103. practiceInfo: {
  104. name: prevData.value.name,
  105. relateId: knowledgeId,
  106. directed: prevData.value.directed
  107. },
  108. }
  109. });
  110. }
  111. const handleViewAnalysis = () => {
  112. if (!examineeData.value) {
  113. return;
  114. }
  115. transferTo('/pagesStudy/pages/exam-start/exam-start', {
  116. data: {
  117. name: paperName.value,
  118. paperType: EnumPaperType.PRACTICE,
  119. readonly: true,
  120. practiceInfo: {
  121. name: prevData.value.name,
  122. relateId: examineeData.value.knowledgeId,
  123. directed: prevData.value.directed,
  124. examineeId: examineeData.value.examineeId
  125. },
  126. }
  127. });
  128. }
  129. const loadData = async () => {
  130. uni.$ie.showLoading();
  131. try {
  132. const res = await getExamineeResult(prevData.value.examineeId);
  133. examineeData.value = res.data;
  134. } finally {
  135. uni.$ie.hideLoading();
  136. }
  137. }
  138. onLoad(() => {
  139. loadData();
  140. });
  141. </script>
  142. <style lang="scss" scoped></style>