exam_detail.js 2.4 KB

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