exam_detail.js 2.0 KB

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