<%@ Page Language="C#" AutoEventWireup="true" Inherits="Web.inherits.UserViewPage" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>安全设置-<%=WebSiteConfig.SiteTitle%></title>
    <link href="<%path:%>Css/common.css" rel="stylesheet" />
    <link href="<%path:%>Css/user.css" rel="stylesheet" />
    <script src="/Js/jquery-1.8.2.min.js"></script>
    <script src="/Js/data.js"></script>
    <script src="/Js/bx.library.js"></script>
    <script src="/Js/form.js"></script>
    <script src="<%path:%>js/web.js"></script>
</head>
<body>
    <!--head-->
    <%template:_head.html%>
    <!--body-->
    <div class="body main">
        <div class="split">&nbsp;</div>
        <div class="usercenter">
            <div class="left"><%template:_usermenu.html%></div>
            <div class="right">
                <div class="content">
                    <div class="title">
                        <h3>安全设置 <span class="note">(<span class="nonullalert">*</span>为必须填写项)</span></h3>
                    </div>
                    <table class="infoform">
                        <tr>
                            <td class="itemtitle">账号</td>
                            <td class="itemcontent">
                                <%=UserIdentity.Account%>
                            </td>
                            <td class="fielddescription">
                                &nbsp;
                            </td>
                        </tr>
                        <tr>
                            <td class="itemtitle">旧密码</td>
                            <td class="itemcontent">
                                <input id="OldPassword" name="OldPassword" type="password" class="text" />
                            </td>
                            <td></td>
                        </tr>
                        <tr>
                            <td class="itemtitle">新密码</td>
                            <td class="itemcontent">
                                <input id="NewPassword" name="NewPassword" type="password" class="text" />
                            </td>
                            <td>
                                如不需要更改密码，此处请留空
                            </td>
                        </tr>
                        <tr>
                            <td class="itemtitle">确认新密码</td>
                            <td class="itemcontent">
                                <input id="NewPassword2" type="password" class="text" />
                            </td>
                            <td>
                                如不需要更改密码，此处请留空
                            </td>
                        </tr>
                        <tr>
                            <td class="itemtitle">邮箱</td>
                            <td class="itemcontent">
                                <input id="Email" name="Email" type="text" class="text" value="<%=UserIdentity.User.Email%>" />
                            </td>
                            <td>
                                <%if (UserIdentity.User.AuthenticationStatus == 1)
                                { %>
                                已验证
                                <%}
                                else
                                { %>
                                未验证
                                <%} %>
                                ,如更换新邮箱需要重新验证
                                <a href="javascript:" onclick="emailAuth();">立即验证</a>
                            </td>
                        </tr>
                        <tr>
                            <td class="itemtitle">邮箱验证码</td>
                            <td class="itemcontent">
                                <input id="EmailAuthCode" name="EmailAuthCode" type="text" class="text" />
                            </td>
                            <td>
                                验证邮箱使用,如果没有则为空
                            </td>
                        </tr>
                        <tr>
                            <td class="itemtitle">密保问题</td>
                            <td class="itemcontent">
                                <input id="Question" name="Question" type="text" class="text" />
                            </td>
                            <td>
                                如不修改,此处留为空
                            </td>
                        </tr>
                        <tr>
                            <td class="itemtitle">问题答案</td>
                            <td class="itemcontent">
                                <input id="Answer" name="Answer" type="text" class="text" />
                            </td>
                            <td>
                                如不修改,此处留为空
                            </td>
                        </tr>
                        <tr>
                            <td colspan="3" align="center">
                                <input id="Button1" type="button" value="保存" onclick="submitData();" />
                            </td>
                        </tr>
                    </table>
                </div>
            </div>
        </div>
    </div>
    <!--foot-->
    <%template:_foot.html%>
    <script type="text/javascript">
        var rule = '[{"Name": "OldPassword", "Type": "password", "Null": "0","Error":"密码不能为空" }';
        rule += ',{ "Name": "NewPassword", "Type": "password", "Null":"1"}';
        rule += ',{ "Name": "Email", "Type": "text", "Null": "0","Error":"邮箱不能为空"}';
        rule += ',{ "Name": "Question", "Type": "text", "Null": "1"}';
        rule += ',{ "Name": "Answer", "Type": "text", "Null": "1"}';
        rule += ']';
        window.onload = function () {
            form.init(eval(rule));
        }
        function submitData() {
            var ck = form.check();
            if (ck == "") {
                User.securitySet(form.getJson(), function (result) {
                    if (result.status == "success") {
                        alert("保存成功");
                    } else if (result.error == "password") {
                        alert("旧密码错误");
                    }
                    else {
                        alert("保存失败，请检查");
                    }
                })
            }
            else {

            }
        }
        function emailAuth() {
            $.post(document.location.href + "?cmd=emailAuth", {}, function (result) {
                if (result.status == "success") {
                    alert("验证邮件已发送");
                } else if (result.error == "limit") {
                    alert("验证邮件已达到最大限制次数,请稍后再试");
                } else {
                    alert("验证邮件发送失败");
                }
            }, "json")
        }
    </script>
</body>
</html>