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 打包无错误
这个提交包含在:
@@ -25,8 +25,15 @@
|
||||
<text class="brand-subtitle">{{ t('subtitle') }}</text>
|
||||
</view>
|
||||
|
||||
<!-- 2. 极简分段控制器 (Segmented Control) -->
|
||||
<!-- 2. 极简分段控制器 (Segmented Control: 账号密码 / 手机号 / 邮箱) -->
|
||||
<view class="segmented-box">
|
||||
<view
|
||||
class="segment-item"
|
||||
:class="{ 'segment-active': state.tab === 'password' }"
|
||||
@click="handleSwitchTab('password')"
|
||||
>
|
||||
<text class="segment-text">{{ t('tabPassword') }}</text>
|
||||
</view>
|
||||
<view
|
||||
class="segment-item"
|
||||
:class="{ 'segment-active': state.tab === 'phone' }"
|
||||
@@ -44,8 +51,35 @@
|
||||
</view>
|
||||
|
||||
<!-- 3. 表单主体 -->
|
||||
<view v-if="state.tab === 'phone'" class="form-section">
|
||||
<!-- 手机号与区号一体化输入组 -->
|
||||
<!-- 3.1 账号密码真实登录面板 (便于测试与前后端对齐) -->
|
||||
<view v-if="state.tab === 'password'" class="form-section">
|
||||
<view class="form-field">
|
||||
<text class="field-label">{{ t('usernamePlaceholder') }}</text>
|
||||
<input
|
||||
class="input-control text-input"
|
||||
type="text"
|
||||
v-model="state.username"
|
||||
:placeholder="t('usernamePlaceholder')"
|
||||
:disabled="state.submitting"
|
||||
/>
|
||||
</view>
|
||||
<view class="form-field">
|
||||
<text class="field-label">{{ t('passwordPlaceholder') }}</text>
|
||||
<input
|
||||
class="input-control text-input"
|
||||
type="password"
|
||||
v-model="state.password"
|
||||
:placeholder="t('passwordPlaceholder')"
|
||||
:disabled="state.submitting"
|
||||
/>
|
||||
</view>
|
||||
<view class="test-account-badge" @click="handleAutofillTest">
|
||||
<text class="test-account-text">{{ t('testAccountTip') }}</text>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 3.2 国际手机号验证码面板 -->
|
||||
<view v-else-if="state.tab === 'phone'" class="form-section">
|
||||
<view class="form-field">
|
||||
<text class="field-label">{{ t('tabPhone') }}</text>
|
||||
<view class="phone-group">
|
||||
@@ -63,7 +97,6 @@
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 行内一体化验证码输入行 -->
|
||||
<view class="form-field">
|
||||
<text class="field-label">{{ t('smsCode') }}</text>
|
||||
<view class="code-group">
|
||||
@@ -85,8 +118,8 @@
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 3.3 邮箱 MagicLink 面板 -->
|
||||
<view v-else class="form-section">
|
||||
<!-- 邮箱输入行 -->
|
||||
<view class="form-field">
|
||||
<text class="field-label">{{ t('tabEmail') }}</text>
|
||||
<input
|
||||
@@ -108,6 +141,8 @@
|
||||
<button
|
||||
class="primary-cta-btn"
|
||||
:class="{ 'primary-cta-disabled': state.submitting }"
|
||||
role="button"
|
||||
aria-label="登录"
|
||||
:disabled="state.submitting"
|
||||
@click="handlePrimarySubmit"
|
||||
>
|
||||
@@ -154,12 +189,14 @@ import { getCurrentLocale, isRtlLocale, OmniLocale, setAppLocale } from '../../c
|
||||
import {
|
||||
createLoginState,
|
||||
switchLoginTab,
|
||||
submitPasswordLogin,
|
||||
submitPhoneLogin,
|
||||
sendMagicLink,
|
||||
sendSmsCode,
|
||||
tickCountdown,
|
||||
tapSocialLogin,
|
||||
resolveLoginText,
|
||||
fillTestAccount,
|
||||
LoginCopyKey,
|
||||
LoginTab,
|
||||
SocialProvider,
|
||||
@@ -201,6 +238,9 @@ const codeButtonText = computed((): string => {
|
||||
});
|
||||
|
||||
const primaryButtonText = computed((): string => {
|
||||
if (state.tab === 'password') {
|
||||
return state.submitting ? t('loading') : t('login');
|
||||
}
|
||||
return state.tab === 'phone' ? t('login') : t('magicLink');
|
||||
});
|
||||
|
||||
@@ -224,14 +264,14 @@ function handleGoBack(): void {
|
||||
try {
|
||||
uni.navigateBack({
|
||||
fail: () => {
|
||||
uni.switchTab({
|
||||
url: '/pages/portal/index',
|
||||
uni.reLaunch({
|
||||
url: '/pages/owner/hall/index',
|
||||
});
|
||||
},
|
||||
});
|
||||
} catch (_e) {
|
||||
uni.switchTab({
|
||||
url: '/pages/portal/index',
|
||||
uni.reLaunch({
|
||||
url: '/pages/owner/hall/index',
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -266,8 +306,14 @@ function handleSendCode(): void {
|
||||
}
|
||||
}
|
||||
|
||||
function handleAutofillTest(): void {
|
||||
fillTestAccount(state);
|
||||
}
|
||||
|
||||
function handlePrimarySubmit(): void {
|
||||
if (state.tab === 'phone') {
|
||||
if (state.tab === 'password') {
|
||||
submitPasswordLogin(state);
|
||||
} else if (state.tab === 'phone') {
|
||||
submitPhoneLogin(state);
|
||||
} else {
|
||||
sendMagicLink(state);
|
||||
@@ -576,6 +622,32 @@ onUnmounted(() => {
|
||||
color: #98A2B3;
|
||||
}
|
||||
|
||||
/* 测试账号一键填充辅助胶囊 */
|
||||
.test-account-badge {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
padding: 6px 10px;
|
||||
background-color: #F7F8FA;
|
||||
border: 1px dashed #D0D5DD;
|
||||
border-radius: 8px;
|
||||
margin-bottom: 12px;
|
||||
cursor: pointer;
|
||||
transition: background-color 150ms cubic-bezier(0.2, 0.8, 0.2, 1);
|
||||
}
|
||||
|
||||
.test-account-badge:active {
|
||||
background-color: #EAF1FF;
|
||||
border-color: #0B5CFF;
|
||||
}
|
||||
|
||||
.test-account-text {
|
||||
font-size: 12px;
|
||||
color: #0B5CFF;
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
/* 错误提示 */
|
||||
.error-banner {
|
||||
padding: 8px 12px;
|
||||
@@ -593,8 +665,13 @@ onUnmounted(() => {
|
||||
.primary-cta-btn {
|
||||
width: 100%;
|
||||
height: 44px;
|
||||
line-height: 44px;
|
||||
min-height: 44px;
|
||||
background-color: #0B5CFF;
|
||||
color: #FFFFFF;
|
||||
font-size: 15px;
|
||||
font-weight: 600;
|
||||
text-align: center;
|
||||
border-radius: 12px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
@@ -602,15 +679,21 @@ onUnmounted(() => {
|
||||
border: none;
|
||||
margin-top: 6px;
|
||||
margin-bottom: 18px;
|
||||
cursor: pointer;
|
||||
transition: opacity 150ms cubic-bezier(0.2, 0.8, 0.2, 1);
|
||||
}
|
||||
|
||||
.primary-cta-btn::after {
|
||||
border: none;
|
||||
}
|
||||
|
||||
.primary-cta-btn:active {
|
||||
opacity: 0.88;
|
||||
}
|
||||
|
||||
.primary-cta-disabled {
|
||||
background-color: #E3E7ED;
|
||||
cursor: not-allowed;
|
||||
}
|
||||
|
||||
.primary-cta-text {
|
||||
|
||||
@@ -1,12 +1,14 @@
|
||||
/**
|
||||
* OmniCard AI (CRMmp) - 统一身份认证登录业务驱动层
|
||||
* 第一版可用骨架:不接真实 Google / Apple SDK,不伪造成功登录
|
||||
* 第一版可用骨架:支持账号密码真实登录对齐后端、手机号验证码、邮箱MagicLink与社交登录入口
|
||||
*/
|
||||
|
||||
import { getCurrentLocale, getOmniText, OmniLocale } from '../../common/locale.uts';
|
||||
import { setAuthToken, setTenantId } from '../../common/request.uts';
|
||||
import { setAuthToken, setTenantId, httpPost } from '../../common/request.uts';
|
||||
import { collectHallContact } from '../../common/api.uts';
|
||||
import { consumePendingCollectCard } from '../owner/hall/useHall.uts';
|
||||
|
||||
export type LoginTab = 'phone' | 'email';
|
||||
export type LoginTab = 'password' | 'phone' | 'email';
|
||||
export type SocialProvider = 'google' | 'apple';
|
||||
|
||||
export type LoginCopyKey =
|
||||
@@ -14,8 +16,14 @@ export type LoginCopyKey =
|
||||
| 'brandTag'
|
||||
| 'subtitle'
|
||||
| 'desc'
|
||||
| 'tabPassword'
|
||||
| 'tabPhone'
|
||||
| 'tabEmail'
|
||||
| 'usernamePlaceholder'
|
||||
| 'passwordPlaceholder'
|
||||
| 'accountRequired'
|
||||
| 'passwordRequired'
|
||||
| 'testAccountTip'
|
||||
| 'countryCode'
|
||||
| 'phonePlaceholder'
|
||||
| 'sendCode'
|
||||
@@ -39,6 +47,8 @@ export type LoginCopyKey =
|
||||
|
||||
export type LoginState = {
|
||||
tab: LoginTab;
|
||||
username: string;
|
||||
password: string;
|
||||
countryCode: string;
|
||||
phone: string;
|
||||
smsCode: string;
|
||||
@@ -48,6 +58,13 @@ export type LoginState = {
|
||||
countdown: number;
|
||||
};
|
||||
|
||||
export type LoginAdminResponse = {
|
||||
token: string;
|
||||
expire?: number;
|
||||
refreshToken?: string;
|
||||
refreshExpire?: number;
|
||||
};
|
||||
|
||||
function isZhLocale(): boolean {
|
||||
return getCurrentLocale() === 'zh-CN';
|
||||
}
|
||||
@@ -71,12 +88,30 @@ export function resolveLoginText(key: LoginCopyKey | string, targetLocale?: stri
|
||||
if (key === 'subtitle') {
|
||||
return zh ? '极简出海商务,连接全球商机' : 'Minimalist global commerce & identity';
|
||||
}
|
||||
if (key === 'tabPassword') {
|
||||
return zh ? '账号密码' : 'Password';
|
||||
}
|
||||
if (key === 'tabPhone') {
|
||||
return zh ? '手机号' : 'Phone';
|
||||
}
|
||||
if (key === 'tabEmail') {
|
||||
return zh ? '邮箱' : 'Email';
|
||||
}
|
||||
if (key === 'usernamePlaceholder') {
|
||||
return zh ? '用户名或手机号' : 'Username or phone';
|
||||
}
|
||||
if (key === 'passwordPlaceholder') {
|
||||
return zh ? '登录密码' : 'Password';
|
||||
}
|
||||
if (key === 'accountRequired') {
|
||||
return zh ? '请填写账号' : 'Enter your username';
|
||||
}
|
||||
if (key === 'passwordRequired') {
|
||||
return zh ? '请填写密码' : 'Enter your password';
|
||||
}
|
||||
if (key === 'testAccountTip') {
|
||||
return zh ? '测试账号: admin / 123456 (点击一键填入)' : 'Test account: admin / 123456 (Click to autofill)';
|
||||
}
|
||||
if (key === 'desc') {
|
||||
return zh ? '使用国际手机号或邮箱继续' : 'Continue with your phone or email';
|
||||
}
|
||||
@@ -148,20 +183,51 @@ function toastNone(title: string): void {
|
||||
}
|
||||
|
||||
function finishAfterLogin(): void {
|
||||
if (typeof uni.switchTab === 'function') {
|
||||
uni.switchTab({
|
||||
url: '/pages/owner/card/index',
|
||||
});
|
||||
} else if (typeof uni.reLaunch === 'function') {
|
||||
uni.reLaunch({
|
||||
url: '/pages/owner/card/index',
|
||||
try {
|
||||
uni.showToast({
|
||||
title: resolveLoginText('loginSuccess'),
|
||||
icon: 'success',
|
||||
});
|
||||
} catch (e) {}
|
||||
|
||||
const pendingCardId = consumePendingCollectCard();
|
||||
if (pendingCardId !== '') {
|
||||
collectHallContact(pendingCardId).catch(() => {});
|
||||
}
|
||||
|
||||
try {
|
||||
if (typeof uni.switchTab === 'function') {
|
||||
uni.switchTab({
|
||||
url: '/pages/owner/card/index',
|
||||
});
|
||||
if (typeof window !== 'undefined' && window.location != null) {
|
||||
try {
|
||||
setTimeout(() => {
|
||||
const currentHash = window.location.hash || '';
|
||||
if (!currentHash.includes('/pages/owner/card/index')) {
|
||||
window.location.hash = '#/pages/owner/card/index';
|
||||
}
|
||||
}, 300);
|
||||
} catch (e) {}
|
||||
}
|
||||
return;
|
||||
}
|
||||
} catch (e) {}
|
||||
|
||||
try {
|
||||
if (typeof uni.reLaunch === 'function') {
|
||||
uni.reLaunch({
|
||||
url: '/pages/owner/card/index',
|
||||
});
|
||||
}
|
||||
} catch (e) {}
|
||||
}
|
||||
|
||||
export function createLoginState(): LoginState {
|
||||
return {
|
||||
tab: 'phone',
|
||||
tab: 'password',
|
||||
username: '',
|
||||
password: '',
|
||||
countryCode: '+86',
|
||||
phone: '',
|
||||
smsCode: '',
|
||||
@@ -177,6 +243,15 @@ export function switchLoginTab(state: LoginState, tab: LoginTab): void {
|
||||
state.errorMessage = '';
|
||||
}
|
||||
|
||||
/**
|
||||
* 一键填充测试账号
|
||||
*/
|
||||
export function fillTestAccount(state: LoginState): void {
|
||||
state.username = 'admin';
|
||||
state.password = '123456';
|
||||
state.errorMessage = '';
|
||||
}
|
||||
|
||||
/**
|
||||
* 倒计时推进函数
|
||||
*/
|
||||
@@ -206,6 +281,52 @@ export function completeLogin(token: string, tenantId?: string): boolean {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 账号密码真实登录:对齐后端 Cool-Admin POST /admin/base/open/login
|
||||
*/
|
||||
export async function submitPasswordLogin(state: LoginState): Promise<boolean> {
|
||||
const username = state.username != null ? state.username.trim() : '';
|
||||
if (username === '') {
|
||||
state.errorMessage = resolveLoginText('accountRequired');
|
||||
toastNone(state.errorMessage);
|
||||
return false;
|
||||
}
|
||||
|
||||
const password = state.password != null ? state.password.trim() : '';
|
||||
if (password === '') {
|
||||
state.errorMessage = resolveLoginText('passwordRequired');
|
||||
toastNone(state.errorMessage);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (state.submitting) {
|
||||
return false;
|
||||
}
|
||||
|
||||
state.submitting = true;
|
||||
state.errorMessage = '';
|
||||
|
||||
try {
|
||||
const res = await httpPost<LoginAdminResponse>('/admin/base/open/login', {
|
||||
username,
|
||||
password,
|
||||
});
|
||||
state.submitting = false;
|
||||
if (res != null && res.token != null && res.token !== '') {
|
||||
completeLogin(res.token);
|
||||
return true;
|
||||
}
|
||||
state.errorMessage = '登录失败,未获取到有效凭证';
|
||||
toastNone(state.errorMessage);
|
||||
return false;
|
||||
} catch (err: any) {
|
||||
state.submitting = false;
|
||||
const msg = err && err.message ? err.message : '账户或密码不正确~';
|
||||
state.errorMessage = msg;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
export function sendSmsCode(state: LoginState): boolean {
|
||||
if (state.countdown > 0) {
|
||||
return false;
|
||||
|
||||
@@ -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}`;
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
<i18n-selector :model-value="currentLang" @change="switchLang" />
|
||||
</view>
|
||||
<text class="locale-chip locale-exchange" @click="openExchange">{{ textOf('card.exchange') }}</text>
|
||||
<text v-if="canCollect" class="locale-chip locale-exchange" @click="handleCollect">{{ collectLabel }}</text>
|
||||
</view>
|
||||
|
||||
<scroll-view class="portal-scroll" :scroll-y="true">
|
||||
@@ -185,6 +186,9 @@ import {
|
||||
PortalQuickAction,
|
||||
} from './usePortal.uts';
|
||||
import { saveToContacts } from '../../common/vcard-export.uts';
|
||||
import { collectHallContact } from '../../common/api.uts';
|
||||
import { getAuthToken } from '../../common/request.uts';
|
||||
import { setPendingCollectCard } from '../owner/hall/useHall.uts';
|
||||
import {
|
||||
OmniLocale,
|
||||
OmniMessageKey,
|
||||
@@ -222,6 +226,10 @@ const defaultAvatar = 'https://cdn.omnicard.ai/assets/default-avatar.png';
|
||||
const state = reactive(createPortalState());
|
||||
const currentCardId = ref('');
|
||||
const currentLang = ref<OmniLocale>(detectLocale());
|
||||
const canCollect = ref(true);
|
||||
const collectLabel = computed((): string => {
|
||||
return currentLang.value === 'zh-CN' ? '收入大厅' : 'Save to hall';
|
||||
});
|
||||
|
||||
const cardAudioUrl = computed((): string => {
|
||||
if (state.card == null) {
|
||||
@@ -309,6 +317,26 @@ function handleCompanyClick(): void {
|
||||
});
|
||||
}
|
||||
|
||||
async function handleCollect(): Promise<void> {
|
||||
if (state.card == null || state.card!.id == null) {
|
||||
return;
|
||||
}
|
||||
if (getAuthToken() === '') {
|
||||
setPendingCollectCard(state.card!.id);
|
||||
uni.navigateTo({
|
||||
url: '/pages/common/login',
|
||||
});
|
||||
return;
|
||||
}
|
||||
try {
|
||||
await collectHallContact(state.card!.id);
|
||||
uni.showToast({
|
||||
title: currentLang.value === 'zh-CN' ? '已收入大厅' : 'Saved to hall',
|
||||
icon: 'none',
|
||||
});
|
||||
} catch (_err) {}
|
||||
}
|
||||
|
||||
function openExchange(): void {
|
||||
if (!state.card) return;
|
||||
const cardId = state.card!.id != null ? String(state.card!.id) : currentCardId.value;
|
||||
|
||||
在新工单中引用
屏蔽一个用户