This commit is contained in:
2026-11-25 10:54:46 +08:00
9 changed files with 529 additions and 5 deletions
Binary file not shown.

After

Width:  |  Height:  |  Size: 304 KiB

@@ -10,13 +10,16 @@ import QRCode from 'qrcode'
import { useCallback, useEffect, useMemo, useRef, useState, type ReactNode } from 'react'
import { useParams } from 'react-router'
import ImageUpload from '@/components/files/ImageUpload'
import {
confirmDouyuBinding,
fetchDouyuFulfillment,
refreshDouyuBinding,
saveDouyuProfile,
startDouyuBinding,
uploadDouyuHomepageScreenshot,
} from '@/services/douyu-fulfillment'
import type { UploadedFile } from '@/types/worker-platform'
import type {
DouyuCustomerFulfillment,
DouyuCustomerPlatform,
@@ -77,6 +80,7 @@ export default function DouyuFulfillmentPage() {
const [roleName, setRoleName] = useState('')
const [platform, setPlatform] = useState<DouyuCustomerPlatform>('wechat')
const [system, setSystem] = useState<DouyuCustomerSystem>('android')
const [homepageScreenshot, setHomepageScreenshot] = useState<UploadedFile[]>([])
const [qrImage, setQrImage] = useState('')
const [bindingQrExpanded, setBindingQrExpanded] = useState(false)
const [nowMs, setNowMs] = useState(() => Date.now())
@@ -151,7 +155,14 @@ export default function DouyuFulfillmentPage() {
const task = data?.task
const live = data?.live
const needsProfile = Boolean(task && !task.customer_role_name)
const hasCustomerProfile = Boolean(
task?.customer_role_name?.trim() &&
['wechat', 'qq'].includes(task.customer_platform) &&
['ios', 'android'].includes(task.customer_system) &&
task.customer_homepage_screenshot_object_key?.trim() &&
task.customer_homepage_screenshot_url?.trim(),
)
const needsProfile = Boolean(task && !hasCustomerProfile)
const bindingFailed = Boolean(live && BINDING_FAILURE_ISSUES.has(live.issueCode))
const bindingFailureRetryable = Boolean(live?.issueCode === 'binding_failed' && live.accountReady)
@@ -239,12 +250,18 @@ export default function DouyuFulfillmentPage() {
message.warning(roleNameIssue)
return
}
const screenshot = homepageScreenshot[0]
if (!screenshot?.objectKey) {
message.warning('请上传游戏主页截图')
return
}
setSaving(true)
try {
const response = await saveDouyuProfile(orderNo, {
roleName: roleName.trim(),
platform,
system,
homepageScreenshotObjectKey: screenshot.objectKey,
})
applyData(response.data)
message.success('资料已提交,正在准备绑定二维码')
@@ -408,6 +425,37 @@ export default function DouyuFulfillmentPage() {
{roleNameIssue ? <ExclamationCircleOutlined aria-hidden="true" /> : null}
<span>{roleNameIssue || DOUYU_ROLE_NAME_FORMAT_HINT}</span>
</p>
<label className="customer-collect-label">游戏主页截图(必填)</label>
<div className="customer-douyu-screenshot-row">
<div className="customer-douyu-screenshot-upload">
<ImageUpload
scene="douyu-homepage-screenshot"
scope="collect"
maxCount={1}
showPasteHint
value={homepageScreenshot}
onChange={setHomepageScreenshot}
uploader={async (file) => {
const response = await uploadDouyuHomepageScreenshot(orderNo, file)
return response.data.file
}}
/>
</div>
<div className="customer-douyu-screenshot-example">
<Image
src="/images/game-home-example.webp"
alt="游戏主页截图示例"
width={150}
height={140}
style={{ objectFit: 'cover', borderRadius: 8, border: '1px solid #334155' }}
/>
<span>示例:需能看到游戏名字和游戏 UID</span>
</div>
</div>
<p className="customer-douyu-role-name-help">
请上传游戏主页截图,需能看到游戏名字/昵称和游戏
UID(编号);用于客服核对绑定是否正确。
</p>
<div className="customer-douyu-submit-bar">
<Button
block
@@ -1,4 +1,6 @@
import { apiGet, apiPost } from '@/lib/http'
import { apiGet, apiPost, apiPostForm } from '@/lib/http'
import { optimizeImageForUpload } from '@/utils/image-upload'
import type { UploadedFile } from '@/types/worker-platform'
import type {
DouyuCustomerFulfillment,
DouyuCustomerPlatform,
@@ -17,6 +19,7 @@ export function saveDouyuProfile(
roleName: string
platform: DouyuCustomerPlatform
system: DouyuCustomerSystem
homepageScreenshotObjectKey: string
},
) {
return apiPost<DouyuCustomerFulfillment>(
@@ -51,3 +54,13 @@ export function confirmDouyuBinding(orderNo: string) {
{},
)
}
export async function uploadDouyuHomepageScreenshot(orderNo: string, file: File) {
const optimized = await optimizeImageForUpload(file, 'douyu-homepage-screenshot')
const form = new FormData()
form.append('file', optimized)
return apiPostForm<{ file: UploadedFile }>(
`/api/v1/douyu-fulfillment/${encodeURIComponent(orderNo)}/homepage-screenshot`,
form,
)
}
@@ -645,3 +645,58 @@
-webkit-overflow-scrolling: touch;
}
}
.customer-douyu-screenshot-row {
display: flex;
align-items: flex-start;
gap: 14px;
min-width: 0;
}
.customer-douyu-screenshot-upload {
flex: 0 0 150px;
min-width: 0;
}
.customer-douyu-screenshot-upload .ant-upload-select,
.customer-douyu-screenshot-upload .ant-upload-list-item-container {
width: 150px !important;
height: 140px !important;
}
.customer-douyu-screenshot-example img {
width: 100% !important;
height: 100% !important;
object-fit: cover;
}
.customer-douyu-screenshot-example {
display: flex;
flex-direction: column;
gap: 6px;
min-width: 0;
color: #94a3b8;
font-size: 12px;
line-height: 1.45;
}
@media (max-width: 480px) {
.customer-douyu-screenshot-row {
gap: 10px;
}
.customer-douyu-screenshot-upload {
flex-basis: 126px;
}
.customer-douyu-screenshot-upload .ant-upload-select,
.customer-douyu-screenshot-upload .ant-upload-list-item-container {
width: 126px !important;
height: 118px !important;
}
.customer-douyu-screenshot-example .ant-image {
width: 126px !important;
height: 118px !important;
}
}
@@ -11,6 +11,11 @@ export type DouyuFulfillmentTask = {
customer_role_name: string
customer_platform: string
customer_system: string
customer_homepage_screenshot_object_key: string
customer_homepage_screenshot_url: string
customer_homepage_screenshot_thumbnail_url: string
customer_homepage_screenshot_filename: string
customer_homepage_screenshot_uploaded_at: string | null
binding_phase: string
live_execution_status: string
live_binding_status: string