<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>百度快递查询接口Demo</title> <script type="text/javascript" src="js/jquery-1.4.2.min.js"></script> </head> <script type="text/javascript">
var strUrl = "http://baidu.kuaidi100.com/query";
var typeValue = "tiantian", postIdValue = "";
typeValue = getCompanyCode("天天"); var gQueryType = ; //查询类型,4为百度查询
var type;
var postid;
var isvalide;
var havereturn = false;
var statuscode = ;
var req;
var ischoose = false;
var returnjson;
var returnjson_up = [];
var returnjson_down = [];
var gSortStatus = ;
var queryurl = '';
var isavailable = ;
var gIsCheck; var t;
getResult();
function $(id) { return document.getElementById(id) } function getCompanyCode(name) {
var companyList = []; // 快递公司名 | 快递公司对应查询快递单号名
companyList.push("EMS|ems");
companyList.push("申通|shentong");
companyList.push("圆通|yuantong");
companyList.push("中通|zhongtong");
companyList.push("汇通|huitongkuaidi");
companyList.push("E邮宝|ems");
companyList.push("UPS|ups");
companyList.push("顺丰|shunfeng");
companyList.push("韵达|yunda");
companyList.push("天天|tiantian");
companyList.push("宅急送|zhaijisong");
companyList.push("邮政包裹|youzhengguonei"); companyList.push("AAE|aae");
companyList.push("安信达|anxindakuaixi");
companyList.push("BHT|bht");
companyList.push("百福东方|aae");
companyList.push("包裹/平邮/挂号信|youzhengguonei");
companyList.push("COE|coe");
companyList.push("CCES(希伊艾斯)|cces");
companyList.push("DHL|dhl");
companyList.push("大田|datianwuliu");
companyList.push("德邦|debangwuliu");
companyList.push("D速|dsukuaidi");
companyList.push("递四方|disifang");
companyList.push("飞康达|feikangda");
companyList.push("FedEx(国际)|fedex");
companyList.push("凡客|rufengda");
companyList.push("能达速递|ganzhongnengda");
companyList.push("挂号信|youzhengguonei");
companyList.push("共速达|gongsuda");
companyList.push("京广|jinguangsudikuaijian");
companyList.push("佳吉|jiajiwuliu");
companyList.push("佳怡|jiayiwuliu");
companyList.push("急先达|jixianda");
companyList.push("龙邦|longbanwuliu");
companyList.push("联昊通|lianhaowuliu");
companyList.push("联邦快递(国内)|lianbangkuaidi");
companyList.push("全一|quanyikuaidi");
companyList.push("全晨|quanchenkuaidi");
companyList.push("全日通|quanritongkuaidi");
companyList.push("全峰|quanfengkuaidi");
companyList.push("速尔|suer");
companyList.push("盛辉|shenghuiwuliu");
companyList.push("申通E物流|shentong");
companyList.push("穗佳物流|suijiawuliu");
companyList.push("TNT|tnt");
companyList.push("天地华宇|tiandihuayu");
companyList.push("特快专递|ems");
companyList.push("新邦|xinbangwuliu");
companyList.push("信丰|xinfengwuliu");
companyList.push("鑫飞鸿|xinhongyukuaidi");
companyList.push("星晨急便|xingchengjibian");
companyList.push("优速|youshuwuliu");
companyList.push("运通|yuntongkuaidi");
companyList.push("源伟丰|yuanweifeng");
companyList.push("远成|yuanchengwuliu");
companyList.push("越丰|yuefengwuliu");
companyList.push("亚风|yafengsudi");
companyList.push("元智捷诚|yuanzhijiecheng");
companyList.push("邮政国内包裹|youzhengguonei");
companyList.push("邮政国际包裹|youzhengguoji");
companyList.push("中铁快运|zhongtiewuliu");
companyList.push("中邮物流|zhongyouwuliu");
var companyCode = "";
var flag = false;
for (var i = ; i < companyList.length; i++) {
var values = companyList[i].split("|");
var companyNames = values[].split("/");
for (var j = ; j < companyNames.length; j++) {
if (companyNames[j].indexOf(name) >= ) {
flag = true;
companyCode = values[];
break;
}
}
if (flag) {
break;
}
}
return companyCode;
} function getResult() {
var url = strUrl + "?type=" + typeValue + "&postid=" + postIdValue + "&id=" + gQueryType;
if (window.XMLHttpRequest) {
req = new XMLHttpRequest()
} else if (window.ActiveXObject) {
req = new ActiveXObject("Microsoft.XMLHTTP")
}
if (req) {
req.open("GET", url, true);
req.onreadystatechange = complete;
req.send(null);
}
} function complete() {
if (req.readyState == ) {
if (req.status == ) {
if (!havereturn) {
var resultcontext = req.responseText;
var json = eval("(" + resultcontext + ")");
statuscode = json.status;
gIsCheck = ;
if (json.status == ) { //如果查询成功 20121011
gIsCheck = json.ischeck;
returnjson = json; returnjson_up = [];
returnjson_down = [];
for (var i in json.data) {
returnjson_up[i] = json.data[i];
returnjson_down[i] = json.data[i];
} for (var i = ; i < returnjson_down.length / ; i++) {
var tmp = returnjson_down[i];
returnjson_down[i] = returnjson_down[returnjson_down.length - i - ];
returnjson_down[returnjson_down.length - i - ] = tmp;
}
$("showcontext").style.display = "block";
var data = json.data;
totalcount = data.length;
currentpage = ;
fenye(currentpage);
} else {
$("errordiv").style.display = "block";
$("errorMessage").innerHTML = "此单号无记录,请核对快递公司名称和运单号码是否正确!";
}
//refreshcode();
}
}
}
} //排序
function sortToggle() {
if (gSortStatus == ) {
gSortStatus = ;
sortup();
} else {
gSortStatus = ;
sortdown();
}
} function sortup() {
var table = $("showtablecontext");
while (table.rows.length > ) {
table.deleteRow();
}
returnjson.data = returnjson_up;
$("b-down").className = "b-down";
$("b-up").className = "b-up b-up-active";
fenye();
} function sortdown() {
var table = $("showtablecontext");
while (table.rows.length > ) {
table.deleteRow();
}
returnjson.data = returnjson_down;
$("b-down").className = "b-down b-down-active";
$("b-up").className = "b-up";
fenye();
} function fenye(currentpage) {
var json = returnjson;
if (json == null) {
return;
}
var data = json.data;
var obj = json;
var pagecount = ;
var pagesize = ;
if (isvalide) pagesize = ;
var totalcount = data.length;
if ((totalcount % pagesize) == ) {
pagecount = parseInt(totalcount / pagesize);
} else {
pagecount = parseInt(totalcount / pagesize) + ;
}
var data = json.data;
var height_table = ;
var table = $("showtablecontext"); while (table.rows.length > ) {
table.deleteRow();
}
for (var i = (currentpage - ) * pagesize; i < currentpage * pagesize; i++) {
if (i > (totalcount - )) break;
if (isvalide) height_table = ;
if ((height_table + table.clientHeight) > ) {
$("fenye").style.display = "block";
break;
}
var newTr = table.insertRow(-);
var newTd0 = newTr.insertCell(-);
var newTd1 = newTr.insertCell(-);
newTd0.innerHTML = data[i].time;
newTd1.innerHTML = data[i].context;
var strlength = ;
if (newTr.clientHeight > ) {
if (data[i].context.length > strlength) {
newTd1.innerHTML = data[i].context;
newTd1.innerHTML = newTd1.innerHTML.substring(, strlength) + "...";
strlength = strlength - ;
newTd1.title = data[i].context;
}
}
if (gSortStatus == && i == ) {
newTd0.className = "nobg c-g-a fontorange";
newTd1.className = "nobg c-g-b fontorange";
newTd1.innerHTML += '<span class="lastTag"></span>';
} else if (gSortStatus == && i == totalcount - ) {
newTd0.className = "nobg c-g-a fontorange";
newTd1.className = "nobg c-g-b fontorange";
newTd1.innerHTML += '<span class="lastTag"></span>';
} else {
newTd0.className = "nobg c-g-a";
newTd1.className = "nobg c-g-b";
}
if ((height_table + table.clientHeight) > ) {
table.deleteRow();
break;
}
}
var sbufferContext = "";
if (pagecount == ) {
$("fenye").innerHTML = sbufferContext;
$("fenye").style.display = "block";
return;
} else {
$("fenye").style.display = "block";
}
var list = "";
if (pagecount <= ) {
for (var i = ; i <= pagecount; i++) {
if (i == currentpage) {
list += "<a href='javascript:void(0)' class='divpaging-a-number2' >" + i + "</a>";
} else {
list += "<a href='javascript:void(0)' class='divpaging-a-number1' onclick='fenye(" + i + ")'>" + i + "</a>";
}
}
} else if (pagecount > ) {
if (currentpage <= ) {
for (var i = ; i <= ; i++) {
if (i == currentpage) {
list += "<a href='javascript:void(0)' class='divpaging-a-number2' >" + i + "</a>";
} else {
list += "<a href='javascript:void(0)' class='divpaging-a-number1' onclick='fenye(" + i + ")'>" + i + "</a>";
}
}
list += "<span class='divpaging-span2'>...</span>";
list += "<a href='javascript:void(0)' class='divpaging-a-number1' onclick='fenye(" + pagecount + ")' >" + pagecount + "</a>";
} else if (currentpage <= pagecount - ) {
list += "<a href='javascript:void(0)' class='divpaging-a-number1' onclick='fenye(1)' >1</a>";
list += "<span class='divpaging-span2'>...</span>";
for (var i = currentpage - ; i <= currentpage + ; i++) {
if (i == currentpage) {
list += "<a href='javascript:void(0)' class='divpaging-a-number2' >" + i + "</a>";
} else {
list += "<a href='javascript:void(0)' class='divpaging-a-number1' onclick='fenye(" + i + ")'>" + i + "</a>";
}
}
list += "<span class='divpaging-span2'>...</span>";
list += "<a href='javascript:void(0)' class='divpaging-a-number1' onclick='fenye(" + pagecount + ")' >" + pagecount + "</a>";
} else if (currentpage > pagecount - ) {
list += "<a href='javascript:void(0)' class='divpaging-a-number1' onclick='fenye(1)' >1</a>";
list += "<span class='divpaging-span2'>...</span>";
for (var i = pagecount - ; i <= pagecount; i++) {
if (i == currentpage) {
list += "<a href='javascript:void(0)' class='divpaging-a-number2' >" + i + "</a>";
} else {
list += "<a href='javascript:void(0)' class='divpaging-a-number1' onclick='fenye(" + i + ")'>" + i + "</a>";
}
}
}
}
$("fenye").innerHTML = list.toString();
}
</script> <style type="text/css"> body
{
background: #ffffff;
}
*
{
margin: 0px;
padding: 0px;
} .round_gray_new { padding:0px 0px 0px 10px; clear:both; width:514px }
.xboxcontent_a { display:block; background:#FFFAE2; border:0px solid #F5E190; border-width:0px 1px; padding:8px 15px }
.xboxcontent_a p { margin:0px; padding:0px; line-height:30px; font-size:14px; font-weight:bold; color:#F00 }
.xboxcontent_a dt { line-height:30px }
.xboxcontent_a dd { line-height:20px; font-family:"瀹嬩綋"; }
.xboxcontent_a a { color:#0A8ECE; font-weight:bold } .divpaging
{
font-size: 12px;
line-height: 16px;
text-align: center;
vertical-align: middle;
margin: 5px 0px 0px 10px;
}
.divpaging a
{
float: left;
}
.divpaging span
{
float: left;
}
.divpaging .divpaging-a-number1
{
border: #cee3f2 1px solid;
padding: 1px 6px 1px 6px;
color: #2477b3;
margin: 2px 1px 2px 2px;
}
.divpaging .divpaging-a-number1:hover
{
border: #fd6d01 1px solid;
padding: 1px 6px 1px 6px;
color: #fd6d01;
margin: 2px 1px 2px 2px;
}
.divpaging .divpaging-a-number2
{
border: none;
padding: 2px 7px 2px 7px;
color: #e63922;
margin: 2px 1px 2px 2px;
font-weight: bold;
}
.divpaging .divpaging-a-number3
{
border: #2477b3 1px solid;
background: #2477b3;
padding: 1px 6px 1px 6px;
color: #ffffff;
margin: 2px 1px 2px 2px;
}
.divpaging .divpaging-a-number3:hover
{
border: #fd6d01 1px solid;
background: #ffffff;
padding: 1px 6px 1px 6px;
color: #fd6d01;
margin: 2px 1px 2px 2px;
}
.divpaging .divpaging-a-button
{
border: #cee3f2 1px solid;
padding: 1px 6px 1px 6px;
color: #2477b3;
margin: 2px 1px 2px 2px;
}
.divpaging .divpaging-a-button:hover
{
border: #fd6d01 1px solid;
padding: 1px 6px 1px 6px;
color: #fd6d01;
margin: 2px 1px 2px 2px;
}
.divpaging .divpaging-span1
{
border: #c0c7cc 1px solid;
padding: 1px 6px 1px 6px;
color: #c0c7cc;
margin: 2px 1px 2px 2px;
}
.divpaging .divpaging-span2
{
border: none;
padding: 2px 6px 2px 6px;
margin: 2px 1px 2px 2px;
}
.divpaging .divpaging-span3
{
border: none;
padding: 2px 0px 2px 10px;
color: #c0c7cc;
margin: 2px 1px 2px 2px;
}
.divpaging .divpaging-span4
{
border: none;
padding: 2px 6px 2px 0px;
color: #c0c7cc;
margin: 2px 1px 2px 2px;
}
.divpaging .divpaging-input1
{
float: left;
border: #cee3f2 1px solid;
width: 32px;
height: 18px;
margin: 2px;
text-align: center;
color: #2477b3;
font-size: 12px;
}
.kd-result-new
{
padding: 10px;
float: left;
width: 514px;
}
#showtablecontext
{
background: #ffffff;
}
#showtablecontext .b-btn
{
float: right;
position: relative;
}
#showtablecontext b
{
font-size: ;
height: ;
line-height: ;
overflow: hidden;
position: absolute;
width: ;
}
#showtablecontext .b-up
{
border-color: transparent transparent #C9C4CA;
border-style: dashed dashed solid;
border-width: 4px;
border-width: 5px \;
right: 5px;
right: 4px \;
top: 4px;
top: 1px \;
}
#showtablecontext .b-down
{
border-color: #C9C4CA transparent transparent;
border-style: solid dashed dashed;
border-width: 4px;
right: 5px;
top: 17px;
top: 15px \;
}
#showtablecontext .b-up-active
{
border-color: transparent transparent #FFFFFF;
}
.bluebg
{
background: #64AADB;
border: #75C2EF 1px solid;
height: 28px;
line-height: 28px;
color: #FFFFFF;
font-weight: bold;
text-indent: 15px;
}
.nobg
{
border: 1px solid #DDDDDD;
font-size: 12px;
line-height: 22px;
padding: 3px 5px;
vertical-align: top;
}
.fontorange
{
color: #FF6600;
}
.lastTag
{
margin-left: 5px;
display: inline-block;
width: 22px;
height: 9px;
background: url("http://cdn.kuaidi100.com/images/frame/baidu/synastry_pics.gif") -251px -49px no-repeat;
vertical-align: top;
}
</style>
<body>
<div class="round_gray_new" id="errordiv" style="display: none; clear: both;">
<b class="xtop"><b class="xb1a"></b><b class="xb2a"></b><b class="xb3a"></b><b class="xb4a">
</b></b>
<div class="xboxcontent_a">
<p style="line-height: 25px; margin: 0px; padding: 0px;">
<font id="errorMessage">您输入的验证码错误,请重新输入!</font></p>
</div>
<b class="xbottom"><b class="xb4a"></b><b class="xb3a"></b><b class="xb2a"></b><b
class="xb1a"></b></b>
</div>
<div class="kd-result-new" id="showcontext" style="display: none;">
<table width="" border="" cellspacing="" cellpadding="" id="showtablecontext">
<tr>
<td width="27%" class="bluebg" onclick="sortToggle()" style="cursor: pointer">
<span class="b-btn"><b class="b-up b-up-active" id="b-up"></b><b class="b-down" id="b-down">
</b></span>时间
</td>
<td width="73%" class="bluebg">
地点和跟踪进度
</td>
</tr>
</table>
<div class="divpaging" id="fenye">
</div>
</div>
</body>
</html>
您输入的验证码错误,请重新输入!
时间 | 地点和跟踪进度 |