功能:更新消息中心和 YumiNail 模块
This commit is contained in:
@@ -0,0 +1,139 @@
|
||||
import api from './index'
|
||||
import type { UserInfo } from './auth'
|
||||
import type { IdType } from '@/utils/id'
|
||||
|
||||
export interface UserVO extends UserInfo {
|
||||
id: IdType
|
||||
shopId?: IdType
|
||||
shopName?: string
|
||||
shopIds?: IdType[]
|
||||
shopNames?: string[]
|
||||
nickname: string
|
||||
account: string
|
||||
avatar: string
|
||||
signature?: string
|
||||
level?: string
|
||||
type: number
|
||||
vipId?: IdType
|
||||
createTime: string
|
||||
updateTime: string
|
||||
status: number
|
||||
phone?: string
|
||||
}
|
||||
|
||||
export interface UpdateUserInfoRequest {
|
||||
nickname?: string
|
||||
avatar?: string
|
||||
signature?: string
|
||||
}
|
||||
|
||||
export interface ListUsersParams {
|
||||
page: number
|
||||
size: number
|
||||
keyword?: string
|
||||
shopId?: IdType
|
||||
status?: number
|
||||
}
|
||||
|
||||
export interface CreateUserRequest {
|
||||
account: string
|
||||
nickname: string
|
||||
phone: string
|
||||
password: string
|
||||
type: number
|
||||
shopId?: IdType
|
||||
shopIds?: IdType[]
|
||||
}
|
||||
|
||||
export interface UpdateUserRequest {
|
||||
account?: string
|
||||
nickname?: string
|
||||
phone?: string
|
||||
type?: number
|
||||
shopId?: IdType
|
||||
shopIds?: IdType[]
|
||||
}
|
||||
|
||||
export interface UpdatePasswordRequest {
|
||||
password: string
|
||||
verificationCode: string
|
||||
}
|
||||
|
||||
export interface BindPhoneRequest {
|
||||
phone: string
|
||||
verificationCode: string
|
||||
}
|
||||
|
||||
export interface AvailabilityCheckResponse {
|
||||
available: boolean
|
||||
message: string
|
||||
}
|
||||
|
||||
export interface LoginAccountCheckResponse {
|
||||
exists: boolean
|
||||
nickname?: string
|
||||
message: string
|
||||
}
|
||||
|
||||
export interface LoginShopSelectionResponse {
|
||||
allowShoplessLogin: boolean
|
||||
message: string
|
||||
shops: Array<{
|
||||
id: IdType
|
||||
shopName: string
|
||||
}>
|
||||
}
|
||||
|
||||
export interface UpdatePhoneRequest {
|
||||
oldPhone: string
|
||||
newPhone: string
|
||||
verificationCode: string
|
||||
}
|
||||
|
||||
export const userApi = {
|
||||
getUserInfo: async (): Promise<UserVO> => {
|
||||
return await api.get<UserVO>('/user/info') as unknown as UserVO
|
||||
},
|
||||
updateUserInfo: (data: UpdateUserInfoRequest) => {
|
||||
return api.put('/user/update', data)
|
||||
},
|
||||
updatePassword: (data: UpdatePasswordRequest) => {
|
||||
return api.put('/user/password', data)
|
||||
},
|
||||
bindPhone: (data: BindPhoneRequest) => {
|
||||
return api.post('/user/bind-phone', data)
|
||||
},
|
||||
updatePhone: (data: UpdatePhoneRequest) => {
|
||||
return api.put('/user/phone', data)
|
||||
},
|
||||
getUserByAccount: async (account: string): Promise<UserVO> => {
|
||||
return await api.get<UserVO>(`/user/get/account/${account}`) as unknown as UserVO
|
||||
},
|
||||
checkAccountAvailability: async (account: string): Promise<AvailabilityCheckResponse> => {
|
||||
return await api.get<AvailabilityCheckResponse>(`/user/check/account/${encodeURIComponent(account)}`) as unknown as AvailabilityCheckResponse
|
||||
},
|
||||
checkLoginAccountAvailability: async (account: string): Promise<LoginAccountCheckResponse> => {
|
||||
return await api.get<LoginAccountCheckResponse>(`/user/check/login-account/${encodeURIComponent(account)}`) as unknown as LoginAccountCheckResponse
|
||||
},
|
||||
getLoginShopsByAccount: async (account: string): Promise<LoginShopSelectionResponse> => {
|
||||
return await api.get<LoginShopSelectionResponse>(`/user/check/login-shops/account/${encodeURIComponent(account)}`) as unknown as LoginShopSelectionResponse
|
||||
},
|
||||
getLoginShopsByPhone: async (phone: string): Promise<LoginShopSelectionResponse> => {
|
||||
return await api.get<LoginShopSelectionResponse>(`/user/check/login-shops/phone/${encodeURIComponent(phone)}`) as unknown as LoginShopSelectionResponse
|
||||
},
|
||||
checkPhoneAvailability: async (phone: string): Promise<AvailabilityCheckResponse> => {
|
||||
return await api.get<AvailabilityCheckResponse>(`/user/check/phone/${encodeURIComponent(phone)}`) as unknown as AvailabilityCheckResponse
|
||||
},
|
||||
listUsersByType: async (type: number): Promise<UserVO[]> => {
|
||||
return await api.get<UserVO[]>(`/user/list/type/${type}`) as unknown as UserVO[]
|
||||
},
|
||||
sendVerificationCode: (data: { phone: string }) => {
|
||||
return api.post('/user/send-verification-code', data)
|
||||
},
|
||||
switchShop: (shopId?: string | number) => {
|
||||
return api.post('/user/switch-shop', { shopId })
|
||||
},
|
||||
deactivateAccount: () => {
|
||||
return api.delete('/user/deactivate')
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user