From fc63bbc99413676dd2f2dd9942b7ee5fe0021576 Mon Sep 17 00:00:00 2001 From: zoujing Date: Mon, 15 Sep 2025 22:52:44 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E8=B0=83=E6=95=B4=E4=BC=98=E5=8C=96?= =?UTF-8?q?=E7=99=BB=E5=BD=95=E7=9A=84=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hooks/useGoLogin.js | 48 ++++---- manager/LoginManager.js | 2 - pages/chat/ChatInputArea.vue | 8 +- pages/chat/ChatMainList.vue | 16 ++- pages/chat/ChatMoreTips.vue | 8 +- pages/chat/ChatQuickAccess.vue | 7 +- pages/chat/ChatTopNavBar.vue | 16 ++- pages/drawer/DrawerHome.vue | 27 +++- pages/drawer/MineSetting.vue | 12 +- pages/login/index.vue | 51 ++++---- pages/login/styles/index.scss | 116 ++++++++++-------- .../detail/DetailCardGoodsContentList.vue | 2 - .../discovery/DiscoveryCradContentList.vue | 10 +- pages/module/recommend/RecommendPostsList.vue | 9 +- request/base/request.js | 17 ++- 15 files changed, 190 insertions(+), 159 deletions(-) diff --git a/hooks/useGoLogin.js b/hooks/useGoLogin.js index 0ca9a36..09a3928 100644 --- a/hooks/useGoLogin.js +++ b/hooks/useGoLogin.js @@ -1,27 +1,25 @@ -import { loginAuth, checkPhone, bindPhone } from "@/manager/LoginManager"; +import { loginAuth, bindPhone } from "@/manager/LoginManager"; // 跳转登录 -export const goLogin = () => uni.reLaunch({ url: "/pages/login/index" }); +export const goLogin = () => uni.navigateTo({ url: "/pages/login/index" }); + +// 登录成功后,返回上一页 +export const goBack = () => uni.navigateBack({ delta: 1 }); // 登录逻辑 -export const onLogin = (e) => { - const token = uni.getStorageSync("token"); +export const onLogin = async (e) => { + return new Promise(async (resolve) => { + await loginAuth().then(async () => { + const { code } = e.detail; + console.info("onLogin code: ", code); - if (token) return; - - const { code } = e.detail; - console.info("onLogin code: ", code); - - loginAuth().then(async () => { - // 检测是否绑定手机号 - const res = await checkPhone(); - - if (res.data) return; - - const params = { wechatPhoneCode: code, clientId: "2" }; - - // 绑定手机号 - bindPhone(params); + // 绑定手机号 + const params = { wechatPhoneCode: code, clientId: "2" }; + const res = await bindPhone(params); + if (res.data) { + resolve(); + } + }); }); }; @@ -29,9 +27,13 @@ export const onLogin = (e) => { export const checkToken = async () => { return new Promise((resolve) => { const token = uni.getStorageSync("token"); - - if (!token) return; - - resolve(token); + if (!token) { + console.log("token不存在,重新登录"); + loginAuth().then(() => { + resolve(); + }); + return; + } + resolve(); }); }; diff --git a/manager/LoginManager.js b/manager/LoginManager.js index de18336..0750345 100644 --- a/manager/LoginManager.js +++ b/manager/LoginManager.js @@ -20,9 +20,7 @@ const loginAuth = () => { if (response.access_token) { uni.setStorageSync("token", response.access_token); - const appStore = useAppStore(); - appStore.setHasToken(true); resolve(); } else { diff --git a/pages/chat/ChatInputArea.vue b/pages/chat/ChatInputArea.vue index 8aa5539..e71e0cd 100644 --- a/pages/chat/ChatInputArea.vue +++ b/pages/chat/ChatInputArea.vue @@ -9,8 +9,6 @@ - -