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

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
+223 -1
View File
@@ -1,3 +1,7 @@
/**
* 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 { UserInfo } from './auth'
import type { IdType } from '@/utils/id'
@@ -19,6 +23,15 @@ export interface UserVO extends UserInfo {
updateTime: string
status: number
phone?: string
email?: string
maskedPhone?: string
maskedEmail?: string
shopRoleId?: IdType
shopRoleName?: string
parentUserId?: IdType
parentUserName?: string
parentUserTypeName?: string
relationSourceType?: string
}
export interface UpdateUserInfoRequest {
@@ -84,25 +97,160 @@ export interface LoginShopSelectionResponse {
}>
}
export interface UserRelationVO {
userId: IdType
shopId?: IdType
shopName?: string
parentUserId?: IdType
parentUserName?: string
parentRoleType?: number
parentRoleTypeName?: string
sourceType?: string
sourceTypeName?: string
}
// 用户端常用接口约定:
// - relation 表示当前用户的门店和直属上级归属;
// - announcement 只用于首页滚动公告,不进入消息通知历史;
// - system-message 才是站内消息,popup/read 分开记录。
export interface InviteCodeVO {
id: IdType
inviteCode: string
ownerUserId?: IdType
ownerUserName?: string
shopId?: IdType
shopName?: string
status?: number
useCount?: number
expireTime?: string
createTime?: string
}
export interface UpdatePhoneRequest {
oldPhone: string
newPhone: string
verificationCode: string
}
export interface UserAssetVO {
userId: IdType
nickname: string
balance: number
totalRechargeAmount: number
lastRechargeTime?: string
vipInfoId?: IdType
vipLevel: string
benefitId?: IdType
benefitInfo?: string
manualOverride?: boolean
vipStartTime?: string
vipExpireTime?: string
}
export interface BalanceHistoryItem {
id: IdType
userId: IdType
userNickname?: string
amount: number
type?: string
currentBalance?: number
beforeBalance?: number
afterBalance?: number
changeScene?: string
relatedOrderId?: IdType
relatedOrderNo?: string
externalOrderNo?: string
remark?: string
changeTime?: string
}
export interface SystemMessageVO {
id: IdType
title: string
content: string
imageFileId?: IdType
imageUrl?: string
publisherName?: string
targetType?: string
targetTypeName?: string
popupEnabled?: number
popupShown?: number
readStatus?: number
publishTime?: string
createTime?: string
}
export interface AnnouncementVO {
id: IdType
title: string
content: string
publisherName?: string
targetType?: string
status?: number
sortOrder?: number
publishTime?: string
}
export interface VipRechargePlanVO {
id: IdType
shopId: IdType
shopName?: string
title: string
rechargeAmount: number
giftAmount: number
vipLevel: string
description?: string
sortOrder?: number
status: number
}
export interface ContactInfoVO {
contactUserId?: IdType
contactName?: string
roleLabel?: string
phone?: string
phoneAvailable?: boolean
platformContactAvailable?: boolean
platformContactText?: string
}
/**
* userApi 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 userApi = {
getUserInfo: async (): Promise<UserVO> => {
return await api.get<UserVO>('/user/info') as unknown as UserVO
},
/**
* `updateUserInfo` 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: UpdateUserInfoRequest caller-supplied value for `data: UpdateUserInfoRequest`
*/
updateUserInfo: (data: UpdateUserInfoRequest) => {
return api.put('/user/update', data)
},
/**
* `updatePassword` 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: UpdatePasswordRequest caller-supplied value for `data: UpdatePasswordRequest`
*/
updatePassword: (data: UpdatePasswordRequest) => {
return api.put('/user/password', data)
},
/**
* `bindPhone` 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: BindPhoneRequest caller-supplied value for `data: BindPhoneRequest`
*/
bindPhone: (data: BindPhoneRequest) => {
return api.post('/user/bind-phone', data)
},
/**
* `updatePhone` 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: UpdatePhoneRequest caller-supplied value for `data: UpdatePhoneRequest`
*/
updatePhone: (data: UpdatePhoneRequest) => {
return api.put('/user/phone', data)
},
@@ -127,12 +275,86 @@ export const userApi = {
listUsersByType: async (type: number): Promise<UserVO[]> => {
return await api.get<UserVO[]>(`/user/list/type/${type}`) as unknown as UserVO[]
},
sendVerificationCode: (data: { phone: string }) => {
/**
* `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: { phone: string; sceneCode?: string } caller-supplied value for `data: { phone: string; sceneCode?: string }`
*/
sendVerificationCode: (data: { phone: string; sceneCode?: string }) => {
return api.post('/user/send-verification-code', data)
},
/**
* `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 shopId?: string | number caller-supplied value for `shopId?: string | number`
*/
switchShop: (shopId?: string | number) => {
return api.post('/user/switch-shop', { shopId })
},
getMyAsset: async (): Promise<UserAssetVO> => {
return await api.get<UserAssetVO>('/user/asset/me') as unknown as UserAssetVO
},
getMyBalanceHistory: async (): Promise<BalanceHistoryItem[]> => {
return await api.get<BalanceHistoryItem[]>('/user/balance/history/me') as unknown as BalanceHistoryItem[]
},
listMyMessages: async (): Promise<SystemMessageVO[]> => {
return await api.get<SystemMessageVO[]>('/system-message/my/list') as unknown as SystemMessageVO[]
},
listMyPopupMessages: async (): Promise<SystemMessageVO[]> => {
return await api.get<SystemMessageVO[]>('/system-message/my/popup') as unknown as SystemMessageVO[]
},
getMyUnreadMessageCount: async (): Promise<{ unreadCount: number }> => {
return await api.get<{ unreadCount: number }>('/system-message/my/unread-count') as unknown as { unreadCount: number }
},
getMyMessage: async (id: IdType): Promise<SystemMessageVO> => {
return await api.get<SystemMessageVO>(`/system-message/my/${id}`) as unknown as SystemMessageVO
},
/**
* `markMessagePopupShown` 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 id: IdType caller-supplied value for `id: IdType`
*/
markMessagePopupShown: (id: IdType) => {
return api.put(`/system-message/my/${id}/popup-shown`, {})
},
/**
* `markMessageRead` 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 id: IdType caller-supplied value for `id: IdType`
*/
markMessageRead: (id: IdType) => {
return api.put(`/system-message/my/${id}/read`, {})
},
listMyAnnouncements: async (): Promise<AnnouncementVO[]> => {
return await api.get<AnnouncementVO[]>('/announcement/my/list') as unknown as AnnouncementVO[]
},
listMyVipRechargePlans: async (): Promise<VipRechargePlanVO[]> => {
return await api.get<VipRechargePlanVO[]>('/vip-recharge-plan/my/list') as unknown as VipRechargePlanVO[]
},
getMyRelation: async (): Promise<UserRelationVO> => {
return await api.get<UserRelationVO>('/user/relation/me') as unknown as UserRelationVO
},
// 注册页输入邀请码时先解析,给用户展示“将归属到谁/哪个店铺”。
resolveInviteCode: async (code: string): Promise<InviteCodeVO> => {
return await api.get<InviteCodeVO>('/user/invite-code/resolve', { params: { code } }) as unknown as InviteCodeVO
},
getShopManagerContact: async (shopId: IdType): Promise<ContactInfoVO> => {
return await api.get<ContactInfoVO>(`/contact-info/shop/${shopId}/manager`) as unknown as ContactInfoVO
},
getProductArtistContact: async (productId: IdType, artistId: IdType): Promise<ContactInfoVO> => {
return await api.get<ContactInfoVO>(`/contact-info/product/${productId}/artist/${artistId}`) as unknown as ContactInfoVO
},
getOrderArtistContact: async (orderId: IdType, artistId?: IdType): Promise<ContactInfoVO> => {
const params = artistId ? { artistId } : {}
return await api.get<ContactInfoVO>(`/contact-info/order/${orderId}/artist`, { params }) as unknown as ContactInfoVO
},
getPlatformContact: async (): Promise<ContactInfoVO> => {
return await api.get<ContactInfoVO>('/contact-info/platform') as unknown as ContactInfoVO
},
/**
* `deactivateAccount` 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.
*/
deactivateAccount: () => {
return api.delete('/user/deactivate')
}