var isMobile = false; // <=1024为移动端 var w_width = 0; // 可视区域宽 var w_height = 0; // 可视区域高 var $mtoph = 0; // 类似header高 var $menuBtn = $('.menu-handler'); // 手机导航按钮 var $menuBox = $('.menuBox'); // 手机导航 var navItem = 0; // 导航是否展开标识 // 移动端事件和PC事件的切换 var _mousemove; var _click; var _mousedown; var _mouseup; if (Modernizr.touch) { _mousemove = 'touchmove'; _click = 'touchend'; _mousedown = 'touchstart'; _mouseup = 'touchend'; _mouseenter = 'touchend'; } else { _mousemove = 'mousemove'; _click = 'click'; _mousedown = 'mousedown'; _mouseup = 'mouseup'; _mouseenter = 'mouseenter'; } function pageBox() { w_width = $(window).width(); w_height = $(window).height(); if ($('.mtop')) { $mtoph = $('.mtop').height(); } isMobile = w_width <= 1024; } pageBox(); $(window).resize(function () { pageBox(); }); function showBackTop() { var ST = $(window).scrollTop(); if (ST > $mtoph) { $('#top').removeClass('hide'); } else { $('#top').addClass('hide'); } } $(function () { showBackTop(); // $(".header .nav li").mouseenter(function () { // var num = $(this).data("num"); // if (num === 4) { // $(".pro-nav").stop().fadeIn(); // } else { // $(".pro-nav").stop().fadeOut(); // } // }); // $(".header").mouseleave(function () { // $(".pro-nav").stop().fadeOut(); // }); // $('.header') // .mousemove(function (e) { // if ($(e.target).parents('.nav').length) { // var num = $(e.target).data('num'); // if (num === 4) { // $('.pro-nav').addClass('show'); // } else { // $('.pro-nav').removeClass('show'); // } // } else if (!$(e.target).parents('.pro-nav').length) { // $('.pro-nav').removeClass('show'); // } // }) // .mouseleave(function () { // $('.pro-nav').removeClass('show'); // }); // $('.course-filter-nav .nav li > p').bind(_click, function () { // var $parent = $(this).parent(); // var $options = $parent.find('.options'); // var act = $parent.hasClass('act'); // if (!act) { // $('.course-filter-nav .nav li').removeClass('act'); // $('.course-filter-nav .nav .options').stop().slideUp(); // $parent.addClass('act'); // $options.stop().slideDown(); // } else { // $parent.removeClass('act'); // $options.stop().slideUp(); // } // }); // $('.page-menu-btn').bind(_click, function (e) { // e.preventDefault(); // var act = $(this).hasClass('act'); // var $menu = $(this).parent().find('.page-menu-box'); // if (act) { // $(this).removeClass('act'); // $menu.removeClass('show'); // } else { // $(this).addClass('act'); // $menu.addClass('show'); // } // }); // gotoDestination(); // setListDelay('.back-wrap2 li'); // setListDelay('.feature-nav li'); // setListDelay('.cul-back li'); // setListDelay('.pnav li'); // setLastClass('.f-nav li'); // setLastClass('.f-service li'); // toggleActive('.go-btns a'); // toggleActive('.btn-collect'); // setListDelay('.f-service li', 200, 200); // setListDelay('.fixctas li', 200, 200); $('.header .nav .more').mouseenter(function () { $('.moreNav').stop(true, true).slideDown(); }); $('.header').mouseleave(function () { $('.moreNav').stop(true, true).slideUp(); }); $('.agreeBtn').bind(_click, function () { $(this).toggleClass('act'); }); // $('input[type=radio]').click(function () { // $('input[type=radio]').parent().removeClass('checked'); // $(this).parent().addClass('checked'); // }); // $('input[type=file]').change(function (e) { // var files = e.target.files; // var imgEle = $(this).parent().next('.uploadImg'); // if (!imgEle.length) { // imgEle = $(this).parents('.de-picture-upload').find('.uImg'); // } // var isHide = imgEle.is(':hidden'); // if (isHide) { // imgEle.show(); // } else { // imgEle.html(''); // } // for (var i = 0; i < files.length; i++) { // var imgUrl = URL.createObjectURL(files[i]); // imgEle.append('
  • '); // } // }); $('.shareBtn').bind(_click, function (e) { e.preventDefault(); $('.ly-share').stop().fadeIn().addClass('show'); }); $('.ly-close').bind(_click, function (e) { e.preventDefault(); $('.ly-share').stop().fadeOut().removeClass('show'); }); $('.menu-handler').bind(_click, function (e) { e.preventDefault(); var active = $(this).hasClass('active'); if (active) { $(this).removeClass('active'); $('.m-header').removeClass('active'); $('.footer .ft').removeClass('active'); } else { $(this).addClass('active'); $('.m-header').addClass('active'); $('.footer .ft').addClass('active'); } }); closeModal('.ly-close'); // openModal('.openModalBtn'); // $('.multipleSelect .options a').on(_click, function () { // var isSelected = $(this).hasClass('selected'); // var parent = $(this).parents('.multipleSelect'); // var textEle = parent.find('.se'); // var placeholder = parent.find('.placeholder'); // var currText = $(this).text(); // var texts = textEle.text(); // if (isSelected) { // $(this).removeClass('selected'); // var arr = texts.split(';'); // var newText = ''; // for (var i = 0; i < arr.length; i++) { // if (arr[i] !== currText && arr[i]) { // newText = arr[i] + ';'; // } // } // textEle.text(newText); // if (!newText) { // placeholder.show(); // } // } else { // $(this).addClass('selected'); // if (!texts) { // placeholder.hide(); // } // textEle.text(texts + currText + ';'); // } // }); // $('.multipleSelect .se').on(_click, function () { // var parent = $(this).parents('.multipleSelect'); // $('.multipleSelect').removeClass('focus'); // $('.multipleSelect').find('.options').stop(true, true).slideUp(); // parent.addClass('focus'); // parent.find('.options').stop(true, true).slideDown(); // }); // $(document).on(_click, function (e) { // var curr = $(e.target).hasClass('multipleSelect'); // var parents = $(e.target).parents('.multipleSelect'); // if (!curr && !parents.length) { // $('.multipleSelect').removeClass('focus'); // $('.multipleSelect').find('.options').stop(true, true).slideUp(); // } // }); // $('.header .pro').mouseenter(function() { // $('.pull-nav').stop().fadeIn().addClass('active'); // $(this).addClass('show'); // }); // $('.pro-nav-list li').each(function(i, e) { // $(this).css({ 'transition-delay': 200*i + 'ms' }); // }); // $('.header').mouseleave(function() { // $('.pull-nav').stop().fadeOut(function() { // $(this).removeClass('active'); // }); // $('.header .pro').removeClass('show'); // }); // $('.navMobile dd').each(function(i, e) { // $(this).css({ 'transition-delay': 300 + 100*i + 'ms' }); // }); // $('.navMobile dd p a').bind(_click, function (e) { // if($(this).parent().next('.mtnav').size() >= 1){ // if(!$(this).hasClass('act')){ // e.preventDefault(); // $('.navMobile dd p a').removeClass('act'); // $('.mtnav').stop().slideUp(300); // $(this).addClass('act'); // $(this).parent().next('.mtnav').stop().slideDown(300); // }else{ // $(this).removeClass('act'); // $(this).parent().next('.mtnav').stop().slideUp(300); // } // } // }); // $('.omenu > li > a').bind(_click, function(e) { // var $tmenu = $(this).next('.tmenu'); // var active = $tmenu.hasClass('active'); // var len = $tmenu.length; // var menuActive = $('.omenu').hasClass('menuActive'); // if (len && !active) { // e.preventDefault(); // if (menuActive) { // $('.tmenu').hide().removeClass('active'); // $('.omenu > li > a').removeClass('act'); // } else { // $('.omenu').addClass('menuActive'); // } // $tmenu.show(function() { // $(this).addClass('active'); // }); // $(this).addClass('act'); // } // }); // $('.tmenu .back').bind(_click, function(e) { // e.preventDefault(); // $('.omenu').removeClass('menuActive'); // var $tmenu = $(this).parents('.tmenu'); // $tmenu.hide().removeClass('active'); // $tmenu.siblings('a').removeClass('act'); // }); // $('.omenu > li').each(function(i) { // var $tmenu = $(this).find('.tmenu'); // var len = $tmenu.length; // if (len) { // setListDelay($tmenu.find('div'), 100, 400); // } // }); // $menuBtn.bind(_click, function () { // if (navItem == 0) { // $(this).addClass("active"); // $menuBox.show().stop(false,false).animate({top:0}).addClass('show'); // navItem = 1; // } else { // $(this).removeClass("active"); // $menuBox.stop(false,false).animate({top:-100+"%"},function(){ // $(this).hide().removeClass('show'); // }); // navItem = 0; // } // }); if ($('.splwo').length !== 0) { $('.splwo').each(function (i) { splitWords($(this)); }); } // 友情链接 // var isopen = 0; // $('.friendship-link').bind(_click, function(){ // if(isopen==0){ // isopen = 1; // $(this).addClass('act'); // $('.friendship-link .k').stop().slideDown(300); // }else{ // isopen = 0; // $(this).removeClass('act'); // $('.friendship-link .k').stop().slideUp(300); // } // }); // $('.friendship-link').mouseleave(function(){ // isopen = 0; // $('.friendship-link').removeClass('act'); // $('.friendship-link .k').stop().slideUp(300); // }); // 手机导航 $('.navMobile dd > p > a').bind(_click, function (e) { var $mtnav = $(this).parent().next('.mtnav'); if ($mtnav.size() >= 1) { if (!$(this).hasClass('act')) { e.preventDefault(); $('.navMobile dd > p > a').removeClass('act'); $('.mtnav').stop().slideUp(300); $(this).addClass('act'); $mtnav.stop().slideDown(300); } else { $(this).removeClass('act'); $mtnav.stop().slideUp(300); } } }); $menuBtn.bind(_click, function () { var w = $menuBox.width(); if (navItem == 0) { $('html').addClass('open'); $(this).addClass('active'); $menuBox.show().stop(false, false).animate({ top: 0 }); navItem = 1; } else { $('html').removeClass('open'); $(this).removeClass('active'); $menuBox.stop(false, false).animate({ top: '-100%' }, function () { $(this).hide(); }); navItem = 0; } }); $(window).scroll(function () { // page banner // var windowTop = $(window).scrollTop(); // if (windowTop < w_height && !isMobile) { // $(".pbanner .pic2 img").css("transform", "translate(0px," + windowTop / 1.5 + "px)"); // } showBackTop(); // intoShowLeaveHide('.pnav', '.container', '.footer'); // intoShowLeaveHide('.feature-nav', '.container', '.footer'); // intoShowLeaveHide('.back-wrap2', '.container', '.footer'); // intoShowLeaveHide('.cul-back', '.container', '.footer'); }); // Imitation placeholder function $('.s-input').bind({ focus: function () { if (this.value == this.defaultValue) { this.value = ''; } }, blur: function () { if (this.value == '') { this.value = this.defaultValue; } }, }); // Back to top $('#top').bind(_click, function () { $('html,body').stop().animate({ scrollTop: 0 }, 800); }); // Scroll a screen $('#mouse').bind(_click, function () { $('html,body').stop().animate({ scrollTop: w_height }, 800); }); // video play $('.videoBox .close, .videoBox .videoBg').bind(_click, function () { objplay.stop(); $('.videoBox').hide(); $('#videoPlay').html(''); }); $('.vi-btn').bind(_click, function (e) { e.stopPropagation(); e.preventDefault(); var img = $(this).attr('data-video-image'); var video = $(this).attr('data-video-url'); Video.load({ vcontainer: 'videoPlay', vfimg: img, vfiles: video, isautoplay: 'true', }); $('.videoBox').fadeIn(); }); // weixin $('.wxBtn').bind(_click, function (e) { e.preventDefault(); if (isMobile) { setPopUp($(this), '请扫描二维码'); } }); function setPopUp(obj, title) { var str = '
    '; $('body').append(str); $('.popUpblack').fadeIn().addClass('show'); $('.popUp .close, .popUpblack').bind(_click, function () { $('.popUpblack').remove(); }); } $('.btn-tel').bind(_click, function () { $('.ly-tel').show(function () { $('.ly-tel').addClass('show'); }); }); $(document).on(_click, '.ly-weixin .ly-close', function (e) { e.preventDefault(); $('.ly-weixin').remove(); }); $(document).on(_click, '.ly-tel .ly-close', function (e) { e.preventDefault(); $('.ly-tel').hide().removeClass('show'); }); $(document).on(_click, function (e) { if ($(e.target).hasClass('ly-tel')) { e.preventDefault(); e.stopPropagation(); $('.ly-tel').hide().removeClass('show'); } if ($(e.target).hasClass('ly-weixin')) { e.preventDefault(); e.stopPropagation(); $('.ly-weixin').remove(); } }); // hash function setScroll(anchorCur) { if (jQuery(anchorCur).length >= 1) { jQuery('html,body').animate({ scrollTop: jQuery(anchorCur).offset().top - $mtoph }, 0); } } window.onload = function () { var hash = location.href.split('#')[1]; if (hash) { setScroll('#' + hash); } }; }); // 移动端定位当前导航(需要结合定位来实现) function showCurrentNav(selector) { var el = $(selector); if (!isMobile || !el) return; el.find('li').each(() => { var _act = $(this).find('a').hasClass('act'); if (_act) { el.scrollLeft($(this).position().left); } }); } // 视频播放 var objplay; var Video = { load: function (objs) { objplay = jwplayer(objs.vcontainer).setup({ flashplayer: 'js/video/flashplay.swf', html5player: 'js/video/html5player.js', file: objs.vfiles, image: objs.vfimg, width: '100%', height: '100%', aspectratio: '16:9', stretching: 'fill', controls: objs.controls, autostart: objs.autostart, repeat: objs.repeat, preload: true, }); return objplay; }, }; // 图片全屏 function setImgMax(img, imgW, imgH, tW, tH) { var tWidth = tW || w_width; var tHeight = tH || w_height; var coe = imgH / imgW; var coe2 = tHeight / tWidth; if (coe < coe2) { var imgWidth = tHeight / coe; img.css({ height: tHeight, width: imgWidth, left: -(imgWidth - tWidth) / 2, top: 0 }); } else { var imgHeight = tWidth * coe; img.css({ height: imgHeight, width: tWidth, left: 0, top: -(imgHeight - tHeight) / 2 }); } } // 弹出层 function openDrawerHTML(addr, ele) { $.ajax({ url: addr, dataType: 'html', success: function (data) { if (!data) return; $('body').append(data); $('html').addClass('open'); setTimeout(function () { $(ele).addClass('show'); }, 50); }, error: function () { $('ele').remove(); }, }); } // 关闭弹窗 function closeDrawer(closeEle, drawerEle) { $(document).on(_click, closeEle, function (e) { e.preventDefault(); $(drawerEle).removeClass('show'); setTimeout(function () { $(drawerEle).remove(); $('html').removeClass('open'); }, 600); }); } function openDrawer(openEle, drawerEle) { $(document).on(_click, openEle, function (e) { e.preventDefault(); var url = $(this).attr('href'); openDrawerHTML(url, drawerEle); }); } // 截图文字段为一个一个 function splitWords(el, time) { if (!time) { time = 100; } var _test = el.html().split('
    '); el.html(''); for (var i = 0; i < _test.length; i++) { el.append(''); _test[i] = _test[i].split(''); var _span = el.find('span'); for (var j = 0; j < _test[i].length; j++) { _span.eq(i).append(''); var _i = _span.eq(i).find('i'); if (_test[i][j] === ' ') { _test[i][j] = ' '; } _i.eq(j) .html(_test[i][j]) .css({ 'animation-delay': time * j + 'ms', '-webkit-animation-delay': time * j + 'ms', }); } } } function getAnchorPointPosition(ele) { var points = []; $(ele).each(function (i, e) { points.push($(this).offset().top - w_height * 0.5); }); return points; } function scrollHandle(pointEle, targetEle) { var st = $(window).scrollTop(); var points = getAnchorPointPosition(pointEle); for (var i = 0; i < points.length; i++) { if (st > points[i]) { $(targetEle).find('a').removeClass('act'); $(targetEle).find('li').eq(i).find('a').addClass('act'); } } } function getUrlParams() { var query = window.location.search.substring(1); var queryArr = query.split('&'); var newQuery = []; for (var i = 0; i < queryArr.length; i++) { var itemArr = queryArr[i].split('='); newQuery.push(itemArr); } return newQuery; } function getParamValue(name) { var params = getUrlParams(); for (var i = 0; i < params.length; i++) { if (params[i][0] === name) { return params[i][1]; } } return; } // 设置list每一元素延迟时间 function setListDelay(ele, time, startTime) { time = time || 100; startTime = startTime || 0; var len = $(ele).length; if (len) { $(ele).each(function (i, e) { $(this).css({ 'transition-delay': startTime + time * i + 'ms' }); }); } } // 为list最后一个元素添加class function setLastClass(ele) { var len = $(ele).length; if (len) { $(ele) .eq(len - 1) .addClass('last'); } } // 进入某个区间出现,离开消失 function intoShowLeaveHide(ele, startEle, endEle, st, et) { var wst = $(window).scrollTop(); var len = $(ele).length; var slen = $(startEle).length; var elen = $(endEle).length; if (len && slen && elen) { var nst = st || $(startEle).offset().top - $mtoph; var net = et || $(endEle).offset().top - w_height * 0.7; var active = $(ele).hasClass('active'); var hidden = $(ele).is(':hidden'); if (wst > nst && wst < net) { !active && $(ele).addClass('active'); hidden && $(ele).stop().fadeIn(); } else if (wst < nst) { active && $(ele).removeClass('active'); } else if (wst > net) { !hidden && $(ele).stop().fadeOut(); } } } // 进入某区间固定 function intoFixed(ele, startEle) { var st = $(window).scrollTop(); if ($(ele).length && $(startEle).length) { var start = $(startEle).offset().top - $mtoph; var active = $(ele).hasClass('active'); if (st > start) { !active && $(ele).addClass('active'); } else { active && $(ele).removeClass('active'); } } } // 点击查看图组 function getMoreBigImgs(addr) { $.ajax({ url: addr, dataType: 'html', success: function (data) { if (data) { $('body').append(data); $('.seeMoreBigImgsWrap').stop().fadeIn(); } }, error: function (XMLHttpRequest, textStatus, errorThrown) { $('.seeMoreBigImgsWrap').remove(); }, }); } $('.btn-moreBigImgs').bind(_click, function (e) { e.preventDefault(); var url = $(this).attr('href'); getMoreBigImgs(url); }); $(document).bind(_click, function (e) { var close = $(e.target).hasClass('btn-bigimgs-close'); var item = $(e.target).hasClass('item'); var video = $(e.target).hasClass('btn-video-close'); var videoWrap = $(e.target).hasClass('playVideoWrap'); if (close || item) { e.preventDefault(); $('.seeMoreBigImgsWrap').remove(); } else if (video || videoWrap) { e.preventDefault(); $('.playVideoWrap').stop().fadeOut(); objplay.stop(); } }); function gotoDestination() { const hash = getParamValue('point'); if (hash) { $('html, body').animate({ scrollTop: $('#' + hash).offset().top - $mtoph }, 0); } } // 切换 active function toggleActive(ele) { $(ele).bind(_click, function (e) { e.preventDefault(); $(this).toggleClass('act'); }); } // 点击同页定位 function jumpPosition(ele, callback) { $(ele).bind(_click, function (e) { var hash = $(this).attr('href').split('#')[1]; if (hash) { e.preventDefault(); $('html, body').animate({ scrollTop: $('#' + hash).offset().top - $mtoph }, 800); if (callback) callback(); } }); } // 通用弹窗 function openModalAjax(addr) { $.ajax({ url: addr, dataType: 'html', success: function (data) { if (!data) return; $('body').append(data); $('html').addClass('open'); setTimeout(function () { $('.myModal').addClass('show'); }, 50); }, error: function () { $('.myModal').remove(); }, }); } $(document).on(_click, '.myModal', function (e) { if ($(e.target).hasClass('myModal')) { $('.myModal').remove(); $('html').removeClass('open'); } }); function closeModal(ele) { $(document).on(_click, ele, function (e) { e.preventDefault(); $('.myModal').remove(); $('html').removeClass('open'); }); } function openModal(ele) { $(document).on(_click, ele, function (e) { e.preventDefault(); const url = $(this).attr('href'); openModalAjax(url); }); } closeModal('.myModal .close'); // (function (doc, win) { // var docEl = doc.documentElement, // isIOS = navigator.userAgent.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/), // dpr = isIOS ? Math.min(win.devicePixelRatio, 3) : 1, // dpr = window.top === window.self ? dpr : 1, //被iframe引用时,禁止缩放 // dpr = 1, // scale = 1 / dpr, // resizeEvt = 'orientationchange' in window ? 'orientationchange' : 'resize'; // docEl.dataset.dpr = dpr; // var metaEl = doc.createElement('meta'); // metaEl.name = 'viewport'; // metaEl.content = // 'initial-scale=' + scale + ',maximum-scale=' + scale + ', minimum-scale=' + scale; // docEl.firstElementChild.appendChild(metaEl); // var recalc = function () { // var width = docEl.clientWidth; // if (width / dpr > 750) { // width = 750 * dpr; // } // // 乘以100,px : rem = 100 : 1 // docEl.style.fontSize = 100 * (width / 750) + 'px'; // }; // recalc(); // if (!doc.addEventListener) return; // win.addEventListener(resizeEvt, recalc, false); // })(document, window); function openshowImg(num, maxnum) { $('body').append( '
    ' ); for (var i = 1; i <= maxnum; i++) { $('.imgShowDemo').append('
    '); var imgurl = $('[data-img-num=' + i + ']').attr('data-img'); $('.imgShowDemo .item') .eq(i - 1) .find('.img') .attr('src', imgurl); } $('.imgShowBox').css({ height: w_height }); $('.imgShowDemo').css({ height: w_height }); $('.imgShowDemo .item').css({ height: w_height }); $(window).resize(function () { $('.imgShowBox').css({ height: w_height }); $('.imgShowDemo').css({ height: w_height }); $('.imgShowDemo .item').css({ height: w_height }); }); $('.imgShowDemo').slick({ fade: true, arrows: true }); $('.imgShowDemo').slick('slickGoTo', num - 1); $('.imgShowBox').addClass('img-show'); } $(document).on('click', '.imgShowClose', function () { $('.imgShowBox').removeClass('img-show'); $('html').removeClass('openImg'); $('.imgShowBox').remove(); });