feat(semi-auto): 换绑失败页支持返回角色核对界面
This commit is contained in:
@@ -75,6 +75,7 @@ export default function CustomerFulfillmentPage() {
|
|||||||
const [profileServerZone, setProfileServerZone] = useState('')
|
const [profileServerZone, setProfileServerZone] = useState('')
|
||||||
const [profileSaving, setProfileSaving] = useState(false)
|
const [profileSaving, setProfileSaving] = useState(false)
|
||||||
const [profileEditing, setProfileEditing] = useState(false)
|
const [profileEditing, setProfileEditing] = useState(false)
|
||||||
|
const [rebindFailureDismissed, setRebindFailureDismissed] = useState(false)
|
||||||
const startingBindingRef = useRef(false)
|
const startingBindingRef = useRef(false)
|
||||||
const hydratingBindingRef = useRef(false)
|
const hydratingBindingRef = useRef(false)
|
||||||
const autoOpenedRoleRef = useRef('')
|
const autoOpenedRoleRef = useRef('')
|
||||||
@@ -136,6 +137,7 @@ export default function CustomerFulfillmentPage() {
|
|||||||
autoOpenedRoleRef.current = ''
|
autoOpenedRoleRef.current = ''
|
||||||
setBindingSessionExpired(false)
|
setBindingSessionExpired(false)
|
||||||
setBindingLoadError('')
|
setBindingLoadError('')
|
||||||
|
setRebindFailureDismissed(false)
|
||||||
}, [selectedTask?.id])
|
}, [selectedTask?.id])
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@@ -709,11 +711,11 @@ export default function CustomerFulfillmentPage() {
|
|||||||
if (!selectedTask || bindingLoading) return
|
if (!selectedTask || bindingLoading) return
|
||||||
const reason = String(bindingInfo?.rebindConfirmMessage || '').trim()
|
const reason = String(bindingInfo?.rebindConfirmMessage || '').trim()
|
||||||
modal.confirm({
|
modal.confirm({
|
||||||
title: '仍使用原绑定角色?',
|
title: '确认使用原角色?',
|
||||||
content: `本次换绑未成功${reason ? `(${reason})` : ''},平台仍返回原绑定角色「${
|
content: `本次换绑未成功${reason ? `(${reason})` : ''},平台仍返回原绑定角色「${
|
||||||
bindingRoleName || '当前角色'
|
bindingRoleName || '当前角色'
|
||||||
}」。确认后本次换绑作废,直接使用该角色继续履约。`,
|
}」。确认后本次换绑作废,直接使用该角色继续履约。`,
|
||||||
okText: '仍使用原角色',
|
okText: '确认使用原角色',
|
||||||
cancelText: '先不确认',
|
cancelText: '先不确认',
|
||||||
onOk: () => handleConfirmBinding(true),
|
onOk: () => handleConfirmBinding(true),
|
||||||
})
|
})
|
||||||
@@ -808,6 +810,8 @@ export default function CustomerFulfillmentPage() {
|
|||||||
})()
|
})()
|
||||||
const bindingRoleName = bindingInfo?.bindGameRole || selectedTask?.bindGameRole || ''
|
const bindingRoleName = bindingInfo?.bindGameRole || selectedTask?.bindGameRole || ''
|
||||||
const rebindUnchanged = bindingInfo?.rebindUnchanged === true
|
const rebindUnchanged = bindingInfo?.rebindUnchanged === true
|
||||||
|
// 换绑失败视图可返回「已识别角色 + 资料不一致」的核对界面;后端 rebindUnchanged 保持不变。
|
||||||
|
const showRebindFailure = rebindUnchanged && !rebindFailureDismissed
|
||||||
const rebindConfirmState = bindingInfo?.rebindConfirmState || 'idle'
|
const rebindConfirmState = bindingInfo?.rebindConfirmState || 'idle'
|
||||||
const rebindRejected = rebindConfirmState === 'rejected'
|
const rebindRejected = rebindConfirmState === 'rejected'
|
||||||
const rebindAccepted = rebindConfirmState === 'accepted'
|
const rebindAccepted = rebindConfirmState === 'accepted'
|
||||||
@@ -829,7 +833,7 @@ export default function CustomerFulfillmentPage() {
|
|||||||
text: '已登录,但平台未返回可核对的角色ID,请联系客服人工核实',
|
text: '已登录,但平台未返回可核对的角色ID,请联系客服人工核实',
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (rebindUnchanged) {
|
if (showRebindFailure) {
|
||||||
return {
|
return {
|
||||||
tone: 'is-warning',
|
tone: 'is-warning',
|
||||||
text: rebindRejected ? '虎牙未接受本次换绑,请查看下方原因' : '换绑未生效,请查看下方原因',
|
text: rebindRejected ? '虎牙未接受本次换绑,请查看下方原因' : '换绑未生效,请查看下方原因',
|
||||||
@@ -857,9 +861,7 @@ export default function CustomerFulfillmentPage() {
|
|||||||
? formatAdminDateTime(bindingInfo.nextRebindAt)
|
? formatAdminDateTime(bindingInfo.nextRebindAt)
|
||||||
: ''
|
: ''
|
||||||
const comparisonMismatch =
|
const comparisonMismatch =
|
||||||
selectedTask?.bindingStatus === 'role_ready' &&
|
selectedTask?.bindingStatus === 'role_ready' && bindingComparison?.verdict === 'mismatch'
|
||||||
!rebindUnchanged &&
|
|
||||||
bindingComparison?.verdict === 'mismatch'
|
|
||||||
const showProfileForm = showBindingStage && profileEditing
|
const showProfileForm = showBindingStage && profileEditing
|
||||||
const bindingCustomerReady = Boolean(
|
const bindingCustomerReady = Boolean(
|
||||||
bindingComparison?.customerRoleId || bindingComparison?.customerRoleName,
|
bindingComparison?.customerRoleId || bindingComparison?.customerRoleName,
|
||||||
@@ -1107,7 +1109,7 @@ export default function CustomerFulfillmentPage() {
|
|||||||
) : null}
|
) : null}
|
||||||
|
|
||||||
{showBindingStage ? (
|
{showBindingStage ? (
|
||||||
<section className="customer-binding-stage">
|
<section id="customer-binding-stage" className="customer-binding-stage">
|
||||||
<div className="customer-binding-info">
|
<div className="customer-binding-info">
|
||||||
<h3>
|
<h3>
|
||||||
绑定信息 <small>(已登录虎牙账号)</small>
|
绑定信息 <small>(已登录虎牙账号)</small>
|
||||||
@@ -1329,7 +1331,7 @@ export default function CustomerFulfillmentPage() {
|
|||||||
orderNo || selectedTask?.orderNo || ''
|
orderNo || selectedTask?.orderNo || ''
|
||||||
} 联系客服,核实完成前请不要确认绑定。`}
|
} 联系客服,核实完成前请不要确认绑定。`}
|
||||||
/>
|
/>
|
||||||
) : rebindUnchanged ? (
|
) : showRebindFailure ? (
|
||||||
<Alert
|
<Alert
|
||||||
type={rebindRejected ? 'error' : 'warning'}
|
type={rebindRejected ? 'error' : 'warning'}
|
||||||
showIcon
|
showIcon
|
||||||
@@ -1365,7 +1367,10 @@ export default function CustomerFulfillmentPage() {
|
|||||||
.join(' · ')}
|
.join(' · ')}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
{!bindingRequiresSupport && comparisonMismatch && bindingComparison ? (
|
{!bindingRequiresSupport &&
|
||||||
|
!showRebindFailure &&
|
||||||
|
comparisonMismatch &&
|
||||||
|
bindingComparison ? (
|
||||||
<Alert
|
<Alert
|
||||||
type="warning"
|
type="warning"
|
||||||
showIcon
|
showIcon
|
||||||
@@ -1411,7 +1416,7 @@ export default function CustomerFulfillmentPage() {
|
|||||||
刷新状态
|
刷新状态
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
) : rebindUnchanged ? (
|
) : showRebindFailure ? (
|
||||||
<div className="customer-binding-role-actions">
|
<div className="customer-binding-role-actions">
|
||||||
<Button
|
<Button
|
||||||
block
|
block
|
||||||
@@ -1436,10 +1441,16 @@ export default function CustomerFulfillmentPage() {
|
|||||||
block
|
block
|
||||||
size="large"
|
size="large"
|
||||||
className="customer-binding-accept"
|
className="customer-binding-accept"
|
||||||
loading={bindingLoading}
|
onClick={() => {
|
||||||
onClick={() => handleAcceptExistingRole()}
|
setRebindFailureDismissed(true)
|
||||||
|
window.setTimeout(() => {
|
||||||
|
document
|
||||||
|
.getElementById('customer-binding-stage')
|
||||||
|
?.scrollIntoView({ behavior: 'smooth', block: 'start' })
|
||||||
|
}, 0)
|
||||||
|
}}
|
||||||
>
|
>
|
||||||
仍使用原角色
|
返回上一步
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
) : comparisonMismatch ? (
|
) : comparisonMismatch ? (
|
||||||
@@ -1464,6 +1475,28 @@ export default function CustomerFulfillmentPage() {
|
|||||||
角色不对,重新扫码换绑
|
角色不对,重新扫码换绑
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
|
) : rebindUnchanged ? (
|
||||||
|
<div className="customer-binding-role-actions">
|
||||||
|
<Button
|
||||||
|
block
|
||||||
|
size="large"
|
||||||
|
className="customer-binding-confirm"
|
||||||
|
loading={bindingLoading}
|
||||||
|
onClick={() => handleAcceptExistingRole()}
|
||||||
|
>
|
||||||
|
确认使用原角色
|
||||||
|
</Button>
|
||||||
|
<Button
|
||||||
|
block
|
||||||
|
size="large"
|
||||||
|
className="customer-binding-rebind"
|
||||||
|
icon={<ExclamationCircleOutlined />}
|
||||||
|
loading={bindingLoading}
|
||||||
|
onClick={() => void handleRefreshBinding(true)}
|
||||||
|
>
|
||||||
|
角色不对,重新扫码换绑
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
) : (
|
) : (
|
||||||
<div className="customer-binding-role-actions">
|
<div className="customer-binding-role-actions">
|
||||||
<Button
|
<Button
|
||||||
|
|||||||
@@ -0,0 +1,31 @@
|
|||||||
|
import assert from 'node:assert/strict'
|
||||||
|
import { readFileSync } from 'node:fs'
|
||||||
|
import { dirname, join } from 'node:path'
|
||||||
|
import { fileURLToPath } from 'node:url'
|
||||||
|
import test from 'node:test'
|
||||||
|
|
||||||
|
const source = readFileSync(
|
||||||
|
join(
|
||||||
|
dirname(fileURLToPath(import.meta.url)),
|
||||||
|
'../src/pages/customer-fulfillment/CustomerFulfillmentPage.tsx',
|
||||||
|
),
|
||||||
|
'utf8',
|
||||||
|
)
|
||||||
|
|
||||||
|
test('换绑失败页用「返回上一步」替换「仍使用原角色」', () => {
|
||||||
|
assert.ok(source.includes('rebindFailureDismissed'))
|
||||||
|
assert.ok(source.includes('返回上一步'))
|
||||||
|
assert.ok(!source.includes('仍使用原角色'))
|
||||||
|
})
|
||||||
|
|
||||||
|
test('返回后展示资料不一致核对界面', () => {
|
||||||
|
assert.ok(source.includes('showRebindFailure'))
|
||||||
|
assert.ok(source.includes('!showRebindFailure &&'))
|
||||||
|
assert.ok(source.includes('同步平台角色并继续'))
|
||||||
|
assert.ok(source.includes('id="customer-binding-stage"'))
|
||||||
|
})
|
||||||
|
|
||||||
|
test('资料同步后提供确认使用原角色', () => {
|
||||||
|
assert.ok(source.includes('确认使用原角色'))
|
||||||
|
assert.ok(source.includes('handleAcceptExistingRole'))
|
||||||
|
})
|
||||||
Reference in New Issue
Block a user