inquiry.html 6.29 KB
<!DOCTYPE html>
<html>
  <head>
    <meta charset=utf-8>
    <meta name=viewport content="width=device-width,initial-scale=1,user-scalable=0">
    <title>保单便捷查询</title>
    <style>
      * {
        margin: 0;
        padding: 0;
        font-size:14px;
      }
      .logo{
        padding:10px;
      }
      .mini_head{
        border-bottom:2px solid #ed5d43;
        padding:0 10px;
      }
      .mini_head .h2{
        background:#ED5D43;
        color:#fff;
        font-weight:normal;
        text-align:center;
        display:inline-block;
        padding:8px 20px;
        font-size:14px;
      }
      .cell_group{
        padding:10px;
      }
      .cell_line{
        display: flex;
        box-sizing: border-box;
        border-bottom:1px solid #d8d8d8;
        padding:5px 10px;
      }
      .cell_line .name{
        width:80px;
        line-height:30px;
      }
      .cell_line .input_box{
        flex:1;
      }
      .cell_line .code_box{
        flex:1;
        font-family:Arial;
        font-style:italic;
        background:#D8B7E3;
        text-align:center;
        letter-spacing:10px;
        font-weight:bolder;            
        cursor:pointer;
        text-align:center;
        font-size:20px;
        line-height:30px;
      }
      .a_input{
        width:100%;
        border:0;
        outline: none;
        line-height:30px;
      }
      
      .btn_group{
        padding:10px;
      }
      .btn_group a{
        display:block;
        background:#ED5D43;
        color:#fff;
        text-decoration:none;
        padding:10px;
        border-radius:4px;
        text-align:center;
      }
      
    </style>
  </head>
  <body>
    <div class="page_wrapper">

      <!-- logo 开始 -->
      <div class="logo">
        <img src="" alt="" />
      </div>
      <!-- logo end -->

      <!-- 保单查询头部 开始 -->
      <div class="mini_head">
        <h2 class="h2">保单查询</h2>
      </div>
      <!-- 保单查询头部 end -->

      <!-- 保单查询输入区域 开始 -->
      <div class="cell_group">
        <div class="cell_line">
          <div class="name">保单凭证</div>
          <div class="input_box">
            <input type="text" class="a_input" placeholder="请输入保单凭证" id="inputNumber" />
          </div>
        </div>

        <div class="cell_line">
          <div class="name">验证码</div>
          <div class="input_box">
            <input type="text" class="a_input" maxlength="4" placeholder="请输入验证码" id="code" />
          </div>
          <div class="code_box" id="codeBox"></div>
        </div>

      </div>
      <!-- 保单查询输入区域 end -->

      <!-- 按钮区域 开始 -->
      <div class="btn_group">
        <a href="javascript:void(0)" id="serchButton">确认查询</a>
      </div>
      <!-- 按钮区域 end -->

    </div>
  </body>
  <script type="text/javascript" src="../static/js/zepto.min.js"></script>
  <script type="text/javascript" src="../static/layer_mobile/layer.js"></script>
  <script type="text/javascript">
    $(function () {
        $.getUrlParam = function (name) {
            var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
            var r = window.location.search.substr(1).match(reg);
            if (r != null) return unescape(r[2]); return null;
        }
        console.log()
        var logoUlr = $.getUrlParam('companyCode')
        $('.logo img').attr('src', '../static/images/'+ logoUlr +'.png')
    })
    Zepto(function($) {

      var inquiry = {};

      /**
       * 绑定event事件
       */
      inquiry.bindEvent = function() {
        $('#serchButton').on('click', function() {
          inquiry.serch();
        })
        
        $('#codeBox').on('click',function(){
          inquiry.createCode();
        })
      }

      /**
       * 生成验证码
       */
      inquiry.createCode = function(length) {
        var code = "";
        var codeLength = length ? parseInt(length) : 4; //验证码的长度
        ////所有候选组成验证码的字符,当然也可以用中文的
        var codeChars = new Array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9,
          'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't',
          'u', 'v',
          'w', 'x', 'y', 'z',
          'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T',
          'U', 'V',
          'W', 'X', 'Y', 'Z');
        //循环组成验证码的字符串
        for (var i = 0; i < codeLength; i++) {
          //获取随机验证码下标
          var charNum = Math.floor(Math.random() * 62);
          //组合成指定字符验证码
          code += codeChars[charNum];
        }
        $('#codeBox').html(code);
        inquiry.code = code;
        return code;
      };

      /**
       * 初始化函数
       */
      inquiry.init = function() {
        inquiry.bindEvent();
        inquiry.createCode();
      }

      /**
       * 查询
       */
      inquiry.serch = function() {
        var num = $('#inputNumber').val();
        var code = $('#code').val();
        if (!num) {
          layer.open({
            content: '请输入保单凭证',
            btn: '关闭'
          });
          return false;
        }

        if (!code) {
          layer.open({
            content: '请输入验证码',
            btn: '关闭'
          });
          return false;
        }

        if (code.toUpperCase() != (inquiry.code).toUpperCase()) {
          layer.open({
            content: '验证码错误',
            btn: '关闭'
          });
          inquiry.createCode();
          return false;
        }

        var mLoading = layer.open({
          type: 2,
          content: '加载中'
        });
        $.ajax({
          type: 'GET',
          url: '/web-dj-mobile/qrCodeQuery/' + num,
          dataType: 'json',
          success: function(res) {
            layer.close(mLoading)
            if (res.returnCode == 0) {
              sessionStorage.setItem('inquiry',JSON.stringify(res.data));
              window.location.href = "detail.html?code=" + num
            } else {
              layer.open({
                content: res.message || '保单不存在',
                btn: '关闭'
              });
            }
          }
        })

      }


      inquiry.init();


    })
  </script>
</html>