From 8e031231c15f4019ed294292cab415c205f293e9 Mon Sep 17 00:00:00 2001 From: dzq Date: Thu, 6 Nov 2025 11:05:21 +0800 Subject: [PATCH] =?UTF-8?q?feat(=E5=BE=AE=E4=BF=A1=E7=99=BB=E5=BD=95):=20?= =?UTF-8?q?=E6=89=A9=E5=B1=95=E5=BE=AE=E4=BF=A1=E7=99=BB=E5=BD=95=E8=BF=94?= =?UTF-8?q?=E5=9B=9E=E7=94=A8=E6=88=B7=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 修改mpCodeToOpenId接口返回类型为WxUserDTO,包含完整的微信用户信息 更新相关页面调用逻辑,将openId改为wxUser 新增WxUserDTO类型定义,包含微信用户相关字段 --- src/api/users/index.ts | 4 ++-- src/api/users/types.ts | 26 ++++++++++++++++++++++++++ src/pages/index/index.vue | 4 ++-- src/pages/login/login.vue | 4 ++-- 4 files changed, 32 insertions(+), 6 deletions(-) diff --git a/src/api/users/index.ts b/src/api/users/index.ts index e46c705..985c9e6 100644 --- a/src/api/users/index.ts +++ b/src/api/users/index.ts @@ -1,5 +1,5 @@ import { http } from "@/http/http"; -import type { CurrentUserResponseData } from './types'; +import type { CurrentUserResponseData, WxUserDTO } from './types'; /** 获取当前登录用户详情 */ export async function getCurrentUserApi() { @@ -7,5 +7,5 @@ export async function getCurrentUserApi() { } export async function mpCodeToOpenId(code: string) { - return await http.get("wx/mpCodeToOpenId", { code }); + return await http.get("wx/mpCodeToOpenId", { code }); } \ No newline at end of file diff --git a/src/api/users/types.ts b/src/api/users/types.ts index 4fd6ba7..678ed47 100644 --- a/src/api/users/types.ts +++ b/src/api/users/types.ts @@ -1,3 +1,29 @@ export type CurrentUserResponseData = { data: { username: string, roles: string[] } +} + +/** 微信用户DTO */ +export interface WxUserDTO { + /** 主键ID */ + wxUserId?: number; + /** openid */ + openid?: string; + /** 汇邦云用户ID */ + ab98UserId?: number; + /** 企业用户ID */ + qyUserId?: number; + /** 昵称 */ + nickName?: string; + /** 手机号码 */ + tel?: string; + /** 余额(分) */ + wxBalance?: number; + /** 余额(元) */ + wxBalanceYuan?: number; + /** 创建时间 */ + createTime?: string; + /** 更新时间 */ + updateTime?: string; + /** 备注 */ + remark?: string; } \ No newline at end of file diff --git a/src/pages/index/index.vue b/src/pages/index/index.vue index cac1c2d..f534c60 100644 --- a/src/pages/index/index.vue +++ b/src/pages/index/index.vue @@ -31,8 +31,8 @@ onMounted(async () => { uni.login({ provider: 'weixin', //使用微信登录 success: function (loginRes) { - mpCodeToOpenId(loginRes.code).then((openId) => { - console.log('openId:', openId) + mpCodeToOpenId(loginRes.code).then((wxUser) => { + console.log('wxUser:', wxUser) }).catch((e) => { console.error('mpCodeToOpenId error:', e) }) diff --git a/src/pages/login/login.vue b/src/pages/login/login.vue index 3b98e1d..6952f7d 100644 --- a/src/pages/login/login.vue +++ b/src/pages/login/login.vue @@ -73,8 +73,8 @@ const login = () => { uni.login({ provider: 'weixin', //使用微信登录 success: function (loginRes) { - mpCodeToOpenId(loginRes.code).then((openId) => { - console.log('openId:', openId) + mpCodeToOpenId(loginRes.code).then((wxUser) => { + console.log('openId:', wxUser) loading.value = false }).catch((e) => { loading.value = false