ajax实现快递单号查询-程序员宅基地

技术标签: ViewUI  php  json  javascript  

效果:(代码写的有点乱,自行修改就可以了)

  

源码:

  index.php

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>中通快递单号查询</title>
    <style type="text/css">
        *{
     
            margin: 0;
            padding: 0;
        }
        body{
     
            color: #333;;
        }
        .clearfix:after{
     
            content: "";
            display: block;
            clear: both;
            height: 0;
            line-height: 0;
            visibility: hidden;
        }
        .clearfix{
     
            zoom: 1;//兼容ie浏览器
        }
        .zt{
     
            width: 540px;
            margin: 20px auto;
        }
        a{
     
            font-weight: normal;
        }
        .title a{
     
            padding-left: 20px;
            background: url("img/small.jpg") no-repeat left center;
        }
        .title em{
     
            font-style: normal;
            color: #c00;
            text-decoration: underline;
        }
        .title{
     
            font-size: 16px;
        }
        .zt .box{
     
            width: 528px;
            padding: 5px;
            margin-top: 5px;
            border: 1px solid #e3e3e3;
        }
        .box .op_delivery_container{
     
            width: 508px;
            padding: 10px;
            background-color: #FAFAFA;
        }
        .op_delivery_container .bottom{
     
            margin-top: 10px;
            position: relative;
        }
        .box .op_delivery_container span{
     
            font-size: 14px;
            margin-right: 10px;
        }
        .box .op_delivery_container input{
     
            display: inline-block;
            width: 178px;
            padding: 0 4px;
            height: 24px;
            font-size: 13px;
            border: 1px solid #999;
            border-bottom-color: #d8d8d8;
            border-right-color: #d8d8d8;
            outline: 0;
            vertical-align: top;
        }
        .box .op_delivery_container button{
     
            display: inline-block;
            background-color: #388bff;
            border-color: #3c8dff #408ffe #3680e6;
            padding: 0 4px;
            height: 24px;
            font-size: 13px;
            color: #fff;
            vertical-align: top;
        }
        .box .info{
     
            display: none;
            position: relative;
            border: 1px solid #f5f5f5;
            border-right: none;
            border-left: none;
        }
        .info .content{
     
            overflow: hidden;
            height: 280px;
            font-size: 12px;
            position: relative;
        }
        .content .content-inner{
     
            position: absolute;
            top: 0;
            left: 0;
        }
        .content li{
     
            list-style: none;
            border-bottom: 1px solid #f5f5f5;
            width: 510px;
            overflow: hidden;

        }
        .content li .delivery-title{
     
            padding: 10px;
            margin-left: 15px;
            float: left;
            border-left: solid 2px #ececec;
        }
        .content li .timeline-circle{
     
            width: 55px;
            height: 32px;
            float: left;
            position: relative;
            left: -19px;
            top: -10px;
        }
        .content li:nth-of-type(1) .timeline-circle{
     
            background-color: #fff;
        }
        .content li .timeline-circle .new{
     
            display: inline-block;
            padding: 2px;
            text-align: center;
            vertical-align: text-bottom;
            font-size: 12px;
            line-height: 100%;
            font-style: normal;
            font-weight: 400;
            color: #fff;
            overflow: hidden;
            background-color: red;
            margin-top: 10px;
            position: absolute;
            left: 20px;
            top: 5px;
        }
        .content li .timeline-circle .circle{
     
            display: inline-block;
            width: 14px;
            height: 14px;
            background: url("img/dout.png") no-repeat right center;
            position: absolute;
            top: 16px;
        }
        .content li:nth-of-type(1) .timeline-circle .circle{
     
            background-position: left center;
            left: 1px;
        }
        .content li:nth-of-type(1){
     
            color: #f54040;
            font-weight: 700;
        }
        .content li .delivery-info{
     
            width: 400px;
            word-break: normal;
            float: left;
            margin-left: -10px;
        }
        .info .scroll-ctr{
     
            width: 7px;
            height: 278px;
            border: 1px solid #e1e1e1;
            background-color: #F2F2F2;
            position: absolute;
            top: 0;
            right: 0;
        }
        .info .scroll-ctr .scroll-inner{
     
            width: 7px;
            height: 130px;
            border: 1px solid #e1e1e1;
            position: absolute;
            left: 0;
            top: 0;
            margin-left: -1px;
            background-color: #fff;
            margin-top: -1px;
        }
        .box .footer{
     
            height: 120px;
            padding-top: 8px;
        }
        .footer .logo{
     
            float: left;
            margin-right: 10px;
        }
        .footer .contact{
     
            float: left;
        }
        .footer .contact p{
     
            font-size: 14px;
            height: 20px;
            line-height: 20px;
            margin-bottom: 5px;
        }
        .footer .contact .link a{
     
            display: inline-block;
            text-decoration: none;
            color: #000;
            padding: 1px 4px;
            margin-right: 15px;
            border: 1px solid #CCCCCC;
            background-color: #F9F9F9;
        }
        .footer-delivery{
     
            float: right;
        }
        .footer-delivery a{
     
            color: #999;
            text-decoration: none;
            font-size: 12px;
            padding-left: 65px;
            background: url("img/mid.jpg") no-repeat left center;
        }
    </style>
</head>
<body>
<div class="zt">
    <h3 class="title">
        <a href="https://www.baidu.com/link?url=badDTxMAZ290Zuwss4KmHgpBa7suA-kxnLB6BuzIvWNdCkRclI1-Tmc7_vmSOGvG&wd=&eqid=ef03cde100041a4c000000065c6cafdb">
            <em>中通快递</em>-<em>快递单号查询</em>
        </a>
    </h3>
    <div class="box">
        <div class="op_delivery_container">
            <div class="c-row">
                <span class="op_name">公司名称</span>
                中通快递
            </div>
            <div class="c-row bottom">
                <span class="op_name">
                    <span class="op_name">快递单号</span>
                    <input type="text" name="code" id="code"><button type="button" id="btn">查询</button>
                </span>
            </div>
        </div>
        <div class="info" id="info"></div>
        <div class="footer">
            <div class="footer-content  clearfix">
                <div class="logo">
                    <img src="img/big.jpg" alt="">
                </div>
                <div class="contact">
                    <p><strong>中通快递</strong></p>
                    <p>官网地址:<a href="www.zto.com">www.zto.com</a></p>
                    <p>客服电话:95311</p>
                    <p class="link"><a href="#">网点查询</a><a href="#">在线寄件</a><a href="#">价格查询</a><a href="#">中通优选</a></p>
                </div>
            </div>
            <div class="footer-delivery">
                <a href="#">数据来源中通速递</a>
            </div>
        </div>
    </div>
</div>
<script type="text/javascript">
    /*ajax获取信息*/
    var btn = document.getElementById("btn");
    btn.onclick = function (ev) {
        document.getElementById("info").style.display = "block";
        var xhr = null;
        if (window.XMLHttpRequest){
            xhr = new XMLHttpRequest();
        } else {
            xhr = new ActiveXObject("Microsoft.XMLHTTP");
        }
        var code = document.getElementById("code").value;
        xhr.open("GET","zt.php?code="+code,true);
        xhr.send(null);
        xhr.onreadystatechange = function () {
            if (xhr.readyState == 4 && xhr.status == 200){
                var data = JSON.parse(xhr.responseText);
                var status = data.status;
                if(status == "-2"){
                    document.getElementById("info").innerHTML = '<div style="color: red;">'+data.msg+'</div>';
                }else if (status == "0"){
                    var data = data.data.info.context;
                    var str = "";
                    str += '<div class="content">';
                        str += '<ul class="content-inner" id="content_inner">';
                        for(var i = 0;i<data.length;i++){
                            str += '<li>';
                                str += '<div class="delivery-title">';
                                    str += '<div class="timeline-circle">';
                                        str += '<i class="circle"></i>';
                                    str += '</div>';
                                    str += '<div class="delivery-info">';
                                        str += formTime(data[i].time)+'<br>'+data[i].desc;
                                    str += '</div>';
                                str += '</div>';
                            str += '</li>';
                        }
                                str += '</ul>';
                            str += '</div>';
                            str += '<div class="scroll-ctr">';
                                str += '<div class="scroll-inner" id="scroll_inner"></div>';
                            str += '</div>';
                            document.getElementById("info").innerHTML = str;
                            var i = document.createElement("i");
                            i.setAttribute("class","new");
                            i.innerHTML = "最新";
                            var content_inner = document.getElementById("content_inner");
                            content_inner.firstChild.firstChild.firstChild.appendChild(i);
                            scroll();
                }
            }
        }
    }
    function formTime(num) {
        var time = num +"000";
        var date = new Date();
        date.setTime(time);
        return date.getFullYear()+''+(date.getMonth()+1)+''+date.getDay()+''+(date.getHours()>12?' 下午':' 上午')+date.getHours()%12+':'+date.getMinutes()+':'+date.getSeconds();
    }
    function scroll() {
        /*滚动控制*/
        var info = document.getElementById("info");
        var content_innerH = document.getElementById("content_inner").offsetHeight;
        var y = 0;//滚动条的滚动距离
        var m = 0;//滚动内容的滚动距离
        info.onmouseover = function (ev) {
            ev.preventDefault();
            ev.stopPropagation();
            window.onmousewheel = function (event) {
                var event = event || window.event;
                if(event.wheelDelta<0){
                    y += 10;
                    m -= ((content_innerH-280)*10)/(280-130);
                }else if(event.wheelDelta>0){
                    y -= 10;
                    m += ((content_innerH-280)*10)/(280-130);
                }
                if(y<=0){
                    y = 0;
                    m = 0;
                }
                if(y>=149){
                    y = 149;
                    m = 280-content_innerH;
                }
                document.getElementById("scroll_inner").style.top = y+"px";
                document.getElementById("content_inner").style.top = m+"px";
            }
        }
        info.onmouseout = function (ev) {
            window.onmousewheel = null;
        }
    }
</script>
</body>
</html>

zt.php

<?php
    $code = $_GET['code'];
    $data = '{"msg":"","status":"0","data":{"info":{"status":"1","com":"ems","state":"3","context":[{"time":"1450252800","desc":"\u3010\u9f99\u9526\u82d1\u6295\u9012\u7ec4\u3011 \u5df2\u7b7e\u6536,\u4ed6\u4eba\u6536[\u9f99\u9526\u82d1\u6295\u9012\u7ec4]"},{"time":"1450172897","desc":"\u3010\u9f99\u9526\u82d1\u6295\u9012\u7ec4\u3011 \u9884\u7ea62015.12.16\u518d\u6295[\u9f99\u9526\u82d1\u6295\u9012\u7ec4]"},{"time":"1450153979","desc":"\u3010\u9f99\u9526\u82d1\u6295\u9012\u7ec4\u3011 [\u9f99\u9526\u82d1\u6295\u9012\u7ec410220812]\u6b63\u5728\u6295\u9012"},{"time":"1450088166","desc":"\u3010\u9f99\u9526\u82d1\u6295\u9012\u7ec4\u3011 \u9884\u7ea62015.12.15\u518d\u6295[\u9f99\u9526\u82d1\u6295\u9012\u7ec4]"},{"time":"1450062684","desc":"\u3010\u9f99\u9526\u82d1\u6295\u9012\u7ec4\u3011 [\u9f99\u9526\u82d1\u6295\u9012\u7ec410220812]\u6b63\u5728\u6295\u9012"},{"time":"1450000825","desc":"\u3010\u9f99\u9526\u82d1\u6295\u9012\u7ec4\u3011 \u5230\u8fbe[\u9f99\u9526\u82d1\u6295\u9012\u7ec410220812]"},{"time":"1449887960","desc":"\u3010\u5929\u901a\u897f\u82d1\u6295\u9012\u7ec4\u3011 \u8f6c\u4ed6\u5c40\u5904\u7406,\u539f\u56e0:\u975e\u672c\u7ad9\u8bd5\u4ed6\u5c40[\u5929\u901a\u897f\u82d1\u6295\u9012\u7ec4]"},{"time":"1449886219","desc":"\u3010\u5929\u901a\u897f\u82d1\u6295\u9012\u7ec4\u3011 [\u5929\u901a\u897f\u82d1\u6295\u9012\u7ec410221806]\u6b63\u5728\u6295\u9012"},{"time":"1449871677","desc":"\u3010\u5929\u901a\u897f\u82d1\u6295\u9012\u7ec4\u3011 \u5230\u8fbe[\u5929\u901a\u897f\u82d1\u6295\u9012\u7ec410221806]"},{"time":"1449866125","desc":"\u3010\u5317\u4eac\u3011 \u79bb\u5f00[\u5317\u4eac10000000]\uff0c\u4e0b\u4e00\u7ad9\u662f[\u4eac\u5929\u901a\u897f],\u603b\u5305[5602],\u90ae\u8def[\u6c99\u6cb3-J1]"},{"time":"1449838500","desc":"\u3010\u5317\u4eac\u5e02\u3011 [\u5317\u4eac\u5e0210000000]\u5df2\u7ecf\u5c01\u53d1,\u603b\u5305[5602]"},{"time":"1449827400","desc":"\u3010\u4e9a\u8fd0\u6751\u90ae\u5c40\u5927\u5b97\u4e8c\u7ec4\u3011 \u79bb\u5f00[\u4e9a\u8fd0\u6751\u90ae\u5c40\u5927\u5b97\u4e8c\u7ec410010120]\uff0c\u4e0b\u4e00\u7ad9\u662f[\u5317\u4eac\u5e02],\u603b\u5305[5434],\u90ae\u8def[\u5546\u51fd-\u5c0f\u5305\u51fa\u53e3]"},{"time":"1449820658","desc":"\u3010\u4e9a\u8fd0\u6751\u90ae\u5c40\u5927\u5b97\u4e8c\u7ec4\u3011 [\u5317\u4eac\u5e02\u4e9a\u8fd0\u6751\u90ae\u5c40\u5927\u5b97\u4e8c\u7ec410010120]\u5df2\u7ecf\u6536\u5bc4"}],"_source_com":""},"com":"ems","company":{"url":"http:\/\/www.kuaidi100.com\/all\/ems.shtml?from=openv","fullname":"EMS","shortname":"EMS","icon":{"id":"2","smallurl":"https:\/\/ss2.baidu.com\/6ONYsjip0QIZ8tyhnq\/it\/u=1807529516,3291075151&fm=58","smallpos":"0,944","middleurl":"https:\/\/ss1.baidu.com\/6ONXsjip0QIZ8tyhnq\/it\/u=1835223070,3312272045&fm=58","middlepos":"0,828","normal":"https:\/\/ss1.baidu.com\/6ONXsjip0QIZ8tyhnq\/it\/u=295567570,1377797753&fm=58"},"website":{"title":"www.ems.com.cn","url":"http:\/\/www.ems.com.cn\/"},"tel":"11183","auxiliary":[{"title":"\u7f51\u70b9\u67e5\u8be2","url":"http:\/\/www.ems.com.cn\/serviceguide\/tong_da_fan_wei.html"},{"title":"\u7f51\u4e0a\u5bc4\u4ef6","url":"http:\/\/www.ems.com.cn\/serviceguide\/zifeichaxun\/zi_fei_biao_zhun.html"}]},"source":{"logo":"https:\/\/ss2.baidu.com\/6ONYsjip0QIZ8tyhnq\/it\/u=1429564979,1787167512&fm=58","title":"\u6570\u636e\u6765\u81ea\u5feb\u9012100","url":"http:\/\/www.kuaidi100.com\/","name":"\u5feb\u9012100"}}}';
    if($code == '9971121346085'){
        echo $data;
    }else{
        echo '{"msg":" 该单号暂无物流进展,请稍后再试,或检查公司和单号是否有误","status":"-2"}';
    }

?>

图片:(4个)

                                               

转载于:https://www.cnblogs.com/alex-xxc/p/10410718.html

版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://blog.csdn.net/dengluandai1740/article/details/101239162

智能推荐

2024最新计算机毕业设计选题大全-程序员宅基地

文章浏览阅读1.6k次,点赞12次,收藏7次。大家好!大四的同学们毕业设计即将开始了,你们做好准备了吗?学长给大家精心整理了最新的计算机毕业设计选题,希望能为你们提供帮助。如果在选题过程中有任何疑问,都可以随时问我,我会尽力帮助大家。在选择毕业设计选题时,有几个要点需要考虑。首先,选题应与计算机专业密切相关,并且符合当前行业的发展趋势。选择与专业紧密结合的选题,可以使你们更好地运用所学知识,并为未来的职业发展奠定基础。要考虑选题的实际可行性和创新性。选题应具备一定的实践意义和应用前景,能够解决实际问题或改善现有技术。

dcn网络与公网_电信运营商DCN网络的演变与规划方法(The evolution and plan method of DCN)...-程序员宅基地

文章浏览阅读3.4k次。摘要:随着电信业务的发展和电信企业经营方式的转变,DCN网络的定位发生了重大的演变。本文基于这种变化,重点讨论DCN网络的规划方法和运维管理方法。Digest: With the development oftelecommunication bussiness and the change of management of telecomcarrier , DCN’s role will cha..._电信dcn

动手深度学习矩阵求导_向量变元是什么-程序员宅基地

文章浏览阅读442次。深度学习一部分矩阵求导知识的搬运总结_向量变元是什么

月薪已炒到15w?真心建议大家冲一冲数据新兴领域,人才缺口极大!-程序员宅基地

文章浏览阅读8次。近期,裁员的公司越来越多今天想和大家聊聊职场人的新出路。作为席卷全球的新概念ESG已然成为当前各个行业关注的最热风口目前,国内官方发布了一项ESG新证书含金量五颗星、中文ESG证书、完整ESG考试体系、名师主讲...而ESG又是与人力资源直接相关甚至在行业圈内成为大佬们的热门话题...当前行业下行,裁员的公司也越来越多大家还是冲一冲这个新兴领域01 ESG为什么重要?在双碳的大背景下,ESG已然成...

对比传统运营模式,为什么越拉越多的企业选择上云?_系统上云的前后对比-程序员宅基地

文章浏览阅读356次。云计算快速渗透到众多的行业,使中小企业受益于技术变革。最近微软SMB的一项研究发现,到今年年底,78%的中小企业将以某种方式使用云。企业希望投入少、收益高,来取得更大的发展机会。云计算将中小企业信息化的成本大幅降低,它们不必再建本地互联网基础设施,节省时间和资金,降低了企业经营风险。科技创新已成时代的潮流,中小企业上云是创新前提。云平台稳定、安全、便捷的IT环境,提升企业经营效率的同时,也为企业..._系统上云的前后对比

esxi网卡直通后虚拟机无网_esxi虚拟机无法联网-程序员宅基地

文章浏览阅读899次。出现选网卡的时候无法选中,这里应该是一个bug。3.保存退出,重启虚拟机即可。1.先随便选择一个网卡。2.勾先取消再重新勾选。_esxi虚拟机无法联网

随便推点

在LaTeX中使用.bib文件统一管理参考文献_egbib-程序员宅基地

文章浏览阅读913次。在LaTeX中,可在.tex文件的同一级目录下创建egbib.bib文件,所有的参考文件信息可以统一写在egbib.bib文件中,然后在.tex文件的\end{document}前加入如下几行代码:{\small\bibliographystyle{IEEEtran}\bibliography{egbib}}即可在文章中用~\cite{}宏命令便捷的插入文内引用,且文章的Reference部分会自动排序、编号。..._egbib

Unity Shader - Predefined Shader preprocessor macros 着色器预处理宏-程序员宅基地

文章浏览阅读950次。目录:Unity Shader - 知识点目录(先占位,后续持续更新)原文:Predefined Shader preprocessor macros版本:2019.1Predefined Shader preprocessor macros着色器预处理宏Unity 编译 shader programs 期间的一些预处理宏。(本篇的宏介绍随便看看就好,要想深入了解,还是直接看Unity...

大数据平台,从“治理”数据谈起-程序员宅基地

文章浏览阅读195次。本文目录:一、大数据时代还需要数据治理吗?二、如何面向用户开展大数据治理?三、面向用户的自服务大数据治理架构四、总结一、大数据时代还需要数据治理吗?数据平台发展过程中随处可见的数据问题大数据不是凭空而来,1981年第一个数据仓库诞生,到现在已经有了近40年的历史,相对数据仓库来说我还是个年轻人。而国内企业数据平台的建设大概从90年代末就开始了,从第一代架构出现到..._数据治理从0搭建

大学抢课python脚本_用彪悍的Python写了一个自动选课的脚本 | 学步园-程序员宅基地

文章浏览阅读2.2k次,点赞4次,收藏12次。高手请一笑而过。物理实验课别人已经做过3、4个了,自己一个还没做呢。不是咱不想做,而是咱不想起那么早,并且仅有的一次起得早,但是哈工大的服务器竟然超负荷,不停刷新还是不行,不禁感慨这才是真正的“万马争过独木桥“啊!服务器不给力啊……好了,废话少说。其实,我的想法很简单。写一个三重循环,不停地提交,直到所有的数据都accepted。其中最关键的是提交最后一个页面,因为提交用户名和密码后不需要再访问其..._哈尔滨工业大学抢课脚本

english_html_study english html-程序员宅基地

文章浏览阅读4.9k次。一些别人收集的英文站点 http://www.lifeinchina.cn (nice) http://www.huaren.us/ (nice) http://www.hindu.com (okay) http://www.italki.com www.talkdatalk.com (transfer)http://www.en8848.com.cn/yingyu/index._study english html

Cortex-M3双堆栈MSP和PSP_stm32 msp psp-程序员宅基地

文章浏览阅读5.5k次,点赞19次,收藏78次。什么是栈?在谈M3堆栈之前我们先回忆一下数据结构中的栈。栈是一种先进后出的数据结构(类似于枪支的弹夹,先放入的子弹最后打出,后放入的子弹先打出)。M3内核的堆栈也不例外,也是先进后出的。栈的作用?局部变量内存的开销,函数的调用都离不开栈。了解了栈的概念和基本作用后我们来看M3的双堆栈栈cortex-M3内核使用了双堆栈,即MSP和PSP,这极大的方便了OS的设计。MSP的含义是Main..._stm32 msp psp

推荐文章

热门文章

相关标签