From 5b61f89c8b81dfa8a6fe5e9624abf60c0c054d5d Mon Sep 17 00:00:00 2001 From: wangyaqi Date: Fri, 29 May 2020 14:19:00 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E9=92=89=E9=92=89=E5=B0=8F=E7=A8=8B?= =?UTF-8?q?=E5=BA=8F=E7=9C=9F=E6=9C=BA=E4=BD=BF=E7=94=A8uni.request?= =?UTF-8?q?=E6=97=B6=E8=AE=BE=E7=BD=AEcontent-type=E4=B8=BAapplication/jso?= =?UTF-8?q?n=E6=8A=A5=E9=94=99=E7=9A=84Bug=20askId:=20https://ask.dcloud.n?= =?UTF-8?q?et.cn/question/97570?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/platforms/mp-alipay/runtime/api/protocols.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/platforms/mp-alipay/runtime/api/protocols.js b/src/platforms/mp-alipay/runtime/api/protocols.js index 838ab1d74..c7e455ddd 100644 --- a/src/platforms/mp-alipay/runtime/api/protocols.js +++ b/src/platforms/mp-alipay/runtime/api/protocols.js @@ -1,3 +1,6 @@ +import { + isPlainObject +} from 'uni-shared' // 不支持的 API 列表 const todos = [ // 'getRecorderManager', @@ -86,6 +89,7 @@ const protocols = { // 需要做转换的 API 列表 request: { name: my.canIUse('request') ? 'request' : 'httpRequest', args (fromArgs) { + const method = fromArgs.method || 'GET' if (!fromArgs.header) { // 默认增加 header 参数,方便格式化 content-type fromArgs.header = {} } @@ -103,8 +107,8 @@ const protocols = { // 需要做转换的 API 列表 } }, data (data) { - // 钉钉在content-type为application/json时,不会自动序列化 - if (my.dd && headers['content-type'].indexOf('application/json') === 0) { + // 钉钉小程序在content-type为application/json时需上传字符串形式data,使用my.dd在真机运行钉钉小程序时不能正确判断 + if (my.canIUse('saveFileToDingTalk') && method.toUpperCase() === 'POST' && headers['content-type'].indexOf('application/json') === 0 && isPlainObject(data)) { return { name: 'data', value: JSON.stringify(data) -- GitLab