wx.login({
success(res){
console.log(res)
var code=res.code;
wx.request({
url: 'http://192.168.1.6:8080/wxLogin',
method :'POST',
data:{
code: code
},
header: {
"Content-Type": "application/x-www-form-urlencoded"
},
success :function (res) {
console.log("-----success-----")
console.log(res)
wx.showToast({
title: res.data.code+"",
})
},
fail : function(error){
console.log("-----fail-----")
console.log(error)
}
})
},
})
微信post表單提交氏涩,應該添加下面內(nèi)容
header: {
"Content-Type": "application/x-www-form-urlencoded"
},
@RestController
public class WXLoginController {
@PostMapping("/wxLogin")
public ResultData<String> wxLogin(@RequestParam(name = "code") String code){
System.out.println("wxLogin---code : "+code);
ResultData data=new ResultData();
data.setCode(33);
return data;
}
@GetMapping("/hello")
public ResultData<String> Hello(){
ResultData data=new ResultData();
data.setCode(33);
return data;
}
}
最后編輯于 :
?著作權歸作者所有,轉載或內(nèi)容合作請聯(lián)系作者