Jelajahi Sumber

文件上传api区分

Xiao_123 6 bulan lalu
induk
melakukan
c80d2f5f6a
3 mengubah file dengan 10 tambahan dan 4 penghapusan
  1. 8 2
      api/file.js
  2. 1 1
      pagesA/info/index.vue
  3. 1 1
      pagesA/resumeOnline/baseInfoEdit.vue

+ 8 - 2
api/file.js

@@ -1,18 +1,24 @@
 import { baseUrl, tenantId, apiPath } from '@/utils/config'
 import { baseUrl, tenantId, apiPath } from '@/utils/config'
 
 
+const uploadApi = {
+  file: '/menduner/system/file/upload',
+  img: '/infra/file/upload'
+}
+
 // 文件上传
 // 文件上传
-export const uploadFile = (file) => {
+export const uploadFile = (file, type = 'file') => {
   uni.showLoading({
   uni.showLoading({
     title: '上传中'
     title: '上传中'
   })
   })
   return new Promise((resolve, reject) => {
   return new Promise((resolve, reject) => {
     uni.uploadFile({
     uni.uploadFile({
-      url: baseUrl + apiPath + '/menduner/system/file/upload',
+      url: baseUrl + apiPath + uploadApi[type],
       filePath: file,
       filePath: file,
       name: 'file',
       name: 'file',
       header: {
       header: {
         Accept: '*/*',
         Accept: '*/*',
         'tenant-id': tenantId,
         'tenant-id': tenantId,
+        'Authorization': 'Bearer ' + uni.getStorageSync('token')
       },
       },
       success: (uploadFileRes) => {
       success: (uploadFileRes) => {
         let result = JSON.parse(uploadFileRes.data)
         let result = JSON.parse(uploadFileRes.data)

+ 1 - 1
pagesA/info/index.vue

@@ -114,7 +114,7 @@ const uploadPhotos = () => {
     sourceType: ['album', 'camera'],
     sourceType: ['album', 'camera'],
     success: function(res){
     success: function(res){
       const path = res.tempFilePaths[0]
       const path = res.tempFilePaths[0]
-      uploadFile(path).then(res => {
+      uploadFile(path, 'img').then(res => {
         formData.value.avatar = res.data
         formData.value.avatar = res.data
       }).catch(error => {
       }).catch(error => {
         uni.showToast({
         uni.showToast({

+ 1 - 1
pagesA/resumeOnline/baseInfoEdit.vue

@@ -123,7 +123,7 @@ const uploadPhotos = () => {
         return
         return
       }
       }
       const path = res.tempFilePaths[0]
       const path = res.tempFilePaths[0]
-      uploadFile(path).then(res => {
+      uploadFile(path, 'img').then(res => {
         formData.value.avatar = res.data
         formData.value.avatar = res.data
       }).catch(error => {
       }).catch(error => {
         uni.showToast({
         uni.showToast({