paper-objective.vue 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. <template>
  2. <view class="page-content">
  3. <mx-nav-bar title="必刷题"/>
  4. <view class="p-30">
  5. <view class="bg-white p-30 mx-card">
  6. <view class="fx-row fx-bet-sta">
  7. <view class="fx-col gap-5">
  8. <view class="text-main font-[FZBangSKJW] objective-paper-major">
  9. {{ prevData.subjectName }}
  10. </view>
  11. <view class="text-2xs text-tips">{{ statTips }}</view>
  12. </view>
  13. <view v-if="showTendency">
  14. <mx-subsection v-model="current" :list="chartTypes" width="140px"/>
  15. </view>
  16. </view>
  17. <template v-if="chartData">
  18. <accuracy-chart v-if="current==0" :value="chartData.accuracy"/>
  19. <recent-detail-chart v-if="current==1" :data="chartData.recentDetails"/>
  20. </template>
  21. <uv-gap v-else height="240"/>
  22. <completed-progress :accuracy="chartData&&chartData.accuracy"
  23. :completed="chartData&&chartData.completed"
  24. :total="chartData&&chartData.total"/>
  25. </view>
  26. </view>
  27. <view class="my-20 text-center">
  28. <text v-if="showExamTip" class="text-2xs text-tips">没有做题记录,快来开始做题吧!</text>
  29. </view>
  30. <view class="mb-40 flex justify-center">
  31. <uv-button type="primary" shape="circle" size="large" text="开始刷题"
  32. color="linear-gradient(to right, var(--primary-light-color), var(--primary-deep-color))"
  33. :custom-style="{width: '55vw', height: '44px'}" @click="handleExam"/>
  34. </view>
  35. </view>
  36. </template>
  37. <script setup>
  38. import {ref, computed, onMounted} from 'vue'
  39. import {useTransfer} from "@/hooks/useTransfer";
  40. import mxConst from "@/common/mxConst";
  41. import {getObjectivePaperStatistic} from "@/api/webApi/paper";
  42. import CompletedProgress from "@/pages/topic-center/paper-objective/components/completed-progress.vue";
  43. import AccuracyChart from "@/pages/topic-center/paper-objective/components/accuracy-chart.vue";
  44. import RecentDetailChart from "@/pages/topic-center/paper-objective/components/recent-detail-chart.vue";
  45. const loaded = ref(false)
  46. const chartTypes = ref(['正确率', '趋势图'])
  47. const current = ref(0)
  48. const chartData = ref(null)
  49. const {prevData, transferTo, onPageCallback} = useTransfer()
  50. const statTips = computed(() => current.value == 0 ? '必刷题分析' : '最近刷题正确率趋势')
  51. const showExamTip = computed(() => chartData.value?.recentDetails?.length == 0)
  52. const showTendency = computed(() => chartData.value?.recentDetails?.length > 2)
  53. onMounted(() => loadChartData())
  54. onPageCallback((data) => {
  55. if (data) {
  56. loaded.value = false
  57. loadChartData()
  58. }
  59. })
  60. const loadChartData = () => {
  61. if (loaded.value) return
  62. loaded.value = true
  63. const {subjectId} = prevData.value
  64. getObjectivePaperStatistic({subjectId}).then(res => {
  65. chartData.value = res.data || {}
  66. })
  67. }
  68. const handleExam = () => {
  69. const {type, testType, subjectId} = prevData.value
  70. const next = {
  71. type, testType, subjectId,
  72. title: '必刷题',
  73. callback: mxConst.globalEvents.paperCompleted
  74. }
  75. transferTo('/pages/topic-center/paper-exam/paper-exam', next)
  76. }
  77. </script>
  78. <style lang="scss">
  79. .objective-paper-major {
  80. position: relative;
  81. z-index: 1;
  82. }
  83. .objective-paper-major::before {
  84. content: " ";
  85. position: absolute;
  86. width: 40px;
  87. height: 8px;
  88. left: -3px;
  89. bottom: 0;
  90. z-index: -1;
  91. border-radius: 4px;
  92. background: linear-gradient(90deg, #62B6FF, #fff);
  93. }
  94. </style>