public.js 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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. $('#main').css('min-height', browserHeight - headerHeight - footerHeight);
  18. }, 0)
  19. }
  20. /**
  21. * 年龄提示方法
  22. */
  23. function ageReminderMethod() {
  24. const ageReminder = localStorage.getItem(VAPES_AGEREMINDER);
  25. const maskElement = $(".maskContainer");
  26. if (!ageReminder) {
  27. maskElement.show(0)
  28. } else {
  29. maskElement.hide(0)
  30. }
  31. }
  32. /**
  33. * 手机端菜单展开收起
  34. */
  35. function starSlideToggle() {
  36. $(".mobileMenuFixed").stop().slideToggle(80);
  37. if (mobileMenuBot.hasClass('open')) {
  38. mobileMenuBot.removeClass('open');
  39. } else {
  40. mobileMenuBot.addClass('open');
  41. }
  42. }
  43. /**
  44. * 年龄提示 NO 点击
  45. */
  46. $(".ageReminderNo").on(tap, function () {
  47. window.close()
  48. history.back();
  49. });
  50. /**
  51. * 年龄提示 Yes 点击
  52. */
  53. $(".ageReminderYes").on(tap, function () {
  54. localStorage.setItem(VAPES_AGEREMINDER, "1");
  55. $(".maskContainer").hide(0)
  56. });
  57. /**
  58. * 手机端菜单绑定事件
  59. */
  60. mobileMenuBot.on('tap', starSlideToggle)
  61. ageReminderMethod()
  62. initMainHeight()
  63. })