只需要在header头里添加 "content-type": "application/x-www-form-urlencoded"
/**
* post请求封装(不需要头文件)
* @param {*} uri 请求地址
* @param {*} params 请求参数
* @param {*} success 成功方法
* @param {*} fail 失败方法
*/
function httpRequest(uri, params, success) {
wx.showLoading({
title: '加载中...',
})
wx.request({
url: host+uri,
data: params,
method: "POST",
header: {
"content-type":"application/x-www-form-urlencoded"
},
success: function(response) {
wx.hideLoading()
console.log(response.data)
success(response)
},
fail: function(error) {
wx.hideLoading()
console.log(error)
}
})
}