feat(mobile): 拆分独立权益中心页面

This commit is contained in:
yml
2026-11-16 18:38:34 +08:00
parent 4ce104f7e8
commit fed950ea5a
3 changed files with 711 additions and 72 deletions
@@ -14,14 +14,12 @@ import {
} from '@/features/quality-owner/api/qualityOwner'
import { readError } from '@/shared/utils/error'
const props = withDefaults(defineProps<{ mobile?: boolean }>(), { mobile: false })
const router = useRouter()
const loading = ref(true)
const errorMessage = ref('')
const summary = ref<PointsSummary | null>(null)
const qualityOwner = ref<QualityOwnerStatus | null>(null)
const selectedLevelCode = ref('')
const isMobile = computed(() => props.mobile)
const levels = computed(() => summary.value?.levels || [])
const currentLevel = computed(
@@ -75,15 +73,15 @@ function selectLevel(level: GrowthLevelRule) {
}
function goBack() {
router.push(isMobile.value ? '/m/profile' : '/profile')
router.push('/profile')
}
function openPointsMall() {
router.push(isMobile.value ? '/m/points-mall' : '/points-mall')
router.push('/points-mall')
}
function openQualityOwner() {
router.push(isMobile.value ? '/m/profile' : '/profile')
router.push('/profile')
}
function multiplierText(level: GrowthLevelRule | null) {
@@ -122,7 +120,7 @@ function formatBps(value: number | undefined, fallback: number) {
</script>
<template>
<main class="benefits-center" :class="{ 'is-mobile': isMobile }">
<main class="benefits-center">
<header class="benefits-header">
<button type="button" class="back-button" @click="goBack">返回</button>
<div>
@@ -860,70 +858,6 @@ function formatBps(value: number | undefined, fallback: number) {
color: #b91c1c;
}
.benefits-center.is-mobile {
padding: 18px 12px 90px;
}
.is-mobile .benefits-header h1 {
font-size: 24px;
}
.is-mobile .vip-overview,
.is-mobile .benefit-grid {
grid-template-columns: 1fr;
}
.is-mobile .vip-copy {
padding: 22px;
}
.is-mobile .vip-copy h2 {
font-size: 24px;
}
.is-mobile .vip-stats {
border-top: 1px solid #f1f2f5;
}
.is-mobile .level-section {
padding: 18px 14px;
}
.is-mobile .section-heading {
display: grid;
align-items: start;
}
.is-mobile .level-tabs {
grid-template-columns: repeat(2, minmax(0, 1fr));
}
.is-mobile .level-benefits {
grid-template-columns: repeat(2, minmax(0, 1fr));
}
.is-mobile .level-benefits > div:nth-child(odd) {
border-left: 0;
}
.is-mobile .level-benefits > div:nth-child(n + 3) {
border-top: 1px solid #f1f2f5;
}
.is-mobile .quality-owner-benefit,
.is-mobile .points-benefit {
padding: 18px;
}
.is-mobile .quality-metrics {
grid-template-columns: 1fr;
}
.is-mobile .quality-action,
.is-mobile .points-action {
width: 100%;
}
@media (max-width: 900px) {
.vip-overview,
.benefit-grid {
@@ -0,0 +1,706 @@
<script setup lang="ts">
import { computed, onMounted, ref } from 'vue'
import { useRouter } from 'vue-router'
import MobileBottomNav from '@/components/MobileBottomNav.vue'
import {
fetchPointsSummary,
type GrowthLevelRule,
type PointsSummary,
} from '@/features/points/api/pointsMall'
import {
fetchQualityOwnerStatus,
type QualityOwnerStatus,
} from '@/features/quality-owner/api/qualityOwner'
import { readError } from '@/shared/utils/error'
const router = useRouter()
const loading = ref(true)
const errorMessage = ref('')
const summary = ref<PointsSummary | null>(null)
const qualityOwner = ref<QualityOwnerStatus | null>(null)
const selectedLevelCode = ref('')
const levels = computed(() => summary.value?.levels || [])
const currentLevel = computed(
() =>
levels.value.find(level => level.code === summary.value?.level_code) || levels.value[0] || null
)
const selectedLevel = computed(
() => levels.value.find(level => level.code === selectedLevelCode.value) || currentLevel.value
)
const nextLevel = computed(() => {
const current = currentLevel.value
if (!current) return null
const index = levels.value.findIndex(level => level.code === current.code)
return levels.value[index + 1] || null
})
const levelProgress = computed(() => {
if (!summary.value || !currentLevel.value || !nextLevel.value) return 100
const range = nextLevel.value.min_points - currentLevel.value.min_points
if (range <= 0) return 100
const progress = ((summary.value.lifetime_points - currentLevel.value.min_points) / range) * 100
return Math.min(100, Math.max(0, progress))
})
const pointsToNextLevel = computed(() => {
if (!summary.value || !nextLevel.value) return 0
return Math.max(0, nextLevel.value.min_points - summary.value.lifetime_points)
})
const qualityOwnerActive = computed(() => Boolean(qualityOwner.value?.active))
onMounted(load)
async function load() {
loading.value = true
errorMessage.value = ''
try {
const [nextSummary, nextQualityOwner] = await Promise.all([
fetchPointsSummary(),
fetchQualityOwnerStatus(),
])
summary.value = nextSummary
qualityOwner.value = nextQualityOwner
selectedLevelCode.value = nextSummary.level_code || nextSummary.levels[0]?.code || ''
} catch (error) {
errorMessage.value = readError(error, '权益中心加载失败')
} finally {
loading.value = false
}
}
function selectLevel(level: GrowthLevelRule) {
selectedLevelCode.value = level.code
}
function multiplierText(level: GrowthLevelRule | null) {
if (!level) return '-'
return `${(level.points_multiplier_bps / 10000).toFixed(2)}x`
}
function payRatioText(level: GrowthLevelRule | null) {
if (!level) return '-'
const ratio = level.discount_bps / 100
return ratio >= 100 ? '原价' : `${ratio.toFixed(2).replace(/\.?0+$/, '')}%`
}
function discountText(level: GrowthLevelRule | null) {
if (!level || level.discount_bps >= 10000) return '暂无租金折扣'
const discount = (10000 - level.discount_bps) / 100
return `租金立省 ${discount.toFixed(2).replace(/\.?0+$/, '')}%`
}
function quotaText(level: GrowthLevelRule | null) {
if (!level || level.deposit_free_quota_cent <= 0) return '暂无等级免押额度'
return `享 ¥${formatCent(level.deposit_free_quota_cent)} 免押额度`
}
function formatCent(value: number) {
return (value / 100).toLocaleString('zh-CN', {
minimumFractionDigits: 0,
maximumFractionDigits: 2,
})
}
function formatBps(value: number | undefined, fallback: number) {
const amount = (value ?? fallback) / 100
return `${amount.toFixed(amount % 1 === 0 ? 0 : 1)}%`
}
</script>
<template>
<main class="mobile-benefits">
<header class="mobile-header">
<button
type="button"
class="back-button"
aria-label="返回"
@click="router.push('/m/profile')"
>
<van-icon name="arrow-left" :size="20" />
</button>
<h1>权益中心</h1>
<span class="header-spacer"></span>
</header>
<div class="benefits-content">
<section class="page-intro">
<span>MEMBER BENEFITS</span>
<p>VIP 成长、优质号主和积分商城权益集中查看。</p>
</section>
<div v-if="errorMessage" class="notice is-error">{{ errorMessage }}</div>
<van-loading v-if="loading" class="page-loading" vertical>加载中...</van-loading>
<template v-else-if="summary">
<section class="summary-card">
<span class="section-kicker">VIP PROGRAM</span>
<h2>{{ summary.level_name }}会员</h2>
<p v-if="!summary.growth_enabled">积分等级权益当前暂未启用。</p>
<p v-else-if="nextLevel">
再获得 <strong>{{ pointsToNextLevel }}</strong> 积分升级为
<strong>{{ nextLevel.name }}</strong>
</p>
<p v-else>已达到最高等级,积分仍可用于商城兑换。</p>
<div class="progress-head">
<span>当前累计 {{ summary.lifetime_points }} 积分</span>
<span v-if="nextLevel">目标 {{ nextLevel.min_points }}</span>
<span v-else>已满级</span>
</div>
<div class="progress-track">
<span :style="{ width: `${levelProgress}%` }"></span>
</div>
<div class="summary-stats">
<div>
<span>当前等级</span>
<strong>{{ summary.level_name }}</strong>
</div>
<div>
<span>积分倍率</span>
<strong>{{ multiplierText(currentLevel) }}</strong>
</div>
<div>
<span>可用积分</span>
<strong>{{ summary.available_points }}</strong>
</div>
<div>
<span>积分规则</span>
<strong>¥1 = {{ summary.points_per_yuan }}</strong>
</div>
</div>
</section>
<section class="panel level-panel">
<div class="panel-heading">
<div>
<span class="section-kicker">VIP LEVELS</span>
<h2>成长等级权益</h2>
</div>
<small>积分只增不减</small>
</div>
<div class="level-tabs">
<button
v-for="level in levels"
:key="level.code"
type="button"
:class="{
active: selectedLevel?.code === level.code,
current: currentLevel?.code === level.code,
}"
@click="selectLevel(level)"
>
<span>{{ level.name }}</span>
<small>{{ level.min_points }} 积分</small>
<em v-if="currentLevel?.code === level.code">当前</em>
</button>
</div>
<template v-if="selectedLevel">
<div class="selected-level-head">
<div>
<strong>{{ selectedLevel.name }}等级权益</strong>
<span>{{ selectedLevel.min_points }} 积分起</span>
</div>
<em>
{{ currentLevel?.code === selectedLevel.code ? '当前等级' : '等级预览' }}
</em>
</div>
<div class="level-benefit-grid">
<div>
<van-icon name="medal-o" :size="18" />
<span>积分加速</span>
<strong>{{ multiplierText(selectedLevel) }}</strong>
<small>消费获得积分时按该倍率累计</small>
</div>
<div>
<van-icon name="gift-o" :size="18" />
<span>租金权益</span>
<strong>{{ payRatioText(selectedLevel) }}</strong>
<small>{{ discountText(selectedLevel) }}</small>
</div>
<div>
<van-icon name="passed" :size="18" />
<span>等级免押</span>
<strong>
{{
selectedLevel.deposit_free_quota_cent > 0
? `¥${formatCent(selectedLevel.deposit_free_quota_cent)}`
: '¥0'
}}
</strong>
<small>{{ quotaText(selectedLevel) }}</small>
</div>
<div>
<van-icon name="shop-o" :size="18" />
<span>积分商城</span>
<strong>全场开放</strong>
<small>租客和卖家均可兑换</small>
</div>
</div>
</template>
</section>
<section class="panel">
<div class="benefit-heading">
<span class="benefit-icon">
<van-icon name="medal-o" :size="18" />
</span>
<div>
<span class="section-kicker">PREMIUM OWNER</span>
<h2>优质号主</h2>
</div>
<em :class="{ active: qualityOwnerActive }">
{{ qualityOwnerActive ? '已开通' : '未开通' }}
</em>
</div>
<p class="benefit-copy">开通后可发布到极品专区,并享受优质号主专享保险服务费率。</p>
<div class="metric-strip">
<div>
<span>保证金</span>
<strong>¥{{ formatCent(qualityOwner?.required_deposit_cent || 20000) }}</strong>
</div>
<div>
<span>普通保险</span>
<strong>{{ formatBps(qualityOwner?.insurance_fee_bps, 800) }}</strong>
</div>
<div>
<span>专区保险</span>
<strong>{{ formatBps(qualityOwner?.premium_insurance_fee_bps, 400) }}</strong>
</div>
</div>
<button type="button" class="panel-action" @click="router.push('/m/profile')">
{{ qualityOwnerActive ? '管理优质号主' : '前往开通' }}
<van-icon name="arrow" :size="10" />
</button>
</section>
<section class="panel">
<div class="benefit-heading">
<span class="benefit-icon">
<van-icon name="shop-o" :size="18" />
</span>
<div>
<span class="section-kicker">POINTS MALL</span>
<h2>积分商城</h2>
</div>
<em>持续开放</em>
</div>
<p class="benefit-copy">
租客按实际租金支出、卖家按租金收入获得积分,可兑换虚拟权益与优惠商品。
</p>
<div class="points-summary">
<div>
<span>可用积分</span>
<strong>{{ summary.available_points }}</strong>
</div>
<div>
<span>累计积分</span>
<strong>{{ summary.lifetime_points }}</strong>
</div>
</div>
<button type="button" class="panel-action" @click="router.push('/m/points-mall')">
进入积分商城
<van-icon name="arrow" :size="10" />
</button>
</section>
</template>
</div>
<MobileBottomNav />
</main>
</template>
<style scoped>
.mobile-benefits {
min-height: 100dvh;
padding-bottom: calc(52px + env(safe-area-inset-bottom));
background: #f4f4f2;
color: #252a31;
--van-primary-color: #a95522;
}
.mobile-header {
position: sticky;
top: 0;
z-index: 100;
display: grid;
grid-template-columns: 38px minmax(0, 1fr) 38px;
align-items: center;
height: 52px;
padding: 0 10px;
border-bottom: 1px solid #ececea;
background: rgba(255, 255, 255, 0.96);
box-shadow: 0 1px 8px rgba(26, 28, 31, 0.03);
backdrop-filter: blur(12px);
}
.mobile-header h1 {
margin: 0;
color: #24282d;
font-size: 17px;
font-weight: 700;
text-align: center;
}
.back-button {
display: grid;
width: 34px;
height: 34px;
place-items: center;
border: 1px solid #ececea;
border-radius: 8px;
background: #f7f7f5;
color: #4f555b;
}
.header-spacer {
width: 38px;
}
.benefits-content {
padding: 12px;
}
.page-intro {
padding: 2px 2px 10px;
}
.page-intro span,
.section-kicker {
color: #a95522;
font-size: 10px;
font-weight: 700;
letter-spacing: 0.04em;
}
.page-intro p {
margin: 5px 0 0;
color: #747980;
font-size: 12px;
line-height: 1.5;
}
.notice {
margin: 10px 0;
padding: 16px;
border: 1px solid #e5e4e1;
border-radius: 8px;
background: #ffffff;
color: #747980;
text-align: center;
}
.notice.is-error {
color: #985858;
}
.page-loading {
display: flex;
justify-content: center;
padding: 70px 0;
}
.summary-card,
.panel {
margin-bottom: 10px;
padding: 14px;
border: 1px solid #e5e4e1;
border-radius: 8px;
background: #ffffff;
box-shadow: 0 4px 14px rgba(28, 31, 35, 0.03);
}
.summary-card h2,
.panel h2 {
margin: 4px 0 0;
color: #252a31;
font-size: 20px;
font-weight: 700;
}
.summary-card > p {
margin: 8px 0 0;
color: #747980;
font-size: 12px;
}
.summary-card > p strong {
color: #9c542b;
}
.progress-head {
display: flex;
justify-content: space-between;
gap: 10px;
margin-top: 16px;
color: #8a8f95;
font-size: 10px;
}
.progress-track {
height: 6px;
margin-top: 6px;
overflow: hidden;
border-radius: 999px;
background: #f0ece8;
}
.progress-track span {
display: block;
height: 100%;
border-radius: inherit;
background: #b96538;
}
.summary-stats {
display: grid;
grid-template-columns: repeat(2, minmax(0, 1fr));
margin-top: 14px;
border-top: 1px solid #eeeeec;
border-left: 1px solid #eeeeec;
}
.summary-stats > div {
display: grid;
gap: 4px;
padding: 10px;
border-right: 1px solid #eeeeec;
border-bottom: 1px solid #eeeeec;
}
.summary-stats span,
.level-benefit-grid span,
.metric-strip span,
.points-summary span {
color: #8a8f95;
font-size: 10px;
}
.summary-stats strong {
color: #454b52;
font-size: 17px;
}
.panel-heading,
.benefit-heading {
display: flex;
align-items: center;
justify-content: space-between;
gap: 10px;
}
.panel-heading small {
color: #92979c;
font-size: 10px;
}
.level-tabs {
display: flex;
gap: 7px;
margin: 13px 0;
padding-bottom: 2px;
overflow-x: auto;
scrollbar-width: none;
}
.level-tabs::-webkit-scrollbar {
display: none;
}
.level-tabs button {
position: relative;
display: grid;
flex: 0 0 96px;
gap: 3px;
min-height: 58px;
padding: 9px;
border: 1px solid #e7e6e3;
border-radius: 6px;
background: #f8f8f6;
color: #5e646b;
text-align: left;
}
.level-tabs button span {
font-size: 13px;
font-weight: 700;
}
.level-tabs button small {
color: #92979c;
font-size: 9px;
}
.level-tabs button em {
position: absolute;
top: 7px;
right: 7px;
color: #9c542b;
font-size: 8px;
font-style: normal;
font-weight: 700;
}
.level-tabs button.active {
border-color: #d8b9a4;
background: #fbf6f2;
color: #8d461c;
}
.selected-level-head {
display: flex;
align-items: center;
justify-content: space-between;
gap: 10px;
padding: 10px 0;
border-top: 1px solid #eeeeec;
}
.selected-level-head > div {
display: grid;
gap: 2px;
}
.selected-level-head strong {
color: #454b52;
font-size: 12px;
}
.selected-level-head span {
color: #92979c;
font-size: 9px;
}
.selected-level-head em,
.benefit-heading em {
padding: 3px 7px;
border-radius: 999px;
background: #f8f1eb;
color: #96542f;
font-size: 9px;
font-style: normal;
font-weight: 600;
white-space: nowrap;
}
.benefit-heading em.active {
background: #eef4ef;
color: #55705d;
}
.level-benefit-grid {
display: grid;
grid-template-columns: repeat(2, minmax(0, 1fr));
border-top: 1px solid #eeeeec;
border-left: 1px solid #eeeeec;
}
.level-benefit-grid > div {
display: grid;
gap: 4px;
padding: 11px;
border-right: 1px solid #eeeeec;
border-bottom: 1px solid #eeeeec;
}
.level-benefit-grid .van-icon,
.benefit-icon {
color: #a65b31;
}
.level-benefit-grid strong {
color: #8d461c;
font-size: 15px;
}
.level-benefit-grid small {
color: #92979c;
font-size: 9px;
line-height: 1.45;
}
.benefit-heading {
justify-content: flex-start;
}
.benefit-heading > div {
min-width: 0;
}
.benefit-heading > em {
margin-left: auto;
}
.benefit-icon {
display: grid;
flex: 0 0 34px;
width: 34px;
height: 34px;
place-items: center;
border-radius: 8px;
background: #f7f1eb;
}
.benefit-copy {
margin: 9px 0 0;
color: #747980;
font-size: 11px;
line-height: 1.6;
}
.metric-strip,
.points-summary {
display: grid;
margin-top: 11px;
border-top: 1px solid #eeeeec;
border-left: 1px solid #eeeeec;
}
.metric-strip {
grid-template-columns: repeat(3, minmax(0, 1fr));
}
.points-summary {
grid-template-columns: repeat(2, minmax(0, 1fr));
}
.metric-strip > div,
.points-summary > div {
display: grid;
gap: 3px;
padding: 9px;
border-right: 1px solid #eeeeec;
border-bottom: 1px solid #eeeeec;
}
.metric-strip strong,
.points-summary strong {
color: #6f5645;
font-size: 14px;
}
.points-summary strong {
color: #9c542b;
font-size: 18px;
}
.panel-action {
display: inline-flex;
min-height: 34px;
align-items: center;
justify-content: center;
gap: 5px;
margin-top: 11px;
padding: 0 12px;
border: 1px solid #a95522;
border-radius: 6px;
background: #a95522;
color: #ffffff;
font: inherit;
font-size: 11px;
font-weight: 600;
}
</style>
+1 -2
View File
@@ -92,9 +92,8 @@ export const mobileRoutes: RouteRecordRaw[] = [
{
path: '/m/benefits',
name: 'mobile-benefits',
component: () => import('@/features/benefits/views/BenefitsCenterView.vue'),
component: () => import('@/features/benefits/views/MobileBenefitsCenterView.vue'),
meta: { layout: 'blank', requiresAuth: true },
props: { mobile: true },
},
{
path: '/m/profile',