public.js 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. $(document).ready(function () {
  2. const VAPES_AGEREMINDER = "vapes_ageReminder"
  3. //用户存储token名
  4. const VAPES_TOKEN = "vapes_token"
  5. //菜单按钮
  6. const mobileMenuBot = $('#mobileMenuBot');
  7. //触屏事件 || 点击事件
  8. const tap = "ontouchstart" in window ? "touchstart" : "click";
  9. if ($.fn.lazyload) {
  10. $("img.lazy").lazyload();
  11. }
  12. const initMainHeight = () => {
  13. setTimeout(() => {
  14. const browserHeight = $(window).height();
  15. const headerHeight = $("#headerContainer").height();
  16. const footerHeight = $("#footerContainer").height();
  17. const minHeight = browserHeight - headerHeight - footerHeight
  18. $('#main').css('min-height', minHeight);
  19. $('#userNavContainer').css('min-height', minHeight);
  20. }, 0)
  21. }
  22. /**
  23. * 年龄提示方法
  24. */
  25. function ageReminderMethod() {
  26. const ageReminder = localStorage.getItem(VAPES_AGEREMINDER);
  27. const maskElement = $(".maskContainer");
  28. if (!ageReminder) {
  29. maskElement.show(0)
  30. } else {
  31. maskElement.hide(0)
  32. }
  33. }
  34. /**
  35. * 手机端菜单展开收起
  36. */
  37. function starSlideToggle() {
  38. $(".mobileMenuFixed").stop().slideToggle(80);
  39. if (mobileMenuBot.hasClass('open')) {
  40. mobileMenuBot.removeClass('open');
  41. } else {
  42. mobileMenuBot.addClass('open');
  43. }
  44. }
  45. /**
  46. * 年龄提示 NO 点击
  47. */
  48. $(".ageReminderNo").on(tap, function () {
  49. window.close()
  50. history.back();
  51. });
  52. /**
  53. * 年龄提示 Yes 点击
  54. */
  55. $(".ageReminderYes").on(tap, function () {
  56. localStorage.setItem(VAPES_AGEREMINDER, "1");
  57. $(".maskContainer").hide(0)
  58. });
  59. /**
  60. * 手机端菜单绑定事件
  61. */
  62. mobileMenuBot.on('tap', starSlideToggle)
  63. ageReminderMethod()
  64. initMainHeight()
  65. })