//方法
function getThrough(){
var date=new Date;
//携带的参数
var params = {gkmc: '广州',
year:date.getFullYear(),
minTtl:'',
maxTtl:'',
arealag:1,
recordPerPage: 10,
page: 1,
};
var _content=obj2string(params); //对参数进行转换字符串格式
var method = "GET_SHIP_PORT_THROUGHPUT";
var post_data = {
action: method,
content: _content,
token: "token3333" //GetCookieBySSOID()
};
$.ajax({
url:"http://121.33.20.100:8000/DCIWebService/rest/zjhy", //url
type:"post", //请求类型 ,
contentType: "application/json; charset=utf-8", //没有说明 ,就使用默认的
async:false,
dataType: "json", //返回的数据类型 ,跟后台配合好 ,一般都是json,
data: post_data,
success: function(msg){
var nameList = [];
var scoreList =[];
//拿到数据循环获取
for(var i = 0;i<msg.data.records.length;i++){var record = msg.data.records[i];
nameList.push(record.P_NAME);
scoreList.push(record.THROUGHOUT);
}
var myChart = echarts.init(document.getElementById('gxhwtj'));
myChart.setOption({
title: {
text: '干线货物统计'
},
tooltip: {},
legend: {
data:['运价']
},
xAxis: {
data: nameList
},
yAxis: {},
series: [{
name: '运价',
type: 'line',
data: scoreList
}]
});
},
error: function(error){
}
});
}
//将参数转换成字符串方法
function obj2string(o) {
var r = [];
if (typeof o == "string") {
return o;
}
if (typeof o == "object") {
if (!o.sort) {
for (var i in o) {
r.push('"'+i+'"' + ":" + this.obj2string(o[i]));
}
if (!!document.all && !/^\n?function\s*toString\(\)\s*\{\n?\s*\[native code\]\n?\s*\}\n?\s*$/.test(o.toString)) {
r.push("toString:" + o.toString.toString());
}
r = "{" + r.join() + "}";
} else {
for (var i = 0; i < o.length; i++) {
r.push(this.obj2string(o[i]))
}
r = "[" + r.join() + "]";
}
return r;
}
return o.toString();
}
![](/qrcode.jpg)