优化领取页角色绑定校验
This commit is contained in:
@@ -93,6 +93,12 @@ export interface ClaimKuaishouCloudFlowInfo {
|
||||
rid: string
|
||||
refreshedAt: string | null
|
||||
errorMessage: string
|
||||
defaultName: string
|
||||
defaultRid: string
|
||||
defaultCapturedAt: string | null
|
||||
defaultCaptureStatus: string
|
||||
defaultErrorMessage: string
|
||||
isDefaultRole: boolean
|
||||
}
|
||||
purchase: {
|
||||
autoBuyEnabled: boolean
|
||||
|
||||
@@ -51,7 +51,8 @@ const claim = useKuaishouCloudClaim(() => props.token)
|
||||
:qr-code-data-url="claim.qrCodeDataUrl.value"
|
||||
:is-binding-prepared="claim.isBindingPrepared.value"
|
||||
:is-binding-preparing="claim.isBindingPreparing.value"
|
||||
:is-role-ready="claim.isRoleReady.value"
|
||||
:is-customer-role-ready="claim.isCustomerRoleReady.value"
|
||||
:confirm-role-disabled-reason="claim.confirmRoleDisabledReason.value"
|
||||
:role-name="claim.roleName.value"
|
||||
:role-id="claim.roleId.value"
|
||||
:refreshing-role="claim.refreshingRole.value"
|
||||
|
||||
@@ -7,7 +7,8 @@ defineProps<{
|
||||
qrCodeDataUrl: string
|
||||
isBindingPrepared: boolean
|
||||
isBindingPreparing: boolean
|
||||
isRoleReady: boolean
|
||||
isCustomerRoleReady: boolean
|
||||
confirmRoleDisabledReason: string
|
||||
roleName: string
|
||||
roleId: string
|
||||
refreshingRole: boolean
|
||||
@@ -41,7 +42,7 @@ defineEmits<{
|
||||
<span>系统正在准备绑定资源,请稍后自动刷新。</span>
|
||||
</div>
|
||||
|
||||
<div class="role-panel" :class="{ pending: !isRoleReady }">
|
||||
<div class="role-panel" :class="{ pending: !isCustomerRoleReady }">
|
||||
<div class="role-panel__item">
|
||||
<span>当前角色</span>
|
||||
<strong>{{ roleName || '待识别' }}</strong>
|
||||
@@ -52,6 +53,10 @@ defineEmits<{
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-if="flow.role.isDefaultRole" class="status-banner warning">
|
||||
<span>当前仍是虚拟机默认角色,请重新绑定自己的角色信息。</span>
|
||||
</div>
|
||||
|
||||
<div class="action-row">
|
||||
<el-button size="large" plain :loading="refreshingRole" @click="$emit('refreshRole')">
|
||||
<el-icon><RefreshRight /></el-icon>
|
||||
@@ -66,15 +71,23 @@ defineEmits<{
|
||||
>
|
||||
换绑角色
|
||||
</el-button>
|
||||
<el-button
|
||||
type="primary"
|
||||
size="large"
|
||||
:loading="confirmingRole"
|
||||
:disabled="!isBindingPrepared || !isRoleReady || rebindingRole"
|
||||
@click="$emit('confirmRole')"
|
||||
<el-tooltip
|
||||
:disabled="!confirmRoleDisabledReason"
|
||||
:content="confirmRoleDisabledReason"
|
||||
placement="top"
|
||||
>
|
||||
我已完成绑定,下一步
|
||||
</el-button>
|
||||
<span class="action-tooltip-wrap">
|
||||
<el-button
|
||||
type="primary"
|
||||
size="large"
|
||||
:loading="confirmingRole"
|
||||
:disabled="Boolean(confirmRoleDisabledReason)"
|
||||
@click="$emit('confirmRole')"
|
||||
>
|
||||
我已完成绑定,下一步
|
||||
</el-button>
|
||||
</span>
|
||||
</el-tooltip>
|
||||
</div>
|
||||
|
||||
<div class="meta-footer">
|
||||
@@ -127,6 +140,11 @@ defineEmits<{
|
||||
color: #1d4ed8;
|
||||
}
|
||||
|
||||
.status-banner.warning {
|
||||
background: #fff7ed;
|
||||
color: #c2410c;
|
||||
}
|
||||
|
||||
.qr-block {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
@@ -239,6 +257,10 @@ defineEmits<{
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
.action-tooltip-wrap {
|
||||
display: inline-flex;
|
||||
}
|
||||
|
||||
.action-row :deep(.el-button) {
|
||||
margin-left: 0;
|
||||
}
|
||||
|
||||
@@ -76,6 +76,31 @@ export function useKuaishouCloudClaim(token: () => string) {
|
||||
const isBindingPreparing = computed(() => flow.value?.binding.prepareStatus === 'pending')
|
||||
const canEnterBindingStep = computed(() => isTicketVerified.value)
|
||||
const isRoleReady = computed(() => Boolean(roleName.value || roleId.value))
|
||||
const hasDefaultRoleSnapshot = computed(() =>
|
||||
Boolean(flow.value?.role.defaultName || flow.value?.role.defaultRid),
|
||||
)
|
||||
const isDefaultRole = computed(() => flow.value?.role.isDefaultRole === true)
|
||||
const isCustomerRoleReady = computed(
|
||||
() => isRoleReady.value && hasDefaultRoleSnapshot.value && !isDefaultRole.value,
|
||||
)
|
||||
const confirmRoleDisabledReason = computed(() => {
|
||||
if (!isBindingPrepared.value) {
|
||||
return '绑定二维码还在准备中,请稍后自动刷新'
|
||||
}
|
||||
if (!hasDefaultRoleSnapshot.value) {
|
||||
return flow.value?.role.defaultErrorMessage || '系统还未获取到虚拟机默认角色信息,请稍后刷新'
|
||||
}
|
||||
if (!isRoleReady.value) {
|
||||
return '请先扫码绑定自己的角色,并刷新角色信息'
|
||||
}
|
||||
if (isDefaultRole.value) {
|
||||
return '当前仍是虚拟机默认角色,请重新绑定自己的角色信息'
|
||||
}
|
||||
if (rebindingRole.value) {
|
||||
return '正在换绑角色,请稍候'
|
||||
}
|
||||
return ''
|
||||
})
|
||||
const isRoleConfirmed = computed(() => isKuaishouCloudRoleConfirmedStatus(task.value?.status))
|
||||
const isDispatched = computed(
|
||||
() => String(flow.value?.dispatch.status || '').trim() === 'success',
|
||||
@@ -239,11 +264,15 @@ export function useKuaishouCloudClaim(token: () => string) {
|
||||
refreshingRole.value = true
|
||||
try {
|
||||
await loadDetail({ silent: true })
|
||||
if (isRoleReady.value) {
|
||||
if (isCustomerRoleReady.value) {
|
||||
showSuccess('角色信息已刷新')
|
||||
} else if (isDefaultRole.value) {
|
||||
showError('当前仍是虚拟机默认角色,请重新绑定自己的角色信息')
|
||||
} else {
|
||||
showError(
|
||||
flow.value?.role.errorMessage || '暂时还没有识别到角色信息,请完成绑定后稍等片刻再试',
|
||||
flow.value?.role.errorMessage ||
|
||||
flow.value?.role.defaultErrorMessage ||
|
||||
'暂时还没有识别到角色信息,请完成绑定后稍等片刻再试',
|
||||
)
|
||||
}
|
||||
} finally {
|
||||
@@ -441,6 +470,10 @@ export function useKuaishouCloudClaim(token: () => string) {
|
||||
isBindingPreparing,
|
||||
canEnterBindingStep,
|
||||
isRoleReady,
|
||||
hasDefaultRoleSnapshot,
|
||||
isDefaultRole,
|
||||
isCustomerRoleReady,
|
||||
confirmRoleDisabledReason,
|
||||
isRoleConfirmed,
|
||||
isDispatched,
|
||||
isRedeemFailed,
|
||||
|
||||
Reference in New Issue
Block a user