Parcourir la source

文件上传api参数添加

Xiao_123 il y a 6 mois
Parent
commit
f59af80d0d

+ 9 - 6
api/file.js

@@ -1,19 +1,22 @@
 import { baseUrl, tenantId, apiPath } from '@/utils/config'
 
-const uploadApi = {
-  file: '/menduner/system/file/upload',
-  img: '/infra/file/upload'
-}
+// const uploadApi = {
+//   file: '/menduner/system/file/upload',
+//   img: '/infra/file/upload'
+// }
 
 // 文件上传
-export const uploadFile = (file, type = 'file') => {
+export const uploadFile = (file, path) => {
   uni.showLoading({
     title: '上传中'
   })
   return new Promise((resolve, reject) => {
     uni.uploadFile({
-      url: baseUrl + apiPath + uploadApi[type],
+      url: baseUrl + apiPath + '/menduner/system/file/upload',
       filePath: file,
+      formData: {
+        path
+      },
       name: 'file',
       header: {
         Accept: '*/*',

+ 7 - 0
package-lock.json

@@ -7,6 +7,7 @@
       "dependencies": {
         "dayjs": "^1.11.13",
         "js-base64": "^3.7.7",
+        "js-sha256": "^0.11.0",
         "lodash-es": "^4.17.21",
         "luch-request": "^3.1.1",
         "pinia": "^2.2.2",
@@ -1277,6 +1278,12 @@
       "resolved": "https://registry.npmmirror.com/js-base64/-/js-base64-3.7.7.tgz",
       "integrity": "sha512-7rCnleh0z2CkXhH67J8K1Ytz0b2Y+yxTPL+/KOJoa20hfnVQ/3/T6W/KflYI4bRHRagNeXeU2bkNGI3v1oS/lw=="
     },
+    "node_modules/js-sha256": {
+      "version": "0.11.0",
+      "resolved": "https://registry.npmmirror.com/js-sha256/-/js-sha256-0.11.0.tgz",
+      "integrity": "sha512-6xNlKayMZvds9h1Y1VWc0fQHQ82BxTXizWPEtEeGvmOUYpBRy4gbWroHLpzowe6xiQhHpelCQiE7HEdznyBL9Q==",
+      "license": "MIT"
+    },
     "node_modules/js-tokens": {
       "version": "9.0.0",
       "resolved": "https://registry.npmmirror.com/js-tokens/-/js-tokens-9.0.0.tgz",

+ 2 - 2
pagesA/chart/index.vue

@@ -503,13 +503,13 @@ function handleUploadResume () {
       if (!test) {
         uni.showToast({
           icon: 'none',
-          title: '请上传pdf、word类型的文件',
+          title: '请上传pdf、doc、docx类型的文件',
           duration: 2000
         })
         return
       }
       //效验是否为支持的文件格式
-      uploadFile(path).then(async (res) => {
+      uploadFile(path, 'attachment').then(async (res) => {
         if (!res.data) {
           uni.showToast({
             title: '上传失败',

+ 2 - 2
pagesA/resume/index.vue

@@ -82,7 +82,7 @@ const handleUpload = () => {
       const path = res.tempFiles[0].path
       //效验是否为支持的文件格式
       if(/\.(pdf|docx|doc)$/.test(title)){
-        uploadFile(path).then(async (res) => {
+        uploadFile(path, 'attachment').then(async (res) => {
           if (!res.data) {
             uni.showToast({
               title: '上传失败',
@@ -100,7 +100,7 @@ const handleUpload = () => {
       }else{
         uni.showToast({
           icon: 'none',
-          title: '请上传pdf、word类型的文件',
+          title: '请上传pdf、doc、docx类型的文件',
           duration: 2000
         })
         return

+ 1 - 1
pagesA/resumeOnline/baseInfoEdit.vue

@@ -123,7 +123,7 @@ const uploadPhotos = () => {
       if (size >= 31457280) {
         uni.showToast({
           icon: 'none',
-          title: '头像上传大小不得超过 30MB !',
+          title: '头像上传大小不得超过 20MB !',
           duration: 2000
         })
         return

+ 2 - 2
pagesB/positionDetail/index.vue

@@ -450,7 +450,7 @@ const handleUpload = () => {
       const path = res.tempFiles[0].path
       //效验是否为支持的文件格式
       if(/\.(pdf|docx|doc)$/.test(title)){
-        uploadFile(path).then(async (res) => {
+        uploadFile(path, 'attachment').then(async (res) => {
           if (!res.data) {
             uni.showToast({
               title: '上传失败',
@@ -468,7 +468,7 @@ const handleUpload = () => {
       }else{
         uni.showToast({
           icon: 'none',
-          title: '请上传pdf、word类型的文件',
+          title: '请上传pdf、doc、docx类型的文件',
           duration: 2000
         })
         return