# 登录后获取用户信息接口文档 ## 概述 登录成功后,前端携带 `token` 调用该接口获取用户基础信息与平台扩展信息(头像、昵称、性别、地区等)。 ## 基础信息 - 方法: `GET` - 路径: `/api/user/profile` - Content-Type: `application/json` ## 请求头 - `Authorization: Bearer ` ## 请求参数(Query) | 字段 | 类型 | 必填 | 说明 | | --- | --- | --- | --- | | platformType | int | 否 | 平台类型,默认 `1`(微信小程序) | ### 请求示例 ``` GET /api/user/profile?platformType=1 Authorization: Bearer ``` ## 响应参数 | 字段 | 类型 | 说明 | | --- | --- | --- | | userId | int64 | 用户ID(t_user.id) | | username | string | 用户名 | | nickname | string | 昵称 | | avatarUrl | string | 头像URL | | phone | string | 手机号 | | gender | int | 性别:0-未知,1-男,2-女 | | region | string | 地区(优先 `platform_extra.region`,否则拼接国家/省/市) | | platformType | int | 平台类型 | | platformOpenid | string | 平台 openid | | platformUnionid | string | 平台 unionid | | platformExtra | object | 平台扩展字段(原样返回) | ### 成功响应示例 ```json { "code": 200, "message": "success", "data": { "userId": 10001, "username": "wx_20260315121500_ab12cd34", "nickname": "张三", "avatarUrl": "https://oss-xxx/avatar.png", "phone": "13800000000", "gender": 1, "region": "中国 广东 深圳", "platformType": 1, "platformOpenid": "oL1oU5gS6Q...", "platformUnionid": "o6_bmasdasds...", "platformExtra": { "country": "中国", "province": "广东", "city": "深圳" } } } ``` ## 错误响应示例 ```json { "code": 401, "message": "未登录", "data": null } ``` ## 备注 - 需要先登录并获取 `token`。 - `platformExtra` 为空时,`region` 可能为空。