sign_in.html 3.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <title>Aisky-Sixth</title>
  6. <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
  7. <!-- 新 Bootstrap4 核心 CSS 文件 -->
  8. <link rel="stylesheet" href="https://cdn.bootcss.com/bootstrap/4.1.0/css/bootstrap.min.css">
  9. <!-- jQuery文件。务必在bootstrap.min.js 之前引入 -->
  10. <script src="https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js"></script>
  11. <!-- popper.min.js 用于弹窗、提示、下拉菜单 -->
  12. <script src="https://cdn.bootcss.com/popper.js/1.12.5/umd/popper.min.js"></script>
  13. <!-- 最新的 Bootstrap4 核心 JavaScript 文件 -->
  14. <script src="https://cdn.bootcss.com/bootstrap/4.1.0/js/bootstrap.min.js"></script>
  15. <script src="../static/js/sign_in.js"></script>
  16. <link rel="stylesheet" href="../static/css/sign_in.css">
  17. {% if errMsg %}
  18. <script>
  19. $(function(){
  20. $(".wrong-span").text("{{errMsg}}");
  21. });
  22. </script>
  23. {% endif %}
  24. <script>
  25. function SignIn(){
  26. var username = $("input[name=username]").val();
  27. var password = $("input[name=password]").val();
  28. var data = {"username":username, "password":password};
  29. $.ajax({
  30. url: "/login",
  31. type: "post",
  32. data: data,
  33. dataType: "json",
  34. success: function(res){
  35. if(res.access_token){
  36. console.log("test");
  37. localStorage.setItem('Hello', res.access_token);
  38. window.location.href='/';
  39. };
  40. if(res.errMsg){
  41. $(".wrong-span").text("{{errMsg}}");
  42. };
  43. },
  44. });
  45. };
  46. </script>
  47. </head>
  48. <body>
  49. <div class="container">
  50. <div class="row">
  51. <div class="col-2"></div>
  52. <div class="col">
  53. <img src="../static/img/logo_new.png" class="img-fluid">
  54. <h1 class="text-center">Sign in</h1>
  55. <!--<form method="post" action="/login">-->
  56. <div class="wrong-info"><span class="wrong-span"></span></div>
  57. <div class="form">
  58. <div class="form-inline">
  59. <label for="usr">Login</label>
  60. <input type="text" class="form-control" id="usr" name="username">
  61. </div>
  62. <div class="form-inline">
  63. <label for="pwd">Password</label>
  64. <input type="password" class="form-control" id="pwd" name="password">
  65. </div>
  66. <div class="radio">
  67. <label><input type="checkbox" name="rem"> Remember me</label>
  68. <a href="#">Reset password</a>
  69. </div>
  70. </div>
  71. <div class="text-center">
  72. <input type="submit" class="btn btn-info" value="Log in" onclick="SignIn()" style="margin-right:100px;">
  73. <input type="button" class="btn btn-info" value="Registration" onclick="Registration()">
  74. </div>
  75. <!--</form>-->
  76. </div>
  77. <div class="col-2"></div>
  78. </div>
  79. </div>
  80. </body>
  81. </html>