feat: 完成全系统30个功能点开发与E2E全链路验收 (8轮调度32个子代理闭环)
- 模块一: 出海案例作品集、博客动态发布、人名发音语音条、RTL阿语多语言切换 - 模块二: AI顾问人设配置、行业术语库润色、RAG切片沙盒调试、流式会话与意向留资卡片 - 模块三: 全球访客雷达大屏、多维加权意向算分、外部CRM对接推送、团队公海池流转 - 模块四: 移动端NFC安全挂失、NFC动态路由规则配置、动态防伪验签、展会制卡Zip批量导出 - 模块五: 组织架构与名片分配、移动端个人中心设置、离职交接与历史线索迁移、安全审计日志 - 模块六: Stripe国际信用卡订阅Webhook、独立二级域名与SSL检测、坐席配额预警、多币种发票 - 模块七: 纸质名片OCR解析入库、国际商务日程RFC 5545 ICS日历、微官网离线SWR预加载、展会实时排行榜大屏 - 模块八: 全球出海SEO OpenGraph元标签注入与社交爬虫探测、30点端到端全链路业务流集成测试套件
这个提交包含在:
@@ -0,0 +1,442 @@
|
||||
/**
|
||||
* OmniCard AI (CRMmp) - 名片主潜客详情与跟进备忘业务驱动层
|
||||
* 拉线索详情 + 足迹分页,备忘只追加不覆盖
|
||||
*/
|
||||
|
||||
import {
|
||||
LeadEntity,
|
||||
LeadStatus,
|
||||
OwnerPageData,
|
||||
OwnerPageQuery,
|
||||
RadarTrack,
|
||||
} from '../../common/types.uts';
|
||||
import {
|
||||
fetchOwnerLeadInfo,
|
||||
fetchOwnerRadarPage,
|
||||
} from '../../common/api.uts';
|
||||
import { httpPost } from '../../common/request.uts';
|
||||
import { getCurrentLocale, getOmniText } from '../../common/locale.uts';
|
||||
import { statusLabel } from './useLeads.uts';
|
||||
import { formatDepth, formatLocation, formatStay } from './useRadar.uts';
|
||||
|
||||
export type LeadDetailCopyKey =
|
||||
| 'title'
|
||||
| 'score'
|
||||
| 'timeline'
|
||||
| 'notes'
|
||||
| 'notesPlaceholder'
|
||||
| 'save'
|
||||
| 'back'
|
||||
| 'empty'
|
||||
| 'missingId'
|
||||
| 'error'
|
||||
| 'loading'
|
||||
| 'stay'
|
||||
| 'depth';
|
||||
|
||||
export type LeadDetailPageOptions = {
|
||||
id?: string;
|
||||
};
|
||||
|
||||
export type LoadDetailApi = {
|
||||
fetchOwnerLeadInfo?: (id: string | number) => Promise<LeadEntity>;
|
||||
fetchOwnerRadarPage?: (
|
||||
query: OwnerPageQuery
|
||||
) => Promise<OwnerPageData<RadarTrack>>;
|
||||
};
|
||||
|
||||
export type LoadDetailResult = {
|
||||
lead: LeadEntity | null;
|
||||
tracks: RadarTrack[];
|
||||
empty: boolean;
|
||||
errorMessage: string;
|
||||
};
|
||||
|
||||
export type SaveNoteInput = {
|
||||
id: string | number;
|
||||
notes?: string;
|
||||
next: string;
|
||||
status?: LeadStatus;
|
||||
};
|
||||
|
||||
export type SaveNoteApi = {
|
||||
httpPost?: (
|
||||
url: string,
|
||||
data: Record<string, string | number>
|
||||
) => Promise<LeadEntity>;
|
||||
updateOwnerLeadStatus?: (
|
||||
id: string | number,
|
||||
status: LeadStatus
|
||||
) => Promise<LeadEntity>;
|
||||
};
|
||||
|
||||
export type LeadDetailState = {
|
||||
rawId: string;
|
||||
leadId: string | number | null;
|
||||
lead: LeadEntity | null;
|
||||
name: string;
|
||||
company: string;
|
||||
status: string;
|
||||
intentScore: number;
|
||||
existingNotes: string;
|
||||
nextNote: string;
|
||||
tracks: RadarTrack[];
|
||||
loading: boolean;
|
||||
saving: boolean;
|
||||
empty: boolean;
|
||||
missingId: boolean;
|
||||
errorMessage: string;
|
||||
};
|
||||
|
||||
const DEFAULT_PAGE = 1;
|
||||
const DEFAULT_SIZE = 20;
|
||||
|
||||
function isZhLocale(): boolean {
|
||||
return getCurrentLocale() === 'zh-CN';
|
||||
}
|
||||
|
||||
/**
|
||||
* 页面文案:标题 / 意向 / 轨迹 / 保存走词典,缺 id 与占位走本地词典
|
||||
*/
|
||||
export function resolveLeadDetailText(key: LeadDetailCopyKey): string {
|
||||
const locale = getCurrentLocale();
|
||||
if (key === 'title') {
|
||||
return getOmniText(locale, 'crm.follow_up');
|
||||
}
|
||||
if (key === 'score') {
|
||||
return getOmniText(locale, 'radar.lead_score');
|
||||
}
|
||||
if (key === 'timeline') {
|
||||
return getOmniText(locale, 'radar.visitor_trace');
|
||||
}
|
||||
if (key === 'notes') {
|
||||
return getOmniText(locale, 'crm.follow_up');
|
||||
}
|
||||
if (key === 'save') {
|
||||
return getOmniText(locale, 'common.save');
|
||||
}
|
||||
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 === 'notesPlaceholder') {
|
||||
return zh ? '追加一条跟进备忘' : 'Add a follow-up note';
|
||||
}
|
||||
if (key === 'back') {
|
||||
return zh ? '返回列表' : 'Back to list';
|
||||
}
|
||||
if (key === 'missingId') {
|
||||
return zh ? '缺少潜客编号' : 'Lead ID is missing';
|
||||
}
|
||||
if (key === 'stay') {
|
||||
return zh ? '停留' : 'Stay';
|
||||
}
|
||||
if (key === 'depth') {
|
||||
return zh ? '滚动深度' : 'Scroll depth';
|
||||
}
|
||||
return '';
|
||||
}
|
||||
|
||||
export function statusLabelOf(status: string): string {
|
||||
return statusLabel(status);
|
||||
}
|
||||
|
||||
export function formatTrackStay(ms: number | null | undefined): string {
|
||||
return formatStay(ms);
|
||||
}
|
||||
|
||||
export function formatTrackDepth(depth: number | null | undefined): string {
|
||||
return formatDepth(depth);
|
||||
}
|
||||
|
||||
export function formatTrackPlace(country?: string, city?: string): string {
|
||||
return formatLocation(country, city);
|
||||
}
|
||||
|
||||
/**
|
||||
* 解析为正整数。非正整数返回 null
|
||||
*/
|
||||
export function parseLeadId(
|
||||
raw: string | number | null | undefined
|
||||
): string | 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);
|
||||
}
|
||||
|
||||
/**
|
||||
* 拼接备忘:新内容追加在旧内容后,空输入不覆盖
|
||||
*/
|
||||
export function appendNote(
|
||||
existing: string | null | undefined,
|
||||
next: string | null | undefined
|
||||
): string {
|
||||
const prev = existing != null ? String(existing).trim() : '';
|
||||
const extra = next != null ? String(next).trim() : '';
|
||||
if (prev === '') {
|
||||
return extra;
|
||||
}
|
||||
if (extra === '') {
|
||||
return prev;
|
||||
}
|
||||
return `${prev}\n${extra}`;
|
||||
}
|
||||
|
||||
function readErrorMessage(err: unknown): string {
|
||||
if (err instanceof Error && err.message !== '') {
|
||||
return err.message;
|
||||
}
|
||||
return resolveLeadDetailText('error');
|
||||
}
|
||||
|
||||
function parseTrackList(
|
||||
payload: OwnerPageData<RadarTrack> | null | undefined
|
||||
): RadarTrack[] {
|
||||
if (payload == null || payload.list == null) {
|
||||
return [];
|
||||
}
|
||||
return payload.list;
|
||||
}
|
||||
|
||||
/**
|
||||
* 拉取潜客详情与足迹。可注入 fetchOwnerLeadInfo / fetchOwnerRadarPage
|
||||
*/
|
||||
export async function loadDetail(
|
||||
id: string | number | null | undefined,
|
||||
api?: LoadDetailApi
|
||||
): Promise<LoadDetailResult> {
|
||||
const leadId = parseLeadId(id);
|
||||
if (leadId == null) {
|
||||
return {
|
||||
lead: null,
|
||||
tracks: [],
|
||||
empty: true,
|
||||
errorMessage: '',
|
||||
};
|
||||
}
|
||||
|
||||
const fetchInfo =
|
||||
api != null && api.fetchOwnerLeadInfo != null
|
||||
? api.fetchOwnerLeadInfo
|
||||
: fetchOwnerLeadInfo;
|
||||
const fetchRadar =
|
||||
api != null && api.fetchOwnerRadarPage != null
|
||||
? api.fetchOwnerRadarPage
|
||||
: fetchOwnerRadarPage;
|
||||
|
||||
try {
|
||||
const lead = await fetchInfo(leadId);
|
||||
const visitorId = lead.visitorId != null ? String(lead.visitorId) : '';
|
||||
const radarQuery: OwnerPageQuery = {
|
||||
page: DEFAULT_PAGE,
|
||||
size: DEFAULT_SIZE,
|
||||
keyWord: visitorId,
|
||||
cardId: lead.cardId,
|
||||
};
|
||||
try {
|
||||
const payload = await fetchRadar(radarQuery);
|
||||
const tracks = parseTrackList(payload);
|
||||
return {
|
||||
lead,
|
||||
tracks,
|
||||
empty: false,
|
||||
errorMessage: '',
|
||||
};
|
||||
} catch (radarErr) {
|
||||
return {
|
||||
lead,
|
||||
tracks: [],
|
||||
empty: false,
|
||||
errorMessage: readErrorMessage(radarErr),
|
||||
};
|
||||
}
|
||||
} catch (err) {
|
||||
return {
|
||||
lead: null,
|
||||
tracks: [],
|
||||
empty: true,
|
||||
errorMessage: readErrorMessage(err),
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 只更新 notes:POST /admin/crm/lead/update { id, notes }
|
||||
*/
|
||||
export async function saveNote(
|
||||
input: SaveNoteInput,
|
||||
api?: SaveNoteApi
|
||||
): Promise<LeadEntity> {
|
||||
const notes = appendNote(input.notes, input.next);
|
||||
const post =
|
||||
api != null && api.httpPost != null ? api.httpPost : httpPost;
|
||||
const payload: Record<string, string | number> = {
|
||||
id: input.id,
|
||||
notes,
|
||||
};
|
||||
return post<LeadEntity>('/admin/crm/lead/update', payload);
|
||||
}
|
||||
|
||||
export function createLeadDetailState(): LeadDetailState {
|
||||
return {
|
||||
rawId: '',
|
||||
leadId: null,
|
||||
lead: null,
|
||||
name: '',
|
||||
company: '',
|
||||
status: '',
|
||||
intentScore: 0,
|
||||
existingNotes: '',
|
||||
nextNote: '',
|
||||
tracks: [],
|
||||
loading: false,
|
||||
saving: false,
|
||||
empty: false,
|
||||
missingId: false,
|
||||
errorMessage: '',
|
||||
};
|
||||
}
|
||||
|
||||
export function applyLeadDetailOptions(
|
||||
state: LeadDetailState,
|
||||
options: LeadDetailPageOptions | null
|
||||
): boolean {
|
||||
if (options == null || options.id == null) {
|
||||
state.rawId = '';
|
||||
state.leadId = null;
|
||||
state.missingId = true;
|
||||
state.empty = true;
|
||||
return false;
|
||||
}
|
||||
const parsed = parseLeadId(options.id);
|
||||
state.rawId = String(options.id).trim();
|
||||
state.leadId = parsed;
|
||||
state.missingId = parsed == null;
|
||||
state.empty = parsed == null;
|
||||
return parsed != null;
|
||||
}
|
||||
|
||||
function applyLeadToState(state: LeadDetailState, lead: LeadEntity): void {
|
||||
state.lead = lead;
|
||||
state.name = lead.name;
|
||||
state.company = lead.company != null ? lead.company : '';
|
||||
state.status = lead.status;
|
||||
state.intentScore = lead.intentScore;
|
||||
state.existingNotes = lead.notes != null ? lead.notes : '';
|
||||
}
|
||||
|
||||
export function applyLoadResult(
|
||||
state: LeadDetailState,
|
||||
result: LoadDetailResult
|
||||
): void {
|
||||
if (result.lead != null) {
|
||||
applyLeadToState(state, result.lead);
|
||||
state.empty = false;
|
||||
state.missingId = false;
|
||||
} else {
|
||||
state.lead = null;
|
||||
state.empty = true;
|
||||
}
|
||||
state.tracks = result.tracks;
|
||||
state.errorMessage = result.errorMessage;
|
||||
}
|
||||
|
||||
export async function refreshLeadDetail(
|
||||
state: LeadDetailState,
|
||||
api?: LoadDetailApi
|
||||
): Promise<LoadDetailResult> {
|
||||
if (state.missingId || state.leadId == null) {
|
||||
const skipped: LoadDetailResult = {
|
||||
lead: null,
|
||||
tracks: [],
|
||||
empty: true,
|
||||
errorMessage: '',
|
||||
};
|
||||
applyLoadResult(state, skipped);
|
||||
state.missingId = true;
|
||||
return skipped;
|
||||
}
|
||||
if (state.loading) {
|
||||
return {
|
||||
lead: state.lead,
|
||||
tracks: state.tracks,
|
||||
empty: state.empty,
|
||||
errorMessage: state.errorMessage,
|
||||
};
|
||||
}
|
||||
state.loading = true;
|
||||
state.errorMessage = '';
|
||||
const result = await loadDetail(state.leadId, api);
|
||||
applyLoadResult(state, result);
|
||||
state.loading = false;
|
||||
return result;
|
||||
}
|
||||
|
||||
export async function submitLeadNote(
|
||||
state: LeadDetailState,
|
||||
api?: SaveNoteApi
|
||||
): Promise<boolean> {
|
||||
if (state.leadId == null || state.saving) {
|
||||
return false;
|
||||
}
|
||||
const next = state.nextNote.trim();
|
||||
if (next === '') {
|
||||
return false;
|
||||
}
|
||||
state.saving = true;
|
||||
state.errorMessage = '';
|
||||
try {
|
||||
const saved = await saveNote(
|
||||
{
|
||||
id: state.leadId,
|
||||
notes: state.existingNotes,
|
||||
next,
|
||||
status: state.lead != null ? state.lead.status : undefined,
|
||||
},
|
||||
api
|
||||
);
|
||||
applyLeadToState(state, saved);
|
||||
state.nextNote = '';
|
||||
state.saving = false;
|
||||
return true;
|
||||
} catch (err) {
|
||||
state.saving = false;
|
||||
state.errorMessage = readErrorMessage(err);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
export function goBackFromLeadDetail(): void {
|
||||
uni.navigateBack({
|
||||
delta: 1,
|
||||
fail: () => {
|
||||
uni.reLaunch({
|
||||
url: '/pages/owner/leads',
|
||||
});
|
||||
},
|
||||
});
|
||||
}
|
||||
在新工单中引用
屏蔽一个用户