添加 'api/System/receiveFile' 作为前后端默认的文件接收接口

This commit is contained in:
陆柯 2021-10-17 11:39:19 +08:00
parent a813ffd913
commit eae8361b7d

View File

@ -183,7 +183,7 @@ module.exports = {
count = 1,
sizeType = ['original', 'compressed'],
sourceType = ['album', 'camera'],
url,
url = 'api/System/receiveFile', // 默认后台用这个接口来接受文件
header = {},
formData = {},
name = 'file',
@ -219,14 +219,14 @@ module.exports = {
// url 所在方法进一步处理后,通过 uploadFile 存在 data 里返回结果
uni.hideLoading()
try{ // 不知为何,返回的 data 是字符串而不是对象
try{ // 不知为何,uni.uploadFile返回的 data 是字符串而不是对象
data = JSON.parse(data)
}catch(exp){
return { _state: 'CLIENT_FAIL_RESPONSE_JSON_MALFORMED'}
}
if (data?._state==='SUCCESS') {
return { _state: 'SUCCESS', fileUrl: this.makeServerUrl(data.webpath || data.path), ...data }
if (data?._state==='SUCCESS' && data?.path) {
return { _state: 'SUCCESS', fileUrl: this.makeServerUrl(data.path), ...data }
}else {
return { _state: 'CLIENT_FAIL_UPLOAD_FILE', errorUpload }
}