<% include ../layout/body_header.ejs %>
<div class="panel-content" id="app">
    <div class="panel-title">
        <div class="title-main">
            <h2>账号资料</h2>
        </div>
    </div>
    <div class="content-wrap">
        <div class="c-body">
            <div class="row">
                <div class="col-5">
                    <!--账号资料-->
                    <form action="/profile/save" method="post" id="base-form">
                        <input-text label="账号" value="<%= accountData.account %>" readonly="readonly"></input-text>
                        <input-text label="姓名" value="<%= accountData.name %>" placeholder="请输入姓名" name="name"></input-text>
                        <input-text label="单位" value="<%= accountData.company %>" name="company"></input-text>
                        <input-text label="角色/职称" value="<%= accountData.role %>" name="role"></input-text>
                        <input-text label="手机" value="<%= accountData.mobile %>" name="mobile" maxlength="11"></input-text>
                        <input-text label="电话" value="<%= accountData.telephone %>" name="telephone"></input-text>
                        <input type="hidden" name="_csrf" value="<%= ctx.csrf %>">
                        <button type="submit" class="btn btn-primary" id="base-submit">确认修改</button>
                    </form>
                    <!--账号安全-->
                    <form action="/profile/password" method="post" style="margin-top: 20px;" id="password-form">
                        <% if(accountData.password !== 'SSO password') { %>
                        <input-text label="旧密码" password="true" name="password"></input-text>
                        <input-text label="新密码" password="true" name="new_password" id="new_password"></input-text>
                        <input-text label="确认新密码" password="true" name="confirm_password"></input-text>
                        <input type="hidden" name="_csrf" value="<%= ctx.csrf %>">
                        <button type="submit" class="btn btn-primary" id="modify-password">修改密码</button>
                        <% } else { %>
                        <p>SSO用户请到<a href="#">此处</a>修改密码</p>
                        <% } %>
                    </form>
                    <!--绑定手机-->
                    <form id="mobile-form" method="post" action="/profile/bind">
                        <div class="form-group mt-5">
                            <label>认证手机（用于 找回密码、接收通知）</label>
                            <input class="form-control" placeholder="输入11位手机号码" value="<%= accountData.auth_mobile %>"
                                   <% if(accountData.auth_mobile !== '') { %>disabled="disabled"<% } %> name="auth_mobile"
                                    maxlength="11"/>
                        </div>
                        <% if (accountData.auth_mobile === '') { %>
                        <div class="form-group">
                            <div class="input-group mb-3">
                                <input class="form-control" readonly="readonly" name="code"/>
                                <input type="hidden" name="_csrf" value="<%= ctx.csrf %>">
                                <div class="input-group-append">
                                    <button class="btn btn-outline-secondary" type="button" id="get-code">获取验证码</button>
                                </div>
                            </div>
                        </div>
                        <button type="submit" class="btn btn-secondary disabled" id="bind-btn">确认绑定</button>
                        <% } %>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>
<%- baseJsValidator %>
<%- passwordJsValidator %>
<script type="text/javascript">
    new Vue({
        el: '#app',
    });
    const csrf = '<%= ctx.csrf %>';
</script>
<script type="text/javascript" src="/public/js/profile.js"></script>