diff --git a/src/apis/modules/common.js b/src/apis/modules/common.js index 4f5547f..b14e84b 100644 --- a/src/apis/modules/common.js +++ b/src/apis/modules/common.js @@ -5,3 +5,10 @@ export const getRegion = (params) => request.basic.get('/region', params) // 获取 验证码ID export const getCaptcha = (params) => request.basic.get('/api/v1/captcha/id', params) + +//上传图片 +export const uploadFile=(params)=>request.basic.post('/api/v1/upload',params,{ + headers: { + 'Content-Type': 'multipart/form-data' + }, + }) \ No newline at end of file diff --git a/src/components/GxUpload/index.vue b/src/components/GxUpload/index.vue index 285e4ce..0e9516f 100644 --- a/src/components/GxUpload/index.vue +++ b/src/components/GxUpload/index.vue @@ -106,9 +106,6 @@ const handlePreview = async (file) => { // 修改handleChange方法 const handleChange = ({ file, fileList: updatedList }) => { - console.log(111) - console.log(file.status) - console.log(updatedList) // 处理上传成功的情况 if (file.status === 'done') { const response = file.response; @@ -145,7 +142,7 @@ const handleCustomRequest = async (options) => { const formData = new FormData(); formData.append('file', file); - const { data } = await apis.common.uploadImg(formData); + const { data } = await apis.common.uploadFile(formData); const fullUrl = config('http.apiBasic') + data; // 正确构造文件对象