<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@page language="java" contentType="text/html; charset=utf-8"
        pageEncoding="utf-8" %>
<%@ include file="header.jsp" %>
<%
    LoginUserVo loginUserVo = (LoginUserVo) request.getSession().getAttribute("logininfo");

%>
<link rel="stylesheet" type="text/css" href="<%=path%>/css/addDialog.css"/>
<style type="text/css">
    .mianWrap {
        width: 400px;
        margin: 100px auto auto;
    }

    table, tr, td {
        border: none;
    }

    td {
        padding-bottom: 15px;
        padding-right: 20px;
    }

    .passwordInput {
        width: 200px;
        height: 32px;
        line-height: 32px;
        border: 1px solid #CCCCCC;
        border-radius: 5px;
        text-indent: 1em;
    }

    input:focus {
        outline: 0 !important
    }

    #modifyBtn {
        width: 100px;
        height: 35px;
        border: none;
        border-radius: 3px;
        font-size: 14px;
        background: #036EB7;
        color: #ffffff;
        margin-top: 10px;
    }

    .starRed {
        color: red;
        margin-left: 4px;
    }
</style>
<script type="text/javascript">
    function inputConfirm() {
        $("#userform").form("clear");
        $("#addedit_dialog").show();
    }
    function submit() {
        $("#id").val(<%=loginUserVo.getId()%>);
        var newPassword = $("#newPassword").val();
        var confirmPassword = $("#confirmPassword").val();
        var password = $("#password").val();
        if(password == null || password == ''){
            alert("旧密码不能为空");
            return;
        }
        if (newPassword == null || newPassword == '') {
            alert('请输入密码');
            return;
        }
        if (newPassword != confirmPassword) {
            alert("密码和确认密码不匹配");
            return;
        }
        $.ajax({
            cache: true,
            type: "POST",
            url:"/user/updatePassword.do",
            data: $('#userform').serialize(),
            async: false,
            error: function (request) {
                alert("Connection error");
            },
            success: function (data) {
                var data = eval("(" + data + ")");
                if (data.flag == 1) {
                    $("#addedit_dialog").hide();
                } else {
                    if(data.msg == '密码错误'){
                        $("#start").html(data.msg);
                    }else {
                        alert(data.msg);
                    }
                }
            }
        });
    }
</script>
<input type="hidden" id="paths" value="<%=path%>"/>
<div id="wrap">
    <div class="mianWrap">
        <table border="" cellspacing="0" cellpadding="0">
            <tr>
                <td>用户名<span class="starRed">*</span></td>
                <td><input class="passwordInput" readonly="readonly" style="caret-color:white" type="text" value="<%=loginUserVo.getName()%>" id="username"/>
                </td>
            </tr>
            <tr>
                <td>登入名<span class="starRed">*</span></td>
                <td><input class="passwordInput" readonly="readonly" style="caret-color:white" type="text" value="<%=loginUserVo.getLogin_name()%>" id="loginName"/></td>
            </tr>
            <tr>
                <td>手机号<span class="starRed">*</span></td>
                <td><input class="passwordInput" readonly="readonly" style="caret-color:white" type="text" value="<%=loginUserVo.getPhone()%>" id="phone"/></td>
            </tr>
            <tr>
                <td>邮箱<span class="starRed">*</span></td>
                <td><input class="passwordInput" readonly="readonly" style="caret-color:white" type="text" value="<%=loginUserVo.getEmail()%>" id="email"/></td>
            </tr>
            <tr>
                <td>&nbsp;</td>
                <td><input id="modifyBtn" type="button" onclick="inputConfirm()" value="修   改  密  码"></td>
            </tr>
        </table>
    </div>
</div>
<div class="order_undo" id="addedit_dialog" style="display: none;">
    <form action="" id="userform" method="post">
        <input type="hidden" value="" id="id" name="id">
        <div class="dialog_default" style="width:1300px;" id="dialogNb">
            <div class="dialog_title" style="margin:auto;width: 40%">修改密码</div>
            <div class="dialog_con" style="margin-left:390px;width:40%">
                <div class="dialog_left" style="padding: 15px 40px;">
                    <table>
                        <tbody>
                        <tr>
                            <td colspan="3"></td>
                        </tr>
                        <tr>
                            <td colspan="2">
                                <span class="concat">旧密码</span>
                                <div class="contactWrap">
                                    <input id="password"  name="password" type="password" placeholder="旧密码"
                                           value=""/></div></td>
                            <td>
                                <div id="start" style="color:red;margin-left:100px;font-size:12px;width:100px"></div>
                            </td>
                        </tr>
                        <tr>
                            <td colspan="2">
                                <span class="concat">新密码</span>
                                <div class="contactWrap">
                                    <input id="newPassword"  name="newPassword" type="password" placeholder="新密码"
                                           value=""/></div></td>
                        </tr>
                        <tr>
                            <td colspan="3">
                                <span class="concat">确认密码</span>
                                <div class="contactWrap">
                                    <input id="confirmPassword"  name="confirmPassword" type="password" placeholder="确认密码"
                                           value=""/>
                                </div>
                            </td>
                        </tr>
                        </tbody>
                    </table>
                    <div class="confirm_cancel clearfix" style="padding-top:10px;width:400px;margin-bottom: 30px">
                        <a href="javascript:void(0);" class="btn2"
                           style="margin-right:20px;margin-left:40px" onclick="submit();">提&nbsp;&nbsp;交</a>
                        <a href="javascript:void(0);" class="btn1 cancel" onclick="cancel()">取&nbsp;&nbsp;消</a>
                    </div>

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

</div>
<%@ include file="footer.jsp" %>