teacher.html 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. <!DOCTYPE html>
  2. {% load staticfiles %}
  3. <html lang="en">
  4. <head>
  5. <meta charset="UTF-8">
  6. <title>讲师信息</title>
  7. <style>
  8. .container {
  9. width: 960px;
  10. margin: 0 auto;
  11. }
  12. .basic {
  13. width: 60%;
  14. float: left;
  15. }
  16. .potrait {
  17. width: 40%;
  18. float: left;
  19. text-align: right;
  20. }
  21. hr {
  22. clear: both;
  23. }
  24. .button {
  25. display: inline-block;
  26. width: 80px;
  27. height: 30px;
  28. background-color: red;
  29. color: white;
  30. font: 16px/30px Arial;
  31. text-decoration: none;
  32. text-align: center;
  33. }
  34. </style>
  35. </head>
  36. <body>
  37. <!-- 页面的显示逻辑 -->
  38. {% for x in teachers_list %}
  39. <div class="container">
  40. <div class="basic">
  41. <h1>{{ x.name }}老师 - {{ x.subject.name }}</h1>
  42. <p><strong>讲师简介</strong></p>
  43. <p>{{ x.intro }}</p>
  44. <p><strong>教学理念</strong></p>
  45. <p>{{ x.motto }}</p>
  46. <a href="/good/{{ x.no }}" class="button">好评({{ x.gcount }})</a>
  47. <a href="/bad/{{ x.no }}" class="button">差评({{ x.bcount }})</a>
  48. </div>
  49. <div class="potrait">
  50. {% if x.photo %}
  51. <img src="{% static x.photo %}">
  52. {% endif %}
  53. </div>
  54. <hr>
  55. </div>
  56. {% endfor %}
  57. <script src="{% static 'js/jquery.min.js' %}"></script>
  58. <script>
  59. $(function() {
  60. $('.basic .button').on('click', function(evt) {
  61. evt.preventDefault();
  62. var $a = $(evt.target);
  63. var url = $a.attr('href');
  64. $.ajax({
  65. 'url': url,
  66. 'type': 'get',
  67. 'data': {},
  68. 'dataType': 'json',
  69. 'success': function(json) {
  70. if (json.code == 200) {
  71. $a.text(json.result);
  72. } else if (json.code == 403) {
  73. alert(json.result);
  74. }
  75. },
  76. 'error': function() {}
  77. });
  78. });
  79. });
  80. </script>
  81. </body>
  82. </html>