<html>
<head>
    <title>个人信息补全</title>
    <% include("base/meta.html"){} %>

    <script src="/js/md5.js"></script>

</head>
<body style="background-color: #fff">


<div class="layui-fluid">
    <div class="layui-row layui-col-space15">
        <div class="layui-col-md12">
            <div class="layui-card">
                <div class="layui-card-body ">
                    <fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
                        <legend>请补充个人信息</legend>
                    </fieldset>
                </div>

                <div class="layui-tab layui-tab-brief" lay-filter="docDemoTabBrief">
                    <ul class="layui-tab-title">
                        <li class="layui-this">用户信息</li>
                    </ul>
                    <div class="layui-tab-content" style="height: 100px;">

                        <div class="layui-tab-item  layui-show">
                            <div class="layui-card-body ">
                                <form class="layui-form layui-form-pane" action="" id="userInfoForm">
                                    <input type="hidden" name="id" id="id" value="${user.id!}">
                                    <input type="hidden" name="roleId" id="roleId" value="${user.roleId!}">


                                    <div class="layui-form-item">
                                        <label class="layui-form-label">账户</label>
                                        <div class="layui-input-inline">
                                            <input type="text" name="ename" id="ename" placeholder="只允许修改一次"
                                                   class="layui-input">
                                        </div>
                                    </div>


                                    <div class="layui-form-item">
                                        <div class="layui-inline">
                                            <label class="layui-form-label">昵称</label>
                                            <div class="layui-input-inline">
                                                <input type="text" placeholder="请输入昵称" autocomplete="off" name="cname"
                                                       value="${user.cname!}"
                                                       id="cname"
                                                       class="layui-input">
                                            </div>
                                        </div>

                                        <div class="layui-inline">
                                            <label class="layui-form-label">手机号</label>
                                            <div class="layui-input-inline">
                                                <input type="text" placeholder="请输入手机号" autocomplete="off" id="mobile"
                                                       name="mobile" value="${user.mobile!}"
                                                       class="layui-input">
                                            </div>
                                        </div>
                                        <div class="layui-inline">
                                            <label class="layui-form-label">邮箱</label>
                                            <div class="layui-input-inline">
                                                <input type="email" placeholder="请输入邮箱" autocomplete="off" name="email"
                                                       id="email" value="${user.email!}"
                                                       class="layui-input">
                                            </div>
                                        </div>

                                        <div class="layui-inline">
                                            <label class="layui-form-label">毕业学校</label>
                                            <div class="layui-input-inline">
                                                <input type="text" placeholder="请输入毕业学校" autocomplete="off" id="school"
                                                       name="school" value="${user.school!}"
                                                       class="layui-input">
                                            </div>
                                        </div>

                                        <div class="layui-inline">
                                            <label class="layui-form-label">学校链接</label>
                                            <div class="layui-input-inline">
                                                <input type="text" placeholder="请输入学校链接" autocomplete="off"
                                                       id="schoolLink" name="schoolLink" value="${user.schoolLink!}"
                                                       class="layui-input">
                                            </div>
                                        </div>

                                        <div class="layui-inline">
                                            <label class="layui-form-label">专业</label>
                                            <div class="layui-input-inline">
                                                <input type="text" placeholder="请输入专业" autocomplete="off"
                                                       id="profession" name="profession" value="${user.profession!}"
                                                       class="layui-input">
                                            </div>
                                        </div>

                                        <div class="layui-inline">
                                            <label class="layui-form-label">开始工作时间</label>
                                            <div class="layui-input-inline">
                                                <input name="beginJobTime" id="beginJobTime" placeholder="请输入开始工作时间"
                                                       value="${user.beginJobTime!}"
                                                       autocomplete="off" class="layui-input">
                                            </div>
                                        </div>

                                        <div class="layui-inline">
                                            <label class="layui-form-label">结束工作时间</label>
                                            <div class="layui-input-inline">
                                                <input name="endJobTime" id="endJobTime" placeholder="请输入结束工作时间"
                                                       autocomplete="off" value="${user.endJobTime!}"
                                                       class="layui-input">
                                            </div>
                                        </div>


                                        <div class="layui-inline">
                                            <label class="layui-form-label">微信</label>
                                            <div class="layui-input-inline">
                                                <input type="text" placeholder="请输入微信" autocomplete="off" id="wechat"
                                                       name="wechat" value="${user.wechat!}"
                                                       class="layui-input">
                                            </div>
                                        </div>


                                        <div class="layui-inline">
                                            <label class="layui-form-label">微博</label>
                                            <div class="layui-input-inline">
                                                <input type="text" placeholder="请输入微博" autocomplete="off" id="weibo"
                                                       name="weibo" value="${user.weibo!}"
                                                       class="layui-input">
                                            </div>
                                        </div>


                                        <div class="layui-inline">
                                            <label class="layui-form-label">QQ</label>
                                            <div class="layui-input-inline">
                                                <input type="text" placeholder="请输入QQ" autocomplete="off" id="qq"
                                                       name="qq" value="${user.qq!}"
                                                       class="layui-input">
                                            </div>
                                        </div>


                                        <div class="layui-inline">
                                            <label class="layui-form-label">Twitter</label>
                                            <div class="layui-input-inline">
                                                <input type="text" placeholder="请输入Twitter" autocomplete="off"
                                                       id="twitter" name="twitter" value="${user.twitter!}"
                                                       class="layui-input">
                                            </div>
                                        </div>


                                        <div class="layui-inline">
                                            <label class="layui-form-label">Facebook</label>
                                            <div class="layui-input-inline">
                                                <input type="text" placeholder="请输入Facebook" autocomplete="off"
                                                       id="facebook" name="facebook" value="${user.facebook!}"
                                                       class="layui-input">
                                            </div>
                                        </div>


                                    </div>
                                    <div class="layui-form-item">
                                        <button type="button" class="layui-btn layui-btn-normal" lay-submit
                                                lay-filter="saveUserInfo">保存
                                        </button>
                                    </div>

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

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


<script>
    layui.use(['form', 'layedit', 'laydate'], function () {
        var form = layui.form;
        var layer = layui.layer;
        var laydate = layui.laydate;


        laydate.render({
            elem: '#beginJobTime' //指定元素
        });

        laydate.render({
            elem: '#endJobTime' //指定元素
        });

        //博主信息监听
        form.on('submit(saveUserInfo)', function (data) {

            if (!data.field.ename) {
                layer.msg("用户名不能为空", {
                    time: 2000
                });
                return;
            }

            if (!data.field.cname) {
                layer.msg("昵称不能为空", {
                    time: 2000
                });
                return;
            }

            if (!data.field.email) {
                layer.msg("邮箱不能为空", {
                    time: 2000
                });
                return;
            }
            $.ajax({
                cache: false,
                type: "POST",
                contentType: 'application/json',
                url: "/user/ext/user",
                data: JSON.stringify(data.field),
                async: false,
                success: function (data) {
                    if (data.code === 0) {
                        layer.msg(data.message);
                        var index = parent.layer.getFrameIndex(window.name);
                        parent.layer.close(index);
                    } else {
                        layer.msg(data.message, {
                            time: 2000
                        });
                    }
                },
                error: function (data) {
                    layer.msg(data.message);
                }
            });
            return false;
        });


    });
</script>


</body>
</html>