feat: 登录异常问题调整

This commit is contained in:
duanshuwen
2025-12-26 22:59:44 +08:00
parent dfadb06934
commit ea56695099
8 changed files with 115 additions and 187 deletions

View File

@@ -1,5 +1,5 @@
import { wxLogin } from "../request/api/LoginApi";
import { loginAuth, bindPhone, checkPhone } from "@/manager/LoginManager";
import { wxLogin, checkUserPhone } from "../request/api/LoginApi";
import { loginAuth, bindPhone } from "@/manager/LoginManager";
import { clientId } from "@/constant/base";
import { NOTICE_EVENT_LOGIN_SUCCESS } from "@/constant/constant";
import { getStorageSyncToken, setStorageSyncToken } from "../constant/token";
@@ -22,8 +22,9 @@ export const onLogin = async (e) => {
}
await loginAuth(e).then(async () => {
console.log("loginAuth resolve success");
// 检查手机号是否绑定
const checkRes = await checkPhone();
const checkRes = await checkUserPhone();
if (checkRes.data) {
resolve();
return;
@@ -61,26 +62,12 @@ export const checkToken = () => {
};
// 刷新token
export const refreshToken = () => {
export const refreshToken = () => {
return new Promise(async (resolve) => {
const token = getStorageSyncToken();
if (!token) {
resolve(true);
return;
}
const checkRes = await checkPhone();
if (!checkRes.data) {
resolve(true);
return;
}
uni.login({
provider: "weixin", //使用微信登录
success: async ({ code }) => {
console.log("refreshToken", code);
console.log("进入 refreshToken success", code);
const params = {
openIdCode: [code],
grant_type: "wechat",
@@ -88,6 +75,7 @@ export const refreshToken = () => {
clientId: clientId,
};
console.log("获取到的微信授权params:", JSON.stringify(params));
const response = await wxLogin(params);
if (response.access_token) {