exam_detail.js 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. $(function () {
  2. let list_flex = $(".list .list-flex ");
  3. function href (e) {
  4. e.stopPropagation();
  5. let url = $(this).data("href");
  6. if (!url) {
  7. $("#toast").show();
  8. return false
  9. };
  10. window.location.href = url;
  11. }
  12. Array.from(list_flex).forEach(item => {
  13. let list_item = $(item).find(".list-item,.p>div");
  14. list_item.click(href);
  15. let list = $(item).find(".list-item");
  16. if (list.length == 1) {
  17. $(item).append(`<div style="visibility:hidden" class="list-item"></div>`);
  18. }
  19. })
  20. })
  21. $(function () {
  22. let path = lxd.parseUrl(window.location.href).pathname;
  23. let reg = /(?<=\/h_exam\/).*?(?=.html)/;
  24. $.ajax({
  25. url: `http://api.gaokaoapp.net/exampaper/h/${path.match(reg)}/`,
  26. data: {
  27. },
  28. type: "get",
  29. error: function (error) {
  30. $(".loading").html("获取更多的评论,请下载大联考app").show();
  31. },
  32. success: function (res) {
  33. let { comments, like_count = 1, read_count = 1 } = res.data;
  34. $(".good>span").html(like_count);
  35. $(".see").html(`阅读数:${read_count}`);
  36. let father = document.createDocumentFragment();
  37. Array.from(comments).forEach(
  38. item => {
  39. item.user_face = item.user_face || '../imgs/user_face.png';
  40. let str = `<div class="user" data-good="false" data-userid="1" >
  41. <div class="u-img"><img src="${item.user_face}" alt="" class="img"></div>
  42. <div class="u-content">
  43. <div class="u-flex">
  44. <div class="u-name">${item.user_name}</div>
  45. <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>
  46. </div>
  47. <div class="u-detail">
  48. ${item.content}
  49. </div>
  50. <div class="u-flex">
  51. <div class="u-date">${item.delay_time}</div>
  52. </div>
  53. </div>
  54. </div>`;
  55. $(father).append(str);
  56. }
  57. )
  58. $("#detail").append(father);
  59. $(".loading").html("获取更多的评论,请下载大联考app").show()
  60. }
  61. })
  62. })