diff --git a/activitylink/.env.development b/activitylink/.env.development index 38be259..663e7fc 100644 --- a/activitylink/.env.development +++ b/activitylink/.env.development @@ -4,4 +4,4 @@ VITE_PUBLIC_PATH = '/testBack/' VITE_APP_BASE_API = 'https://dbqb.nfdxy.net/devLotApi/' # VITE_APP_BASE_API = 'http://localhost:12699' VITE_USE_MOCK = true -VITE_UPLOAD_URL='http://39.101.133.168:8828/hljw/api/aws/upload' \ No newline at end of file +VITE_UPLOAD_URL='http://39.101.133.168:8828/hljw/api/aws/upload' diff --git a/activitylink/.env.production b/activitylink/.env.production index 9c652b5..bbe0ab8 100644 --- a/activitylink/.env.production +++ b/activitylink/.env.production @@ -2,7 +2,11 @@ VITE_ENV = 'production' VITE_OUTPUT_DIR = 'dist' VITE_PUBLIC_PATH = '/testBack/' VITE_USE_MOCK = true +VITE_UPLOAD_URL='https://api.homilychart.com/hljw/api/aws/upload' +VITE_APP_BASE_API = 'https://dbqb.nfdxy.net/devLotApi' + + VITE_BUILD_COMPRESS = 'none' VITE_BUILD_COMPRESS_DELETE_ORIGIN_FILE = false VITE_UPLOAD_URL='https://api.homilychart.com/hljw/api/aws/upload' -VITE_APP_BASE_API = 'https://dbqb.nfdxy.net/devLotApi/' \ No newline at end of file +VITE_APP_BASE_API = 'https://dbqb.nfdxy.net/devLotApi/' diff --git a/activitylink/src/utils/request.js b/activitylink/src/utils/request.js index 78b95ee..9aa5d5a 100644 --- a/activitylink/src/utils/request.js +++ b/activitylink/src/utils/request.js @@ -33,14 +33,4 @@ service.interceptors.response.use( return Promise.reject(error) } ) -export const uploadFile = (file) => { - const formData = new FormData(); - formData.append('file', file); - - return service.post(import.meta.env.VITE_UPLOAD_URL, formData, { - headers: { - 'Content-Type': 'multipart/form-data' - } - }); -}; export default service \ No newline at end of file diff --git a/activitylink/src/views/zhongchou/gift/index.vue b/activitylink/src/views/zhongchou/gift/index.vue index 5c8aa80..844ae1c 100644 --- a/activitylink/src/views/zhongchou/gift/index.vue +++ b/activitylink/src/views/zhongchou/gift/index.vue @@ -48,9 +48,10 @@ - + @@ -85,9 +86,10 @@ - + @@ -247,7 +249,7 @@ const submitAdd = async () => { } // 删除 const deleteGift = (row) => { - ElMessageBox.confirm('确定要删除该等级吗?', '提示', { + ElMessageBox.confirm('确定要删除该礼品吗?', '提示', { confirmButtonText: '确定', cancelButtonText: '取消', type: 'warning' @@ -320,7 +322,30 @@ const goToimportFixedList = (row) => { } }); } +const customUpload = async (options) => { + try { + const formData = new FormData(); + formData.append('file', options.file); + + const response = await axios.post(import.meta.env.VITE_UPLOAD_URL, formData, { + headers: { + 'Content-Type': 'multipart/form-data', + 'Authorization': `Bearer ${localStorage.getItem('token')}` + } + }); + if (response.data.code === 200 && response.data.data) { + // 传递原始文件对象和响应数据 + handleUploadSuccess(response.data, options.file); + ElMessage.success('上传成功'); + } else { + ElMessage.error(response.data.msg || '上传失败'); + } + } catch (error) { + console.error('上传错误:', error); + ElMessage.error(`上传失败: ${error.response?.data?.message || error.message}`); + } +}; const goToimportUsers = () => { router.push({ name: 'importUsers' }); } diff --git a/activitylink/vite.config.js b/activitylink/vite.config.js index 729ad69..36e8f7e 100644 --- a/activitylink/vite.config.js +++ b/activitylink/vite.config.js @@ -10,16 +10,13 @@ export default defineConfig({ '@': path.resolve(__dirname, './src') } }, - server: { - proxy: { - '/api': { - target: 'https://dbqb.nfdxy.net', // 后端基础地址 - changeOrigin: true, - rewrite: (path) => path.replace(/^\/api/, ''), // 移除 /api 前缀 - // 或者更精确的重写(根据后端路径调整): - // rewrite: (path) => path.replace(/^\/api\/admin/, '/admin'), - } + server: { + proxy: { + '/api': { + target: 'https://dbqb.nfdxy.net', + changeOrigin: true, + rewrite: (path) => path.replace(/^\/api/, '') }, - }, - }, -); \ No newline at end of file + } + } +});