feat(quality-owner): 增加优质号主自助取消与权益校验
This commit is contained in:
@@ -23,6 +23,7 @@ import { realnameStatusLabel } from '@/shared/utils/statusLabels'
|
||||
import { setPassword } from '@/features/auth/api/auth'
|
||||
import {
|
||||
activateQualityOwner,
|
||||
cancelQualityOwner,
|
||||
fetchQualityOwnerStatus,
|
||||
queryQualityOwnerPayment,
|
||||
startQualityOwnerPayment,
|
||||
@@ -38,6 +39,7 @@ const router = useRouter()
|
||||
const saving = ref(false)
|
||||
const qualityOwnerLoading = ref(false)
|
||||
const qualityOwnerOnlineLoading = ref(false)
|
||||
const qualityOwnerCancelling = ref(false)
|
||||
const qualityOwnerPayWayVisible = ref(false)
|
||||
const qualityOwnerStatus = ref<QualityOwnerStatus | null>(null)
|
||||
const uploadingAvatar = ref(false)
|
||||
@@ -154,6 +156,39 @@ async function handleQualityOwnerPaymentSucceeded() {
|
||||
await session.loadMe()
|
||||
}
|
||||
|
||||
async function handleCancelQualityOwner() {
|
||||
const status = qualityOwnerStatus.value
|
||||
if (!status?.active) return
|
||||
const activeListings = status.active_premium_listing_count || 0
|
||||
if (activeListings > 0) {
|
||||
ElMessage.warning(`极品专区还有 ${activeListings} 个进行中账号,请先下架或完成订单`)
|
||||
return
|
||||
}
|
||||
const depositHint =
|
||||
status.deposit_source === 'paid' && status.deposit_amount_cent > 0
|
||||
? `保证金 ¥${formatCent(status.deposit_amount_cent)} 将退回可用余额。`
|
||||
: '该资格由后台开通,无保证金退回。'
|
||||
try {
|
||||
await ElMessageBox.confirm(`取消后将立即失去极品专区发布权限,${depositHint}`, '取消优质号主', {
|
||||
type: 'warning',
|
||||
confirmButtonText: '确认取消',
|
||||
cancelButtonText: '暂不取消',
|
||||
})
|
||||
} catch {
|
||||
return
|
||||
}
|
||||
qualityOwnerCancelling.value = true
|
||||
try {
|
||||
qualityOwnerStatus.value = await cancelQualityOwner()
|
||||
await session.loadMe()
|
||||
ElMessage.success('优质号主已取消,极品专区权限已关闭')
|
||||
} catch (error) {
|
||||
ElMessage.error(readError(error, '取消优质号主失败,请先处理极品专区进行中账号'))
|
||||
} finally {
|
||||
qualityOwnerCancelling.value = false
|
||||
}
|
||||
}
|
||||
|
||||
function resetForm() {
|
||||
form.nickname = session.nickname || session.displayName
|
||||
form.avatar_url = session.avatarUrl || ''
|
||||
@@ -439,11 +474,28 @@ async function savePassword() {
|
||||
</div>
|
||||
<div class="quality-owner-actions">
|
||||
<span v-if="qualityOwnerStatus?.active">
|
||||
<template v-if="qualityOwnerStatus.deposit_source === 'manual'">已由后台开通</template>
|
||||
<template v-if="qualityOwnerStatus.active_premium_listing_count > 0">
|
||||
极品专区还有 {{ qualityOwnerStatus.active_premium_listing_count }}
|
||||
个进行中账号,请先处理
|
||||
</template>
|
||||
<template v-else-if="qualityOwnerStatus.deposit_source === 'manual'"
|
||||
>已由后台开通</template
|
||||
>
|
||||
<template v-else>保证金已冻结</template>
|
||||
</span>
|
||||
<span v-else>保证金取消资格时原路退回余额。</span>
|
||||
<div v-if="!qualityOwnerStatus?.active" class="quality-owner-action-buttons">
|
||||
<div v-if="qualityOwnerStatus?.active" class="quality-owner-action-buttons">
|
||||
<el-button
|
||||
type="danger"
|
||||
plain
|
||||
:loading="qualityOwnerCancelling"
|
||||
:disabled="qualityOwnerStatus.active_premium_listing_count > 0"
|
||||
@click="handleCancelQualityOwner"
|
||||
>
|
||||
取消优质号主
|
||||
</el-button>
|
||||
</div>
|
||||
<div v-else class="quality-owner-action-buttons">
|
||||
<el-button
|
||||
type="primary"
|
||||
:loading="qualityOwnerLoading"
|
||||
|
||||
Reference in New Issue
Block a user