{% load staticfiles %}
<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <link rel="stylesheet" href="{% static '/lib/layui/css/layui.css' %}">
    <link rel="stylesheet" href="{% static '/lib/css/reset.css' %}">
    <style>
        .breadcrumbs {
            padding: 12px 0 12px 30px;
            border-bottom: 1px solid #dbdbdb;
        }

        .layui-breadcrumb>* {
            font-size: 16px;
        }

        .fixedDiv {
            position: fixed;
            width: 100%;
            z-index: 999;
            box-shadow: 0px 3px 5px 0px #ececec;
            background: #fff;
        }

        /* 发布类型 */

        .widget-title {
            position: relative;
            padding-left: 10px;
            font-size: 16px;
            padding: 5px 0 5px 10px;
        }

        .widget-title::after {
            position: absolute;
            content: '';
            left: 0;
            top: 9px;
            height: 15px;
            border-left: 5px solid #23a3ee;
            padding-left: 10px;
            font-size: 16px;
            padding: 5px 0 5px 10px;
        }

        .widget-title h2 {
            font-weight: 700;
            line-height: 33px;
        }

        .widget-title h2 span {
            font-size: 13px;
            font-weight: 100;
            margin-left: 20px;
            color: #333;
        }



        /* 上传详情 */

        .layui-form-item .layui-input-inline {
            width: 40%;
        }

        .uploadContent {
            width: 50%;
            padding: 25px;
        }

        .site-title {
            margin: 10px 0 20px;
        }

        .site-title fieldset {
            border: none;
            padding: 0;
            border-top: 1px solid #eee;
        }

        .site-title fieldset legend {
            margin-left: 20px;
            padding: 0 10px;
            font-size: 22px;
            font-weight: 300;
        }

        .innerDiv {
            max-width: 500px;
        }

        /* 图片预览 */

        .layui-upload-img {
            width: 92px;
            height: 92px;
            margin: 0 10px 10px 0;
        }

        #progressBar {
            display: none;
        }

        /* 产品展厅上传多图 */

        .uploadParent {
            position: absolute;
            margin: 10px 0;
        }

        .uploadParent>div {
            display: inline-block;
            width: 92px;
            height: 92px;
            /* border: 1px solid #b8b8b8; */
            background: url(../../static/imgs/addicon.png) no-repeat center;
            background-size: 80% 80%;
            cursor: pointer;
            margin-right: 8px;
        }

        .uploadShowParent .layui-upload-list {
            display: inline-block;
        }

        /* 表单样式 */

        .uploadImg {
            position: absolute;
            margin: 10px 0;
            width: 92px;
            height: 92px;
            background: none;
            border: 1px solid #b8b8b8;
            cursor: pointer;
        }

        .uploadImgIcon {
            background: url(../../static/imgs/uploadImgIcon.png) no-repeat center;
            background-size: 80% 80%;
        }

        div.layui-form-mid {
            color: red !important;
        }
    </style>
</head>

<body>
    <div class="content">
        <div class="floatNav">
            <!-- 导航 -->
            <div class="breadcrumbs">
                <span class="layui-breadcrumb">
                    <a target="BoardRight">首页</a>
                    <a>
                        <cite>修改密码</cite>
                    </a>
                </span>
            </div>
        </div>

        <!-- 内容 -->
        <div>
            <!-- 发布详情 -->
            <div class="uploadContent" id="uploadContent">
                <!-- <div class="widget-title">
                    <h2>新闻发布
                        <span id="Uptime"></span>
                    </h2>
                </div> -->
                <div class="site-title">
                    <fieldset>
                        <legend>
                            <a name="use">修改密码</a>
                        </legend>
                    </fieldset>
                </div>
                <div>
                    <form class="layui-form" action="" id="formDiv" lay-filter="newsFormDiv">
                        <div class="layui-form-item">
                            <label class="layui-form-label">旧密码：</label>
                            <div class="layui-input-inline">
                                <input type="password" name="oldpassword" value="" required lay-verify="required" placeholder="请输入旧密码" autocomplete="off"
                                    class="layui-input">
                            </div>
                            <div class="layui-form-mid layui-word-aux">*</div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">新密码：</label>
                            <div class="layui-input-inline">
                                <input type="password" name="passwordFirst" value="" required lay-verify="required" placeholder="请填写新密码" autocomplete="off"
                                    class="layui-input">
                            </div>
                            <div class="layui-form-mid layui-word-aux">*</div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">确认密码：</label>
                            <div class="layui-input-inline">
                                <input type="password" name="password" value="" required lay-verify="required" placeholder="请确认密码" autocomplete="off" class="layui-input">
                            </div>
                            <div class="layui-form-mid layui-word-aux">*</div>
                        </div>
                        <div class="layui-form-item">
                            <div class="layui-input-block">
                                <button class="layui-btn layui-btn-normal" lay-submit lay-filter="formDemo">修改密码</button>
                            </div>
                        </div>
                    </form>
                </div>

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


    <script src="{% static '/lib/js/jquery-2.1.4.min.js'%}"></script>
    <script src="{% static '/lib/layui/layui.js'%}"></script>
    <script src="{% static '/js/backstageNet/common.js'%}"></script>
    <script>
        var element, form;
        layui.use(['element', 'form',], function () {
            element = layui.element;
            form = layui.form;
            //一些事件监听
            element.on('tab(demo)', function (data) {
                console.log(data);
            });


            //监听提交
            form.on('submit(formDemo)', function (data) {
                console.log(data)
                if (data.field.password != data.field.passwordFirst) {
                    layer.msg("两次输入密码不一致！", { icon: 0 });
                    return false;
                }
                $.ajax({
                    url: 'user_change_pwd',
                    data: $("#formDiv").serialize(),
                    type: 'post',
                    success: function (dat) {
                        if (dat == 1) {
                            layer.msg("修改成功", { icon: 1 });
                            form.val("newsFormDiv", {
                                "oldpassword": "" // "name": "value"
                                , "passwordFirst": ""
                                , "password": ""
                            })
                        } else {
                            layer.msg("修改失败", { icon: 2 });

                        }
                    },
                    error: function (type) {

                    }
                })
                return false;

            });


        });


        windowAddMouseWheel();
        function windowAddMouseWheel() {
            var scrollFunc = function (e) {
                e = e || window.event;
                var top = $(window).scrollTop();
                if (e.wheelDelta) {  //判断浏览器IE，谷歌滑轮事件
                    if (e.wheelDelta > 0) { //当滑轮向上滚动时
                        if (top < 60) {
                            if ($(".floatNav").hasClass("fixedDiv")) {
                                $(".floatNav").removeClass("fixedDiv");
                                $(window).scrollTop(0)
                            }
                        }
                    }
                    if (e.wheelDelta < 0) { //当滑轮向下滚动时
                        if (top >= 60) {
                            $(".floatNav").addClass("fixedDiv");
                        }
                    }
                } else if (e.detail) {  //Firefox滑轮事件
                    if (e.detail > 0) { //当滑轮向上滚动时
                        if (top < 60) {
                            if ($(".floatNav").hasClass("fixedDiv")) {
                                $(".floatNav").removeClass("fixedDiv");
                                $(window).scrollTop(0)
                            }
                        }
                    }
                    if (e.detail < 0) { //当滑轮向下滚动时
                        if (top >= 60) {
                            $(".floatNav").addClass("fixedDiv");
                        }
                    }
                }
            };
            //给页面绑定滑轮滚动事件
            if (document.addEventListener) {
                document.addEventListener('DOMMouseScroll', scrollFunc, false);
            }
            //滚动滑轮触发scrollFunc方法
            window.onmousewheel = document.onmousewheel = scrollFunc;
        }

        // 返回
        function goback() {
            var currPage = $('#currPage').val();
            var f_name = $('#f_name').val();
            window.location.href = 'person_view?uname=' + f_name + '&page=' + currPage;
        }

    </script>
</body>

</html>