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

397 行
9.8 KiB
Plaintext

<template>
<view class="hall-page" :style="pageTheme">
<view class="hall-header">
<text class="hall-title">{{ pageTitle }}</text>
<text class="hall-subtitle">{{ pageSubtitle }}</text>
<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>
<input
class="hall-search"
type="text"
v-model="state.keyWord"
:placeholder="searchPlaceholder"
:disabled="state.loading"
/>
<input
v-if="state.tab === 'contacts'"
class="hall-search"
type="number"
maxlength="6"
v-model="state.exchangeCode"
:placeholder="exchangePlaceholder"
:disabled="state.loading"
/>
<input
v-if="state.tab === 'event'"
class="hall-search"
type="text"
maxlength="6"
v-model="state.eventCode"
:placeholder="eventPlaceholder"
:disabled="state.loading"
/>
</view>
<view v-if="state.loading" class="hall-skeleton">
<view class="skeleton-line"></view>
<view class="skeleton-card"></view>
<view class="skeleton-card"></view>
</view>
<view v-else-if="state.errorMessage !== ''" class="hall-feedback">
<text class="feedback-title">{{ t('error') }}</text>
<text class="feedback-desc">{{ state.errorMessage }}</text>
</view>
<view v-else-if="state.empty" class="hall-feedback">
<text class="feedback-title">{{ t('empty') }}</text>
<text class="feedback-desc">{{ emptyDesc }}</text>
</view>
<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)">
<view class="hall-main">
<text class="hall-name">{{ item.peerName }}</text>
<text class="hall-meta-text">{{ formatField(item.peerTitle) }}</text>
<text class="hall-meta-text">{{ formatField(item.peerCompany) }}</text>
</view>
</view>
</list-item>
</list-view>
<view class="hall-cta-bar">
<button
class="primary-cta-btn"
:class="{ 'primary-cta-btn-disabled': state.loading }"
:disabled="state.loading"
@click="handlePrimary"
>
<text class="primary-cta-btn-text">{{ ctaLabel }}</text>
</button>
</view>
</view>
</template>
<script setup lang="uts">
import { utsLightColors, utsRadius, utsSpacing } 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-radius-btn': utsRadius.button,
'--oc-radius-card': utsRadius.card,
'--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 = ref(resolveHallText('title'));
const pageSubtitle = ref(resolveHallText('subtitle'));
const searchPlaceholder = ref(resolveHallText('searchPlaceholder'));
const exchangePlaceholder = ref(resolveHallText('exchangePlaceholder'));
const eventPlaceholder = ref(resolveHallText('eventPlaceholder'));
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;
}
async function handleTab(tab: HallTab): Promise<void> {
applyHallTab(state, tab);
await refreshHall(state);
}
function handleOpenPortal(item: HallContactItem): void {
openHallPortal(item);
}
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-surface, #F7F8FA);
}
.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-bg, #FFFFFF);
border-bottom: 1px solid var(--oc-border, #E3E7ED);
}
.hall-title {
font-size: 24px;
font-weight: 700;
color: var(--oc-text, #101828);
line-height: 1.25;
margin-bottom: var(--oc-space-8, 8px);
}
.hall-subtitle {
font-size: 14px;
color: var(--oc-text-2, #667085);
line-height: 1.6;
margin-bottom: var(--oc-space-12, 12px);
}
.hall-tabs {
display: flex;
flex-direction: row;
margin-bottom: var(--oc-space-12, 12px);
}
.hall-tab {
min-height: 44px;
min-width: 44px;
padding-inline: 16px;
margin-inline-end: 8px;
border: 1px solid var(--oc-border, #E3E7ED);
border-radius: 12px;
background-color: var(--oc-bg, #FFFFFF);
display: flex;
align-items: center;
justify-content: center;
}
.hall-tab-active {
background-color: var(--oc-primary-soft, #EAF1FF);
border-color: var(--oc-primary, #0B5CFF);
}
.hall-tab-text {
font-size: 13px;
font-weight: 600;
color: var(--oc-text-2, #667085);
}
.hall-tab-active .hall-tab-text {
color: var(--oc-primary, #0B5CFF);
}
.hall-search {
height: 44px;
padding-inline: 12px;
margin-bottom: var(--oc-space-12, 12px);
background-color: var(--oc-surface, #F7F8FA);
border: 1px solid var(--oc-border, #E3E7ED);
border-radius: var(--oc-radius-btn, 12px);
font-size: 16px;
color: var(--oc-text, #101828);
}
.hall-skeleton {
flex: 1;
padding-inline: var(--oc-space-16, 16px);
padding-block: var(--oc-space-16, 16px);
}
.skeleton-line {
height: 16px;
width: 40%;
background-color: var(--oc-border, #E3E7ED);
border-radius: 8px;
margin-bottom: var(--oc-space-12, 12px);
}
.skeleton-card {
height: 88px;
background-color: var(--oc-border, #E3E7ED);
border-radius: var(--oc-radius-card, 16px);
margin-bottom: var(--oc-space-12, 12px);
}
.hall-feedback {
flex: 1;
margin: 40px var(--oc-space-16, 16px);
padding: var(--oc-space-24, 24px);
background-color: var(--oc-bg, #FFFFFF);
border: 1px solid var(--oc-border, #E3E7ED);
border-radius: var(--oc-radius-card, 16px);
display: flex;
flex-direction: column;
align-items: center;
}
.feedback-title {
font-size: 16px;
font-weight: 600;
color: var(--oc-text, #101828);
margin-bottom: var(--oc-space-8, 8px);
}
.feedback-desc {
font-size: 14px;
color: var(--oc-text-2, #667085);
text-align: center;
line-height: 1.6;
}
.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: var(--oc-space-16, 16px);
margin-bottom: var(--oc-space-12, 12px);
background-color: var(--oc-bg, #FFFFFF);
border: 1px solid var(--oc-border, #E3E7ED);
border-radius: var(--oc-radius-card, 16px);
display: flex;
flex-direction: row;
align-items: center;
}
.hall-main {
display: flex;
flex-direction: column;
flex: 1;
}
.hall-name {
font-size: 16px;
font-weight: 600;
color: var(--oc-text, #101828);
line-height: 1.25;
margin-bottom: 4px;
}
.hall-meta-text {
font-size: 14px;
color: var(--oc-text-2, #667085);
line-height: 1.6;
}
.hall-cta-bar {
position: fixed;
left: 0;
right: 0;
bottom: var(--window-bottom, 0px);
padding: 12px var(--oc-space-16, 16px) calc(12px + env(safe-area-inset-bottom, 0px)) var(--oc-space-16, 16px);
background-color: var(--oc-bg, #FFFFFF);
border-top: 1px solid var(--oc-border, #E3E7ED);
box-sizing: border-box;
z-index: 100;
}
.primary-cta-btn {
height: 48px;
min-height: 44px;
background-color: var(--oc-primary, #0B5CFF);
border-radius: var(--oc-radius-btn, 12px);
display: flex;
align-items: center;
justify-content: center;
width: 100%;
border-width: 0;
}
.primary-cta-btn-disabled {
background-color: var(--oc-border, #E3E7ED);
}
.primary-cta-btn-text {
color: var(--oc-bg, #FFFFFF);
font-size: 15px;
font-weight: 600;
}
.primary-cta-btn-disabled .primary-cta-btn-text {
color: var(--oc-text-2, #667085);
}
</style>