<%@ 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>
    <script src="/static/weixin/common/layer_mobile/layer.js"></script>
    <link rel="stylesheet" href="/static/weixin/common/layer_mobile/need/right.css">
    <title>下级信息修改</title>
</head>
<body id="contain">
<form   method="post"   id="defaultForm">
<div class="contain">
    <div class="bai-head">
        <span>下级信息修改</span>
        <a href="javascript:;" onclick="okButton()" 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="hidden"  id="id" name="id" value="${company.id}" class="input-text">

                <input type="text" placeholder="请输入名称" id="companyName" name="companyName" value="${company.companyName}" class="input-text">
            </li>
            <li>
                <span>企业/个人</span>
                <p id="enterprise">
                    <c:if test="${company.terminalType  eq '1'}">企业</c:if>
                    <c:if test="${company.terminalType  eq '2'}">个人</c:if>
                </p>
                <select name="terminalType" id="ssss_enterprise" style="display: none;">
                    <option value="1" <c:if test="${company.terminalType  eq '1'}">selected</c:if> >企业</option>
                    <option value="2" <c:if test="${company.terminalType  eq '2'}">selected</c:if>>个人</option>
                </select>
            </li>

            <li>
                <span>证件类型</span>
                <p id="papers">
                    <c:if test="${company.terminalType  eq '1'}">
                          <c:if  test="${company.documentType  eq '1'}">营业执照</c:if>
                          <c:if  test="${company.documentType  eq '2'}">统一社会信用代码</c:if>
                          <c:if  test="${company.documentType  eq '3'}">组织机构代码证</c:if>
                    </c:if>

                    <c:if test="${company.terminalType  eq '2'}">
                        <c:if  test="${company.documentType  eq '0'}">身份证</c:if>
                        <c:if  test="${company.documentType  eq '1'}">台胞证</c:if>
                        <c:if  test="${company.documentType  eq '2'}">护照</c:if>
                        <c:if  test="${company.documentType  eq '3'}">回乡证</c:if>
                        <c:if  test="${company.documentType  eq '5'}">其他</c:if>
                    </c:if>

                </p>
                <div id="qqqqqq" style="display: none;">
                    <select name="documentType" id="ssss_idcard">
                        <c:if test="${company.terminalType  eq '1'}">
                            <option value="1" <c:if  test="${company.documentType  eq '1'}">selected="selected"</c:if>>营业执照</option>
                            <option value="2" <c:if  test="${company.documentType  eq '2'}">selected="selected"</c:if>>统一社会信用代码</option>
                            <option value="3" <c:if  test="${company.documentType  eq '3'}">selected="selected"</c:if>>组织机构代码证</option>
                        </c:if>
                        <c:if test="${company.terminalType  eq '2'}">
                            <option value="0" <c:if  test="${company.documentType  eq '0'}">selected="selected"</c:if>>身份证</option>
                            <option value="1" <c:if  test="${company.documentType  eq '1'}">selected="selected"</c:if>>台胞证</option>
                            <option value="2" <c:if  test="${company.documentType  eq '2'}">selected="selected"</c:if>>护照</option>
                            <option value="3" <c:if  test="${company.documentType  eq '3'}">selected="selected"</c:if>>回乡证</option>
                            <option value="5" <c:if  test="${company.documentType  eq '5'}">selected="selected"</c:if>>其他</option>
                        </c:if>
                    </select>
                </div>
            </li>
            <li>
                <span>证件号</span>
                <input type="text" placeholder="请输入证件号" id="organizationCode" value="${company.organizationCode}" name="organizationCode" class="input-text">
            </li>
            <li>
                <span>所在城市</span>
                <p id="selectBtn"></p>
                <div class="s-city" style="display: none">
                    <input type="hidden" name="province" value="${company.province}" id="s-province">
                    <input type="hidden" name="city" value="${company.city}" id="s-city">
                    <input type="hidden" name="district" value="${company.district}" id="s-area">
                </div>
            </li>
            <li>
                <span>具体地址</span>
                <p id="specific">${company.address}</p>
                <input type="text" style="display: none;" name="address" id="adwer" value="${company.address}">
            </li>
        </ul>
        <h2>联系人</h2>
        <ul class="basic-information">
            <li>
                <span>姓名</span>
                <input type="hidden" name="contactsList[0].id"  value="${contactsList[0].id}">
                <input type="text" id="linkName" placeholder="请输入姓名" name="contactsList[0].name"  value="${contactsList[0].name}" class="input-text">
            </li>
            <li>
                <span>手机</span>
                <input type="text" id="linkPhone" placeholder="请输入手机号码"  name="contactsList[0].contactsWay"  value="${contactsList[0].contactsWay}" class="input-text">
                </li>
            <li>
                <span>电子邮箱</span>
                <input type="text"  id="linkEmail" name="contactsList[0].email"  value="${contactsList[0].email}" placeholder="请输入电子邮箱" class="input-text">

            </li>
        </ul>
    </div>
</div>
<div class="pro-steps">
    <div class="steps">
        <c:if test="${not  empty  newType &&newType  eq '1'}">
            <button class="xia active" type="button"  onclick="tijiao()">下一步</button>

        </c:if>
        <c:if test="${empty  newType}">
            <button class="xia active"  type="button" onclick="tijiao()">确认</button>

        </c:if>
    </div>
</div>
</form>
<p id="erty_dan"></p>
<div class="tooltip-grm" >
    <p id="error_msg">操作成功</p>
    <div class="tooltip-button">
        <button class="sure">确定</button>
    </div>
</div>
<!--企业/个人选择弹窗-->
<div class="person-model">
    <ul>
        <li>
            <p>企业</p>
        </li>
        <li>
            <p>个人</p>
        </li>
    </ul>
</div>
<!--黑色蒙版-->
<div class="block-mask-more"></div>

<!--企业证件类型弹窗-->
<div class="papers-model" id="ertff">
    <ul>
        <c:if test="${company.terminalType  eq '1'}">
            <li>
                <p onclick="tyu(this)">营业执照</p>
            </li>
            <li>
                <p onclick="tyu(this)">统一社会信用代码</p>
            </li>
            <li>
                <p onclick="tyu(this)">组织机构代码证</p>
            </li>
        </c:if>
        <c:if test="${company.terminalType  eq '2'}">
            <li>
                <p onclick="tyu(this)">身份证</p>
            </li>
            <li>
                <p onclick="tyu(this)">台胞证</p>
            </li>
            <li>
                <p onclick="tyu(this)">护照</p>
            </li>
            <li>
                <p onclick="tyu(this)">其他</p>
            </li>
            <li>
                <p onclick="tyu(this)">回乡证</p>
            </li>
         </c:if>

        </li>
    </ul>
</div>

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

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

<script src="${ctxwxsta}/js/jquery-1.8.3.min.js"></script>
<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">


    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;

    }
    $(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'});


        $('#erty_dan').click(function () {
            $('.tooltip-grm').show();
            $('.block-mask-more').css({"display":"block"});
        });
        $('.tooltip-grm .sure').click(function () {
            $('.tooltip-grm').hide();
            $('.block-mask-more').hide();
        });



    })
</script>



<script>

    function  tijiao(){

        var  baseUrl = '${pageContext.request.contextPath }';

        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;
        }


        var  newType='${newType}';
        // layer.open({type: 2});
        $('.block-mask-more').show();
        $.ajax({
            type: 'POST',
            url: baseUrl+"/weixin/partner/savePartner",
            data:$('#defaultForm').serialize(),
            dataType:"json",
            async: true,
            success: function(data){
                console.log(JSON.stringify(data));
                if(data.success){
                     if(newType){
                             window.location.href="/weixin/product/changeList/"+data.data+"?newType=1";
                     }else{
                         $('.block-mask-more').hide();
                             menu();
                     }
                }else{
                    $('.block-mask-more').hide();
                    layer.open({content:"操作失败！",btn: '我知道了'});
                }
            }
        });

    }
    
    function tishi() {
        $("#error_msg").html("信息已保存，可进入“下级管理”中继续帐号的设置。");
        $("#erty_dan").click();
        setTimeout(function () {
            window.location.href="/weixin/partner/detatil/"+$("#id").val();
        },2000);
    }
    function  okButton(){
        layer.open({
            content: '修改的内容未保存，确定要返回吗？'
            ,btn: ['确认返回', '取消返回'] ,yes: function(index){
                window.location.href="/weixin/partner/detatil/"+$("#id").val();            }
        });
    }

    function  menu() {

        window.location.href="/weixin/partner/detatil/"+$("#id").val();
    }



    $(document).ready(function(){

          var   city=$("#s-province").val()+$("#s-city").val()+$("#s-area").val()+"";
      // alert(city);
          if(city!=''){
              $("#selectBtn").html(g_getRegion($("#s-province").val()).province+g_getRegion($("#s-city").val()).citytype+g_getRegion($("#s-area").val()).city);
          }
    });



</script>

</body>
</html>