<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="selfinfo.aspx.cs" Inherits="renkou.teaapp.selfinfo" %>

<!doctype html>
<html>
<head>
    <meta charset="utf-8">
    <title>个人信息——<%=xxsoft_check.check.getseting("systitle") %></title>
    <meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=0">
    <link rel="stylesheet" href="../weui/css/weui.css"/>
    <link rel="stylesheet" href="../weui/css/weuix.css"/>
    <script src="../weui/js/zepto.min.js"></script>
    <script src="../weui/js/zepto.weui.js"></script>
    <script src="../weui/js/php.js"></script>

</head>

<body ontouchstart>
<div class="weui-header bg-blue"> 
  <div class="weui-header-left"> <a class="icon icon-109 f-white" href="javascript:history.go(-1);">返回</a>  </div>
   <h1 class="weui-header-title">个人信息</h1>
    <div class="weui-header-right"><a class="icon icon-112 f-white" href="exit.aspx"></a></div> 
    </div>
    <form name="form1" id="form1">
 <div class="weui-cells weui-cells_form">
        <input id="oldxm" name="oldxm" type="hidden" />
        <input id="photo" name="photo" type="hidden" />
    <div class="weui-cell">      
        <div class="weui-avatar-circle">
           <img src="" id="pic">
            <input type="file" name="file" id="file" class="file" value="" accept="image/jpg,image/jpeg,image/png,image/bmp" style="display:none;" onchange="previewImage(this)"/>
       </div>
</div>   
 <div class="weui-cell">  
        <div class="weui-cell__hd">
            <label class="weui-label">用户名</label>
        </div>
        <div class="weui-cell__bd">
            <input class="weui-input" placeholder="请输入用户名" type="text" id="xm" name="xm" readonly>
        </div>
    </div>   
   <div class="weui-cell">
        <div class="weui-cell__hd">
            <label class="weui-label">姓名</label>
        </div>
        <div class="weui-cell__bd">
            <input class="weui-input" placeholder="请输入姓名" type="text" id="userxm" name="userxm" readonly>
        </div>
    </div>
   <div class="weui-cell">
        <div class="weui-cell__hd"><label class="weui-label">身份证号</label></div>
        <div class="weui-cell__bd">
            <input class="weui-input" placeholder="请输入身份证号" type="text" id="card" name="card" onblur="checksfz()">
        </div>
    </div>
    <div class="weui-cell">
        <div class="weui-cell__hd">
            <label class="weui-label">性别</label>
        </div>
        <div class="weui-cell__bd">
             <div class="weui-form-li iblock">
            <input class="weui-form-checkbox"  name="xb"  id="g1" value="男" type="radio">
            <label for="g1" >
                <i class="weui-icon-radio"></i>
                <div class="weui-form-text"><p>男</p></div>
            </label>
        </div>
        <div class="weui-form-li iblock">
            <input class="weui-form-checkbox"  name="xb"  id="g2" value="女" type="radio">
            <label for="g2" >
                <i class="weui-icon-radio"></i>
                <div class="weui-form-text"><p>女</p></div>
            </label>
        </div>
        </div>
    </div>
    <div class="weui-cell">
        <div class="weui-cell__hd"><label class="weui-label">出生年月</label></div>
        <div class="weui-cell__bd">
           <input class="weui-input" placeholder="请输入出生年月" type="text" id="csny" name="csny">
        </div>
    </div>
    <div class="weui-cell">
        <div class="weui-cell__hd"><label class="weui-label">部门</label></div>
        <div class="weui-cell__bd">
           <input class="weui-input"  type="text" id="bumen" name="bumen" readonly>
        </div>
    </div>
    <div class="weui-cell">
        <div class="weui-cell__hd"><label class="weui-label">职务</label></div>
        <div class="weui-cell__bd">
           <input class="weui-input"  type="text" id="zhiwu" name="zhiwu" readonly>
        </div>
    </div>
    <div class="weui-cell">
        <div class="weui-cell__hd"><label class="weui-label">分组</label></div>
        <div class="weui-cell__bd">
           <input class="weui-input"  type="text" id="fenzu" name="fenzu" readonly>
        </div>
    </div>
    <div class="weui-cell">
        <div class="weui-cell__hd"><label class="weui-label">电话</label></div>
        <div class="weui-cell__bd">
            <input class="weui-input" placeholder="请输入您的电话" type="text" id="tel" name="tel">
        </div>
    </div>
    <div class="weui-cell">
        <div class="weui-cell__hd"><label class="weui-label">入职时间</label></div>
        <div class="weui-cell__bd">
           <input class="weui-input" placeholder="请输入入职时间" type="text" id="ruzhidate" name="ruzhidate">
        </div>
    </div>
     <div class="weui-cell">
        <div class="weui-cell__hd"><label class="weui-label">宿舍</label></div>
        <div class="weui-cell__bd">
          <input class="weui-input" placeholder="请输入宿舍" type="text" id="sushe" name="sushe">
        </div>
    </div>    
     <div class="weui-cell">
        <div class="weui-cell__hd"><label class="weui-label">地址</label></div>
        <div class="weui-cell__bd">
          <input class="weui-input" placeholder="请输入地址" type="text" id="zhuzhi" name="zhuzhi">
        </div>
    </div>
     <div class="weui-cell">
        <div class="weui-cell__hd"><label class="weui-label">备注</label></div>
        <div class="weui-cell__bd">
          <input class="weui-input" placeholder="请输入备注" type="text" id="beizhu" name="beizhu">
        </div>
    </div>
</div>
<div class="weui-flex__item"><a href="javascript:;" class="weui-btn weui-btn_primary" id="btn">保存</a></div>
</form>
    <br>
    <br>
    

    <script>
         $("#pic").click(function () {
            $("#file").click();
            });
        function previewImage(file) {
         var MAXWIDTH = 1000;
         var MAXHEIGHT = 1200;
         if (file.files && file.files[0]) {
             var reader = new FileReader();
             reader.onload = function (evt) {
                 $.post("../api/upfile.ashx", { imgbase64: evt.target.result }, function (rs) {
                     $("#photo").val(rs.url);
                     $("#pic").attr("src",rs.url);
                 },'json');
             };
             reader.readAsDataURL(file.files[0]);
             console.log(file.files[0]);
         }
     }

        function checksfz() {
            //获取输入身份证号码 
            var UUserCard = $("#card").val();
            //获取出生日期 
            $("#csny").val(UUserCard.substring(6, 10) + "-" + UUserCard.substring(10, 12) + "-" + UUserCard.substring(12, 14));
            //获取性别 
            if (parseInt(UUserCard.substr(16, 1)) % 2 == 1) {
                $("input[name='xb'][value='男']").attr("checked", true);
            } else {
                $("input[name='xb'][value='女']").attr("checked", true);
            }
        }
        $.ajax({
            type: "post",
            url: 'selfinfo.aspx?action=edit',
            dataType: 'json',
            success: function (data) {
                $("#id").val(data.id);
                $("#pic").attr("src", data.photo);
                $("#photo").val(data.photo);
                $("#xm").val(data.xm);
                $("#oldxm").val(data.xm);
                $("#userxm").val(data.userxm);
                $("input[name='xb'][value='"+data.xb+"']").attr("checked", true);
                $("#csny").val(data.csny);
                $("#card").val(data.card);
                $("#tel").val(data.phone);
                $("#bumen").val(data.bumen);
                $("#zhiwu").val(data.zhiwu);
                $("#fenzu").val(data.fenzu);
                $("#sushe").val(data.sushe);
                $("#zhuzhi").val(data.zhuzhi);
                $("#beizhu").val(data.beizhu);
                $("#ruzhidate").val(data.ruzhidate);
            },
            error: function (xhr) {
                alert('获取数据出错');
            }
        });
            $(document).on("click", "#btn", function () {
                var tel = $("#tel").val();
                if (tel == "") {
                    $.toptip("电话不能为空");
                    return false;
                }
                $.post('selfinfo.aspx?action=addsave', $("#form1").serialize(), function (data, status) {
                    if (status == "success") {
                        var jsonData = data;
                        if (jsonData.isOk == 1) {
                            //alert(jsonData.message)
                            $.toast("个人信息保存成功!");
                        } else {
                            $.alert(jsonData.message);
                        }
                    }
                }, 'json');
            });
        $(document).on("open", ".weui-popup-modal", function () {
            console.log("open popup");
        }).on("close", ".weui-popup-modal", function () {
            console.log("close popup");
        });
</script>
</body>
</html>


