login.html 3.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. {% extends "index/base.html" %}
  2. {% block title %}登陆 - 河海大学论坛{% endblock %}
  3. {%- block content -%}
  4. <script type=text/javascript>
  5. $(document).ready(function(){
  6. $('a#clickCode').click(function() {
  7. $("#changeCode").attr("src","/validcode?code=" + Math.random());
  8. });
  9. $('button#ajax').click(function() {
  10. $.ajax ({
  11. type : "POST",
  12. url : "{{ url_for('auth.login') }}",
  13. data:JSON.stringify({
  14. name: $('#name').val(),
  15. passwd: $('#passwd').val(),
  16. remember: $("#remember").is(':checked'),
  17. code:$("#code").val()
  18. }),
  19. contentType: 'application/json;charset=UTF-8',
  20. success: function(result) {
  21. if (result.judge == true)
  22. {
  23. window.location = '{{ request.args.get('next') or '/' }}';
  24. }
  25. else
  26. {
  27. $("#showerror").show();
  28. $("#error").text(result.error);
  29. }
  30. }
  31. });
  32. });
  33. });
  34. </script>
  35. <ol class="breadcrumb" style="margin-bottom:0;">
  36. <li><a href="{{ url_for('forums.forums') }}"><span class="glyphicon glyphicon-home" aria-hidden="true"></span>社区首页</a></li>
  37. <li class="active">登陆</li>
  38. </ol>
  39. <div class="panel panel-primary">
  40. <div class="panel-heading">
  41. <a href="{{ url_for('auth.login') }}" style="color:#fff">登陆页</a>
  42. </div>
  43. <div class="panel-body" style="border-bottom:1px solid #f6e1e1;">
  44. <table align="center" style="font-size:14px;">
  45. <tr>
  46. <td colspan="2">
  47. <div class="alert alert-info" id="showerror" style="padding:8px;">
  48. <button type="button" class="close" id="hide">
  49. <span aria-hidden="true">&times;</span>
  50. </button>
  51. <ul>
  52. <li id="error"></li>
  53. </ul>
  54. </div>
  55. </td>
  56. </tr>
  57. <tr>
  58. <td>{{ form.name.label }}</td>
  59. <td style="padding-bottom:10px;"> {{ form.name(class="form-control",placeholder="name",style="width:240px") }}</td>
  60. </tr>
  61. <tr>
  62. <td>{{ form.passwd.label }}</td>
  63. <td style="padding-bottom:10px;">{{ form.passwd(class="form-control",placeholder="password",style="width:240px") }}</td>
  64. </tr>
  65. <tr>
  66. <td>{{ form.code.label }}</td>
  67. <td colspan="2" style="padding-bottom:10px;">
  68. {% include 'auth/validate.html' %}
  69. </td>
  70. </tr>
  71. <tr>
  72. <td></td>
  73. <td style="padding-bottom:10px;">
  74. <button type="button" class="btn btn-primary" id="ajax">登陆</button>
  75. <a href="{{ url_for('auth.forget') }}">忘记密码?</a>
  76. </td>
  77. </tr>
  78. <tr>
  79. <td></td>
  80. <td>{{ form.remember() }} 记住我</td>
  81. </tr>
  82. <tr>
  83. <td></td>
  84. <td><a href="{{ url_for('auth.register') }}">还未注册</a></td>
  85. </tr>
  86. </table>
  87. </div>
  88. </div>
  89. {% endblock %}