var masterInfo = {
mainIScroll:'',
scrollDatas:{},
windowHeight:$(window).height(),
rollAniList:[],
parallaxList:[],
fontAniList:[],
mobile_move:false,
counterStr:true,
headerStyle:$('.header').is('.onShow'),
rollArr:{
mainRoll:{
mainRollName:document.getElementById('main'),
mainRollData: {
speed:1,damping:.06,
alwaysShowTracks:true,
syncCallbacks:true
},
},
textRoll:{
textRollName:document.getElementsByClassName('liTxt'),
textRollData: {
speed:1,
damping:.04,
alwaysShowTracks:true
},
},
},
//鍒濆鍖
init:function(){
//鍒ゆ柇鎵嬫満銆乸c
masterInfo.mobile();
$(window).resize(function () {
masterInfo.mobile();
});
//鍘婚櫎杩
$('.transition_none').removeClass('transition_none');
//鎸傝浇鍣
masterInfo.loadRoll();
if(!masterInfo.mobile_move){
let e = $('.nav_a:nth-child(2)'),s = $('.menu'),h = $('.header'),m;
$(e).hover(function(){
h.addClass('onShow');
clearInterval(m);
s.find('._list').children().show();
},function(){
h.removeClass('onShow');
m = setTimeout(() => {
s.find('._list').children().hide();
},500);
});
}
//杩斿洖椤堕儴
$(document).on('click','#back_top',function(){
if(!masterInfo.mobile_move){
if($('#screenSwiper').length!=0){
screenSwiper.slideTo(0, 1200, true);
}else{
masterInfo.customScroll.scrollTo(0, 0, 1000);
}
masterInfo.scrollDatas.solTop = 0;
}else{
$('html,body').animate({scrollTop: 0},600);
}
});
if($(".Hservice_bg").length!=0){
let prevs = 0;
var HserviceBg = new Swiper ('.Hservice_bg', {
speed:1000,
rewind:true,
autoplay: {
delay:4000,
stopOnLastSlide: false,
disableOnInteraction: false,
},
effect: 'fade',
slideActiveClass: 'active',
navigation: {
prevEl:'.Hservice_prev',
nextEl:'.Hservice_next'
},
on:{
init:function(){
},
slideChangeTransitionStart:function(){
TweenLite.to($("#glTxt_ul").children().eq(prevs), .6,{
opacity:0,
});
TweenLite.to($("#glTxt_ul").children().eq(this.activeIndex), .6,{
opacity:1,
onComplete:()=>{
$("#glTxt_ul").children().eq(this.activeIndex).addClass('on').siblings().removeClass('on');
}
});
prevs = this.activeIndex;
},
}
});
HserviceBg.on('slideChange', function () {
let i = this.activeIndex;
$('._tabUl ._li').eq(i).addClass('on').siblings().removeClass('on');
$("#glTxt_num").children('span').text('0'+(i+1));
});
$(document).on('click','._tabUl ._li>a',function(){
HserviceBg.slideTo($(this).parent().index(), 1000, true);
});
}
if($('.HnewsList').length!=0){
var HnewsList = new Swiper ('.HnewsList', {
speed:600,
slidesPerView:1,
grabCursor : true,
autoplay: {
delay:4000,
},
pagination: {
el: '.partyTopswrnav',
clickable :true
},
scrollbar: {
el: '.Hnewsroll',
draggable: true,
},
breakpoints:{
768:{
slidesPerView:3,
}
},
});
var screen_width = $(window).width();
if(screen_width < 768){
HnewsList.destroy(false);
}
}
$(document).on('click','.light_open_btn',function(){
$('.light,.light_open').addClass('on');
});
$(document).on('click','.light_close_btn',function(){
$('.light').removeClass('on');
setTimeout(() => {
$('.light_open').removeClass('on');
},1000);
});
//涓€灞忓紡
if(!masterInfo.mobile_move && $('#screenSwiper').length!=0){
$('.light_open').hide();
$('.hang').css('right',0);
var screenSwiper = new Swiper ('#screenSwiper', {
speed:1200,
slidesPerView:'auto',
direction:'vertical',
simulateTouch:false,
mousewheel:true,
initialSlide:0,
parallax: true,
slideActiveClass: 'active',
on:{
slideChangeTransitionStart: function(){
this.activeIndex > 0?$("#back_top").addClass('onshow'):$("#back_top").removeClass('onshow');
$('#screenTab .item').eq(this.activeIndex).addClass('on').siblings().removeClass("on");
this.activeIndex == 6?$('#screenTab').addClass('on'):$('#screenTab').removeClass('on');
},
},
});
$(document).on('click','#screenTab .item>a',function(){
screenSwiper.slideTo($(this).parent().index(), 1200, true);
});
}
if($('.slidenav').length!=0){
let i = $('.slidenav .swiper-slide.active').index();
var slidenav = new Swiper('.slidenav', {
speed:400,
freeMode: true,
slidesPerView: 'auto',
freeModeSticky: true,
initialSlide:i,
navigation: {
nextEl: '.slidenav_next>a',
},
});
}
if($('.courseSwiper').length!=0){
var courseSwiper = new Swiper ('.courseSwiper', {
loop:false,
speed:600,
slidesPerView:'auto',
direction:'vertical',
simulateTouch:false,
slideActiveClass: 'active',
autoplay: {
delay:4000,
},
mousewheel:{
releaseOnEdges: true,
},
});
}
if($('.aptitudeSwiper').length!=0){
var aptitudeSwiper = new Swiper ('.aptitudeSwiper', {
speed:600,
initialSlide:2,
slidesPerView:'auto',
centeredSlides: true,
grabCursor:true,
slideActiveClass: 'active',
autoplay: {
delay:4000,
disableOnInteraction: false
},
on:{
init:function(){
let n = this.slides.eq(this.activeIndex).attr('name');
$('.aptitude_name').text(n);
}
}
});
aptitudeSwiper.on('slideChange', function () {
let n = this.slides.eq(this.activeIndex).attr('name');
$('.aptitude_name').text(n);
})
}
if($('#recruitList').length!=0){
$(document).on('click','#recruitList ._check',function(){
let is = $(this),el = is.next('._info').find('._txt');
if(is.is('.on')){
is.removeClass('on');
TweenLite.to(el, .5, {
height:0
});
}else{
is.addClass('on').siblings('._check').removeClass('on');
TweenLite.to(is.siblings('._info').find('._txt'), .5, {
height:0
});
TweenLite.to(el, .5, {
height:el.children().outerHeight()
});
}
});
}
if($('.gaodemap').length!=0){
var m = $(".gaodemap");
$.getScript("https://webapi.amap.com/maps?v=1.4.15&key=dedfdb033dd70e7c4c13a2445450b733",function(){
$.each(m, function(o,j) {
let c = $(this).data('city'),center = [
{x:117,y:40},
{x:122,y:31.5}
];
var map = new AMap.Map("index"+o, {
zoom: 7,
center:[center[o].x,center[o].y],
resizeEnable: true,
zoomEnable: true,
mapStyle: 'amap://styles/098d448b119c161e0e72e5843efa94fa'
});
var mapSpot = ``;
var markerList = [];
$.each(c.split('|'), function(i,k) {
let maps = new AMap.Marker({
position: [k.split(',')[0],k.split(',')[1]],
content: '
'+mapSpot,
offset: new AMap.Pixel(-13, -30)
})
markerList.push(maps);
})
map.add(markerList);
});
});
}
if($('.cir_bg').length!=0){
let prevs = 0;
var cirBg = new Swiper ('.cir_bg', {
speed:1000,
rewind:true,
autoplay: {
delay:4000,
stopOnLastSlide: false,
disableOnInteraction: false,
},
effect: 'fade',
slideActiveClass: 'active',
on:{
init:function(){
},
slideChangeTransitionStart:function(){
TweenLite.to($(".HprojectInfo").children().eq(prevs), .6,{
opacity:0,
});
TweenLite.to($(".HprojectInfo"), .6,{
height:$(".HprojectInfo").children().eq(this.activeIndex).outerHeight(),
});
TweenLite.to($(".HprojectInfo").children().eq(this.activeIndex), .6,{
opacity:1,
onComplete:()=>{
$(".HprojectInfo").children().eq(this.activeIndex).addClass('on').siblings().removeClass('on');
}
});
prevs = this.activeIndex;
},
}
});
cirBg.on('slideChange', function () {
let i = this.activeIndex;
$('.clock ._list ._li').eq(i).addClass('on').siblings().removeClass('on');
});
$(document).on('click','.clock ._list>._li a',function(){
cirBg.slideTo($(this).parent().parent().index(), 1000, true);
});
}
//MENU
if($(".openMenu").length!=0 && masterInfo.mobile_move){
$(document).on('click','.openMenu_btn',function(){
if($('.header').is('.mobileNav')){
$('.header').removeClass('mobileNav');
}else{
$('.header').addClass('mobileNav');
}
});
}
//绐楀彛鐩戝惉
window.onresize = function(){
masterInfo.windowHeight = $(window).height();
}
},
//鐩戝惉mobile
mobile:function(){
var screen_width = $(window).width();
//鐩戝惉pc锛岀Щ鍔ㄧ
if(screen_width <= 1024){
masterInfo.mobile_move = true;
}else{
masterInfo.mobile_move = false;
}
},
getUrlParms:function(name){
var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)");
var r = window.location.search.substr(1).match(reg);
if(r!=null)
return unescape(r[2]);
return null;
},
counters:function(){
var move = $(".counters");
$.each(move, function(i,k) {
var is = $(this),numbers = {score:0},istime = $(this).data('time')?$(this).data('time'):2,isnumbermax = $(this).data('numbermax');
TweenLite.to(numbers,istime,{
score:isnumbermax,
onUpdate:function(){
is.text(parseInt(numbers.score));
},
});
});
},
//parallax
parallax:function(){
if(!masterInfo.mobile_move){
$(".parallax").each(function () {
masterInfo.parallaxList.push({
offsetTop: $(this).offset().top,
speed: $(this).data('speed'),
direction:$(this).data('direction'),
el: $(this).get(0)
});
});
}
},
fontEffect:function (elem) {
var condition = '';
if (elem.getAttribute('data-word') == 1){
condition = ' ';
}
var array = elem.getAttribute('data-text').split(condition);
var delay = elem.getAttribute('data-delay');
var effect = elem.getAttribute('data-effect') || 'fadeIn';
var widthE = elem.clientWidth;
var thisI=0;
if ($(elem).parents('.font_par').length != 0){
// console.log($(elem).index());
thisI = $(elem).index()
}
elem.innerHTML = '';
var Fragment = document.createDocumentFragment();
array.forEach(function (item,i) {
var spanP = document.createElement("span");
var span = document.createElement("font");
span.className='animated';
span.classList.add(effect);
if(delay){
span.style.animationDelay = delay * i + delay*thisI + 's';
}else{
span.style.animationDelay = 0.1 * i + 0.1*thisI + 's';
}
span.innerText = item;
if(span.textContent == ' ' || span.textContent == null || span.textContent == undefined){
span.innerHTML = ' ';
}
spanP.appendChild(span);
Fragment.appendChild(spanP);
});
elem.style.visibility = 'visible';
elem.appendChild(Fragment);
},
//scrollView
scrollView:function(){
var idName = window.location.href.split('#')[1];
if(idName && !masterInfo.mobile_move){
masterInfo.customScroll.scrollIntoView(document.getElementById(idName),{
offsetTop:80,
});
}
},
//rollAni
rollAni:function(){
$(".rollAni").each(function () {
$(this).get(0).classList.add('animated');
$(this).get(0).style.visibility = 'hidden';
$(this).data('delay')?$(this).get(0).style.animationDelay = $(this).data('delay')+'s':'';
console.log($(this).scrollTop)
masterInfo.rollAniList.push({
offsetTop: $(this).offset().top,
delay: $(this).data('delay'),
inType:$(this).data('in'),
el: $(this).get(0)
});
if($(this).offset().top < ($(document).scrollTop() + masterInfo.windowHeight)){
setTimeout(() =>{
$(this).get(0).style.visibility = 'visible';
$(this).get(0).classList.add($(this).data('in'));
},200);
}
});
$(".font_effect").each(function(i){
$(this).get(0).style.visibility = 'hidden';
masterInfo.fontAniList.push({
offsetTop: $(this).offset().top,
el: $(this).get(0)
});
if($(this).offset().top < ($(document).scrollTop() + masterInfo.windowHeight)){
setTimeout(() =>{
masterInfo.fontEffect($(this).get(0));
},200);
}
});
},
Ani:function(datas){
var _num = $('.counters'),topEl = $('.header'),hotFixed = $('#hotFixed'),backBtn = $("#back_top");
if(masterInfo.fontAniList.length!=0 && !masterInfo.mobile_move){
masterInfo.fontAniList.forEach(function (el,index) {
if(el.offsetTop + 120 < (datas.scrollY + masterInfo.windowHeight) && el.el.style.visibility == 'hidden'){
masterInfo.fontEffect(el.el);
}else if(el.offsetTop >= (datas.scrollY + masterInfo.windowHeight) && el.el.style.visibility == 'visible'){
el.el.style.visibility = 'hidden';
}
});
}
if(masterInfo.rollAniList.length!=0 && !masterInfo.mobile_move){
masterInfo.rollAniList.forEach(function (el,index) {
if(el.offsetTop + 120 < (datas.scrollY + masterInfo.windowHeight) && el.el.style.visibility == 'hidden'){
el.el.style.visibility = 'visible';
el.el.classList.add(el.inType);
}else if(el.offsetTop >= (datas.scrollY + masterInfo.windowHeight) && el.el.style.visibility == 'visible'){
el.el.style.visibility = 'hidden';
el.el.classList.remove(el.inType);
}
});
}
if(masterInfo.parallaxList.length!=0 && !masterInfo.mobile_move){
masterInfo.parallaxList.forEach(function (el) {
var $scroll,$direction;
if(el.direction == 'x'){
$scroll = Math.round((datas.scrollY - el.offsetTop) * el.speed);
$direction = "translate3d("+$scroll+"px, 0px, 0px)";
}else if(el.direction == 'x,y'){
var $scroll1 = Math.round((datas.scrollY - el.offsetTop) * el.speed.split(',')[0]);
var $scroll2 = Math.round((datas.scrollY - el.offsetTop) * el.speed.split(',')[1]);
$direction = "translate3d("+$scroll1+"px, "+$scroll2+"px, 0px)";
}else{
$scroll = Math.round((datas.scrollY - el.offsetTop) * el.speed);
$direction = "translate3d(0px, "+$scroll+"px, 0px)";
}
el.el.style.transform = el.el.style.webkitTransform = $direction;
});
}
if(!masterInfo.mobile_move){
if(datas.scrollY > masterInfo.windowHeight/3){
!$('.header').is('.onWhite')?$('.header').addClass('onWhite'):'';
}else{
$('.header').is('.onWhite')?$('.header').removeClass('onWhite'):'';
}
}
if(_num.length!=0){
if(datas.countersTop < (datas.scrollY + masterInfo.windowHeight) && masterInfo.counterStr == true){
masterInfo.counters();
masterInfo.counterStr = false;
}else if(datas.countersTop >= (datas.scrollY + masterInfo.windowHeight)){
masterInfo.counterStr = true;
}
}
if(hotFixed.length!=0 && !masterInfo.mobile_move){
let h = $('.header').height() + 50;
if(datas.scrollY >= datas.hotFixed - h){
if(datas.scrollY < datas.hotFixed + (hotFixed.outerHeight() - hotFixed.children().outerHeight()) - h){
hotFixed.children()[0].style.transform = `translateY(${datas.scrollY - datas.hotFixed + h}px)`;
}
}else{
hotFixed.children()[0].style.transform = 'translate3d(0px, 0px, 0px)';
}
}
if(datas.scrollY > masterInfo.windowHeight/2){
backBtn.addClass('onshow');
}else{
backBtn.removeClass('onshow');
}
},
//init
loadRoll:function(){
var imgNum = 0,images = [];
function preLoadImg() {
var imgs = document.images;
for (var i = 0; i < imgs.length; i++) {
images.push(imgs[i].src);
}
var cssImages = getallBgimages();
for (var j = 0; j < cssImages.length; j++) {
images.push(cssImages[j]);
}
$.imgpreload(images,{
each:function () {
//杩涘害
},
all:function () {
setTimeout(() => {
$(".pageBanner").length!=0?$(".pageBanner").addClass('on'):'';
},0);
if(!masterInfo.mobile_move){
masterInfo.rollAni();
masterInfo.parallax();
$('#counter').length!=0?masterInfo.scrollDatas.countersTop = $('#counter').offset().top:'';
$('#hotFixed').length!=0?masterInfo.scrollDatas.hotFixed = $('#hotFixed').offset().top:'';
masterInfo.customScroll = Scrollbar.init(masterInfo.rollArr.mainRoll.mainRollName, masterInfo.rollArr.mainRoll.mainRollData);
masterInfo.scrollDatas.scrollY = masterInfo.customScroll.offset.y;
masterInfo.customScroll.addListener(function (status) {
masterInfo.scrollDatas.scrollY = status.offset.y;
masterInfo.Ani(masterInfo.scrollDatas);
});
masterInfo.scrollView();
window.addEventListener("hashchange", function(){
setTimeout(() => {
masterInfo.scrollView();
},100);
});
}else{
masterInfo.scrollDatas.scrollY = $(document).scrollTop();
window.addEventListener("scroll",function(doc) {
masterInfo.scrollDatas.scrollY = $(document).scrollTop();
masterInfo.Ani(masterInfo.scrollDatas);
},false);
}
if(!masterInfo.mobile_move && masterInfo.rollArr.textRoll.textRollName!=null){
$.each(masterInfo.rollArr.textRoll.textRollName, function() {
Scrollbar.init($(this)[0],masterInfo.rollArr.textRoll.textRolldata);
});
}
masterInfo.Hbanner();
}
});
}
function getallBgimages() {
var url, B = [], A = document.getElementsByTagName('*');
A = B.slice.call(A, 0, A.length);
while (A.length) {
url = document.deepCss(A.shift(), 'background-image');
if (url) url = /url\(['"]?([^")]+)/.exec(url) || [];
url = url[1];
if (url && B.indexOf(url) == -1) B[B.length] = url;
}
return B;
}
document.deepCss = function (who, css) {
if (!who || !who.style) return '';
var sty = css.replace(/\-([a-z])/g, function (a, b) {
return b.toUpperCase();
});
if (who.currentStyle) {
return who.style[sty] || who.currentStyle[sty] || '';
}
var dv = document.defaultView || window;
return who.style[sty] ||
dv.getComputedStyle(who, "").getPropertyValue(css) || '';
}
Array.prototype.indexOf = Array.prototype.indexOf ||
function (what, index) {
index = index || 0;
var L = this.length;
while (index < L) {
if (this[index] === what) return index;
++index;
}
return -1;
}
preLoadImg();
},
//棣栭〉banner
Hbanner:function(){
if($('#Hbanner').length!=0){
let prevs = 0;
var Hbanner = new Swiper ('#Hbanner', {
loop: true,
speed:1200,
parallax: true,
autoplay: {
delay:5000,
stopOnLastSlide: false,
disableOnInteraction: false,
},
slideActiveClass: 'active',
pagination: {
el: '#Hbanner .Hbanner_nav ._pvn',
clickable :true,
}
});
Hbanner.on('slideChange', function () {
let n = this.realIndex + 1;
$('#Hbanner .Hbanner_nav ._page span').text('0'+n);
})
}
},
}
masterInfo.init();