功能(订单服务): 将未成年提示和底部引导图并入分类配置
This commit is contained in:
@@ -45,7 +45,6 @@ import { formatAdminDateTime } from '@/utils/admin-time'
|
||||
import { normalizeProductNameSuffixText } from '@/utils/product-name-source-suffix'
|
||||
|
||||
import HallConfigPanel from './HallConfigPanel'
|
||||
import OrderServiceAgeGateConfigCard from './OrderServiceAgeGateConfigCard'
|
||||
|
||||
function isDepositUnfreezeJob(job: AdminScheduledJobItem) {
|
||||
return job.type === 'deposit_unfreeze' || job.id === 'deposit-unfreeze'
|
||||
@@ -55,7 +54,6 @@ export default function AnnouncementPanel() {
|
||||
return (
|
||||
<Space direction="vertical" size={16} style={{ width: '100%' }}>
|
||||
<AnnouncementCard />
|
||||
<OrderServiceAgeGateConfigCard />
|
||||
<SupportContactCard />
|
||||
<ProductNameSourceSuffixCard />
|
||||
<DepositUnfreezeCard />
|
||||
|
||||
@@ -1,198 +0,0 @@
|
||||
import { SaveOutlined } from '@ant-design/icons'
|
||||
import { App, Button, Card, Col, Form, Input, Row, Space, Switch, Typography } from 'antd'
|
||||
import { useQuery, useQueryClient } from '@tanstack/react-query'
|
||||
import { useEffect, useState } from 'react'
|
||||
|
||||
import {
|
||||
fetchAdminOrderServiceAgeGateConfig,
|
||||
saveAdminOrderServiceAgeGateConfig,
|
||||
} from '@/services/admin'
|
||||
import type { OrderServiceAgeGateConfig } from '@/types/worker-platform'
|
||||
import {
|
||||
DEFAULT_ORDER_SERVICE_AGE_GATE_CONFIG,
|
||||
mergeOrderServiceAgeGateConfig,
|
||||
} from '@/utils/order-service-age-gate'
|
||||
|
||||
const { Text } = Typography
|
||||
|
||||
export default function OrderServiceAgeGateConfigCard() {
|
||||
const { message } = App.useApp()
|
||||
const queryClient = useQueryClient()
|
||||
const [form] = Form.useForm<OrderServiceAgeGateConfig>()
|
||||
const [saving, setSaving] = useState(false)
|
||||
const configQuery = useQuery({
|
||||
queryKey: ['admin-order-service-age-gate'],
|
||||
queryFn: fetchAdminOrderServiceAgeGateConfig,
|
||||
})
|
||||
const enabled = Form.useWatch('enabled', form) === true
|
||||
|
||||
useEffect(() => {
|
||||
if (!configQuery.data?.data) return
|
||||
form.setFieldsValue(mergeOrderServiceAgeGateConfig(configQuery.data.data))
|
||||
}, [configQuery.data, form])
|
||||
|
||||
async function save(values: OrderServiceAgeGateConfig) {
|
||||
setSaving(true)
|
||||
try {
|
||||
await saveAdminOrderServiceAgeGateConfig(values)
|
||||
await queryClient.invalidateQueries({ queryKey: ['admin-order-service-age-gate'] })
|
||||
message.success('工单补资料页未成年提示已保存')
|
||||
} catch (error) {
|
||||
message.error(error instanceof Error ? error.message : '保存未成年提示配置失败')
|
||||
} finally {
|
||||
setSaving(false)
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
<Card
|
||||
title="工单补资料页未成年提示"
|
||||
bordered={false}
|
||||
extra={
|
||||
<Button
|
||||
type="primary"
|
||||
icon={<SaveOutlined />}
|
||||
loading={saving}
|
||||
disabled={configQuery.isLoading}
|
||||
onClick={() => void form.submit()}
|
||||
>
|
||||
保存配置
|
||||
</Button>
|
||||
}
|
||||
>
|
||||
<Typography.Paragraph type="secondary" style={{ marginBottom: 16 }}>
|
||||
仅作用于客户工单补资料页(<Text code>/o/<订单号></Text>)的待补资料工单。
|
||||
默认关闭;启用后,客户进入页面先看到购买前提示,点击“已成年”才显示资料表单。
|
||||
提示内容、按钮文字和未成年拦截提示都可在下方配置。
|
||||
</Typography.Paragraph>
|
||||
{enabled ? (
|
||||
<Typography.Paragraph type="warning" style={{ marginBottom: 16 }}>
|
||||
当前已启用:所有待补资料工单进入页面时都会显示该提示。
|
||||
</Typography.Paragraph>
|
||||
) : (
|
||||
<Typography.Paragraph type="secondary" style={{ marginBottom: 16 }}>
|
||||
当前未启用:不会影响现有补资料流程。
|
||||
</Typography.Paragraph>
|
||||
)}
|
||||
{configQuery.isError ? (
|
||||
<Typography.Paragraph type="danger" style={{ marginBottom: 16 }}>
|
||||
读取配置失败,当前显示的是默认文案;请确认后端已更新并重启后再保存。
|
||||
</Typography.Paragraph>
|
||||
) : null}
|
||||
|
||||
<Form
|
||||
form={form}
|
||||
layout="vertical"
|
||||
initialValues={DEFAULT_ORDER_SERVICE_AGE_GATE_CONFIG}
|
||||
onFinish={(values) => void save(values)}
|
||||
style={{ maxWidth: 900 }}
|
||||
>
|
||||
<Form.Item
|
||||
name="enabled"
|
||||
label="启用未成年提示"
|
||||
valuePropName="checked"
|
||||
extra="默认关闭。将该开关打开并保存后,客户端才会弹出提示。"
|
||||
>
|
||||
<Switch checkedChildren="启用" unCheckedChildren="关闭" />
|
||||
</Form.Item>
|
||||
|
||||
<Row gutter={[12, 0]}>
|
||||
<Col xs={24} md={12}>
|
||||
<Form.Item
|
||||
name="title"
|
||||
label="弹窗标题"
|
||||
rules={[{ required: true, whitespace: true, message: '请填写弹窗标题' }]}
|
||||
>
|
||||
<Input maxLength={40} placeholder="购买前必读" />
|
||||
</Form.Item>
|
||||
</Col>
|
||||
<Col xs={24} md={12}>
|
||||
<Form.Item
|
||||
name="warningText"
|
||||
label="红色警示语"
|
||||
rules={[{ required: true, whitespace: true, message: '请填写红色警示语' }]}
|
||||
>
|
||||
<Input maxLength={200} placeholder="无法向未成年人操作发货,请认真阅读作答!!!" />
|
||||
</Form.Item>
|
||||
</Col>
|
||||
</Row>
|
||||
|
||||
<Form.Item
|
||||
name="content"
|
||||
label="正文内容"
|
||||
rules={[{ required: true, whitespace: true, message: '请填写正文内容' }]}
|
||||
extra="支持换行;客户页面会按原样展示。"
|
||||
>
|
||||
<Input.TextArea
|
||||
autoSize={{ minRows: 8, maxRows: 18 }}
|
||||
maxLength={2000}
|
||||
showCount
|
||||
placeholder="请输入购买前须知"
|
||||
/>
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item
|
||||
name="importantNotice"
|
||||
label="重要提示"
|
||||
extra="显示在正文下方的红色提示框;留空后后端会使用默认内容。"
|
||||
>
|
||||
<Input.TextArea
|
||||
autoSize={{ minRows: 2, maxRows: 5 }}
|
||||
maxLength={500}
|
||||
showCount
|
||||
placeholder="【重要提示】请警惕冒充售后、道具回收等诈骗行为。"
|
||||
/>
|
||||
</Form.Item>
|
||||
|
||||
<Row gutter={[12, 0]}>
|
||||
<Col xs={24} md={12}>
|
||||
<Form.Item
|
||||
name="adultButtonText"
|
||||
label="已成年按钮文字"
|
||||
rules={[{ required: true, whitespace: true, message: '请填写已成年按钮文字' }]}
|
||||
>
|
||||
<Input maxLength={12} placeholder="我已成年" />
|
||||
</Form.Item>
|
||||
</Col>
|
||||
<Col xs={24} md={12}>
|
||||
<Form.Item
|
||||
name="minorButtonText"
|
||||
label="未成年按钮文字"
|
||||
rules={[{ required: true, whitespace: true, message: '请填写未成年按钮文字' }]}
|
||||
>
|
||||
<Input maxLength={12} placeholder="我是未成年" />
|
||||
</Form.Item>
|
||||
</Col>
|
||||
</Row>
|
||||
|
||||
<Form.Item
|
||||
name="minorBlockedTitle"
|
||||
label="未成年拦截标题"
|
||||
rules={[{ required: true, whitespace: true, message: '请填写未成年拦截标题' }]}
|
||||
>
|
||||
<Input maxLength={40} placeholder="未成年不能购买" />
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item
|
||||
name="minorBlockedContent"
|
||||
label="未成年拦截正文"
|
||||
rules={[{ required: true, whitespace: true, message: '请填写未成年拦截正文' }]}
|
||||
>
|
||||
<Input.TextArea
|
||||
autoSize={{ minRows: 3, maxRows: 6 }}
|
||||
maxLength={500}
|
||||
showCount
|
||||
placeholder="根据平台规则,本店无法向未成年人销售或操作发货。当前流程已停止。"
|
||||
/>
|
||||
</Form.Item>
|
||||
|
||||
<Space>
|
||||
<Button type="primary" htmlType="submit" loading={saving}>
|
||||
保存配置
|
||||
</Button>
|
||||
<Text type="secondary">保存后新打开的客户工单补资料页立即使用最新配置。</Text>
|
||||
</Space>
|
||||
</Form>
|
||||
</Card>
|
||||
)
|
||||
}
|
||||
@@ -50,8 +50,9 @@ import {
|
||||
type OrderServiceStatusSteps,
|
||||
} from '@/services/admin/worker-platform'
|
||||
import { uploadFile } from '@/services/files'
|
||||
import type { UploadedFile } from '@/types/worker-platform'
|
||||
import type { OrderServiceAgeGateConfig, UploadedFile } from '@/types/worker-platform'
|
||||
import { formatAdminDateTime } from '@/utils/admin-time'
|
||||
import { DEFAULT_ORDER_SERVICE_AGE_GATE_CONFIG } from '@/utils/order-service-age-gate'
|
||||
|
||||
const { Text, Title } = Typography
|
||||
|
||||
@@ -82,6 +83,8 @@ type OrderServiceFormValues = {
|
||||
autoPublish: AutoPublishForm
|
||||
materialConfirmation: OrderServiceMaterialConfirmation
|
||||
statusSteps: OrderServiceStatusSteps
|
||||
ageGate: OrderServiceAgeGateConfig
|
||||
bottomGuideImage: { enabled: boolean }
|
||||
}
|
||||
|
||||
type OrderServiceCategoryNode = {
|
||||
@@ -256,6 +259,9 @@ export default function OrderServicePanel() {
|
||||
const [expandedCategoryIds, setExpandedCategoryIds] = useState<Set<number>>(() => new Set())
|
||||
const [fields, setFields] = useState<OrderServiceField[]>([])
|
||||
const [guideImage, setGuideImage] = useState<UploadedFile | Record<string, unknown> | null>(null)
|
||||
const [bottomGuideImage, setBottomGuideImage] = useState<
|
||||
UploadedFile | Record<string, unknown> | null
|
||||
>(null)
|
||||
const [saving, setSaving] = useState(false)
|
||||
const [publishing, setPublishing] = useState(false)
|
||||
const [retryingJobId, setRetryingJobId] = useState(0)
|
||||
@@ -342,6 +348,12 @@ export default function OrderServicePanel() {
|
||||
Form.useWatch('materialConfirmation', form) || DEFAULT_MATERIAL_CONFIRMATION
|
||||
const confirmationEnabledValue = Form.useWatch(['materialConfirmation', 'enabled'], form)
|
||||
const confirmationEnabled = confirmationEnabledValue !== false
|
||||
const ageGateEnabled = Form.useWatch(['ageGate', 'enabled'], form) === true
|
||||
const bottomGuideEnabled = Form.useWatch(['bottomGuideImage', 'enabled'], form) === true
|
||||
const bottomGuideFiles = useMemo(() => {
|
||||
const image = resolveGuideImage(bottomGuideImage)
|
||||
return image ? [image] : []
|
||||
}, [bottomGuideImage])
|
||||
|
||||
useEffect(() => {
|
||||
if (selectedCategoryId !== null || categories.length === 0) return
|
||||
@@ -361,6 +373,8 @@ export default function OrderServicePanel() {
|
||||
title: nextProfile?.title || '',
|
||||
description: nextProfile?.description || '',
|
||||
guideImageDescription: nextProfile?.guideImageDescription || '',
|
||||
ageGate: nextProfile?.ageGate || DEFAULT_ORDER_SERVICE_AGE_GATE_CONFIG,
|
||||
bottomGuideImage: { enabled: nextProfile?.bottomGuideImage?.enabled === true },
|
||||
submitText: nextProfile?.submitText || '提交资料',
|
||||
successText: nextProfile?.successText || '资料已提交,请等待处理',
|
||||
postSubmitText: nextProfile?.postSubmitText || DEFAULT_POST_SUBMIT_TEXT,
|
||||
@@ -375,6 +389,7 @@ export default function OrderServicePanel() {
|
||||
),
|
||||
)
|
||||
setGuideImage(resolveGuideImage(nextProfile?.guideImage))
|
||||
setBottomGuideImage(resolveGuideImage(nextProfile?.bottomGuideImage?.image || null))
|
||||
}
|
||||
|
||||
async function refresh() {
|
||||
@@ -473,6 +488,11 @@ export default function OrderServicePanel() {
|
||||
description: values.description || '',
|
||||
guideImage: guideImage || {},
|
||||
guideImageDescription: values.guideImageDescription || '',
|
||||
ageGate: values.ageGate,
|
||||
bottomGuideImage: {
|
||||
enabled: values.bottomGuideImage?.enabled === true,
|
||||
image: bottomGuideImage || null,
|
||||
},
|
||||
fields: normalizedFields,
|
||||
screenshots: values.screenshots,
|
||||
autoPublish: values.autoPublish,
|
||||
@@ -1243,6 +1263,147 @@ export default function OrderServicePanel() {
|
||||
</Col>
|
||||
</Row>
|
||||
|
||||
<section className="order-service-section">
|
||||
<div className="order-service-section-head">
|
||||
<OrderServiceSectionTitle
|
||||
index="07"
|
||||
title="未成年提示"
|
||||
description="客户进入待补资料页时先展示,确认成年后才显示资料表单"
|
||||
/>
|
||||
<div className="order-service-confirmation-switch">
|
||||
<span>
|
||||
<Text strong>{ageGateEnabled ? '已启用' : '已停用'}</Text>
|
||||
<Text type="secondary">
|
||||
{ageGateEnabled ? '命中该分类时弹窗' : '命中该分类时不弹窗'}
|
||||
</Text>
|
||||
</span>
|
||||
<Form.Item name={['ageGate', 'enabled']} valuePropName="checked" noStyle>
|
||||
<Switch />
|
||||
</Form.Item>
|
||||
</div>
|
||||
</div>
|
||||
<Row gutter={[12, 0]}>
|
||||
<Col xs={24} md={12}>
|
||||
<Form.Item
|
||||
name={['ageGate', 'title']}
|
||||
label="弹窗标题"
|
||||
rules={[{ required: true, whitespace: true, message: '请填写弹窗标题' }]}
|
||||
>
|
||||
<Input maxLength={40} placeholder="购买前必读" />
|
||||
</Form.Item>
|
||||
</Col>
|
||||
<Col xs={24} md={12}>
|
||||
<Form.Item
|
||||
name={['ageGate', 'warningText']}
|
||||
label="红色警示语"
|
||||
rules={[
|
||||
{ required: true, whitespace: true, message: '请填写红色警示语' },
|
||||
]}
|
||||
>
|
||||
<Input
|
||||
maxLength={200}
|
||||
placeholder="无法向未成年人操作发货,请认真阅读作答!!!"
|
||||
/>
|
||||
</Form.Item>
|
||||
</Col>
|
||||
</Row>
|
||||
<Form.Item
|
||||
name={['ageGate', 'content']}
|
||||
label="正文内容"
|
||||
rules={[{ required: true, whitespace: true, message: '请填写正文内容' }]}
|
||||
extra="支持换行;客户页面按原样展示。"
|
||||
>
|
||||
<Input.TextArea
|
||||
autoSize={{ minRows: 8, maxRows: 18 }}
|
||||
maxLength={2000}
|
||||
showCount
|
||||
/>
|
||||
</Form.Item>
|
||||
<Form.Item name={['ageGate', 'importantNotice']} label="重要提示">
|
||||
<Input.TextArea
|
||||
autoSize={{ minRows: 2, maxRows: 5 }}
|
||||
maxLength={500}
|
||||
showCount
|
||||
placeholder="显示在正文下方的重要提示"
|
||||
/>
|
||||
</Form.Item>
|
||||
<Row gutter={[12, 0]}>
|
||||
<Col xs={24} md={12}>
|
||||
<Form.Item
|
||||
name={['ageGate', 'adultButtonText']}
|
||||
label="已成年按钮文字"
|
||||
rules={[{ required: true, whitespace: true, message: '请填写按钮文字' }]}
|
||||
>
|
||||
<Input maxLength={12} placeholder="我已成年" />
|
||||
</Form.Item>
|
||||
</Col>
|
||||
<Col xs={24} md={12}>
|
||||
<Form.Item
|
||||
name={['ageGate', 'minorButtonText']}
|
||||
label="未成年按钮文字"
|
||||
rules={[{ required: true, whitespace: true, message: '请填写按钮文字' }]}
|
||||
>
|
||||
<Input maxLength={12} placeholder="我是未成年" />
|
||||
</Form.Item>
|
||||
</Col>
|
||||
</Row>
|
||||
<Form.Item
|
||||
name={['ageGate', 'minorBlockedTitle']}
|
||||
label="未成年拦截标题"
|
||||
rules={[{ required: true, whitespace: true, message: '请填写拦截标题' }]}
|
||||
>
|
||||
<Input maxLength={40} placeholder="未成年不能购买" />
|
||||
</Form.Item>
|
||||
<Form.Item
|
||||
name={['ageGate', 'minorBlockedContent']}
|
||||
label="未成年拦截正文"
|
||||
rules={[{ required: true, whitespace: true, message: '请填写拦截正文' }]}
|
||||
>
|
||||
<Input.TextArea
|
||||
autoSize={{ minRows: 3, maxRows: 6 }}
|
||||
maxLength={500}
|
||||
showCount
|
||||
/>
|
||||
</Form.Item>
|
||||
</section>
|
||||
|
||||
<section className="order-service-section">
|
||||
<div className="order-service-section-head">
|
||||
<OrderServiceSectionTitle
|
||||
index="08"
|
||||
title="底部引导图"
|
||||
description="独立于截图填写参考图,显示在客户填写资料页最底部"
|
||||
/>
|
||||
<div className="order-service-confirmation-switch">
|
||||
<span>
|
||||
<Text strong>{bottomGuideEnabled ? '已启用' : '已停用'}</Text>
|
||||
<Text type="secondary">
|
||||
{bottomGuideEnabled ? '命中分类时展示图片' : '命中分类时不展示'}
|
||||
</Text>
|
||||
</span>
|
||||
<Form.Item
|
||||
name={['bottomGuideImage', 'enabled']}
|
||||
valuePropName="checked"
|
||||
noStyle
|
||||
>
|
||||
<Switch />
|
||||
</Form.Item>
|
||||
</div>
|
||||
</div>
|
||||
<Form.Item
|
||||
label="引导图"
|
||||
extra="只配置图片,不配置说明文字;没有图片或未启用时不显示。"
|
||||
>
|
||||
<ImageUpload
|
||||
scene="order-service-guide"
|
||||
scope="admin"
|
||||
maxCount={1}
|
||||
value={bottomGuideFiles}
|
||||
onChange={(files) => setBottomGuideImage(files[0] || null)}
|
||||
uploader={uploadGuideImage}
|
||||
/>
|
||||
</Form.Item>
|
||||
</section>
|
||||
<div className="order-service-save-bar">
|
||||
<Text type="secondary">保存只更新草稿,发布后才会影响新工单。</Text>
|
||||
<Space>
|
||||
|
||||
@@ -38,8 +38,10 @@ import {
|
||||
import type { UploadedFile } from '@/types/worker-platform'
|
||||
import { normalizeOrderServiceInput } from '@/utils/order-service-link'
|
||||
import {
|
||||
dedupeOrderServiceBottomGuideImages,
|
||||
isOrderServiceAgeGateOpen,
|
||||
resolveOrderServiceAgeGateDecision,
|
||||
selectFirstOrderServiceAgeGate,
|
||||
shouldRequireOrderServiceAgeGate,
|
||||
type OrderServiceAgeGateState,
|
||||
} from '@/utils/order-service-age-gate'
|
||||
@@ -109,11 +111,14 @@ export default function OrderServicePage() {
|
||||
const confirmationOpenRef = useRef(false)
|
||||
const requestSeqRef = useRef(0)
|
||||
const loadedOrderRef = useRef('')
|
||||
const infoRef = useRef<OrderServiceInfo | null>(null)
|
||||
|
||||
const pendingItems = (info?.items || []).filter((item) => item.canSubmit)
|
||||
const selectedAgeGate = selectFirstOrderServiceAgeGate(pendingItems)
|
||||
const bottomGuideImages = dedupeOrderServiceBottomGuideImages(pendingItems)
|
||||
const ageGateDecision = resolveOrderServiceAgeGateDecision(ageGateState, orderNo)
|
||||
const ageGateRequired = shouldRequireOrderServiceAgeGate({
|
||||
enabled: info?.ageGate?.enabled,
|
||||
enabled: Boolean(selectedAgeGate),
|
||||
pendingCount: pendingItems.length,
|
||||
})
|
||||
const ageGateOpen = isOrderServiceAgeGateOpen({
|
||||
@@ -123,6 +128,11 @@ export default function OrderServicePage() {
|
||||
|
||||
useOrderServicePageMeta(ageGateOpen ? '购买前确认' : info?.items[0]?.title || '订单服务')
|
||||
|
||||
useEffect(() => {
|
||||
infoRef.current = info
|
||||
}, [info])
|
||||
|
||||
/* eslint-disable react-hooks/preserve-manual-memoization */
|
||||
const load = useCallback(
|
||||
async (options: { silent?: boolean } = {}) => {
|
||||
const seq = requestSeqRef.current + 1
|
||||
@@ -145,7 +155,7 @@ export default function OrderServicePage() {
|
||||
setLoadError(null)
|
||||
} catch (error) {
|
||||
if (seq !== requestSeqRef.current) return
|
||||
if (options.silent && info) return
|
||||
if (options.silent && infoRef.current) return
|
||||
setInfo(null)
|
||||
setLoadError({
|
||||
code: resolveErrorCode(error),
|
||||
@@ -155,7 +165,7 @@ export default function OrderServicePage() {
|
||||
if (seq === requestSeqRef.current && !options.silent) setLoading(false)
|
||||
}
|
||||
},
|
||||
[info, orderNo, setInfo, setLoading, setLoadError, setSubmittedNames, setLastSuccessText],
|
||||
[orderNo],
|
||||
)
|
||||
|
||||
useEffect(() => {
|
||||
@@ -320,11 +330,11 @@ export default function OrderServicePage() {
|
||||
|
||||
return (
|
||||
<main className="collect-link-page">
|
||||
{info?.ageGate ? (
|
||||
{selectedAgeGate ? (
|
||||
<OrderServiceAgeGateModal
|
||||
open={ageGateOpen}
|
||||
minorSelected={ageGateDecision === 'minor'}
|
||||
config={info.ageGate}
|
||||
config={selectedAgeGate}
|
||||
onAdult={() => setAgeGateState({ orderNo, decision: 'adult' })}
|
||||
onMinor={() => setAgeGateState({ orderNo, decision: 'minor' })}
|
||||
/>
|
||||
@@ -419,6 +429,21 @@ export default function OrderServicePage() {
|
||||
<Text type="secondary" className="collect-link-footnote">
|
||||
{pageConfig?.postSubmitText || '资料提交后如需修改,请联系客服。'}
|
||||
</Text>
|
||||
{bottomGuideImages.length > 0 ? (
|
||||
<Image.PreviewGroup>
|
||||
<div className="collect-link-bottom-guides">
|
||||
{bottomGuideImages.map((guide) => (
|
||||
<Image
|
||||
key={guide.image.objectKey || guide.image.url}
|
||||
alt="资料填写引导图"
|
||||
className="collect-link-bottom-guide-image"
|
||||
preview={{ mask: '查看大图' }}
|
||||
src={guide.image.url}
|
||||
/>
|
||||
))}
|
||||
</div>
|
||||
</Image.PreviewGroup>
|
||||
) : null}
|
||||
</Space>
|
||||
) : null}
|
||||
</Card>
|
||||
|
||||
@@ -34,6 +34,7 @@ import type {
|
||||
WorkerProductMatchConfig,
|
||||
WorkerAnnouncementConfig,
|
||||
OrderServiceAgeGateConfig,
|
||||
OrderServiceBottomGuideImageConfig,
|
||||
WorkerSupportContactConfig,
|
||||
WorkerProductNameSuffixConfig,
|
||||
WorkerLevel,
|
||||
@@ -138,17 +139,6 @@ export function saveAdminWorkerAnnouncement(payload: WorkerAnnouncementConfig) {
|
||||
return apiPost<WorkerAnnouncementConfig>('/api/v1/admin/worker-platform/announcement', payload)
|
||||
}
|
||||
|
||||
export function fetchAdminOrderServiceAgeGateConfig() {
|
||||
return apiGet<OrderServiceAgeGateConfig>('/api/v1/admin/worker-platform/order-service-age-gate')
|
||||
}
|
||||
|
||||
export function saveAdminOrderServiceAgeGateConfig(payload: OrderServiceAgeGateConfig) {
|
||||
return apiPost<OrderServiceAgeGateConfig>(
|
||||
'/api/v1/admin/worker-platform/order-service-age-gate',
|
||||
payload,
|
||||
)
|
||||
}
|
||||
|
||||
export function fetchAdminWorkerSupportContact() {
|
||||
return apiGet<WorkerSupportContactConfig>('/api/v1/admin/worker-platform/support-contact')
|
||||
}
|
||||
@@ -1281,6 +1271,11 @@ export type AdminOrderServiceProfile = {
|
||||
description: string
|
||||
guideImage: UploadedFile | Record<string, unknown>
|
||||
guideImageDescription: string
|
||||
ageGate: OrderServiceAgeGateConfig
|
||||
bottomGuideImage: {
|
||||
enabled: boolean
|
||||
image: UploadedFile | Record<string, unknown> | null
|
||||
}
|
||||
fields: OrderServiceField[]
|
||||
screenshots: {
|
||||
enabled: boolean
|
||||
@@ -1331,6 +1326,11 @@ export function saveAdminOrderServiceProfile(payload: {
|
||||
description?: string
|
||||
guideImage?: UploadedFile | Record<string, unknown>
|
||||
guideImageDescription?: string
|
||||
ageGate: OrderServiceAgeGateConfig
|
||||
bottomGuideImage: {
|
||||
enabled: boolean
|
||||
image: UploadedFile | Record<string, unknown> | null
|
||||
}
|
||||
fields: OrderServiceField[]
|
||||
screenshots: {
|
||||
enabled: boolean
|
||||
|
||||
@@ -10,6 +10,7 @@ import type {
|
||||
WorkerCancelRequestRisk,
|
||||
WorkerAnnouncementConfig,
|
||||
OrderServiceAgeGateConfig,
|
||||
OrderServiceBottomGuideImageConfig,
|
||||
WorkerSupportContactConfig,
|
||||
WorkerProductNameSuffixConfig,
|
||||
WorkerProductNameSuffixDisplayConfig,
|
||||
@@ -707,13 +708,14 @@ export type OrderServiceItem = {
|
||||
submittedAt?: string
|
||||
acceptanceSubmittedAt?: string
|
||||
acceptedAt?: string
|
||||
ageGate?: OrderServiceAgeGateConfig
|
||||
bottomGuideImage?: OrderServiceBottomGuideImageConfig
|
||||
}
|
||||
|
||||
export type OrderServiceInfo = {
|
||||
platformOrderId: string
|
||||
items: OrderServiceItem[]
|
||||
pendingCount: number
|
||||
ageGate?: OrderServiceAgeGateConfig
|
||||
}
|
||||
|
||||
export type OrderServiceSubmitResult = {
|
||||
|
||||
@@ -1002,3 +1002,26 @@
|
||||
font-size: 15px;
|
||||
}
|
||||
}
|
||||
|
||||
/* ===== 工单补资料页底部引导图 ===== */
|
||||
|
||||
.collect-link-bottom-guides {
|
||||
display: grid;
|
||||
gap: 12px;
|
||||
width: 100%;
|
||||
margin-top: 4px;
|
||||
}
|
||||
|
||||
.collect-link-bottom-guides .ant-image {
|
||||
display: block;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.collect-link-bottom-guides .ant-image-img {
|
||||
display: block;
|
||||
width: 100%;
|
||||
height: auto;
|
||||
border: 1px solid #e7edf5;
|
||||
border-radius: 10px;
|
||||
background: #ffffff;
|
||||
}
|
||||
|
||||
@@ -349,7 +349,7 @@ export type WorkerAnnouncementConfig = {
|
||||
content: string
|
||||
}
|
||||
|
||||
/** 工单补资料页未成年提示:全局配置,默认关闭。 */
|
||||
/** 订单服务分类级未成年提示配置。 */
|
||||
export type OrderServiceAgeGateConfig = {
|
||||
enabled: boolean
|
||||
title: string
|
||||
@@ -362,6 +362,11 @@ export type OrderServiceAgeGateConfig = {
|
||||
minorBlockedContent: string
|
||||
}
|
||||
|
||||
export type OrderServiceBottomGuideImageConfig = {
|
||||
enabled: boolean
|
||||
image: UploadedFile | null
|
||||
}
|
||||
|
||||
export type WorkerSupportContactConfig = {
|
||||
enabled: boolean
|
||||
wechatId: string
|
||||
|
||||
@@ -68,11 +68,7 @@ export const WORKER_PLATFORM_TAB_QUERY_KEYS: Record<string, string[][]> = {
|
||||
finance: [['admin-finance-settlements'], ['admin-finance-withdrawals']],
|
||||
levels: [['admin-worker-levels']],
|
||||
notifications: [['admin-notifications']],
|
||||
announcement: [
|
||||
['admin-announcements'],
|
||||
['admin-worker-support-contact'],
|
||||
['admin-order-service-age-gate'],
|
||||
],
|
||||
announcement: [['admin-announcements'], ['admin-worker-support-contact']],
|
||||
'hall-config': [['admin-hall-config']],
|
||||
'risk-control': [['admin-worker-risk-overview'], ['admin-worker-risk-events']],
|
||||
}
|
||||
|
||||
@@ -1,4 +1,8 @@
|
||||
import type { OrderServiceAgeGateConfig } from '@/types/worker-platform'
|
||||
import type {
|
||||
OrderServiceAgeGateConfig,
|
||||
OrderServiceBottomGuideImageConfig,
|
||||
UploadedFile,
|
||||
} from '@/types/worker-platform'
|
||||
|
||||
export type OrderServiceAgeGateDecision = 'pending' | 'adult' | 'minor'
|
||||
|
||||
@@ -127,3 +131,25 @@ export function mergeOrderServiceAgeGateConfig(
|
||||
),
|
||||
}
|
||||
}
|
||||
|
||||
export function selectFirstOrderServiceAgeGate(
|
||||
items: Array<{ ageGate?: OrderServiceAgeGateConfig }>,
|
||||
): OrderServiceAgeGateConfig | null {
|
||||
return items.find((item) => item.ageGate)?.ageGate || null
|
||||
}
|
||||
|
||||
export function dedupeOrderServiceBottomGuideImages(
|
||||
items: Array<{ bottomGuideImage?: OrderServiceBottomGuideImageConfig }>,
|
||||
): Array<OrderServiceBottomGuideImageConfig & { image: UploadedFile }> {
|
||||
const result: Array<OrderServiceBottomGuideImageConfig & { image: UploadedFile }> = []
|
||||
const seen = new Set<string>()
|
||||
for (const item of items) {
|
||||
const config = item.bottomGuideImage
|
||||
if (!config?.enabled || !config.image) continue
|
||||
const identity = String(config.image.objectKey || config.image.url || '').trim()
|
||||
if (!identity || seen.has(identity)) continue
|
||||
seen.add(identity)
|
||||
result.push({ ...config, image: config.image })
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
@@ -3,10 +3,12 @@ import test from 'node:test'
|
||||
|
||||
import {
|
||||
DEFAULT_ORDER_SERVICE_AGE_GATE_CONFIG,
|
||||
dedupeOrderServiceBottomGuideImages,
|
||||
canAccessOrderServiceMaterial,
|
||||
isOrderServiceAgeGateOpen,
|
||||
mergeOrderServiceAgeGateConfig,
|
||||
parseOrderServiceAgeGateContent,
|
||||
selectFirstOrderServiceAgeGate,
|
||||
resolveOrderServiceAgeGateDecision,
|
||||
shouldRequireOrderServiceAgeGate,
|
||||
} from '../src/utils/order-service-age-gate.ts'
|
||||
@@ -79,3 +81,37 @@ test('弹窗打开时整页内容必须隐藏,已成年后才恢复', () => {
|
||||
assert.equal(isOrderServiceAgeGateOpen({ required: true, decision: 'adult' }), false)
|
||||
assert.equal(isOrderServiceAgeGateOpen({ required: false, decision: 'pending' }), false)
|
||||
})
|
||||
|
||||
test('多商品只选第一个未成年提示配置,底部引导图按图片去重', () => {
|
||||
const gateA = {
|
||||
enabled: true,
|
||||
title: 'A',
|
||||
warningText: 'A',
|
||||
content: 'A',
|
||||
importantNotice: 'A',
|
||||
adultButtonText: '我已成年',
|
||||
minorButtonText: '我是未成年',
|
||||
minorBlockedTitle: '不能购买',
|
||||
minorBlockedContent: '停止',
|
||||
}
|
||||
const gateB = { ...gateA, title: 'B' }
|
||||
const image = {
|
||||
objectKey: 'order-service-guide/a.png',
|
||||
url: '/a.png',
|
||||
thumbnailUrl: '/a.png',
|
||||
mediumUrl: '/a.png',
|
||||
filename: 'a.png',
|
||||
contentType: 'image/png',
|
||||
size: 1,
|
||||
}
|
||||
|
||||
assert.equal(selectFirstOrderServiceAgeGate([{ ageGate: gateA }, { ageGate: gateB }])?.title, 'A')
|
||||
assert.equal(
|
||||
dedupeOrderServiceBottomGuideImages([
|
||||
{ bottomGuideImage: { enabled: true, image } },
|
||||
{ bottomGuideImage: { enabled: true, image } },
|
||||
{ bottomGuideImage: { enabled: false, image } },
|
||||
]).length,
|
||||
1,
|
||||
)
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user