账户密码登录

This commit is contained in:
liu
2026-08-21 11:01:37 +08:00
parent 3bd26acbb9
commit f0d8f6bac4
13 changed files with 328 additions and 599 deletions
+27 -24
View File
@@ -1,39 +1,42 @@
import { get, post } from '@/utils/request'
import { get, post, put } from '@/utils/request'
import type { User } from '@/types/user'
/** 微信登录参数 */
export interface WxLoginParams {
/** wx.login 的临时凭证 */
code: string
/** 账号密码登录参数 */
export interface LoginParams {
/** 登录账号(商家后台分配,4~20 位) */
username: string
/** 登录密码 */
password: string
}
/** 微信注册参数 */
export interface RegisterParams {
/** wx.login 的临时凭证 */
code: string
/** wx.getPhoneNumber 授权得到的 code */
phoneCode: string
/** 门店编码(后台门店管理维护) */
storeCode: string
}
/** 登录 / 注册返回 */
/** 登录返回 */
export interface AuthResult {
token: string
/** 门店即用户(扁平结构) */
user: User
}
/** 微信登录(仅已注册用户可登录):POST /mini/auth/login */
export function wxLoginApi(params: WxLoginParams) {
/** 修改密码参数 */
export interface ChangePasswordParams {
/** 原密码 */
oldPassword: string
/** 新密码(6~20 位) */
newPassword: string
/** 确认新密码(须与 newPassword 一致) */
rePassword: string
}
/** 账号密码登录:POST /mini/auth/login */
export function loginApi(params: LoginParams) {
return post<AuthResult>('/mini/auth/login', params)
}
/** 微信注册(code 换 openid + phoneCode 换手机号 + storeCode 绑定门店):POST /mini/auth/register */
export function registerApi(params: RegisterParams) {
return post<AuthResult>('/mini/auth/register', params)
}
/** 当前用户信息(含门店客户等级):GET /mini/auth/info */
/** 当前门店信息(含客户等级):GET /mini/auth/info */
export function getUserInfoApi() {
return get<User>('/mini/auth/info')
}
/** 修改密码(成功后现有 token 仍有效):PUT /mini/auth/password */
export function changePasswordApi(params: ChangePasswordParams) {
return put<null>('/mini/auth/password', params)
}