Login.cshtml

@{
    ViewData["Title"] = "Login";
    Layout = "~/Views/Shared/_Layout_default.cshtml";
}

@section Css
{

    <style>

        body {
            /* 加载背景图 */
            background-image: url(../../icon/aa.png);
            /* 背景图垂直、水平均居中 */
            background-position: 20% 190px;
            /* 背景图不平铺 */
            background-repeat: no-repeat;
            /* 当内容高度大于图片高度时,背景图像的位置相对于viewport固定 */
            background-attachment: fixed;
            /* 让背景图基于容器大小伸缩 */
            background-size: auto;
            /* 设置背景颜色,背景图加载过程中会显示背景色 */
            /*background-color: #464646;*/
        }

        .outerlayer {
            height: 500px;
            padding-top: 200px;
            /* 加载背景图 */
            background-image: url(../../icon/bb.png);
            /* 背景图垂直、水平均居中 */
            background-position: 80% 50%;
            /* 背景图不平铺 */
            background-repeat: no-repeat;
            /* 当内容高度大于图片高度时,背景图像的位置相对于viewport固定 */
            background-attachment: fixed;
            /* 让背景图基于容器大小伸缩 */
            background-size: 22%;
            /* 设置背景颜色,背景图加载过程中会显示背景色 */
            /*background-color: #464646;*/
        }

        .Absolute-Center {
            margin: auto;
            position: fixed;
            top: 0px;
            left: 0;
            bottom: 100px;
            right: 0;
            width: 600px;
            height: 300px;
            padding: 50px;
            border: 1px solid #d2d2d2;
            background-color: white;
            border-radius: 10px;
            opacity: 0.95;
            box-shadow: 5px 5px 30px white;
        }

        .layui-form-item {
            padding-left: 75px;
        }


        /*隐藏ie浏览器密码框小眼睛图标*/
        input[type="password"]::-ms-reveal {
            display: none;
        }

        input[type="password"]::-ms-clear {
            display: none;
        }

        input[type="password"]::-o-clear {
            display: none;
        }
    </style>

}

<div class="outerlayer">
    <div class="layui-form Absolute-Center">
        <h1 style="margin:auto;width:460px; margin-bottom:50px; color:#333;">ESL IP Address Managment System</h1>
        <div class="layui-form-item">
            <label class="layui-form-label">Login ID:</label>
            <div class="layui-input-inline">
                <input type="text" name="LoginID" required lay-verify="required" lay-reqtext="" placeholder="Login ID" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">Password:</label>
            <div class="layui-input-inline">
                <input type="password" name="LoginPwd" required lay-verify="required" lay-reqtext="" placeholder="Password" 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" id="submit" style="width:190px;">Login</button>
                <input type="hidden" name="currentUser" value="@ViewData["currentUser"]" />
                <input type="hidden" name="a" value="@ViewData["a"]" />
                <input type="hidden" name="b" value="@ViewData["b"]" />
                <input type="hidden" name="c" value="@ViewData["c"]" />
                <input type="hidden" name="DomainAccount" value="@ViewData["DomainAccount"]" />
            </div>
        </div>
    </div>
</div>

@section Scripts{

    <script src="~/js/helper.js"></script>

    <script>


        //.net mvc 登录验证超时自动跳转到登录页,会嵌套到iframe中的解决方法
        if (window.top.location.href != location.href) {
            window.top.location.href = location.href;
        }

        layui.use('form', function () {
            var form = layui.form;

            var _alert = false;

            //监听提交
            form.on('submit(formDemo)', function (data) {
                //layer.msg(JSON.stringify(data.field));
                console.log("submit:" + _alert);
                //AccountLogin(data.field);
                _alert = true;
                $.post("/Login/LoginAct", data.field, function (data) {



                    if (data.code == 0) {

                        objSessionStorage.SetJsonData("UserInfo", data.data);
                        window.location.href = "/Login/Welcome";


                    }
                    //账号密码错误  ID未激活
                    else if (data.code == -1 || data.code == -2) {
                        layer.alert(data.msg, {
                            icon: 5,
                            shadeClose: true,
                            title: '提示',
                            end: function () {
                                _alert = false;
                            }
                        });

                    } else if (data.code == -4) {
                        //首次登录没有改过密码或密码超过90天未修改
                        layer.alert(data.msg, {
                            icon: 7,
                            shadeClose: true,
                            title: '提示'
                        }, function () {
                            window.location.href = "/Login/UpdatePwd";
                        });

                    }
                    else {
                        //限制10分钟不能再登录   其他
                        layer.alert(data.msg, {
                            icon: 0,
                            shadeClose: true,
                            title: '提示',
                            end: function () {
                                _alert = false;
                            }
                        });

                        //layer.msg(data.msg);
                    }

                });

                return false;
            });




            //回车登录
            $(document).keydown(function (event) {
                //console.log(6);
                if (event.keyCode == 13) {
                    console.log("keydown:" + _alert);
                    if (_alert) {
                        layer.closeAll(function () { //关闭所有层并执行回调
                            _alert = false;
                        });

                    } else {
                        $("#submit").trigger("click");
                    }
                }
            });



        });

        function AccountLogin(fdata) {

            $.post("/Login/LoginAct", fdata, function (data) {



                if (data.code == 0) {

                    objSessionStorage.SetJsonData("UserInfo", data.data);
                    window.location.href = "/Login/Welcome";


                }
                else if (data.code == -1 || data.code == -2) {
                    layer.alert(data.msg, {
                        icon: 5,
                        shadeClose: true,
                        title: '提示'
                    });
                    _alert = true;
                } else if (data.code == -4) {
                    layer.alert(data.msg, {
                        icon: 7,
                        shadeClose: true,
                        title: '提示'
                    }, function () {
                        window.location.href = "/Login/UpdatePwd";
                    });
                    _alert = true;
                }
                else {

                    layer.alert(data.msg, {
                        icon: 0,
                        shadeClose: true,
                        title: '提示'
                    });
                    _alert = true;
                    //layer.msg(data.msg);
                }

            });

        }

        //APO域账号自动登录
        function DomainAutoLogin() {

            $.post("/Login/DomainAutoLogin", {}, function (data) {
                if (data.code == 0) {
                    //console.log(data.data);
                    //alert(data.data);
                    objSessionStorage.SetJsonData("UserInfo", data.data);
                    window.location.href = "/Login/Welcome";


                }

            });

        }

        //检查是否满足 域名账号自动登录
        function DomainAutoLoginCheck() {

            $.post("/Login/DomainAutoLoginCheck", {}, function (data) {
                if (data.code == 1) {

                    layer.confirm('检测到可使用CN账号自动登录?', { icon: 3, title: '提示' }, function (index) {
                        //do something
                        DomainAutoLogin();
                        layer.close(index);

                    });

                }

            });

        }


        DomainAutoLoginCheck();


    </script>

}

 

posted @ 2023-06-26 12:21  妖狐鬼魅  阅读(49)  评论(0编辑  收藏  举报