374 行
9.2 KiB
Plaintext
374 行
9.2 KiB
Plaintext
<template>
|
|
<view class="card-home-page" :style="pageTheme">
|
|
<view class="card-home-header">
|
|
<text class="card-home-title">{{ pageTitle }}</text>
|
|
<text class="card-home-subtitle">{{ pageSubtitle }}</text>
|
|
<input
|
|
class="card-home-search"
|
|
type="text"
|
|
v-model="state.keyWord"
|
|
:placeholder="searchPlaceholder"
|
|
:disabled="state.loading"
|
|
/>
|
|
</view>
|
|
|
|
<view v-if="state.loading" class="card-home-skeleton">
|
|
<view class="skeleton-line"></view>
|
|
<view class="skeleton-card"></view>
|
|
<view class="skeleton-card"></view>
|
|
</view>
|
|
|
|
<view v-else-if="state.errorMessage !== ''" class="card-home-feedback">
|
|
<text class="feedback-title">{{ t('error') }}</text>
|
|
<text class="feedback-desc">{{ state.errorMessage }}</text>
|
|
</view>
|
|
|
|
<view v-else-if="state.empty" class="card-home-feedback">
|
|
<text class="feedback-title">{{ t('empty') }}</text>
|
|
<text class="feedback-desc">{{ pageSubtitle }}</text>
|
|
</view>
|
|
|
|
<list-view v-else class="card-home-list" :scroll-y="true">
|
|
<list-item v-for="item in state.list" :key="item.id">
|
|
<view class="card-row" @click="handleOpenPreview(item)">
|
|
<view class="card-main">
|
|
<text class="card-name">{{ item.name }}</text>
|
|
<text class="card-title">{{ formatField(item.title) }}</text>
|
|
<text class="card-company">{{ formatField(item.company) }}</text>
|
|
</view>
|
|
<view class="card-meta">
|
|
<text class="card-status">{{ statusLabelOf(item.status) }}</text>
|
|
<text class="card-poster" @click.stop="handleOpenEdit(item)">{{ editLabel }}</text>
|
|
</view>
|
|
</view>
|
|
</list-item>
|
|
</list-view>
|
|
|
|
<view class="card-home-cta-bar">
|
|
<button
|
|
class="primary-cta-btn"
|
|
:class="{ 'primary-cta-btn-disabled': state.loading }"
|
|
:disabled="state.loading"
|
|
@click="handleRefresh"
|
|
>
|
|
<text class="primary-cta-btn-text">{{ ctaLabel }}</text>
|
|
</button>
|
|
</view>
|
|
</view>
|
|
</template>
|
|
|
|
<script setup lang="uts">
|
|
import { getCurrentLocale, getOmniText } from '../../../common/locale.uts';
|
|
import { fetchCardQuota } from '../../../common/api.uts';
|
|
import { getTenantId } from '../../../common/request.uts';
|
|
import { utsLightColors, utsRadius, utsSpacing } from '../../../common/tokens.uts';
|
|
import {
|
|
applyCardHomeOptions,
|
|
createCardHomeState,
|
|
formatCardField,
|
|
openCardEdit,
|
|
openCardPreview,
|
|
openCardQrcode,
|
|
pickShareCard,
|
|
refreshCards,
|
|
resolveCardHomeText,
|
|
statusLabel,
|
|
CardHomeCopyKey,
|
|
CardHomeItem,
|
|
CardHomePageOptions,
|
|
} from './useCardHome.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(createCardHomeState());
|
|
const pageTitle = ref(resolveCardHomeText('title'));
|
|
const pageSubtitle = ref(resolveCardHomeText('subtitle'));
|
|
const searchPlaceholder = ref(resolveCardHomeText('searchPlaceholder'));
|
|
const editLabel = ref(getOmniText(getCurrentLocale(), 'common.edit'));
|
|
|
|
const ctaLabel = computed((): string => {
|
|
if (state.loading) {
|
|
return resolveCardHomeText('loading');
|
|
}
|
|
return resolveCardHomeText('refresh');
|
|
});
|
|
|
|
function t(key: CardHomeCopyKey): string {
|
|
return resolveCardHomeText(key);
|
|
}
|
|
|
|
function formatField(value: string | null | undefined): string {
|
|
return formatCardField(value);
|
|
}
|
|
|
|
function statusLabelOf(status: string | null | undefined): string {
|
|
return statusLabel(status);
|
|
}
|
|
|
|
function handleOpenEdit(item: CardHomeItem): void {
|
|
if (item.id == null) {
|
|
return;
|
|
}
|
|
openCardEdit(item.id);
|
|
}
|
|
|
|
function handleOpenPreview(item: CardHomeItem): void {
|
|
openCardPreview(item);
|
|
}
|
|
|
|
async function handleRefresh(): Promise<void> {
|
|
const shareCard = pickShareCard(state.list);
|
|
if (shareCard != null) {
|
|
openCardQrcode(shareCard);
|
|
return;
|
|
}
|
|
await refreshCards(state);
|
|
}
|
|
|
|
async function applyQuotaHint(): Promise<void> {
|
|
try {
|
|
const tenantId = getTenantId();
|
|
const quota = await fetchCardQuota(tenantId !== '' ? tenantId : 1);
|
|
if (quota.exceeded === true) {
|
|
pageSubtitle.value = resolveCardHomeText('quotaExceeded');
|
|
} else {
|
|
pageSubtitle.value = resolveCardHomeText('subtitle');
|
|
}
|
|
} catch (_e) {}
|
|
}
|
|
|
|
onLoad((options: CardHomePageOptions) => {
|
|
applyCardHomeOptions(state, options);
|
|
refreshCards(state);
|
|
applyQuotaHint();
|
|
});
|
|
|
|
onShow(() => {
|
|
refreshCards(state);
|
|
applyQuotaHint();
|
|
});
|
|
</script>
|
|
|
|
<style scoped>
|
|
.card-home-page {
|
|
display: flex;
|
|
flex-direction: column;
|
|
height: 100%;
|
|
background-color: var(--oc-surface, #F7F8FA);
|
|
}
|
|
|
|
.card-home-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);
|
|
}
|
|
|
|
.card-home-title {
|
|
font-size: 24px;
|
|
font-weight: 700;
|
|
color: var(--oc-text, #101828);
|
|
line-height: 1.25;
|
|
margin-bottom: var(--oc-space-8, 8px);
|
|
}
|
|
|
|
.card-home-subtitle {
|
|
font-size: 14px;
|
|
color: var(--oc-text-2, #667085);
|
|
line-height: 1.6;
|
|
margin-bottom: var(--oc-space-16, 16px);
|
|
}
|
|
|
|
.card-home-search {
|
|
height: 44px;
|
|
padding-inline: 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);
|
|
}
|
|
|
|
.card-home-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);
|
|
}
|
|
|
|
.card-home-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;
|
|
}
|
|
|
|
.card-home-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));
|
|
}
|
|
|
|
.card-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;
|
|
justify-content: space-between;
|
|
align-items: center;
|
|
transition: transform 150ms cubic-bezier(0.2, 0.8, 0.2, 1);
|
|
}
|
|
|
|
.card-row:active {
|
|
transform: scale(0.99);
|
|
}
|
|
|
|
.card-main {
|
|
display: flex;
|
|
flex-direction: column;
|
|
flex: 1;
|
|
padding-inline-end: 12px;
|
|
}
|
|
|
|
.card-name {
|
|
font-size: 16px;
|
|
font-weight: 600;
|
|
color: var(--oc-text, #101828);
|
|
line-height: 1.25;
|
|
margin-bottom: 4px;
|
|
}
|
|
|
|
.card-title {
|
|
font-size: 14px;
|
|
color: var(--oc-text-2, #667085);
|
|
line-height: 1.6;
|
|
}
|
|
|
|
.card-company {
|
|
font-size: 14px;
|
|
color: var(--oc-text-2, #667085);
|
|
line-height: 1.6;
|
|
}
|
|
|
|
.card-meta {
|
|
display: flex;
|
|
flex-direction: column;
|
|
align-items: flex-end;
|
|
}
|
|
|
|
.card-status {
|
|
font-size: 12px;
|
|
font-weight: 600;
|
|
color: var(--oc-primary, #0B5CFF);
|
|
margin-bottom: 8px;
|
|
}
|
|
|
|
.card-poster {
|
|
min-height: 44px;
|
|
min-width: 44px;
|
|
font-size: 12px;
|
|
font-weight: 600;
|
|
color: var(--oc-primary, #0B5CFF);
|
|
display: flex;
|
|
align-items: center;
|
|
}
|
|
|
|
.card-home-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;
|
|
transition: opacity 150ms cubic-bezier(0.2, 0.8, 0.2, 1);
|
|
}
|
|
|
|
.primary-cta-btn:active {
|
|
opacity: 0.85;
|
|
}
|
|
|
|
.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>
|