|
|
|
@ -178,10 +178,12 @@ |
|
|
|
|
|
|
|
<!-- 生产环境:上传方式选择 --> |
|
|
|
<van-action-sheet |
|
|
|
v-if="isEdit" |
|
|
|
v-model:show="showUploadAction" |
|
|
|
:actions="uploadActions" |
|
|
|
cancel-text="取消" |
|
|
|
close-on-click-action |
|
|
|
teleport="body" |
|
|
|
@select="onSelectUploadAction" |
|
|
|
/> |
|
|
|
</div> |
|
|
|
@ -323,7 +325,7 @@ const isProd = computed(() => appEnv === 'prod') |
|
|
|
const showUploadAction = ref(false) |
|
|
|
const activeUploadItem = ref(null) |
|
|
|
const uploadActions = [ |
|
|
|
{ name: '拍照(带水印与经纬度)' }, |
|
|
|
{ name: '拍照' }, |
|
|
|
{ name: '录制视频' }, |
|
|
|
] |
|
|
|
|
|
|
|
@ -401,23 +403,27 @@ const onOpenUploadAction = (item) => { |
|
|
|
const onSelectUploadAction = ({ name }) => { |
|
|
|
const item = activeUploadItem.value |
|
|
|
if (!item) return |
|
|
|
if (name === '拍照(带水印与经纬度)') onTakePhoto(item) |
|
|
|
if (name === '拍照') onTakePhoto(item) |
|
|
|
else if (name === '录制视频') onRecordVideo(item) |
|
|
|
} |
|
|
|
|
|
|
|
// 拍照带水印(时间戳 + 经纬度自动叠加) |
|
|
|
const onTakePhoto = async (item) => { |
|
|
|
console.log('[NosDetail] onTakePhoto 开始, item:', item, 'fileList:', item?.fileList) |
|
|
|
try { |
|
|
|
const watermarkContent = $globalStore.useCommon?.enterpriseName || '深圳市行政执法监督码' |
|
|
|
const res = await takePhotoWithWaterMark({ content: watermarkContent }) |
|
|
|
console.log('[NosDetail] 拍照返回 res:', res, 'imageURL:', res?.imageURL, 'key:', res?.key) |
|
|
|
const localPath = res.imageURL || res.key |
|
|
|
console.log('[NosDetail] 解析出的 localPath:', localPath) |
|
|
|
await pushSdkFileToFileList(item, { |
|
|
|
localPath: res.imageURL || res.key, |
|
|
|
localPath, |
|
|
|
fileName: `photo-${Date.now()}.jpg`, |
|
|
|
mimeType: 'image/jpeg', |
|
|
|
isImage: true, |
|
|
|
}) |
|
|
|
} catch (err) { |
|
|
|
console.error('w6s 拍照失败', err) |
|
|
|
console.error('[NosDetail] w6s 拍照失败', err) |
|
|
|
showToast('拍照失败或已取消') |
|
|
|
} |
|
|
|
} |
|
|
|
@ -441,7 +447,11 @@ const onRecordVideo = async (item) => { |
|
|
|
|
|
|
|
// 通用:把 SDK 返回的本地文件上传后端 → 写入 fileList |
|
|
|
const pushSdkFileToFileList = async (item, { localPath, fileName, mimeType, isImage }) => { |
|
|
|
if (!localPath) return |
|
|
|
console.log('[NosDetail] pushSdkFileToFileList 开始, 入参:', { localPath, fileName, mimeType, isImage }) |
|
|
|
if (!localPath) { |
|
|
|
console.warn('[NosDetail] pushSdkFileToFileList localPath 为空, 直接返回') |
|
|
|
return |
|
|
|
} |
|
|
|
const fileObj = { |
|
|
|
url: '', |
|
|
|
isImage, |
|
|
|
@ -449,22 +459,27 @@ const pushSdkFileToFileList = async (item, { localPath, fileName, mimeType, isIm |
|
|
|
message: '上传中...', |
|
|
|
} |
|
|
|
item.fileList.push(fileObj) |
|
|
|
console.log('[NosDetail] 已 push 到 fileList, 当前 fileList 长度:', item.fileList.length, 'fileObj:', fileObj) |
|
|
|
try { |
|
|
|
const res = await uploadLocalFileToBackend({ fileURL: localPath, fileName, mimeType }) |
|
|
|
console.log('[NosDetail] 上传后端返回 res:', res) |
|
|
|
const data = res && res.data ? res.data : res |
|
|
|
const filePath = typeof data === 'string' |
|
|
|
? data |
|
|
|
: (data && (data.data || data.url || data.fileUrl || data.path)) || '' |
|
|
|
console.log('[NosDetail] 解析出的 filePath:', filePath, 'data:', data) |
|
|
|
if (filePath) { |
|
|
|
fileObj.url = toFullFileUrl(filePath) |
|
|
|
fileObj.status = 'done' |
|
|
|
fileObj.message = '' |
|
|
|
console.log('[NosDetail] 上传成功, fileObj.url:', fileObj.url) |
|
|
|
} else { |
|
|
|
fileObj.status = 'failed' |
|
|
|
fileObj.message = '上传失败' |
|
|
|
console.warn('[NosDetail] 上传失败: filePath 为空') |
|
|
|
} |
|
|
|
} catch (err) { |
|
|
|
console.error('w6s 上传后端失败', err) |
|
|
|
console.error('[NosDetail] w6s 上传后端失败:', err) |
|
|
|
fileObj.status = 'failed' |
|
|
|
fileObj.message = '上传失败' |
|
|
|
} |
|
|
|
|