diff --git a/pages/user/info.vue b/pages/user/info.vue index 255a9b3f..f3784d09 100644 --- a/pages/user/info.vue +++ b/pages/user/info.vue @@ -38,7 +38,7 @@ - + - - + - @@ -185,11 +183,12 @@ diff --git a/sheep/api/app.js b/sheep/api/app.js index 5e4eb41f..184882f0 100644 --- a/sheep/api/app.js +++ b/sheep/api/app.js @@ -72,48 +72,4 @@ export default { method: 'GET' }), }, - - //上传 - upload: (file, group = 'ugc', callback) => { - const token = uni.getStorageSync('token'); - uni.showLoading({ - title: '上传中', - }); - return new Promise((resolve, reject) => { - // 此处先换成yudao - uni.uploadFile({ - url: 'http://api-dashboard.yudao.iocoder.cn' + '/app-api/infra/file/upload', - filePath: file, - name: 'file', - formData: { - group, - }, - header: { - // Accept: 'text/json', - // Authorization: token, - Accept : '*/*', - 'tenant-id' :'1', - Authorization: 'Bearer test247', - }, - success: (uploadFileRes) => { - let result = JSON.parse(uploadFileRes.data); - if (result.error === 1) { - uni.showToast({ - icon: 'none', - title: result.msg, - }); - } else { - return resolve(result.data); - } - }, - fail: (error) => { - console.log('上传失败:', error); - return resolve(false); - }, - complete: () => { - uni.hideLoading(); - }, - }); - }); - }, }; diff --git a/sheep/api/infra/file.js b/sheep/api/infra/file.js new file mode 100644 index 00000000..264f646d --- /dev/null +++ b/sheep/api/infra/file.js @@ -0,0 +1,49 @@ +import request2 from '@/sheep/request2'; + +const FileApi = { + // 上传文件 + uploadFile: (file) => { + const token = uni.getStorageSync('token'); + uni.showLoading({ + title: '上传中', + }); + return new Promise((resolve, reject) => { + // 此处先换成yudao + // TODO 芋艿:后续搞下 + uni.uploadFile({ + // url: 'http://api-dashboard.yudao.iocoder.cn' + '/app-api/infra/file/upload', + url: 'http://127.0.0.1:48080' + '/app-api/infra/file/upload', + filePath: file, + name: 'file', + header: { + // Accept: 'text/json', + // Authorization: token, + Accept : '*/*', + 'tenant-id' :'1', + Authorization: 'Bearer test247', + }, + success: (uploadFileRes) => { + debugger + let result = JSON.parse(uploadFileRes.data); + if (result.error === 1) { + uni.showToast({ + icon: 'none', + title: result.msg, + }); + } else { + return resolve(result); + } + }, + fail: (error) => { + console.log('上传失败:', error); + return resolve(false); + }, + complete: () => { + uni.hideLoading(); + }, + }); + }); + }, +}; + +export default FileApi;