fix(semi-auto): 换绑失败卡透出虎牙原因与下次换绑时间,会话过期可返回登录
1) 下次换绑时间改按虎牙日界口径:changeBindTime 是绑定日次日 00:00,(日界 + changeBindDay - 1) 天;11-16 绑定 → 2026-11-23,与虎牙绑定页一致(原 +7 天会显示 11-24)。 2) 客户页换绑失败卡同时展示虎牙原文原因、预计下次可换绑时间与「每 7 个自然日可换绑 1 次」规则。 3) 绑定会话失效时给出整行「返回登录」入口;二维码加载失败可重试;告警标题统一为亮色不再黑字;提交类按钮统一 56px 蓝色主按钮。
This commit is contained in:
@@ -209,10 +209,18 @@ export function resolveRebindCooldown(
|
||||
if (!response || (response.status !== undefined && response.status !== 200)) {
|
||||
return { days: 0, nextRebindAt: '' }
|
||||
}
|
||||
const changeBindDay = Number(response.changeBindDay || 0)
|
||||
const hasPlatformWindow =
|
||||
Number.isFinite(changeBindDay) && changeBindDay > 0 && changeBindDay <= 30
|
||||
const windowDays = hasPlatformWindow ? Math.round(changeBindDay) : REBIND_WINDOW_DAYS
|
||||
const changeBindTime = Number(response.accountData?.changeBindTime || 0)
|
||||
if (Number.isFinite(changeBindTime) && changeBindTime > 0) {
|
||||
const changedAtMs = changeBindTime > 1e12 ? changeBindTime : changeBindTime * 1000
|
||||
const nextRebindMs = changedAtMs + REBIND_WINDOW_DAYS * DAY_MS
|
||||
// 虎牙把「本次绑定日」记成次日 00:00 的日界:11-16 绑定 → changeBindTime = 2026-11-17 00:00,
|
||||
// 配合 changeBindDay = 7,绑定页提示「预计下次换绑时间 2026/11/23」。
|
||||
// 因此下次可换绑 = 日界 + (窗口天数 - 1) 天;不能用 +7 天,否则会显示成 11-24。
|
||||
const offsetDays = hasPlatformWindow ? Math.max(windowDays - 1, 0) : REBIND_WINDOW_DAYS
|
||||
const nextRebindMs = changedAtMs + offsetDays * DAY_MS
|
||||
if (nextRebindMs > now) {
|
||||
return {
|
||||
days: Math.ceil((nextRebindMs - now) / DAY_MS),
|
||||
@@ -220,10 +228,8 @@ export function resolveRebindCooldown(
|
||||
}
|
||||
}
|
||||
}
|
||||
const changeBindDay = Number(response.changeBindDay || 0)
|
||||
if (Number.isFinite(changeBindDay) && changeBindDay > 0 && changeBindDay <= 30) {
|
||||
const days = Math.round(changeBindDay)
|
||||
return { days, nextRebindAt: iso(now + days * DAY_MS) }
|
||||
if (hasPlatformWindow) {
|
||||
return { days: windowDays, nextRebindAt: iso(now + windowDays * DAY_MS) }
|
||||
}
|
||||
return { days: 0, nextRebindAt: '' }
|
||||
}
|
||||
|
||||
@@ -20,6 +20,18 @@ test('换绑冷却:changeBindTime 为初次绑定时间时,下次换绑为 7
|
||||
assert.equal(result.nextRebindAt.slice(0, 10), '2026-11-23')
|
||||
})
|
||||
|
||||
test('换绑冷却:按虎牙日界推算(11-16 绑定 → 11-23 才能换绑)', () => {
|
||||
// 实测 task 34:changeBindTime = 1794844800 = 2026-11-17 00:00 +08:00,changeBindDay = 7。
|
||||
const now = Date.UTC(2026, 10, 16, 6, 31) // 2026-11-16 14:31 +08:00
|
||||
const result = resolveRebindCooldown(
|
||||
{ status: 200, changeBindDay: 7, accountData: { changeBindTime: 1794844800 } },
|
||||
now,
|
||||
)
|
||||
assert.equal(result.days, 7)
|
||||
// 2026-11-23 00:00 +08:00,与虎牙绑定页「预计下次换绑时间 2026/11/23」一致。
|
||||
assert.equal(result.nextRebindAt, '2026-11-22T16:00:00.000Z')
|
||||
})
|
||||
|
||||
test('换绑冷却:changeBindTime 已超过 7 天时不再限制', () => {
|
||||
const result = resolveRebindCooldown(
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user