155 lines
4.2 KiB
Vue
Raw Normal View History

2025-04-22 10:22:33 +08:00
<template>
<view class="wh-full">
2025-05-13 15:39:44 +08:00
<BasicLoading
:isShow="isShow"
bgColor="#fff"
isShowTitle
textColor="#000"
title="启动中..."
:type="1"
/>
2025-04-22 10:22:33 +08:00
</view>
</template>
<script lang="ts" setup>
2025-05-13 15:39:44 +08:00
import { onLoad } from "@dcloudio/uni-app";
import { useDataStore } from "@/store/modules/data";
import { useUserStore } from "@/store/modules/user";
import { checkOpenId, findJsByPhoneApi } from "@/api/system/login";
2025-08-02 11:15:22 +08:00
import { PermissionCacheManager } from "@/utils/permission";
2025-04-22 10:22:33 +08:00
2025-09-19 20:16:05 +08:00
const { setGlobal, getGlobal } = useDataStore();
2025-05-13 15:39:44 +08:00
const { afterLoginAction } = useUserStore();
const { setFile, getFile } = useDataStore();
const isShow = ref(true);
2025-08-02 11:15:22 +08:00
/**
* 强制刷新权限
*/
async function forceRefreshPermission(changeTime?: string): Promise<void> {
try {
// 重新获取用户权限
const userStore = useUserStore();
const currentUser = userStore.getUser;
if (currentUser && currentUser.id) {
// 重新调用权限获取接口
const { authenticationApi } = await import('@/api/system/login');
const result = await authenticationApi({ userId: currentUser.id });
if (result && result.result) {
// 直接设置权限并刷新缓存不调用setAuth避免重复操作
userStore.auth = result.result;
// 手动刷新缓存,传递权限变更时间
const { refreshPermissionCache } = await import('@/utils/permission');
refreshPermissionCache(result.result, changeTime);
}
}
} catch (error) {
console.error('强制刷新权限失败:', error);
}
}
2025-06-20 09:51:43 +08:00
function goByJs(js: any) {
2025-09-23 18:15:14 +08:00
// 检查是否有签到相关参数
const globalData = getGlobal;
console.log('goByJs - globalData:', globalData);
console.log('goByJs - js:', js);
if (globalData && globalData.qdId) {
// 有签到参数,重定向到签到确认页面
let confirmUrl = `/pages/view/routine/qd/confirm?qdId=${globalData.qdId}`;
if (globalData.rqgqtime) {
confirmUrl += `&rqgqtime=${globalData.rqgqtime}`;
}
2025-09-29 21:58:16 +08:00
if (globalData.timestampqd) {
confirmUrl += `&timestampqd=${globalData.timestampqd}`;
2025-09-23 18:15:14 +08:00
}
console.log('重定向到签到确认页面:', confirmUrl);
uni.reLaunch({
url: confirmUrl
});
return;
}
2025-09-19 20:16:05 +08:00
if (getGlobal && getGlobal.type === '1') {
uni.reLaunch({
url: "/pages/view/routine/xk/qd?from=login"
});
}
2025-08-02 11:15:22 +08:00
if (js.confirmStatus == "A") {
// 跳转到自助服务首页
uni.reLaunch({
2025-08-02 11:15:22 +08:00
url: "/pages/base/service/index",
});
} else {
setFile({
...js,
...getFile,
});
setTimeout(() => {
uni.reLaunch({
url: "/pages/view/hr/teacherProfile/index",
});
}, 1500);
}
2025-05-13 15:39:44 +08:00
}
2025-08-02 11:15:22 +08:00
2025-05-13 15:39:44 +08:00
onLoad(async (data: any) => {
2025-09-23 18:15:14 +08:00
console.log('launchPage onLoad - 接收到的参数:', data);
2025-05-13 15:39:44 +08:00
if (data && data.openId) {
setGlobal(data);
2025-09-23 18:15:14 +08:00
console.log('launchPage onLoad - 设置global数据后:', getGlobal);
2025-08-02 11:15:22 +08:00
try {
const res = await checkOpenId({
openId: data.openId,
appCode: "JS",
});
2025-09-23 18:15:14 +08:00
console.log('launchPage onLoad - checkOpenId结果:', res);
2025-08-02 11:15:22 +08:00
if (res.resultCode == 1 && res.result) {
// 执行登录操作
afterLoginAction(res.result);
// 如果有changeTime参数更新权限缓存
if (data.changeTime) {
const { refreshPermissionCache } = await import('@/utils/permission');
const userStore = useUserStore();
const currentPermissions = userStore.getAuth;
if (currentPermissions && currentPermissions.length > 0) {
refreshPermissionCache(currentPermissions, data.changeTime);
2025-05-13 15:39:44 +08:00
}
}
2025-08-02 11:15:22 +08:00
// 跳转页面
2025-09-23 18:15:14 +08:00
console.log('launchPage onLoad - 准备调用goByJs');
2025-08-02 11:15:22 +08:00
goByJs(res.result.js);
} else {
uni.reLaunch({
url: "/pages/system/login/login",
});
2025-08-02 11:15:22 +08:00
}
} catch (err) {
2025-09-23 18:15:14 +08:00
console.error('launchPage onLoad - checkOpenId失败:', err);
2025-08-02 11:15:22 +08:00
uni.reLaunch({
url: "/pages/system/login/login"
});
2025-08-02 11:15:22 +08:00
}
2025-06-20 09:51:43 +08:00
} else {
2025-09-23 18:15:14 +08:00
console.log('launchPage onLoad - 没有openId参数跳转到登录页面');
2025-08-02 11:15:22 +08:00
uni.reLaunch({
url: "/pages/system/login/login"
});
2025-04-22 10:22:33 +08:00
}
2025-05-13 15:39:44 +08:00
});
2025-04-22 10:22:33 +08:00
</script>