refactor(arch): 落地平台架构演进第一二阶段整改,消除OOM与越权风险并支持高并发缓冲与AI多租户BYOK
- [P0安全底座] 多租户数据闭环:公开留资与雷达足迹自动逆向追溯绑定名片 tenantId 与归属销售 userId - [P0性能稳定] 消除内存全量加载:公海池分批带条件扫描回收,雷达国家分布改用 SQL 原生 GROUP BY 聚合查询彻底消除 OOM 隐患 - [P0商业变现] 商业化配额门禁切面:在 Cool-Admin modifyBefore 生命周期织入 assertQuotaAvailable 校验,阻断超额名片创建 - [P0环境解耦] 客户端解耦本地硬编码:request.uts 支持 api_base_url 本地覆盖,生产数据库名修正为 crmmpdata - [P1高并发削峰] 雷达足迹批量缓冲引擎:引入 CrmRadarBufferService 环形缓冲队列与阈值/定时批量 Bulk Insert 落盘 - [P2中枢租户化] AI 智能中枢多租户 BYOK 与 Token 成本风控:支持企业自带 Key 隔离、Token 消耗账本、用量配额门禁与名片人设个性化联动 - [跨端规范] 对齐 Uni-app x 移动微官网原生首屏与底部原生 tabBar 规范 - [测试驱动] 全工程 116 个测试套件,1,175 个单元与集成测试用例全部 100% 绿色通过,管理后台 Vite 打包无错误
这个提交包含在:
@@ -30,7 +30,7 @@
|
||||
|
||||
<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-row" @click="handleOpenPreview(item)">
|
||||
<view class="card-main">
|
||||
<text class="card-name">{{ item.name }}</text>
|
||||
<text class="card-title">{{ formatField(item.title) }}</text>
|
||||
@@ -38,7 +38,7 @@
|
||||
</view>
|
||||
<view class="card-meta">
|
||||
<text class="card-status">{{ statusLabelOf(item.status) }}</text>
|
||||
<text class="card-poster" @click.stop="handleOpenPoster(item)">{{ posterLabel }}</text>
|
||||
<text class="card-poster" @click.stop="handleOpenEdit(item)">{{ editLabel }}</text>
|
||||
</view>
|
||||
</view>
|
||||
</list-item>
|
||||
@@ -59,13 +59,17 @@
|
||||
|
||||
<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,
|
||||
@@ -94,7 +98,7 @@ 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 editLabel = ref(getOmniText(getCurrentLocale(), 'common.edit'));
|
||||
|
||||
const ctaLabel = computed((): string => {
|
||||
if (state.loading) {
|
||||
@@ -122,17 +126,35 @@ function handleOpenEdit(item: CardHomeItem): void {
|
||||
openCardEdit(item.id);
|
||||
}
|
||||
|
||||
function handleOpenPoster(item: CardHomeItem): void {
|
||||
openCardQrcode(item);
|
||||
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();
|
||||
});
|
||||
</script>
|
||||
|
||||
|
||||
@@ -26,13 +26,16 @@ export type CardHomeCopyKey =
|
||||
| 'subtitle'
|
||||
| 'searchPlaceholder'
|
||||
| 'refresh'
|
||||
| 'share'
|
||||
| 'preview'
|
||||
| 'poster'
|
||||
| 'empty'
|
||||
| 'error'
|
||||
| 'loading'
|
||||
| 'statusDraft'
|
||||
| 'statusPublished'
|
||||
| 'statusArchived';
|
||||
| 'statusArchived'
|
||||
| 'quotaExceeded';
|
||||
|
||||
export type LoadCardsQuery = {
|
||||
page: number;
|
||||
@@ -83,9 +86,12 @@ function isZhLocale(): boolean {
|
||||
*/
|
||||
export function resolveCardHomeText(key: CardHomeCopyKey): string {
|
||||
const locale = getCurrentLocale();
|
||||
if (key === 'poster') {
|
||||
if (key === 'poster' || key === 'share') {
|
||||
return getOmniText(locale, 'card.share');
|
||||
}
|
||||
if (key === 'preview') {
|
||||
return getOmniText(locale, 'card.view_profile');
|
||||
}
|
||||
if (key === 'empty') {
|
||||
return getOmniText(locale, 'common.empty');
|
||||
}
|
||||
@@ -98,16 +104,16 @@ export function resolveCardHomeText(key: CardHomeCopyKey): string {
|
||||
|
||||
const zh = isZhLocale();
|
||||
if (key === 'title') {
|
||||
return zh ? '名片中心' : 'Cards';
|
||||
return zh ? '我的名片' : 'My cards';
|
||||
}
|
||||
if (key === 'subtitle') {
|
||||
return zh ? '编辑资料或生成分享海报' : 'Edit a card or open its poster';
|
||||
return zh ? '预览微官网或分享当前名片' : 'Preview the site or share a card';
|
||||
}
|
||||
if (key === 'searchPlaceholder') {
|
||||
return zh ? '搜索姓名、职位或公司' : 'Search name, title or company';
|
||||
}
|
||||
if (key === 'refresh') {
|
||||
return zh ? '刷新名片' : 'Refresh cards';
|
||||
return zh ? '分享名片' : 'Share card';
|
||||
}
|
||||
if (key === 'statusDraft') {
|
||||
return zh ? '草稿' : 'Draft';
|
||||
@@ -118,6 +124,9 @@ export function resolveCardHomeText(key: CardHomeCopyKey): string {
|
||||
if (key === 'statusArchived') {
|
||||
return zh ? '已归档' : 'Archived';
|
||||
}
|
||||
if (key === 'quotaExceeded') {
|
||||
return zh ? '名片配额已满,升级后可继续创建' : 'Card quota is full. Upgrade to create more.';
|
||||
}
|
||||
return '';
|
||||
}
|
||||
|
||||
@@ -311,3 +320,31 @@ export function openCardQrcode(card: CardHomeItem): void {
|
||||
url: buildQrcodeUrl(card),
|
||||
});
|
||||
}
|
||||
|
||||
export function buildPortalPreviewUrl(card: CardHomeItem): string {
|
||||
if (card.slug != null && card.slug !== '') {
|
||||
return `/pages/portal/index?slug=${card.slug}`;
|
||||
}
|
||||
if (card.id != null) {
|
||||
return `/pages/portal/index?id=${card.id}`;
|
||||
}
|
||||
return '/pages/portal/index';
|
||||
}
|
||||
|
||||
export function openCardPreview(card: CardHomeItem): void {
|
||||
uni.navigateTo({
|
||||
url: buildPortalPreviewUrl(card),
|
||||
});
|
||||
}
|
||||
|
||||
export function pickShareCard(list: CardHomeItem[]): CardHomeItem | null {
|
||||
for (let i = 0; i < list.length; i++) {
|
||||
if (list[i].status === 'published') {
|
||||
return list[i];
|
||||
}
|
||||
}
|
||||
if (list.length > 0) {
|
||||
return list[0];
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
368
mpuniapp/pages/owner/hall/index.uvue
普通文件
368
mpuniapp/pages/owner/hall/index.uvue
普通文件
@@ -0,0 +1,368 @@
|
||||
<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>
|
||||
<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"
|
||||
/>
|
||||
</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,
|
||||
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 emptyDesc = computed((): string => {
|
||||
if (state.tab === 'team') {
|
||||
return resolveHallText('teamEmpty');
|
||||
}
|
||||
return pageSubtitle.value;
|
||||
});
|
||||
|
||||
const ctaLabel = computed((): string => {
|
||||
if (state.loading) {
|
||||
return resolveHallText('loading');
|
||||
}
|
||||
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.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>
|
||||
@@ -0,0 +1,273 @@
|
||||
/**
|
||||
* OmniCard AI - 名片大厅人脉驱动层
|
||||
*/
|
||||
|
||||
import {
|
||||
CardContact,
|
||||
OwnerPageData,
|
||||
OwnerPageQuery,
|
||||
} from '../../../common/types.uts';
|
||||
import {
|
||||
collectHallContact,
|
||||
confirmHallExchange,
|
||||
fetchHallContactPage,
|
||||
fetchTeamWallPage,
|
||||
} from '../../../common/api.uts';
|
||||
import { getCurrentLocale, getOmniText } from '../../../common/locale.uts';
|
||||
|
||||
export type HallCopyKey =
|
||||
| 'title'
|
||||
| 'subtitle'
|
||||
| 'searchPlaceholder'
|
||||
| 'refresh'
|
||||
| 'exchangePlaceholder'
|
||||
| 'exchange'
|
||||
| 'empty'
|
||||
| 'error'
|
||||
| 'loading'
|
||||
| 'scan'
|
||||
| 'tabContacts'
|
||||
| 'tabTeam'
|
||||
| 'teamEmpty';
|
||||
|
||||
export type HallContactItem = {
|
||||
id?: string | number;
|
||||
peerCardId: number;
|
||||
peerName: string;
|
||||
peerTitle?: string;
|
||||
peerCompany?: string;
|
||||
peerSlug?: string;
|
||||
source?: string;
|
||||
};
|
||||
|
||||
export type HallTab = 'contacts' | 'team';
|
||||
|
||||
export type HallState = {
|
||||
tab: HallTab;
|
||||
list: HallContactItem[];
|
||||
page: number;
|
||||
size: number;
|
||||
total: number;
|
||||
keyWord: string;
|
||||
exchangeCode: string;
|
||||
loading: boolean;
|
||||
empty: boolean;
|
||||
errorMessage: string;
|
||||
};
|
||||
|
||||
export type LoadHallApi = {
|
||||
fetchHallContactPage: (
|
||||
query: OwnerPageQuery
|
||||
) => Promise<OwnerPageData<CardContact>>;
|
||||
fetchTeamWallPage?: (
|
||||
query: OwnerPageQuery
|
||||
) => Promise<OwnerPageData<CardContact>>;
|
||||
confirmHallExchange?: (
|
||||
exchangeCode: string
|
||||
) => Promise<{ status: string; isDualSynced: boolean }>;
|
||||
collectHallContact?: (peerCardId: string | number) => Promise<CardContact>;
|
||||
};
|
||||
|
||||
function isZhLocale(): boolean {
|
||||
return getCurrentLocale() === 'zh-CN';
|
||||
}
|
||||
|
||||
export function resolveHallText(key: HallCopyKey): string {
|
||||
const locale = getCurrentLocale();
|
||||
if (key === 'empty') {
|
||||
return getOmniText(locale, 'common.empty');
|
||||
}
|
||||
if (key === 'error') {
|
||||
return getOmniText(locale, 'common.error');
|
||||
}
|
||||
if (key === 'loading') {
|
||||
return getOmniText(locale, 'common.loading');
|
||||
}
|
||||
if (key === 'scan') {
|
||||
return getOmniText(locale, 'card.scan_nfc');
|
||||
}
|
||||
|
||||
const zh = isZhLocale();
|
||||
if (key === 'title') {
|
||||
return zh ? '名片大厅' : 'Card hall';
|
||||
}
|
||||
if (key === 'subtitle') {
|
||||
return zh ? '已互换和收藏的名片' : 'Exchanged and saved cards';
|
||||
}
|
||||
if (key === 'searchPlaceholder') {
|
||||
return zh ? '搜索姓名或公司' : 'Search name or company';
|
||||
}
|
||||
if (key === 'refresh') {
|
||||
return zh ? '刷新人脉' : 'Refresh network';
|
||||
}
|
||||
if (key === 'exchangePlaceholder') {
|
||||
return zh ? '输入 6 位互换码' : '6-digit exchange code';
|
||||
}
|
||||
if (key === 'exchange') {
|
||||
return zh ? '确认互换' : 'Confirm exchange';
|
||||
}
|
||||
if (key === 'tabContacts') {
|
||||
return zh ? '人脉' : 'Network';
|
||||
}
|
||||
if (key === 'tabTeam') {
|
||||
return zh ? '团队' : 'Team';
|
||||
}
|
||||
if (key === 'teamEmpty') {
|
||||
return zh ? '还没有同事发布名片' : 'No published teammate cards yet';
|
||||
}
|
||||
return '';
|
||||
}
|
||||
|
||||
export function toHallItem(row: CardContact): HallContactItem {
|
||||
return {
|
||||
id: row.id,
|
||||
peerCardId: Number(row.peerCardId),
|
||||
peerName: row.peerName != null ? row.peerName : '',
|
||||
peerTitle: row.peerTitle,
|
||||
peerCompany: row.peerCompany,
|
||||
peerSlug: row.peerSlug,
|
||||
source: row.source,
|
||||
};
|
||||
}
|
||||
|
||||
export function createHallState(): HallState {
|
||||
return {
|
||||
tab: 'contacts',
|
||||
list: [],
|
||||
page: 1,
|
||||
size: 20,
|
||||
total: 0,
|
||||
keyWord: '',
|
||||
exchangeCode: '',
|
||||
loading: false,
|
||||
empty: false,
|
||||
errorMessage: '',
|
||||
};
|
||||
}
|
||||
|
||||
function readErrorMessage(err: unknown): string {
|
||||
if (err instanceof Error && err.message !== '') {
|
||||
return err.message;
|
||||
}
|
||||
return resolveHallText('error');
|
||||
}
|
||||
|
||||
export function buildHallPortalUrl(item: HallContactItem): string {
|
||||
if (item.peerSlug != null && item.peerSlug !== '') {
|
||||
return `/pages/portal/index?slug=${item.peerSlug}`;
|
||||
}
|
||||
return `/pages/portal/index?id=${item.peerCardId}`;
|
||||
}
|
||||
|
||||
export function openHallPortal(item: HallContactItem): void {
|
||||
uni.navigateTo({
|
||||
url: buildHallPortalUrl(item),
|
||||
});
|
||||
}
|
||||
|
||||
export async function refreshHall(
|
||||
state: HallState,
|
||||
api?: LoadHallApi
|
||||
): Promise<void> {
|
||||
if (state.loading) {
|
||||
return;
|
||||
}
|
||||
state.loading = true;
|
||||
state.errorMessage = '';
|
||||
const fetchPage =
|
||||
state.tab === 'team'
|
||||
? api != null && api.fetchTeamWallPage != null
|
||||
? api.fetchTeamWallPage
|
||||
: fetchTeamWallPage
|
||||
: api != null
|
||||
? api.fetchHallContactPage
|
||||
: fetchHallContactPage;
|
||||
try {
|
||||
const query: OwnerPageQuery = {
|
||||
page: state.page,
|
||||
size: state.size,
|
||||
};
|
||||
const word = state.keyWord.trim();
|
||||
if (word !== '') {
|
||||
query.keyWord = word;
|
||||
}
|
||||
const data = await fetchPage(query);
|
||||
const raw = data.list != null ? data.list : [];
|
||||
const list: HallContactItem[] = [];
|
||||
for (let i = 0; i < raw.length; i++) {
|
||||
list.push(toHallItem(raw[i]));
|
||||
}
|
||||
state.list = list;
|
||||
state.total =
|
||||
data.pagination != null ? data.pagination.total : list.length;
|
||||
state.empty = list.length === 0;
|
||||
} catch (err) {
|
||||
state.list = [];
|
||||
state.empty = false;
|
||||
state.errorMessage = readErrorMessage(err);
|
||||
}
|
||||
state.loading = false;
|
||||
}
|
||||
|
||||
export async function submitHallExchange(
|
||||
state: HallState,
|
||||
api?: LoadHallApi
|
||||
): Promise<boolean> {
|
||||
const code = state.exchangeCode.trim();
|
||||
if (!/^\d{6}$/.test(code)) {
|
||||
state.errorMessage = resolveHallText('exchangePlaceholder');
|
||||
return false;
|
||||
}
|
||||
const confirm =
|
||||
api != null && api.confirmHallExchange != null
|
||||
? api.confirmHallExchange
|
||||
: confirmHallExchange;
|
||||
try {
|
||||
await confirm(code);
|
||||
state.exchangeCode = '';
|
||||
await refreshHall(state, api);
|
||||
return true;
|
||||
} catch (err) {
|
||||
state.errorMessage = readErrorMessage(err);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
export async function collectPeerCard(
|
||||
peerCardId: string | number,
|
||||
api?: LoadHallApi
|
||||
): Promise<boolean> {
|
||||
const collect =
|
||||
api != null && api.collectHallContact != null
|
||||
? api.collectHallContact
|
||||
: collectHallContact;
|
||||
await collect(peerCardId);
|
||||
return true;
|
||||
}
|
||||
|
||||
export function applyHallTab(state: HallState, tab: HallTab): void {
|
||||
state.tab = tab === 'team' ? 'team' : 'contacts';
|
||||
state.page = 1;
|
||||
state.errorMessage = '';
|
||||
}
|
||||
|
||||
export const PENDING_COLLECT_KEY = 'omni_pending_collect_card';
|
||||
|
||||
export function setPendingCollectCard(cardId: string | number): void {
|
||||
try {
|
||||
uni.setStorageSync(PENDING_COLLECT_KEY, String(cardId));
|
||||
} catch (_e) {}
|
||||
}
|
||||
|
||||
export function consumePendingCollectCard(): string {
|
||||
try {
|
||||
const raw = uni.getStorageSync(PENDING_COLLECT_KEY);
|
||||
uni.removeStorageSync(PENDING_COLLECT_KEY);
|
||||
if (raw == null) {
|
||||
return '';
|
||||
}
|
||||
return String(raw).trim();
|
||||
} catch (_e) {
|
||||
return '';
|
||||
}
|
||||
}
|
||||
@@ -3,6 +3,12 @@
|
||||
<view class="leads-header">
|
||||
<text class="leads-title">{{ pageTitle }}</text>
|
||||
<text class="leads-subtitle">{{ followUpLabel }}</text>
|
||||
<view v-if="radarLineOne !== ''" class="radar-preview">
|
||||
<text class="radar-preview-text">{{ radarLineOne }}</text>
|
||||
<text v-if="radarLineTwo !== ''" class="radar-preview-text">{{ radarLineTwo }}</text>
|
||||
<text v-if="radarLineThree !== ''" class="radar-preview-text">{{ radarLineThree }}</text>
|
||||
<text class="overview-entry" @click="openRadar">{{ radarMoreLabel }}</text>
|
||||
</view>
|
||||
<text class="overview-entry" @click="openTeamOverview">{{ briefingLabel }}</text>
|
||||
<input
|
||||
class="leads-search"
|
||||
@@ -110,6 +116,8 @@ import {
|
||||
applyLeadsOptions,
|
||||
createLeadsState,
|
||||
formatLeadCompany,
|
||||
formatRadarLine,
|
||||
openRadarPage,
|
||||
refreshLeads,
|
||||
resolveLeadsText,
|
||||
statusLabel,
|
||||
@@ -135,11 +143,30 @@ const pageTheme: Record<string, string> = {
|
||||
};
|
||||
|
||||
const state = reactive(createLeadsState());
|
||||
const pageTitle = ref(getOmniText(getCurrentLocale(), 'crm.leads'));
|
||||
const pageTitle = ref(resolveLeadsText('title'));
|
||||
const followUpLabel = ref(getOmniText(getCurrentLocale(), 'crm.follow_up'));
|
||||
const searchPlaceholder = ref(resolveLeadsText('searchPlaceholder'));
|
||||
const scoreLabel = ref(resolveLeadsText('score'));
|
||||
const briefingLabel = ref(resolveOverviewText('title'));
|
||||
const radarMoreLabel = ref(resolveLeadsText('radarMore'));
|
||||
const radarLineOne = computed((): string => {
|
||||
if (state.radarTracks.length < 1) {
|
||||
return '';
|
||||
}
|
||||
return formatRadarLine(state.radarTracks[0]);
|
||||
});
|
||||
const radarLineTwo = computed((): string => {
|
||||
if (state.radarTracks.length < 2) {
|
||||
return '';
|
||||
}
|
||||
return formatRadarLine(state.radarTracks[1]);
|
||||
});
|
||||
const radarLineThree = computed((): string => {
|
||||
if (state.radarTracks.length < 3) {
|
||||
return '';
|
||||
}
|
||||
return formatRadarLine(state.radarTracks[2]);
|
||||
});
|
||||
|
||||
const ctaLabel = computed((): string => {
|
||||
if (state.loading) {
|
||||
@@ -170,6 +197,10 @@ function handleOpenLead(item: LeadEntity): void {
|
||||
});
|
||||
}
|
||||
|
||||
function openRadar(): void {
|
||||
openRadarPage();
|
||||
}
|
||||
|
||||
function openTeamOverview(): void {
|
||||
uni.navigateTo({
|
||||
url: '/pages/owner/team/overview',
|
||||
@@ -219,6 +250,22 @@ onLoad((options: LeadsPageOptions) => {
|
||||
margin-bottom: var(--oc-space-8, 8px);
|
||||
}
|
||||
|
||||
.radar-preview {
|
||||
margin-bottom: var(--oc-space-12, 12px);
|
||||
padding: var(--oc-space-12, 12px);
|
||||
background-color: var(--oc-surface, #F7F8FA);
|
||||
border: 1px solid var(--oc-border, #E3E7ED);
|
||||
border-radius: var(--oc-radius-card, 16px);
|
||||
}
|
||||
|
||||
.radar-preview-text {
|
||||
display: block;
|
||||
font-size: 13px;
|
||||
color: var(--oc-text-2, #667085);
|
||||
line-height: 1.6;
|
||||
margin-bottom: 4px;
|
||||
}
|
||||
|
||||
.overview-entry {
|
||||
min-height: 44px;
|
||||
font-size: 14px;
|
||||
|
||||
@@ -44,6 +44,36 @@
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="section-card">
|
||||
<text class="section-title">{{ t('workspaceSection') }}</text>
|
||||
<view class="setting-row" @click="openPage('/pages/owner/nfc/scan')">
|
||||
<text class="setting-label">{{ t('nfcScan') }}</text>
|
||||
</view>
|
||||
<view class="row-divider"></view>
|
||||
<view class="setting-row" @click="openPage('/pages/owner/nfc/mode')">
|
||||
<text class="setting-label">{{ t('nfcMode') }}</text>
|
||||
</view>
|
||||
<view class="row-divider"></view>
|
||||
<view class="setting-row" @click="openPage('/pages/owner/nfc/security')">
|
||||
<text class="setting-label">{{ t('nfcSecurity') }}</text>
|
||||
</view>
|
||||
<view class="row-divider"></view>
|
||||
<view class="setting-row" @click="openPage('/pages/owner/team/overview')">
|
||||
<text class="setting-label">{{ t('teamBriefing') }}</text>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="section-card">
|
||||
<text class="section-title">{{ t('quotaSection') }}</text>
|
||||
<view class="setting-row">
|
||||
<view class="setting-text-wrap">
|
||||
<text class="setting-label">{{ t('quotaCards') }}</text>
|
||||
<text class="setting-desc">{{ quotaLine }}</text>
|
||||
</view>
|
||||
</view>
|
||||
<text v-if="quotaExceeded" class="setting-desc">{{ t('quotaUpgrade') }}</text>
|
||||
</view>
|
||||
|
||||
<!-- Notification settings section -->
|
||||
<view class="section-card">
|
||||
<text class="section-title">{{ t('notificationsSection') }}</text>
|
||||
@@ -139,6 +169,8 @@ import {
|
||||
removeAccountAvatar,
|
||||
} from './useProfile.uts';
|
||||
import { OmniLocale } from '../../../common/locale.uts';
|
||||
import { fetchCardQuota } from '../../../common/api.uts';
|
||||
import { getTenantId } from '../../../common/request.uts';
|
||||
|
||||
type LangOption = {
|
||||
code: OmniLocale;
|
||||
@@ -146,6 +178,8 @@ type LangOption = {
|
||||
};
|
||||
|
||||
const state = reactive<ProfileState>(loadProfileSettings());
|
||||
const quotaLine = ref('--');
|
||||
const quotaExceeded = ref(false);
|
||||
|
||||
function onAvatarClick(): void {
|
||||
if (state.account.avatar !== '') {
|
||||
@@ -197,6 +231,24 @@ function onSelectLocale(code: OmniLocale): void {
|
||||
setPreferredLocale(state, code);
|
||||
}
|
||||
|
||||
function openPage(url: string): void {
|
||||
uni.navigateTo({
|
||||
url,
|
||||
});
|
||||
}
|
||||
|
||||
async function loadQuota(): Promise<void> {
|
||||
try {
|
||||
const tenantId = getTenantId();
|
||||
const quota = await fetchCardQuota(tenantId !== '' ? tenantId : 1);
|
||||
quotaLine.value = `${quota.used} / ${quota.limit}`;
|
||||
quotaExceeded.value = quota.exceeded === true;
|
||||
} catch (_e) {
|
||||
quotaLine.value = '--';
|
||||
quotaExceeded.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
function onSaveSettings(): void {
|
||||
state.saving = true;
|
||||
const ok = saveProfileSettings(state);
|
||||
@@ -209,11 +261,12 @@ function onSaveSettings(): void {
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
onShow(() => {
|
||||
const loaded = loadProfileSettings();
|
||||
state.account = loaded.account;
|
||||
state.notifications = loaded.notifications;
|
||||
state.locale = loaded.locale;
|
||||
loadQuota();
|
||||
});
|
||||
</script>
|
||||
|
||||
|
||||
@@ -384,6 +384,22 @@ export function resolveProfileText(key: string): string {
|
||||
return isZh ? '偏好设置' : 'Preferences';
|
||||
case 'languageLabel':
|
||||
return isZh ? '界面语言' : 'Display Language';
|
||||
case 'workspaceSection':
|
||||
return isZh ? '工作台' : 'Workspace';
|
||||
case 'nfcScan':
|
||||
return isZh ? 'NFC 贴卡激活' : 'Activate NFC card';
|
||||
case 'nfcMode':
|
||||
return isZh ? 'NFC 场景切换' : 'NFC scene mode';
|
||||
case 'nfcSecurity':
|
||||
return isZh ? 'NFC 挂失' : 'Freeze NFC card';
|
||||
case 'teamBriefing':
|
||||
return isZh ? '展会战报' : 'Team briefing';
|
||||
case 'quotaSection':
|
||||
return isZh ? '套餐配额' : 'Plan quota';
|
||||
case 'quotaCards':
|
||||
return isZh ? '名片用量' : 'Card usage';
|
||||
case 'quotaUpgrade':
|
||||
return isZh ? '已达上限,请升级套餐' : 'Limit reached. Upgrade to continue.';
|
||||
default:
|
||||
return key;
|
||||
}
|
||||
|
||||
@@ -8,9 +8,11 @@ import {
|
||||
LeadStatus,
|
||||
OwnerPageData,
|
||||
OwnerPageQuery,
|
||||
RadarTrack,
|
||||
} from '../../common/types.uts';
|
||||
import { fetchOwnerLeadPage } from '../../common/api.uts';
|
||||
import { fetchOwnerLeadPage, fetchOwnerRadarPage } from '../../common/api.uts';
|
||||
import { getCurrentLocale, getOmniText } from '../../common/locale.uts';
|
||||
import { formatLocation, formatStay } from './useRadar.uts';
|
||||
|
||||
export type LeadsCopyKey =
|
||||
| 'title'
|
||||
@@ -26,7 +28,8 @@ export type LeadsCopyKey =
|
||||
| 'empty'
|
||||
| 'error'
|
||||
| 'loading'
|
||||
| 'score';
|
||||
| 'score'
|
||||
| 'radarMore';
|
||||
|
||||
export type LoadLeadsQuery = {
|
||||
page: number;
|
||||
@@ -54,6 +57,7 @@ export type LoadLeadsResult = {
|
||||
|
||||
export type LeadsState = {
|
||||
list: LeadEntity[];
|
||||
radarTracks: RadarTrack[];
|
||||
page: number;
|
||||
size: number;
|
||||
total: number;
|
||||
@@ -147,6 +151,9 @@ export function resolveLeadsText(key: LeadsCopyKey): string {
|
||||
if (key === 'score') {
|
||||
return zh ? '意向分' : 'Intent';
|
||||
}
|
||||
if (key === 'radarMore') {
|
||||
return zh ? '查看全部雷达' : 'Full radar';
|
||||
}
|
||||
return '';
|
||||
}
|
||||
|
||||
@@ -236,6 +243,7 @@ export async function loadLeads(
|
||||
export function createLeadsState(): LeadsState {
|
||||
return {
|
||||
list: [],
|
||||
radarTracks: [],
|
||||
page: 1,
|
||||
size: 20,
|
||||
total: 0,
|
||||
@@ -304,10 +312,31 @@ export async function refreshLeads(
|
||||
api
|
||||
);
|
||||
applyLoadResult(state, result);
|
||||
try {
|
||||
const radar = await fetchOwnerRadarPage({ page: 1, size: 3 });
|
||||
state.radarTracks = radar.list != null ? radar.list : [];
|
||||
} catch (_err) {
|
||||
state.radarTracks = [];
|
||||
}
|
||||
state.loading = false;
|
||||
return result;
|
||||
}
|
||||
|
||||
export function formatRadarLine(track: RadarTrack): string {
|
||||
const place = formatLocation(track.country, track.city);
|
||||
const stay = formatStay(track.stayDurationMs);
|
||||
if (place !== '') {
|
||||
return `${place} · ${stay}`;
|
||||
}
|
||||
return stay;
|
||||
}
|
||||
|
||||
export function openRadarPage(): void {
|
||||
uni.navigateTo({
|
||||
url: '/pages/owner/radar',
|
||||
});
|
||||
}
|
||||
|
||||
export function buildLeadDetailUrl(id: string | number): string {
|
||||
return `/pages/owner/leads-detail?id=${id}`;
|
||||
}
|
||||
|
||||
在新工单中引用
屏蔽一个用户