文件
OmniCard/mpuniapp/pages/owner/hall/index.uvue

860 行
21 KiB
Plaintext

<template>
<view class="hall-page" :class="pageRtlClass" :style="pageTheme">
<!-- Header: Bento Hero & Action Control Pod -->
<view class="hall-header">
<view class="hall-header-top">
<view class="hall-title-group">
<text class="hall-title">{{ pageTitle }}</text>
<text class="hall-subtitle">{{ pageSubtitle }}</text>
</view>
<view class="hall-counter-badge">
<view class="hall-counter-dot"></view>
<text class="hall-counter-num">{{ state.total }}</text>
<text class="hall-counter-unit">{{ countUnitText }}</text>
</view>
</view>
<!-- Bento Capsule Tabs (Contacts / Team / Event) -->
<view class="hall-tabs">
<view
class="hall-tab"
:class="{ 'hall-tab-active': state.tab === 'contacts' }"
@click="handleTab('contacts')"
>
<text class="hall-tab-text">{{ t('tabContacts') }}</text>
</view>
<view
class="hall-tab"
:class="{ 'hall-tab-active': state.tab === 'team' }"
@click="handleTab('team')"
>
<text class="hall-tab-text">{{ t('tabTeam') }}</text>
</view>
<view
class="hall-tab"
:class="{ 'hall-tab-active': state.tab === 'event' }"
@click="handleTab('event')"
>
<text class="hall-tab-text">{{ t('tabEvent') }}</text>
</view>
</view>
<!-- Global Filter Search Input -->
<view class="hall-search-box">
<view class="search-icon-mark"></view>
<input
class="hall-search-input field-input"
type="text"
v-model="state.keyWord"
:placeholder="searchPlaceholder"
:disabled="state.loading"
@confirm="handleSearchConfirm"
/>
</view>
<!-- Contextual Quick Action Pod: 6-Digit Exchange Code (Contacts Tab) -->
<view v-if="state.tab === 'contacts'" class="hall-context-pod">
<view class="pod-label-row">
<text class="pod-title">{{ exchangePodTitle }}</text>
<text class="pod-hint">{{ exchangePodHint }}</text>
</view>
<view class="pod-input-row">
<input
class="pod-input field-input pod-code-input"
type="number"
maxlength="6"
v-model="state.exchangeCode"
:placeholder="exchangePlaceholder"
:disabled="state.loading"
@confirm="handlePrimary"
/>
</view>
</view>
<!-- Contextual Quick Action Pod: 6-Char Event Floor Pass (Event Tab) -->
<view v-if="state.tab === 'event'" class="hall-context-pod pod-event">
<view class="pod-label-row">
<text class="pod-title">{{ eventPodTitle }}</text>
<text class="pod-hint">{{ eventPodHint }}</text>
</view>
<view class="pod-input-row">
<input
class="pod-input field-input pod-code-input"
type="text"
maxlength="6"
v-model="state.eventCode"
:placeholder="eventPlaceholder"
:disabled="state.loading"
@confirm="handlePrimary"
/>
</view>
</view>
</view>
<!-- Loading Skeleton Cards -->
<view v-if="state.loading" class="hall-skeleton">
<view class="skeleton-card">
<view class="skeleton-avatar"></view>
<view class="skeleton-meta">
<view class="skeleton-line"></view>
<view class="skeleton-line skeleton-line-sub"></view>
</view>
</view>
<view class="skeleton-card">
<view class="skeleton-avatar"></view>
<view class="skeleton-meta">
<view class="skeleton-line"></view>
<view class="skeleton-line skeleton-line-sub"></view>
</view>
</view>
<view class="skeleton-card">
<view class="skeleton-avatar"></view>
<view class="skeleton-meta">
<view class="skeleton-line"></view>
<view class="skeleton-line skeleton-line-sub"></view>
</view>
</view>
</view>
<!-- Error State Feedback Card -->
<view v-else-if="state.errorMessage !== ''" class="hall-feedback">
<view class="feedback-halo error-halo">
<view class="feedback-halo-inner error-halo-inner"></view>
</view>
<text class="feedback-title">{{ t('error') }}</text>
<text class="feedback-desc">{{ state.errorMessage }}</text>
</view>
<!-- Empty State Feedback Card -->
<view v-else-if="state.empty" class="hall-feedback">
<view class="feedback-halo empty-halo">
<view class="feedback-halo-inner empty-halo-inner"></view>
</view>
<text class="feedback-title">{{ t('empty') }}</text>
<text class="feedback-desc">{{ emptyDesc }}</text>
</view>
<!-- Virtualized High-Performance Bento Contact List -->
<list-view v-else class="hall-list" :scroll-y="true">
<list-item v-for="item in state.list" :key="item.peerCardId">
<view class="hall-row" @click="handleOpenPortal(item)">
<!-- Squircle Initials Avatar -->
<view class="hall-avatar">
<text class="hall-avatar-text">{{ getInitial(item.peerName) }}</text>
</view>
<!-- Contact Details -->
<view class="hall-main">
<view class="hall-name-row">
<text class="hall-name">{{ item.peerName }}</text>
<text v-if="formatSourceTag(item.source) !== ''" class="hall-source-tag">
{{ formatSourceTag(item.source) }}
</text>
</view>
<text v-if="formatField(item.peerTitle) !== ''" class="hall-meta-text">
{{ formatField(item.peerTitle) }}
</text>
<text v-if="formatField(item.peerCompany) !== ''" class="hall-meta-text hall-meta-company">
{{ formatField(item.peerCompany) }}
</text>
</view>
<!-- Forward Chevron Arrow -->
<view class="hall-arrow"></view>
</view>
</list-item>
</list-view>
<!-- Fixed Floating Main CTA Bar -->
<view class="hall-cta-bar">
<button
class="primary-cta-btn"
:class="{ 'primary-cta-btn-disabled': state.loading }"
:disabled="state.loading"
:aria-label="ctaLabel"
@click="handlePrimary"
>
<text class="primary-cta-btn-text">{{ ctaLabel }}</text>
</button>
</view>
</view>
</template>
<script setup lang="uts">
import { getCurrentLocale, isRtl } from '../../../common/locale.uts';
import { utsLightColors, utsRadius, utsSpacing, utsTypography } from '../../../common/tokens.uts';
import {
applyHallTab,
createHallState,
HallContactItem,
HallCopyKey,
HallTab,
openHallPortal,
refreshHall,
resolveHallText,
submitHallEventJoin,
submitHallExchange,
} from './useHall.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-radius-pill': utsRadius.pill,
'--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-24': utsSpacing.space24,
};
const state = reactive(createHallState());
const pageTitle = computed((): string => resolveHallText('title'));
const pageSubtitle = computed((): string => resolveHallText('subtitle'));
const searchPlaceholder = computed((): string => resolveHallText('searchPlaceholder'));
const exchangePlaceholder = computed((): string => resolveHallText('exchangePlaceholder'));
const eventPlaceholder = computed((): string => resolveHallText('eventPlaceholder'));
const isZh = computed((): boolean => {
return getCurrentLocale() === 'zh-CN';
});
const countUnitText = computed((): string => {
return isZh.value ? '人' : 'cards';
});
const exchangePodTitle = computed((): string => {
return isZh.value ? '面对面极速互换' : 'Quick Exchange';
});
const exchangePodHint = computed((): string => {
return isZh.value ? '输入 6 位数字码' : '6-digit offline code';
});
const eventPodTitle = computed((): string => {
return isZh.value ? '展会同场' : 'Floor Pass';
});
const eventPodHint = computed((): string => {
return isZh.value ? '输入 6 位活动码' : '6-char event code';
});
const pageRtlClass = computed((): string => {
return isRtl(getCurrentLocale()) ? 'hall-rtl' : '';
});
const emptyDesc = computed((): string => {
if (state.tab === 'team') {
return resolveHallText('teamEmpty');
}
if (state.tab === 'event') {
return resolveHallText('eventEmpty');
}
return pageSubtitle.value;
});
const ctaLabel = computed((): string => {
if (state.loading) {
return resolveHallText('loading');
}
if (state.tab === 'event' && state.eventCode.trim() !== '') {
return resolveHallText('eventJoin');
}
if (state.exchangeCode.trim() !== '') {
return resolveHallText('exchange');
}
return resolveHallText('refresh');
});
function t(key: HallCopyKey): string {
return resolveHallText(key);
}
function formatField(value: string | null | undefined): string {
if (value == null) {
return '';
}
return value;
}
function getInitial(name: string): string {
const trimmed = name.trim();
if (trimmed.length === 0) {
return 'O';
}
return trimmed.substring(0, 1).toUpperCase();
}
function formatSourceTag(source: string | null | undefined): string {
if (source == null || source === '') {
return '';
}
const zh = isZh.value;
if (source === 'exchange') {
return zh ? '互换' : 'Exchange';
}
if (source === 'event') {
return zh ? '现场' : 'Floor';
}
if (source === 'team') {
return zh ? '团队' : 'Team';
}
if (source === 'collect') {
return zh ? '收藏' : 'Saved';
}
return source;
}
async function handleTab(tab: HallTab): Promise<void> {
applyHallTab(state, tab);
await refreshHall(state);
}
function handleOpenPortal(item: HallContactItem): void {
openHallPortal(item);
}
async function handleSearchConfirm(): Promise<void> {
await refreshHall(state);
}
async function handlePrimary(): Promise<void> {
if (state.tab === 'event' && state.eventCode.trim() !== '') {
await submitHallEventJoin(state);
return;
}
if (state.exchangeCode.trim() !== '') {
await submitHallExchange(state);
return;
}
await refreshHall(state);
}
onShow(() => {
refreshHall(state);
});
</script>
<style scoped>
.hall-page {
display: flex;
flex-direction: column;
height: 100%;
background-color: var(--oc-bg, #F5F8FC);
}
.hall-rtl {
direction: rtl;
}
.hall-header {
display: flex;
flex-direction: column;
padding-inline: var(--oc-space-16, 16px);
padding-block-start: var(--oc-space-16, 16px);
padding-block-end: var(--oc-space-12, 12px);
background-color: var(--oc-surface, #FFFFFF);
border-bottom: 1px solid var(--oc-border, #EBF1F7);
box-shadow: 0 2px 8px rgba(11, 99, 229, 0.02);
}
.hall-header-top {
display: flex;
flex-direction: row;
align-items: flex-start;
justify-content: space-between;
margin-block-end: var(--oc-space-12, 12px);
}
.hall-title-group {
display: flex;
flex-direction: column;
flex: 1;
min-width: 0;
}
.hall-title {
font-size: 24px;
font-weight: 700;
color: var(--oc-text, #101828);
line-height: 1.25;
margin-block-end: 4px;
}
.hall-subtitle {
font-size: 13px;
color: var(--oc-text-2, #64748B);
line-height: 1.5;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
lines: 1;
}
.hall-counter-badge {
display: flex;
flex-direction: row;
align-items: center;
background-color: var(--oc-primary-soft, #EBF5FF);
padding-inline: 10px;
padding-block: 5px;
border-radius: 9999px;
margin-inline-start: 12px;
flex-shrink: 0;
}
.hall-counter-dot {
width: 6px;
height: 6px;
border-radius: 3px;
background-color: var(--oc-primary, #0B5CFF);
margin-inline-end: 6px;
}
.hall-counter-num {
font-size: 13px;
font-weight: 700;
color: var(--oc-primary, #0B5CFF);
margin-inline-end: 2px;
}
.hall-counter-unit {
font-size: 11px;
color: var(--oc-text-2, #64748B);
}
.hall-tabs {
display: flex;
flex-direction: row;
flex-wrap: nowrap;
margin-block-end: var(--oc-space-8, 8px);
gap: 8px;
}
.hall-tab {
height: 44px;
min-height: 44px;
min-width: 44px;
padding-inline: 16px;
border: 1px solid var(--oc-border, #EBF1F7);
border-radius: var(--oc-radius-btn, 14px);
background-color: var(--oc-bg, #F5F8FC);
display: flex;
align-items: center;
justify-content: center;
flex: 1;
transition: opacity 150ms cubic-bezier(0.2, 0.8, 0.2, 1);
}
.hall-tab:active {
opacity: 0.85;
}
.hall-tab-active {
background-color: var(--oc-primary-soft, #EBF5FF);
border-color: var(--oc-primary, #0B5CFF);
}
.hall-tab-text {
font-size: 14px;
font-weight: 600;
color: var(--oc-text-2, #64748B);
}
.hall-tab-active .hall-tab-text {
color: var(--oc-primary, #0B5CFF);
}
.hall-search-box {
height: 44px;
min-height: 44px;
padding-inline: 14px;
background-color: var(--oc-bg, #F5F8FC);
border: 1px solid var(--oc-border, #EBF1F7);
border-radius: var(--oc-radius-btn, 14px);
display: flex;
flex-direction: row;
align-items: center;
box-sizing: border-box;
}
.search-icon-mark {
width: 14px;
height: 14px;
border: 2px solid var(--oc-text-2, #64748B);
border-radius: 7px;
margin-inline-end: 8px;
flex-shrink: 0;
opacity: 0.65;
}
.hall-search-input {
flex: 1;
height: 100%;
font-size: 16px;
color: var(--oc-text, #101828);
background-color: transparent;
border: none;
}
.hall-context-pod {
margin-block-start: 10px;
padding: 12px 14px;
border-radius: 16px;
background: linear-gradient(135deg, #F0F7FF 0%, #F8FAFD 100%);
border: 1px solid rgba(0, 136, 255, 0.16);
display: flex;
flex-direction: column;
}
.pod-event {
background: linear-gradient(135deg, #F5F3FF 0%, #FAF8FD 100%);
border-color: rgba(99, 102, 241, 0.2);
}
.pod-label-row {
display: flex;
flex-direction: row;
align-items: center;
justify-content: space-between;
margin-block-end: 8px;
}
.pod-title {
font-size: 12px;
font-weight: 700;
color: var(--oc-primary, #0B5CFF);
letter-spacing: 0.2px;
}
.pod-event .pod-title {
color: #6366F1;
}
.pod-hint {
font-size: 11px;
color: var(--oc-text-2, #64748B);
}
.pod-input-row {
display: flex;
flex-direction: row;
align-items: center;
}
.pod-input {
height: 44px;
min-height: 44px;
flex: 1;
padding-inline: 12px;
background-color: var(--oc-surface, #FFFFFF);
border: 1px solid rgba(0, 136, 255, 0.25);
border-radius: 10px;
font-size: 16px;
font-weight: 600;
color: var(--oc-text, #101828);
box-sizing: border-box;
}
.pod-event .pod-input {
border-color: rgba(99, 102, 241, 0.3);
}
.pod-code-input {
letter-spacing: 2px;
}
.hall-skeleton {
flex: 1;
padding-inline: var(--oc-space-16, 16px);
padding-block-start: var(--oc-space-16, 16px);
padding-block-end: calc(88px + var(--window-bottom, 0px) + env(safe-area-inset-bottom, 0px));
}
.skeleton-card {
height: 88px;
min-height: 72px;
padding-inline: var(--oc-space-16, 16px);
background-color: var(--oc-surface, #FFFFFF);
border: 1px solid var(--oc-border, #EBF1F7);
border-radius: var(--oc-radius-card, 20px);
margin-block-end: 10px;
display: flex;
flex-direction: row;
align-items: center;
box-sizing: border-box;
box-shadow: 0 4px 16px rgba(0, 0, 0, 0.02);
}
.skeleton-avatar {
width: 40px;
height: 40px;
border-radius: 20px;
background-color: var(--oc-border, #EBF1F7);
flex-shrink: 0;
margin-inline-end: 12px;
}
.skeleton-meta {
display: flex;
flex-direction: column;
flex: 1;
}
.skeleton-line {
height: 14px;
width: 65%;
background-color: var(--oc-border, #EBF1F7);
border-radius: 8px;
margin-block-end: 8px;
}
.skeleton-line-sub {
width: 40%;
margin-block-end: 0;
}
.hall-feedback {
flex: 1;
margin-inline: var(--oc-space-16, 16px);
margin-block-start: 32px;
margin-block-end: calc(88px + var(--window-bottom, 0px) + env(safe-area-inset-bottom, 0px));
padding: 32px 24px;
background-color: var(--oc-surface, #FFFFFF);
border: 1px solid var(--oc-border, #EBF1F7);
border-radius: var(--oc-radius-card, 20px);
box-shadow: var(--oc-shadow-card, 0 8px 30px rgba(0, 0, 0, 0.04));
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
}
.feedback-halo {
width: 60px;
height: 60px;
border-radius: 30px;
display: flex;
align-items: center;
justify-content: center;
margin-block-end: 16px;
}
.empty-halo {
background: linear-gradient(135deg, rgba(0, 136, 255, 0.12) 0%, rgba(99, 102, 241, 0.08) 100%);
}
.empty-halo-inner {
width: 28px;
height: 28px;
border-radius: 14px;
background-color: rgba(0, 136, 255, 0.2);
}
.error-halo {
background: linear-gradient(135deg, rgba(240, 68, 56, 0.12) 0%, rgba(247, 144, 9, 0.08) 100%);
}
.error-halo-inner {
width: 28px;
height: 28px;
border-radius: 14px;
background-color: rgba(240, 68, 56, 0.22);
}
.feedback-title {
font-size: 16px;
font-weight: 600;
color: var(--oc-text, #101828);
margin-block-end: var(--oc-space-8, 8px);
}
.feedback-desc {
font-size: 14px;
color: var(--oc-text-2, #64748B);
text-align: center;
line-height: 1.6;
max-width: 280px;
}
.hall-list {
flex: 1;
padding-inline: var(--oc-space-16, 16px);
padding-block-start: var(--oc-space-12, 12px);
padding-block-end: calc(88px + var(--window-bottom, 0px) + env(safe-area-inset-bottom, 0px));
}
.hall-row {
min-height: 88px;
padding: 14px 16px;
margin-block-end: 10px;
background-color: var(--oc-surface, #FFFFFF);
border: 1px solid var(--oc-border, #EBF1F7);
border-radius: var(--oc-radius-card, 20px);
box-shadow: var(--oc-shadow-card, 0 8px 30px rgba(0, 0, 0, 0.04), 0 2px 8px rgba(11, 99, 229, 0.03));
display: flex;
flex-direction: row;
align-items: center;
transition: opacity 150ms cubic-bezier(0.2, 0.8, 0.2, 1);
}
.hall-row:active {
opacity: 0.88;
}
.hall-avatar {
width: 40px;
height: 40px;
border-radius: 20px;
background: linear-gradient(135deg, #EBF5FF 0%, #D8EBFF 100%);
border: 1px solid rgba(0, 136, 255, 0.15);
display: flex;
align-items: center;
justify-content: center;
flex-shrink: 0;
margin-inline-end: 12px;
}
.hall-avatar-text {
font-size: 16px;
font-weight: 700;
color: var(--oc-primary, #0B5CFF);
line-height: 1;
}
.hall-main {
display: flex;
flex-direction: column;
flex: 1;
min-width: 0;
}
.hall-name-row {
display: flex;
flex-direction: row;
align-items: center;
margin-block-end: 2px;
}
.hall-name {
font-size: 16px;
font-weight: 600;
color: var(--oc-text, #101828);
line-height: 1.3;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
lines: 1;
}
.hall-source-tag {
font-size: 10px;
font-weight: 600;
color: var(--oc-primary, #0B5CFF);
background-color: var(--oc-primary-soft, #EBF5FF);
padding-inline: 6px;
padding-block: 2px;
border-radius: 9999px;
margin-inline-start: 6px;
flex-shrink: 0;
}
.hall-meta-text {
font-size: 13px;
color: var(--oc-text-2, #64748B);
line-height: 1.4;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
lines: 1;
margin-block-start: 2px;
}
.hall-meta-company {
color: #475467;
}
.hall-arrow {
width: 8px;
height: 8px;
border-top: 2px solid #94A3B8;
border-right: 2px solid #94A3B8;
transform: rotate(45deg);
margin-inline-start: 8px;
flex-shrink: 0;
opacity: 0.6;
}
.hall-rtl .hall-arrow {
transform: rotate(-135deg);
}
.hall-cta-bar {
position: fixed;
left: 0;
right: 0;
bottom: var(--window-bottom, 0px);
padding-block-start: 12px;
padding-inline: 16px;
padding-block-end: calc(16px + env(safe-area-inset-bottom, 0px));
background-color: var(--oc-surface, #FFFFFF);
border-top: 1px solid var(--oc-border, #EBF1F7);
box-sizing: border-box;
z-index: 100;
box-shadow: 0 -4px 16px rgba(16, 24, 40, 0.04);
}
.primary-cta-btn {
height: 48px;
min-height: 44px;
width: 100%;
border-width: 0;
border-radius: var(--oc-radius-btn, 14px);
background: linear-gradient(135deg, #00A3FF 0%, #0B63E5 100%);
background-color: var(--oc-primary, #0B5CFF);
box-shadow: var(--oc-shadow-cta, 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: var(--oc-border, #EBF1F7);
background-color: var(--oc-border, #EBF1F7);
box-shadow: none;
}
.primary-cta-btn-text {
color: #FFFFFF;
font-size: 16px;
font-weight: 600;
letter-spacing: 0.3px;
}
.primary-cta-btn-disabled .primary-cta-btn-text {
color: var(--oc-text-2, #64748B);
}
@media (prefers-reduced-motion: reduce) {
* {
animation: none !important;
transition: none !important;
}
}
</style>