common.js 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. var videonum = 12; //视频数量 实际数量+1
  2. var sknum = 3; //南朝石刻数量
  3. var dmznum = 0; //大明展数量
  4. var wwnum = 14; //文物数量
  5. var othernum = 2; //无分类数量
  6. window.linkUrl = "https://4dscene.4dage.com/culturalrelics/HBSBWG-TS/Model2.html";
  7. // window.linkUrl = "http://192.168.10.63:8080";
  8. const isMobile = () => {
  9. const userAgent = navigator.userAgent.toLowerCase();
  10. const isIOS = /iphone|ipod|ipad/.test(userAgent);
  11. const isAndroid = /android/.test(userAgent);
  12. const isTablet = /ipad|tablet|playbook|silk|kindle/i.test(userAgent);
  13. const hasTouch = "ontouchstart" in window || navigator.maxTouchPoints > 0;
  14. // 屏幕宽度判断
  15. const screenWidth = window.innerWidth;
  16. const isSmallScreen = screenWidth <= 1024;
  17. return isIOS || isAndroid || isTablet || (hasTouch && isSmallScreen) || screenWidth < 600;
  18. };
  19. window.isMobile = isMobile();
  20. var _czc = _czc || [];
  21. (function () {
  22. var um = document.createElement("script");
  23. um.src = "https://s4.cnzz.com/z.js?id=1281246688&async=1";
  24. var s = document.getElementsByTagName("script")[0];
  25. s.parentNode.insertBefore(um, s);
  26. })();
  27. $(function () {
  28. if (window.isMobile) {
  29. $("body").removeClass("pcbody wapbody");
  30. document.body.classList.add("wapbody");
  31. } else {
  32. $("body").removeClass("pcbody wapbody");
  33. document.body.classList.add("pcbody");
  34. }
  35. });
  36. // 或者使用防抖函数优化性能
  37. var resizeId;
  38. $(window).on("resize", function () {
  39. clearTimeout(resizeId);
  40. resizeId = setTimeout(function () {
  41. $.fn.fullpage.reBuild();
  42. }, 500);
  43. });
  44. document.oncontextmenu = new Function("event.returnValue=false;");
  45. document.onselectstart = new Function("event.returnValue=false;");
  46. document.addEventListener("contextmenu", function (event) {
  47. event.preventDefault();
  48. });
  49. var videotarget = ""; //铜牛灯另一个视频
  50. // 设置幻灯片向右滑动
  51. function showSlideNext(src) {
  52. $.fn.fullpage.moveSlideRight();
  53. videotarget = src;
  54. // 获取当前section的索引
  55. if ($("body").hasClass("pcbody")) {
  56. var index = $(".fp-completely").index();
  57. if (src) {
  58. var video = $(".section" + index + " video");
  59. $(video[0]).attr("src", src);
  60. $(video).css("width", "100%");
  61. }
  62. }
  63. }
  64. // 设置幻灯片向左滑动
  65. function showSlideBack() {
  66. $.fn.fullpage.moveSlideLeft();
  67. }
  68. //获取地址栏参数
  69. function GetQueryString(name) {
  70. var reg = new RegExp("(^|&)" + encodeURIComponent(name) + "=([^&]*)(&|$)");
  71. var r = window.location.search.substr(1).match(reg);
  72. if (r != null) {
  73. return decodeURIComponent(r[2]); // 使用 decodeURIComponent 解码
  74. }
  75. return null;
  76. }
  77. function openLink(link) {
  78. // const li = encodeURIComponent(link);
  79. // wx.miniProgram.navigateTo({
  80. // url: `/pages/webview/webview?url=${li}`,
  81. // });
  82. window.open(link);
  83. }
  84. function openDetail(id, e) {
  85. if (e) {
  86. e.stopPropagation();
  87. }
  88. if (lxs[id].url) {
  89. // const li = encodeURIComponent(lxs[id].url);
  90. // wx.miniProgram.navigateTo({
  91. // url: `/pages/webview/webview?url=${li}`,
  92. // });
  93. window.open(lxs[id].url);
  94. } else {
  95. // const li = encodeURIComponent(window.linkUrl + '#' + id);
  96. // wx.miniProgram.navigateTo({
  97. // url: `/pages/webview/webview?url=${li}`,
  98. // });
  99. window.open(window.linkUrl + "?m=" + id);
  100. }
  101. }