feat(salon): 支持散客预约拨号并发布协议新版本强制重新同意
自动发布开发环境 Nacos 配置 / publish (push) Successful in 23s

This commit is contained in:
2026-11-04 23:38:42 +08:00
parent 114a8a423c
commit 88589e2575
22 changed files with 602 additions and 44 deletions
+15
View File
@@ -234,6 +234,13 @@ export const authApi = {
}
}
export interface AgreementPending {
pending: boolean | null
currentVersions: Record<string, string>
acceptedVersions: Record<string, string>
pendingTypes: string[]
}
/**
* Purpose: legalAgreementApi supports auth.ts by holding or executing the legal agreement api page or API role.
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
@@ -247,5 +254,13 @@ export const legalAgreementApi = {
},
getMyConsent: () => {
return api.get<{ consentVersions: Record<string, string> }>('/user/agreement-consent/me')
},
getPending: () => {
return api.get<AgreementPending>('/legal-agreement/pending')
},
accept: (clientType = 'WEB') => {
return api.post<AgreementPending>('/legal-agreement/accept', null, {
params: { clientType }
})
}
}
+19 -2
View File
@@ -11,6 +11,7 @@ import type { IdType } from '@/utils/id'
import { clearAdminSessionStorage } from '@/utils/admin-session'
import { attachRequestSignature } from '@/utils/request-signature'
import { isApiAuthFreePath } from './auth-free-paths'
import { isAgreementPending } from '../utils/agreement-gate'
import {
getApiResponseMessage,
isPermissionErrorMessage,
@@ -77,6 +78,18 @@ const getStoredAccessToken = (isAdmin = false) => {
: (localStorage.getItem('accessToken') || sessionStorage.getItem('accessToken'))
}
/**
* 协议门禁接口在后台登录态下也需要使用管理员 token;其余沿用原有 admin 路径判断。
*/
const isAdminScopedUrl = (url?: string) => {
if (!url) return false
if (url.includes('/admin/') || url.includes('/order/admin/')) return true
const hasAdminToken = Boolean(localStorage.getItem('adminAccessToken') || sessionStorage.getItem('adminAccessToken'))
return hasAdminToken && (url.includes('/legal-agreement/pending') || url.includes('/legal-agreement/accept'))
}
const AGREEMENT_GATE_ALLOWLIST = ['/legal-agreement/', '/admin/auth/', '/user/logout', '/user/info']
/**
* Purpose: getStoredRefreshToken supports index.ts by holding or executing the get stored refresh token page or API role.
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
@@ -238,7 +251,11 @@ const handleTokenExpired = (isAdmin = false, failedToken: string | null = null)
api.interceptors.request.use(
async config => {
const isAdminRequest = config.url?.includes('/admin/') || config.url?.includes('/order/admin/')
if (isAgreementPending() && !AGREEMENT_GATE_ALLOWLIST.some(path => config.url?.includes(path))) {
return Promise.reject(new Error('请先阅读并同意最新版用户协议与隐私政策'))
}
const isAdminRequest = isAdminScopedUrl(config.url)
let token = isAdminRequest
? (localStorage.getItem('adminAccessToken') || sessionStorage.getItem('adminAccessToken'))
: (localStorage.getItem('accessToken') || sessionStorage.getItem('accessToken'))
@@ -286,7 +303,7 @@ api.interceptors.response.use(
if (error.response?.status === 401) {
// 检查是否是后台管理的API请求
const isAdminRequest = originalRequest.url?.includes('/admin/') || originalRequest.url?.includes('/order/admin/')
const isAdminRequest = isAdminScopedUrl(originalRequest.url)
const requestToken = getRequestToken(originalRequest)
const isRealTokenExpired = isTokenExpiredResponse(error, requestToken)
+7 -3
View File
@@ -278,9 +278,13 @@ export const userApi = {
/**
* 后台管理员按预约/订单上下文单次取号,号码不入库、不缓存。
*/
dialCustomer: async (customerId: IdType, orderId: IdType): Promise<CustomerDialResult> => {
return await api.post<CustomerDialResult>(`/manager/customers/${customerId}/dial`, null, {
params: { orderId }
dialCustomer: async (params: { customerId?: IdType; appointmentId?: IdType; orderId?: IdType }): Promise<CustomerDialResult> => {
return await api.post<CustomerDialResult>('/manager/customers/dial', null, {
params: {
customerId: params.customerId || undefined,
appointmentId: params.appointmentId || undefined,
orderId: params.orderId || undefined
}
}) as unknown as CustomerDialResult
},
getUserInfo: async (): Promise<UserVO> => {