From eae8361b7d84b2cb746ff2c2ba260eb57c421135 Mon Sep 17 00:00:00 2001 From: Luk Lu Date: Sun, 17 Oct 2021 11:39:19 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=20'api/System/receiveFile'?= =?UTF-8?q?=20=E4=BD=9C=E4=B8=BA=E5=89=8D=E5=90=8E=E7=AB=AF=E9=BB=98?= =?UTF-8?q?=E8=AE=A4=E7=9A=84=E6=96=87=E4=BB=B6=E6=8E=A5=E6=94=B6=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- index.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/index.js b/index.js index 115230e..f15d337 100644 --- a/index.js +++ b/index.js @@ -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 } }