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 = () => { {/* 微信快捷登录 */}