feat(semi-auto): 首次绑定自动提交并由客户本地确认,统一客户页控件尺寸
1) 首次绑定(isBindAccount/isBindRole 任一为 0)扫码完成后自动调 confirmBindActAccount,新增 bindConfirmState/bindConfirmMessage,失败透出虎牙原文并提示重新扫码。 2) 确认绑定改为纯本地流转:不再调用 confirmBindActAccount,也不再重复查角色;换绑被虎牙拒绝时需 acceptExistingRole 二次确认「仍使用原角色」。新增 bindingSnapshot 只读快照。 3) 客户页资料收集去掉顶部大图,只保留温馨提示;输入框/选择器 48px、主按钮 52px、次级按钮 48px,登录/绑定/资料页统一。 4) 修正已确认/已过期/绑定失败状态仍显示「登录成功,请继续扫码绑定游戏角色」的横幅错误,改为按 bindingStatus 显式映射,确认后只保留「等待客服核实」卡片。
This commit is contained in:
@@ -120,11 +120,17 @@ router.post(
|
|||||||
router.post(
|
router.post(
|
||||||
'/:orderNo/tasks/:taskId/binding/confirm',
|
'/:orderNo/tasks/:taskId/binding/confirm',
|
||||||
writeLimit,
|
writeLimit,
|
||||||
createRouteHandler((req) => confirmPublicBinding(req.params.orderNo, req.params.taskId), {
|
createRouteHandler(
|
||||||
successMessage: '绑定已确认',
|
(req) =>
|
||||||
errorMessage: '确认账号绑定失败',
|
confirmPublicBinding(req.params.orderNo, req.params.taskId, {
|
||||||
scope: '[customer-fulfillment/:orderNo/tasks/:taskId/binding/confirm]',
|
acceptExistingRole: req.body?.acceptExistingRole === true,
|
||||||
}),
|
}),
|
||||||
|
{
|
||||||
|
successMessage: '绑定已确认',
|
||||||
|
errorMessage: '确认账号绑定失败',
|
||||||
|
scope: '[customer-fulfillment/:orderNo/tasks/:taskId/binding/confirm]',
|
||||||
|
},
|
||||||
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
router.get(
|
router.get(
|
||||||
|
|||||||
@@ -105,6 +105,8 @@ export type ConnectorBindingSession = {
|
|||||||
rebindUnchanged?: boolean
|
rebindUnchanged?: boolean
|
||||||
rebindConfirmState?: 'idle' | 'submitting' | 'accepted' | 'rejected'
|
rebindConfirmState?: 'idle' | 'submitting' | 'accepted' | 'rejected'
|
||||||
rebindConfirmMessage?: string
|
rebindConfirmMessage?: string
|
||||||
|
bindConfirmState?: 'idle' | 'submitting' | 'accepted' | 'rejected'
|
||||||
|
bindConfirmMessage?: string
|
||||||
rebindCooldownDays?: number
|
rebindCooldownDays?: number
|
||||||
nextRebindAt?: string
|
nextRebindAt?: string
|
||||||
platformChangeBindDay?: number
|
platformChangeBindDay?: number
|
||||||
@@ -419,14 +421,34 @@ export async function getHuyaBinding(
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function confirmHuyaBinding(
|
/**
|
||||||
|
* 只读绑定快照:不触发虎牙查询,供「确认绑定」这类本地动作使用。
|
||||||
|
* 外部 Connector 没有独立快照端点,只能复用 GET(由 Connector 侧决定是否访问虎牙)。
|
||||||
|
*/
|
||||||
|
export async function getHuyaBindingSnapshot(
|
||||||
sessionId: string,
|
sessionId: string,
|
||||||
mode: SemiAutoConnectorMode = defaultSemiAutoConnectorMode(),
|
mode: SemiAutoConnectorMode = defaultSemiAutoConnectorMode(),
|
||||||
): Promise<ConnectorBindingSession> {
|
): Promise<ConnectorBindingSession> {
|
||||||
if (mode === 'embedded') return huyaNativeConnector.confirmBinding(sessionId)
|
if (mode === 'embedded') return huyaNativeConnector.bindingSnapshot(sessionId)
|
||||||
|
return callConnector<ConnectorBindingSession>(
|
||||||
|
`/api/internal/huya-semi-auto/sessions/${encodeURIComponent(sessionId)}/binding`,
|
||||||
|
{},
|
||||||
|
mode,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function confirmHuyaBinding(
|
||||||
|
sessionId: string,
|
||||||
|
mode: SemiAutoConnectorMode = defaultSemiAutoConnectorMode(),
|
||||||
|
options: { acceptExistingRole?: boolean } = {},
|
||||||
|
): Promise<ConnectorBindingSession> {
|
||||||
|
if (mode === 'embedded') return huyaNativeConnector.confirmBinding(sessionId, options)
|
||||||
return callConnector<ConnectorBindingSession>(
|
return callConnector<ConnectorBindingSession>(
|
||||||
`/api/internal/huya-semi-auto/sessions/${encodeURIComponent(sessionId)}/binding/confirm`,
|
`/api/internal/huya-semi-auto/sessions/${encodeURIComponent(sessionId)}/binding/confirm`,
|
||||||
{ method: 'POST', body: {} },
|
{
|
||||||
|
method: 'POST',
|
||||||
|
body: options.acceptExistingRole ? { acceptExistingRole: true } : {},
|
||||||
|
},
|
||||||
mode,
|
mode,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,96 @@
|
|||||||
|
import assert from 'node:assert/strict'
|
||||||
|
import test from 'node:test'
|
||||||
|
|
||||||
|
import { resolveBindingConfirmDecision, shouldSubmitFirstBind } from './huya-native-connector.js'
|
||||||
|
|
||||||
|
test('确认绑定:识别到角色即可本地确认,不需要虎牙接口', () => {
|
||||||
|
assert.equal(
|
||||||
|
resolveBindingConfirmDecision({ status: 'role_ready', role: '大鲨鱼伊塞53' }),
|
||||||
|
'confirm',
|
||||||
|
)
|
||||||
|
})
|
||||||
|
|
||||||
|
test('确认绑定:换绑被虎牙拒绝时必须由客户二选一', () => {
|
||||||
|
assert.equal(
|
||||||
|
resolveBindingConfirmDecision({
|
||||||
|
status: 'role_ready',
|
||||||
|
role: '大鲨鱼伊塞53',
|
||||||
|
rebindRequested: true,
|
||||||
|
rebindUnchanged: true,
|
||||||
|
}),
|
||||||
|
'needs_rebind_decision',
|
||||||
|
)
|
||||||
|
})
|
||||||
|
|
||||||
|
test('确认绑定:客户确认仍使用原角色后放行', () => {
|
||||||
|
assert.equal(
|
||||||
|
resolveBindingConfirmDecision(
|
||||||
|
{
|
||||||
|
status: 'role_ready',
|
||||||
|
role: '大鲨鱼伊塞53',
|
||||||
|
rebindRequested: true,
|
||||||
|
rebindUnchanged: true,
|
||||||
|
},
|
||||||
|
{ acceptExistingRole: true },
|
||||||
|
),
|
||||||
|
'confirm',
|
||||||
|
)
|
||||||
|
})
|
||||||
|
|
||||||
|
test('确认绑定:换绑还在进行中(未判定失败)不拦截确认', () => {
|
||||||
|
assert.equal(
|
||||||
|
resolveBindingConfirmDecision({
|
||||||
|
status: 'role_ready',
|
||||||
|
role: '大鲨鱼伊塞53',
|
||||||
|
rebindRequested: true,
|
||||||
|
}),
|
||||||
|
'confirm',
|
||||||
|
)
|
||||||
|
})
|
||||||
|
|
||||||
|
test('确认绑定:没有角色或状态不对时不能确认', () => {
|
||||||
|
assert.equal(resolveBindingConfirmDecision({ status: 'role_ready', role: '' }), 'not_ready')
|
||||||
|
assert.equal(
|
||||||
|
resolveBindingConfirmDecision({ status: 'qr_pending', role: '大鲨鱼伊塞53' }),
|
||||||
|
'not_ready',
|
||||||
|
)
|
||||||
|
assert.equal(
|
||||||
|
resolveBindingConfirmDecision({ status: 'confirmed', role: '大鲨鱼伊塞53' }),
|
||||||
|
'confirm',
|
||||||
|
)
|
||||||
|
})
|
||||||
|
|
||||||
|
test('首次绑定:没有绑定角色且扫码完成才提交虎牙绑定', () => {
|
||||||
|
assert.equal(shouldSubmitFirstBind({}, { qrCompleted: true, scanned: true }), true)
|
||||||
|
assert.equal(shouldSubmitFirstBind({}, { qrCompleted: false, scanned: true }), false)
|
||||||
|
assert.equal(shouldSubmitFirstBind({}, { qrCompleted: true, scanned: false }), false)
|
||||||
|
})
|
||||||
|
|
||||||
|
test('首次绑定:已有绑定角色或正在换绑时不提交绑定', () => {
|
||||||
|
assert.equal(
|
||||||
|
shouldSubmitFirstBind({ hasExistingBinding: true }, { qrCompleted: true, scanned: true }),
|
||||||
|
false,
|
||||||
|
)
|
||||||
|
assert.equal(
|
||||||
|
shouldSubmitFirstBind(
|
||||||
|
{ rebindRequested: true, hasExistingBinding: false },
|
||||||
|
{ qrCompleted: true, scanned: true },
|
||||||
|
),
|
||||||
|
false,
|
||||||
|
)
|
||||||
|
})
|
||||||
|
|
||||||
|
test('首次绑定:同一张码只提交一次', () => {
|
||||||
|
assert.equal(
|
||||||
|
shouldSubmitFirstBind({ bindConfirmState: 'accepted' }, { qrCompleted: true, scanned: true }),
|
||||||
|
false,
|
||||||
|
)
|
||||||
|
assert.equal(
|
||||||
|
shouldSubmitFirstBind({ bindConfirmState: 'rejected' }, { qrCompleted: true, scanned: true }),
|
||||||
|
false,
|
||||||
|
)
|
||||||
|
assert.equal(
|
||||||
|
shouldSubmitFirstBind({ bindConfirmState: 'submitting' }, { qrCompleted: true, scanned: true }),
|
||||||
|
false,
|
||||||
|
)
|
||||||
|
})
|
||||||
@@ -82,6 +82,11 @@ type NativeBindState = {
|
|||||||
rebindConfirmMessage: string
|
rebindConfirmMessage: string
|
||||||
rebindConfirmAt: number
|
rebindConfirmAt: number
|
||||||
rebindEffectDeadlineMs: number
|
rebindEffectDeadlineMs: number
|
||||||
|
/** 首次绑定(账号还没有绑定角色)时,扫码后由项目侧提交 confirmBindActAccount 的状态。 */
|
||||||
|
bindConfirmState: 'idle' | 'submitting' | 'accepted' | 'rejected'
|
||||||
|
bindConfirmMessage: string
|
||||||
|
bindConfirmAt: number
|
||||||
|
bindEffectDeadlineMs: number
|
||||||
rebindCooldownDays: number
|
rebindCooldownDays: number
|
||||||
nextRebindAt: string
|
nextRebindAt: string
|
||||||
changeBindTime: number
|
changeBindTime: number
|
||||||
@@ -166,6 +171,10 @@ function defaultBindingState(): NativeBindState {
|
|||||||
rebindConfirmMessage: '',
|
rebindConfirmMessage: '',
|
||||||
rebindConfirmAt: 0,
|
rebindConfirmAt: 0,
|
||||||
rebindEffectDeadlineMs: 0,
|
rebindEffectDeadlineMs: 0,
|
||||||
|
bindConfirmState: 'idle',
|
||||||
|
bindConfirmMessage: '',
|
||||||
|
bindConfirmAt: 0,
|
||||||
|
bindEffectDeadlineMs: 0,
|
||||||
rebindCooldownDays: 0,
|
rebindCooldownDays: 0,
|
||||||
nextRebindAt: '',
|
nextRebindAt: '',
|
||||||
changeBindTime: 0,
|
changeBindTime: 0,
|
||||||
@@ -234,6 +243,54 @@ export function resolveRebindCooldown(
|
|||||||
return { days: 0, nextRebindAt: '' }
|
return { days: 0, nextRebindAt: '' }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export type BindingConfirmDecision = 'confirm' | 'needs_rebind_decision' | 'not_ready'
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 客户点「确认绑定」时只做本地流转:角色已识别即可确认,不调用任何虎牙接口。
|
||||||
|
* 唯一需要客户决定的情况是「换绑被虎牙拒绝、平台仍返回原角色」:
|
||||||
|
* 要么重新扫码换绑,要么显式确认继续使用原绑定角色。
|
||||||
|
*/
|
||||||
|
export function resolveBindingConfirmDecision(
|
||||||
|
binding: {
|
||||||
|
status?: string
|
||||||
|
role?: string
|
||||||
|
rebindRequested?: boolean
|
||||||
|
rebindUnchanged?: boolean
|
||||||
|
},
|
||||||
|
options: { acceptExistingRole?: boolean } = {},
|
||||||
|
): BindingConfirmDecision {
|
||||||
|
const role = String(binding.role || '').trim()
|
||||||
|
const status = String(binding.status || '')
|
||||||
|
if (!role || (status !== 'role_ready' && status !== 'confirmed')) return 'not_ready'
|
||||||
|
if (
|
||||||
|
binding.rebindRequested === true &&
|
||||||
|
binding.rebindUnchanged === true &&
|
||||||
|
options.acceptExistingRole !== true
|
||||||
|
) {
|
||||||
|
return 'needs_rebind_decision'
|
||||||
|
}
|
||||||
|
return 'confirm'
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 首次绑定:账号还没有绑定角色(isBindAccount / isBindRole 任一为 0)时,
|
||||||
|
* 扫码完成后必须由项目侧调用 confirmBindActAccount 完成绑定,再读取角色做本地比对。
|
||||||
|
* 已经有绑定角色、也没发起换绑时不需要任何平台写接口。
|
||||||
|
*/
|
||||||
|
export function shouldSubmitFirstBind(
|
||||||
|
binding: {
|
||||||
|
rebindRequested?: boolean
|
||||||
|
hasExistingBinding?: boolean
|
||||||
|
bindConfirmState?: string
|
||||||
|
},
|
||||||
|
input: { qrCompleted: boolean; scanned: boolean },
|
||||||
|
): boolean {
|
||||||
|
if (!input.qrCompleted || !input.scanned) return false
|
||||||
|
if (binding.rebindRequested === true) return false
|
||||||
|
if (binding.hasExistingBinding === true) return false
|
||||||
|
return (binding.bindConfirmState || 'idle') === 'idle'
|
||||||
|
}
|
||||||
|
|
||||||
function applyRebindMeta(
|
function applyRebindMeta(
|
||||||
session: NativeSession,
|
session: NativeSession,
|
||||||
response: HuyaBindResponse | null,
|
response: HuyaBindResponse | null,
|
||||||
@@ -861,9 +918,17 @@ export class HuyaNativeConnector {
|
|||||||
session.binding.qrUrl = urls.qrUrl
|
session.binding.qrUrl = urls.qrUrl
|
||||||
session.binding.qrToken = mini.token
|
session.binding.qrToken = mini.token
|
||||||
session.binding.expiresAtMs = this.now() + BINDING_QR_TTL_MS
|
session.binding.expiresAtMs = this.now() + BINDING_QR_TTL_MS
|
||||||
|
if (!options.forceRebind) {
|
||||||
|
// 新的绑定码:清掉上一次绑定提交状态,等这次扫码完成后再提交。
|
||||||
|
session.binding.bindConfirmState = 'idle'
|
||||||
|
session.binding.bindConfirmMessage = ''
|
||||||
|
session.binding.bindConfirmAt = 0
|
||||||
|
session.binding.bindEffectDeadlineMs = 0
|
||||||
|
session.binding.rebindScanned = false
|
||||||
|
}
|
||||||
session.binding.message = options.forceRebind
|
session.binding.message = options.forceRebind
|
||||||
? '请使用虎牙 App 扫码选择需要换绑的游戏角色'
|
? '请使用虎牙 App 扫码选择需要换绑的游戏角色'
|
||||||
: '请使用虎牙 App 扫码绑定游戏角色'
|
: '该虎牙账号还没有绑定游戏角色,请用虎牙 App 扫码完成绑定'
|
||||||
return this.bindingView(session)
|
return this.bindingView(session)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@@ -902,6 +967,39 @@ export class HuyaNativeConnector {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 首次绑定:账号还没有绑定角色时,扫码完成后由项目侧替客户点「绑定」。
|
||||||
|
* 与换绑共用 confirmBindActAccount,只是状态记录在 bindConfirmState,避免和换绑失败混淆。
|
||||||
|
*/
|
||||||
|
private async submitBindLocked(session: NativeSession, rpc: HuyaRpcClient): Promise<void> {
|
||||||
|
const { bindActId, outerActId } = configValues()
|
||||||
|
const now = this.now()
|
||||||
|
session.binding.bindConfirmState = 'submitting'
|
||||||
|
session.binding.bindConfirmMessage = ''
|
||||||
|
session.binding.bindConfirmAt = now
|
||||||
|
try {
|
||||||
|
const confirmed = await rpc.confirmBindActAccount({
|
||||||
|
uid: session.uid,
|
||||||
|
cookie: session.cookie,
|
||||||
|
bindActId,
|
||||||
|
outerActId,
|
||||||
|
})
|
||||||
|
if (confirmed && confirmed.status === 200) {
|
||||||
|
session.binding.bindConfirmState = 'accepted'
|
||||||
|
session.binding.bindEffectDeadlineMs = now + REBIND_EFFECT_WINDOW_MS
|
||||||
|
session.binding.message = '已向虎牙提交绑定,正在等待角色生效'
|
||||||
|
return
|
||||||
|
}
|
||||||
|
session.binding.bindConfirmState = 'rejected'
|
||||||
|
session.binding.bindConfirmMessage = confirmed?.msg || '虎牙未接受本次绑定'
|
||||||
|
session.binding.message = `虎牙未接受本次绑定:${session.binding.bindConfirmMessage}`
|
||||||
|
} catch (error) {
|
||||||
|
session.binding.bindConfirmState = 'rejected'
|
||||||
|
session.binding.bindConfirmMessage = errorMessage(error)
|
||||||
|
session.binding.message = `提交绑定失败:${session.binding.bindConfirmMessage}`
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
async pollBinding(sessionId: string): Promise<ConnectorBindingSession> {
|
async pollBinding(sessionId: string): Promise<ConnectorBindingSession> {
|
||||||
return this.withLock(sessionId, async () => {
|
return this.withLock(sessionId, async () => {
|
||||||
const session = this.requireAuthenticatedSession(sessionId)
|
const session = this.requireAuthenticatedSession(sessionId)
|
||||||
@@ -913,7 +1011,11 @@ export class HuyaNativeConnector {
|
|||||||
timeoutMs: this.rpcTimeoutMs,
|
timeoutMs: this.rpcTimeoutMs,
|
||||||
})
|
})
|
||||||
if (qrStatus) {
|
if (qrStatus) {
|
||||||
if (qrStatus.isExpired || qrStatus.isFailure) {
|
// 平台已受理(绑定/换绑)时二维码会先过期,此时要等角色生效,不能直接判过期。
|
||||||
|
const waitingPlatformEffect =
|
||||||
|
session.binding.rebindConfirmState === 'accepted' ||
|
||||||
|
session.binding.bindConfirmState === 'accepted'
|
||||||
|
if ((qrStatus.isExpired || qrStatus.isFailure) && !waitingPlatformEffect) {
|
||||||
session.binding.status = 'expired'
|
session.binding.status = 'expired'
|
||||||
session.binding.message = '绑定二维码已过期,请重新获取'
|
session.binding.message = '绑定二维码已过期,请重新获取'
|
||||||
return this.bindingView(session)
|
return this.bindingView(session)
|
||||||
@@ -943,6 +1045,15 @@ export class HuyaNativeConnector {
|
|||||||
) {
|
) {
|
||||||
await this.submitRebindLocked(session, rpc)
|
await this.submitRebindLocked(session, rpc)
|
||||||
}
|
}
|
||||||
|
// 首次绑定:账号还没有绑定角色时,扫码完成后由项目侧主动提交绑定。
|
||||||
|
if (
|
||||||
|
shouldSubmitFirstBind(session.binding, {
|
||||||
|
qrCompleted,
|
||||||
|
scanned: session.binding.rebindScanned,
|
||||||
|
})
|
||||||
|
) {
|
||||||
|
await this.submitBindLocked(session, rpc)
|
||||||
|
}
|
||||||
const response = await rpc.checkUserBindGameAccount({
|
const response = await rpc.checkUserBindGameAccount({
|
||||||
uid: session.uid,
|
uid: session.uid,
|
||||||
cookie: session.cookie,
|
cookie: session.cookie,
|
||||||
@@ -1001,92 +1112,103 @@ export class HuyaNativeConnector {
|
|||||||
if (rebindRequested) {
|
if (rebindRequested) {
|
||||||
session.binding.message = '已识别换绑角色,请确认换绑'
|
session.binding.message = '已识别换绑角色,请确认换绑'
|
||||||
}
|
}
|
||||||
|
} else if (
|
||||||
|
!session.binding.rebindRequested &&
|
||||||
|
session.binding.bindConfirmState === 'rejected'
|
||||||
|
) {
|
||||||
|
session.binding.status = 'failed'
|
||||||
|
session.binding.message = `虎牙未接受本次绑定:${session.binding.bindConfirmMessage}`
|
||||||
|
} else if (
|
||||||
|
!session.binding.rebindRequested &&
|
||||||
|
session.binding.bindConfirmState === 'accepted'
|
||||||
|
) {
|
||||||
|
if (this.now() < session.binding.bindEffectDeadlineMs) {
|
||||||
|
session.binding.status = 'scanned'
|
||||||
|
session.binding.message = '已向虎牙提交绑定,正在等待角色生效'
|
||||||
|
} else {
|
||||||
|
session.binding.status = 'failed'
|
||||||
|
session.binding.message = '虎牙已受理绑定,但未返回角色,请重新扫码绑定'
|
||||||
|
}
|
||||||
} else if (!['scanned', 'expired', 'failed'].includes(session.binding.status)) {
|
} else if (!['scanned', 'expired', 'failed'].includes(session.binding.status)) {
|
||||||
session.binding.status = 'qr_pending'
|
session.binding.status = 'qr_pending'
|
||||||
session.binding.message = '等待扫码绑定游戏角色'
|
session.binding.message = '该虎牙账号还没有绑定游戏角色,请扫码完成绑定'
|
||||||
}
|
}
|
||||||
return this.bindingView(session)
|
return this.bindingView(session)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
async confirmBinding(sessionId: string): Promise<ConnectorBindingSession> {
|
/** 只读绑定状态快照:不访问虎牙,供「确认绑定」这类纯本地动作使用。 */
|
||||||
|
async bindingSnapshot(sessionId: string): Promise<ConnectorBindingSession> {
|
||||||
|
return this.withLock(sessionId, async () =>
|
||||||
|
this.bindingView(this.requireAuthenticatedSession(sessionId)),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 客户点「确认绑定」:只做本地状态流转,不调用虎牙接口。
|
||||||
|
* 虎牙侧的绑定已由扫码(小程序/弹窗)完成,确认绑定只是核对三项后落库;
|
||||||
|
* 需要调用虎牙接口的地方只有「换绑确认」(submitRebind / pollBinding 自动提交)。
|
||||||
|
*/
|
||||||
|
async confirmBinding(
|
||||||
|
sessionId: string,
|
||||||
|
options: { acceptExistingRole?: boolean } = {},
|
||||||
|
): Promise<ConnectorBindingSession> {
|
||||||
return this.withLock(sessionId, async () => {
|
return this.withLock(sessionId, async () => {
|
||||||
const session = this.requireAuthenticatedSession(sessionId)
|
const session = this.requireAuthenticatedSession(sessionId)
|
||||||
const { bindActId, outerActId } = configValues()
|
const binding = session.binding
|
||||||
const rpc = new HuyaRpcClient({ fetchImpl: this.fetchImpl, timeoutMs: this.rpcTimeoutMs })
|
const decision = resolveBindingConfirmDecision(binding, options)
|
||||||
const rebindRequested = session.binding.rebindRequested
|
if (decision === 'not_ready') {
|
||||||
if (rebindRequested && session.binding.rebindConfirmState !== 'accepted') {
|
|
||||||
// 客户点确认前再兜底提交一次,避免小程序扫码后项目没来得及自动提交。
|
|
||||||
await this.submitRebindLocked(session, rpc)
|
|
||||||
}
|
|
||||||
const response = await rpc.checkUserBindGameAccount({
|
|
||||||
uid: session.uid,
|
|
||||||
cookie: session.cookie,
|
|
||||||
bindActId,
|
|
||||||
outerActId,
|
|
||||||
})
|
|
||||||
const role = parseRole(response)
|
|
||||||
if (!response || response.status !== 200 || !role.role) {
|
|
||||||
throw createHttpError('尚未识别到可确认的绑定角色', {
|
throw createHttpError('尚未识别到可确认的绑定角色', {
|
||||||
statusCode: 409,
|
statusCode: 409,
|
||||||
errorCode: 'huya_bind_role_not_ready',
|
errorCode: 'huya_bind_role_not_ready',
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
applyRebindMeta(session, response, this.now())
|
const rebindRequested = binding.rebindRequested
|
||||||
if (
|
const acceptExistingRole = options.acceptExistingRole === true
|
||||||
rebindRequested &&
|
if (decision === 'needs_rebind_decision') {
|
||||||
session.binding.baselineRoleKey &&
|
const reason = readString(binding.rebindConfirmMessage)
|
||||||
bindingRoleKey(role) === session.binding.baselineRoleKey
|
|
||||||
) {
|
|
||||||
// 只有虎牙实际未生效时才拦截;冷却原因以虎牙返回的原文为准。
|
|
||||||
throw createHttpError(
|
throw createHttpError(
|
||||||
rebindFailureMessage(
|
`${
|
||||||
role.role,
|
reason
|
||||||
session.binding.rebindConfirmMessage,
|
? `换绑未成功:${reason}。`
|
||||||
session.binding.nextRebindAt,
|
: `换绑未成功:平台仍返回原绑定角色「${binding.role}」。`
|
||||||
),
|
}请重新扫码换绑,或确认继续使用原绑定角色`,
|
||||||
{
|
{ statusCode: 409, errorCode: 'huya_bind_rebind_decision_required' },
|
||||||
statusCode: 409,
|
|
||||||
errorCode:
|
|
||||||
session.binding.rebindConfirmState === 'rejected'
|
|
||||||
? 'huya_bind_rebind_rejected'
|
|
||||||
: 'huya_bind_rebind_not_effective',
|
|
||||||
},
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
const useExistingBinding = hasExistingHuyaBinding(response) && !rebindRequested
|
const role = {
|
||||||
if (!useExistingBinding && session.binding.rebindConfirmState !== 'accepted') {
|
account: binding.account,
|
||||||
const confirmed = await rpc.confirmBindActAccount({
|
role: binding.role,
|
||||||
uid: session.uid,
|
roleId: binding.roleId,
|
||||||
cookie: session.cookie,
|
channel: binding.channel,
|
||||||
bindActId,
|
|
||||||
outerActId,
|
|
||||||
})
|
|
||||||
if (!confirmed || confirmed.status !== 200) {
|
|
||||||
throw createHttpError(confirmed?.msg || '确认虎牙绑定失败', {
|
|
||||||
statusCode: 409,
|
|
||||||
errorCode: 'huya_bind_confirm_failed',
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
const useExistingBinding =
|
||||||
|
binding.hasExistingBinding === true && (!rebindRequested || acceptExistingRole)
|
||||||
this.markRoleReady(session, role, useExistingBinding)
|
this.markRoleReady(session, role, useExistingBinding)
|
||||||
session.binding.status = 'confirmed'
|
binding.status = 'confirmed'
|
||||||
session.binding.hasExistingBinding = true
|
binding.hasExistingBinding = true
|
||||||
session.binding.rebindRequested = false
|
binding.rebindRequested = false
|
||||||
session.binding.rebindScanned = false
|
binding.rebindScanned = false
|
||||||
session.binding.rebindUnchanged = false
|
binding.rebindUnchanged = false
|
||||||
session.binding.rebindConfirmState = 'idle'
|
binding.rebindConfirmState = 'idle'
|
||||||
session.binding.rebindConfirmMessage = ''
|
binding.rebindConfirmMessage = ''
|
||||||
session.binding.rebindConfirmAt = 0
|
binding.rebindConfirmAt = 0
|
||||||
session.binding.rebindEffectDeadlineMs = 0
|
binding.rebindEffectDeadlineMs = 0
|
||||||
session.binding.rebindCooldownDays = 0
|
binding.bindConfirmState = 'idle'
|
||||||
session.binding.nextRebindAt = ''
|
binding.bindConfirmMessage = ''
|
||||||
session.binding.baselineRoleKey = ''
|
binding.bindConfirmAt = 0
|
||||||
session.binding.message = useExistingBinding
|
binding.bindEffectDeadlineMs = 0
|
||||||
? '当前虎牙账号已有绑定角色,已确认直接使用'
|
binding.rebindCooldownDays = 0
|
||||||
: rebindRequested
|
binding.nextRebindAt = ''
|
||||||
? '虎牙角色换绑已确认'
|
binding.baselineRoleKey = ''
|
||||||
: '虎牙角色绑定已确认'
|
binding.message =
|
||||||
|
rebindRequested && acceptExistingRole
|
||||||
|
? '本次换绑未生效,已按原绑定角色确认'
|
||||||
|
: useExistingBinding
|
||||||
|
? '当前虎牙账号已有绑定角色,已确认直接使用'
|
||||||
|
: rebindRequested
|
||||||
|
? '虎牙角色换绑已确认'
|
||||||
|
: '虎牙角色绑定已确认'
|
||||||
return this.bindingView(session)
|
return this.bindingView(session)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@@ -1419,6 +1541,8 @@ export class HuyaNativeConnector {
|
|||||||
rebindUnchanged: binding.rebindUnchanged,
|
rebindUnchanged: binding.rebindUnchanged,
|
||||||
rebindConfirmState: binding.rebindConfirmState,
|
rebindConfirmState: binding.rebindConfirmState,
|
||||||
rebindConfirmMessage: binding.rebindConfirmMessage,
|
rebindConfirmMessage: binding.rebindConfirmMessage,
|
||||||
|
bindConfirmState: binding.bindConfirmState,
|
||||||
|
bindConfirmMessage: binding.bindConfirmMessage,
|
||||||
rebindCooldownDays: binding.rebindCooldownDays,
|
rebindCooldownDays: binding.rebindCooldownDays,
|
||||||
nextRebindAt: binding.nextRebindAt,
|
nextRebindAt: binding.nextRebindAt,
|
||||||
platformChangeBindDay: binding.changeBindDay,
|
platformChangeBindDay: binding.changeBindDay,
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ import {
|
|||||||
confirmHuyaBinding,
|
confirmHuyaBinding,
|
||||||
exportHuyaSessionCredential,
|
exportHuyaSessionCredential,
|
||||||
getHuyaBinding,
|
getHuyaBinding,
|
||||||
|
getHuyaBindingSnapshot,
|
||||||
getHuyaLoginSession,
|
getHuyaLoginSession,
|
||||||
loginHuyaSms,
|
loginHuyaSms,
|
||||||
revokeHuyaSession,
|
revokeHuyaSession,
|
||||||
@@ -959,6 +960,8 @@ function mapBindingUpdate(session: ConnectorBindingSession) {
|
|||||||
rebindUnchanged: session.rebindUnchanged === true,
|
rebindUnchanged: session.rebindUnchanged === true,
|
||||||
rebindConfirmState: session.rebindConfirmState || 'idle',
|
rebindConfirmState: session.rebindConfirmState || 'idle',
|
||||||
rebindConfirmMessage: String(session.rebindConfirmMessage || ''),
|
rebindConfirmMessage: String(session.rebindConfirmMessage || ''),
|
||||||
|
bindConfirmState: session.bindConfirmState || 'idle',
|
||||||
|
bindConfirmMessage: String(session.bindConfirmMessage || ''),
|
||||||
rebindCooldownDays: Number(session.rebindCooldownDays || 0),
|
rebindCooldownDays: Number(session.rebindCooldownDays || 0),
|
||||||
nextRebindAt: String(session.nextRebindAt || ''),
|
nextRebindAt: String(session.nextRebindAt || ''),
|
||||||
platformChangeBindDay: Number(session.platformChangeBindDay || 0),
|
platformChangeBindDay: Number(session.platformChangeBindDay || 0),
|
||||||
@@ -1144,6 +1147,8 @@ async function updateBindingTask(
|
|||||||
rebindUnchanged: mapped.rebindUnchanged,
|
rebindUnchanged: mapped.rebindUnchanged,
|
||||||
rebindConfirmState: mapped.rebindConfirmState,
|
rebindConfirmState: mapped.rebindConfirmState,
|
||||||
rebindConfirmMessage: mapped.rebindConfirmMessage,
|
rebindConfirmMessage: mapped.rebindConfirmMessage,
|
||||||
|
bindConfirmState: mapped.bindConfirmState,
|
||||||
|
bindConfirmMessage: mapped.bindConfirmMessage,
|
||||||
rebindCooldownDays: mapped.rebindCooldownDays,
|
rebindCooldownDays: mapped.rebindCooldownDays,
|
||||||
nextRebindAt: mapped.nextRebindAt,
|
nextRebindAt: mapped.nextRebindAt,
|
||||||
changeBindDay: mapped.platformChangeBindDay,
|
changeBindDay: mapped.platformChangeBindDay,
|
||||||
@@ -1166,6 +1171,8 @@ async function updateBindingTask(
|
|||||||
rebindUnchanged: mapped.rebindUnchanged,
|
rebindUnchanged: mapped.rebindUnchanged,
|
||||||
rebindConfirmState: mapped.rebindConfirmState,
|
rebindConfirmState: mapped.rebindConfirmState,
|
||||||
rebindConfirmMessage: mapped.rebindConfirmMessage,
|
rebindConfirmMessage: mapped.rebindConfirmMessage,
|
||||||
|
bindConfirmState: mapped.bindConfirmState,
|
||||||
|
bindConfirmMessage: mapped.bindConfirmMessage,
|
||||||
rebindCooldownDays: mapped.rebindCooldownDays,
|
rebindCooldownDays: mapped.rebindCooldownDays,
|
||||||
nextRebindAt: mapped.nextRebindAt,
|
nextRebindAt: mapped.nextRebindAt,
|
||||||
platformChangeBindDay: mapped.platformChangeBindDay,
|
platformChangeBindDay: mapped.platformChangeBindDay,
|
||||||
@@ -1341,7 +1348,11 @@ export async function pollPublicBinding(orderNoInput: unknown, taskIdInput: unkn
|
|||||||
return { task: mapTask(updated), binding }
|
return { task: mapTask(updated), binding }
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function confirmPublicBinding(orderNoInput: unknown, taskIdInput: unknown) {
|
export async function confirmPublicBinding(
|
||||||
|
orderNoInput: unknown,
|
||||||
|
taskIdInput: unknown,
|
||||||
|
options: { acceptExistingRole?: boolean } = {},
|
||||||
|
) {
|
||||||
const orderNo = normalizeOrderNo(orderNoInput)
|
const orderNo = normalizeOrderNo(orderNoInput)
|
||||||
const taskId = normalizeId(taskIdInput)
|
const taskId = normalizeId(taskIdInput)
|
||||||
const task = await loadTaskForOrder(orderNo, taskId)
|
const task = await loadTaskForOrder(orderNo, taskId)
|
||||||
@@ -1360,15 +1371,27 @@ export async function confirmPublicBinding(orderNoInput: unknown, taskIdInput: u
|
|||||||
errorCode: 'semi_auto_binding_not_ready',
|
errorCode: 'semi_auto_binding_not_ready',
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
const session = await getBindingForTask(task, task.connector_session_id)
|
// 确认绑定是纯本地动作:虎牙侧只读内存快照,不再触发角色查询或换绑提交。
|
||||||
if (task.platform === 'huya' && session.rebindUnchanged === true) {
|
const session =
|
||||||
throw createHttpError(session.message || '换绑未生效:平台仍返回原绑定角色,请重新扫码', {
|
task.platform === 'huya'
|
||||||
statusCode: 409,
|
? await getHuyaBindingSnapshot(task.connector_session_id, task.connector_mode)
|
||||||
errorCode:
|
: await getBindingForTask(task, task.connector_session_id)
|
||||||
session.rebindConfirmState === 'rejected'
|
if (
|
||||||
? 'semi_auto_binding_rebind_rejected'
|
task.platform === 'huya' &&
|
||||||
: 'semi_auto_binding_rebind_unchanged',
|
session.rebindUnchanged === true &&
|
||||||
})
|
options.acceptExistingRole !== true
|
||||||
|
) {
|
||||||
|
// 换绑被虎牙拒绝时不直接放行,要求客户二选一:重新扫码换绑 / 仍使用原角色。
|
||||||
|
const reason = String(session.rebindConfirmMessage || '').trim()
|
||||||
|
throw createHttpError(
|
||||||
|
`${
|
||||||
|
reason ? `换绑未成功:${reason}。` : '换绑未生效:平台仍返回原绑定角色。'
|
||||||
|
}请重新扫码换绑,或确认继续使用原绑定角色「${session.bindGameRole || '原角色'}」`,
|
||||||
|
{
|
||||||
|
statusCode: 409,
|
||||||
|
errorCode: 'semi_auto_binding_rebind_decision_required',
|
||||||
|
},
|
||||||
|
)
|
||||||
}
|
}
|
||||||
const comparison = compareBindingRole(task, session)
|
const comparison = compareBindingRole(task, session)
|
||||||
if (comparison.verdict === 'mismatch') {
|
if (comparison.verdict === 'mismatch') {
|
||||||
@@ -1380,7 +1403,7 @@ export async function confirmPublicBinding(orderNoInput: unknown, taskIdInput: u
|
|||||||
// 必须调用 Connector 完成确认,否则会话仍是 role_ready,数据库也会停在待确认。
|
// 必须调用 Connector 完成确认,否则会话仍是 role_ready,数据库也会停在待确认。
|
||||||
const confirmedSession =
|
const confirmedSession =
|
||||||
task.platform === 'huya'
|
task.platform === 'huya'
|
||||||
? await confirmHuyaBinding(task.connector_session_id, task.connector_mode)
|
? await confirmHuyaBinding(task.connector_session_id, task.connector_mode, options)
|
||||||
: session
|
: session
|
||||||
const binding = await updateBindingTask(task, confirmedSession, 'customer')
|
const binding = await updateBindingTask(task, confirmedSession, 'customer')
|
||||||
const updated = await loadTask(task.id)
|
const updated = await loadTask(task.id)
|
||||||
|
|||||||
@@ -37,7 +37,6 @@ import type {
|
|||||||
CustomerSemiAutoTask,
|
CustomerSemiAutoTask,
|
||||||
} from '@/types/customer-fulfillment'
|
} from '@/types/customer-fulfillment'
|
||||||
import { formatAdminDateTime } from '@/utils/admin-time'
|
import { formatAdminDateTime } from '@/utils/admin-time'
|
||||||
import collectHero from '@/assets/claim/game-role-id-guide.jpg'
|
|
||||||
import { runWeiboYidunChallenge } from '@/utils/weibo-yidun'
|
import { runWeiboYidunChallenge } from '@/utils/weibo-yidun'
|
||||||
import HuyaChallengeModal from './HuyaChallengeModal'
|
import HuyaChallengeModal from './HuyaChallengeModal'
|
||||||
|
|
||||||
@@ -49,7 +48,7 @@ const SERVER_ZONE_OPTIONS = ['苹果Q区', '苹果V区', '安卓Q区', '安卓V
|
|||||||
const SERVER_ZONE_SELECT_CLASS_NAMES = { popup: { root: 'customer-collect-dropdown' } }
|
const SERVER_ZONE_SELECT_CLASS_NAMES = { popup: { root: 'customer-collect-dropdown' } }
|
||||||
|
|
||||||
export default function CustomerFulfillmentPage() {
|
export default function CustomerFulfillmentPage() {
|
||||||
const { message } = App.useApp()
|
const { message, modal } = App.useApp()
|
||||||
const { orderNo: routeOrderNo } = useParams<{ orderNo?: string }>()
|
const { orderNo: routeOrderNo } = useParams<{ orderNo?: string }>()
|
||||||
const orderNo = String(routeOrderNo || '').trim()
|
const orderNo = String(routeOrderNo || '').trim()
|
||||||
const [loading, setLoading] = useState(true)
|
const [loading, setLoading] = useState(true)
|
||||||
@@ -677,17 +676,23 @@ export default function CustomerFulfillmentPage() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function handleConfirmBinding() {
|
async function handleConfirmBinding(acceptExistingRole = false) {
|
||||||
if (!selectedTask) return
|
if (!selectedTask) return
|
||||||
setBindingLoading(true)
|
setBindingLoading(true)
|
||||||
try {
|
try {
|
||||||
const response = await confirmCustomerBinding(orderNo, selectedTask.id)
|
const response = await confirmCustomerBinding(
|
||||||
|
orderNo,
|
||||||
|
selectedTask.id,
|
||||||
|
acceptExistingRole ? { acceptExistingRole: true } : {},
|
||||||
|
)
|
||||||
setTasks((current) =>
|
setTasks((current) =>
|
||||||
current.map((task) => (task.id === response.data.task.id ? response.data.task : task)),
|
current.map((task) => (task.id === response.data.task.id ? response.data.task : task)),
|
||||||
)
|
)
|
||||||
setBindingInfo(response.data.binding)
|
setBindingInfo(response.data.binding)
|
||||||
setBindingConfirmOpen(false)
|
setBindingConfirmOpen(false)
|
||||||
message.success('绑定已确认,等待客服处理')
|
message.success(
|
||||||
|
acceptExistingRole ? '已按原绑定角色确认,等待客服处理' : '绑定已确认,等待客服处理',
|
||||||
|
)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (isHuyaSessionExpired(error)) {
|
if (isHuyaSessionExpired(error)) {
|
||||||
setBindingSessionExpired(true)
|
setBindingSessionExpired(true)
|
||||||
@@ -701,6 +706,21 @@ export default function CustomerFulfillmentPage() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** 换绑被虎牙拒绝时的二次确认:客户可以选择继续使用原绑定角色。 */
|
||||||
|
function handleAcceptExistingRole() {
|
||||||
|
if (!selectedTask || bindingLoading) return
|
||||||
|
const reason = String(bindingInfo?.rebindConfirmMessage || '').trim()
|
||||||
|
modal.confirm({
|
||||||
|
title: '仍使用原绑定角色?',
|
||||||
|
content: `本次换绑未成功${reason ? `(${reason})` : ''},平台仍返回原绑定角色「${
|
||||||
|
bindingRoleName || '当前角色'
|
||||||
|
}」。确认后本次换绑作废,直接使用该角色继续履约。`,
|
||||||
|
okText: '仍使用原角色',
|
||||||
|
cancelText: '先不确认',
|
||||||
|
onOk: () => handleConfirmBinding(true),
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
async function handleSaveProfile() {
|
async function handleSaveProfile() {
|
||||||
if (!selectedTask) return
|
if (!selectedTask) return
|
||||||
if (!profileServerZone.trim() || !profileRoleId.trim() || !profileRoleName.trim()) {
|
if (!profileServerZone.trim() || !profileRoleId.trim() || !profileRoleName.trim()) {
|
||||||
@@ -778,6 +798,42 @@ export default function CustomerFulfillmentPage() {
|
|||||||
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'
|
||||||
|
const bindConfirmState = bindingInfo?.bindConfirmState || 'idle'
|
||||||
|
const bindConfirmRejected = bindConfirmState === 'rejected'
|
||||||
|
const bindConfirmPending = bindConfirmState === 'submitting' || bindConfirmState === 'accepted'
|
||||||
|
// 还没有绑定角色时,二维码区域已经说明了原因,不再重复提示「缺角色ID」。
|
||||||
|
const showMissingRoleIdWarning =
|
||||||
|
!bindingPendingUid && !rebindUnchanged && bindingInfo?.hasExistingBinding !== false
|
||||||
|
// 绑定阶段顶部状态条:按 bindingStatus 显式映射,已确认/已过期/失败不再显示(各自有卡片)。
|
||||||
|
const bindingBanner = (() => {
|
||||||
|
if (bindingSessionExpired) return null
|
||||||
|
if (rebindUnchanged) {
|
||||||
|
return {
|
||||||
|
tone: 'is-warning',
|
||||||
|
text: rebindRejected ? '虎牙未接受本次换绑,请查看下方原因' : '换绑未生效,请查看下方原因',
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (selectedTask?.bindingStatus === 'role_ready') {
|
||||||
|
return { tone: 'is-info', text: '已识别绑定角色,请核对后确认' }
|
||||||
|
}
|
||||||
|
if (
|
||||||
|
selectedTask?.bindingStatus === 'confirmed' ||
|
||||||
|
selectedTask?.bindingStatus === 'expired' ||
|
||||||
|
selectedTask?.bindingStatus === 'failed'
|
||||||
|
) {
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
if (bindingInfo?.hasExistingBinding === false) {
|
||||||
|
return {
|
||||||
|
tone: 'is-info',
|
||||||
|
text: '登录成功,该虎牙账号还没有绑定游戏角色,请扫码完成绑定',
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!bindingRoleId) {
|
||||||
|
return { tone: 'is-warning', text: '未获取到已绑定的角色ID,请重新扫码绑定' }
|
||||||
|
}
|
||||||
|
return null
|
||||||
|
})()
|
||||||
const nextRebindText = bindingInfo?.nextRebindAt
|
const nextRebindText = bindingInfo?.nextRebindAt
|
||||||
? formatAdminDateTime(bindingInfo.nextRebindAt)
|
? formatAdminDateTime(bindingInfo.nextRebindAt)
|
||||||
: ''
|
: ''
|
||||||
@@ -1121,24 +1177,10 @@ export default function CustomerFulfillmentPage() {
|
|||||||
</div>
|
</div>
|
||||||
) : null}
|
) : null}
|
||||||
|
|
||||||
{!bindingSessionExpired ? (
|
{bindingBanner ? (
|
||||||
rebindUnchanged ? (
|
<div className={`customer-binding-alert ${bindingBanner.tone}`}>
|
||||||
<div className="customer-binding-alert is-warning">
|
{bindingBanner.text}
|
||||||
{rebindRejected
|
</div>
|
||||||
? '虎牙未接受本次换绑,请查看下方原因'
|
|
||||||
: '换绑未生效,请查看下方原因'}
|
|
||||||
</div>
|
|
||||||
) : selectedTask?.bindingStatus === 'role_ready' ? (
|
|
||||||
<div className="customer-binding-alert is-info">已识别绑定角色,请核对后确认</div>
|
|
||||||
) : selectedTask?.bindingStatus === 'confirmed' || bindingRoleId ? (
|
|
||||||
<div className="customer-binding-alert is-info">
|
|
||||||
登录成功,请继续扫码绑定游戏角色
|
|
||||||
</div>
|
|
||||||
) : (
|
|
||||||
<div className="customer-binding-alert is-warning">
|
|
||||||
未获取到已绑定的角色ID,请重新扫码绑定
|
|
||||||
</div>
|
|
||||||
)
|
|
||||||
) : null}
|
) : null}
|
||||||
|
|
||||||
{showProfileForm && !bindingSessionExpired ? (
|
{showProfileForm && !bindingSessionExpired ? (
|
||||||
@@ -1219,14 +1261,20 @@ export default function CustomerFulfillmentPage() {
|
|||||||
<span>正在生成绑定二维码...</span>
|
<span>正在生成绑定二维码...</span>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
<p className="customer-binding-qr-hint">请使用微信APP扫码进行游戏角色绑定</p>
|
<p className="customer-binding-qr-hint">
|
||||||
|
{bindingInfo?.hasExistingBinding === false
|
||||||
|
? '该虎牙账号还没有绑定游戏角色,请用微信扫码完成绑定'
|
||||||
|
: '请使用微信APP扫码进行游戏角色绑定'}
|
||||||
|
</p>
|
||||||
<p className="customer-binding-qr-tip">
|
<p className="customer-binding-qr-tip">
|
||||||
{selectedTask?.bindingStatus === 'scanned'
|
{selectedTask?.bindingStatus === 'scanned'
|
||||||
? rebindAccepted
|
? rebindAccepted
|
||||||
? '已向虎牙提交换绑,正在等待角色生效,请稍候刷新。'
|
? '已向虎牙提交换绑,正在等待角色生效,请稍候刷新。'
|
||||||
: bindingInfo?.rebindRequested
|
: bindConfirmPending
|
||||||
? '扫码后请在虎牙弹窗中选中目标角色;选好后点下方「已选好角色,提交换绑」。'
|
? '已向虎牙提交绑定,正在等待角色生效,请稍候刷新。'
|
||||||
: '请在微信中完成角色绑定确认,再点击下方按钮进入下一步。'
|
: bindingInfo?.rebindRequested
|
||||||
|
? '扫码后请在虎牙弹窗中选中目标角色;选好后点下方「已选好角色,提交换绑」。'
|
||||||
|
: '请在微信中完成角色绑定确认,再点击下方按钮进入下一步。'
|
||||||
: '扫码后请在微信确认框中核对目标角色。'}
|
: '扫码后请在微信确认框中核对目标角色。'}
|
||||||
</p>
|
</p>
|
||||||
{nextRebindText ? (
|
{nextRebindText ? (
|
||||||
@@ -1267,7 +1315,9 @@ export default function CustomerFulfillmentPage() {
|
|||||||
loading={bindingLoading}
|
loading={bindingLoading}
|
||||||
onClick={() => void handlePollBindingNow()}
|
onClick={() => void handlePollBindingNow()}
|
||||||
>
|
>
|
||||||
{rebindAccepted ? '刷新绑定状态' : '已扫码绑定,点击进入下一步'}
|
{rebindAccepted || bindConfirmPending
|
||||||
|
? '刷新绑定状态'
|
||||||
|
: '已扫码绑定,点击进入下一步'}
|
||||||
</Button>
|
</Button>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
@@ -1291,7 +1341,7 @@ export default function CustomerFulfillmentPage() {
|
|||||||
<Alert
|
<Alert
|
||||||
type="error"
|
type="error"
|
||||||
showIcon
|
showIcon
|
||||||
message="绑定失败"
|
message={bindConfirmRejected ? '虎牙未接受本次绑定' : '绑定失败'}
|
||||||
description={
|
description={
|
||||||
bindingInfo?.message || '请刷新二维码后重新扫码,如持续失败请联系客服。'
|
bindingInfo?.message || '请刷新二维码后重新扫码,如持续失败请联系客服。'
|
||||||
}
|
}
|
||||||
@@ -1363,7 +1413,7 @@ export default function CustomerFulfillmentPage() {
|
|||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
) : null}
|
) : null}
|
||||||
{!bindingPendingUid && !rebindUnchanged ? (
|
{showMissingRoleIdWarning ? (
|
||||||
<Alert
|
<Alert
|
||||||
type="warning"
|
type="warning"
|
||||||
showIcon
|
showIcon
|
||||||
@@ -1392,6 +1442,15 @@ export default function CustomerFulfillmentPage() {
|
|||||||
>
|
>
|
||||||
重新扫码换绑
|
重新扫码换绑
|
||||||
</Button>
|
</Button>
|
||||||
|
<Button
|
||||||
|
block
|
||||||
|
size="large"
|
||||||
|
className="customer-binding-accept"
|
||||||
|
loading={bindingLoading}
|
||||||
|
onClick={() => handleAcceptExistingRole()}
|
||||||
|
>
|
||||||
|
仍使用原角色
|
||||||
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
) : comparisonMismatch ? (
|
) : comparisonMismatch ? (
|
||||||
<div className="customer-binding-role-actions">
|
<div className="customer-binding-role-actions">
|
||||||
@@ -1672,8 +1731,6 @@ function CustomerCollectStep(input: {
|
|||||||
return (
|
return (
|
||||||
<div className="customer-collect-page">
|
<div className="customer-collect-page">
|
||||||
<div className="customer-collect-hero">
|
<div className="customer-collect-hero">
|
||||||
<img src={collectHero} alt="" className="customer-collect-hero-image" />
|
|
||||||
<div className="customer-collect-hero-mask" />
|
|
||||||
<p className="customer-collect-warning">温馨提示:未成年人禁止下单</p>
|
<p className="customer-collect-warning">温馨提示:未成年人禁止下单</p>
|
||||||
</div>
|
</div>
|
||||||
<div className="customer-collect-body">
|
<div className="customer-collect-body">
|
||||||
|
|||||||
@@ -59,10 +59,14 @@ export function pollCustomerBinding(orderNo: string, taskId: number) {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
export function confirmCustomerBinding(orderNo: string, taskId: number) {
|
export function confirmCustomerBinding(
|
||||||
|
orderNo: string,
|
||||||
|
taskId: number,
|
||||||
|
options: { acceptExistingRole?: boolean } = {},
|
||||||
|
) {
|
||||||
return apiPost<{ task: CustomerSemiAutoTask; binding: CustomerBindingInfo }>(
|
return apiPost<{ task: CustomerSemiAutoTask; binding: CustomerBindingInfo }>(
|
||||||
`/api/v1/customer-fulfillment/${encodeURIComponent(orderNo)}/tasks/${taskId}/binding/confirm`,
|
`/api/v1/customer-fulfillment/${encodeURIComponent(orderNo)}/tasks/${taskId}/binding/confirm`,
|
||||||
{},
|
options.acceptExistingRole ? { acceptExistingRole: true } : {},
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2149,30 +2149,12 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.customer-collect-hero {
|
.customer-collect-hero {
|
||||||
position: relative;
|
padding: 42px 20px 6px;
|
||||||
height: 210px;
|
text-align: center;
|
||||||
overflow: hidden;
|
background: linear-gradient(180deg, #0f1a2d, #0b1220);
|
||||||
}
|
|
||||||
|
|
||||||
.customer-collect-hero-image {
|
|
||||||
width: 100%;
|
|
||||||
height: 100%;
|
|
||||||
object-fit: cover;
|
|
||||||
object-position: left center;
|
|
||||||
filter: saturate(0.9) brightness(0.72);
|
|
||||||
}
|
|
||||||
|
|
||||||
.customer-collect-hero-mask {
|
|
||||||
position: absolute;
|
|
||||||
inset: 0;
|
|
||||||
background: linear-gradient(180deg, rgba(11, 18, 32, 0.1), rgba(11, 18, 32, 0.96));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.customer-collect-warning {
|
.customer-collect-warning {
|
||||||
position: absolute;
|
|
||||||
left: 0;
|
|
||||||
right: 0;
|
|
||||||
bottom: 22px;
|
|
||||||
margin: 0;
|
margin: 0;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
color: #f87171;
|
color: #f87171;
|
||||||
@@ -2201,7 +2183,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.customer-collect-readonly {
|
.customer-collect-readonly {
|
||||||
height: 56px;
|
height: 48px;
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
padding: 0 16px;
|
padding: 0 16px;
|
||||||
@@ -2255,7 +2237,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.customer-collect-input.ant-input {
|
.customer-collect-input.ant-input {
|
||||||
height: 56px;
|
height: 48px;
|
||||||
border-radius: 12px;
|
border-radius: 12px;
|
||||||
background: #1b2436;
|
background: #1b2436;
|
||||||
border-color: #26344d;
|
border-color: #26344d;
|
||||||
@@ -2268,7 +2250,7 @@
|
|||||||
|
|
||||||
.customer-collect-select.ant-select {
|
.customer-collect-select.ant-select {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
height: 56px;
|
height: 48px;
|
||||||
padding-inline: 16px;
|
padding-inline: 16px;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
font-size: 15px;
|
font-size: 15px;
|
||||||
@@ -2276,7 +2258,7 @@
|
|||||||
border: 1px solid #26344d;
|
border: 1px solid #26344d;
|
||||||
background: #1b2436;
|
background: #1b2436;
|
||||||
color: #fff;
|
color: #fff;
|
||||||
--ant-select-height: 56px;
|
--ant-select-height: 48px;
|
||||||
--ant-select-border-radius: 12px;
|
--ant-select-border-radius: 12px;
|
||||||
--ant-select-border-color: #26344d;
|
--ant-select-border-color: #26344d;
|
||||||
--ant-select-background-color: #1b2436;
|
--ant-select-background-color: #1b2436;
|
||||||
@@ -2340,7 +2322,7 @@
|
|||||||
|
|
||||||
.customer-collect-page .customer-collect-submit.ant-btn,
|
.customer-collect-page .customer-collect-submit.ant-btn,
|
||||||
.customer-auth-profile .customer-collect-submit.ant-btn {
|
.customer-auth-profile .customer-collect-submit.ant-btn {
|
||||||
height: 56px;
|
height: 52px;
|
||||||
margin-top: 14px;
|
margin-top: 14px;
|
||||||
border-radius: 14px;
|
border-radius: 14px;
|
||||||
font-size: 17px;
|
font-size: 17px;
|
||||||
@@ -2391,7 +2373,7 @@
|
|||||||
.customer-login-mobile.ant-input {
|
.customer-login-mobile.ant-input {
|
||||||
flex: 1;
|
flex: 1;
|
||||||
min-width: 0;
|
min-width: 0;
|
||||||
height: 52px;
|
height: 48px;
|
||||||
padding: 0 16px;
|
padding: 0 16px;
|
||||||
border-radius: 8px;
|
border-radius: 8px;
|
||||||
border-color: #3a4150;
|
border-color: #3a4150;
|
||||||
@@ -2407,7 +2389,7 @@
|
|||||||
.customer-login-code-button.ant-btn {
|
.customer-login-code-button.ant-btn {
|
||||||
flex: none;
|
flex: none;
|
||||||
width: 118px;
|
width: 118px;
|
||||||
height: 52px;
|
height: 48px;
|
||||||
border-radius: 8px;
|
border-radius: 8px;
|
||||||
background: #3b82f6 !important;
|
background: #3b82f6 !important;
|
||||||
border-color: #3b82f6 !important;
|
border-color: #3b82f6 !important;
|
||||||
@@ -2416,7 +2398,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.customer-login-code-input.ant-input {
|
.customer-login-code-input.ant-input {
|
||||||
height: 52px;
|
height: 48px;
|
||||||
border-radius: 8px;
|
border-radius: 8px;
|
||||||
border-color: #3a4150;
|
border-color: #3a4150;
|
||||||
background: #1b2130;
|
background: #1b2130;
|
||||||
@@ -2431,7 +2413,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.customer-login-submit.ant-btn {
|
.customer-login-submit.ant-btn {
|
||||||
height: 56px;
|
height: 52px;
|
||||||
border-radius: 14px;
|
border-radius: 14px;
|
||||||
background: #2563eb !important;
|
background: #2563eb !important;
|
||||||
border-color: #2563eb !important;
|
border-color: #2563eb !important;
|
||||||
@@ -2448,7 +2430,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.customer-login-alt.ant-btn {
|
.customer-login-alt.ant-btn {
|
||||||
height: 52px;
|
height: 48px;
|
||||||
border-radius: 8px;
|
border-radius: 8px;
|
||||||
background: transparent !important;
|
background: transparent !important;
|
||||||
border-color: #3a4150 !important;
|
border-color: #3a4150 !important;
|
||||||
@@ -2634,7 +2616,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.customer-binding-role-actions .customer-binding-confirm.ant-btn {
|
.customer-binding-role-actions .customer-binding-confirm.ant-btn {
|
||||||
height: 56px;
|
height: 52px;
|
||||||
border-radius: 14px;
|
border-radius: 14px;
|
||||||
background: #2563eb !important;
|
background: #2563eb !important;
|
||||||
border-color: #2563eb !important;
|
border-color: #2563eb !important;
|
||||||
@@ -2651,7 +2633,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.customer-binding-role-actions .customer-binding-rebind.ant-btn {
|
.customer-binding-role-actions .customer-binding-rebind.ant-btn {
|
||||||
height: 56px;
|
height: 48px;
|
||||||
border-radius: 14px;
|
border-radius: 14px;
|
||||||
background: transparent !important;
|
background: transparent !important;
|
||||||
border-color: #3a4150 !important;
|
border-color: #3a4150 !important;
|
||||||
@@ -2671,6 +2653,23 @@
|
|||||||
color: #fbbf24 !important;
|
color: #fbbf24 !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.customer-binding-role-actions .customer-binding-accept.ant-btn {
|
||||||
|
height: 46px;
|
||||||
|
border-radius: 12px;
|
||||||
|
background: transparent !important;
|
||||||
|
border-color: transparent !important;
|
||||||
|
color: #94a3b8 !important;
|
||||||
|
font-size: 15px;
|
||||||
|
font-weight: 500;
|
||||||
|
}
|
||||||
|
|
||||||
|
.customer-binding-role-actions .customer-binding-accept.ant-btn:hover,
|
||||||
|
.customer-binding-role-actions .customer-binding-accept.ant-btn:focus-visible {
|
||||||
|
background: rgba(148, 163, 184, 0.1) !important;
|
||||||
|
border-color: transparent !important;
|
||||||
|
color: #e2e8f0 !important;
|
||||||
|
}
|
||||||
|
|
||||||
.customer-binding-info {
|
.customer-binding-info {
|
||||||
padding: 16px;
|
padding: 16px;
|
||||||
border: 1px solid #3a4150;
|
border: 1px solid #3a4150;
|
||||||
@@ -2804,7 +2803,7 @@
|
|||||||
|
|
||||||
.customer-binding-next.ant-btn {
|
.customer-binding-next.ant-btn {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
height: 56px;
|
height: 52px;
|
||||||
margin-top: 6px;
|
margin-top: 6px;
|
||||||
border-radius: 14px;
|
border-radius: 14px;
|
||||||
background: #2563eb !important;
|
background: #2563eb !important;
|
||||||
@@ -2897,7 +2896,7 @@
|
|||||||
|
|
||||||
.customer-auth-button-stack .ant-btn,
|
.customer-auth-button-stack .ant-btn,
|
||||||
.customer-auth-form > .ant-btn {
|
.customer-auth-form > .ant-btn {
|
||||||
height: 50px;
|
height: 52px;
|
||||||
font-size: 17px;
|
font-size: 17px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -62,6 +62,8 @@ export type CustomerBindingInfo = {
|
|||||||
rebindUnchanged: boolean
|
rebindUnchanged: boolean
|
||||||
rebindConfirmState: 'idle' | 'submitting' | 'accepted' | 'rejected'
|
rebindConfirmState: 'idle' | 'submitting' | 'accepted' | 'rejected'
|
||||||
rebindConfirmMessage: string
|
rebindConfirmMessage: string
|
||||||
|
bindConfirmState?: 'idle' | 'submitting' | 'accepted' | 'rejected'
|
||||||
|
bindConfirmMessage?: string
|
||||||
rebindCooldownDays: number
|
rebindCooldownDays: number
|
||||||
nextRebindAt: string
|
nextRebindAt: string
|
||||||
platformChangeBindDay?: number
|
platformChangeBindDay?: number
|
||||||
|
|||||||
Reference in New Issue
Block a user