index.vue 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. <template>
  2. <ie-page ref="iePageRef" bg-color="white">
  3. <ie-navbar>
  4. <template #headerLeft>
  5. <view class="flex items-center">
  6. <uv-icon name="arrow-left" size="20px" color="#333"></uv-icon>
  7. <ie-image :is-oss="true" src="/study-title.png" custom-class="ml-8 w-148 h-36" mode="heightFix" />
  8. <view class="w-6 h-6 rounded-2 bg-black mx-12"></view>
  9. <view>
  10. <ie-dict :dict-name="EnumDictName.EXAM_TYPE" :dict-value="userStore.getExamType || '--'" />
  11. </view>
  12. </view>
  13. </template>
  14. </ie-navbar>
  15. <view class="mx-30 mt-20 flex items-center bg-[#E3F4FA] rounded-8 py-16 px-16 gap-x-40">
  16. <view class="text-24 text-[#34B0D7] flex-1">
  17. <text v-if="!hasDirectedSchool">你还未开启定向学习,快来设置吧!</text>
  18. <view v-else class="flex items-center">
  19. <text class="flex-shrink-0">定向:</text>
  20. <text class="min-w-1 ellipsis-1">{{ firstDirectedSchool.universityName }}</text>
  21. <uv-icon name="arrow-right" size="14" color="#0DACF5"></uv-icon>
  22. <text class="flex-shrink-0">{{ firstDirectedSchool.majorName }}</text>
  23. </view>
  24. </view>
  25. <view class="text-24 text-white bg-gradient-to-r from-[#26C5F7] to-[#0DACF5] rounded-full px-18 py-6"
  26. @click="handleSetting">{{ hasDirectedSchool ? '已开启' : '去开启' }}</view>
  27. </view>
  28. <view class="mx-30 mt-20">
  29. <view class="flex items-center gap-x-28">
  30. <view class="bg-gradient-to-r from-[#0088FE] to-[#31A0FC] flex-1 rounded-15 relative overflow-hidden">
  31. <!-- <view class="h-70 z-1 relative"></view> -->
  32. <view class="mt-30 p-30 z-1 relative">
  33. <view class="text-30 text-white font-bold">全量刷题</view>
  34. <view class="mt-8 text-24 text-white">全面刷题,高效备考</view>
  35. <view class="mt-32 w-200 h-56 flex items-center justify-center rounded-full text-26 text-primary bg-white"
  36. @click="handlePracticeAll">
  37. 开始练习
  38. </view>
  39. </view>
  40. <ie-image :is-oss="true" src="/study-bg13.png" custom-class="absolute bottom-0 left-0 w-full h-full z-0"
  41. mode="aspectFill" />
  42. </view>
  43. <view class="bg-gradient-to-r from-[#32B5FD] to-[#79DCFD] flex-1 rounded-15 relative overflow-hidden">
  44. <view class="mt-30 p-30 z-1 relative">
  45. <view class="text-30 text-white font-bold">定向刷题</view>
  46. <view class="mt-8 text-24 text-white">紧扣考纲,精准练习</view>
  47. <view class="mt-32 w-200 h-56 flex items-center justify-center rounded-full text-26 text-primary bg-white"
  48. @click="handlePracticeDirected">
  49. 开始练习
  50. </view>
  51. </view>
  52. <ie-image :is-oss="true" src="/study-bg13.png" custom-class="absolute bottom-0 left-0 w-full h-full z-0"
  53. mode="aspectFill" />
  54. </view>
  55. </view>
  56. </view>
  57. <index-menu />
  58. <index-banner />
  59. <block v-if="hasTestAndRecord">
  60. <view class="h-16 bg-back my-32"></view>
  61. <index-test :directed-school="firstDirectedSchool" />
  62. <index-exam-record />
  63. </block>
  64. </ie-page>
  65. </template>
  66. <script lang="ts" setup>
  67. import IndexMenu from './compoentns/index-menu.vue';
  68. import IndexBanner from './compoentns/index-banner.vue';
  69. import IndexTest from './compoentns/index-test.vue';
  70. import IndexExamRecord from './compoentns/index-exam-record.vue';
  71. import { EnumDictName, EnumExamType } from '@/common/enum';
  72. import { useUserStore } from '@/store/userStore';
  73. import { useTransferPage } from '@/hooks/useTransferPage';
  74. import { getDirectedSchool } from '@/api/modules/study';
  75. import { DirectedSchool } from '@/types/study';
  76. import IePage from '@/components/ie-page/ie-page.vue';
  77. const { transferTo } = useTransferPage();
  78. const userStore = useUserStore();
  79. const hasTestAndRecord = computed(() => userStore.getExamType !== EnumExamType.VHS);
  80. // 通过 ref 获取 ie-page 组件实例
  81. const iePageRef = ref<InstanceType<typeof IePage>>();
  82. const directedSchoolData = ref<DirectedSchool[]>([]);
  83. const firstDirectedSchool = computed(() => directedSchoolData.value[0] || {});
  84. const hasDirectedSchool = computed(() => directedSchoolData.value.length > 0);
  85. const handlePracticeAll = () => {
  86. transferTo('/pagesStudy/pages/knowledge-practice/knowledge-practice', {
  87. data: {
  88. directed: false
  89. }
  90. });
  91. }
  92. const handlePracticeDirected = async () => {
  93. if (!hasDirectedSchool.value) {
  94. uni.$ie.showToast('请先选择定向院校');
  95. return;
  96. }
  97. transferTo('/pagesStudy/pages/knowledge-practice/knowledge-practice', {
  98. data: {
  99. directed: true
  100. }
  101. });
  102. }
  103. const handleSetting = async () => {
  104. if (hasDirectedSchool.value) {
  105. const notice = firstDirectedSchool.value.notice;
  106. if (notice) {
  107. await uni.$ie.showModal({
  108. title: '提示',
  109. content: notice,
  110. showCancel: false,
  111. confirmText: '知道了'
  112. });
  113. }
  114. }
  115. transferTo('/pagesStudy/pages/targeted-setting/targeted-setting');
  116. }
  117. const loadData = async () => {
  118. const res = await getDirectedSchool();
  119. if (res.data) {
  120. directedSchoolData.value = res.data;
  121. }
  122. }
  123. onShow(() => {
  124. loadData();
  125. });
  126. </script>
  127. <style></style>