<%@ page language="java" contentType="text/html;charset=UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
<%@ taglib uri="/WEB-INF/tld/fns.tld" prefix="fns" %>
<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,Chrome=1"/>
    <meta http-equiv="X-UA-Compatible" content="IE=9"/>
    <meta name="keywords"
          content="保险保函、电子保函、保证保险、保函开具、工程投标保证保险、建设合同履约保证保险、业主合同款支付保证保险、建设工程质量保证保险、建筑业企业人工工资支付保证保险、海关税保险、诉讼财产保全责任保险">
    <meta name="description" content="百联保是百川信（厦门）网络信息服务有限公司基于金融创新并响应“互联网＋”计划搭建的第三方金融服务平台。 ">
    <meta name="viewport" content="width=device-width, initial-scale=1,maximum-scale=1, user-scalable=no">
    <title>常用投保人</title>
</head>

<body>
<jsp:include page="../index/multi_h.jsp"/>
<style>
    .rightLabel {
        margin-left: 15px;
        position: relative;
        top: -16px;
    }

    .container .contacts {
        height: auto;
    }
</style>
<div class="container">
    <%--<div class="addr">
        <span>当前位置：</span>
        <span class="current">首页 > </span>
        <a class="active" href="#">我的账户</a>
    </div>--%>
    <jsp:include page="../index/multi_pc_l.jsp"/>

    <!--右边常用联系人内容区开始-->
    <div class="right contacts">
        <div class="title">
                <span class="tit-name">
                    常用投保人
                </span>
            <button class="tit-btn add-user-person">
                + 添加个人
            </button>
            <button class="tit-btn add-user-company" style="margin-right: 10px;">
                + 添加企业
            </button>
        </div>
        <div class="opera-name">
                <span>
                    名称
                </span>
            <span class="name-right">
                    操作
                </span>
        </div>
        <ul id="userList" class="user-list">
            <%--<li>--%>
            <%--<span class="user-name">张百川</span>--%>
            <%--<i class="delete-icon"></i>--%>
            <%--<span class="user-oper">编辑</span>--%>
            <%--</li>--%>
            <%--<li>--%>
            <%--<span class="user-name">董小天</span>--%>
            <%--<i class="delete-icon"></i>--%>
            <%--<span class="user-oper">编辑</span>--%>
            <%--</li>--%>
            <%--<li>--%>
            <%--<span class="user-name">高 &nbsp;&nbsp;蓉</span>--%>
            <%--<i dataid="8888888" class="delete-icon"></i>--%>
            <%--<span dataid="8888888" class="user-oper">编辑</span>--%>
            <%--</li>--%>
        </ul>
    </div>
    <!--右边常用联系人内容区结束-->
    <!--右边编辑常用联系人开始  个人用户-->
    <div class="right edit">
        <div class="title">
                <span class="tit-name">
                    编辑投保人-个人信息
                </span>
        </div>
        <!--表单内容开始-->
        <form id="defaultForm">
            <ul class="form-list">
                <li>
                    <div class="list-name">
                        <span class="red">*</span>
                        <label>姓名</label>
                    </div>
                    <div class="list-input">
                        <input type="text" class="inp myValid" id="user_name" name="user_name">
                    </div>
                </li>
                <li>
                    <div class="list-name">
                        <label>姓名拼音/英文名</label>
                    </div>
                    <div class="list-input">
                        <input type="text" class="inp myValid" id="user_ename" name="user_ename">
                    </div>
                </li>
                <li>
                    <div class="list-name">
                        <span class="red">*</span>
                        <label>证件类型</label>
                    </div>
                    <div class="list-input">
                        <i class="down-icon" style="left: 279px"></i>
                        <select class="default myValid" id="certificate_type" name="certificate_type"
                                style="width: 298px;height: 45px;">
                            <option value="" selected>请选择证件类型</option>
                            <option value="0">身份证</option>
                            <option value="1">护照</option>
                            <option value="2">出生证</option>
                            <option value="3">驾照</option>
                            <option value="4">港澳通行证</option>
                            <option value="5">军官证</option>
                            <option value="6">台胞证</option>
                            <option value="7">警官证</option>
                            <option value="8">港澳台回乡证</option>
                            <%--<option value="9">组织机构代码证</option>--%>
                            <%--<option value="10">营业执照</option>--%>
                            <%--<option value="11">税务登记证</option>--%>
                            <%--<option value="12">三证合一</option>--%>
                            <%--<option value="13">统一信用代码证</option>--%>
                            <%--<option value="14">其他</option>--%>
                        </select>
                    </div>
                </li>
                <li>
                    <div class="list-name">
                        <span class="red">*</span>
                        <label>证件号码</label>
                    </div>
                    <div class="list-input">
                        <input type="text" class="inp myValid" id="certificate_code" name="certificate_code">
                    </div>
                </li>
                <li>
                    <div class="list-name">
                        <strong>性别</strong>
                    </div>
                    <div class="list-input">
                        <div class="man rad-io">
                            <input type="radio" class="myValid" name="sex" value="1" id="man">
                            <label for="man"><strong class="rightLabel">男</strong></label>
                        </div>
                        <div class="women rad-io">
                            <input type="radio" class="myValid" name="sex" value="0" id="women">
                            <label for="women"><strong class="rightLabel">女</strong></label>
                        </div>
                    </div>
                </li>
                <li>
                    <div class="list-name">
                        <label>出生日期</label>
                    </div>
                    <div class="list-input">
                        <input class="laydate-icon inp myValid" id="birthday" name="birthday">
                        <span class="list-msg"></span>
                    </div>
                </li>
                <li>
                    <div class="list-name">
                        <label>与你的关系</label>
                    </div>
                    <div class="list-input  real-input">
                        <i class="down-icon"></i>
                        <select class="default myValid" name="relative_about_you"
                                style="height: 45px;width: 300px">
                            <option value="">请选择与你的关系</option>
                            <option value="0">妻子</option>
                            <option value="1">丈夫</option>
                            <option value="2">儿子</option>
                            <option value="3">女儿</option>
                            <option value="4">父亲</option>
                            <option value="5">母亲</option>
                            <option value="6">兄弟</option>
                            <option value="7">姐妹</option>
                            <option value="8">祖父/祖母/外祖父/外祖母</option>
                            <option value="9">孙子/孙女/外孙/外孙女</option>
                            <option value="10">叔父/伯父/舅舅</option>
                            <option value="11">婶/姨/姑</option>
                            <option value="12">侄子/侄女/外甥/外甥女</option>
                            <option value="13">堂兄弟/堂姐妹/表兄弟/表姐妹</option>
                            <option value="14">岳父</option>
                            <option value="15">岳母</option>
                            <option value="16">同事</option>
                            <option value="17">朋友</option>
                            <option value="18">雇主</option>
                            <option value="19">雇员</option>
                            <option value="20">法定监护人</option>
                            <option value="21">其他</option>
                        </select>
                    </div>
                </li>
                <li>
                    <div class="list-name">
                        <label>居住地</label>
                    </div>
                    <div class="list-input picker_area_div">
                        <div class="sel-choice">
                            <i class="down-icon"></i>
                            <select class="default picker_province myValid" id="picker_province_p"
                                    name="province" style="height: 45px;width: 150px">
                                <option value="0" selected>请选择省</option>
                            </select>
                        </div>
                        <div class="sel-choice">
                            <i class="down-icon"></i>
                            <select class="default picker_city myValid" id="picker_city_p" name="city"
                                    style="height: 45px;width: 150px">
                                <option value="0" selected>请选择市</option>
                            </select>
                        </div>
                        <div class="sel-choice">
                            <i class="down-icon"></i>
                            <select class="default picker_district myValid" id="picker_district_p"
                                    name="district" style="height: 45px;width: 150px">
                                <option value="0" selected>请选择区</option>
                            </select>
                        </div>
                    </div>
                </li>
                <li>
                    <div class="list-name">
                        <label>详细地址</label>
                    </div>
                    <div class="list-input">
                        <input type="text" class="inp myValid" id="address" placeholder="请输入详细地址" name="address">
                    </div>
                </li>
                <li>
                    <div class="list-name">
                        <label>邮编</label>
                    </div>
                    <div class="list-input">
                        <input type="text" class="inp myValid" placeholder="请输入居住地邮编" id="post_code" name="post_code">
                    </div>
                </li>
                <li>
                    <div class="list-name">
                        <label>联系人email</label>
                    </div>
                    <div class="list-input">
                        <input type="text" class="inp myValid" placeholder="请输入联系人email" id="email" name="email">
                    </div>
                </li>
                <li>
                    <div class="list-name">
                        <label>手机号</label>
                    </div>
                    <div class="list-input">
                        <input type="text" class="inp myValid" placeholder="请输入手机号" id="telephone" name="telephone">
                    </div>
                </li>
                <li>
                    <div class="list-name"></div>
                    <div class="list-input">
                        <button class="btn an_save save" type="button">保存</button>
                        <button class="btn an_back back" type="button">返回</button>
                    </div>
                </li>
            </ul>
        </form>
        <!--表单内容结束-->
    </div>
    <!--右边编辑常用联系人结束  个人用户-->

    <!--右边编辑常用联系人开始  企业用户-->
    <div class="right enter">
        <div class="title">
                <span class="tit-name">
                    编辑投保人-企业信息
                </span>
        </div>
        <!--表单内容开始-->
        <form id="defaultFormCompany">
            <h2 class="person-info" style="font-size: 16px;">
                企业联系人信息
            </h2>
            <ul class="form-list">
                <li>
                    <div class="list-name">
                        <label>联系人姓名</label>
                    </div>
                    <div class="list-input">
                        <input type="text" class="inp myValid" placeholder="请输入联系人姓名" name="user_name">
                    </div>
                </li>
                <li>
                    <div class="list-name">
                        <label>电子邮件</label>
                    </div>
                    <div class="list-input">
                        <input type="text" class="inp myValid" placeholder="请输入电子邮件" name="email">
                    </div>
                </li>
                <li>
                    <div class="list-name">
                        <label>手机号</label>
                    </div>
                    <div class="list-input">
                        <input type="text" class="inp myValid" placeholder="请输入手机号" name="telephone">
                    </div>
                </li>
            </ul>
            <h2 class="person-info" style="font-size: 16px;">
                企业基本信息
            </h2>
            <ul class="form-list">
                <li>
                    <div class="list-name">
                        <label>企业名称</label>
                    </div>
                    <div class="list-input">
                        <input type="text" class="inp myValid" placeholder="请输入企业名称" name="company_name">
                    </div>
                </li>
                <li>
                    <div class="list-name">
                        <label>企业类型</label>
                    </div>
                    <div class="list-input">
                        <input type="text" class="inp myValid" placeholder="请输入企业类型" name="company_type">
                    </div>
                </li>
                <li>
                    <div class="list-name">
                        <label>营业性质</label>
                    </div>
                    <div class="list-input enterprise_type_div">
                        <%--<input type="text" class="inp sel myValid" style="width:200px" placeholder="证件类型" >--%>
                        <div class="sel-choice">
                            <%--<input type="text" class="inp sel ">--%>
                            <i class="down-icon"></i>
                            <select class=" default enterprise_type_one myValid" name="enterprise_type_one" style="height: 45px">
                                <option value="" selected>-请选择-</option>
                            </select>
                        </div>
                        <div class="sel-choice enterprise_type_two_div">
                            <i class="down-icon"></i>
                            <select class=" default enterprise_type_two myValid" name="enterprise_type_two" style="height: 45px">
                                <option value="" selected>-请选择-</option>
                            </select>
                        </div>
                    </div>
                </li>
                <li>
                    <div class="list-name">
                        <label>证件类型</label>
                    </div>
                    <div class="list-input">
                        <%--<input type="text" class="inp sel myValid" placeholder="证件类型">--%>
                        <i class="down-icon"></i>
                        <select class="default myValid" name="certificate_type" style="height: 45px">
                            <option selected value="">-请选择-</option>
                            <option value="1">组织机构代码证</option>
                            <option value="6">税务登记证</option>
                            <option value="7">营业执照</option>
                            <option value="2">三证合一统一信用代码</option>
                        </select>
                    </div>
                </li>
                <li>
                    <div class="list-name">
                        <label>证件号码</label>
                    </div>
                    <div class="list-input">
                        <input type="text" class="inp myValid" placeholder="请输入证件号码" name="certificate_code">
                    </div>
                </li>
                <li>
                    <div class="list-name">
                        <label>企业所在地</label>
                    </div>
                    <div class="list-input picker_area_div">
                        <div class="sel-choice">
                            <%--<input type="text" class="inp sel ">--%>
                            <i class="down-icon"></i>
                            <select class=" default picker_province myValid" id="picker_province" name="province" style="height: 45px;width: 150px">
                                <option value="0" selected>请选择省</option>
                            </select>
                        </div>
                        <div class="sel-choice">
                            <%--<input type="text" class="inp sel">--%>
                            <i class="down-icon"></i>
                            <select class=" default picker_city myValid" id="picker_city" name="city" style="height: 45px;width: 150px">
                                <option value="0" selected>请选择市</option>
                            </select>
                        </div>
                        <div class="sel-choice">
                            <%--<input type="text" class="inp sel">--%>
                            <i class="down-icon"></i>
                            <select class=" default picker_district myValid" id="picker_district" name="district" style="height: 45px;width: 150px">
                                <option value="0" selected>请选择区</option>
                            </select>
                        </div>
                    </div>
                </li>
                <li>
                    <div class="list-name">
                        <label>详细地址</label>
                    </div>
                    <div class="list-input">
                        <input type="text" class="inp myValid" placeholder="请输入详细地址" name="address">
                    </div>
                </li>
                <li>
                    <div class="list-name"></div>
                    <div class="list-input">
                        <button class="btn anc_save save" type="button">保存</button>
                        <button class="btn anc_back back" type="button">返回</button>
                    </div>
                </li>
            </ul>
        </form>
        <!--表单内容结束-->
    </div>


</div>
<jsp:include page="../index/multi_f.jsp"/>
<script src="<c:url value='/resources/version_new/js/jquery-1.8.3.min.js' />"></script>
<script src="<c:url value='/resources/version_new/js/jquery.form.js' />"></script>
<script src="<c:url value='/resources/version_new/js/jquery.formHelper.js' />"></script>
<script src="<c:url value='/resources/version_new/js/laydate/laydate.js' />"></script>
<script src="<c:url value='/resources/version_new/js/layer/layer.js' />"></script>
<script src="<c:url value='/resources/version_new/js/applicant.js' />"></script>
<script src="<c:url value='/resources/public/g.js' />"></script>
<script type="text/javascript" src="<c:url value='/resources/commonJS/con-common.js' />"></script>
</body>
<script type="text/javascript">
    var allright = true;

    function isWrong(el, obj, msg) {
        if (el) {
            $(obj).nextAll("span").remove();
            if (msg != "") $(obj).after("<span class='list-msg'>" + msg + "</span>");
            $(obj).addClass("err");
            allright = false;
//            $(obj).focus();
            return false;
        } else {
            $(obj).nextAll("span").remove();
            $(obj).removeClass("err");
            return true;
        }
    }


    function clearErr(obj) {
        $(obj).nextAll("span").remove();
        $(obj).removeClass("err");
    }
    var applicant_mark = "add", u_id = "";
    $('.contacts').on('click', '.add-user-person', function () {
        person();
        unbind('2');
        // 点击添加联系人
        applicant_mark = "add",u_id = "";
        $("#defaultForm").clearForm();
        $("#defaultForm").setForm({
            province: "",
            city: "",
            district: "",
            relative_about_you: "",
            certificate_type: ""
        });
        $(".contacts").css('display', "none").siblings('.edit').css('display', 'block'); //页面切换
    });

    $('.contacts').on('click', '.add-user-company', function () {
        company();
        unbind('1');
        // 点击添加联系人
        applicant_mark = "add",u_id = "";
        $("#defaultFormCompany").clearForm();
        $("#defaultFormCompany").setForm({
            province: "",
            city: "",
            district: "",
            enterprise_type_one: "",
            enterprise_type_two: "",
            company_certificate_type: "",
            certificate_type: ""
        });
        $(".contacts").css('display', "none").siblings('.enter').css('display', 'block'); //页面切换
    });

    //删除操作
    $('.user-list').on('click', '.delete-icon', function () {
        var type = $(this).attr("datatp");
        var id = $(this).attr("dataid");
        if(type == '1'){
            delHandler(function (index) {
                //配套js(/resources/commonJS/con-common.js)1.表单参数，2.请求地址，3.是否同步，4.是否遮盖，5.返回处理
                setParamDatas({sys_client_user_contract_p_id: id},'/pc/commonApplicant/person/del',false,true,function(json){
                    if (json.success == true) {
                        layer.msg(json.msg, {icon: 1, time: 1000});
                        reload();
                        layer.close(index);
                    } else {
                        layer.alert(json.msg, {icon: 2});
                    }
                });
            });
        }else if(type == '2'){
            delHandler(function (index) {
                //配套js(/resources/commonJS/con-common.js)1.表单参数，2.请求地址，3.是否同步，4.是否遮盖，5.返回处理
                setParamDatas({sys_client_user_contract_c_id: id},'/pc/commonApplicant/company/del',false,true,function(json){
                    if (json.success == true) {
                        layer.msg(json.msg, {icon: 1, time: 1000});
                        reload();
                        layer.close(index);
                    } else {
                        layer.alert(json.msg, {icon: 2});
                    }
                });
            });
        }
    });

    // 点击编辑联系人
    $(".contacts").on("click", '.user-oper', function () {
        applicant_mark = "upd";
        u_id = $(this).attr("dataid"); //页面切换
        var type = $(this).attr("datatp");
        if(type == '1'){
            person();
            unbind('2');
            $(".contacts").css('display', "none").siblings('.edit').css('display', 'block');
            //配套js(/resources/commonJS/con-common.js)1.表单参数，2.请求地址，3.是否同步，4.是否遮盖，5.返回处理
            setParamDatas({sys_client_user_contract_p_id: u_id},'/pc/commonApplicant/person/queryByID',false,true,function(json){
                var obj = json[0];
                console.log(obj);
                $("#defaultForm").setForm(obj);
                if (obj.district != undefined) {
                    $("#picker_province_p").change();
                    $("#picker_city_p").val(obj.city);
                    $("#picker_city_p").change();
                    $("#picker_district_p").val(obj.district);
                }
            });
        }else if(type == '2'){
            company();
            unbind('1');
            $(".contacts").css('display', "none").siblings('.enter').css('display', 'block');
            //配套js(/resources/commonJS/con-common.js)1.表单参数，2.请求地址，3.是否同步，4.是否遮盖，5.返回处理
            setParamDatas({sys_client_user_contract_c_id: u_id},'/pc/commonApplicant/company/queryByID',false,true,function(json){
                var obj = json[0];
                $("#defaultFormCompany").setForm(obj);
                if (obj.district != undefined) {
                    $("#picker_province").change();
                    $("#picker_city").val(obj.city);
                    $("#picker_city").change();
                    $("#picker_district").val(obj.district);
//                    districtObj.init(obj);//初始化联动控件{province:140000,city:140100,district:140423}
                }
                if (obj.enterprise_type_two != undefined) {
                    $(".enterprise_type_one").change();
                    $(".enterprise_type_two").val(obj.enterprise_type_two);
                }
            });
        }
    });

    //点击返回按钮
    $(".list-input").on("click", '.back', function () {
        $(".edit").css('display', "none").siblings('.contacts').css('display', 'block');
    });

    //点击返回按钮
    $(".list-input").on("click", '.back', function () {
        $(".enter").css('display', "none").siblings('.contacts').css('display', 'block');
    });

    function unbind(_tp){
        if(_tp == '1'){
           $('.edit').unbind(".pev");
            $('.an_save').unbind();
        }else if(_tp == '2'){
           $('.enter').unbind(".cev");
            $('.anc_save').unbind();
        }
    }

    function person() {

        //联系人，个人
        $("#user_name").bind("blur keyup.pev", function () {
            var r1 = isWrong($(this).val().trim() == "", this, "姓名必填");
            if (!r1) return r1;
            var r2 = isWrong(!/^[\u4e00-\u9fa5a-zA-Z0-9]{2,30}$/.test($(this).val()), this, "姓名必须是2-30个中英文字母");
        });
        $("#user_ename").bind("blur keyup.pev", function () {
            if ($(this).val().trim() == "") {
                clearErr(this);
                return;
            } //允许为空
            var r2 = isWrong(!/^[A-Za-z_\s]{2,30}$/.test($(this).val()), this, "姓名必须是2-30个英文");
        });
        $("#certificate_type").bind("blur keyup.pev", function () {
            var r1 = isWrong($(this).val().trim() == "", this, "证件类型必填"); //证件类型必填 TODO 下拉框bug，不提示，否则css混乱
        });
        $("#certificate_code").bind("blur keyup.pev", function () {
            var r1 = isWrong($(this).val().trim() == "", this, "证件号码必填");
            if (!r1) return r1;
            var r2 = isWrong(!/^[a-zA-Z0-9]{5,40}$/.test($(this).val()), this, "证件号码为5-40个数字英文");
        });
        $("#telephone").bind("blur keyup.pev", function () {
            if ($(this).val().trim() == "") {
                clearErr(this);
                return;
            } //允许为空
            var r2 = isWrong(!/^[0-9]{11}$/.test($(this).val()), this, "手机必须是11位数字");
        });
        $("#address").bind("blur keyup.pev", function () {
            if ($(this).val().trim() == "") {
                clearErr(this);
                return;
            } //允许为空
            var r2 = isWrong(!/^[\u4e00-\u9fa5_a-zA-Z0-9_\(\)]{1,100}$/.test($(this).val()), this, "请输入()中文字母数字100个字符长度");
        });
        $("#post_code").bind("blur keyup.pev", function () {
            if ($(this).val().trim() == "") {
                clearErr(this);
                return;
            } //允许为空
            var r2 = isWrong(!/^[1-9][0-9]{5}$/.test($(this).val()), this, "请输入正确的邮编");
        });
        $("#email").bind("blur keyup.pev", function () {
            if ($(this).val().trim() == "") {
                clearErr(this);
                return;
            } //允许为空
            var r2 = isWrong(!/^([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+@([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+\.[a-zA-Z]{2,3}$/.test($(this).val()), this, "请输入正确的电子邮箱");
        });

        // 联系人保存
        $('.an_save').click(function () {
            allright = true;
            $(".myValid").each(function () {
                $(this).trigger("blur");
                if ($(this).hasClass("err")) $(this).focus();
            }); //校验表单
            if (allright) {
                var data = $("#defaultForm").serializeJson();
                data.sys_client_user_id = '${userdetail.oid}'; //终端用户主键ID
                if (applicant_mark == "add") {
                    //配套js(/resources/commonJS/con-common.js)1.表单参数，2.请求地址，3.是否同步，4.是否遮盖，5.返回处理
                    setParamDatas(data,'/pc/commonApplicant/person/add',false,true,function(json){
                        layer.alert(json.msg, {
                            icon: 1, closeBtn: 0, yes: function () {
                                layer.closeAll();
                                reload();
                                $(".an_back").trigger("click");
                            }
                        });
                    });
                } else {
                    data.sys_client_user_contract_p_id = u_id; //个人联系人表ID
                    //配套js(/resources/commonJS/con-common.js)1.表单参数，2.请求地址，3.是否同步，4.是否遮盖，5.返回处理
                    setParamDatas(data,'/pc/commonApplicant/person/upd',false,true,function(json){
                        layer.alert(json.msg, {
                            icon: 1, closeBtn: 0, yes: function () {
                                layer.closeAll();
                                reload();
                                $(".an_back").trigger("click");
                            }
                        });
                    });
                }
            }
        });
    }

    function company() {

        //联系人，企业
        $("#defaultFormCompany input[name='user_name']").bind("blur keyup.cev", function () {
            var r1 = isWrong($(this).val().trim() == "", this, "联系人名必填");
            if (!r1) return r1;
            var r2 = isWrong(!/^[\u4e00-\u9fa5a-zA-Z0-9\（\）]{2,40}$/.test($(this).val()), this, "姓名必须是2-40个中英文字母");
        });
        $("#defaultFormCompany input[name='email']").bind("blur keyup.cev", function () {
            if ($(this).val().trim() == "") {
                clearErr(this);
                return;
            } //允许为空
            var r2 = isWrong(!/^([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+@([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+\.[a-zA-Z]{2,3}$/.test($(this).val()), this, "请输入正确的电子邮箱");
        });
        $("#defaultFormCompany  input[name='certificate_code']").bind("blur keyup.cev", function () {
            if ($(this).val().trim() == "") {
                clearErr(this);
                return;
            } //允许为空
            var r2 = isWrong(!/^[a-zA-Z0-9]{5,40}$/.test($(this).val()), this, "证件号码为5-40个数字英文");
        });
        $("#defaultFormCompany  input[name='telephone']").bind("blur keyup.cev", function () {
            if ($(this).val().trim() == "") {
                clearErr(this);
                return;
            } //允许为空
            var r2 = isWrong(!/^[0-9]{11}$/.test($(this).val()), this, "手机必须是11位数字");
        });
        $("#defaultFormCompany  input[name='company_name']").bind("blur keyup.cev", function () {
            if ($(this).val().trim() == "") {
                clearErr(this);
                return;
            } //允许为空
            var r2 = isWrong(!/^[\u4e00-\u9fa5a-zA-Z0-9\（\）]{2,60}$/.test($(this).val()), this, "企业名称必须是2-40个中英文字母");
        });
        $("#defaultFormCompany  input[name='company_certificate_code']").bind("blur keyup.cev", function () {
            if ($(this).val().trim() == "") {
                clearErr(this);
                return;
            } //允许为空
            var r2 = isWrong(!/^[a-zA-Z0-9]{5,40}$/.test($(this).val()), this, "企业证件号码为5-40个数字英文");
        });
        $("#defaultFormCompany  input[name='address']").bind("blur keyup.cev", function () {
            if ($(this).val().trim() == "") {
                clearErr(this);
                return;
            } //允许为空
            var r2 = isWrong(!/^[\u4e00-\u9fa5_a-zA-Z0-9_\(\)]{1,100}$/.test($(this).val()), this, "请输入()中文字母数字100个字符长度");
        });


        // 联系人保存
        $('.anc_save').click(function () {
            allright = true;
            $(".myValid").each(function () {
                $(this).trigger("blur");
                if ($(this).hasClass("err")) $(this).focus();
            }); //校验表单
            if (allright) {
                var data = $("#defaultFormCompany").serializeJson();
                data.sys_client_user_id = '${userdetail.oid}'; //终端用户主键ID
                if (applicant_mark == "add") {
                    //配套js(/resources/commonJS/con-common.js)1.表单参数，2.请求地址，3.是否同步，4.是否遮盖，5.返回处理
                    setParamDatas(data,'/pc/commonApplicant/company/add',false,true,function(json){
                        layer.alert(json.msg, {
                            icon: 1, closeBtn: 0, yes: function () {
                                layer.closeAll();
                                reload();
                                $(".an_back").trigger("click");
                            }
                        });
                    });
                } else {
                    data.sys_client_user_contract_c_id = u_id; //个人联系人表ID
                    //配套js(/resources/commonJS/con-common.js)1.表单参数，2.请求地址，3.是否同步，4.是否遮盖，5.返回处理
                    setParamDatas(data,'/pc/commonApplicant/company/upd',false,true,function(json){
                        layer.alert(json.msg, {
                            icon: 1, closeBtn: 0, yes: function () {
                                layer.closeAll();
                                reload();
                                $(".an_back").trigger("click");
                            }
                        });
                    });
                }
            }
        });
    }

    $(document).ready(function () {
        <%--var terminal_type = '${userdetail.terminal_type}';--%>
        reload();
//        if ("1" == terminal_type) {
//            person();
//        } else if ("2" == terminal_type) {
//            company();
//        }
    });

    //列表展示
    function reload() {
        unbind('1');
        unbind('2');
        setParamDatas({sys_client_user_id: '${userdetail.oid}'},'/pc/commonApplicant/c-p/query',false,true,function(json){
            var str = "";
            if (json.length > 0) {
                for (var i = 0; i < json.length; i++) {
                    str += '<li><span class="user-name">' + json[i].user_name + '</span>' +
                        '<i dataid="' + json[i].id + '" datatp="' + json[i].type + '" class="delete-icon"></i>' +
                        '<span dataid="' + json[i].id + '" datatp="' + json[i].type + '" class="user-oper">编辑</span></li>';
                }
            } else {
                str += '<li style="float: none">' +'<p style="text-align: center">暂无常用投保人！！</p>' +'</li>';
            }$("#userList").html(str);
        });
    }

</script>

</html>
<script>
    $('ul.aside-list li').removeClass('on');
    $("#linkMan").addClass('on');
</script>
