From 11b62320fea17ff2c81150f0a921fc93fdc9a5dd Mon Sep 17 00:00:00 2001 From: ywyonui Date: Wed, 3 Sep 2025 19:46:26 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=8A=A2=E8=AF=BE=E6=98=BE?= =?UTF-8?q?=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/base/components/XsPicker/index.vue | 5 ++- src/pages/base/home/index.vue | 6 ++-- .../base/xk/components/XkPicker/index.vue | 31 ++++++++++++------- src/pages/base/xk/detail.vue | 4 +-- src/pages/base/xk/qk/index.vue | 5 ++- src/pages/base/xk/qk/wks.vue | 19 +++++++----- src/utils/pageUtil.ts | 8 ++++- 7 files changed, 51 insertions(+), 27 deletions(-) diff --git a/src/pages/base/components/XsPicker/index.vue b/src/pages/base/components/XsPicker/index.vue index 37a7d7b..495bcfb 100644 --- a/src/pages/base/components/XsPicker/index.vue +++ b/src/pages/base/components/XsPicker/index.vue @@ -105,7 +105,10 @@ if (props.isBar) { } else { // 首次初始化 if (getUser.xsList.length > 1) { - showPicker(); + if(!props.isBar) { + // 显示选择器 + showPicker(); + } } else { // 只有一个学生时,直接设置但不显示提示 setCurrentStudent(getUser.xsList[0]); diff --git a/src/pages/base/home/index.vue b/src/pages/base/home/index.vue index 0143bad..210213b 100644 --- a/src/pages/base/home/index.vue +++ b/src/pages/base/home/index.vue @@ -85,9 +85,11 @@ import { useUserStore } from "@/store/modules/user"; import { useDataStore } from "@/store/modules/data"; import { hasPermission } from "@/utils/permission"; import { PageUtils } from "@/utils/pageUtil"; +import { useDebounce } from "@/utils/debounce"; const { getCurXs } = useUserStore(); const { setData, getAppCode, setGlobal } = useDataStore(); +const { debounce } = useDebounce(2000); // 刷新相关变量 const { getLastRefreshTime, getRefreshInterval, setLastRefreshTime, updateStudentInfo, updateStudentList } = useUserStore(); @@ -258,7 +260,7 @@ const goToGlxs = () => { } // 处理菜单点击 -function handleMenuClick(item: any) { +const handleMenuClick = debounce(async (item: any) => { if (item.path) { if (!item.lxId) { uni.navigateTo({ @@ -269,7 +271,7 @@ function handleMenuClick(item: any) { PageUtils.toHome(item.lxId); } } -} +}); // 切换学生 function switchXs(xs: any) { diff --git a/src/pages/base/xk/components/XkPicker/index.vue b/src/pages/base/xk/components/XkPicker/index.vue index 7d471bf..cd6621b 100644 --- a/src/pages/base/xk/components/XkPicker/index.vue +++ b/src/pages/base/xk/components/XkPicker/index.vue @@ -105,8 +105,9 @@ const loadXkList = async () => { } else { const qk = getQk || {}; if (props.xsId === qk.xsId && qk.xklxId === props.xklxId && qk.xsXkStatus === "KQK") { - xkList.value = qk.xkList || []; - switchXk(xkList.value[0]); + nextTick(() => { + initXkList(qk.xkList || []); + }); } else { const res = await getXsXkListApi(params); if (res.resultCode === 1) { @@ -120,11 +121,9 @@ const loadXkList = async () => { return; } else if (result.type === 2 || result.type === 3) { // 正常选课列表或已支付但有选课列表供切换 - if (result.xkList && result.xkList.length) { - xkList.value = result.xkList; - switchXk(result.xkList[0]); - return; - } + nextTick(() => { + initXkList(result.xkList || []); + }); } } } @@ -133,10 +132,17 @@ const loadXkList = async () => { uni.hideLoading(); }; +const initXkList = (list: any) => { + xkList.value = list; + switchXk(xkList.value[0]); +}; + + // 切换选课 const switchXk = (xk: any) => { curXk.value = xk; showFlag.value = false; + console.log("切换选课", xk); emit("change", xk); }; @@ -149,10 +155,13 @@ watch( } ); -// 初始化加载数据 -if (props.xsId) { - loadXkList(); -} +onMounted(() => { + // 初始化加载数据 + if (props.xsId) { + loadXkList(); + } +}); +