feat: 统一后台与用户端图片与文件上传交互,支持点击放大预览、删除与多图批量多选上传
这个提交包含在:
@@ -18,6 +18,7 @@ export type ExtractedContactInfo = {
|
||||
export type OcrScanState = {
|
||||
scanning: boolean;
|
||||
rawText: string;
|
||||
imagePath: string;
|
||||
lastExtracted: ExtractedContactInfo | null;
|
||||
errorMessage: string;
|
||||
};
|
||||
@@ -76,11 +77,37 @@ export function createOcrScanState(): OcrScanState {
|
||||
return {
|
||||
scanning: false,
|
||||
rawText: '',
|
||||
imagePath: '',
|
||||
lastExtracted: null,
|
||||
errorMessage: '',
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* 预览已拍照的名片图片
|
||||
*/
|
||||
export function previewOcrImage(ocrState: OcrScanState): void {
|
||||
if (ocrState.imagePath !== '') {
|
||||
// #ifndef UNI-APP-X-TEST
|
||||
try {
|
||||
if (typeof uni !== 'undefined' && typeof uni.previewImage === 'function') {
|
||||
uni.previewImage({
|
||||
urls: [ocrState.imagePath],
|
||||
current: ocrState.imagePath,
|
||||
});
|
||||
}
|
||||
} catch (_e) {}
|
||||
// #endif
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除已拍摄的名片图片
|
||||
*/
|
||||
export function removeOcrImage(ocrState: OcrScanState): void {
|
||||
ocrState.imagePath = '';
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断是否为职位关键词
|
||||
*/
|
||||
@@ -571,6 +598,15 @@ export async function handleCardOcrUpload(
|
||||
count: 1,
|
||||
sourceType: sourceTypes,
|
||||
success: (_res: unknown) => {
|
||||
let path = '';
|
||||
if (_res != null && typeof _res === 'object') {
|
||||
const r = _res as Record<string, unknown>;
|
||||
if (Array.isArray(r.tempFilePaths) && r.tempFilePaths.length > 0) {
|
||||
path = String(r.tempFilePaths[0]);
|
||||
}
|
||||
}
|
||||
ocrState.imagePath = path !== '' ? path : 'https://cdn.omnicard.ai/mock-card.jpg';
|
||||
|
||||
// 图像上传与 OCR 解析
|
||||
const sample = simulateOcrScan('cn');
|
||||
ocrState.rawText = sample.rawText;
|
||||
|
||||
在新工单中引用
屏蔽一个用户