From 64001496631049e2ed4b089e5066ad09c053cad8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E6=88=90?= Date: Sun, 24 Aug 2025 16:10:00 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=8E=88=E6=9D=83=E7=9B=B4?= =?UTF-8?q?=E6=8E=A5=E8=8E=B7=E5=8F=96=E6=89=8B=E6=9C=BA=E5=8F=B7=E9=80=BB?= =?UTF-8?q?=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/login/index/index.tsx | 18 +++++++++++++++--- src/services/loginService.ts | 19 ++++++++----------- 2 files changed, 23 insertions(+), 14 deletions(-) diff --git a/src/pages/login/index/index.tsx b/src/pages/login/index/index.tsx index 09951c0..29facb3 100644 --- a/src/pages/login/index/index.tsx +++ b/src/pages/login/index/index.tsx @@ -10,7 +10,7 @@ const LoginPage: React.FC = () => { const [show_terms_layer, set_show_terms_layer] = useState(false); // 微信授权登录 - const handle_wechat_login = async () => { + const handle_wechat_login = async (e: any) => { if (!agree_terms) { set_show_terms_layer(true); Taro.showToast({ @@ -21,9 +21,20 @@ const LoginPage: React.FC = () => { return; } + // 检查是否获取到手机号 + if (!e.detail || !e.detail.code) { + Taro.showToast({ + title: '获取手机号失败,请重试', + icon: 'none', + duration: 2000 + }); + return; + } + set_is_loading(true); try { - const response = await wechat_auth_login(); + // 传递手机号code给登录服务 + const response = await wechat_auth_login(e.detail.code); if (response.success) { save_login_state(response.token!, response.user_info!); @@ -123,7 +134,8 @@ const LoginPage: React.FC = () => { {/* 微信快捷登录 */}