<%@ 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="${ctxwxsta}/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="fanhui(0)" class="left">
            <img src="${ctxwxsta}/images/head-left.png"/>
        </a>
    </div>

    <div class="account-settings">
        <ul class="accout-cont">
            <li>
                <span>登录账号</span>
                <input type="text" placeholder="请输入登录账号" id="loginName" name="loginName" value="${sysUser.loginName}" class="input-text" <c:if test="${!empty sysUser.id}">readonly="readonly"</c:if>>
            </li>
            <li>
                <span>密码</span>

                <input type="password"  <c:if test="${not empty sysUser}">placeholder="不填写默认原来密码"</c:if>  <c:if test="${ empty sysUser}">placeholder="请输入密码"</c:if> id="loginPassword" name="loginPassword" value="" class="input-text">
            </li>
        </ul>
        <ul class="accout-cont">
            <li>
                <span>真实姓名</span>
                <input type="text" placeholder="请输入真实姓名" id="realName"  name="realName" value="${sysUser.realName}" class="input-text">
            </li>
            <li>
                <span>性别</span>
                <p id="select-sex">
                    <c:if test="${sysUser.sex  eq '1'}">男</c:if>
                    <c:if test="${sysUser.sex  eq '2'}">女</c:if>
                </p>

            </li>
            <select name="sex" id="ssss" style="display: none;">
                <option value="1" <c:if test="${sysUser.sex  eq '1'}">selected</c:if>>男</option>
                <option value="2" <c:if test="${sysUser.sex  eq '2'}">selected</c:if>>女</option>
            </select>
        </ul>
        <ul class="accout-cont">
            <li>
                <span>状态</span>
                <p id="state">
                        <c:if test="${sysUser.status  eq '1'}">启用</c:if>
                        <c:if test="${sysUser.status  eq '0'}">禁用</c:if>
                </p>
            </li>
            <select name="status" id="ssss_status" style="display: none;">
                <option value="1" <c:if test="${sysUser.status  eq '1'}">selected</c:if> >启用</option>
                <option value="0" <c:if test="${sysUser.status  eq '0'}">selected</c:if>>禁用</option>
            </select>
        </ul>
    </div>

</div>
<div class="pro-steps assigned-steps">
    <div class="steps">
        <input type="hidden" name="id" id="sid" value="${sysUser.id}">
        <input type="hidden" name="sysCompany.id" id="companyId" value="${companyId}">
        <c:forEach items="${sysRoles}" var="sysRoles">
            <input type="hidden" name="roleId" value="${sysRoles.id}"/>
        </c:forEach>
        <c:if test="${not empty newType}">
            <button class="xia" type="button" onclick="tijiao()">提交</button>
            <button onclick="fanhui(1)"  type="button">上一步</button>
        </c:if>
        <c:if test="${ empty newType}">
            <button class="xia" type="button" onclick="tijiao()">提交</button>
<%--
            <button onclick="fanhui(0)"  type="button">返回</button>
--%>
        </c:if>

    </div>
</div>
</form>

<!--性别选择弹窗-->
<div class="sex-model">
    <ul>
        <li>
            <p>男</p>
        </li>
        <li>
            <p>女</p>
        </li>
    </ul>
</div>

<!--状态选择弹窗-->
<div class="state-model">
    <ul>
        <li>
            <p>启用</p>
        </li>
        <li>
            <p>停用</p>
        </li>
    </ul>
</div>

<div class="tooltip-box">
    <p>当前信息未保存是否取消，账号设置</p>
    <div class="tooltip-button">
        <button class="sure" type="button" onclick="fanhui(0)">确定</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="${ctxwxsta}/js/basicTwo.js"></script>

<script>
    function  tijiao(){
            var  baseUrl = '${pageContext.request.contextPath }';
            var  password=$("#loginPassword").val();
            var  sid=$("#sid").val();
            var  loginName =$("#loginName").val();
            var  realName  =$("#realName").val();
            var  sex  =$("#ssss").val();
            var  status  =$("#ssss_status").val();

            if(loginName==''){
                layer.open({content:"账号名不能为空！",btn: '我知道了'});
               return ;
            }
            var regChinese =  /^[^\u4e00-\u9fa5]{0,}$/;
            var checkChinese = regChinese.test(loginName);
            if(!checkChinese){
                layer.open({content:"登陆账号不支持中文！",btn: '我知道了'});
                return ;
            }
            if(sid==''&&password==''){
                layer.open({content:"密码不能为空！",btn: '我知道了'});
                return ;
            }
            if(realName==''){
                layer.open({content:"真实姓名不能为空！",btn: '我知道了'});
                return ;
            }
            if(sex==''){
                layer.open({content:"请选择性别！",btn: '我知道了'});
                return ;
            }
            if(status==''){
                layer.open({content:"请选择状态！",btn: '我知道了'});
                return ;
            }
            var  companyId =$("#companyId").val();
            layer.open({type: 2});
            $.ajax({
                type: 'POST',
                url: "/weixin/partner/account/save",
                data:$('#defaultForm').serialize(),
                dataType:"json",
                async: false,
                success: function(data){
                    if(data.success){
                        window.location.href="/weixin/partner/detatil/"+companyId;
                    }else{
                        layer.closeAll();
                        layer.open({content:"账号已经存在！",btn: '我知道了'});
                    }
                }
            });

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

        $('#erty').click(function () {
            $('.tooltip-box').css({"display":"block"});
            $('.block-mask-more').css({"display":"block"});
        });


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


    })


    function fanhui(type) {
        var  companyId =$("#companyId").val();
        if(type=='0'){
            //弹窗
            window.location.href="/weixin/partner/detatil/"+companyId;
        }
        if(type=='1'){
            //返回上一步

            window.location.href="/weixin/partner/area/"+companyId+"?newType=1";
        }

    }

</script>

</body>
</html>