

// 回到顶部功能
$(document).on('click', '[back-btn]', function (event) {
  event.preventDefault();
  $('html, body').animate({
    scrollTop: 0
  }, 600);
  return false;
});

// 复制到粘贴板功能
function copyText(str) {

  $('#copy').val(str).show();

  var ele = document.getElementById("copy");
  ele.select();
  document.execCommand('copy', false, null);
  $('#copy').hide();
}
//  // 复制到粘贴板
$(document).on('click', '[data-btn="copy"]', function () {
  layer.msg('联系方式已复制到粘贴板', {
    time: 2000
  })
  var str = $(this).attr('data-text');
  copyText(str);
})


var InterValObj; //timer变量，控制时间
var count = 60; //间隔函数，1秒执行
var curCount; //当前剩余秒数

//发送验证码
function mail() {
  curCount = count;
  var email = $('[name="phone"]').val();
  layer.msg('验证码已发送');
  document.getElementById("btnSendCode").setAttribute("disabled", "true"); //设置按钮为禁用状态
  $('#btnSendCode').addClass('layui-btn-disabled');
  $('#btnSendCode').text("剩余" + curCount + "s");
  InterValObj = window.setInterval(SetRemainTime, 1000); // 启动计时器timer处理函数，1秒执行一次
  $.ajax({
    url: "",
    data: {},
    type: "Post",
    dataType: "json",
    success: function (data) {

    },
    error: function (data) {
      $.messager.alert('错误', data.msg);
    }
  });
}

//timer处理函数
function SetRemainTime() {
  if (curCount == 0) {
    $('#btnSendCode').removeClass('layui-btn-disabled');
    $('#btnSendCode').text("重获验证码");
    window.clearInterval(InterValObj); // 停止计时器
    document.getElementById("btnSendCode").removeAttribute("disabled"); //移除禁用状态改为可用
  } else {
    curCount--;
    $('#btnSendCode').text(curCount + "秒后重获");
  }
}

var docWidth1 = document.documentElement.clientWidth > 750;
(function () {

  $('[data-load]').each(function () {
    $(this).load($(this).attr('data-load') + '.html')

  })

  var docWidth = document.documentElement.clientWidth > 750;
  var deviceWidth = document.documentElement.clientWidth > 750 ? 750 : document.documentElement.clientWidth;
  document.documentElement.style.fontSize = (deviceWidth / 7.5) + 'px';
  $(window).resize(function () {
    var deviceWidth = document.documentElement.clientWidth > 750 ? 750 : document.documentElement.clientWidth;
    document.documentElement.style.fontSize = (deviceWidth / 7.5) + 'px';

  })
  $(document).on('click', '.site-tree-mobile', function () {
    $('body').addClass('site-mobile');
  }).on('click', '.site-mobile-shade', function () {
    $('body').removeClass('site-mobile');
  });

  // // 计算input字数
  $(document).on("input", '[data-box="input-number"] input,[data-box="input-number"] textarea', function (e) {
    $(this).closest('[data-box="input-number"]').find('[data-input-num]').text(e.srcElement.value.length)
  });

  var wow = new WOW({
    boxClass: 'wow',
    animateClass: 'animate__animated',
    offset: 0,
    mobile: true,
    live: true
  });
  wow.init();


  $(document).scroll(function () {
    var scroH = $(document).scrollTop();
    if (scroH > 1) {
      $('header').addClass('bgcolor')
    } else {
      $('header').removeClass('bgcolor')
    }
  });

  $(document).on('click', '.active_ul .item', function () {
    if ($(this).closest('.active_ul').hasClass('more')) {
      $(this).toggleClass('active')
      return;
    }

    $(this).closest('.active_ul').find('.active').removeClass('active');
    $(this).addClass('active')
  })



})();