From 091411cda032d2577e731e6f46b327c476591be9 Mon Sep 17 00:00:00 2001 From: ywyonui Date: Wed, 22 Oct 2025 12:20:00 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B5=8B=E8=AF=95=E8=B0=83=E6=95=B4pre?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/base/xk/qk/pre.vue | 16 +++++++++++++++- src/store/modules/common.ts | 1 + src/store/modules/data.ts | 1 + src/store/modules/dic.ts | 1 + src/store/modules/user.ts | 6 +++--- 5 files changed, 21 insertions(+), 4 deletions(-) diff --git a/src/pages/base/xk/qk/pre.vue b/src/pages/base/xk/qk/pre.vue index 0ed51ce..aad9000 100644 --- a/src/pages/base/xk/qk/pre.vue +++ b/src/pages/base/xk/qk/pre.vue @@ -30,6 +30,9 @@ const loadByDb = async (data: any) => { console.log("用户未登录,跳过处理"); return; } + // 等待下一个 tick 确保响应式更新完成 + await nextTick(); + try { // 优先从后端根据url中的id去查询Xxts const xxtsRes = await xxtsFindByIdApi({ id: data.id }); @@ -37,12 +40,23 @@ const loadByDb = async (data: any) => { const xxts = xxtsRes.result; setXxts(xxts); } - const xsList = getUser.xsList || []; + + // 等待下一个 tick 确保响应式更新完成 + await nextTick(); + + // 或者直接从 store 实例获取最新数据 + const currentUser = useUserStore().getUser; + + const xsList = currentUser.xsList || []; if (xsList && xsList.length > 0) { // 获取当前学生信息 const curXs = xsList.find((xs: any) => xs.id == data.xsId); if (curXs) { setCurXs(curXs); + + // 等待下一个 tick 确保响应式更新完成 + await nextTick(); + // 检查抢课逻辑 PageUtils.checkQkLogic(data.xkLxId); } diff --git a/src/store/modules/common.ts b/src/store/modules/common.ts index b5c0598..cf18ef3 100644 --- a/src/store/modules/common.ts +++ b/src/store/modules/common.ts @@ -59,6 +59,7 @@ export const useCommonStore = defineStore({ actions: { cleanData() { this.data = {}; + this.$reset(); }, setData(key: string, data: any) { this.data[key] = data; diff --git a/src/store/modules/data.ts b/src/store/modules/data.ts index c9c9f47..4373848 100644 --- a/src/store/modules/data.ts +++ b/src/store/modules/data.ts @@ -68,6 +68,7 @@ export const useDataStore = defineStore({ this.jcBz = {}; this.lcgl = {}; this.xxts = {}; + this.$reset(); }, setData(data: any) { this.data = data; diff --git a/src/store/modules/dic.ts b/src/store/modules/dic.ts index 66414b0..cfe6c38 100644 --- a/src/store/modules/dic.ts +++ b/src/store/modules/dic.ts @@ -19,6 +19,7 @@ export const useDicStore = defineStore({ actions: { cleanData() { this.data = {}; + this.$reset(); }, setData(data: any) { this.data = data; diff --git a/src/store/modules/user.ts b/src/store/modules/user.ts index 028dfdb..b4d9ee9 100644 --- a/src/store/modules/user.ts +++ b/src/store/modules/user.ts @@ -163,6 +163,7 @@ export const useUserStore = defineStore({ if (this.userdata && this.userdata.openId && this.userdata.userType === "JZ" && openId && this.userdata.openId === openId ) { + this.afterLoginAction(this.userdata); return true; } // 如果当前登录的用户的openid和传入的openid不匹配,则调用checkOpenId接口进行校验 @@ -192,9 +193,7 @@ export const useUserStore = defineStore({ */ afterLoginAction(value: any) { // 为了避免数据加载异常。这里清理一下缓存 - useDicStore().cleanData() - useCommonStore().cleanData(); - useDataStore().cleanData(); + this.logout(); // 设置用户数据 this.setUser(value) if (value.xsList && value.xsList.length > 0) { @@ -228,6 +227,7 @@ export const useUserStore = defineStore({ this.setXsPickerInitialized(false); // 注销时重置学生选择器状态 this.exitWs(); this.wsCallback = defWsCallback; + this.$reset(); useDicStore().cleanData() useCommonStore().cleanData(); useDataStore().cleanData();