| | |
| | | form.on('submit(login)', function (data) { |
| | | var mobile = $("#mobile").val(); |
| | | if (mobile === "") { |
| | | alert("请输入账号"); |
| | | layer.msg("请输入账号", {icon: 2}) |
| | | $("#mobile").focus(); |
| | | return; |
| | | } |
| | | var password = $("#password").val(); |
| | | if (password === "") { |
| | | alert("请输入密码"); |
| | | layer.msg("请输入密码", {icon: 2}) |
| | | $("#password").focus(); |
| | | return; |
| | | } |
| | | |
| | |
| | | method: 'POST', |
| | | success: function (res) { |
| | | if (res.code === 200){ |
| | | layer.msg("登录成功", {icon: 1}) |
| | | localStorage.setItem("token", res.data.token); |
| | | localStorage.setItem("username", res.data.username); |
| | | window.location.href = "index.html"; |
| | | } else { |
| | | alert(res.msg); |
| | | layer.msg(res.msg, {icon: 2}) |
| | | } |
| | | } |
| | | }); |
| | |
| | | $('body').keydown(function () { |
| | | if (event.keyCode === 13) { |
| | | $("#login-button").click(); |
| | | } else if (event.keyCode === 115) { |
| | | $("#login-button").click(); |
| | | } |
| | | }); |
| | | |