feat: 调整了登录的逻辑

This commit is contained in:
2026-05-12 21:17:11 +08:00
parent f0b6e86e64
commit 0f6d8f7ff1
7 changed files with 200 additions and 120 deletions

View File

@@ -31,6 +31,7 @@
<script setup>
import { onMounted, ref } from "vue";
import { getTimeNoticeList } from "@/request/api/MainPageDataApi";
import { NOTICE_EVENT_LOGIN_SUCCESS } from "@/constant/constant";
const autoplay = ref(true);
const interval = ref(7000);
@@ -52,6 +53,9 @@ const getTimeNoticeListData = async () => {
onMounted(() => {
getTimeNoticeListData();
uni.$on(NOTICE_EVENT_LOGIN_SUCCESS, () => {
getTimeNoticeListData();
});
});
const clickItem = (item) => {

View File

@@ -53,7 +53,7 @@ import {
getServiceAgreement,
getPrivacyAgreement,
} from "@/request/api/LoginApi";
import { onLogin, goBack, refreshToken } from "@/hooks/useGoLogin";
import { onLogin, goBack, onCheckPhoneLogin, onAppleLogin } from "@/hooks/useGoLogin";
import CheckBox from "@/components/CheckBox/index.vue";
import AgreePopup from "./components/AgreePopup/index.vue";
import { zniconsMap } from "@/static/fonts/znicons";
@@ -93,7 +93,33 @@ const handleAgreeAndGetPhone = () => {
return;
}
refreshToken().then(() => loginSuccess());
if (isAppleLogin.value) {
onAppleLogin()
.then((res) => {
if (res) {
loginSuccess();
}
})
.catch(() => {
uni.showToast({
title: "Apple ID登录失败",
icon: "none",
});
});
} else {
onCheckPhoneLogin()
.then((res) => {
if (!res) {
loginSuccess();
}
})
.catch(() => {
uni.showToast({
title: "手机号登录失败",
icon: "none",
});
});
}
};
/// 获取授权后绑定手机号登录
@@ -154,10 +180,12 @@ const getPrivacyAgreementData = async () => {
};
getPrivacyAgreementData();
// 页面显示时刷新token
onShow(async () => {
const res = await refreshToken();
needWxAuthLogin.value = res;
if (!isAppleLogin.value) {
// 页面显示时检查微信授权登录状态
const res = await onCheckPhoneLogin();
needWxAuthLogin.value = res;
}
});