flat: 添加企业2
This commit is contained in:
52
api/upload.js
Normal file
52
api/upload.js
Normal file
@@ -0,0 +1,52 @@
|
||||
import {
|
||||
request
|
||||
} from '@/untils/AxiosUtils.js';
|
||||
import {
|
||||
baseUrl
|
||||
} from '@/config/env.js'
|
||||
import {
|
||||
getStore
|
||||
} from '@/untils/store.js'
|
||||
import {
|
||||
Base64
|
||||
} from 'js-base64'
|
||||
import website from "@/config/website.js"
|
||||
|
||||
export async function uploadFile(file) {
|
||||
uni.showLoading({
|
||||
title: '上传中'
|
||||
})
|
||||
var token = getStore({
|
||||
name: 'token'
|
||||
})
|
||||
return new Promise((resolve, reject) => {
|
||||
const header = {
|
||||
'Authorization': `Basic ${Base64.encode(`${website.clientId}:${website.clientSecret}`)}`,
|
||||
}
|
||||
header[website.tokenName] = "bearer " + token
|
||||
uni.uploadFile({
|
||||
url: `${baseUrl}/api/jobslink-api/resource/file/save?bussinessType=5`,
|
||||
header,
|
||||
filePath: file.url,
|
||||
// formData: formdata,
|
||||
name: 'file',
|
||||
success: ({
|
||||
statusCode,
|
||||
data
|
||||
}) => {
|
||||
const resp = JSON.parse(data)
|
||||
if (statusCode === 200 && resp.code === 200) {
|
||||
resolve(resp.msg)
|
||||
} else {
|
||||
reject(new Error('数据异常'))
|
||||
}
|
||||
},
|
||||
fail: (uploadFileRes) => {
|
||||
reject(uploadFileRes)
|
||||
},
|
||||
complete: () => {
|
||||
uni.hideLoading()
|
||||
}
|
||||
});
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user