From 630f486831096dba2e3eec6bbe82561587eb186f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E7=90=A6?= Date: Thu, 18 Jun 2026 17:04:50 +0800 Subject: [PATCH] =?UTF-8?q?1.=20=E8=AF=8A=E6=89=80=E7=AE=A1=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/upload.js | 16 +- common/js/oss-upload.js | 11 +- .../account-switch/account-switch-panel.vue | 7 +- components/doctor-login/doctor-login.vue | 7 +- .../common/inputFormHelpers.js | 14 +- .../components/ImageGalleryPicker.vue | 200 ++++++++++++++++-- utils/doctorWxAuth.js | 19 ++ 7 files changed, 234 insertions(+), 40 deletions(-) create mode 100644 utils/doctorWxAuth.js diff --git a/api/upload.js b/api/upload.js index c76e9e0..41bea39 100644 --- a/api/upload.js +++ b/api/upload.js @@ -28,26 +28,30 @@ function getOssSignatureByPrefix(prefix, headerKey) { }); } -function registerOssFileByPrefix(prefix, headerKey, url, fileSize = 0) { +function registerOssFileByPrefix(prefix, headerKey, url, fileSize = 0, fileName = '') { + const data = { url, source: 2, file_size: fileSize } + if (fileName) { + data.file_name = fileName + } return req.request({ url: `${prefix}register-oss-file`, method: 'POST', - data: { url, source: 2, file_size: fileSize }, + data, header: { [headerKey]: '1', }, }); } -function registerBusinessOssFile(url, fileSize = 0) { +function registerBusinessOssFile(url, fileSize = 0, fileName = '') { const mode = uni.getStorageSync('loginMode'); if (mode === 'platform_admin') { - return registerOssFileByPrefix(PLATFORM_PREFIX, '_platformAdmin', url, fileSize); + return registerOssFileByPrefix(PLATFORM_PREFIX, '_platformAdmin', url, fileSize, fileName); } if (mode === 'clinic_admin') { - return registerOssFileByPrefix(CLINIC_ADMIN_PREFIX, '_clinicAdmin', url, fileSize); + return registerOssFileByPrefix(CLINIC_ADMIN_PREFIX, '_clinicAdmin', url, fileSize, fileName); } - return registerOssFileByPrefix(SALESPERSON_PREFIX, '_salesperson', url, fileSize); + return registerOssFileByPrefix(SALESPERSON_PREFIX, '_salesperson', url, fileSize, fileName); } export { registerBusinessOssFile }; diff --git a/common/js/oss-upload.js b/common/js/oss-upload.js index 0a6d9f9..fd00ef1 100644 --- a/common/js/oss-upload.js +++ b/common/js/oss-upload.js @@ -31,6 +31,12 @@ export function generateObjectName(filePath) { return `xk_upload_${dateStr}/${uuid}_${timestamp}.${extension}`; } +function basenameFromPath(filePath) { + const pathStr = String(filePath || ''); + const parts = pathStr.split(/[/\\]/); + return parts[parts.length - 1] || ''; +} + /** * @returns {Promise<{ accessKeyId, policy, signature, host, bucket, key, expire }>} */ @@ -48,7 +54,7 @@ export async function getOssSignatureFromBackend() { * @returns {Promise<{ url: string, objectName: string }>} */ export async function uploadToOss(options) { - const { filePath, onProgress, fileSize = 0 } = options || {}; + const { filePath, onProgress, fileSize = 0, fileName = '' } = options || {}; if (!filePath) { throw new Error('文件路径为空'); } @@ -76,7 +82,8 @@ export async function uploadToOss(options) { if (code >= 200 && code < 300 || code === 204) { const host = String(signature.host).replace(/\/$/, ''); const url = `${host}/${objectName}`; - registerBusinessOssFile(url, fileSize).catch((err) => { + const displayName = fileName || basenameFromPath(filePath); + registerBusinessOssFile(url, fileSize, displayName).catch((err) => { console.warn('OSS 文件登记失败:', err); }); resolve({ diff --git a/components/account-switch/account-switch-panel.vue b/components/account-switch/account-switch-panel.vue index d0bb66c..d574cb0 100644 --- a/components/account-switch/account-switch-panel.vue +++ b/components/account-switch/account-switch-panel.vue @@ -49,6 +49,7 @@