exam_detail_img.js 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. $(function () {
  2. $("img").lazyload();
  3. const globaldata = {
  4. active: null,
  5. maxlength: null,
  6. };
  7. // 实现跳转
  8. let my_nav = $(".my-nav"), top = my_nav.offset().top;
  9. $(".my-nav").click(function (e) {
  10. if (e.target.className == "my-nav") return false;
  11. let active = Array.prototype.slice.call($(this).find("li")).indexOf(e.target), id = null;
  12. // if (active == globaldata.active) return false;
  13. // globaldata.active = active;
  14. // 模板之间跳转逻辑
  15. if (e.target == $(this).find("li.active")[0]) return false;
  16. console.log(active)
  17. switch (active) {
  18. case 0:
  19. id = lxd.parseUrl(window.location.href).pathname.match(/(?<=\/h_exam\/d_).*?(?=.html)/);
  20. window.open(`/h_exam/s_${id}.html`);
  21. break;
  22. case 1:
  23. id = lxd.parseUrl(window.location.href).pathname.match(/(?<=\/h_exam\/s_).*?(?=.html)/);
  24. window.open(`/h_exam/d_${id}.html`);
  25. break;
  26. default:
  27. break;
  28. }
  29. // 模板内部跳转逻辑
  30. // $(this).find(".active").removeClass("active");
  31. // $(e.target).addClass("active");
  32. // // 获取跳转锚点到顶部的距离
  33. // let title = $("#title").offset().top;
  34. // let edi_answer = $("#edi-answer").offset().top;
  35. // let interactive = $("#interactive").offset().top;
  36. // let lis = $(this).find("li");
  37. // let i = Array.prototype.slice.call(lis).indexOf($(e.target)[0]);
  38. // // 储存锚点
  39. // let maos = [title, edi_answer, interactive];
  40. // $(window).scrollTop(maos[i]);
  41. })
  42. $(window).scroll(
  43. function () {
  44. let scrolltop = document.documentElement.scrollTop || document.body.scrollTop;
  45. if (scrolltop >= top) { my_nav.addClass("fixed"); } else {
  46. my_nav.removeClass("fixed")
  47. }
  48. }
  49. )
  50. // 查看更多
  51. $("[data-click='open']").click(function () {
  52. let bool = $(this).data("open");
  53. if (!bool) {
  54. $("#toast").show();
  55. // $(this).data("open", true).children("span").text("收起阅读全部").parent().children("i").removeClass("glyphicon-chevron-down").addClass("glyphicon-chevron-up").parent().parent().parent().addClass("edi-body-height");
  56. } else {
  57. $(this).data("open", false).children("span").text("展开阅读全部").parent().children("i").removeClass("glyphicon-chevron-up").addClass("glyphicon-chevron-down").parent().parent().parent().removeClass("edi-body-height");
  58. }
  59. })
  60. // // 不能实现的事件
  61. // function warm () {
  62. // alert("请在大联考App内登录后操作")
  63. // }
  64. // // $(".edi-open>span[data-click='open']").click(warm)
  65. // $(".edi-user").click(warm)
  66. // $(".choose").click(warm)
  67. // 默认 时间
  68. // $(".pull-right>span").click(function () {
  69. // $(this).addClass('active').siblings("span").removeClass("active");
  70. // })
  71. })