From acd7e64577b6f21245fa72a1d0c1667a275ffe76 Mon Sep 17 00:00:00 2001 From: wangyaqi Date: Wed, 4 Mar 2020 11:28:56 +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=8Fcontent-type=E4=B8=BAapplication/json=E6=97=B6?= =?UTF-8?q?=E8=87=AA=E5=8A=A8=E5=BA=8F=E5=88=97=E5=8C=96data?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mp-alipay/runtime/api/protocols.js | 25 ++++++++++++++----- 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/src/platforms/mp-alipay/runtime/api/protocols.js b/src/platforms/mp-alipay/runtime/api/protocols.js index 655a79f3e..9f7377de4 100644 --- a/src/platforms/mp-alipay/runtime/api/protocols.js +++ b/src/platforms/mp-alipay/runtime/api/protocols.js @@ -89,19 +89,32 @@ const protocols = { // 需要做转换的 API 列表 if (!fromArgs.header) { // 默认增加 header 参数,方便格式化 content-type fromArgs.header = {} } + const headers = { + 'content-type': 'application/json' + } + Object.keys(fromArgs.header).forEach(key => { + headers[key.toLocaleLowerCase()] = fromArgs.header[key] + }) return { header (header = {}, toArgs) { - const headers = { - 'content-type': 'application/json' - } - Object.keys(header).forEach(key => { - headers[key.toLocaleLowerCase()] = header[key] - }) return { name: 'headers', value: headers } }, + data (data) { + // 钉钉在content-type为application/json时,不会自动序列化 + if (my.dd && headers['content-type'].indexOf('application/json') === 0) { + return { + name: 'data', + value: JSON.stringify(data) + } + } + return { + name: 'data', + value: data + } + }, method: 'method', // TODO 支付宝小程序仅支持 get,post responseType: false } -- GitLab