var videonum = 12; //视频数量 实际数量+1
var sknum = 3; //南朝石刻数量
var dmznum = 0; //大明展数量
var wwnum = 14; //文物数量
var othernum = 2; //无分类数量
window.linkUrl = "https://4dscene.4dage.com/culturalrelics/HBSBWG-TS/Model2.html";
// window.linkUrl = "http://192.168.10.63:8080";
const isMobile = () => {
  const userAgent = navigator.userAgent.toLowerCase();
  const isIOS = /iphone|ipod|ipad/.test(userAgent);
  const isAndroid = /android/.test(userAgent);
  const isTablet = /ipad|tablet|playbook|silk|kindle/i.test(userAgent);
  const hasTouch = "ontouchstart" in window || navigator.maxTouchPoints > 0;

  // 屏幕宽度判断
  const screenWidth = window.innerWidth;
  const isSmallScreen = screenWidth <= 1024;

  return isIOS || isAndroid || isTablet || (hasTouch && isSmallScreen) || screenWidth < 600;
};
window.isMobile = isMobile();

var _czc = _czc || [];
(function () {
  var um = document.createElement("script");
  um.src = "https://s4.cnzz.com/z.js?id=1281246688&async=1";
  var s = document.getElementsByTagName("script")[0];
  s.parentNode.insertBefore(um, s);
})();

$(function () {
  if (window.isMobile) {
    $("body").removeClass("pcbody wapbody");
    document.body.classList.add("wapbody");
  } else {
    $("body").removeClass("pcbody wapbody");
    document.body.classList.add("pcbody");
  }
});
// 或者使用防抖函数优化性能
var resizeId;
$(window).on("resize", function () {
  clearTimeout(resizeId);
  resizeId = setTimeout(function () {
    $.fn.fullpage.reBuild();
  }, 500);
});

document.oncontextmenu = new Function("event.returnValue=false;");
document.onselectstart = new Function("event.returnValue=false;");

document.addEventListener("contextmenu", function (event) {
  event.preventDefault();
});
var videotarget = ""; //铜牛灯另一个视频
// 设置幻灯片向右滑动
function showSlideNext(src) {
  $.fn.fullpage.moveSlideRight();
  videotarget = src;
  // 获取当前section的索引
  if ($("body").hasClass("pcbody")) {
    var index = $(".fp-completely").index();
    if (src) {
      var video = $(".section" + index + " video");
      $(video[0]).attr("src", src);
      $(video).css("width", "100%");
    }
  }
}

// 设置幻灯片向左滑动
function showSlideBack() {
  $.fn.fullpage.moveSlideLeft();
}

//获取地址栏参数
function GetQueryString(name) {
  var reg = new RegExp("(^|&)" + encodeURIComponent(name) + "=([^&]*)(&|$)");
  var r = window.location.search.substr(1).match(reg);
  if (r != null) {
    return decodeURIComponent(r[2]); // 使用 decodeURIComponent 解码
  }
  return null;
}

function openLink(link) {
  // const li = encodeURIComponent(link);
  // wx.miniProgram.navigateTo({
  //   url: `/pages/webview/webview?url=${li}`,
  // });
  window.open(link);
}

function openDetail(id, e) {
  if (e) {
    e.stopPropagation();
  }
  if (lxs[id].url) {
    // const li = encodeURIComponent(lxs[id].url);
    // wx.miniProgram.navigateTo({
    //   url: `/pages/webview/webview?url=${li}`,
    // });
    window.open(lxs[id].url);
  } else {
    // const li = encodeURIComponent(window.linkUrl + '#' + id);
    // wx.miniProgram.navigateTo({
    //   url: `/pages/webview/webview?url=${li}`,
    // });
    window.open(window.linkUrl + "?m=" + id);
  }
}
