会员接口
注册与登录
会员注册、密码登录、手机验证码登录与找回密码,成功即返回登录态 JWT。
会员注册
POST
/_api/member/register公开接口使用用户名与密码注册会员,注册成功直接返回登录态。
请求体字段
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
| username | string | 是 | 用户名,至少 3 位且全局唯一。 |
| password | string | 是 | 密码,至少 6 位。 |
| nickname | string | 否 | 昵称,缺省使用用户名。 |
| string | 否 | 邮箱,可选,用于邮箱登录与找回密码。 |
请求示例
{
"username": "zhangsan",
"password": "secret123",
"nickname": "张三",
"email": "zhangsan@example.com"
}响应示例
{
"token": "eyJhbGciOiJIUzI1NiIs...",
"expiresIn": 604800,
"isDefaultPassword": false
}会员密码登录
POST
/_api/member/login公开接口使用用户名与密码登录,返回 JWT。
请求体字段
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
| username | string | 是 | 用户名。 |
| password | string | 是 | 密码。 |
请求示例
{ "username": "zhangsan", "password": "secret123" }响应示例
{
"token": "eyJhbGciOiJIUzI1NiIs...",
"expiresIn": 604800,
"isDefaultPassword": false
}发送短信登录验证码
POST
/_api/member/sms/send公开接口向手机号发送登录验证码。同一手机号 60 秒内不可重复发送,每日有上限。
请求体字段
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
| phone | string | 是 | 中国大陆手机号(11 位)。 |
请求示例
{ "phone": "13800000000" }响应示例
{ "expiresIn": 300, "resendAfter": 60 }手机验证码登录
POST
/_api/member/sms/login公开接口手机号 + 短信验证码登录;手机号未注册时自动创建会员账号。
请求体字段
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
| phone | string | 是 | 中国大陆手机号(11 位)。 |
| code | string | 是 | 6 位短信验证码。 |
请求示例
{ "phone": "13800000000", "code": "123456" }响应示例
{
"token": "eyJhbGciOiJIUzI1NiIs...",
"expiresIn": 604800,
"isDefaultPassword": false
}发送找回密码验证码
POST
/_api/member/password/reset-code公开接口按手机号或邮箱发送重置密码验证码;该手机号/邮箱必须已绑定会员账号。
请求体字段
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
| channel | string | 是 | 投递渠道:sms 或 email。 |
| target | string | 是 | 手机号或邮箱地址。 |
请求示例
{ "channel": "email", "target": "zhangsan@example.com" }响应示例
{ "expiresIn": 300, "resendAfter": 60 }重置密码
POST
/_api/member/password/reset公开接口通过验证码重置密码,成功后直接返回登录态。
请求体字段
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
| channel | string | 是 | 投递渠道:sms 或 email。 |
| target | string | 是 | 手机号或邮箱地址。 |
| code | string | 是 | 6 位验证码。 |
| newPassword | string | 是 | 新密码,至少 6 位。 |
请求示例
{
"channel": "email",
"target": "zhangsan@example.com",
"code": "654321",
"newPassword": "newSecret123"
}响应示例
{
"token": "eyJhbGciOiJIUzI1NiIs...",
"expiresIn": 604800,
"isDefaultPassword": false
}