Files
JayuCloud/YumiNail-Frontend/src/views/VipCenterView.vue
T

268 lines
10 KiB
Vue
Raw Normal View History

<template>
<div class="vip-center">
<header class="vip-header">
<button class="back-btn" type="button" @click="router.back()">‹</button>
<div>
<p>VIP 中心</p>
<h1>{{ asset?.vipLevel || '普通' }}</h1>
</div>
</header>
<main class="vip-main">
<section class="balance-panel">
<div>
<span>当前余额</span>
<strong>¥{{ money(asset?.balance) }}</strong>
</div>
<div>
<span>累计充值</span>
<strong>¥{{ money(asset?.totalRechargeAmount) }}</strong>
</div>
</section>
<a-button type="primary" size="large" block @click="rechargeOpen = true">
去充值 / 查看充值说明
</a-button>
<section class="vip-section">
<h2>会员信息</h2>
<div class="info-grid">
<div>
<span>等级</span>
<strong>{{ asset?.vipLevel || '普通' }}</strong>
</div>
<div>
<span>最近充值</span>
<strong>{{ formatTime(asset?.lastRechargeTime) }}</strong>
</div>
<div>
<span>生效时间</span>
<strong>{{ formatTime(asset?.vipStartTime) }}</strong>
</div>
<div>
<span>等级来源</span>
<strong>{{ asset?.manualOverride ? '后台指定' : '自动计算' }}</strong>
</div>
</div>
<p class="benefit">{{ asset?.benefitInfo || '暂无额外权益说明' }}</p>
</section>
<section class="vip-section">
<h2>余额变动</h2>
<a-spin :spinning="loading">
<div v-if="history.length" class="history-list">
<article v-for="item in history" :key="String(item.id)" class="history-row">
<div>
<strong>{{ sceneText(item.changeScene || item.type) }}</strong>
<span>{{ formatTime(item.changeTime) }}</span>
<em v-if="item.remark">{{ item.remark }}</em>
</div>
<b :class="{ income: Number(item.amount) > 0 }">
{{ Number(item.amount) > 0 ? '+' : '' }}¥{{ money(item.amount) }}
</b>
</article>
</div>
<a-empty v-else description="暂无余额变动" />
</a-spin>
</section>
</main>
<a-modal v-model:open="rechargeOpen" title="充值档位展示" :footer="null">
<div v-if="plans.length" class="plan-list">
<article v-for="plan in plans" :key="String(plan.id)" class="plan-card">
<div>
<strong>{{ plan.title }}</strong>
<span>{{ plan.vipLevel }}</span>
</div>
<b>充 {{ money(plan.rechargeAmount) }} 送 {{ money(plan.giftAmount) }}</b>
<p>{{ plan.description || '该档位仅展示,暂不发起支付。' }}</p>
</article>
</div>
<a-empty v-else description="暂无可展示充值档位" />
</a-modal>
</div>
</template>
<script setup lang="ts">
/**
* VipCenterView page script.
* Call guide: the template binds the reactive state below, and the methods are triggered by button clicks, lifecycle hooks, or router events.
*/
import { onMounted, ref } from 'vue'
import { useRouter } from 'vue-router'
import { message } from 'ant-design-vue'
2026-05-23 18:44:57 +08:00
/**
* Purpose: BalanceHistoryItem supports VipCenterView.vue by holding or executing the balance history item page or API role.
* Usage: import, call, read, or update this type from the owning page/module while preserving the surrounding loading and permission flow.
*/
import { userApi, type BalanceHistoryItem, type UserAssetVO, type VipRechargePlanVO } from '@/api/user'
2026-05-23 18:44:57 +08:00
/**
* Purpose: router supports VipCenterView.vue by holding or executing the router page or API role.
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
*/
const router = useRouter()
/** loading is a reactive state variable used by the template and event handlers. */
const loading = ref(false)
2026-05-23 18:44:57 +08:00
/**
* Purpose: asset supports VipCenterView.vue by holding or executing the asset page or API role.
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
*/
const asset = ref<UserAssetVO | null>(null)
2026-05-23 18:44:57 +08:00
/**
* Purpose: history supports VipCenterView.vue by holding or executing the history page or API role.
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
*/
const history = ref<BalanceHistoryItem[]>([])
2026-05-23 18:44:57 +08:00
/**
* Purpose: plans supports VipCenterView.vue by holding or executing the plans page or API role.
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
*/
const plans = ref<VipRechargePlanVO[]>([])
/** rechargeOpen is a reactive state variable used by the template and event handlers. */
const rechargeOpen = ref(false)
/** money is a local helper used by this page script. */
const money = (value?: number | string) => Number(value || 0).toFixed(2)
/** formatTime is a local helper used by this page script. */
const formatTime = (value?: string) => value ? value.replace('T', ' ').slice(0, 16) : '--'
/** sceneText is a local helper used by this page script. */
const sceneText = (scene?: string) => {
const map: Record<string, string> = {
MANUAL_RECHARGE: '手工充值',
MANUAL_DEDUCT: '手工扣减',
ORDER_PAY: '订单消费',
ORDER_REFUND: '订单退款',
RECHARGE: '充值',
CONSUME: '消费'
}
return map[scene || ''] || scene || '余额变动'
}
/** loadData is an async page action. Trigger it from the template or lifecycle hook, then await the result. */
const loadData = async () => {
loading.value = true
try {
const [assetRes, historyRes] = await Promise.all([
userApi.getMyAsset(),
userApi.getMyBalanceHistory()
])
asset.value = assetRes
history.value = historyRes || []
plans.value = await userApi.listMyVipRechargePlans().catch(() => [])
} catch (error: any) {
message.error(error?.message || '获取 VIP 信息失败')
} finally {
loading.value = false
}
}
onMounted(loadData)
</script>
<style scoped>
2026-05-29 13:30:56 +08:00
.vip-center { min-height: 100vh; background: var(--theme-page-bg); color: var(--text-primary); }
.vip-header { display: flex; gap: 16px; align-items: center; padding: 18px 18px 28px; color: #fff; background: var(--theme-gradient); }
.vip-header p { margin: 0 0 4px; opacity: .78; }
.vip-header h1 { margin: 0; font-size: 30px; font-weight: 700; }
.back-btn { width: 36px; height: 36px; border: 0; border-radius: 18px; background: rgba(255,255,255,.18); color: #fff; font-size: 28px; line-height: 1; }
.vip-main { padding: 16px; display: grid; gap: 14px; }
2026-05-29 13:30:56 +08:00
.balance-panel { display: grid; grid-template-columns: 1fr 1fr; gap: 1px; overflow: hidden; border-radius: 8px; background: var(--theme-border); }
.balance-panel > div { padding: 18px; background: var(--theme-card-bg); }
.balance-panel span, .info-grid span, .history-row span { display: block; color: var(--text-secondary); font-size: 12px; }
.balance-panel strong { display: block; margin-top: 8px; font-size: 24px; }
2026-05-29 13:30:56 +08:00
.vip-section { padding: 18px; border-radius: 8px; background: var(--theme-card-bg); border: 1px solid var(--theme-border); }
.vip-section h2 { margin: 0 0 14px; font-size: 17px; }
.info-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.info-grid strong { display: block; margin-top: 5px; font-size: 14px; }
2026-05-29 13:30:56 +08:00
.benefit { margin: 16px 0 0; padding-top: 14px; border-top: 1px solid var(--theme-border); color: var(--text-secondary); }
.history-list { display: grid; gap: 12px; }
2026-05-29 13:30:56 +08:00
.history-row { display: flex; justify-content: space-between; gap: 12px; padding-bottom: 12px; border-bottom: 1px solid var(--theme-border); }
.history-row:last-child { border-bottom: 0; padding-bottom: 0; }
2026-05-29 13:30:56 +08:00
.history-row em { display: block; margin-top: 4px; color: var(--text-secondary); font-style: normal; font-size: 12px; }
.history-row b { color: var(--text-primary); white-space: nowrap; }
.history-row b.income { color: #0f8f63; }
.plan-list { display: grid; gap: 12px; }
2026-05-29 13:30:56 +08:00
.plan-card { padding: 14px; border-radius: 8px; border: 1px solid var(--theme-border); background: var(--theme-gradient-soft); }
.plan-card div { display: flex; justify-content: space-between; gap: 12px; }
2026-05-29 13:30:56 +08:00
.plan-card span { color: var(--theme-primary); }
.plan-card b { display: block; margin-top: 8px; font-size: 18px; }
2026-05-29 13:30:56 +08:00
.plan-card p { margin: 8px 0 0; color: var(--text-secondary); }
.vip-center {
background:
radial-gradient(circle at 82% 0%, color-mix(in srgb, var(--theme-primary) 26%, transparent), transparent 32%),
linear-gradient(180deg, color-mix(in srgb, var(--theme-card-bg) 72%, transparent), var(--theme-page-bg));
}
.vip-header {
padding: 18px 18px 34px;
color: var(--text-primary);
background: transparent;
}
.vip-header p {
color: var(--theme-secondary);
font-family: Georgia, 'Times New Roman', serif;
font-weight: 800;
}
.vip-header h1 {
font-size: 32px;
font-weight: 860;
}
.back-btn {
color: var(--theme-primary-action);
background: color-mix(in srgb, var(--theme-card-bg) 80%, transparent);
box-shadow: 0 12px 24px color-mix(in srgb, var(--theme-neutral) 8%, transparent);
}
.vip-main {
padding: 0 18px 34px;
gap: 16px;
}
.balance-panel {
gap: 0;
border: 1px solid color-mix(in srgb, var(--theme-secondary) 24%, var(--theme-border));
border-radius: 26px;
background: linear-gradient(135deg, color-mix(in srgb, var(--theme-primary) 20%, var(--theme-card-bg)), color-mix(in srgb, var(--theme-secondary) 18%, var(--theme-card-bg)));
box-shadow: 0 22px 46px color-mix(in srgb, var(--theme-neutral) 10%, transparent);
}
.balance-panel > div {
background: transparent;
}
.balance-panel strong {
color: var(--theme-primary-action);
font-family: Georgia, 'Times New Roman', serif;
}
.vip-section {
border-radius: 24px;
background: color-mix(in srgb, var(--theme-card-bg) 90%, transparent);
box-shadow: 0 18px 42px color-mix(in srgb, var(--theme-neutral) 8%, transparent);
}
.vip-section h2 {
font-weight: 820;
}
.info-grid > div,
.history-row,
.plan-card {
border-radius: 18px;
}
.history-row b.income {
color: var(--theme-primary-action);
}
:deep(.ant-btn-primary) {
border-color: transparent;
background: linear-gradient(135deg, var(--theme-primary-action), var(--theme-secondary));
}
</style>