shmily1213 пре 1 месец
родитељ
комит
a4c7df2cc0

+ 71 - 39
src/pagesOther/pages/university/detail/components/plus/college-brochure-list.vue

@@ -1,58 +1,90 @@
 <template>
-    <uv-cell-group :border="false">
-        <uv-cell v-for="item in list" :key="item.id" cell-style="padding: 10px 0" @click="handlePreview(item)">
-            <template #title>
-                <view class="text-28 text-fore-title mb-20">{{ item.title }}</view>
-            </template>
-            <template #label>
-                <view class="text-24 text-fore-light">{{ item.createTime }}</view>
-            </template>
-        </uv-cell>
-    </uv-cell-group>
+  <uv-cell-group :border="false">
+    <uv-cell v-for="item in list" :key="item.id" cell-style="padding: 10px 0" @click="handlePreview(item)">
+      <template #title>
+        <view class="text-28 text-fore-title mb-20">{{ item.title }}</view>
+      </template>
+      <template #label>
+        <view class="text-24 text-fore-light">{{ item.createTime }}</view>
+      </template>
+    </uv-cell>
+  </uv-cell-group>
 </template>
 
 <script setup lang="ts">
-import {UniversityBrochure, UniversityDetail} from "@/types/university";
-import {UNIVERSITY_DETAIL} from "@/types/injectionSymbols";
-import {useTransferPage} from "@/hooks/useTransferPage";
-import {EnumBrochureType} from "@/common/enum";
-import {routes} from "@/common/routes";
+import { UniversityBrochure, UniversityDetail } from "@/types/university";
+import { UNIVERSITY_DETAIL } from "@/types/injectionSymbols";
+import { useTransferPage } from "@/hooks/useTransferPage";
+import { EnumBrochureType } from "@/common/enum";
+import { routes } from "@/common/routes";
 
 withDefaults(defineProps<{
-    list: UniversityBrochure[]
+  list: UniversityBrochure[]
 }>(), {
-    list: () => []
+  list: () => []
 })
 
 const detail = inject(UNIVERSITY_DETAIL, ref({} as UniversityDetail))
 const baseInfo = computed(() => detail.value.baseInfo || {})
-const {transferTo} = useTransferPage()
+const { transferTo } = useTransferPage()
 
 const handlePreview = function (brochure: UniversityBrochure) {
-    if (brochure.url) {
-        uni.openDocument({
-            filePath: brochure.url,
-            fail: result => {
-                uni.setClipboardData({
-                    data: brochure.url,
-                    showToast: false,
-                    success: () => {
-                        uni.$ie.showModal({
-                            title: '提示',
-                            content: '已将文件地址复制到粘贴板',
-                            showCancel: false
-                        })
-                    }
-                })
+  if (brochure.url) {
+    // 获取文件后缀,判断是否是doc,docx,xls,xlsx,ppt,pptx,pdf
+    const fileExtension = brochure.url.split('.').pop() || '';
+    if (['doc', 'docx', 'xls', 'xlsx', 'ppt', 'pptx', 'pdf'].includes(fileExtension)) {
+      // #ifdef MP-WEIXIN
+      uni.$ie.showLoading();
+      uni.downloadFile({
+        url: brochure.url,
+        success: (res) => {
+          const filePath = res.tempFilePath;
+          uni.openDocument({
+            filePath: filePath,
+            showMenu: true,
+            success: (res) => { },
+            fail: () => {
+              handleCopy(brochure.url);
             }
-        })
+          });
+        },
+        complete: () => {
+          uni.$ie.hideLoading();
+        }
+      });
+      // #endif
+      // #ifdef H5
+      try {
+        const a = document.createElement('a');
+        a.setAttribute('href', brochure.url);
+        a.setAttribute('target', '_blank');
+        a.click();
+      } catch (error) {
+        handleCopy(brochure.url);
+      }
+      // #endif
     } else {
-        brochure.logo = baseInfo.value.logo
-        transferTo(routes.universityIntroduction, {bigData: brochure})
+      handleCopy(brochure.url);
     }
+  } else {
+    brochure.logo = baseInfo.value.logo
+    transferTo(routes.universityIntroduction, { bigData: brochure })
+  }
 }
-</script>
 
-<style scoped>
+const handleCopy = (content: string) => {
+  uni.setClipboardData({
+    data: content,
+    showToast: false,
+    success: () => {
+      uni.$ie.showModal({
+        title: '提示',
+        content: '已将文件地址复制到粘贴板,请在浏览器打开',
+        showCancel: false
+      });
+    }
+  });
+}
+</script>
 
-</style>
+<style scoped></style>

+ 15 - 9
src/pagesStudy/pages/index/compoentns/vhs-exam.vue

@@ -11,10 +11,9 @@
           </view>
         </view>
       </view>
-
       <view v-if="list.length > 0" class="px-30 pb-24 bg-back flex flex-col gap-20 sticky z-1 "
         :style="{ top: baseStickyTop + 20 + 'px' }">
-        <vhs-exam-item v-for="(item, index) in list" :key="index" :data="item" :type="current" />
+        <vhs-exam-item v-for="(item, index) in list" :key="item.id" :data="item" :type="subjectType" />
       </view>
       <view v-else class="bg-white">
         <z-paging-empty-view :empty-view-fixed="false" />
@@ -33,16 +32,23 @@ const { transferTo } = useTransferPage();
 const { baseStickyTop } = useNavbar();
 const list = ref<Study.VHSPaper[]>([]);
 const current = ref(0);
-const handleChange = (index: number) => {
+const subjectType = ref(0);
+
+const handleChange = async (index: number) => {
   current.value = index;
-  loadData();
+  await loadData();
+  subjectType.value = index;
 }
 const loadData = async () => {
-  list.value = [];
-  const { data } = await getVHSPaperList({
-    subjectId: current.value
-  });
-  list.value = data;
+  try {
+    uni.$ie.showLoading();
+    const { data } = await getVHSPaperList({
+      subjectId: current.value
+    });
+    list.value = data;
+  } catch (error) { } finally {
+    uni.$ie.hideLoading();
+  }
 }
 onShow(() => {
   loadData();

+ 43 - 25
src/pagesStudy/pages/knowledge-practice/knowledge-practice.vue

@@ -3,16 +3,18 @@
     <z-paging ref="pagingRef" v-model="treeData" :loading-more-enabled="false" :auto="false" @query="loadKnowledgeList">
       <template #top>
         <ie-navbar :title="pageTitle" />
-        <uv-tabs :list="subjectList" key-name="subjectName" @click="handleChangeTab" :scrollable="true"></uv-tabs>
-        <view class="px-30 py-16 bg-back">
-          <view class="flex items-center justify-end gap-x-4" @click="handleViewHistory">
-            <uv-icon name="clock" size="16" color="#31A0FC"></uv-icon>
-            <text class="text-28 text-primary">查看记录</text>
-            <uv-icon name="arrow-right" size="16" color="#31A0FC"></uv-icon>
+        <template v-if="subjectList.length">
+          <uv-tabs :list="subjectList" key-name="subjectName" @click="handleChangeTab" :scrollable="true"></uv-tabs>
+          <view class="px-30 py-16 bg-back">
+            <view class="flex items-center justify-end gap-x-4" @click="handleViewHistory">
+              <uv-icon name="clock" size="16" color="#31A0FC"></uv-icon>
+              <text class="text-28 text-primary">查看记录</text>
+              <uv-icon name="arrow-right" size="16" color="#31A0FC"></uv-icon>
+            </view>
           </view>
-        </view>
+        </template>
       </template>
-      <view class="px-40 safe-area-inset-bottom">
+      <view class="px-40">
         <knowledgeTree :tree-data="treeData" @start-practice="handleStartPractice" />
       </view>
     </z-paging>
@@ -24,7 +26,7 @@ import IePage from '@/components/ie-page/ie-page.vue';
 import { useTransferPage } from '@/hooks/useTransferPage';
 import { getSubjectList, getKnowledgeList } from '@/api/modules/study';
 import knowledgeTree from '@/pagesStudy/components/knowledge-tree.vue';
-import * as Study from '@/types/study';
+import type { Study, Transfer } from '@/types';
 import { EnumPaperType, EnumUserRole } from '@/common/enum';
 import { useUserStore } from '@/store/userStore';
 import { useAuth } from '@/hooks/useAuth';
@@ -32,14 +34,24 @@ import { useAuth } from '@/hooks/useAuth';
 const { prevData, transferTo } = useTransferPage();
 const currentSubjectIndex = ref<number>(-1);
 const userStore = useUserStore();
-const pagingRef = ref();
+const pagingRef = ref<ZPagingInstance>();
 
 const { hasPermission } = useAuth();
 const pageTitle = computed(() => {
-  if (prevData.value.directed) {
-    return '定向刷题';
+  const { isVHS, directed, questionType } = prevData.value;
+  if (isVHS) {
+    if (questionType === 0) {
+      return '知识点练习';
+    } else if (questionType === 2) {
+      return '必刷题';
+    }
+  } else {
+    if (directed) {
+      return '定向刷题';
+    } else {
+      return '全量刷题';
+    }
   }
-  return '全量刷题';
 });
 const currentSubjectId = computed(() => {
   if (subjectList.value.length > 0 && currentSubjectIndex.value >= 0) {
@@ -70,10 +82,10 @@ const loadKnowledgeList = async () => {
       directed: prevData.value.directed
     });
     treeData.value = data as Study.KnowledgeNode[];
-    pagingRef.value.complete(data);
+    pagingRef.value?.complete(data);
   } catch (error) {
     console.log(error);
-    pagingRef.value.complete(false);
+    pagingRef.value?.complete(false);
   } finally {
     uni.$ie.hideLoading();
   }
@@ -84,29 +96,35 @@ const handleStartPractice = async (node: Study.KnowledgeNode) => {
   if (hasAuth) {
     transferTo('/pagesStudy/pages/exam-start/exam-start', {
       data: {
-        name: '知识点练习-' + node.name,
         paperType: EnumPaperType.PRACTICE,
         practiceInfo: {
           name: node.name,
           relateId: node.id,
-          directed: prevData.value.directed
-        },
-      }
+          directed: prevData.value.directed,
+          // 对口升学
+          questionType: prevData.value.questionType
+        }
+      } as Transfer.ExamAnalysisPageOptions
     });
   }
 }
 
 watch(() => currentSubjectIndex.value, () => {
-  pagingRef.value.reload();
+  pagingRef.value?.reload();
 }, {
   immediate: false
 });
 
 const loadData = async () => {
+  const { isVHS, directed, subjectType } = prevData.value;
   try {
-    const { data } = await getSubjectList({
-      directed: !!prevData.value.directed
-    });
+    const params = {} as Study.SubjectListRequestDTO;
+    if (isVHS) {
+      params.subjectType = subjectType;
+    } else {
+      params.directed = !!directed;
+    }
+    const { data } = await getSubjectList(params);
     subjectList.value = data.map(item => ({ subjectId: item.subjectId, subjectName: item.subjectName }));
     currentSubjectIndex.value = 0;
   } catch (error) { }
@@ -117,10 +135,10 @@ onLoad(() => {
 onShow(() => {
   nextTick(() => {
     if (subjectList.value.length > 0) {
-      pagingRef.value.refresh();
+      pagingRef.value?.refresh();
     }
   });
 });
 </script>
 
-<style></style>
+<style></style>