功能:完善门店能力与用户安全配置

This commit is contained in:
xiaowang
2026-05-18 10:04:57 +08:00
parent 4563dd2538
commit 3797938616
356 changed files with 24983 additions and 1858 deletions
+93
View File
@@ -1,8 +1,13 @@
/**
* Front-end API wrapper for this module.
* Call guide: import the named API object, then call the matching method from a Vue page or composable.
*/
import api from './index'
import type { IdType } from '@/utils/id'
export interface SendVerificationCodeRequest {
phone: string
sceneCode?: string
}
export interface LoginRequest {
@@ -10,12 +15,18 @@ export interface LoginRequest {
password: string
rememberMe?: boolean
shopId?: string | number
agreementAccepted?: boolean
agreementVersions?: Record<string, string>
clientType?: string
}
export interface PhoneLoginRequest {
phone: string
verificationCode: string
shopId?: string | number
agreementAccepted?: boolean
agreementVersions?: Record<string, string>
clientType?: string
}
export interface RegisterRequest {
@@ -23,8 +34,24 @@ export interface RegisterRequest {
password: string
nickname: string
shopId?: string | number
inviteCode?: string
phone?: string
verificationCode?: string
agreementAccepted?: boolean
agreementVersions?: Record<string, string>
clientType?: string
}
export interface LegalAgreement {
id: IdType
agreementType: 'USER_TERMS' | 'PRIVACY_POLICY'
agreementTypeName: string
title: string
version: string
content: string
status: number
statusText?: string
effectiveTime?: string
}
export interface LoginResponse {
@@ -42,6 +69,8 @@ export interface UserInfo {
type?: number
shopId?: IdType
shopName?: string
shopAuthorizationExpireTime?: string
shopAuthorizationExpired?: boolean
shopIds?: IdType[]
shopNames?: string[]
createTime: string
@@ -67,44 +96,108 @@ export interface SwitchShopRequest {
shopId?: string | number
}
/**
* authApi groups all API calls for this page domain.
* Call guide: pass the typed payload or identifier into the method below, and use the returned Promise in the page script.
*/
export const authApi = {
/**
* `sendVerificationCode` API call. Use this method from the page script to invoke the backend endpoint tied to this feature.
* Call guide: supply the parameters below, await the returned Promise, and handle loading / error UI in the caller.
* @param data: SendVerificationCodeRequest caller-supplied value for `data: SendVerificationCodeRequest`
*/
sendVerificationCode: (data: SendVerificationCodeRequest) => {
return api.post('/user/send-verification-code', data)
},
/**
* `login` API call. Use this method from the page script to invoke the backend endpoint tied to this feature.
* Call guide: supply the parameters below, await the returned Promise, and handle loading / error UI in the caller.
* @param data: LoginRequest caller-supplied value for `data: LoginRequest`
*/
login: (data: LoginRequest) => {
return api.post<LoginResponse>('/user/login', data)
},
/**
* `phoneLogin` API call. Use this method from the page script to invoke the backend endpoint tied to this feature.
* Call guide: supply the parameters below, await the returned Promise, and handle loading / error UI in the caller.
* @param data: PhoneLoginRequest caller-supplied value for `data: PhoneLoginRequest`
*/
phoneLogin: (data: PhoneLoginRequest) => {
return api.post<LoginResponse>('/user/phone-login', data)
},
/**
* `adminLogin` API call. Use this method from the page script to invoke the backend endpoint tied to this feature.
* Call guide: supply the parameters below, await the returned Promise, and handle loading / error UI in the caller.
* @param data: LoginRequest caller-supplied value for `data: LoginRequest`
*/
adminLogin: (data: LoginRequest) => {
return api.post<LoginResponse>('/admin/auth/login', data)
},
/**
* `register` API call. Use this method from the page script to invoke the backend endpoint tied to this feature.
* Call guide: supply the parameters below, await the returned Promise, and handle loading / error UI in the caller.
* @param data: RegisterRequest caller-supplied value for `data: RegisterRequest`
*/
register: (data: RegisterRequest) => {
return api.post('/user/register', data)
},
/**
* `refreshToken` API call. Use this method from the page script to invoke the backend endpoint tied to this feature.
* Call guide: supply the parameters below, await the returned Promise, and handle loading / error UI in the caller.
* @param data: RefreshTokenRequest caller-supplied value for `data: RefreshTokenRequest`
*/
refreshToken: (data: RefreshTokenRequest) => {
return api.post<RefreshTokenResponse>('/user/refresh-token', data)
},
/**
* `logout` API call. Use this method from the page script to invoke the backend endpoint tied to this feature.
* Call guide: supply the parameters below, await the returned Promise, and handle loading / error UI in the caller.
*/
logout: () => {
return api.post('/user/logout')
},
/**
* `switchShop` API call. Use this method from the page script to invoke the backend endpoint tied to this feature.
* Call guide: supply the parameters below, await the returned Promise, and handle loading / error UI in the caller.
* @param data: SwitchShopRequest caller-supplied value for `data: SwitchShopRequest`
*/
switchShop: (data: SwitchShopRequest) => {
return api.post<LoginResponse>('/user/switch-shop', data)
},
/**
* `getUserInfo` API call. Use this method from the page script to invoke the backend endpoint tied to this feature.
* Call guide: supply the parameters below, await the returned Promise, and handle loading / error UI in the caller.
*/
getUserInfo: () => {
return api.get<UserInfo>('/user/info')
},
/**
* `resetPasswordByPhone` API call. Use this method from the page script to invoke the backend endpoint tied to this feature.
* Call guide: supply the parameters below, await the returned Promise, and handle loading / error UI in the caller.
* @param data: ResetPasswordRequest caller-supplied value for `data: ResetPasswordRequest`
*/
resetPasswordByPhone: (data: ResetPasswordRequest) => {
return api.post('/user/reset-password-by-phone', data)
}
}
export const legalAgreementApi = {
listCurrent: () => {
return api.get<LegalAgreement[]>('/legal-agreement/current')
},
getCurrent: (type: 'USER_TERMS' | 'PRIVACY_POLICY') => {
return api.get<LegalAgreement>(`/legal-agreement/current/${type}`)
},
getMyConsent: () => {
return api.get<{ consentVersions: Record<string, string> }>('/user/agreement-consent/me')
}
}