文件
OmniCard/mpuniapp/pages/owner/team/overview.uvue

895 行
22 KiB
Plaintext

<template>
<view class="overview-page" :class="pageRtlClass" :style="pageTheme">
<!-- Ambient Aurora Top Glow -->
<view class="overview-aurora-glow"></view>
<!-- Header Cockpit: Bento Briefing Hero -->
<view class="overview-header">
<view class="header-live-bar">
<view class="live-pill">
<view class="live-pulse-dot"></view>
<text class="live-pill-text">{{ t('liveBadge') }}</text>
</view>
<view class="sync-pill">
<text class="sync-pill-text">{{ t('syncTime') }}</text>
</view>
</view>
<text class="overview-title">{{ pageTitle }}</text>
<text class="overview-desc">{{ pageDesc }}</text>
</view>
<!-- Loading Skeleton Cards -->
<view v-if="state.loading" class="overview-skeleton">
<view class="skeleton-pill"></view>
<view class="skeleton-grid">
<view class="skeleton-grid-card"></view>
<view class="skeleton-grid-card"></view>
<view class="skeleton-grid-card"></view>
<view class="skeleton-grid-card"></view>
</view>
<view class="skeleton-row-card"></view>
<view class="skeleton-row-card"></view>
</view>
<!-- Overview Body -->
<view v-else class="overview-body">
<!-- Error Notification Banner -->
<view v-if="state.errorMessage !== ''" class="overview-feedback">
<view class="feedback-indicator"></view>
<view class="feedback-info">
<text class="feedback-title">{{ t('error') }}</text>
<text class="feedback-desc">{{ state.errorMessage }}</text>
</view>
</view>
<!-- Bento Grid Metrics (2x2 Modular Pyramid) -->
<view class="metrics-grid">
<!-- Bento 1: Hot Intent Leads (High Priority Focus) -->
<view class="metric-card metric-card-hot">
<view class="metric-top-row">
<text class="metric-label metric-label-hot">{{ t('hotCount') }}</text>
<view class="hot-spark-dot"></view>
</view>
<text class="metric-value metric-value-hot">{{ state.summary.hotCount }}</text>
<view class="metric-bottom-row">
<text class="metric-sub-label">{{ leadsLabel }}</text>
</view>
</view>
<!-- Bento 2: Total Leads Converted -->
<view class="metric-card">
<view class="metric-top-row">
<text class="metric-label">{{ leadsLabel }}</text>
</view>
<text class="metric-value metric-value-primary">{{ state.summary.totalLeads }}</text>
<view class="metric-bottom-row">
<text class="metric-sub-label">{{ t('leadsUnit') }}</text>
</view>
</view>
<!-- Bento 3: Total Visitor Interaction Touches -->
<view class="metric-card">
<view class="metric-top-row">
<text class="metric-label">{{ tracksLabel }}</text>
</view>
<text class="metric-value">{{ state.summary.totalTracks }}</text>
<view class="metric-bottom-row">
<text class="metric-sub-label">{{ t('touchesUnit') }}</text>
</view>
</view>
<!-- Bento 4: Core Market Country -->
<view class="metric-card">
<view class="metric-top-row">
<text class="metric-label">{{ t('topCountry') }}</text>
</view>
<text class="metric-value" :class="countryValueClass">{{ countryText }}</text>
<view class="metric-bottom-row">
<text class="metric-sub-label">{{ tracksLabel }}</text>
</view>
</view>
</view>
<!-- Section: Floor Ranking Leaderboard (List View 1) -->
<view class="recent-section">
<view class="section-title-wrap">
<text class="section-title">{{ t('rankTitle') }}</text>
<view v-if="state.ranks.length > 0" class="section-badge">
<text class="section-badge-text">{{ state.ranks.length }}</text>
</view>
</view>
<list-view v-if="state.ranks.length > 0" class="recent-list">
<list-item v-for="item in state.ranks" :key="item.memberId">
<view class="rank-row">
<view class="rank-badge" :class="rankBadgeClass(item.rank)">
<text class="rank-no">{{ item.rank }}</text>
</view>
<view class="rank-avatar">
<text class="rank-avatar-text">{{ getInitial(item.memberName) }}</text>
</view>
<view class="rank-main">
<view class="rank-header-row">
<text class="rank-name">{{ item.memberName }}</text>
<text v-if="item.rank === 1" class="champion-pill">{{ t('championBadge') }}</text>
</view>
<text class="rank-meta">{{ formatRankMeta(item) }}</text>
</view>
<view class="rank-score-box">
<text class="rank-score-num">{{ item.score }}</text>
<text class="rank-score-unit">{{ t('scoreUnit') }}</text>
</view>
</view>
</list-item>
</list-view>
<view v-else class="overview-empty">
<view class="empty-halo"></view>
<text class="empty-sentence">{{ t('empty') }}</text>
<text class="empty-hint">{{ t('liveBadge') }}</text>
</view>
</view>
<!-- Section: Real-time Follow-up Stream (List View 2) -->
<view class="recent-section">
<view class="section-title-wrap">
<text class="section-title">{{ recentLabel }}</text>
<view v-if="state.leads.length > 0" class="section-badge">
<text class="section-badge-text">{{ state.leads.length }}</text>
</view>
</view>
<view v-if="state.leads.length === 0" class="overview-empty">
<view class="empty-halo"></view>
<text class="empty-sentence">{{ t('empty') }}</text>
<text class="empty-hint">{{ t('emptyLeads') }}</text>
</view>
<list-view v-else class="recent-list">
<list-item v-for="item in state.leads" :key="item.id">
<view class="lead-row">
<view class="lead-avatar">
<text class="lead-avatar-text">{{ getInitial(item.name) }}</text>
</view>
<view class="lead-main">
<view class="lead-title-row">
<text class="lead-name">{{ item.name }}</text>
</view>
<text class="lead-company">{{ item.company }}</text>
</view>
<view
class="lead-status-box"
:class="{ 'lead-status-box-hot': item.status === 'hot' }"
>
<view v-if="item.status === 'hot'" class="status-hot-dot"></view>
<text
class="lead-status"
:class="{ 'lead-status-hot': item.status === 'hot' }"
>{{ statusLabelOf(item.status) }}</text>
</view>
</view>
</list-item>
</list-view>
</view>
</view>
<!-- Floating Primary CTA Bar -->
<view class="overview-cta-bar">
<button
class="primary-cta-btn"
:class="{ 'primary-cta-btn-disabled': state.loading }"
:disabled="state.loading"
:aria-label="ctaLabel"
@click="handleRefresh"
>
<text class="primary-cta-btn-text">{{ ctaLabel }}</text>
</button>
</view>
</view>
</template>
<script setup lang="uts">
import { getCurrentLocale, getOmniText, isRtl } from '../../../common/locale.uts';
import { TeamRankItem } from '../../../common/types.uts';
import { utsLightColors, utsRadius, utsSpacing, utsTypography } from '../../../common/tokens.uts';
import { statusLabel } from '../useLeads.uts';
import {
createOverviewState,
formatTopCountry,
refreshOverview,
resolveOverviewText,
OverviewCopyKey,
} from './useOverview.uts';
const pageTheme: Record<string, string> = {
'--oc-primary': utsLightColors.primary,
'--oc-primary-soft': utsLightColors.primarySoft,
'--oc-bg': utsLightColors.bg,
'--oc-surface': utsLightColors.surface,
'--oc-border': utsLightColors.border,
'--oc-text': utsLightColors.text,
'--oc-text-2': utsLightColors.text2,
'--oc-success': utsLightColors.success,
'--oc-warning': utsLightColors.warning,
'--oc-error': utsLightColors.error,
'--oc-radius-btn': utsRadius.button,
'--oc-radius-card': utsRadius.card,
'--oc-radius-modal': utsRadius.modal,
'--oc-shadow': utsTypography.shadow,
'--oc-shadow-card': utsTypography.shadowCard,
'--oc-shadow-cta': utsTypography.shadowCta,
'--oc-space-8': utsSpacing.space8,
'--oc-space-12': utsSpacing.space12,
'--oc-space-16': utsSpacing.space16,
'--oc-space-20': utsSpacing.space20,
'--oc-space-24': utsSpacing.space24,
};
const state = reactive(createOverviewState());
const pageTitle = ref(resolveOverviewText('title'));
const pageDesc = ref(resolveOverviewText('desc'));
const leadsLabel = ref(getOmniText(getCurrentLocale(), 'crm.leads'));
const tracksLabel = ref(getOmniText(getCurrentLocale(), 'radar.visitor_trace'));
const recentLabel = ref(getOmniText(getCurrentLocale(), 'crm.follow_up'));
const countryText = computed((): string => {
return formatTopCountry(state.summary.topCountry);
});
const countryValueClass = computed((): string => {
return countryText.value.length > 8 ? 'metric-country-long' : '';
});
const pageRtlClass = computed((): string => {
return isRtl(getCurrentLocale()) ? 'overview-rtl' : '';
});
const ctaLabel = computed((): string => {
if (state.loading) {
return resolveOverviewText('loading');
}
return resolveOverviewText('refresh');
});
function t(key: OverviewCopyKey): string {
return resolveOverviewText(key);
}
function formatRankMeta(item: TeamRankItem): string {
return `${item.leads} · ${item.touches} · ${item.score}`;
}
function statusLabelOf(status: string): string {
return statusLabel(status);
}
function getInitial(name: string): string {
const clean = name.trim();
if (clean.length === 0) {
return 'U';
}
return clean.substring(0, 1).toUpperCase();
}
function rankBadgeClass(rank: number): string {
if (rank === 1) {
return 'rank-badge-gold';
}
if (rank === 2) {
return 'rank-badge-silver';
}
if (rank === 3) {
return 'rank-badge-bronze';
}
return 'rank-badge-normal';
}
function handleRefresh(): void {
refreshOverview(state);
}
onLoad(() => {
refreshOverview(state);
});
</script>
<style scoped>
.overview-page {
position: relative;
display: flex;
flex-direction: column;
min-height: 100%;
background-color: var(--oc-bg, #F7F8FA);
}
.overview-rtl {
direction: rtl;
}
.overview-aurora-glow {
position: absolute;
top: 0;
left: 0;
right: 0;
height: 140px;
background: linear-gradient(180deg, rgba(0, 136, 255, 0.06) 0%, rgba(245, 248, 252, 0) 100%);
pointer-events: none;
}
.overview-header {
position: relative;
padding-inline: var(--oc-space-16, 16px);
padding-block-start: var(--oc-space-16, 16px);
padding-block-end: var(--oc-space-16, 16px);
background-color: var(--oc-surface, #FFFFFF);
border-bottom: 1px solid var(--oc-border, #E3E7ED);
}
.header-live-bar {
display: flex;
flex-direction: row;
justify-content: space-between;
align-items: center;
margin-block-end: 10px;
}
.live-pill {
display: flex;
flex-direction: row;
align-items: center;
padding-inline: 8px;
padding-block: 4px;
background-color: #ECFDF5;
border: 1px solid rgba(18, 183, 106, 0.2);
border-radius: 9999px;
}
.live-pulse-dot {
width: 6px;
height: 6px;
border-radius: 9999px;
background-color: #12B76A;
margin-inline-end: 6px;
}
.live-pill-text {
font-size: 11px;
font-weight: 700;
color: #027A48;
letter-spacing: 0.5px;
}
.sync-pill {
padding-inline: 8px;
padding-block: 3px;
background-color: var(--oc-bg, #F7F8FA);
border-radius: 9999px;
}
.sync-pill-text {
font-size: 11px;
color: var(--oc-text-2, #667085);
}
.overview-title {
font-size: 22px;
font-weight: 700;
color: var(--oc-text, #101828);
line-height: 1.25;
margin-block-end: 4px;
}
.overview-desc {
font-size: 13px;
color: var(--oc-text-2, #667085);
line-height: 1.5;
}
.overview-skeleton {
flex: 1;
padding-inline: var(--oc-space-16, 16px);
padding-block: var(--oc-space-16, 16px);
}
.skeleton-pill {
height: 20px;
width: 35%;
background-color: var(--oc-border, #E3E7ED);
border-radius: 9999px;
margin-block-end: 16px;
}
.skeleton-grid {
display: flex;
flex-direction: row;
flex-wrap: wrap;
gap: 12px;
margin-block-end: 16px;
}
.skeleton-grid-card {
width: calc((100% - 12px) / 2);
height: 96px;
background-color: var(--oc-surface, #FFFFFF);
border-radius: var(--oc-radius-card, 20px);
border: 1px solid var(--oc-border, #E3E7ED);
box-sizing: border-box;
}
.skeleton-row-card {
height: 68px;
background-color: var(--oc-surface, #FFFFFF);
border-radius: var(--oc-radius-card, 20px);
border: 1px solid var(--oc-border, #E3E7ED);
margin-block-end: 12px;
}
.overview-body {
flex: 1;
padding-inline: var(--oc-space-16, 16px);
padding-block-start: var(--oc-space-16, 16px);
padding-block-end: calc(96px + var(--window-bottom, 0px) + env(safe-area-inset-bottom, 0px));
}
.overview-feedback {
position: relative;
display: flex;
flex-direction: row;
align-items: center;
padding: var(--oc-space-16, 16px);
margin-block-end: var(--oc-space-16, 16px);
background-color: var(--oc-surface, #FFFFFF);
border: 1px solid #FEE4E2;
border-radius: var(--oc-radius-card, 20px);
box-shadow: 0 4px 16px rgba(240, 68, 56, 0.06);
}
.feedback-indicator {
width: 4px;
height: 36px;
background-color: var(--oc-error, #F04438);
border-radius: 2px;
margin-inline-end: 12px;
}
.feedback-info {
flex: 1;
display: flex;
flex-direction: column;
}
.feedback-title {
font-size: 15px;
font-weight: 600;
color: var(--oc-text, #101828);
margin-block-end: 2px;
}
.feedback-desc {
font-size: 13px;
color: var(--oc-text-2, #667085);
line-height: 1.5;
}
.metrics-grid {
display: flex;
flex-direction: row;
flex-wrap: wrap;
gap: 12px;
margin-block-end: var(--oc-space-20, 20px);
}
.metric-card {
width: calc((100% - 12px) / 2);
min-height: 96px;
padding: 14px 16px;
background-color: var(--oc-surface, #FFFFFF);
border: 1px solid var(--oc-border, #E3E7ED);
border-radius: var(--oc-radius-card, 20px);
box-shadow: 0 8px 30px rgba(0, 0, 0, 0.04), 0 2px 8px rgba(11, 99, 229, 0.03);
display: flex;
flex-direction: column;
justify-content: space-between;
box-sizing: border-box;
overflow: hidden;
}
.metric-card-hot {
border-color: rgba(240, 68, 56, 0.2);
background: linear-gradient(180deg, #FFFFFF 0%, #FFF8F8 100%);
}
.metric-top-row {
display: flex;
flex-direction: row;
justify-content: space-between;
align-items: center;
margin-block-end: 6px;
}
.metric-label {
font-size: 12px;
font-weight: 600;
color: var(--oc-text-2, #667085);
}
.metric-label-hot {
color: var(--oc-error, #F04438);
}
.hot-spark-dot {
width: 6px;
height: 6px;
border-radius: 9999px;
background-color: var(--oc-error, #F04438);
box-shadow: 0 0 6px rgba(240, 68, 56, 0.5);
}
.metric-value {
font-size: 26px;
font-weight: 700;
color: var(--oc-text, #101828);
line-height: 1.15;
letter-spacing: -0.5px;
}
.metric-value-primary {
color: var(--oc-primary, #0B5CFF);
}
.metric-value-hot {
color: var(--oc-error, #F04438);
}
.metric-country-long {
font-size: 15px;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
letter-spacing: normal;
}
.metric-bottom-row {
margin-block-start: 4px;
}
.metric-sub-label {
font-size: 11px;
color: var(--oc-text-2, #667085);
opacity: 0.85;
}
.recent-section {
display: flex;
flex-direction: column;
margin-block-end: var(--oc-space-20, 20px);
}
.section-title-wrap {
display: flex;
flex-direction: row;
align-items: center;
margin-block-end: 12px;
}
.section-title {
font-size: 16px;
font-weight: 700;
color: var(--oc-text, #101828);
line-height: 1.25;
}
.section-badge {
margin-inline-start: 8px;
padding-inline: 6px;
padding-block: 2px;
background-color: var(--oc-primary-soft, #EBF5FF);
border-radius: 9999px;
}
.section-badge-text {
font-size: 11px;
font-weight: 700;
color: var(--oc-primary, #0B5CFF);
}
.recent-list {
min-height: 44px;
}
.overview-empty {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
padding: 32px 16px;
background-color: var(--oc-surface, #FFFFFF);
border: 1px solid var(--oc-border, #E3E7ED);
border-radius: var(--oc-radius-card, 20px);
}
.empty-halo {
width: 44px;
height: 44px;
border-radius: 9999px;
background: linear-gradient(135deg, rgba(0, 136, 255, 0.1) 0%, rgba(99, 102, 241, 0.05) 100%);
margin-block-end: 12px;
}
.empty-sentence {
font-size: 15px;
font-weight: 600;
color: var(--oc-text, #101828);
line-height: 1.25;
margin-block-end: 4px;
}
.empty-hint {
font-size: 12px;
color: var(--oc-text-2, #667085);
}
.rank-row {
min-height: 68px;
padding: 12px 14px;
margin-block-end: 10px;
background-color: var(--oc-surface, #FFFFFF);
border: 1px solid var(--oc-border, #E3E7ED);
border-radius: var(--oc-radius-card, 20px);
box-shadow: 0 4px 16px rgba(16, 24, 40, 0.03);
display: flex;
flex-direction: row;
align-items: center;
}
.rank-badge {
width: 24px;
height: 24px;
border-radius: 8px;
display: flex;
align-items: center;
justify-content: center;
margin-inline-end: 10px;
}
.rank-badge-gold {
background: linear-gradient(135deg, #F59E0B 0%, #D97706 100%);
}
.rank-badge-silver {
background: linear-gradient(135deg, #94A3B8 0%, #64748B 100%);
}
.rank-badge-bronze {
background: linear-gradient(135deg, #D97706 0%, #B45309 100%);
}
.rank-badge-normal {
background-color: var(--oc-bg, #F7F8FA);
}
.rank-no {
font-size: 12px;
font-weight: 700;
color: #FFFFFF;
}
.rank-badge-normal .rank-no {
color: var(--oc-text-2, #667085);
}
.rank-avatar {
width: 36px;
height: 36px;
border-radius: 10px;
background: linear-gradient(135deg, #EBF5FF 0%, #E0EEFD 100%);
display: flex;
align-items: center;
justify-content: center;
margin-inline-end: 10px;
}
.rank-avatar-text {
font-size: 14px;
font-weight: 700;
color: var(--oc-primary, #0B5CFF);
}
.rank-main {
display: flex;
flex-direction: column;
flex: 1;
padding-inline-end: 10px;
min-width: 0;
}
.rank-header-row {
display: flex;
flex-direction: row;
align-items: center;
margin-block-end: 2px;
}
.rank-name {
font-size: 15px;
font-weight: 600;
color: var(--oc-text, #101828);
line-height: 1.25;
}
.champion-pill {
margin-inline-start: 6px;
padding-inline: 6px;
padding-block: 1px;
background-color: #FEF3C7;
border-radius: 9999px;
font-size: 10px;
font-weight: 700;
color: #B45309;
}
.rank-meta {
font-size: 12px;
color: var(--oc-text-2, #667085);
line-height: 1.5;
}
.rank-score-box {
display: flex;
flex-direction: column;
align-items: flex-end;
}
.rank-score-num {
font-size: 16px;
font-weight: 700;
color: var(--oc-text, #101828);
}
.rank-score-unit {
font-size: 10px;
color: var(--oc-text-2, #667085);
}
.lead-row {
min-height: 68px;
padding: 12px 14px;
margin-block-end: 10px;
background-color: var(--oc-surface, #FFFFFF);
border: 1px solid var(--oc-border, #E3E7ED);
border-radius: var(--oc-radius-card, 20px);
box-shadow: 0 4px 16px rgba(16, 24, 40, 0.03);
display: flex;
flex-direction: row;
align-items: center;
}
.lead-avatar {
width: 36px;
height: 36px;
border-radius: 10px;
background-color: var(--oc-bg, #F7F8FA);
display: flex;
align-items: center;
justify-content: center;
margin-inline-end: 10px;
}
.lead-avatar-text {
font-size: 14px;
font-weight: 600;
color: var(--oc-text-2, #667085);
}
.lead-main {
display: flex;
flex-direction: column;
flex: 1;
padding-inline-end: 10px;
min-width: 0;
}
.lead-title-row {
display: flex;
flex-direction: row;
align-items: center;
margin-block-end: 2px;
}
.lead-name {
font-size: 15px;
font-weight: 600;
color: var(--oc-text, #101828);
line-height: 1.25;
}
.lead-company {
font-size: 12px;
color: var(--oc-text-2, #667085);
line-height: 1.4;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.lead-status-box {
display: flex;
flex-direction: row;
align-items: center;
padding-inline: 8px;
padding-block: 4px;
border-radius: 9999px;
background-color: var(--oc-primary-soft, #EBF5FF);
}
.lead-status-box-hot {
background-color: #FEF2F2;
}
.status-hot-dot {
width: 5px;
height: 5px;
border-radius: 9999px;
background-color: var(--oc-error, #F04438);
margin-inline-end: 4px;
}
.lead-status {
font-size: 11px;
font-weight: 600;
color: var(--oc-primary, #0B5CFF);
}
.lead-status-hot {
color: var(--oc-error, #F04438);
}
.overview-cta-bar {
position: fixed;
left: 0;
right: 0;
bottom: var(--window-bottom, 0px);
padding: 12px 16px calc(14px + env(safe-area-inset-bottom, 0px));
background-color: var(--oc-surface, #FFFFFF);
border-top: 1px solid var(--oc-border, #E3E7ED);
box-sizing: border-box;
z-index: 100;
}
.primary-cta-btn {
height: 48px;
min-height: 44px;
width: 100%;
border-width: 0;
border-radius: var(--oc-radius-btn, 14px);
background-color: var(--oc-primary, #0B5CFF);
box-shadow: 0 8px 20px rgba(0, 136, 255, 0.22);
display: flex;
align-items: center;
justify-content: center;
transition: opacity 150ms cubic-bezier(0.2, 0.8, 0.2, 1);
}
.primary-cta-btn:active {
opacity: 0.88;
}
.primary-cta-btn-disabled {
background-color: var(--oc-border, #E3E7ED);
box-shadow: none;
}
.primary-cta-btn-text {
color: #FFFFFF;
font-size: 15px;
font-weight: 600;
}
.primary-cta-btn-disabled .primary-cta-btn-text {
color: var(--oc-text-2, #667085);
}
@media (prefers-reduced-motion: reduce) {
* {
animation: none !important;
transition: none !important;
}
}
</style>