diff --git a/packages/uni-mp-alipay/dist/index.js b/packages/uni-mp-alipay/dist/index.js index 87df9f2975263836de2b8223d16eab8d7fbef23a..8c0c767c338ee91b54da5b2d81110c664e38b3fa 100644 --- a/packages/uni-mp-alipay/dist/index.js +++ b/packages/uni-mp-alipay/dist/index.js @@ -132,6 +132,34 @@ const protocols = { } return res }, + request: { + name: 'httpRequest', + args (fromArgs) { + if (!fromArgs.header) { // 默认增加 header 参数,方便格式化 content-type + fromArgs.header = {}; + } + 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 + } + }, + method: 'method', // TODO 支付宝小程序仅支持 get,post + responseType: false + } + }, + returnValue: { + status: 'statusCode', + headers: 'header' + } + }, setNavigationBarColor: { name: 'setNavigationBar', args: { @@ -227,7 +255,7 @@ function processArgs (methodName, fromArgs, argsOption = {}, returnValue = {}) { if (hasOwn(argsOption, key)) { let keyOption = argsOption[key]; if (isFn(keyOption)) { - keyOption = keyOption(fromArgs[key], fromArgs); + keyOption = keyOption(fromArgs[key], fromArgs, toArgs); } if (!keyOption) { // 不支持的参数 console.warn(`支付宝小程序 ${methodName}暂不支持${key}`); diff --git a/src/core/runtime/wrapper.js b/src/core/runtime/wrapper.js index 03f20fec39b2f7e37163c0ba50106285ec8764dc..6189636fb8f43439e1973c4a47c7227407ca1809 100644 --- a/src/core/runtime/wrapper.js +++ b/src/core/runtime/wrapper.js @@ -29,7 +29,7 @@ function processArgs (methodName, fromArgs, argsOption = {}, returnValue = {}) { if (hasOwn(argsOption, key)) { let keyOption = argsOption[key] if (isFn(keyOption)) { - keyOption = keyOption(fromArgs[key], fromArgs) + keyOption = keyOption(fromArgs[key], fromArgs, toArgs) } if (!keyOption) { // 不支持的参数 console.warn(`__PLATFORM_TITLE__ ${methodName}暂不支持${key}`) diff --git a/src/platforms/mp-alipay/service/api/protocols.js b/src/platforms/mp-alipay/service/api/protocols.js index 452fa9d29fb7387dde4e48c8839d7ff0315102d0..966c50cdf843076d0f86f7e52bc6640c45f7fa25 100644 --- a/src/platforms/mp-alipay/service/api/protocols.js +++ b/src/platforms/mp-alipay/service/api/protocols.js @@ -18,6 +18,34 @@ const protocols = { } return res }, + request: { + name: 'httpRequest', + args (fromArgs) { + if (!fromArgs.header) { // 默认增加 header 参数,方便格式化 content-type + fromArgs.header = {} + } + 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 + } + }, + method: 'method', // TODO 支付宝小程序仅支持 get,post + responseType: false + } + }, + returnValue: { + status: 'statusCode', + headers: 'header' + } + }, setNavigationBarColor: { name: 'setNavigationBar', args: {