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