软件系统开发定制layui 实现登录

软件系统开发定制好文章需要耐心阅读…茶凡—Matrix

软件系统开发定制在做前端登录的时候需软件系统开发定制要先理解数据提交的原理,账户和密码框实际就是一个表单数据。

🍕 输入数据后,需要获取输入表单的数据,封装好

🍕 把从表单获取的数据提交给后台,提交成功后就跳转到后台管理系统的主页面。

1、login.html

注意

本文中采用的是 + springboot + java + layui 来创建的项目,如果单纯写html可能会有一些区别。

这里需要引用layui.jquery 来做 。

<!DOCTYPE html><html lang="en" xmlns:th="http://www.thymeleaf.org/"><head>    <meta charset="UTF-8">    <title>Title</title>    <link rel="stylesheet" th:href="@{//unpkg.com/layui@2.6.8/dist/css/layui.css}">    <script type="text/javascript" th:src="@{//unpkg.com/layui@2.6.8/dist/layui.js}"></script>    <style type="text/css">        .container{            width: 420px;            height: 320px;            min-height: 320px;            max-height: 320px;            position: absolute;            top: 0;            left: 0;            bottom: 0;            right: 0;            margin: auto;            padding: 20px;            z-index: 130;            border-radius: 8px;            background-color: #fff;            box-shadow: 0 3px 18px rgba(100, 0, 0, .5);            font-size: 16px;        }        .close{            background-color: white;            border: none;            font-size: 18px;            margin-left: 410px;            margin-top: -10px;        }        .layui-input{            border-radius: 5px;            width: 300px;            height: 40px;            font-size: 15px;        }        .layui-form-item{            margin-left: -20px;        }        #logoid{            margin-top: -16px;            padding-left:150px;            padding-bottom: 15px;        }        .layui-btn{            margin-left: -50px;            border-radius: 5px;            width: 350px;            height: 40px;            font-size: 15px;        }        .verity{            width: 120px;        }        .font-set{            font-size: 13px;            text-decoration: none;            margin-left: 120px;        }        a:hover{            text-decoration: underline;        }    </style></head><body background="https://cn.bing.com/th?id=OHR.BigHole_ZH-CN2671071218_1920x1080.jpg&rf=LaDigue_1920x1080.jpg&pid=hp"><form class="layui-form" >    <div class="container">        <button class="close" title="关闭">X</button>        <div class="layui-form-mid layui-word-aux">            <img src="//tva1.sinaimg.cn/crop.0.0.118.118.180/5db11ff4gw1e77d3nqrv8j203b03cweg.jpg" class="layui-nav-img">        </div>        <div class="layui-form-item">            <label class="layui-form-label">用户名</label>            <div class="layui-input-block">                <input type="text" name="username" id="username"required  lay-verify="required" placeholder="请输入用户名" autocomplete="off" class="layui-input">            </div>        </div>        <div class="layui-form-item">            <label class="layui-form-label">&nbsp;&nbsp;</label>            <div class="layui-input-inline">                <input type="password" name="password" id="password" required lay-verify="required" placeholder="请输入密码" autocomplete="off" class="layui-input">            </div>        </div>        <div class="layui-form-item">            <div class="layui-input-block">                <button class="layui-btn" lay-submit lay-filter="login" name="login" id="login">                    登陆                </button>            </div>        </div>    </div></form><script type="text/javascript"  src="//unpkg.com/layui@2.6.8/dist/layui.js"></script><script>    layui.use(['form','jquery', 'layedit', 'laydate'], function(){        var form = layui.form            ,layer = layui.layer            ,layedit = layui.layedit            ,$= layui.jquery            ,laydate = layui.laydate;        //监听提交        form.on('submit(login)', function(data){            var $1 = $.trim($("#username").val());            var $2 = $.trim($("#password").val());            if($1 == ''){                layer.msg('用户名不能为空',function() {time:2000});                return false;            }            if($2 == ''){                layer.msg('密码不能为空',function() {time:2000});                return false;            }            $.ajax({                url:'/sys-admin/login',//发出请求                type:'post',                data:{"id":$1,"password":$2},                success:function (data)  {                    console.log(data)                    if(data.code==1){//返回1说明登录成功                        window.parent.frames.location.href="/about"                    }                    if(data.code==0){                        layer.msg('登录失败')                        window.parent.frames.location.href="/login"                    }                }            });            return false;        });    });</script></body></html>
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
  • 64
  • 65
  • 66
  • 67
  • 68
  • 69
  • 70
  • 71
  • 72
  • 73
  • 74
  • 75
  • 76
  • 77
  • 78
  • 79
  • 80
  • 81
  • 82
  • 83
  • 84
  • 85
  • 86
  • 87
  • 88
  • 89
  • 90
  • 91
  • 92
  • 93
  • 94
  • 95
  • 96
  • 97
  • 98
  • 99
  • 100
  • 101
  • 102
  • 103
  • 104
  • 105
  • 106
  • 107
  • 108
  • 109
  • 110
  • 111
  • 112
  • 113
  • 114
  • 115
  • 116
  • 117
  • 118
  • 119
  • 120
  • 121
  • 122
  • 123
  • 124
  • 125
  • 126
  • 127
  • 128
  • 129
  • 130
  • 131
  • 132
  • 133
  • 134
  • 135
  • 136
  • 137
  • 138
  • 139
  • 140
  • 141
  • 142
  • 143
  • 144
  • 145
  • 146
  • 147
  • 148
  • 149
  • 150
  • 151
  • 152
  • 153
  • 154
  • 155
  • 156
  • 157
  • 158
  • 159
  • 160

2、后台接口数据格式

后台的就不贴代码了,文章末尾可以获取
在做前端登录的时候需要先理解数据提交的原理,账户和密码框实际就是一个表单数据。

🍕 输入数据后,需要获取输入表单的数据,封装好

🍕 把从表单获取的数据提交给后台,提交成功后就跳转到后台管理系统的主页面。

1、login.html

注意

本文中采用的是 thymeleaf + springboot + java + layui 来创建的项目,如果单纯写html可能会有一些区别。

这里需要引用layui.jquery 来做 ajax请求。

<!DOCTYPE html><html lang="en" xmlns:th="http://www.thymeleaf.org/"><head>    <meta charset="UTF-8">    <title>Title</title>    <link rel="stylesheet" th:href="@{//unpkg.com/layui@2.6.8/dist/css/layui.css}">    <script type="text/javascript" th:src="@{//unpkg.com/layui@2.6.8/dist/layui.js}"></script>    <style type="text/css">        .container{            width: 420px;            height: 320px;            min-height: 320px;            max-height: 320px;            position: absolute;            top: 0;            left: 0;            bottom: 0;            right: 0;            margin: auto;            padding: 20px;            z-index: 130;            border-radius: 8px;            background-color: #fff;            box-shadow: 0 3px 18px rgba(100, 0, 0, .5);            font-size: 16px;        }        .close{            background-color: white;            border: none;            font-size: 18px;            margin-left: 410px;            margin-top: -10px;        }        .layui-input{            border-radius: 5px;            width: 300px;            height: 40px;            font-size: 15px;        }        .layui-form-item{            margin-left: -20px;        }        #logoid{            margin-top: -16px;            padding-left:150px;            padding-bottom: 15px;        }        .layui-btn{            margin-left: -50px;            border-radius: 5px;            width: 350px;            height: 40px;            font-size: 15px;        }        .verity{            width: 120px;        }        .font-set{            font-size: 13px;            text-decoration: none;            margin-left: 120px;        }        a:hover{            text-decoration: underline;        }    </style></head><body background="https://cn.bing.com/th?id=OHR.BigHole_ZH-CN2671071218_1920x1080.jpg&rf=LaDigue_1920x1080.jpg&pid=hp"><form class="layui-form" >    <div class="container">        <button class="close" title="关闭">X</button>        <div class="layui-form-mid layui-word-aux">            <img src="//tva1.sinaimg.cn/crop.0.0.118.118.180/5db11ff4gw1e77d3nqrv8j203b03cweg.jpg" class="layui-nav-img">        </div>        <div class="layui-form-item">            <label class="layui-form-label">用户名</label>            <div class="layui-input-block">                <input type="text" name="username" id="username"required  lay-verify="required" placeholder="请输入用户名" autocomplete="off" class="layui-input">            </div>        </div>        <div class="layui-form-item">            <label class="layui-form-label">&nbsp;&nbsp;</label>            <div class="layui-input-inline">                <input type="password" name="password" id="password" required lay-verify="required" placeholder="请输入密码" autocomplete="off" class="layui-input">            </div>        </div>        <div class="layui-form-item">            <div class="layui-input-block">                <button class="layui-btn" lay-submit lay-filter="login" name="login" id="login">                    登陆                </button>            </div>        </div>    </div></form><script type="text/javascript"  src="//unpkg.com/layui@2.6.8/dist/layui.js"></script><script>    layui.use(['form','jquery', 'layedit', 'laydate'], function(){        var form = layui.form            ,layer = layui.layer            ,layedit = layui.layedit            ,$= layui.jquery            ,laydate = layui.laydate;        //监听提交        form.on('submit(login)', function(data){            var $1 = $.trim($("#username").val());            var $2 = $.trim($("#password").val());            if($1 == ''){                layer.msg('用户名不能为空',function() {time:2000});                return false;            }            if($2 == ''){                layer.msg('密码不能为空',function() {time:2000});                return false;            }            $.ajax({                url:'/sys-admin/login',//发出请求                type:'post',                data:{"id":$1,"password":$2},                success:function (data)  {                    console.log(data)                    if(data.code==1){//返回1说明登录成功                        window.parent.frames.location.href="/about"                    }                    if(data.code==0){                        layer.msg('登录失败')                        window.parent.frames.location.href="/login"                    }                }            });            return false;        });    });</script></body></html>
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
  • 64
  • 65
  • 66
  • 67
  • 68
  • 69
  • 70
  • 71
  • 72
  • 73
  • 74
  • 75
  • 76
  • 77
  • 78
  • 79
  • 80
  • 81
  • 82
  • 83
  • 84
  • 85
  • 86
  • 87
  • 88
  • 89
  • 90
  • 91
  • 92
  • 93
  • 94
  • 95
  • 96
  • 97
  • 98
  • 99
  • 100
  • 101
  • 102
  • 103
  • 104
  • 105
  • 106
  • 107
  • 108
  • 109
  • 110
  • 111
  • 112
  • 113
  • 114
  • 115
  • 116
  • 117
  • 118
  • 119
  • 120
  • 121
  • 122
  • 123
  • 124
  • 125
  • 126
  • 127
  • 128
  • 129
  • 130
  • 131
  • 132
  • 133
  • 134
  • 135
  • 136
  • 137
  • 138
  • 139
  • 140
  • 141
  • 142
  • 143
  • 144
  • 145
  • 146
  • 147
  • 148
  • 149
  • 150
  • 151
  • 152
  • 153
  • 154
  • 155
  • 156
  • 157
  • 158
  • 159
  • 160

2、后台接口数据格式

后台的就不贴代码了,文章末尾可以获取

茶凡_Matrix仓亏地址:()

网站建设定制开发 软件系统开发定制 定制软件开发 软件开发定制 定制app开发 app开发定制 app开发定制公司 电商商城定制开发 定制小程序开发 定制开发小程序 客户管理系统开发定制 定制网站 定制开发 crm开发定制 开发公司 小程序开发定制 定制软件 收款定制开发 企业网站定制开发 定制化开发 android系统定制开发 定制小程序开发费用 定制设计 专注app软件定制开发 软件开发定制定制 知名网站建设定制 软件定制开发供应商 应用系统定制开发 软件系统定制开发 企业管理系统定制开发 系统定制开发