由于项目原因必须采用 application/x-www-form-urlencoded 类型传递参数,但是参数中需要传递数组类型,我采用如下方式传递后台是不能接收到的
export const httpRequest = (options)=>{
return new Promise((resolve,reject)=>{
uni.request({
url:BASE_URL+options.url,
method: options.method || 'GET',
data: options.data || {},
header: options.header || {
'content-type': 'application/x-www-form-urlencoded'
},
success: (res)=>{
resolve(res)
},
fail: (err)=>{
reject(err)
}
})
})
}
前台代码如下
submit:async function() {
// 表单提交
let that = this;
console.log('请求参数:'+this.healthCertificateVo);
let obj = that.healthCertificateVo.attachmentVos[0];
debugger
const res = await this.$httpRequest({
url: '/wxapi/healthcertificate/' ,
method: 'POST',
data:that.healthCertificateVo
});
console.log("响应结果:"+res);
}