From f46c01a984291b52685bf050a76b510d1d727f5a Mon Sep 17 00:00:00 2001 From: DU Date: Fri, 20 Mar 2026 14:20:12 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E7=99=BB=E9=99=86=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/login.ts | 4 ++-- src/pages/user/index.tsx | 9 +++++---- src/types/login.ts | 7 ++----- 3 files changed, 9 insertions(+), 11 deletions(-) diff --git a/src/api/login.ts b/src/api/login.ts index 4409159..20292c7 100644 --- a/src/api/login.ts +++ b/src/api/login.ts @@ -8,8 +8,8 @@ import { WechatLoginRequest, WechatAuthResponse } from '../types/login' * 微信登录 * @param code 微信登录凭证 */ -export const wechatLogin = (code: string, grpSn=''): Promise => { - const data: WechatLoginRequest = { code,grpSn } +export const wechatLogin = (code: string): Promise => { + const data: WechatLoginRequest = { code } return request({ url: '/WechatAuth/login-wechat', diff --git a/src/pages/user/index.tsx b/src/pages/user/index.tsx index c869cf3..ee4769f 100644 --- a/src/pages/user/index.tsx +++ b/src/pages/user/index.tsx @@ -73,7 +73,6 @@ const UserIndex = observer(() => { // 微信登录 const handleWechatLogin = async () => { - let grpSn = '212' try { userStore.setLoading(true) @@ -83,10 +82,12 @@ const UserIndex = observer(() => { throw new Error('获取微信登录凭证失败') } + console.log('loginResult', loginResult.code) + // return // 调用后端接口 - const response = await wechatLogin(loginResult.code,grpSn) + const response = await wechatLogin(loginResult.code) - if (response.success && response.data.success) { + if (response.success && response.data) { // 保存用户信息到store userStore.setUserInfoFromWechat(response.data.customer) @@ -95,7 +96,7 @@ const UserIndex = observer(() => { icon: 'success' }) } else { - throw new Error(response.data.message || response.message || '登录失败') + throw new Error(response.data?.message || response.message || '登录失败') } } catch (error: any) { console.error('微信登录失败:', error) diff --git a/src/types/login.ts b/src/types/login.ts index 5d5a0cd..d68fe96 100644 --- a/src/types/login.ts +++ b/src/types/login.ts @@ -2,10 +2,9 @@ * 微信登录相关类型定义 */ -// 微信登录请求参数 +// 微信登录请求参数 - 根据接口文档更新 export interface WechatLoginRequest { - code: string - grpSn?: string + code: string // 微信登录凭证code,通过 wx.login() 获取的临时登录凭证 } // 客户信息 @@ -31,9 +30,7 @@ export interface CustomerDto { // 微信登录结果数据 export interface WechatAuthResultDto { - success: boolean customer: CustomerDto - operationResult: any isNewCustomer: boolean message: string }