guest_book.html 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  1. <style>
  2. .comment-respond {
  3. background: white;
  4. box-shadow: 0 0 2px 0 rgba(58, 58, 58, 0.2);
  5. padding: 1.5em 4.6875375%;
  6. }
  7. .guestbook {
  8. width: 100%;
  9. float: left;
  10. padding-bottom: 3em;
  11. }
  12. .guestbook h2 span {
  13. font-size: 12px;
  14. }
  15. @media only screen and (max-width: 767px) {
  16. .comment-respond {
  17. background: white;
  18. box-shadow: 0 0 2px 0 rgba(58, 58, 58, 0.2);
  19. padding: 1.5em 7.50006%;
  20. }
  21. }
  22. h3 {
  23. font-size: 1.125em;
  24. /* 18px / 16px */
  25. line-height: 1.333;
  26. /* 24px */
  27. }
  28. .comment-respond p {
  29. margin: 1.125em 0;
  30. }
  31. .comment-respond p.comment-notes {
  32. margin: 1.5em 0;
  33. }
  34. .comment-respond label {
  35. display: block;
  36. margin-bottom: 6px;
  37. font-weight: 700;
  38. font-size: 0.875em;
  39. line-height: 1.715;
  40. }
  41. input:not([type="checkbox"]):not([type="radio"]):not([type="submit"]):not([type="file"]):not([type="image"]),
  42. textarea {
  43. width: 100%;
  44. font-family: "Roboto", "Open Sans", sans-serif;
  45. font-weight: 400;
  46. padding: 10px 12px;
  47. max-width: 27.75em;
  48. min-height: 26px;
  49. background: #F7F7F7;
  50. color: #333333;
  51. border: solid 1px #D4D4D4;
  52. border-radius: 0;
  53. -webkit-appearance: none;
  54. -webkit-transition: background 0.2s;
  55. transition: background 0.2s;
  56. }
  57. textarea {
  58. max-width: 41.625em;
  59. overflow: auto;
  60. }
  61. .comment-respond p.form-submit {
  62. margin-top: 2.25em;
  63. }
  64. input[type="submit"] {
  65. font-size: 0.75em;
  66. line-height: 1.5;
  67. }
  68. input[type="submit"] {
  69. font-family: "Roboto", "Open Sans", sans-serif;
  70. font-weight: 400;
  71. padding: 10px 12px;
  72. color: #333333;
  73. border: solid 1px #333333;
  74. background: none;
  75. border-radius: 0;
  76. -webkit-appearance: none;
  77. -webkit-transition: all 0.2s;
  78. transition: all 0.2s;
  79. }
  80. .pager {
  81. margin-left: 10%;
  82. width: 60%;
  83. background: red;
  84. }
  85. ul.pager li:first-child {
  86. float: left;
  87. }
  88. ul.pager li:last-child {
  89. float: left;
  90. margin-left: 30%;
  91. }
  92. </style>
  93. <div class="box">
  94. <div class="newsview">
  95. <h2>留言</h2>
  96. <div class="news_infos">
  97. <p>有什么想告诉我说的, 就在这吧ヾ(✿゚▽゚)ノ</p>
  98. </div>
  99. </div>
  100. <!-- #respond -->
  101. <div id="respond" class="comment-respond">
  102. <h3 id="reply-title" class="comment-reply-title">Leave a Reply</h3>
  103. <form action="{:url('/index/save_guest_book')}" method="post" id="commentform" class="comment-form" novalidate="">
  104. <p class="comment-notes"><span id="email-notes">我会妥善保存你的邮箱哒(`・ω・´).</span> 必填项已标记<span class="required">*</span>
  105. </p>
  106. <p class="comment-form-comment">
  107. <label for="comment">Comment*</label>
  108. <textarea required="" id="content" name="content" cols="45" rows="8" aria-required="true"></textarea>
  109. </p>
  110. <p class="comment-form-author">
  111. <label for="author">Name*</label>
  112. <input id="name" name="name" type="text" placeholder="Jane Doe" value="" size="26">
  113. </p>
  114. <p class="comment-form-email">
  115. <label for="contact">contact*</label>
  116. <input id="contact" name="contact" type="text" placeholder="name@email.com or 13355556666" value="" size="26">
  117. </p>
  118. <p class="comment-form-url">
  119. <label for="url">url</label>
  120. <input id="url" name="url" type="text" placeholder="https://www.google.com" value="" size="26">
  121. </p>
  122. <p class="form-submit">
  123. <button type="button" id="submit" class="submit">Post Comment</button>
  124. <!-- <input type="hidden" name="comment_post_ID" value="23" id="comment_post_ID">
  125. <input type="hidden" name="comment_parent" id="comment_parent" value="0"> -->
  126. </p>
  127. </form>
  128. <div>
  129. <p class="msg" style="display: none;color: orangered;">提交成功</p>
  130. </div>
  131. </div><!-- #respond end-->
  132. <div class="blank"></div>
  133. <div class="guestbook">
  134. {foreach $list as $val}
  135. <div class="bloglist">
  136. <div>
  137. <h2>{$val.name} <span>{$val.time|date="Y/m/d"}</span></h2>
  138. </div>
  139. <p>{$val.content}</p>
  140. </div>
  141. {/foreach}
  142. {$list->render()}
  143. </div>
  144. </div>
  145. <script>
  146. $("#submit").click(function () {
  147. $.post('/index/save_guest_book', {
  148. 'name': $("#name").val(),
  149. 'content': $("#content").val(),
  150. 'contact': $("#contact").val(),
  151. 'url': $("#url").val(),
  152. }, function (res) {
  153. console.log(res);
  154. if (res.code == 0) {
  155. $(".msg").show();
  156. var html = '<div class="bloglist"><div><h2>'+res.data.name+'<span>'+res.data.datetime+'</span></h2>';
  157. html += '</div><p>'+res.data.content+'</p></div>';
  158. $(".guestbook").prepend(html);
  159. setTimeout(()=>{
  160. $(".msg").hide();
  161. }, 1000);
  162. } else {
  163. $(".msg").html(res.msg);
  164. $(".msg").show();
  165. setTimeout(()=>{
  166. $(".msg").hide();
  167. }, 1000);
  168. $(".msg").html('提交成功');
  169. }
  170. }, 'json');
  171. })
  172. </script>