调用wx.request后,返回值为乱码。如何解决?能否对返回值进行再编码,如果不能如何解决?
我的代码片断如下:
wx.request({ url: 'https://省略隐藏.../miniProgramInterface/login.action' , data:{ user: '1a用户' , password: '2b密码' , code: '3c代码' , }, header:{ 'content-type' : 'application/x-www-form-urlencoded' , }, method: 'POST' , success: function (res){ console.log(res.data) }, }); |
微信开发者工具里面一切正常,手机运行时乱码,代码如下:
data: {
phoNo: ‘’,
area: ‘’
},
wx.request({
url: ‘https://tcc.taobao.com/cc/json/mobile_tel_segment.htm?tel=’ + this.data.phoNo,
header: {
‘content-type’: ‘application/json’
},
//以下也试过,不行
//header: { ‘Content-Type’: ‘application/json;charset=UTF-8;’ },
//header: {‘Content-Type’: ‘application/x-www-form-urlencoded;charset=GB-2312’},
//header: {‘Content-Type’: ‘application/x-www-form-urlencoded;charset=GBK’},
success(res) {
console.log(res.data)
self.setData({
area: res.data
});
}
})
https://tcc.taobao.com/cc/json/mobile_tel_segment.htm?tel=17312319729
用以上地址通过浏览器访问,一切正常!