new_detail.js 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. $(function () {
  2. let path = lxd.parseUrl(window.location.href).pathname;
  3. let reg = /(?<=\/h_news\/).*?(?=.html)/;
  4. $.ajax({
  5. url: `http://api.gaokaoapp.net/news/h/${path.match(reg)}/`,
  6. data: {
  7. },
  8. type: "get",
  9. error: function (error) {
  10. $(".loading").html("获取更多的评论,请下载大联考app").show();
  11. },
  12. success: function (res) {
  13. let { comments, like_count = 1, read_count = 1 } = res.data;
  14. $(".good>span").html(like_count);
  15. $(".see").html(`阅读数:${read_count}`);
  16. let father = document.createDocumentFragment();
  17. Array.from(comments).forEach(
  18. item => {
  19. let str = `<div class="user" data-good="false" data-userid="1" >
  20. <div class="u-img"><img src="${item.user_face}" alt="" class="img"></div>
  21. <div class="u-content">
  22. <div class="u-flex">
  23. <div class="u-name">${item.user_name}</div>
  24. <div class="u-fabulous" data-gods="1"><span>${item.like_count}</span><i data-gods="1" style="margin-left:5px" class="glyphicon glyphicon-thumbs-up"></i></div>
  25. </div>
  26. <div class="u-detail">
  27. ${item.content}
  28. </div>
  29. <div class="u-flex">
  30. <div class="u-date">${item.delay_time}</div>
  31. </div>
  32. </div>
  33. </div>`;
  34. $(father).append(str);
  35. }
  36. )
  37. $("#detail").append(father);
  38. $(".loading").html("获取更多的评论,请下载大联考app").show()
  39. }
  40. })
  41. })