var Register = {
    registData: {},
    validateFields: {
        username: {validators: {notEmpty: {message: '登录账号不能为空'}}},
        name: {validators: {notEmpty: {message: '单位/企业名称不能为空'}}}, //, regexp: {regexp: /^([\u4E00-\u9FA5]|\（|\）){1,100}$/, message: "单位/企业名称只允许中文"}
        //idCard: {validators: {notEmpty: {message: '统一社会信用代码不能为空'}}},
        agentName: {validators: {notEmpty: {message: '人才联络员不能为空'}}},
        agentPhone: {
            validators: {
                notEmpty: {
                    message: '人才联络员手机号不能为空'
                }, regexp: {
                    regexp: /(^(\d{11})|^((\d{7,8})|(\d{4}|\d{3})-(\d{7,8})|(\d{4}|\d{3})-(\d{7,8})-(\d{4}|\d{3}|\d{2}|\d{1})|(\d{7,8})-(\d{4}|\d{3}|\d{2}|\d{1})))$/,
                    message: "人才联络员手机号格式不合法"
                }
            }
        },
        verificationCode: {validators: {notEmpty: {message: '手机验证码不能为空'}}},
        //legal: {validators: {notEmpty: {message: '法人代表不能为空'},regexp:{regexp:/^[\u4e00-\u9fa5]{1,50}$/,message:"法人代表只允许中文"}}},
        street: {validators: {notEmpty: {message: '所属街道不能为空'}}},
        address: {validators: {notEmpty: {message: '单位/企业地址不能为空'}}},
        ephone: {
            validators: {
                notEmpty: {
                    message: '单位/企业电话不能为空'
                }, regexp: {
                    regexp: /(^(\d{11})|^((\d{7,8})|(\d{4}|\d{3})-(\d{7,8})|(\d{4}|\d{3})-(\d{7,8})-(\d{4}|\d{3}|\d{2}|\d{1})|(\d{7,8})-(\d{4}|\d{3}|\d{2}|\d{1})))$/,
                    message: "单位/企业电话格式不合法"
                }
            }
        },
        agentEmail: {
            validators: {
                notEmpty: {
                    message: '电子邮箱不能为空'
                },
                regexp: {
                    regexp: /[\w!#$%&'*+/=?^_`{|}~-]+(?:\.[\w!#$%&'*+/=?^_`{|}~-]+)*@(?:[\w](?:[\w-]*[\w])?\.)+[\w](?:[\w-]*[\w])?/,
                    message: "电子邮箱格式不正确"
                }
            }
        },
        //bankCard: {validators: {notEmpty: {message: '企业银行账号不能为空'}}},
        //bankNetwork: {validators: {notEmpty: {message: '企业开户银行网点不能为空'}}},
        //bank: {validators: {notEmpty: {message: '企业开户银行不能为空'}}}
    },
    sy_validateFields: {
        username: {validators: {notEmpty: {message: '登录账号不能为空'}}},
        name: {validators: {notEmpty: {message: '单位名称不能为空'}, regexp: {regexp: /^[\u4e00-\u9fa5]{1,100}$/, message: "单位名称只允许中文"}}},
        agentName: {validators: {notEmpty: {message: '人才联络员不能为空'}}},
        agentPhone: {
            validators: {
                notEmpty: {
                    message: '人才联络员手机号不能为空'
                }, regexp: {
                    regexp: /(^(\d{11})|^((\d{7,8})|(\d{4}|\d{3})-(\d{7,8})|(\d{4}|\d{3})-(\d{7,8})-(\d{4}|\d{3}|\d{2}|\d{1})|(\d{7,8})-(\d{4}|\d{3}|\d{2}|\d{1})))$/,
                    message: "人才联络员手机号格式不合法"
                }
            }
        },
        verificationCode: {validators: {notEmpty: {message: '手机验证码不能为空'}}},
        street: {validators: {notEmpty: {message: '所属街道不能为空'}}},
        address: {validators: {notEmpty: {message: '单位地址不能为空'}}},
        ephone: {
            validators: {
                notEmpty: {
                    message: '单位电话不能为空'
                }, regexp: {
                    regexp: /(^(\d{11})|^((\d{7,8})|(\d{4}|\d{3})-(\d{7,8})|(\d{4}|\d{3})-(\d{7,8})-(\d{4}|\d{3}|\d{2}|\d{1})|(\d{7,8})-(\d{4}|\d{3}|\d{2}|\d{1})))$/,
                    message: "单位电话格式不合法"
                }
            }
        },
        agentEmail: {
            validators: {
                notEmpty: {
                    message: '电子邮箱不能为空'
                },
                regexp: {
                    regexp: /[\w!#$%&'*+/=?^_`{|}~-]+(?:\.[\w!#$%&'*+/=?^_`{|}~-]+)*@(?:[\w](?:[\w-]*[\w])?\.)+[\w](?:[\w-]*[\w])?/,
                    message: "电子邮箱格式不正确"
                }
            }
        }
    }
};

var enterpriseCountDown = 0;
var enterpriseSmsBtn = $("#enterprise_sms_btn");
var persionCountDown = 0;
var psSmsBtn = $("#ps_sms_btn");
var lock = false;

Register.addSubmit = function () {

    var regType = $(".active").attr("regType");
    if (regType == "en") {                                                          //企业用户注册
        Register.enterpriseUserRegister();
    } else if (regType == "ps") {                                                   //个人用户注册
        Register.personUserRegister();
    }
};

/**
 * 验证数据
 */
Register.validate = function () {

    $('#ep_form').data("bootstrapValidator").resetForm();
    $('#ep_form').bootstrapValidator('validate');
    return $("#ep_form").data('bootstrapValidator').isValid();
}



var isDis = false;
Register.enterpriseUserRegister = function () {

    var type = $("#type").val();
    var special = $("#ep_form .active").attr("special");
    $("#special").val(special)
    $('#ep_form').bootstrapValidator({
        feedbackIcons: {
            valid: 'glyphicon glyphicon-ok',
            invalid: 'glyphicon glyphicon-remove',
            validating: 'glyphicon glyphicon-refresh'
        },
        group: '.rowGroup',
        fields: Register.validateFields,
        live: 'enabled',
        message: '该字段不能为空'
    });
    //初始化
    $("#tab-3 .form-control").attr("disabled", "disabled");
    $("#tab-4 .form-control").attr("disabled", "disabled");
    $("#tab-5 .form-control").attr("disabled", "disabled");
    $("#tab-6 .form-control").attr("disabled", "disabled");
    $("#tab-7 .form-control").attr("disabled", "disabled");
    $('#ep_form').bootstrapValidator("addField", "name", {validators: {notEmpty: {message: '单位/企业名称不能为空'}}});
    $('#ep_form').bootstrapValidator("addField", "name", {validators: {notEmpty: {message: '所属街道不能为空'}}});
    $('#ep_form').bootstrapValidator("addField", "address", {validators: {notEmpty: {message: '单位/企业地址不能为空'}}});
    $('#ep_form').bootstrapValidator("addField", "ephone", {validators: {
            notEmpty: {
                message: '单位/企业电话不能为空'
            }, regexp: {
                regexp: /(^(\d{11})|^((\d{7,8})|(\d{4}|\d{3})-(\d{7,8})|(\d{4}|\d{3})-(\d{7,8})-(\d{4}|\d{3}|\d{2}|\d{1})|(\d{7,8})-(\d{4}|\d{3}|\d{2}|\d{1})))$/,
                message: "单位/企业电话格式不合法"
            }
        }}
    );
    $('#ep_form').bootstrapValidator("removeField", "idCard");
    $('#ep_form').bootstrapValidator("removeField", "legal");
    $('#ep_form').bootstrapValidator("removeField", "bankCard");
    $('#ep_form').bootstrapValidator("removeField", "bankNetwork");
    $('#ep_form').bootstrapValidator("removeField", "bank");
    $('#ep_form').bootstrapValidator("removeField", "medicalCommunityId");
    $('#ep_form').bootstrapValidator("removeField", "isGeneral");
    $('#ep_form').bootstrapValidator("removeField", "province");
    $('#ep_form').bootstrapValidator("removeField", "city");
    $('#ep_form').bootstrapValidator("removeField", "county");
    switch (special) {
        case 'qiye':
            $("#tab-3 .form-control").removeAttr("disabled");
            $('#ep_form').bootstrapValidator("addField", "idCard", {validators: {notEmpty: {message: '统一社会信用代码不能为空'}}});
            $('#ep_form').bootstrapValidator("addField", "legal", {validators: {notEmpty: {message: '法人代表不能为空'}}});//, regexp: {regexp: /^[\u4e00-\u9fa5]{1,50}$/, message: "法人代表只允许中文"}
            if (type == 1) {
                $('#ep_form').bootstrapValidator("addField", "bankCard", {validators: {notEmpty: {message: '开户银行账号不能为空'}}});
                $('#ep_form').bootstrapValidator("addField", "bankNetwork", {validators: {notEmpty: {message: '开户银行网点不能为空'},
                        regexp: {
                            regexp: /^[\u4e00-\u9fa5]*银行[\u4e00-\u9fa5]*$/,
                            message: "开户银行网点格式不正确"
                        }}});
                $('#ep_form').bootstrapValidator("addField", "bank", {validators: {notEmpty: {message: '开户银行不能为空'}, regexp: {
                            regexp: /^[\u4e00-\u9fa5]*$/,
                            message: "开户银行必须为中文"
                        }}});
            }
            var prefix = '企业';
            break;
        case 'minfei':
            $("#tab-5 .form-control").removeAttr("disabled");
            $('#ep_form').bootstrapValidator("addField", "idCard", {validators: {notEmpty: {message: '统一社会信用代码不能为空'}}});
            $('#ep_form').bootstrapValidator("addField", "legal", {validators: {notEmpty: {message: '法人代表不能为空'}}});//, regexp: {regexp: /^[\u4e00-\u9fa5]{1,50}$/, message: "法人代表只允许中文"}
            $('#ep_form').bootstrapValidator("addField", "bankCard", {validators: {notEmpty: {message: '开户银行账号不能为空'}}});
            $('#ep_form').bootstrapValidator("addField", "bankNetwork", {validators: {notEmpty: {message: '开户银行网点不能为空'},
                    regexp: {
                        regexp: /^[\u4e00-\u9fa5]*银行[\u4e00-\u9fa5]*$/,
                        message: "开户银行网点格式不正确"
                    }}});
            $('#ep_form').bootstrapValidator("addField", "bank", {validators: {notEmpty: {message: '开户银行不能为空'}, regexp: {
                        regexp: /^[\u4e00-\u9fa5]*$/,
                        message: "开户银行必须为中文"
                    }}});
            var prefix = '企业';
            break;
        case 'shiye':
            $("#tab-4 .form-control").removeAttr("disabled");
            var prefix = '单位';
            break;
        case 'weijian':
            $("#tab-6 .form-control").removeAttr("disabled");
            $('#ep_form').bootstrapValidator("addField", "name", {validators: {notEmpty: {message: '医院名称不能为空'}}});
            $('#ep_form').bootstrapValidator("addField", "idCard", {validators: {notEmpty: {message: '登记号不能为空'}}});
            $('#ep_form').bootstrapValidator("addField", "legal", {validators: {notEmpty: {message: '法人代表不能为空'}}});
            $('#ep_form').bootstrapValidator("addField", "ephone", {validators: {notEmpty: {message: '医院电话不能为空'}}});
            $('#ep_form').bootstrapValidator("addField", "medicalCommunityId", {validators: {notEmpty: {message: '请选择医共体'}}});
            $('#ep_form').bootstrapValidator("addField", "isGeneral", {validators: {notEmpty: {message: '请选择是否总院'}}});
            $('#ep_form').bootstrapValidator("addField", "province", {validators: {notEmpty: {message: '请选择医院所在省份'}}});
            $('#ep_form').bootstrapValidator("addField", "city", {validators: {notEmpty: {message: '请选择医院所在市'}}});
            $('#ep_form').bootstrapValidator("addField", "county", {
                validators: {
                    callback: {
                        message: "请选择医院所在县/区",
                        callback: function (value, validator) {
                            if ($("#wj_province").val() > 0 && $("#wj_city").val() > 0 && $("#wj_county option").length > 1 && $("#wj_county option:selected").length == 0) {
                                //当省市都有值时，如果县有列表，必选
                                return false;
                            }
                            return true;
                        }
                    }
                }
            });
            $('#ep_form').bootstrapValidator("addField", "address", {validators: {notEmpty: {message: '请填写医院详细地址'}}});
            $('#ep_form').bootstrapValidator("addField", "bankCard", {validators: {notEmpty: {message: '银行账号不能为空'}}});
            $('#ep_form').bootstrapValidator("addField", "bank", {validators: {notEmpty: {message: '开户银行不能为空'}, regexp: {
                        regexp: /^[\u4e00-\u9fa5]*$/,
                        message: "开户银行必须为中文"
                    }}});
            $('#ep_form').bootstrapValidator("addField", "bankNetwork", {validators: {notEmpty: {message: '开户银行网点不能为空'},
                    regexp: {
                        regexp: /^[\u4e00-\u9fa5]*银行[\u4e00-\u9fa5]*$/,
                        message: "开户银行网点格式不正确"
                    }}});
            $('#ep_form').bootstrapValidator("removeField", "street");
            var prefix = "医院";
            break;
        case 'gaojiao':
            $("#tab-7 .form-control").removeAttr("disabled");
            $('#ep_form').bootstrapValidator("addField", "idCard", {validators: {notEmpty: {message: '统一社会信用代码不能为空'}}});
            $('#ep_form').bootstrapValidator("addField", "legal", {validators: {notEmpty: {message: '法人代表不能为空'}}});
            $('#ep_form').bootstrapValidator("addField", "ephone", {validators: {notEmpty: {message: '学校电话不能为空'}}});
            $('#ep_form').bootstrapValidator("addField", "province", {validators: {notEmpty: {message: '请选择学校所在省份'}}});
            $('#ep_form').bootstrapValidator("addField", "city", {validators: {notEmpty: {message: '请选择学校所在市'}}});
            $('#ep_form').bootstrapValidator("addField", "county", {
                validators: {
                    callback: {
                        message: "请选择学校所在县/区",
                        callback: function (value, validator) {
                            if ($("#gj_province").val() > 0 && $("#gj_city").val() > 0 && $("#gj_county option").length > 1 && $("#gj_county option:selected").length == 0) {
                                //当省市都有值时，如果县有列表，必选
                                return false;
                            }
                            return true;
                        }
                    }
                }
            });
            $('#ep_form').bootstrapValidator("addField", "address", {validators: {notEmpty: {message: '请填写学校详细地址'}}});
            $('#ep_form').bootstrapValidator("removeField", "street");
            var prefix = "学校";
            break;
    }


    if (!Register.validate()) {

        return;
    }


    isDis = $("#type").prop("disabled");
    var source = $("#source").val();
    switch (special) {
        case 'qiye':
            var username = $("#username").val();
            var password = $("#password").val();
            var rePassword = $("#re_password").val();
            var name = $("#name").val();
            var idCard = $("#idCard").val();
            var legal = $("#legal").val();
            var street = $("#street").val();
            var address = $("#address").val();
            var ephone = $("#ephone").val();
            var bankCard = $("#bankCard").val();
            var bank = $("#bank").val();
            var bankNetwork = $("#bankNetwork").val();
            break;
        case 'minfei':
            var username = $("#mf_username").val();
            var password = $("#mf_password").val();
            var rePassword = $("#mf_re_password").val();
            var name = $("#mf_name").val();
            var idCard = $("#mf_idCard").val();
            var legal = $("#mf_legal").val();
            var street = $("#mf_street").val();
            var address = $("#mf_address").val();
            var ephone = $("#mf_ephone").val();
            var bankCard = $("#mf_bankCard").val();
            var bank = $("#mf_bank").val();
            var bankNetwork = $("#mf_bankNetwork").val();
            break;
        case 'shiye':
            var username = $("#sy_username").val();
            var password = $("#sy_password").val();
            var rePassword = $("#sy_re_password").val();
            var name = $("#sy_name").val();
            var street = $("#sy_street").val();
            var address = $("#sy_address").val();
            var ephone = $("#sy_ephone").val();
            break;
        case "weijian":
            var username = $("#wj_username").val();
            var password = $("#wj_password").val();
            var rePassword = $("#wj_re_password").val();
            var name = $("#wj_name").val();
            var idCard = $("#wj_idCard").val();
            var legal = $("#wj_legal").val();
            var ephone = $("#wj_ephone").val();
            var medicalCommunityId = $("#wj_medicalCommunityId").val();
            var isGeneral = $("#wj_isGeneral").val();
            var province = $("#wj_province").val();
            var city = $("#wj_city").val();
            var county = $("#wj_county").val();
            var address = $("#wj_address").val();
            var bankCard = $("#wj_bankCard").val();
            var bank = $("#wj_bank").val();
            var bankNetwork = $("#wj_bankNetwork").val();
            break;
        case "gaojiao":
            var username = $("#gj_username").val();
            var password = $("#gj_password").val();
            var rePassword = $("#gj_re_password").val();
            var name = $("#gj_name").val();
            var idCard = $("#gj_idCard").val();
            var legal = $("#gj_legal").val();
            var ephone = $("#gj_ephone").val();
            var province = $("#gj_province").val();
            var city = $("#gj_city").val();
            var county = $("#gj_county").val();
            var address = $("#gj_address").val();
            break;
    }

    var agentName = $("#agentName").val();
    var agentPhone = $("#agentPhone").val();
    var verificationCode = $("#verificationCode").val();

    if (isDis) {
        $("#type").removeAttr("disabled");
    }
    var agencyType = $("#agencyType").val();
    var agentEmail = $("#agentEmail").val();
    var enterpriseTag = $("#enterpriseTag").val();
    var enterpriseType = $("#enterpriseType").val();
    var industryFieldNew = $("#industryFieldNew").val();
    var industryFieldOld = $("#industryFieldOld").val();

    if (username == null || username == '') {
        Feng.info("请填写账号!");
        return;
    }
    if (username.length > 50) {
        Feng.info("账号最多50个字符!");
        return;
    }
    if (source != 2) {
        if (password == null || password == '') {
            Feng.info("请填写密码!");
            return;
        }
        if (!/^(?=.*\d)(?=.*[a-zA-Z]).{8,20}$/.test(password)) {
            Feng.info("密码格式错误，密码由字母与数字组成，且长度必须8个字符及以上!");
            return;
        }
        if (rePassword == null || rePassword == '') {
            Feng.info("请填写重复密码!");
            return;
        }
        if (password != rePassword) {
            Feng.info("两次密码填写不一致!");
            return;
        }
    }
    if (name == null || name == '') {
        Feng.info("请填写" + prefix + "名称!");
        return;
    }
    /*if (!/^([\u4E00-\u9FA5]|\(|\)|\（|\）){1,100}$/.test(name)) {
     Feng.info(prefix + "名称只能输入中文 !");
     return;
     }*/
    if (name.length > 100) {
        Feng.info(prefix + "名称最多100个字符!");
        return;
    }
    if (ephone == null || ephone == '') {
        Feng.info("请填写" + prefix + "电话");
        return;
    }

    if ((street == null || street == '') && special != "weijian" && special != "gaojiao") {
        Feng.info("请选择所属街道!");
        return;
    }

    if (address == null || address == '') {
        Feng.info("请填写" + prefix + "地址!");
        return;
    }

    switch (special) {
        case 'qiye':
            if ((idCard == null || idCard == '')) {
                Feng.info("请填写统一社会信用代码!");
                return;
            }
            if (idCard.length > 40) {
                Feng.info("统一社会信用代码最多40个字符!");
                return;
            }
            if (legal == null || legal == '') {
                Feng.info("请填写法人代表!");
                return;
            }

            if (type == null || type == '') {
                Feng.info("请选择申报类型!");
                return;
            }
            /*if (!/^[\u4e00-\u9fa5]{1,50}$/.test(legal)) {
             Feng.info("法人代表只能输入中文 !");
             return;
             }*/
            if (type == 1) {
                if (bankCard == null || bankCard == '') {
                    Feng.info("请填写企业银行账号!");
                    return;
                }
                if (bank == null || bank == '') {
                    Feng.info("请填写企业开户银行!");
                    return;
                }
                if (bankNetwork == null || bankNetwork == '') {
                    Feng.info("请填写企业开户银行网点");
                    return;
                }
            }
            var x = document.getElementById("imgurl").value;
            if (x == "") {
                Feng.info("请上传营业执照照片!");
                return;
            }
            if (!Feng.chkFileInvalid(document.getElementById("imgurl").files[0], 5, 10, ["image/jpeg", "image/gif", "image/png", "image/jpg", "application/pdf"], "营业执照只允许上传PDF或图片")) {
                return;
            }
            if (type == 1) {
                var xx = document.getElementById("bankImg").value;
                if (xx == "") {
                    Feng.info("请上传开户银行许可证!");
                    return;
                }
                if (!Feng.chkFileInvalid(document.getElementById("bankImg").files[0], 5, 10, ["image/jpeg", "image/gif", "image/png", "image/jpg", "application/pdf"], "开户银行许可证只允许上传PDF或图片")) {
                    return;
                }
                if (agencyType == null || agencyType == '') {
                    Feng.info("请选择机构类型");
                    return;
                }
                switch (agencyType) {
                    case "1":
                        if (industryFieldNew == null || industryFieldNew == '') {
                            Feng.info("请选择产业领域");
                            return;
                        }
                        if (industryFieldOld == null || industryFieldOld == '') {
                            Feng.info("请选择行业领域");
                            return;
                        }
                        var xxx = document.getElementById("domainImg").value;
                        if (xxx == "") {
                            Feng.info("请上传行业领域佐证材料!");
                            return;
                        }
                        if (!Feng.chkFileInvalid(document.getElementById("domainImg").files[0], 5, 10, ["image/jpeg", "image/gif", "image/png", "image/jpg", "application/pdf"], "行业领域佐证材料只允许上传PDF或图片")) {
                            return;
                        }
                        break;
                    case "2":
                        break;
                }
                if (enterpriseTag == null || enterpriseTag == '') {
                    Feng.info("请选择企业标签!");
                    return;
                }
                if (enterpriseType == null || enterpriseType == '') {
                    Feng.info("请选择企业类型!");
                    return;
                }
                var checkType = ["guishang", "gaoxinjishu", "zhuanjingtexin"];
                if (checkType.indexOf(enterpriseType) > -1) {
                    var typeImg = document.getElementById("typeImg").value;
                    if (typeImg == "") {
                        Feng.info("规上、高新技术、专精特新企业需要上传佐证材料!");
                        return;
                    }
                    if (!Feng.chkFileInvalid(document.getElementById("typeImg").files[0], 5, 10, ["image/jpeg", "image/gif", "image/png", "image/jpg", "application/pdf"], "规上、高新技术、专精特新企业佐证材料只允许上传PDF或图片")) {
                        return;
                    }
                }
            }
            break;
        case 'minfei':
            if ((idCard == null || idCard == '')) {
                Feng.info("请填写统一社会信用代码!");
                return;
            }
            if (idCard.length > 40) {
                Feng.info("统一社会信用代码最多40个字符!");
                return;
            }
            if (legal == null || legal == '') {
                Feng.info("请填写法人代表!");
                return;
            }
            /*if (!/^[\u4e00-\u9fa5]{1,50}$/.test(legal)) {
             Feng.info("法人代表只能输入中文 !");
             return;
             }*/
            if (bankCard == null || bankCard == '') {
                Feng.info("请填写机构银行账号!");
                return;
            }
            if (bank == null || bank == '') {
                Feng.info("请填写机构开户银行!");
                return;
            }
            if (bankNetwork == null || bankNetwork == '') {
                Feng.info("请填写机构开户银行网点");
                return;
            }
            var x = document.getElementById("mf_imgurl").value;
            if (x == "") {
                Feng.info("请上传营业执照照片!");
                return;
            }
            if (!Feng.chkFileInvalid(document.getElementById("mf_imgurl").files[0], 5, 10, ["image/jpeg", "image/gif", "image/png", "image/jpg", "application/pdf"], "营业执照只允许上传PDF或图片")) {
                return;
            }
            var xx = document.getElementById("mf_bankImg").value;
            if (xx == "") {
                Feng.info("请上传开户银行许可证!");
                return;
            }
            if (!Feng.chkFileInvalid(document.getElementById("mf_bankImg").files[0], 5, 10, ["image/jpeg", "image/gif", "image/png", "image/jpg", "application/pdf"], "开户银行许可证只允许上传PDF或图片")) {
                return;
            }

            break;
        case 'shiye':
            var x = document.getElementById("sy_imgurl").value;
            if (x == "") {
                Feng.info("请上传法人证或批文!");
                return;
            }
            if (!Feng.chkFileInvalid(document.getElementById("sy_imgurl").files[0], 5, 10, ["image/jpeg", "image/gif", "image/png", "image/jpg", "application/pdf"], "法人证或批文只允许上传PDF或图片")) {
                return;
            }
            break;
        case "weijian":
            var x = document.getElementById("wj_imgurl").value;
            if (x == "") {
                Feng.info("请上传医疗机构执业许可证!");
                return;
            }
            if (!Feng.chkFileInvalid(document.getElementById("wj_imgurl").files[0], 5, 10, ["image/jpeg", "image/gif", "image/png", "image/jpg", "application/pdf"], "医疗机构执业许可证只允许上传PDF或图片")) {
                return;
            }
            var xx = document.getElementById("wj_bankImg").value;
            if (xx == "") {
                Feng.info("请上传开户银行许可证!");
                return;
            }
            if (!Feng.chkFileInvalid(document.getElementById("wj_bankImg").files[0], 5, 10, ["image/jpeg", "image/gif", "image/png", "image/jpg", "application/pdf"], "开户银行许可证只允许上传PDF或图片")) {
                return;
            }
            break;
        case "gaojiao":
            var x = document.getElementById("gj_imgurl").value;
            if (x == "") {
                Feng.info("请上传办学许可证、法人证书或登记证书!");
                return;
            }
            if (!Feng.chkFileInvalid(document.getElementById("gj_imgurl").files[0], 5, 10, ["image/jpeg", "image/gif", "image/png", "image/jpg", "application/pdf"], "办学许可证、法人证书或登记证书只允许上传PDF或图片")) {
                return;
            }
            break;
    }



    if (agentName == null || agentName == '') {
        Feng.info("请填写人才联络员!");
        return;
    }
    if (agentName.length > 30) {
        Feng.info("人才联络员最多30个字符!");
        return;
    }
    if (agentPhone == null || agentPhone == '') {
        Feng.info("请填写人才联络员电话!");
        return;
    }

    if (verificationCode == null || verificationCode == '') {
        Feng.info("请填写手机验证码!");
        return;
    }

    if (agentEmail == null || agentEmail == '') {
        Feng.info("请填写电子邮箱!");
        return;
    }


    var xxxx = document.getElementById("beian").value;
    if (xxxx == "") {
        Feng.info("请上传人才联络员信息备案表!");
        return;
    }
    if (!Feng.chkFileInvalid(document.getElementById("beian").files[0], 5, 10, ["image/jpeg", "image/gif", "image/png", "image/jpg", "application/pdf"], "人才联络员信息备案表只允许上传PDF或图片")) {
        return;
    }
    if (!/(^(\d{11})|^((\d{7,8})|(\d{4}|\d{3})-(\d{7,8})|(\d{4}|\d{3})-(\d{7,8})-(\d{4}|\d{3}|\d{2}|\d{1})|(\d{7,8})-(\d{4}|\d{3}|\d{2}|\d{1})))$/.test(ephone)) {
        Feng.info(prefix + "电话格式不合法!");
        return;
    }
    if (!/(^(\d{11})|^((\d{7,8})|(\d{4}|\d{3})-(\d{7,8})|(\d{4}|\d{3})-(\d{7,8})-(\d{4}|\d{3}|\d{2}|\d{1})|(\d{7,8})-(\d{4}|\d{3}|\d{2}|\d{1})))$/.test(agentPhone)) {
        Feng.info("人才联络员电话格式不合法!");
        return;
    }
    if (!/[\w!#$%&'*+/=?^_`{|}~-]+(?:\.[\w!#$%&'*+/=?^_`{|}~-]+)*@(?:[\w](?:[\w-]*[\w])?\.)+[\w](?:[\w-]*[\w])?/.test(agentEmail)) {
        Feng.info("电子邮箱格式不合法!");
        return;
    }
    if (!lock) {
        lock = true;
    } else {
        Feng.info("不能重复点击");
        return;
    }
    $("#ep_form")[0].submit();
};

Register.changeEnterpriseType = function () {
    var enterpriseType = $("#enterpriseType").val();
    switch (enterpriseType) {
        case "guishang":
            console.log("规上")
            $("#typeName").text("规上");
            $("td.typeUploader").css("display", "table-cell");
            break;
        case "gaoxinjishu":
            console.log("高新技术")
            $("#typeName").html("高新技术");
            $("td.typeUploader").css("display", "table-cell");
            break;
        case "zhuanjingtexin":
            console.log("专精特新")
            $("#typeName").html("专精特新");
            $("td.typeUploader").css("display", "table-cell");
            break;
        default:
            $("td.typeUploader").css("display", "none");
            break;
    }
};

Register.personUserRegister = function () {
    var source = $("#ps_source").val();
    var username = $("#ps_username").val();
    var password = $("#ps_password").val();
    var rePassword = $("#ps_re_password").val();
    var name = $("#ps_name").val();
    var sex = $("#ps_sex").val();
    var idCard = $("#ps_idCard").val();
    var phone = $("#ps_phone").val();
    var verificationCode = $("#ps_verificationCode").val();
    if (username == null || username == '') {
        Feng.info("请填写账号!");
        return;
    }
    if (username.length > 50) {
        Feng.info("账号最多20个字符!");
        return;
    }
    if (source != 2) {
        if (password == null || password == '') {
            Feng.info("请填写密码!");
            return;
        }
        if (rePassword == null || rePassword == '') {
            Feng.info("请填写重复密码!");
            return;
        }
        if (password != rePassword) {
            Feng.info("两次密码填写不一致!");
            return;
        }
    }
    if (name == null || name == '') {
        Feng.info("请填写姓名!");
        return;
    }
    if (name.length > 20) {
        Feng.info("姓名最多20个字符!");
        return;
    }
    if (sex == null || sex == '') {
        Feng.info("请选择性别!");
        return;
    }
    if (idCard == null || idCard == '') {
        Feng.info("请填写身份证号!");
        return;
    }
    if (phone == null || phone == '') {
        Feng.info("请填写手机号!");
        return;
    }
    if (verificationCode == null || verificationCode == '') {
        Feng.info("请填写手机验证码!")
        return;
    }
    if (!/0?(13|14|15|16|17|18|19)[0-9]{9}/.test(phone)) {
        Feng.info("手机号格式不合法!");
        return;
    }
    var da = {"source": source, "username": username, "password": password, "name": name, "sex": sex, "idCard": idCard, "phone": phone, "verificationCode": verificationCode};
    var ajax = new $ax("/common/auth/person_register", function (data) {
        Feng.info(data.msg);
        if (data.code == 200) {
            parent.layer.close(window.parent.Login.layerIndex);
        }
    }, function (data) {
        Feng.error("操作失败!" + data.responseJSON.message + "!");
    });
    ajax.set(da);
    ajax.start();
};

Register.getEnterpriseSms = function () {
    var agentPhone = $("#agentPhone").val();
    if (agentPhone == null || agentPhone == "") {
        Feng.info("请填写人才联络员手机号!");
        return;
    }
    agentPhone = $.trim(agentPhone);
    if (!Feng.checkMobilePhoneNum(agentPhone)) {
        Feng.info("手机号格式有误，请填写正确的手机号码!");
        return;
    }

    Register.enterpriseBtnCountDown();

    var ajax = new $ax(Feng.ctxPath + "/common/auth/verificationCode?phone=" + agentPhone + "&type=1", function (data) {
        Feng.info(data.msg);
    }, function (data) {
        Feng.error("操作失败!" + data.responseJSON.message + "!");
    });
    ajax.set(null);
    ajax.start();
};

Register.enterpriseBtnCountDown = function () {
    if (enterpriseCountDown == 0) {
        enterpriseCountDown = 60;
    } else if (enterpriseCountDown == 1) {
        enterpriseSmsBtn.removeAttr("disabled");
        enterpriseSmsBtn.html("获取验证码");
        enterpriseCountDown = 0;
        return;
    }
    enterpriseSmsBtn.attr("disabled", true);
    enterpriseSmsBtn.html(enterpriseCountDown + "秒");
    enterpriseCountDown--;
    setTimeout("Register.enterpriseBtnCountDown()", 1000);
};

Register.getPersionSms = function () {
    var phone = $("#ps_phone").val();
    if (phone == null || phone == "") {
        Feng.info("请填写手机号!");
        return;
    }
    phone = $.trim(phone);
    if (!Feng.checkMobilePhoneNum(phone)) {
        Feng.info("手机号格式有误，请填写正确的手机号码!");
        return;
    }
    Register.getPersionBtnCountDown();
    var ajax = new $ax(Feng.ctxPath + "/common/auth/verificationCode?phone=" + phone + "&type=1", function (data) {
        Feng.info(data.msg);
    }, function (data) {
        Feng.error("操作失败!" + data.responseJSON.message + "!");
    });
    ajax.set(null);
    ajax.start();
};

Register.getPersionBtnCountDown = function () {
    if (persionCountDown == 0) {
        persionCountDown = 60;
    } else if (persionCountDown == 1) {
        psSmsBtn.removeAttr("disabled");
        psSmsBtn.html("获取验证码");
        persionCountDown = 0;
        return;
    }
    psSmsBtn.attr("disabled", true);
    psSmsBtn.html(persionCountDown + "秒");
    persionCountDown--;
    setTimeout("Register.getPersionBtnCountDown()", 1000);
};

/**
 * 企业用户注册回调
 */
Register.epCallBack = function (data) {
    lock = false;
    var nowDis = $("#type").prop("disabled");
    if (isDis != nowDis) {
        $("#type").attr("disabled", "disabled");
    }
    Feng.info(data.msg);
    if (data.code == 200) {
        parent.layer.close(window.parent.Login.layerIndex);
    }
};
Register.typeChange = function () {
    $("#type").removeAttr("disabled");
    var type = $("#type").val();
    if (type == 1) {
        $(".agencyType").attr("style", "display:block");

        $("#bankCard").parent().find("span").css("display", "");
        $("#bankNetwork").parent().find("span").css("display", "");
        $("#bank").parent().find("span").css("display", "");
        $("#bankImg").parent().find("span").css("display", "");
    } else {
        $(".agencyType").attr("style", "display:none");
        $("#typeGroup").attr("style", "display:none");
        $("#enterpriseTag,#industryFieldNew,#industryFieldOld,#enterpriseType").val("");

        $("#bankCard").parent().find("span").css("display", "none");
        $("#bankNetwork").parent().find("span").css("display", "none");
        $("#bank").parent().find("span").css("display", "none");
        $("#bankImg").parent().find("span").css("display", "none");
    }
}
Register.agencyTypeChange = function () {
    var agencyType = $("#agencyType").val();
    switch (agencyType) {
        case "1":
            $("#typeGroup").attr("style", "display:block");
            $(".agencyType1").attr("style", "");
            $(".agencyType2").attr("style", "");
            break;
        case "2":
            $("#typeGroup").attr("style", "display:block");
            $(".agencyType1").attr("style", "display:none");
            $(".agencyType2").attr("style", "");
            $("#industryFieldNew").val("");
            $("#industryFieldOld").val("");
            break;
        default:
            $("#typeGroup").attr("style", "display:none");
            break;
    }
}
Register.industryChange = function () {
    var industryNew = $("#industryFieldNew").val();
    var arr = [{"name": "industryFieldOld", "code": industryNew + "_field"}];
    Feng.findChildDictBatch(JSON.stringify(arr));
}


Register.afterSelectProvince = function (prefix) {
    var province = $("#" + prefix + "_province").val();
    $("#" + prefix + "_city").empty();
    $("#" + prefix + "_county").empty();
    if (province == null || province == '') {
        return;
    }
    Feng.addAjaxSelect({
        "id": prefix + "_city",
        "displayCode": "code",
        "displayName": "name",
        "type": "GET",
        "url": Feng.ctxPath + "/common/tool/findCityByProvinceSelect/code/" + province
    });
}
/**
 * 加载县
 */
Register.afterSelectCity = function (prefix) {
    var city = $("#" + prefix + "_city").val();
    $("#" + prefix + "_county").empty();
    if (city == null || city == '') {
        return;
    }
    Feng.addAjaxSelect({
        "id": prefix + "_county",
        "displayCode": "code",
        "displayName": "name",
        "type": "GET",
        "url": Feng.ctxPath + "/common/tool/findCountyByCitySelect/code/" + city
    });
}

$(function () {
    $('#ep_form').bootstrapValidator({
        feedbackIcons: {
            valid: 'glyphicon glyphicon-ok',
            invalid: 'glyphicon glyphicon-remove',
            validating: 'glyphicon glyphicon-refresh'
        },
        group: '.rowGroup',
        fields: Register.validateFields,
        live: 'enabled',
        message: '该字段不能为空'
    });

    var userType = Feng.getUrlValue("userType");
    var username = Feng.getUrlValue("username");
    var name = Feng.getUrlValue("name");
    var idCard = Feng.getUrlValue("idCard");
    var type = Feng.getUrlValue("type");
    if (userType == 1) {			//企业用户trigger
        $("#source").val(2);
        $("#username").val(username).attr("readonly", "readonly");
        $("#name").val(name).attr("readonly", "readonly");
        $("#idCard").val(idCard).attr("readonly", "readonly");
        $("#type").val(type).trigger("change");
        $("#type").attr("disabled", "disabled");
        $("#password").val("").attr("placeholder", "密码为聚才网账号密码").attr("readonly", "readonly");
        $("#re_password").val("").attr("placeholder", "密码为聚才网账号密码").attr("readonly", "readonly");
        $("#personTab").css("pointer-events", "none");
    } else if (userType == 2) {	//个人用户
        $("#personTab").css("pointer-events", "block");
        $("#personTab").children().click();
        $("#ps_source").val(2);
        $("#ps_username").val(name).attr("readonly", "readonly");
        $("#ps_idCard").val(idCard).attr("readonly", "readonly");
        $("#ps_password").val("").attr("placeholder", "密码为聚才网账号密码").attr("readonly", "readonly");
        $("#ps_re_password").val("").attr("placeholder", "密码为聚才网账号密码").attr("readonly", "readonly");
        $("#enTab").css("pointer-events", "none");
    } else {						//无

    }
    var arr = [
        {"name": "street", "code": "street"},
        {"name": "enterpriseTag", "code": "enterprise_tag"},
        {"name": "organizationTag", "code": "organization_tag"},
        {"name": "institutionTag", "code": "institution_tag"},
        {"name": "industryFieldNew", "code": "industry_field"},
        {"name": "enterpriseType", "code": "enterprise_type"},
        {"name": "sy_street", "code": "street"},
        {"name": "mf_street", "code": "street"},
        {"name": "agencyType", "code": "agency_type"}];
    Feng.findChildDictBatch(JSON.stringify(arr));
    $("#imgurl,#sy_imgurl,#mf_imgurl,#wj_imgurl,#wj_bankImg,#gj_imgurl,#bankImg,#mf_bankImg,#sy_bankImg,#beian,#domainImg,#typeImg").change(function (e) {
        var that = this;
        if (!Feng.chkFileInvalid(that.files[0], 5, 10)) {
            return;
        }
        var file = that.files[0];
        var imgSrc;
        var reader = new FileReader();
        reader.readAsDataURL(file);
        reader.onload = function () {
            if (Feng.isImg(file.type)) {
                imgSrc = this.result;
                $(that).prev("img").attr("src", imgSrc);
            } else {
                $(that).prev("img").attr("src", Feng.ctxPath + "/static/img/Pdf.png");
            }
        };
    });

    //加载省份
    Feng.addAjaxSelect({
        "id": "wj_province",
        "displayCode": "code",
        "displayName": "name",
        "type": "GET",
        "url": Feng.ctxPath + "/common/tool/getProvinceSelect"
    });
    var provinceList = $("#wj_province option").clone();
    $("#gj_province").html(provinceList);
});