html5代码

<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="renderer" content="webkit|ie-comp|ie-stand"/>
    <title>接口测试</title>
    <style type="text/css">
        .body{
            width: 1100px;
            height: 1000px;
            margin: 0 auto;
        }
        .body span {
            display: block;
            width: 100px;
            height: 80px;
            margin: 0 auto;
            color: red;
        }
        .b{
            float: left;
            height: 400px;
        }
        .b input {
           margin: 338px 0;
        }
        .a{float:left; width: 500px; height: 700px;border: 1px solid #000; margin: 0 auto;}
        textarea{
            margin: 6px 0 0 28px;
        }
        .input{
            width: 365px;
            height: 25px;
            margin-bottom: 4px;
        }
    </style>
    <script type="text/javascript" src="js/jquery-1.11.3.js"></script>
</head>
<body background = "img/04.jpg">
    <div class="body">
        <span>文件上传</span>
        <div>
            <input type="file" name="file" id="fileId">
            <button type="submit" name="btn" value="提交" id="btnId" onclick="check()"/> 提交
        </div>
        <span>接口测试</span>
        <div class="a">
            <div>
                <label>税务机关代码:</label>
                <input type="text" value="" id="swjg_dm" class="input"/>
            </div>
            <div>
                <label>税务人员代码:</label>
                <input type="text" value="" id="swry_dm" class="input"/>
            </div>
            <div>
                <font color = "red">*</font>Service&nbsp&nbsp&nbsp&nbsp名:
                <input type="text" value="" id="ser_id" class="input"/>
                <lable><font color = "red">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;例如:SWZJ.HXZG.DJ.ZRRJJDJ</font></lable>
            </div>
            <div>
                <font color = "red">*</font>接口请求报文:
                <textarea name="" id="req_text" cols="60" rows="34"></textarea>
            </div>
        </div>
        <div class="b">
            <input type="submit" value="测试" id="test"/>
        </div>
        <div class="a">
            <p style="padding-top:67px">接口返回报文:</p>
            <textarea style="margin-top: 32px"  name="" id="res_text" cols="60" rows="34"></textarea>
        </div>
    </div>
    <script>
        $("#test").click(function(){
            var swjg_dm = $.trim($("#swjg_dm").val());
            var swry_dm = $.trim($("#swry_dm").val());
            var req_text = $.trim($("#req_text").val());
            var ser_id = $.trim($("#ser_id").val());
            var channel_id = $.trim($("#channel_id").val());
            var url = "xxm/FwskServlet"
            console.log(swjg_dm+swry_dm+req_text)
            $.ajax({
                type: 'POST',
                url: url,
                data: {
                    swjg_dm: swjg_dm,
                    swry_dm: swry_dm,
                    req_text: req_text,
                    ser_id: ser_id,
                    channel_id: channel_id
                },
                success: function(data){                  

                    $("#res_text").val(data)
                },
                error: function(){
                    alert("","操作失败",0)
                }
            });
        });
    </script>
    <script type="text/javascript">
        function check(){
            var objFile = document.getElementById("fileId");
            if (objFile.value == "") {
                alert("不能空");
            }
            console.log(objFile.files[0].size);

            var files = $("#fileId").prop('files');
            if (files.length == 0) {
                alert("请选择文件");
            }else{
                var reader = new FileReader();
                reader.readAsText(files[0], "UTF-8");
                reader.onload = function (evt) {
                    var fileString = evt.target.result;
                    console.log(fileString)
                }
            }
        }
    </script>
</body>

</html>

猜你喜欢

转载自blog.csdn.net/qq_36227844/article/details/80564477
今日推荐