teacher.html 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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. }
  20. hr {
  21. clear: both;
  22. }
  23. .button {
  24. display: inline-block;
  25. width: 80px;
  26. height: 30px;
  27. background-color: red;
  28. color: white;
  29. font: 16px/30px Arial;
  30. text-decoration: none;
  31. text-align: center;
  32. }
  33. </style>
  34. </head>
  35. <body>
  36. <!-- 页面的显示逻辑 -->
  37. {% for x in teachers_list %}
  38. <div class="container">
  39. <div class="basic">
  40. <h1>{{ x.name }}老师</h1>
  41. <p><strong>讲师简介</strong></p>
  42. <p>{{ x.intro }}</p>
  43. <p><strong>教学理念</strong></p>
  44. <p>{{ x.motto }}</p>
  45. <a href="/good/{{ x.no }}" class="button">好评({{ x.good_count }})</a>
  46. <a href="/bad/{{ x.no }}" class="button">差评({{ x.bad_count }})</a>
  47. </div>
  48. <div class="potrait">
  49. {% if x.photo %}
  50. <img src="{% static x.photo %}">
  51. {% endif %}
  52. </div>
  53. <hr>
  54. </div>
  55. {% endfor %}
  56. <script src="{% static 'js/jquery.min.js' %}"></script>
  57. <script>
  58. $(function() {
  59. $('.basic .button').on('click', function(evt) {
  60. evt.preventDefault();
  61. var a = $(evt.target)
  62. var url = a.attr('href')
  63. $.getJSON(url, function(json) {
  64. if (json.code == 200) {
  65. a.text(json.result);
  66. }
  67. });
  68. });
  69. });
  70. </script>
  71. </body>
  72. </html>