exam_detail.js 2.0 KB

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