修改用户授权调用位置和逻辑
This commit is contained in:
@@ -15,6 +15,7 @@ import { useEvaluate, EvaluateScene } from "@/store/evaluateStore";
|
||||
import { useGlobalState } from "@/store/global";
|
||||
import { delay, getCurrentFullPath } from "@/utils";
|
||||
import { formatNtrpDisplay } from "@/utils/helper";
|
||||
import { waitForAuthInit } from "@/utils/authInit";
|
||||
import CloseIcon from "@/static/ntrp/ntrp_close_icon.svg";
|
||||
import DocCopy from "@/static/ntrp/ntrp_doc_copy.svg";
|
||||
import ArrowRight from "@/static/ntrp/ntrp_arrow_right.svg";
|
||||
@@ -151,16 +152,14 @@ function Intro() {
|
||||
const { ntrp_level, create_time, id } = last_test_result || {};
|
||||
const lastTestTime = create_time ? dayjs(create_time).format("YYYY年M月D日") : "";
|
||||
|
||||
// 组件初始化时立即获取用户信息
|
||||
useEffect(() => {
|
||||
// 如果用户信息为空,立即获取
|
||||
if (!userInfo || Object.keys(userInfo).length === 0) {
|
||||
fetchUserInfo();
|
||||
}
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
getLastResult();
|
||||
const init = async () => {
|
||||
// 先等待静默登录完成
|
||||
await waitForAuthInit();
|
||||
// 然后再调用接口
|
||||
await getLastResult();
|
||||
};
|
||||
init();
|
||||
}, []);
|
||||
|
||||
async function getLastResult() {
|
||||
@@ -193,9 +192,8 @@ function Intro() {
|
||||
});
|
||||
}
|
||||
Taro.redirectTo({
|
||||
url: `/other_pages/ntrp-evaluate/index?stage=${type}${
|
||||
type === StageType.RESULT ? `&id=${id}` : ""
|
||||
}`,
|
||||
url: `/other_pages/ntrp-evaluate/index?stage=${type}${type === StageType.RESULT ? `&id=${id}` : ""
|
||||
}`,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -450,20 +448,18 @@ function Result() {
|
||||
[propName: string, prop: number][]
|
||||
>([]);
|
||||
|
||||
// 组件初始化时立即获取用户信息
|
||||
useEffect(() => {
|
||||
// 如果用户信息为空,立即获取
|
||||
if (!userInfo || Object.keys(userInfo).length === 0) {
|
||||
fetchUserInfo();
|
||||
}
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
getResultById();
|
||||
// 确保用户信息已加载
|
||||
if (!userInfo || Object.keys(userInfo).length === 0) {
|
||||
fetchUserInfo();
|
||||
}
|
||||
const init = async () => {
|
||||
// 先等待静默登录完成
|
||||
await waitForAuthInit();
|
||||
// 然后再调用接口
|
||||
await getResultById();
|
||||
// 确保用户信息已加载
|
||||
if (!userInfo || Object.keys(userInfo).length === 0) {
|
||||
await fetchUserInfo();
|
||||
}
|
||||
};
|
||||
init();
|
||||
}, [id]);
|
||||
|
||||
async function getResultById() {
|
||||
@@ -624,9 +620,8 @@ function Result() {
|
||||
}
|
||||
const currentPage = getCurrentFullPath();
|
||||
Taro.redirectTo({
|
||||
url: `/login_pages/index/index${
|
||||
currentPage ? `?redirect=${encodeURIComponent(currentPage)}` : ""
|
||||
}`,
|
||||
url: `/login_pages/index/index${currentPage ? `?redirect=${encodeURIComponent(currentPage)}` : ""
|
||||
}`,
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user