From 06d5d5ca81585e3cec90493ca09793e4824b796e Mon Sep 17 00:00:00 2001 From: "luk.lu" Date: Wed, 20 Oct 2021 10:19:03 +0800 Subject: [PATCH] u --- index.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/index.js b/index.js index 7cfae14..1a63fbc 100644 --- a/index.js +++ b/index.js @@ -62,6 +62,7 @@ module.exports = { makeServerUrl(route = '') { if (typeof route !== 'string') route = '' // 防止 route 为 null, undefined 等由于后台数据库默认值而造成的异常。 + route.replace('\\', '/') if (/^https?:\/\//.test(route)) { return route } @@ -219,12 +220,12 @@ module.exports = { // url 所在方法进一步处理后,通过 uploadFile 存在 data 里返回结果 uni.hideLoading() - try{ // 不知为何,uni.uploadFile返回的 data 是字符串而不是对象 - if (typeof(data)==='string') { + if (typeof(data)==='string') { // 不知为何,uni.uploadFile返回的 data 是字符串而不是对象 + try{ data = JSON.parse(data) + }catch(exp){ + return { _state: 'CLIENT_FAIL_RESPONSE_JSON_MALFORMED'} } - }catch(exp){ - return { _state: 'CLIENT_FAIL_RESPONSE_JSON_MALFORMED'} } if (data?._state==='SUCCESS' && data?.path) {