| | |
| | | if (url.startsWith("http://") || url.startsWith("https://")) { |
| | | return url; |
| | | } |
| | | const uploadsIndex = url.indexOf("uploads"); |
| | | if (uploadsIndex !== -1) { |
| | | const relativePath = url.substring(uploadsIndex); |
| | | return `${config.baseUrl}/${relativePath}`; |
| | | } |
| | | return `${config.baseUrl}/${url}`; |
| | | // const uploadsIndex = url.indexOf("uploads"); |
| | | // if (uploadsIndex !== -1) { |
| | | // const relativePath = url.substring(uploadsIndex); |
| | | // return `${config.fileUrl}/${relativePath}`; |
| | | // } |
| | | return `${config.fileUrl}/${url}`; |
| | | }; |
| | | |
| | | // 判断是否为图片文件 |
| | |
| | | |
| | | // 预览文件 |
| | | const previewFile = file => { |
| | | if (file.type.includes("image")) { |
| | | uni.previewImage({ |
| | | urls: [file.url], |
| | | current: file.url, |
| | | }); |
| | | } else { |
| | | // 视频预览 |
| | | const videoUrl = formatFileUrl(file.url || file.downloadUrl); |
| | | uni.navigateTo({ |
| | | url: `/pages/common/videoPreview?url=${encodeURIComponent(videoUrl)}`, |
| | | }); |
| | | } |
| | | // if (file.type.includes("image")) { |
| | | uni.previewImage({ |
| | | urls: [formatFileUrl(file.url)], |
| | | current: formatFileUrl(file.url), |
| | | }); |
| | | // } else { |
| | | // // 视频预览 |
| | | // const videoUrl = formatFileUrl(file.url || file.downloadUrl); |
| | | // uni.navigateTo({ |
| | | // url: `/pages/common/videoPreview?url=${encodeURIComponent(videoUrl)}`, |
| | | // }); |
| | | // } |
| | | }; |
| | | |
| | | // 获取详情数据 |
| | |
| | | // 处理附件数据 - 支持多种数据结构 |
| | | console.log(data.imagesFile); |
| | | fileList.value = data.imagesFile; |
| | | console.log(formatFileUrl(fileList.value[0].url)); |
| | | }; |
| | | |
| | | // 返回上一页 |