<?php
$k3 = date("Y-m-d H:i:s",strtotime('-1 months'));
$k4 = date("Y-m-d H:i:s");
$data = [];
$t_str1 = [];
$t_str2 = [];
$t_str3 = [];
$datelist = getDateFromRange($k3,$k4);
for($i=0;$i<count($datelist);$i++)
{
$t_date1 = $datelist[$i] . ' 00:00:00';
$t_date2 = $datelist[$i] . ' 23:59:59';
$order_num = OrderModel::where('order_state','=','2')->where("is_type","=",3)->where('confirm_date','between',[strtotime($t_date1),strtotime($t_date2)])->count();
$order_price = OrderModel::where('order_state','=','2')->where("is_type","=",3)->where('confirm_date','between',[strtotime($t_date1),strtotime($t_date2)])->sum('realoil_price');
$t_str1[] = date('Y-m-d',strtotime($datelist[$i])) ;
$t_str2[] = $order_num*4;
$t_str3[] = $order_price*4;
}
$data["xAxis_date"] = $t_str1;
$data["series_date1"] = $t_str2;
$data["series_date2"] = $t_str3;
// echo json_encode(['result'=>1,'xAxis_date'=>$t_str1,'series_date1'=>$t_str2,'series_date2'=>$t_str3]);//方法二
return json_encode($data);//方法一
?>
$.ajax({
type:"POST",
url:"{:url('chashu')}",
cache: false,
dataType:"json",
data:{'stime':s_time,'etime':e_time,'washercar_id':washercar_id},
success:function(data){
arr=eval("("+data+")");//方法一
console.log(arr.add);//方法一
console.log(data.add);//方法二
}
});
下一篇:前端技术经验总结