前端环境 antd umi dva 用
umi
的request
https://github.com/umijs/umi-request/blob/master/README_zh-CN.md
前端代码:
request(BASE_URL + '/raycare/api/userCenter/get7DayJiance' + RTOKEN, {
method: 'post',
requestType: 'json', //json格式
data: {
day: JSON.stringify(day_arr),//数组转为json字符串
custom_id: custom_id,
},
// headers: { 'Content-Type': 'text/json'}
})
.then(res => {
this.setState({ loading: false }) // 隐藏loading
if (res.status === 'ok') {
/*this.setState({
sevenDayXuetang: res.xuetang,
sevenDayXueya: res.xueya,
sevenDayTizhong: res.tizhong,
sevenDayXinlv: res.xinlv,
})*/
console.log(res.day);
}
if (res.status === 'error') {
/*this.setState({
sevenDayXuetang: [],
sevenDayXueya: [],
sevenDayTizhong: [],
sevenDayXinlv: [],
})*/
message.error(res.data)
}
});
后端代码: php
public function get7DayJiance()
{
//接收json 数据
$post_string = file_get_contents("php://input");
//把json字符串转数组 加 tue
$to_2array = json_decode($post_string,true);
//把数组字符串转为数组
$day=json_decode($to_2array['day']);
$custom_id = $to_2array['custom_id'];
var_dump($custom_id);
exit();
}
网友评论