<%@ page language="java" import="java.util.*" contentType="text/html; charset=utf-8"%>
<%@ include file="/WEB-INF/include/taglib.jsp"%>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="renderer" content="webkit">
    <meta name="description" content="">
    <meta name="keywords" content="">
    <link rel="stylesheet" href="${ctxwxsta}/css/public.css">
    <link rel="stylesheet" href="${ctxwxsta}/css/basic.css">
    <link rel="stylesheet" href="/static/weixin/activity/css/SG_area_select.css?v=1.0.6">
    <script src="${ctxwxsta}/js/flexible.js"></script>

    <title>下级信息新增</title>
</head>
<body id="contain">
<form   method="post"   id="defaultForm">

    <div class="contain">
        <div class="bai-head">
            <span>下级信息新增</span>
            <a href="javascript:;" onclick="fanhui()" class="left">
                <img src="${ctxwxsta}/images/head-left.png"/>
            </a>
        </div>
        <div class="lower-level">
            <h2>基础信息</h2>
            <ul class="basic-information">
                <li>
                    <span>名称</span>

                    <input type="text" placeholder="请输入名称" name="companyName"  id="companyName" class="input-text">
                </li>
                <li>
                    <span>企业/个人</span>
                    <p id="enterprise">

                    </p>
                    <select name="terminalType" id="ssss_enterprise" style="display: none;">
                        <option value="1" >企业</option>
                        <option value="2" >个人</option>
                    </select>
                </li>

                <li>
                    <span>证件类型</span>
                    <p id="papers">

                    </p>
                    <div id="qqqqqq" style="display: none;">
                        <select  id="ssss_idcard">
                        </select>
                    </div>
                    <input type="hidden" name="documentType" id="documentType" value="">

                </li>
                <li>
                    <span>证件号</span>
                    <input type="text" placeholder="请输入证件号"  name="organizationCode" id="organizationCode" class="input-text">
                </li>
                <li>
                    <span>所在城市</span>
                    <p id="selectBtn"></p>
                    <div class="s-city" style="display: none">
                        <input type="text" name="province" value="" id="s-province">
                        <input type="text" name="city" value="" id="s-city">
                        <input type="text" name="district" value="" id="s-area">
                    </div>
                </li>
                <li>
                    <span>具体地址</span>
                    <p id="specific"></p>
                    <input type="text" style="display: none;" name="address" id="adwer" >
                </li>
            </ul>
            <h2>联系人</h2>
            <ul class="basic-information">
                <li>
                    <span>姓名</span>
                    <input type="hidden"  name="contactsList[0].id"  value="">
                    <input type="text" id="linkName" placeholder="请输入姓名" name="contactsList[0].name"  value="" class="input-text">
                </li>
                <li>
                    <span>手机</span>
                    <input type="text"  id="linkPhone"  placeholder="请输入手机号码"  name="contactsList[0].contactsWay"  value="" class="input-text">
                </li>
                <li>
                    <span>电子邮箱</span>
                    <input type="text"  id="linkEmail" name="contactsList[0].email"  value="" placeholder="请输入电子邮箱" class="input-text">
                </li>
            </ul>
        </div>
    </div>

    <div class="pro-steps">
        <div class="steps">
            <button class="xia active" type="button"  onclick="tijiao()">下一步</button>

        </div>
    </div>
</form>
<!--企业/个人选择弹窗-->
<div class="person-model">
    <ul>
        <li>
            <p>企业</p>
        </li>
        <li>
            <p>个人</p>
        </li>
    </ul>
</div>

<!--企业证件类型弹窗-->
<div class="papers-model" id="ertff">
    <ul>

    </ul>
</div>

<!--具体地址填写弹窗-->
<div class="specific-address">
    <textarea></textarea>
    <div class="select-sdf">
        <button class="cancel">取消</button>
        <button class="bao">保存</button>
    </div>
</div>

<div class="tooltip-box">
    <p>当前信息未保存是否取消，新增分销商</p>
    <div class="tooltip-button">
        <button class="sure"  onclick="fanhui()">确定</button>
        <button class="no-qu">取消</button>
    </div>
</div>


<!--黑色蒙版-->
<div class="block-mask-more"></div>
<!--黑色蒙版-->
<div class="block-mask"></div>

<script src="${ctxwxsta}/js/jquery-1.8.3.min.js"></script>
<script src="/static/weixin/common/layer_mobile/layer.js"></script>
<link rel="stylesheet" href="/static/weixin/common/layer_mobile/need/right.css">
<script src="${ctxwxsta}/js/iscroll.js"></script>
<script src="${ctxwxsta}/js/SG_area_select.js"></script>
<script src="${ctxwxsta}/js/basicTwo.js"></script>
<script src="${ctxwxsta}/js/g.js"></script>

<script type="text/javascript">

    $(document).ready(function () {
        $('#selectBtn').on('click', function () {
            $.areaSelect();
            $('.title-min .query').on('click', function () {
                // $('#city').text('');
                $(".popups-box").show().animate({bottom: '-251px'}, function () {
                    $('.sg-mask').css('display', 'none');
                    $('.sg-mask').remove();
                });
            })
            /*移动端确定操作响应*/
            $('.title-min .submit').on('click', function () {
                var test = $('#hasCheck').val();
                if(test.split("-").length!=3){
                    layer.open({content:"必须选择省市县三级",btn: '我知道了'});
                    return;
                }
                $('#city').text($('#hasCheck').val());
                $(".popups-box").show().animate({bottom: '-251px'}, function () {
                    $('.sg-mask').css('display', 'none');
                    $('.sg-mask').remove();
                });
            })
        });


    });

    $(function () {
        var tool_height = parseInt($('.tooltip-box').height()/2);
        $('.tooltip-box').css({"margin-top":-tool_height+'px'});

        $('.tooltip-box button').click(function () {
            $('.tooltip-box').hide();
            $('.block-mask-more').hide();
        });


    })



    function isNull(msg,obj){
        var flag=false;
        var val=$("#"+obj).val();
        if(val==undefined || val=="" || val==null){
            layer.open({content:""+msg,btn: '我知道了'});
            flag=true;
        }
        return flag;

    }

    function isHtmlNull(msg,obj){
        var flag=false;
        var val=$("#"+obj).html().trim();
        if(val==undefined || val=="" || val==null){
            layer.open({content:""+msg,btn: '我知道了'});
            flag=true;
        }
        return flag;

    }
    function  tijiao(){


        var  s1=isNull("用户名不能为空","companyName");
        if(s1){
            return ;
        }
        var  s2=isHtmlNull("请选择企业/个人","enterprise");
        if(s2){
            return ;
        }
        var  s3=isHtmlNull("证件类型为空","papers");
        if(s3){
            return ;
        }
        var  s4= isNull("证件号为空","organizationCode");
        if(s4){
            return ;
        }
        var  s9=isHtmlNull("所在城市不能为空","selectBtn");
        if(s9){
            return ;
        }
        var  s5=isNull("具体地址不能为空","adwer");
        if(s5){
            return ;
        }
        var  s6= isNull("联系人不能为空","linkName");
        if(s6){
            return ;
        }
        var  s7=isNull("联系人电话不能为空","linkPhone");
        if(s7){
            return ;
        }
        var  s8=isNull("联系人邮件不能为空","linkEmail");
        if(s8){
            return ;
        }

        if(!g_reg.ckPhone($("#linkPhone").val())) {
            layer.open({content:"手机号码不正确",btn: '我知道了'});
            return;
        }
        if(!g_reg.ckEmail($("#linkEmail").val())) {
            layer.open({content:"邮箱格式不正确",btn: '我知道了'});
            return;
        }

        $("#documentType").val($("#ssss_idcard").val());
        $('.block-mask-more').show();
        // layer.open({type:2});
        $.ajax({
            type: 'POST',
            url: "/weixin/partner/savePartner",
            data:$('#defaultForm').serialize(),
            dataType:"json",
            async: true,
            success: function(data){

                if(data.success){
                    // alert(1)
                    window.location.href="/weixin/product/changeList/"+data.data+"?newType=1";
                }else{
                    $('.block-mask-more').hide();
                    // layer.closeAll();
                    layer.open({content:"保存失败！",btn: '我知道了'});
                }
            }
        });
    }

    function fanhui() {
      window.location.href="/weixin/partner/list";
    }

</script>

</body>
</html>