<extend name="Public/apply" />

<block name="location">

	<a class="z_nav" href="{:U('Apply/apply')}">账号中心</a>

	<a class="z_nav curt_nav" href="{:U('Apply/apply')}">基本信息</a>

</block>

<block name="body" >

        <div class="main">

            <div class="container user_pt clearfix">

                <ol class="breadcrumb">

                    <li><span class="iconfont icon-home" aria-hidden="true"></span><a href="{:U('Index/index')}">首页</a></li>

                    <li><a class="" href="{:U('manage/index')}">账号中心</a></li>

                    <li class="active">基本信息</li>

                </ol>

                <div class="matter clearfix matter_box matter_box_tag" style="min-height:600px;">

                    <style>

                        .matter_box_tag .title {

                            margin: 0 auto;

                            height: 44px;

                            border-bottom: #e5e5e5 solid 1px;

                            width: 100%;

                            line-height: 44px;

                        }



                        .matter_box_tag .title span {

                            color: #000;

                            font-size: 20px;

                            margin-left: 40px;

                        }



                        .matter_box_tag .title p {

                            color: #7f7f7f;

                            font-size: 14px;

                            margin-left: 15px;

                            display: inline;

                        }



                        .matter_box_tag .desc {

                            color: #7f7f7f;

                            font-size: 14px;

                            margin: 18px 0 0 225px;

                            width: 605px;

                            display: block;

                        }



                        .matter_box_tag .certification {

                            margin: 62px auto 0;

                        }



                        .matter_box_tag .certification .developer {

                            float: left;

                            margin-left: 138px;

                        }



                        .matter_box_tag .certification .developer img {

                            width: 300px;

                            height: 175px;

                            display: block;

                        }



                        .matter_box_tag .certification .developer dd {

                        }



                        .matter_box_tag .certification .developer a {

                            display: block;

                            width: 160px;

                            height: 40px;

                            line-height: 40px;

                            text-align: center;

                            font-size: 20px;

                            margin: 10px auto;

                        }

                    </style>

                    <div class="title">

                        <span>开发者认证</span>



                        <p>没有门槛,信息透明</p>

                    </div>

                    <p class="desc">免费注册成为----软件开发者享受完善的产品服务。开发者可以轻松发布,管理自己的应用同时支持查看应用数据,账户报表等信息。</p>

                    <div class="certification clearfix">

                        <dl class="developer">

                            <dt><img src="__IMG__/person.jpg" alt="个人开发者"></dt>

                            <dd><a class="btn btn_primary user_btn matter_create" href="{:U('Apply/personal')}">个人开发者</a></dd>

                        </dl>

                        <dl class="developer">

                            <dt><img src="__IMG__/company.jpg" alt="企业开发者"></dt>

                            <dd><a class="btn btn_primary user_btn matter_create" href="{:U('Apply/company')}">企业开发者</a></dd>

                        </dl>

                    </div>

                    

                </div>

            </div>

        </div>

        <script>

            

            var dever_from = "";



            $(document).ready(function(){

                

                /**

                 * 新增验证方法

                 */

                

                $.validator.addMethod("checkMobile", function(value, element) {

                    var mobile = /^(((13[0-9]{1})|(14[0-9]{1})|(15[0-9]{1})|(17[0-9]{1})|(18[0-9]{1}))+\d{8})$/;

                    var tel = /^\d{3,4}-?\d{7,9}$/;

                    return mobile.test(value)||tel.test(value);

                }, '联系电话格式不正确。<br/>手机参考格式:13666668888。<br/>座机参考格式: 010-66668888。');

                $.validator.addMethod("checkL", function(value, element) {

                    if(value.length!=18){

                        return false;

                    }else{return true;}

                }, '营业执照注册号格式不正确');



            $.validator.addMethod("checkQQWechat", function(value, element){

                var qq = $("input[name='qq']").val();

                var wechat = $("input[name='wx']").val();



                if(qq == "" && wechat == ""){

                    return false;

                }else{

                    return true;

                }

            }, "QQ和微信请至少填写一项!");



            $("input[type='file']").change(function() {

                var thisButton = $(this);

                var target = thisButton.data("target");

                var formName = target + "AjaxFileForm";



                if ($("#" + formName).length < 1) {

                    thisButton.wrap('<form id="' + formName + '" action="http://static.egret.com/uploadt.php" method="post" enctype="multipart/form-data"></form>');

                }

                $("#" + formName).ajaxSubmit({

                    success: function(data) {

                        if (data.code != 0) {

                            thisButton.val("");

                            alert(data.msg);

                        } else {

                            $("#" + target).attr("src", data["data"]["imgUrl"]);

                            $("input[name='" + target + "']").val(data["data"]["filePath"]);

                            thisButton.unwrap();

                        }

                    }

                });

            });



            $("#editButton").click(function(event){

                event.preventDefault();

                $("input").prop("readonly", false);

                $(".hide").removeClass("hide");

                $(".show-form-info").addClass("hide");

                $("select").prop("disabled", false);

                $("input[type='radio']").parent("label").removeClass("disabled");

                $("#cancelEdit").removeClass("hidden").show();

                $("#saveButton").removeClass("hidden").show();

                $("#editButton").hide();

                $(".user_file").removeClass("hidden").show();



                $('#ADDTOPICBLB').addClass('hide');



                $("#saveButton").click(function(){

                    var isOpenToGame = $("input[name='isOpenToGame']").val();

                    var isOpenToChan = $("input[name='isOpenToChan']").val();

                    var param = {};

                    param['checkCode'] = 301;

                    if(isOpenToChan == 0 && isOpenToGame == 0){

                        $("#editForm").submit();

                    }else{

                        $.post("/Ajax/Member.checkStatus", param, function(result){

                            if(result.code != 0){

                                alert(result.msg);

                                return false;

                            }else{

                                $("#editForm").submit();

                            }

                        });

                    }

                });

            });



            checkFields();

            

            // 取消修改

            $("#cancelEdit").click(function(event){

                window.location.href = "base.html";

            });



            // 公司帐号,个人帐号表单

            $("[data-toggle='buttons']").click(function() {

                var label = $("input[type='radio']").parent("label");

                if (!label.hasClass("disabled")) {

                    label.removeClass("btn_primary user_btn").addClass("btn_default user_btn_default");

                    setTimeout(function(){

                        var dom = $("input[type='radio']:checked");

                        var accountType = dom.val();

                        dom.parent("label").removeClass("btn_default user_btn_default").addClass("btn_primary user_btn");

                        if (accountType == "person") {

                            $("[tag='company']").hide();

                            $("[tag='person']").removeClass('hidden');

                            checkFields();



                        } else {

                            $("[tag='company']").show();

                            $("[tag='person']").addClass('hidden');

                            checkFields();

                        }

                    }, 10);

                }

            });



            

            // 表单元素不可用

            $("input").prop("readonly", true);

            $("select").prop("disabled", true);

            });



            var checkFields = function(){

                var accountType = $("input[type='radio']:checked").val();

                var formValidate;



                formValidate = {

                    rules:{

                        firstname: "required",

                        fullname:{

                            required:true

                        },

                        codenum: {

                            required: false//dever_from != 'TOPICBLB' ? true : false  //专题 公司信息 不必填

                        },

                        businessLicense: {

                            required: dever_from != 'TOPICBLB' ? true : false,

                            checkL:true,

                        },

                        linkman: {

                            required: true

                        },

                        mobile: {

                            required: true,

                            checkMobile: true

                        },

                        email: {

                            required: true,

                            email:true

                        },

                        address:{

                            required: true,

                        },

                        qq:{

                            checkQQWechat: true,

                        },

                        wx:{

                            checkQQWechat: true,

                        }

                        ,

                        nickname:{

                            required:true,

                        },

                    },

                    //定义错误消息

                    messages:{



                        fullname:{

                            required:"公司全称不能为空"

                        },

                        codenum: {

                            required: "组织机构代码不能为空"

                        },

                        businessLicense: {

                            required: "营业执照注册号不能为空",

                            checkL:"营业执照注册号格式不正确"

                        },

                        linkman: {

                            required: "联系人不能为空"

                        },

                        mobile: {

                            required: "联系电话不能为空",

                        },

                        email: {

                            required: "邮箱不能为空",

                            email : '邮箱格式不对'

                        },

                        address:{

                            required: "联系地址不能为空",

                        },

                        nickname:{

                            required:"公司简称不能为空",

                        },

                    },

                };

                $("#editForm").validate(formValidate);

                if (accountType == "company") {



                    //定义规则

                    formValidate = {

                        rules:{

                            firstname: "required",

                            fullname:{

                                required:true

                            },

                            codenum: {

                                required: false//dever_from != 'TOPICBLB' ? true : false  //专题 公司信息 不必填

                            },

                            businessLicense: {

                                required: dever_from != 'TOPICBLB' ? true : false,

                                checkL:true,

                            },

                            linkman: {

                                required: true

                            },

                            mobile: {

                                required: true,

                                checkMobile: true

                            },

                            email: {

                                required: true,

                                email:true

                            },

                            address:{

                                required: true,

                            },

                            qq:{

                                checkQQWechat: true,

                            },

                            wx:{

                                checkQQWechat: true,

                            }

                            ,

                            nickname:{

                                required:true,

                            },

                        },

                        //定义错误消息

                        messages:{

                                

                            fullname:{

                                required:"公司全称不能为空"

                            },

                            codenum: {

                                required: "组织机构代码不能为空"

                            },

                            businessLicense: {

                                required: "营业执照注册号不能为空",

                                checkL:"营业执照格式不正确"

                            },

                            linkman: {

                                required: "联系人不能为空"

                            },

                            mobile: {

                                required: "联系电话不能为空",

                            },

                            email: {

                                required: "邮箱不能为空",

                                email : '邮箱格式不对'

                            },

                            address:{

                                required: "联系地址不能为空",

                            },

                            nickname:{

                                required:"公司简称不能为空",

                            },

                        },

                    };



                } else {



                    formValidate = {

                        //定义规则

                        rules:{

                            linkman: {

                                required: true

                            },

                            mobile: {

                                required: true,

                                checkMobile: true

                            },

                            email: {

                                required: true,

                                email:true

                            },

                            address:{

                                required: true,

                            },

                            qq:{

                                checkQQWechat: true,

                            },

                            wx:{

                                checkQQWechat: true,

                            }

                        },

                        //定义错误消息

                        messages:{

                            linkman: {

                                required: "联系人不能为空"

                            },

                            mobile: {

                                required: "联系电话不能为空",

                            },

                            email: {

                                required: "邮箱不能为空",

                                email : '邮箱格式不对'

                            },

                            address:{

                                required: "联系地址不能为空",

                            }

                        },

                    };

                }

                // 表单验证

                $("#editForm").validate(formValidate);

            };

            

            $.VMenu.show('#menu');

            $.VMenu.open('m1.1');

        </script>

</block>