fix(client): 修复极速名片编辑与潜客详情白屏,补齐战报空状态与AI回退逻辑
这个提交包含在:
@@ -9,6 +9,7 @@ import {
|
||||
OwnerPageData,
|
||||
OwnerPageQuery,
|
||||
RadarTrack,
|
||||
CardProfile,
|
||||
} from '../../common/types.uts';
|
||||
import {
|
||||
fetchOwnerLeadInfo,
|
||||
@@ -19,6 +20,7 @@ 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';
|
||||
import { saveToContacts } from '../../common/vcard-export.uts';
|
||||
|
||||
export type LeadDetailCopyKey =
|
||||
| 'title'
|
||||
@@ -46,6 +48,7 @@ export type LeadDetailCopyKey =
|
||||
| 'saveContactAction'
|
||||
| 'generateAiAction'
|
||||
| 'copyScriptAction'
|
||||
| 'applyScriptAction'
|
||||
| 'scriptCopiedToast'
|
||||
| 'savedContactToast'
|
||||
| 'leadTitle';
|
||||
@@ -93,6 +96,9 @@ export type LeadDetailState = {
|
||||
lead: LeadEntity | null;
|
||||
name: string;
|
||||
company: string;
|
||||
phone: string;
|
||||
email: string;
|
||||
source: string;
|
||||
status: string;
|
||||
intentScore: number;
|
||||
existingNotes: string;
|
||||
@@ -199,6 +205,9 @@ export function resolveLeadDetailText(key: LeadDetailCopyKey): string {
|
||||
if (key === 'copyScriptAction') {
|
||||
return zh ? '复制话术' : 'Copy Script';
|
||||
}
|
||||
if (key === 'applyScriptAction') {
|
||||
return zh ? '填入备忘' : 'Apply to Note';
|
||||
}
|
||||
if (key === 'scriptCopiedToast') {
|
||||
return zh ? '话术已复制' : 'Script copied';
|
||||
}
|
||||
@@ -208,6 +217,12 @@ export function resolveLeadDetailText(key: LeadDetailCopyKey): string {
|
||||
if (key === 'leadTitle') {
|
||||
return zh ? '潜客档案' : 'Lead Profile';
|
||||
}
|
||||
if (key === 'noteSavedToast') {
|
||||
return zh ? '备忘已保存' : 'Note saved';
|
||||
}
|
||||
if (key === 'notesRequiredToast') {
|
||||
return zh ? '请输入备忘或上传附件' : 'Please enter note or upload attachment';
|
||||
}
|
||||
return '';
|
||||
}
|
||||
|
||||
@@ -363,8 +378,44 @@ export function appendStructuredNote(
|
||||
return `${prev}\n${extra}`;
|
||||
}
|
||||
|
||||
export type ParsedNoteResult = {
|
||||
cleanText: string;
|
||||
imageUrls: string[];
|
||||
};
|
||||
|
||||
/**
|
||||
* 保存到手机系统通讯录 (vCard 兼容)
|
||||
* 结构化解析历史备忘,分离纯文本说明与附件图片 URL 列表
|
||||
*/
|
||||
export function parseNoteAttachments(
|
||||
rawNote: string | null | undefined
|
||||
): ParsedNoteResult {
|
||||
if (rawNote == null || rawNote.trim() === '') {
|
||||
return { cleanText: '', imageUrls: [] };
|
||||
}
|
||||
const trimmed = rawNote.trim();
|
||||
const bracketRegex = /\[(.*?)\]/g;
|
||||
const imageUrls: string[] = [];
|
||||
let match: RegExpExecArray | null = null;
|
||||
|
||||
while ((match = bracketRegex.exec(trimmed)) !== null) {
|
||||
const inside = match[1];
|
||||
if (inside.includes('http://') || inside.includes('https://')) {
|
||||
const parts = inside.split(/\s+/);
|
||||
for (const part of parts) {
|
||||
const p = part.trim();
|
||||
if (p.startsWith('http://') || p.startsWith('https://')) {
|
||||
imageUrls.push(p);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const cleanText = trimmed.replace(bracketRegex, '').trim();
|
||||
return { cleanText, imageUrls };
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存到手机系统通讯录 (深度复用通用 RFC 6350 / vCard 引擎)
|
||||
*/
|
||||
export async function saveContactToDevice(
|
||||
lead: LeadEntity | null
|
||||
@@ -372,32 +423,14 @@ export async function saveContactToDevice(
|
||||
if (lead == null) {
|
||||
return false;
|
||||
}
|
||||
try {
|
||||
if (typeof uni.addPhoneContact === 'function') {
|
||||
uni.addPhoneContact({
|
||||
firstName: lead.name,
|
||||
organization: lead.company != null ? lead.company : '',
|
||||
mobilePhoneNumber: lead.phone != null ? lead.phone : '',
|
||||
email: lead.email != null ? lead.email : '',
|
||||
success: () => {
|
||||
uni.showToast({
|
||||
title: resolveLeadDetailText('savedContactToast'),
|
||||
icon: 'none',
|
||||
});
|
||||
},
|
||||
fail: () => {
|
||||
const contactText = `${lead.name} ${
|
||||
lead.phone != null ? lead.phone : ''
|
||||
} ${lead.email != null ? lead.email : ''}`.trim();
|
||||
uni.setClipboardData({
|
||||
data: contactText,
|
||||
});
|
||||
},
|
||||
});
|
||||
return true;
|
||||
}
|
||||
} catch (e) {}
|
||||
return false;
|
||||
const card: CardProfile = {
|
||||
id: lead.id,
|
||||
name: lead.name,
|
||||
company: lead.company != null ? lead.company : '',
|
||||
phone: lead.phone != null ? lead.phone : '',
|
||||
email: lead.email != null ? lead.email : '',
|
||||
};
|
||||
return saveToContacts(card);
|
||||
}
|
||||
|
||||
function readErrorMessage(err: unknown): string {
|
||||
@@ -506,6 +539,9 @@ export function createLeadDetailState(): LeadDetailState {
|
||||
lead: null,
|
||||
name: '',
|
||||
company: '',
|
||||
phone: '',
|
||||
email: '',
|
||||
source: '',
|
||||
status: '',
|
||||
intentScore: 0,
|
||||
existingNotes: '',
|
||||
@@ -545,6 +581,9 @@ function applyLeadToState(state: LeadDetailState, lead: LeadEntity): void {
|
||||
state.lead = lead;
|
||||
state.name = lead.name;
|
||||
state.company = lead.company != null ? lead.company : '';
|
||||
state.phone = lead.phone != null ? lead.phone : '';
|
||||
state.email = lead.email != null ? lead.email : '';
|
||||
state.source = lead.source != null ? String(lead.source) : '';
|
||||
state.status = lead.status;
|
||||
state.intentScore = lead.intentScore;
|
||||
state.existingNotes = lead.notes != null ? lead.notes : '';
|
||||
@@ -605,7 +644,8 @@ export async function submitLeadNote(
|
||||
return false;
|
||||
}
|
||||
const next = state.nextNote.trim();
|
||||
if (next === '') {
|
||||
const hasAttachments = state.attachments != null && state.attachments.length > 0;
|
||||
if (next === '' && !hasAttachments) {
|
||||
return false;
|
||||
}
|
||||
state.saving = true;
|
||||
|
||||
在新工单中引用
屏蔽一个用户