index.html 1.8 KB
<include file="public@header" />
</head>
<body>

<form class="form-horizontal" role="form" style="width:800px;margin-top:100px;">
  <div class="form-group">
    <label for="firstname" class="col-sm-2 control-label">核销码:</label>
    <div class="col-sm-10">
      <input type="text" name="ma" class="form-control" id="firstname"
           placeholder="请输入核销码">
    </div>
  </div>
  <div class="form-group">
    <div class="col-sm-offset-2 col-sm-10">
      <button type="button" class="btn btn-default" onclick="hexiao()">核销</button>
      <button type="button" class="btn btn-default" onclick="shenfen()">身份证号</button>
    </div>
  </div>
</form>

<script>
  //点击核销时
  function hexiao(){

    ma = $("input[name='ma']").val();
    if(ma == ''){
      alert('请输入核销码');
    }else{
      $.post("{:url('Hexiao/hxCancel')}", {code:ma}, function(data) {

        if(data == 2){
          alert('核销码不存在');
        }else if (data == 3) {
          alert('优惠券已过期');
        }else if (data ==4) {
          alert('核销失败');
        }else if (data == 5) {
          alert('请在生日当天使用');
        }else if (data == 1) {
          alert('核销成功');
        }

      });
    }

  }

  /**
   *点击身份证号
   */
  function shenfen(){
      ma = $("input[name='ma']").val();
      if(ma == ''){
          alert('请输入核销码');
      }else{
          $.post("{:url('Hexiao/hexiao_idnum')}",{code:ma},function(data){
              if(data){
                  $('#sfsf').remove();
                $('#firstname').after("<input type='text' class='form-control' value='"+data+"' id='sfsf' style='margin-top: 10px;'>");
              }else{
                  $('#sfsf').remove();
                  alert('请补全身份信息');
              }
          });
      }
  }
</script>
</body>
</html>