feat: 完成全系统30个功能点开发与E2E全链路验收 (8轮调度32个子代理闭环)
- 模块一: 出海案例作品集、博客动态发布、人名发音语音条、RTL阿语多语言切换 - 模块二: AI顾问人设配置、行业术语库润色、RAG切片沙盒调试、流式会话与意向留资卡片 - 模块三: 全球访客雷达大屏、多维加权意向算分、外部CRM对接推送、团队公海池流转 - 模块四: 移动端NFC安全挂失、NFC动态路由规则配置、动态防伪验签、展会制卡Zip批量导出 - 模块五: 组织架构与名片分配、移动端个人中心设置、离职交接与历史线索迁移、安全审计日志 - 模块六: Stripe国际信用卡订阅Webhook、独立二级域名与SSL检测、坐席配额预警、多币种发票 - 模块七: 纸质名片OCR解析入库、国际商务日程RFC 5545 ICS日历、微官网离线SWR预加载、展会实时排行榜大屏 - 模块八: 全球出海SEO OpenGraph元标签注入与社交爬虫探测、30点端到端全链路业务流集成测试套件
这个提交包含在:
346
mpuniapp/pages/owner/card/edit.uvue
普通文件
346
mpuniapp/pages/owner/card/edit.uvue
普通文件
@@ -0,0 +1,346 @@
|
||||
<template>
|
||||
<view class="card-edit-page" :style="pageTheme">
|
||||
<view v-if="state.missingId || state.empty" class="card-empty">
|
||||
<text class="card-empty-text">{{ emptyMessage }}</text>
|
||||
<button class="primary-cta-btn" @click="handleBack">
|
||||
<text class="primary-cta-btn-text">{{ t('back') }}</text>
|
||||
</button>
|
||||
</view>
|
||||
|
||||
<view v-else-if="state.loading" class="card-skeleton">
|
||||
<view class="skeleton-line skeleton-title"></view>
|
||||
<view class="skeleton-card"></view>
|
||||
<view class="skeleton-card"></view>
|
||||
</view>
|
||||
|
||||
<view v-else class="card-body">
|
||||
<scroll-view class="card-scroll" :scroll-y="true">
|
||||
<view class="card-form">
|
||||
<text class="card-heading">{{ t('heading') }}</text>
|
||||
|
||||
<view class="field">
|
||||
<text class="field-label">{{ t('name') }}</text>
|
||||
<input
|
||||
class="field-input"
|
||||
type="text"
|
||||
v-model="state.name"
|
||||
:placeholder="t('name')"
|
||||
:disabled="state.saving"
|
||||
/>
|
||||
</view>
|
||||
|
||||
<view class="field">
|
||||
<text class="field-label">{{ t('jobTitle') }}</text>
|
||||
<input
|
||||
class="field-input"
|
||||
type="text"
|
||||
v-model="state.title"
|
||||
:placeholder="t('jobTitle')"
|
||||
:disabled="state.saving"
|
||||
/>
|
||||
</view>
|
||||
|
||||
<view class="field">
|
||||
<text class="field-label">{{ t('company') }}</text>
|
||||
<input
|
||||
class="field-input"
|
||||
type="text"
|
||||
v-model="state.company"
|
||||
:placeholder="t('company')"
|
||||
:disabled="state.saving"
|
||||
/>
|
||||
</view>
|
||||
|
||||
<view class="field">
|
||||
<text class="field-label">{{ t('phone') }}</text>
|
||||
<input
|
||||
class="field-input"
|
||||
type="text"
|
||||
v-model="state.phone"
|
||||
:placeholder="t('phone')"
|
||||
:disabled="state.saving"
|
||||
/>
|
||||
</view>
|
||||
|
||||
<view class="field">
|
||||
<text class="field-label">{{ t('email') }}</text>
|
||||
<input
|
||||
class="field-input"
|
||||
type="text"
|
||||
v-model="state.email"
|
||||
:placeholder="t('email')"
|
||||
:disabled="state.saving"
|
||||
/>
|
||||
</view>
|
||||
|
||||
<view class="field">
|
||||
<text class="field-label">{{ t('whatsapp') }}</text>
|
||||
<input
|
||||
class="field-input"
|
||||
type="text"
|
||||
v-model="state.whatsapp"
|
||||
:placeholder="t('whatsapp')"
|
||||
:disabled="state.saving"
|
||||
/>
|
||||
</view>
|
||||
|
||||
<view class="field">
|
||||
<text class="field-label">{{ t('linkedin') }}</text>
|
||||
<input
|
||||
class="field-input"
|
||||
type="text"
|
||||
v-model="state.linkedin"
|
||||
:placeholder="t('linkedin')"
|
||||
:disabled="state.saving"
|
||||
/>
|
||||
</view>
|
||||
|
||||
<view v-if="state.errorMessage !== ''" class="card-error">
|
||||
<text class="card-error-text">{{ state.errorMessage }}</text>
|
||||
</view>
|
||||
</view>
|
||||
<view class="card-bottom-spacer"></view>
|
||||
</scroll-view>
|
||||
|
||||
<view class="card-cta-bar">
|
||||
<button
|
||||
class="primary-cta-btn"
|
||||
:class="{ 'primary-cta-btn-disabled': state.saving }"
|
||||
:disabled="state.saving"
|
||||
@click="handleSave"
|
||||
>
|
||||
<text class="primary-cta-btn-text">{{ saveLabel }}</text>
|
||||
</button>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script setup lang="uts">
|
||||
import { getCurrentLocale, getOmniText } from '../../../common/locale.uts';
|
||||
import { utsLightColors, utsRadius, utsSpacing } from '../../../common/tokens.uts';
|
||||
import {
|
||||
applyCardEditOptions,
|
||||
createCardEditState,
|
||||
goBackFromCardEdit,
|
||||
refreshCardEdit,
|
||||
resolveCardEditText,
|
||||
submitCardEdit,
|
||||
CardEditCopyKey,
|
||||
CardEditPageOptions,
|
||||
} from './useCardEdit.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(createCardEditState());
|
||||
|
||||
const emptyMessage = computed((): string => {
|
||||
if (state.missingId) {
|
||||
return resolveCardEditText('missingId');
|
||||
}
|
||||
if (state.errorMessage !== '') {
|
||||
return state.errorMessage;
|
||||
}
|
||||
return resolveCardEditText('empty');
|
||||
});
|
||||
|
||||
const saveLabel = computed((): string => {
|
||||
if (state.saving) {
|
||||
return resolveCardEditText('loading');
|
||||
}
|
||||
return resolveCardEditText('save');
|
||||
});
|
||||
|
||||
function t(key: CardEditCopyKey): string {
|
||||
return resolveCardEditText(key);
|
||||
}
|
||||
|
||||
function handleBack(): void {
|
||||
goBackFromCardEdit();
|
||||
}
|
||||
|
||||
async function handleSave(): Promise<void> {
|
||||
const ok = await submitCardEdit(state);
|
||||
if (ok) {
|
||||
uni.showToast({
|
||||
title: getOmniText(getCurrentLocale(), 'common.save'),
|
||||
icon: 'none',
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
onLoad((options: CardEditPageOptions) => {
|
||||
const ready = applyCardEditOptions(state, options);
|
||||
if (ready) {
|
||||
refreshCardEdit(state);
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.card-edit-page {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
height: 100%;
|
||||
background-color: var(--oc-surface, #F7F8FA);
|
||||
}
|
||||
|
||||
.card-empty {
|
||||
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;
|
||||
}
|
||||
|
||||
.card-empty-text {
|
||||
font-size: 16px;
|
||||
font-weight: 600;
|
||||
color: var(--oc-text, #101828);
|
||||
text-align: center;
|
||||
line-height: 1.6;
|
||||
margin-bottom: var(--oc-space-24, 24px);
|
||||
}
|
||||
|
||||
.card-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-title {
|
||||
width: 56%;
|
||||
height: 24px;
|
||||
}
|
||||
|
||||
.skeleton-card {
|
||||
height: 72px;
|
||||
background-color: var(--oc-border, #E3E7ED);
|
||||
border-radius: var(--oc-radius-card, 16px);
|
||||
margin-bottom: var(--oc-space-12, 12px);
|
||||
}
|
||||
|
||||
.card-body {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.card-scroll {
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.card-form {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
margin: var(--oc-space-16, 16px);
|
||||
padding: var(--oc-space-24, 24px) 20px;
|
||||
background-color: var(--oc-bg, #FFFFFF);
|
||||
border: 1px solid var(--oc-border, #E3E7ED);
|
||||
border-radius: var(--oc-radius-card, 16px);
|
||||
}
|
||||
|
||||
.card-heading {
|
||||
font-size: 24px;
|
||||
font-weight: 700;
|
||||
color: var(--oc-text, #101828);
|
||||
line-height: 1.25;
|
||||
margin-bottom: var(--oc-space-24, 24px);
|
||||
}
|
||||
|
||||
.field {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
margin-bottom: var(--oc-space-16, 16px);
|
||||
}
|
||||
|
||||
.field-label {
|
||||
font-size: 14px;
|
||||
color: var(--oc-text, #101828);
|
||||
font-weight: 600;
|
||||
margin-bottom: var(--oc-space-8, 8px);
|
||||
}
|
||||
|
||||
.field-input {
|
||||
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: 14px;
|
||||
color: var(--oc-text, #101828);
|
||||
}
|
||||
|
||||
.card-error {
|
||||
margin-bottom: var(--oc-space-12, 12px);
|
||||
}
|
||||
|
||||
.card-error-text {
|
||||
font-size: 12px;
|
||||
color: var(--oc-text-2, #667085);
|
||||
}
|
||||
|
||||
.card-bottom-spacer {
|
||||
height: 80px;
|
||||
}
|
||||
|
||||
.card-cta-bar {
|
||||
position: fixed;
|
||||
left: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
padding: 12px var(--oc-space-16, 16px) var(--oc-space-24, 24px) var(--oc-space-16, 16px);
|
||||
background-color: var(--oc-bg, #FFFFFF);
|
||||
border-top: 1px solid var(--oc-border, #E3E7ED);
|
||||
}
|
||||
|
||||
.primary-cta-btn {
|
||||
height: 48px;
|
||||
background-color: var(--oc-primary, #0B5CFF);
|
||||
border-radius: var(--oc-radius-btn, 12px);
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.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>
|
||||
332
mpuniapp/pages/owner/card/index.uvue
普通文件
332
mpuniapp/pages/owner/card/index.uvue
普通文件
@@ -0,0 +1,332 @@
|
||||
<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="handleOpenEdit(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="handleOpenPoster(item)">{{ posterLabel }}</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 { utsLightColors, utsRadius, utsSpacing } from '../../../common/tokens.uts';
|
||||
import {
|
||||
applyCardHomeOptions,
|
||||
createCardHomeState,
|
||||
formatCardField,
|
||||
openCardEdit,
|
||||
openCardQrcode,
|
||||
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 posterLabel = ref(getOmniText(getCurrentLocale(), 'card.share'));
|
||||
|
||||
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 handleOpenPoster(item: CardHomeItem): void {
|
||||
openCardQrcode(item);
|
||||
}
|
||||
|
||||
async function handleRefresh(): Promise<void> {
|
||||
await refreshCards(state);
|
||||
}
|
||||
|
||||
onLoad((options: CardHomePageOptions) => {
|
||||
applyCardHomeOptions(state, options);
|
||||
refreshCards(state);
|
||||
});
|
||||
</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: 14px;
|
||||
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: 88px;
|
||||
}
|
||||
|
||||
.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;
|
||||
}
|
||||
|
||||
.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: 0;
|
||||
padding: 12px var(--oc-space-16, 16px) var(--oc-space-24, 24px) var(--oc-space-16, 16px);
|
||||
background-color: var(--oc-bg, #FFFFFF);
|
||||
border-top: 1px solid var(--oc-border, #E3E7ED);
|
||||
}
|
||||
|
||||
.primary-cta-btn {
|
||||
height: 48px;
|
||||
background-color: var(--oc-primary, #0B5CFF);
|
||||
border-radius: var(--oc-radius-btn, 12px);
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.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>
|
||||
@@ -0,0 +1,226 @@
|
||||
<template>
|
||||
<view class="qrcode-page" :style="pageTheme">
|
||||
<scroll-view class="qrcode-scroll" :scroll-y="true">
|
||||
<view class="qrcode-content">
|
||||
<view v-if="state.loading" class="qrcode-skeleton">
|
||||
<view class="skeleton-line"></view>
|
||||
<view class="skeleton-card"></view>
|
||||
</view>
|
||||
|
||||
<view v-else-if="state.errorMessage !== ''" class="qrcode-feedback">
|
||||
<text class="feedback-title">{{ t('error') }}</text>
|
||||
<text class="feedback-desc">{{ state.errorMessage }}</text>
|
||||
</view>
|
||||
|
||||
<view v-else-if="state.empty" class="qrcode-feedback">
|
||||
<text class="feedback-title">{{ t('empty') }}</text>
|
||||
<text class="feedback-desc">{{ t('urlLabel') }}</text>
|
||||
</view>
|
||||
|
||||
<view v-else class="qrcode-card">
|
||||
<text class="qrcode-title">{{ t('title') }}</text>
|
||||
<text class="qrcode-label">{{ t('urlLabel') }}</text>
|
||||
<text class="qrcode-url">{{ state.url }}</text>
|
||||
<text v-if="state.svg !== ''" class="qrcode-ready">{{ t('generated') }}</text>
|
||||
</view>
|
||||
</view>
|
||||
</scroll-view>
|
||||
|
||||
<view class="qrcode-cta-bar">
|
||||
<button
|
||||
class="primary-cta-btn"
|
||||
:class="{ 'primary-cta-btn-disabled': !canCopy }"
|
||||
:disabled="!canCopy"
|
||||
@click="handleCopy"
|
||||
>
|
||||
<text class="primary-cta-btn-text">{{ t('copyCta') }}</text>
|
||||
</button>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script setup lang="uts">
|
||||
import { utsLightColors, utsRadius, utsSpacing } from '../../../common/tokens.uts';
|
||||
import { getCurrentLocale, getOmniText } from '../../../common/locale.uts';
|
||||
import {
|
||||
applyQrcodeOptions,
|
||||
copyPosterUrl,
|
||||
createQrcodeState,
|
||||
loadPosterIntoState,
|
||||
resolveQrcodeText,
|
||||
QrcodeCopyKey,
|
||||
QrcodeQuery,
|
||||
} from './useCardQrcode.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(createQrcodeState());
|
||||
|
||||
const canCopy = computed((): boolean => {
|
||||
return state.url !== '' && !state.loading;
|
||||
});
|
||||
|
||||
function t(key: QrcodeCopyKey): string {
|
||||
if (key === 'title') {
|
||||
return getOmniText(getCurrentLocale(), 'card.share');
|
||||
}
|
||||
return resolveQrcodeText(key);
|
||||
}
|
||||
|
||||
function handleCopy(): void {
|
||||
copyPosterUrl(state.url);
|
||||
}
|
||||
|
||||
onLoad((options: QrcodeQuery) => {
|
||||
const slugOrId = applyQrcodeOptions(state, options);
|
||||
loadPosterIntoState(state, slugOrId);
|
||||
});
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.qrcode-page {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
height: 100%;
|
||||
background-color: var(--oc-surface, #F7F8FA);
|
||||
}
|
||||
|
||||
.qrcode-scroll {
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.qrcode-content {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
padding-inline: var(--oc-space-16, 16px);
|
||||
padding-block: var(--oc-space-16, 16px);
|
||||
}
|
||||
|
||||
.qrcode-skeleton {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.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: 160px;
|
||||
background-color: var(--oc-border, #E3E7ED);
|
||||
border-radius: var(--oc-radius-card, 16px);
|
||||
}
|
||||
|
||||
.qrcode-feedback {
|
||||
background-color: var(--oc-bg, #FFFFFF);
|
||||
border: 1px solid var(--oc-border, #E3E7ED);
|
||||
border-radius: var(--oc-radius-card, 16px);
|
||||
padding: var(--oc-space-24, 24px) 20px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.feedback-title {
|
||||
font-size: 20px;
|
||||
font-weight: 700;
|
||||
color: var(--oc-text, #101828);
|
||||
line-height: 1.25;
|
||||
margin-bottom: var(--oc-space-8, 8px);
|
||||
}
|
||||
|
||||
.feedback-desc {
|
||||
font-size: 14px;
|
||||
color: var(--oc-text-2, #667085);
|
||||
line-height: 1.6;
|
||||
}
|
||||
|
||||
.qrcode-card {
|
||||
background-color: var(--oc-bg, #FFFFFF);
|
||||
border: 1px solid var(--oc-border, #E3E7ED);
|
||||
border-radius: var(--oc-radius-card, 16px);
|
||||
padding: var(--oc-space-24, 24px) 20px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.qrcode-title {
|
||||
font-size: 24px;
|
||||
font-weight: 700;
|
||||
color: var(--oc-text, #101828);
|
||||
margin-bottom: var(--oc-space-16, 16px);
|
||||
line-height: 1.25;
|
||||
}
|
||||
|
||||
.qrcode-label {
|
||||
font-size: 14px;
|
||||
font-weight: 600;
|
||||
color: var(--oc-text, #101828);
|
||||
margin-bottom: var(--oc-space-8, 8px);
|
||||
}
|
||||
|
||||
.qrcode-url {
|
||||
font-size: 16px;
|
||||
color: var(--oc-text, #101828);
|
||||
line-height: 1.6;
|
||||
margin-bottom: var(--oc-space-12, 12px);
|
||||
word-break: break-all;
|
||||
}
|
||||
|
||||
.qrcode-ready {
|
||||
font-size: 14px;
|
||||
color: var(--oc-text-2, #667085);
|
||||
line-height: 1.6;
|
||||
}
|
||||
|
||||
.qrcode-cta-bar {
|
||||
position: fixed;
|
||||
left: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
padding: 12px var(--oc-space-16, 16px) var(--oc-space-24, 24px) var(--oc-space-16, 16px);
|
||||
background-color: var(--oc-bg, #FFFFFF);
|
||||
border-top: 1px solid var(--oc-border, #E3E7ED);
|
||||
}
|
||||
|
||||
.primary-cta-btn {
|
||||
height: 48px;
|
||||
background-color: var(--oc-primary, #0B5CFF);
|
||||
border-radius: var(--oc-radius-btn, 12px);
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.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>
|
||||
@@ -0,0 +1,476 @@
|
||||
/**
|
||||
* OmniCard AI (CRMmp) - 名片主极速编辑业务驱动层
|
||||
* 拉名片详情,仅提交已填字段,不做 Bento 搭建
|
||||
*/
|
||||
|
||||
import { CardProfile } from '../../../common/types.uts';
|
||||
import { fetchOwnerCardInfo, updateOwnerCard } from '../../../common/api.uts';
|
||||
import { getCurrentLocale, getOmniText } from '../../../common/locale.uts';
|
||||
|
||||
export type CardEditCopyKey =
|
||||
| 'heading'
|
||||
| 'name'
|
||||
| 'jobTitle'
|
||||
| 'company'
|
||||
| 'phone'
|
||||
| 'email'
|
||||
| 'whatsapp'
|
||||
| 'linkedin'
|
||||
| 'save'
|
||||
| 'loading'
|
||||
| 'success'
|
||||
| 'error'
|
||||
| 'empty'
|
||||
| 'missingId'
|
||||
| 'back';
|
||||
|
||||
export type CardEditForm = {
|
||||
id?: string | number | null;
|
||||
name?: string;
|
||||
title?: string;
|
||||
company?: string;
|
||||
slogan?: string;
|
||||
phone?: string;
|
||||
email?: string;
|
||||
whatsapp?: string;
|
||||
linkedin?: string;
|
||||
telegram?: string;
|
||||
twitter?: string;
|
||||
wechat?: string;
|
||||
};
|
||||
|
||||
export type CardUpdatePayload = {
|
||||
id: string | number;
|
||||
name?: string;
|
||||
title?: string;
|
||||
company?: string;
|
||||
slogan?: string;
|
||||
phone?: string;
|
||||
email?: string;
|
||||
whatsapp?: string;
|
||||
linkedin?: string;
|
||||
telegram?: string;
|
||||
twitter?: string;
|
||||
wechat?: string;
|
||||
};
|
||||
|
||||
export type LoadCardApi = {
|
||||
fetchOwnerCardInfo?: (id: string | number) => Promise<CardProfile>;
|
||||
};
|
||||
|
||||
export type LoadCardResult = {
|
||||
card: CardProfile | null;
|
||||
empty: boolean;
|
||||
errorMessage: string;
|
||||
};
|
||||
|
||||
export type SaveCardApi = {
|
||||
updateOwnerCard?: (
|
||||
payload: CardProfile & { id: string | number }
|
||||
) => Promise<CardProfile>;
|
||||
};
|
||||
|
||||
export type SaveCardResult = {
|
||||
ok: boolean;
|
||||
card: CardProfile | null;
|
||||
errorMessage: string;
|
||||
};
|
||||
|
||||
export type CardEditPageOptions = {
|
||||
id?: string;
|
||||
};
|
||||
|
||||
export type CardEditState = {
|
||||
rawId: string;
|
||||
cardId: number | null;
|
||||
name: string;
|
||||
title: string;
|
||||
company: string;
|
||||
phone: string;
|
||||
email: string;
|
||||
whatsapp: string;
|
||||
linkedin: string;
|
||||
loading: boolean;
|
||||
saving: boolean;
|
||||
empty: boolean;
|
||||
missingId: boolean;
|
||||
errorMessage: string;
|
||||
};
|
||||
|
||||
function isZhLocale(): boolean {
|
||||
return getCurrentLocale() === 'zh-CN';
|
||||
}
|
||||
|
||||
/**
|
||||
* 页面文案:保存 / 社交走词典,字段标签走本地词典
|
||||
*/
|
||||
export function resolveCardEditText(key: CardEditCopyKey): string {
|
||||
const locale = getCurrentLocale();
|
||||
if (key === 'save') {
|
||||
return getOmniText(locale, 'common.save');
|
||||
}
|
||||
if (key === 'loading') {
|
||||
return getOmniText(locale, 'common.loading');
|
||||
}
|
||||
if (key === 'success') {
|
||||
return getOmniText(locale, 'common.success');
|
||||
}
|
||||
if (key === 'error') {
|
||||
return getOmniText(locale, 'common.error');
|
||||
}
|
||||
if (key === 'empty') {
|
||||
return getOmniText(locale, 'common.empty');
|
||||
}
|
||||
if (key === 'whatsapp') {
|
||||
return getOmniText(locale, 'portal.whatsapp');
|
||||
}
|
||||
if (key === 'linkedin') {
|
||||
return getOmniText(locale, 'portal.linkedin');
|
||||
}
|
||||
|
||||
const zh = isZhLocale();
|
||||
if (key === 'heading') {
|
||||
return zh ? '极速编辑' : 'Quick edit';
|
||||
}
|
||||
if (key === 'name') {
|
||||
return zh ? '姓名' : 'Name';
|
||||
}
|
||||
if (key === 'jobTitle') {
|
||||
return zh ? '头衔' : 'Title';
|
||||
}
|
||||
if (key === 'company') {
|
||||
return zh ? '公司' : 'Company';
|
||||
}
|
||||
if (key === 'phone') {
|
||||
return zh ? '电话' : 'Phone';
|
||||
}
|
||||
if (key === 'email') {
|
||||
return zh ? '邮箱' : 'Email';
|
||||
}
|
||||
if (key === 'missingId') {
|
||||
return zh ? '缺少名片编号' : 'Card ID is missing';
|
||||
}
|
||||
if (key === 'back') {
|
||||
return zh ? '返回名片' : 'Back to card';
|
||||
}
|
||||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
* 解析为正整数。非正整数返回 null
|
||||
*/
|
||||
export function parseCardId(
|
||||
raw: string | number | null | undefined
|
||||
): number | null {
|
||||
if (raw == null) {
|
||||
return null;
|
||||
}
|
||||
if (typeof raw === 'number') {
|
||||
if (raw <= 0) {
|
||||
return null;
|
||||
}
|
||||
if (Math.floor(raw) !== raw) {
|
||||
return null;
|
||||
}
|
||||
return raw;
|
||||
}
|
||||
const text = String(raw).trim();
|
||||
if (text === '') {
|
||||
return null;
|
||||
}
|
||||
if (!/^[1-9]\d*$/.test(text)) {
|
||||
return null;
|
||||
}
|
||||
return Number(text);
|
||||
}
|
||||
|
||||
function pickFilled(value: string | null | undefined): string | null {
|
||||
if (value == null) {
|
||||
return null;
|
||||
}
|
||||
const text = String(value).trim();
|
||||
if (text === '') {
|
||||
return null;
|
||||
}
|
||||
return text;
|
||||
}
|
||||
|
||||
function assignFilled(
|
||||
payload: CardUpdatePayload,
|
||||
key:
|
||||
| 'name'
|
||||
| 'title'
|
||||
| 'company'
|
||||
| 'slogan'
|
||||
| 'phone'
|
||||
| 'email'
|
||||
| 'whatsapp'
|
||||
| 'linkedin'
|
||||
| 'telegram'
|
||||
| 'twitter'
|
||||
| 'wechat',
|
||||
value: string | null | undefined
|
||||
): void {
|
||||
const filled = pickFilled(value);
|
||||
if (filled != null) {
|
||||
payload[key] = filled;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 只带已填字段与解析后的 id。缺 id 返回 null
|
||||
*/
|
||||
export function buildUpdatePayload(form: CardEditForm): CardUpdatePayload | null {
|
||||
const id = parseCardId(form.id);
|
||||
if (id == null) {
|
||||
return null;
|
||||
}
|
||||
const payload: CardUpdatePayload = { id };
|
||||
assignFilled(payload, 'name', form.name);
|
||||
assignFilled(payload, 'title', form.title);
|
||||
assignFilled(payload, 'company', form.company);
|
||||
assignFilled(payload, 'slogan', form.slogan);
|
||||
assignFilled(payload, 'phone', form.phone);
|
||||
assignFilled(payload, 'email', form.email);
|
||||
assignFilled(payload, 'whatsapp', form.whatsapp);
|
||||
assignFilled(payload, 'linkedin', form.linkedin);
|
||||
assignFilled(payload, 'telegram', form.telegram);
|
||||
assignFilled(payload, 'twitter', form.twitter);
|
||||
assignFilled(payload, 'wechat', form.wechat);
|
||||
return payload;
|
||||
}
|
||||
|
||||
function readErrorMessage(err: unknown): string {
|
||||
if (err instanceof Error && err.message !== '') {
|
||||
return err.message;
|
||||
}
|
||||
return resolveCardEditText('error');
|
||||
}
|
||||
|
||||
function asUpdatePayload(
|
||||
payload: CardUpdatePayload
|
||||
): CardProfile & { id: string | number } {
|
||||
return payload as CardProfile & { id: string | number };
|
||||
}
|
||||
|
||||
/**
|
||||
* 拉取名片详情。可注入 fetchOwnerCardInfo。缺 id 不请求
|
||||
*/
|
||||
export async function loadCard(
|
||||
id: string | number | null | undefined,
|
||||
api?: LoadCardApi
|
||||
): Promise<LoadCardResult> {
|
||||
const cardId = parseCardId(id);
|
||||
if (cardId == null) {
|
||||
return {
|
||||
card: null,
|
||||
empty: true,
|
||||
errorMessage: '',
|
||||
};
|
||||
}
|
||||
|
||||
const fetchInfo =
|
||||
api != null && api.fetchOwnerCardInfo != null
|
||||
? api.fetchOwnerCardInfo
|
||||
: fetchOwnerCardInfo;
|
||||
|
||||
try {
|
||||
const card = await fetchInfo(cardId);
|
||||
return {
|
||||
card,
|
||||
empty: false,
|
||||
errorMessage: '',
|
||||
};
|
||||
} catch (err) {
|
||||
return {
|
||||
card: null,
|
||||
empty: true,
|
||||
errorMessage: readErrorMessage(err),
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存名片。可注入 updateOwnerCard。缺 id 不请求
|
||||
*/
|
||||
export async function saveCard(
|
||||
form: CardEditForm,
|
||||
api?: SaveCardApi
|
||||
): Promise<SaveCardResult> {
|
||||
const payload = buildUpdatePayload(form);
|
||||
if (payload == null) {
|
||||
return {
|
||||
ok: false,
|
||||
card: null,
|
||||
errorMessage: '',
|
||||
};
|
||||
}
|
||||
|
||||
const update =
|
||||
api != null && api.updateOwnerCard != null
|
||||
? api.updateOwnerCard
|
||||
: updateOwnerCard;
|
||||
|
||||
try {
|
||||
const card = await update(asUpdatePayload(payload));
|
||||
return {
|
||||
ok: true,
|
||||
card,
|
||||
errorMessage: '',
|
||||
};
|
||||
} catch (err) {
|
||||
return {
|
||||
ok: false,
|
||||
card: null,
|
||||
errorMessage: readErrorMessage(err),
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
export function createCardEditState(): CardEditState {
|
||||
return {
|
||||
rawId: '',
|
||||
cardId: null,
|
||||
name: '',
|
||||
title: '',
|
||||
company: '',
|
||||
phone: '',
|
||||
email: '',
|
||||
whatsapp: '',
|
||||
linkedin: '',
|
||||
loading: false,
|
||||
saving: false,
|
||||
empty: false,
|
||||
missingId: false,
|
||||
errorMessage: '',
|
||||
};
|
||||
}
|
||||
|
||||
export function applyCardEditOptions(
|
||||
state: CardEditState,
|
||||
options: CardEditPageOptions | null
|
||||
): boolean {
|
||||
if (options == null || options.id == null) {
|
||||
state.rawId = '';
|
||||
state.cardId = null;
|
||||
state.missingId = true;
|
||||
state.empty = true;
|
||||
return false;
|
||||
}
|
||||
const parsed = parseCardId(options.id);
|
||||
state.rawId = String(options.id).trim();
|
||||
state.cardId = parsed;
|
||||
state.missingId = parsed == null;
|
||||
state.empty = parsed == null;
|
||||
return parsed != null;
|
||||
}
|
||||
|
||||
function readOptionalText(value: string | null | undefined): string {
|
||||
if (value == null) {
|
||||
return '';
|
||||
}
|
||||
return String(value);
|
||||
}
|
||||
|
||||
function applyCardToState(state: CardEditState, card: CardProfile): void {
|
||||
if (card.id != null) {
|
||||
const parsed = parseCardId(card.id);
|
||||
if (parsed != null) {
|
||||
state.cardId = parsed;
|
||||
}
|
||||
}
|
||||
state.name = card.name != null ? String(card.name) : '';
|
||||
state.title = readOptionalText(card.title);
|
||||
state.company = readOptionalText(card.company);
|
||||
state.phone = readOptionalText(card.phone);
|
||||
state.email = readOptionalText(card.email);
|
||||
state.whatsapp = readOptionalText(card.whatsapp);
|
||||
state.linkedin = readOptionalText(card.linkedin);
|
||||
}
|
||||
|
||||
export function applyLoadResult(
|
||||
state: CardEditState,
|
||||
result: LoadCardResult
|
||||
): void {
|
||||
if (result.card != null) {
|
||||
applyCardToState(state, result.card);
|
||||
state.empty = false;
|
||||
state.missingId = false;
|
||||
} else {
|
||||
state.empty = true;
|
||||
}
|
||||
state.errorMessage = result.errorMessage;
|
||||
}
|
||||
|
||||
export function formFromState(state: CardEditState): CardEditForm {
|
||||
return {
|
||||
id: state.cardId,
|
||||
name: state.name,
|
||||
title: state.title,
|
||||
company: state.company,
|
||||
phone: state.phone,
|
||||
email: state.email,
|
||||
whatsapp: state.whatsapp,
|
||||
linkedin: state.linkedin,
|
||||
};
|
||||
}
|
||||
|
||||
export async function refreshCardEdit(
|
||||
state: CardEditState,
|
||||
api?: LoadCardApi
|
||||
): Promise<LoadCardResult> {
|
||||
if (state.missingId || state.cardId == null) {
|
||||
const skipped: LoadCardResult = {
|
||||
card: null,
|
||||
empty: true,
|
||||
errorMessage: '',
|
||||
};
|
||||
applyLoadResult(state, skipped);
|
||||
state.missingId = true;
|
||||
return skipped;
|
||||
}
|
||||
if (state.loading) {
|
||||
return {
|
||||
card: null,
|
||||
empty: state.empty,
|
||||
errorMessage: state.errorMessage,
|
||||
};
|
||||
}
|
||||
state.loading = true;
|
||||
state.errorMessage = '';
|
||||
const result = await loadCard(state.cardId, api);
|
||||
applyLoadResult(state, result);
|
||||
state.loading = false;
|
||||
return result;
|
||||
}
|
||||
|
||||
export async function submitCardEdit(
|
||||
state: CardEditState,
|
||||
api?: SaveCardApi
|
||||
): Promise<boolean> {
|
||||
if (state.cardId == null || state.saving) {
|
||||
return false;
|
||||
}
|
||||
state.saving = true;
|
||||
state.errorMessage = '';
|
||||
const result = await saveCard(formFromState(state), api);
|
||||
if (result.ok && result.card != null) {
|
||||
applyCardToState(state, result.card);
|
||||
state.saving = false;
|
||||
return true;
|
||||
}
|
||||
state.saving = false;
|
||||
state.errorMessage = result.errorMessage;
|
||||
return false;
|
||||
}
|
||||
|
||||
export function goBackFromCardEdit(): void {
|
||||
uni.navigateBack({
|
||||
delta: 1,
|
||||
fail: () => {
|
||||
uni.reLaunch({
|
||||
url: '/pages/owner/card/index',
|
||||
});
|
||||
},
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,313 @@
|
||||
/**
|
||||
* OmniCard AI (CRMmp) - 名片主移动名片中心业务驱动层
|
||||
* 分页拉自己的名片、空态与错误、编辑 / 海报跳转
|
||||
*/
|
||||
|
||||
import {
|
||||
CardProfile,
|
||||
CardStatus,
|
||||
OwnerPageData,
|
||||
OwnerPageQuery,
|
||||
} from '../../../common/types.uts';
|
||||
import { fetchOwnerCardPage } from '../../../common/api.uts';
|
||||
import { getCurrentLocale, getOmniText } from '../../../common/locale.uts';
|
||||
|
||||
export type CardHomeItem = {
|
||||
id?: string | number;
|
||||
name: string;
|
||||
title?: string;
|
||||
company?: string;
|
||||
status?: CardStatus;
|
||||
slug?: string;
|
||||
};
|
||||
|
||||
export type CardHomeCopyKey =
|
||||
| 'title'
|
||||
| 'subtitle'
|
||||
| 'searchPlaceholder'
|
||||
| 'refresh'
|
||||
| 'poster'
|
||||
| 'empty'
|
||||
| 'error'
|
||||
| 'loading'
|
||||
| 'statusDraft'
|
||||
| 'statusPublished'
|
||||
| 'statusArchived';
|
||||
|
||||
export type LoadCardsQuery = {
|
||||
page: number;
|
||||
size: number;
|
||||
keyWord?: string;
|
||||
};
|
||||
|
||||
export type LoadCardsApi = {
|
||||
fetchOwnerCardPage: (
|
||||
query: OwnerPageQuery
|
||||
) => Promise<OwnerPageData<CardProfile>>;
|
||||
};
|
||||
|
||||
export type LoadCardsResult = {
|
||||
list: CardHomeItem[];
|
||||
pagination: {
|
||||
page: number;
|
||||
size: number;
|
||||
total: number;
|
||||
};
|
||||
empty: boolean;
|
||||
errorMessage: string;
|
||||
};
|
||||
|
||||
export type CardHomeState = {
|
||||
list: CardHomeItem[];
|
||||
page: number;
|
||||
size: number;
|
||||
total: number;
|
||||
keyWord: string;
|
||||
loading: boolean;
|
||||
empty: boolean;
|
||||
errorMessage: string;
|
||||
};
|
||||
|
||||
export type CardHomePageOptions = {
|
||||
keyWord?: string;
|
||||
page?: string;
|
||||
size?: string;
|
||||
};
|
||||
|
||||
function isZhLocale(): boolean {
|
||||
return getCurrentLocale() === 'zh-CN';
|
||||
}
|
||||
|
||||
/**
|
||||
* 页面文案:分享走词典,标题 / 刷新 / 状态用本地词典
|
||||
*/
|
||||
export function resolveCardHomeText(key: CardHomeCopyKey): string {
|
||||
const locale = getCurrentLocale();
|
||||
if (key === 'poster') {
|
||||
return getOmniText(locale, 'card.share');
|
||||
}
|
||||
if (key === 'empty') {
|
||||
return getOmniText(locale, 'common.empty');
|
||||
}
|
||||
if (key === 'error') {
|
||||
return getOmniText(locale, 'common.error');
|
||||
}
|
||||
if (key === 'loading') {
|
||||
return getOmniText(locale, 'common.loading');
|
||||
}
|
||||
|
||||
const zh = isZhLocale();
|
||||
if (key === 'title') {
|
||||
return zh ? '名片中心' : 'Cards';
|
||||
}
|
||||
if (key === 'subtitle') {
|
||||
return zh ? '编辑资料或生成分享海报' : 'Edit a card or open its poster';
|
||||
}
|
||||
if (key === 'searchPlaceholder') {
|
||||
return zh ? '搜索姓名、职位或公司' : 'Search name, title or company';
|
||||
}
|
||||
if (key === 'refresh') {
|
||||
return zh ? '刷新名片' : 'Refresh cards';
|
||||
}
|
||||
if (key === 'statusDraft') {
|
||||
return zh ? '草稿' : 'Draft';
|
||||
}
|
||||
if (key === 'statusPublished') {
|
||||
return zh ? '已发布' : 'Published';
|
||||
}
|
||||
if (key === 'statusArchived') {
|
||||
return zh ? '已归档' : 'Archived';
|
||||
}
|
||||
return '';
|
||||
}
|
||||
|
||||
export function statusLabel(status: string | null | undefined): string {
|
||||
if (status === 'draft') {
|
||||
return resolveCardHomeText('statusDraft');
|
||||
}
|
||||
if (status === 'published') {
|
||||
return resolveCardHomeText('statusPublished');
|
||||
}
|
||||
if (status === 'archived') {
|
||||
return resolveCardHomeText('statusArchived');
|
||||
}
|
||||
return status != null ? status : '';
|
||||
}
|
||||
|
||||
export function formatCardField(value: string | null | undefined): string {
|
||||
if (value == null) {
|
||||
return '';
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
function readOptionalSlug(card: CardProfile): string {
|
||||
const extra = card as CardHomeItem;
|
||||
if (extra.slug == null) {
|
||||
return '';
|
||||
}
|
||||
return extra.slug.trim();
|
||||
}
|
||||
|
||||
export function toCardHomeItem(card: CardProfile): CardHomeItem {
|
||||
const slug = readOptionalSlug(card);
|
||||
return {
|
||||
id: card.id,
|
||||
name: card.name,
|
||||
title: card.title,
|
||||
company: card.company,
|
||||
status: card.status,
|
||||
slug: slug !== '' ? slug : undefined,
|
||||
};
|
||||
}
|
||||
|
||||
export function sanitizeCardQuery(query: LoadCardsQuery): OwnerPageQuery {
|
||||
const next: OwnerPageQuery = {
|
||||
page: query.page,
|
||||
size: query.size,
|
||||
};
|
||||
if (query.keyWord != null) {
|
||||
const word = query.keyWord.trim();
|
||||
if (word !== '') {
|
||||
next.keyWord = word;
|
||||
}
|
||||
}
|
||||
return next;
|
||||
}
|
||||
|
||||
function readErrorMessage(err: unknown): string {
|
||||
if (err instanceof Error && err.message !== '') {
|
||||
return err.message;
|
||||
}
|
||||
return resolveCardHomeText('error');
|
||||
}
|
||||
|
||||
/**
|
||||
* 拉取名片分页。可注入 fetchOwnerCardPage
|
||||
*/
|
||||
export async function loadCards(
|
||||
query: LoadCardsQuery,
|
||||
api?: LoadCardsApi
|
||||
): Promise<LoadCardsResult> {
|
||||
const fetchPage =
|
||||
api != null ? api.fetchOwnerCardPage : fetchOwnerCardPage;
|
||||
try {
|
||||
const data = await fetchPage(sanitizeCardQuery(query));
|
||||
const rawList = data.list != null ? data.list : [];
|
||||
const list: CardHomeItem[] = [];
|
||||
for (let i = 0; i < rawList.length; i++) {
|
||||
list.push(toCardHomeItem(rawList[i]));
|
||||
}
|
||||
const pagination =
|
||||
data.pagination != null
|
||||
? data.pagination
|
||||
: { page: query.page, size: query.size, total: list.length };
|
||||
return {
|
||||
list,
|
||||
pagination,
|
||||
empty: list.length === 0,
|
||||
errorMessage: '',
|
||||
};
|
||||
} catch (err) {
|
||||
return {
|
||||
list: [],
|
||||
pagination: { page: query.page, size: query.size, total: 0 },
|
||||
empty: false,
|
||||
errorMessage: readErrorMessage(err),
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
export function createCardHomeState(): CardHomeState {
|
||||
return {
|
||||
list: [],
|
||||
page: 1,
|
||||
size: 20,
|
||||
total: 0,
|
||||
keyWord: '',
|
||||
loading: false,
|
||||
empty: false,
|
||||
errorMessage: '',
|
||||
};
|
||||
}
|
||||
|
||||
export function applyCardHomeOptions(
|
||||
state: CardHomeState,
|
||||
options: CardHomePageOptions | null
|
||||
): void {
|
||||
if (options == null) {
|
||||
return;
|
||||
}
|
||||
if (options.keyWord != null) {
|
||||
state.keyWord = options.keyWord;
|
||||
}
|
||||
}
|
||||
|
||||
export function applyLoadResult(
|
||||
state: CardHomeState,
|
||||
result: LoadCardsResult
|
||||
): void {
|
||||
state.list = result.list;
|
||||
state.page = result.pagination.page;
|
||||
state.size = result.pagination.size;
|
||||
state.total = result.pagination.total;
|
||||
state.empty = result.empty;
|
||||
state.errorMessage = result.errorMessage;
|
||||
}
|
||||
|
||||
export async function refreshCards(
|
||||
state: CardHomeState,
|
||||
api?: LoadCardsApi
|
||||
): Promise<LoadCardsResult> {
|
||||
if (state.loading) {
|
||||
return {
|
||||
list: state.list,
|
||||
pagination: {
|
||||
page: state.page,
|
||||
size: state.size,
|
||||
total: state.total,
|
||||
},
|
||||
empty: state.empty,
|
||||
errorMessage: state.errorMessage,
|
||||
};
|
||||
}
|
||||
state.loading = true;
|
||||
state.errorMessage = '';
|
||||
const result = await loadCards(
|
||||
{
|
||||
page: state.page,
|
||||
size: state.size,
|
||||
keyWord: state.keyWord,
|
||||
},
|
||||
api
|
||||
);
|
||||
applyLoadResult(state, result);
|
||||
state.loading = false;
|
||||
return result;
|
||||
}
|
||||
|
||||
export function buildEditUrl(id: string | number): string {
|
||||
return `/pages/owner/card/edit?id=${id}`;
|
||||
}
|
||||
|
||||
export function buildQrcodeUrl(card: CardHomeItem): string {
|
||||
if (card.slug != null && card.slug !== '') {
|
||||
return `/pages/owner/card/qrcode?slug=${card.slug}`;
|
||||
}
|
||||
if (card.id != null) {
|
||||
return `/pages/owner/card/qrcode?id=${card.id}`;
|
||||
}
|
||||
return '/pages/owner/card/qrcode?id=';
|
||||
}
|
||||
|
||||
export function openCardEdit(id: string | number): void {
|
||||
uni.navigateTo({
|
||||
url: buildEditUrl(id),
|
||||
});
|
||||
}
|
||||
|
||||
export function openCardQrcode(card: CardHomeItem): void {
|
||||
uni.navigateTo({
|
||||
url: buildQrcodeUrl(card),
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,266 @@
|
||||
/**
|
||||
* OmniCard AI (CRMmp) - 名片主参展分享码海报业务驱动层
|
||||
* 解析 slug / id,拉取公开短链二维码,复制链接
|
||||
*/
|
||||
|
||||
import { fetchCardQrcodeSvg } from '../../../common/api.uts';
|
||||
import {
|
||||
getCurrentLocale,
|
||||
getOmniText,
|
||||
OmniLocale,
|
||||
} from '../../../common/locale.uts';
|
||||
|
||||
export type QrcodeQuery = {
|
||||
slug?: string;
|
||||
id?: string;
|
||||
};
|
||||
|
||||
export type CardQrcodePoster = {
|
||||
svg: string;
|
||||
url: string;
|
||||
};
|
||||
|
||||
export type LoadPosterApi = {
|
||||
fetchCardQrcodeSvg: (slugOrId: string) => Promise<CardQrcodePoster>;
|
||||
};
|
||||
|
||||
export type LoadPosterResult = {
|
||||
svg: string;
|
||||
url: string;
|
||||
empty: boolean;
|
||||
errorMessage: string;
|
||||
};
|
||||
|
||||
export type QrcodeState = {
|
||||
slugOrId: string;
|
||||
svg: string;
|
||||
url: string;
|
||||
loading: boolean;
|
||||
empty: boolean;
|
||||
errorMessage: string;
|
||||
};
|
||||
|
||||
export type QrcodeCopyKey =
|
||||
| 'copyCta'
|
||||
| 'generated'
|
||||
| 'urlLabel'
|
||||
| 'empty'
|
||||
| 'error'
|
||||
| 'loading'
|
||||
| 'title';
|
||||
|
||||
const QRCODE_COPY: Record<OmniLocale, Record<QrcodeCopyKey, string>> = {
|
||||
'zh-CN': {
|
||||
title: '分享名片',
|
||||
copyCta: '复制链接',
|
||||
generated: '二维码已生成',
|
||||
urlLabel: '短链',
|
||||
empty: '暂无数据',
|
||||
error: '出错了',
|
||||
loading: '加载中...',
|
||||
},
|
||||
'en-US': {
|
||||
title: 'Share Card',
|
||||
copyCta: 'Copy link',
|
||||
generated: 'QR code ready',
|
||||
urlLabel: 'Short link',
|
||||
empty: 'Nothing here yet',
|
||||
error: 'Something went wrong',
|
||||
loading: 'Loading...',
|
||||
},
|
||||
'ar-SA': {
|
||||
title: 'مشاركة البطاقة',
|
||||
copyCta: 'نسخ الرابط',
|
||||
generated: 'رمز الاستجابة جاهز',
|
||||
urlLabel: 'الرابط المختصر',
|
||||
empty: 'لا توجد بيانات بعد',
|
||||
error: 'حدث خطأ',
|
||||
loading: 'جار التحميل...',
|
||||
},
|
||||
'es-ES': {
|
||||
title: 'Compartir tarjeta',
|
||||
copyCta: 'Copiar enlace',
|
||||
generated: 'Codigo QR listo',
|
||||
urlLabel: 'Enlace corto',
|
||||
empty: 'Aun no hay datos',
|
||||
error: 'Algo salio mal',
|
||||
loading: 'Cargando...',
|
||||
},
|
||||
'de-DE': {
|
||||
title: 'Karte teilen',
|
||||
copyCta: 'Link kopieren',
|
||||
generated: 'QR-Code bereit',
|
||||
urlLabel: 'Kurzlink',
|
||||
empty: 'Noch keine Daten',
|
||||
error: 'Etwas ist schiefgelaufen',
|
||||
loading: 'Wird geladen...',
|
||||
},
|
||||
'fr-FR': {
|
||||
title: 'Partager la carte',
|
||||
copyCta: 'Copier le lien',
|
||||
generated: 'QR code pret',
|
||||
urlLabel: 'Lien court',
|
||||
empty: 'Aucune donnee',
|
||||
error: 'Une erreur est survenue',
|
||||
loading: 'Chargement...',
|
||||
},
|
||||
'ja-JP': {
|
||||
title: '名刺をシェア',
|
||||
copyCta: 'リンクをコピー',
|
||||
generated: 'QRコードを生成しました',
|
||||
urlLabel: 'ショートリンク',
|
||||
empty: 'データがありません',
|
||||
error: 'エラーが発生しました',
|
||||
loading: '読み込み中...',
|
||||
},
|
||||
};
|
||||
|
||||
function trimText(value: string | number | null | undefined): string {
|
||||
if (value == null) {
|
||||
return '';
|
||||
}
|
||||
return String(value).trim();
|
||||
}
|
||||
|
||||
/**
|
||||
* 页面文案:能复用 locale.uts 的走词典,其余走本地七语表
|
||||
*/
|
||||
export function resolveQrcodeText(key: QrcodeCopyKey): string {
|
||||
if (key === 'title') {
|
||||
return getOmniText(getCurrentLocale(), 'card.share');
|
||||
}
|
||||
if (key === 'empty') {
|
||||
return getOmniText(getCurrentLocale(), 'common.empty');
|
||||
}
|
||||
if (key === 'error') {
|
||||
return getOmniText(getCurrentLocale(), 'common.error');
|
||||
}
|
||||
if (key === 'loading') {
|
||||
return getOmniText(getCurrentLocale(), 'common.loading');
|
||||
}
|
||||
const locale = getCurrentLocale();
|
||||
const bag = QRCODE_COPY[locale] != null ? QRCODE_COPY[locale] : QRCODE_COPY['en-US'];
|
||||
return bag[key];
|
||||
}
|
||||
|
||||
/**
|
||||
* 路由查询优先 slug,否则 id
|
||||
*/
|
||||
export function resolveSlugOrId(query: QrcodeQuery | null | undefined): string {
|
||||
if (query == null) {
|
||||
return '';
|
||||
}
|
||||
const slug = trimText(query.slug);
|
||||
if (slug !== '') {
|
||||
return slug;
|
||||
}
|
||||
return trimText(query.id);
|
||||
}
|
||||
|
||||
function resolvePosterApi(api?: LoadPosterApi): LoadPosterApi {
|
||||
if (api != null) {
|
||||
return api;
|
||||
}
|
||||
return {
|
||||
fetchCardQrcodeSvg,
|
||||
};
|
||||
}
|
||||
|
||||
export function createQrcodeState(): QrcodeState {
|
||||
return {
|
||||
slugOrId: '',
|
||||
svg: '',
|
||||
url: '',
|
||||
loading: false,
|
||||
empty: false,
|
||||
errorMessage: '',
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* 拉取公开 SVG 海报:可注入 fetchCardQrcodeSvg
|
||||
*/
|
||||
export async function loadPoster(
|
||||
slugOrId: string | null | undefined,
|
||||
api?: LoadPosterApi
|
||||
): Promise<LoadPosterResult> {
|
||||
const key = trimText(slugOrId);
|
||||
if (key === '') {
|
||||
return {
|
||||
svg: '',
|
||||
url: '',
|
||||
empty: true,
|
||||
errorMessage: '',
|
||||
};
|
||||
}
|
||||
|
||||
try {
|
||||
const poster = await resolvePosterApi(api).fetchCardQrcodeSvg(key);
|
||||
const svg = poster != null && poster.svg != null ? String(poster.svg) : '';
|
||||
const url = poster != null && poster.url != null ? String(poster.url) : '';
|
||||
return {
|
||||
svg,
|
||||
url,
|
||||
empty: svg === '' && url === '',
|
||||
errorMessage: '',
|
||||
};
|
||||
} catch (err) {
|
||||
const message =
|
||||
err instanceof Error
|
||||
? err.message
|
||||
: getOmniText(getCurrentLocale(), 'common.error');
|
||||
return {
|
||||
svg: '',
|
||||
url: '',
|
||||
empty: false,
|
||||
errorMessage: message,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
export async function loadPosterIntoState(
|
||||
state: QrcodeState,
|
||||
slugOrId: string | null | undefined,
|
||||
api?: LoadPosterApi
|
||||
): Promise<LoadPosterResult> {
|
||||
state.slugOrId = trimText(slugOrId);
|
||||
state.loading = true;
|
||||
state.errorMessage = '';
|
||||
const result = await loadPoster(state.slugOrId, api);
|
||||
state.svg = result.svg;
|
||||
state.url = result.url;
|
||||
state.empty = result.empty;
|
||||
state.errorMessage = result.errorMessage;
|
||||
state.loading = false;
|
||||
return result;
|
||||
}
|
||||
|
||||
export function applyQrcodeOptions(
|
||||
state: QrcodeState,
|
||||
options: QrcodeQuery | null | undefined
|
||||
): string {
|
||||
const slugOrId = resolveSlugOrId(options);
|
||||
state.slugOrId = slugOrId;
|
||||
return slugOrId;
|
||||
}
|
||||
|
||||
/**
|
||||
* 主 CTA:复制短链
|
||||
*/
|
||||
export function copyPosterUrl(url: string | null | undefined): boolean {
|
||||
const text = trimText(url);
|
||||
if (text === '') {
|
||||
return false;
|
||||
}
|
||||
|
||||
uni.setClipboardData({
|
||||
data: text,
|
||||
success: () => {
|
||||
uni.showToast({
|
||||
title: getOmniText(getCurrentLocale(), 'portal.copied_link'),
|
||||
icon: 'none',
|
||||
});
|
||||
},
|
||||
});
|
||||
return true;
|
||||
}
|
||||
在新工单中引用
屏蔽一个用户