let w = document.body.offsetWidth || document.body.clientWidth, h = window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight, _ = function (select) { return document.querySelector(select) }, _$ = function (select) { return document.querySelectorAll(select) }, clickEvent = (function () { if ('ontouchstart' in document.documentElement === true) { return 'touchstart'; } else { return 'click'; } })(), active = function (node, active) { return node.classList.add(active); //娣诲姞绫 }, inactive = function (node, active) { //绉婚櫎绫 return node.classList.remove(active); }, getScrollbarWidth = function() { // 寰楀埌婊氬姩鏉″搴 const container = document.createElement('div'); container.style.visibility = 'hidden'; container.style.position = 'absolute'; container.style.left = '-9999px'; container.style.width = '100px'; container.style.overflow = 'scroll'; let fragment = document.createDocumentFragment(); fragment.appendChild(container); document.body.appendChild(fragment); const containerWidth = container.offsetWidth; const inner = document.createElement('div'); inner.style.width = '100%'; let fragment1 = document.createDocumentFragment(); fragment1.appendChild(inner); container.appendChild(fragment1); const innerWidth = inner.offsetWidth; container.parentNode.removeChild(container); return containerWidth - innerWidth; }, scrollMarginRightTrue = function(){ // 绂佹婊氬姩 if ('ontouchstart' in document.documentElement === false){ _('html').style.marginRight = getScrollbarWidth() + 'px'; document.documentElement.style.overflowY='hidden'; } }, scrollMarginRightFalse = function(){ // 寮€鍚粴鍔 if ('ontouchstart' in document.documentElement === false){ _('html').style.marginRight = 0; document.documentElement.style.overflowY = 'auto'; } }; calculateDanage = function (min, max) { return Math.max(Math.floor(Math.random() * max) + 1, min); }, xmlHttp = function () { // 灏佽 XMLHttpRequest let request = new XMLHttpRequest(), _url = ""; return { requestFun: function (method, url, data, success) { request.open(method, _url + url); if (method == 'GET') { request.send(); } else { request.setRequestHeader('Content-Type', 'application/json'); request.send(data); } request.onload = function () { if (this.status >= 200 && this.status < 400) { success(request.responseText) } else { console.log('error'); } }; } } }, debounce = function (func, delay) { // 闃叉姈 var timeout; return function () { clearTimeout(timeout); timeout = setTimeout(function () { func.apply(this, arguments); }, delay); } }; const userBrowser = (function () { const ua = navigator.userAgent; const testUa = function (regexp) { return regexp.test(ua.toLowerCase()) }; let userBrowserClient = function () { let client = ''; if (/(iPhone|iPad|iPod|iOS)/i.test(ua)) { client = 'iOS'; } else if (/(Android)/i.test(ua)) { client = 'Android'; } else { client = 'PC'; } return client; }; let userBrowserType = function () { let shell = "none"; let shellVs = "unknow"; if (testUa(/micromessenger/g)) { shell = "wechat"; // 寰俊娴忚鍣 } else if (testUa(/qqbrowser/g)) { shell = "qq"; // QQ娴忚鍣 } else if (testUa(/ubrowser/g)) { shell = "uc"; // UC娴忚鍣 } else if (testUa(/qihu 360se/g)) { shell = "360"; // 360娴忚鍣 } else if (testUa(/2345explorer/g)) { shell = "2345"; // 2345娴忚鍣 } else if (testUa(/metasr/g)) { shell = "sougou"; // 鎼滅嫍娴忚鍣 } else if (testUa(/lbbrowser/g)) { shell = "liebao"; // 鐚庤惫娴忚鍣 } else if (testUa(/maxthon/g)) { shell = "maxthon"; // 閬ㄦ父娴忚鍣 }else if (testUa(/edg/g)) { shell = "edg"; // 閬ㄦ父娴忚鍣 } return shell }; return { userBrowserClient: userBrowserClient, userBrowserType: userBrowserType } })(); const chin = (function () { const photoActives = (function () { //缁檌mg娣诲姞鍔ㄦ晥 閰嶅悎婊氬姩浣跨敤 let section = document.createElement('section'); section.classList.add('photoActive'); for (let i = 0; i < _$('.photoActives').length; i++) { _$('.photoActives')[i].appendChild(section.cloneNode()); } })(); const maodianlink = (function () { // 濡傛灉鐐瑰嚮鍏冪礌鏄敋鐐 鍏堝埛鏂颁笅缃戦〉鍦ㄨ繘琛岃烦杞 if (_$('.mobilelinkitems a')) { let mao = _$('.mobilelinkitems a'); for (let i = 0; i < mao.length; i++) { mao[i].addEventListener('click', function () { if (mao[i].href.match('#')) { location.reload(); }; }); }; } })(); const itemAnimates = (function () { //瀵瑰涓」鐩繘琛屽姩鐢诲欢杩熷鐞 let itemAnimates = _$(".itemAnimates"); for (let i = 0; i < itemAnimates.length; i++) { let itemAnimate = itemAnimates[i].querySelectorAll('.itemAnimate'), delay = 0, delayCount = parseInt(itemAnimates[i].getAttribute('delay')); if (!delayCount) { delayCount = 300; } for (let j = 0; j < itemAnimate.length; j++) { if (itemAnimates[i].getAttribute('random') == '1') { delay = Math.random() * itemAnimates[i].getAttribute('randomMax'); } else { delay += delayCount; } itemAnimate[j].style.animationDelay = delay + "ms"; } } })(); // const newsPaperTable = (function () { // 瀵瑰嚭鐜皌able鏍囩杩涜鐖惰妭鐐?00%澶勭悊 // Array.prototype.forEach.call(_$('.newspaper table'), function (el) { // let section = document.createElement('section'); // section.className = 'tablebox'; // let fragment = document.createDocumentFragment(); // section.appendChild(fragment); // fragment.appendChild(section); // el.parentNode.replaceChild(fragment, el); // }); // })(); const splitlist = function (splitlist, bool) { Array.prototype.forEach.call(_$(splitlist), function (item) { let flag = false, isRandom = bool, delays = parseInt(item.getAttribute('delay')), speeds = parseInt(item.getAttribute('speed')), Arrays = item.innerHTML.replace(/
/g, "\n").replace(//g, "\\").replace(/<\/i>/g, "\t").replace(/&/g, "&").split(""); item.innerHTML = ''; if (!delays) { delays = 200 } if (!speeds) { speeds = 60 } Array.prototype.forEach.call(Arrays, function (letter, i) { let span = document.createElement("span"), br = document.createElement("br"), random = 1; if (letter.indexOf("\n") >= 0) { let fragment = document.createDocumentFragment(); fragment.appendChild(br); item.appendChild(fragment); return } if (letter.indexOf("\\") >= 0) { flag = true; return } if (letter.indexOf("\t") >= 0) { flag = false; return } if (flag) { span.className = 'letters'; } if (isRandom) { random = Math.random(); } delays += speeds; span.style.animationDelay = delays * random + 'ms'; span.innerHTML = letter; let fragments = document.createDocumentFragment(); fragments.appendChild(span); item.appendChild(fragments); }); }); }; const hasChild = function (item) { if (item) { Array.prototype.forEach.call(item, function (slider) { if (slider.hasChildNodes()) { active(slider, 'hasChildActive'); } }); } }; const mobileMenu = function () { let menu = _('.mobileMenu_box'), nav = _('.mobileNav'), header = _('header'); if (menu && nav) { nav.style.display = 'block'; menu.addEventListener(clickEvent, function () { if (w > 1024) { if (!header.classList.contains('active')) { active(header, 'active'); } else { inactive(header, 'active'); } }; if (menu.classList.contains('active')) { inactive(menu, 'active'); inactive(nav, 'active'); scrollMarginRightFalse(); } else { active(menu, 'active'); active(nav, 'active'); scrollMarginRightTrue(); } }); } }; const isAutoHeight = function (event, items, item, isTrue) { let height = [], flag = isTrue, nodeFather; function publicIf(index) { if (items[index].classList.contains('active')) { item[index].style.height = height[index]; items[index].classList.add('active'); } }; function public(index) { for (let i = 0; i < item.length; i++) { nodeFather[i] = items[i].parentNode; item[i].style.height = 0; items[i].classList.remove('active'); nodeFather[i].classList.remove('active'); } item[index].style.height = height[index]; items[index].classList.add('active'); nodeFather.classList.add('active'); }; for (let j = 0; j < item.length; j++) { item[j].style.height = 'auto'; height.push(getComputedStyle(item[j]).height); item[j].style.height = '0px'; } if (event == 'mouseover') { for (let i = 0; i < items.length; i++) { items[i].index = i; publicIf(i); items[i].addEventListener(event, function () { nodeFather = items[this.index].parentNode; public(this.index); }); if (flag == true) { items[i].addEventListener('mouseout', function () { item[this.index].style.height = 0; items[this.index].classList.remove('active'); }); }; }; }; if (event == 'click') { for (let i = 0; i < items.length; i++) { items[i].index = i; publicIf(i); items[i].addEventListener(event, function () { nodeFather = items[this.index].parentNode; if (item[this.index].style.height == '0px') { public(this.index); } else { item[this.index].style.height = 0; items[this.index].classList.remove('active'); nodeFather.classList.remove('active'); } }); } }; }; const needvideo = function () { function need() { let root = document.body, rootSection = document.createElement('section'), rootDiv = document.createElement('div'), rootVideo = document.createElement('video'); rootRemove = document.createElement('i'); rootRemove.className = 'iconfont'; rootSection.className = 'videobox'; rootDiv.className = 'bg'; rootVideo.controls = true; rootVideo.loop = true; rootVideo.setAttribute('x5-video-player-type', 'h5'); rootVideo.setAttribute('playsinline', 'true'); rootVideo.setAttribute('webkit-playsinline', 'true'); rootVideo.setAttribute('x5-video-player-fullscreen', 'true'); rootVideo.setAttribute('x-webkit-airplay', 'true'); rootSection.appendChild(rootDiv); rootSection.appendChild(rootVideo); rootSection.appendChild(rootRemove); let fragment = document.createDocumentFragment(); fragment.appendChild(rootSection); root.appendChild(fragment); }; let needs = _$('.needVideo'); if (needs.length > 0) { need(); let a = _('.videobox'), b = _('.videobox .bg'), c = _('.videobox video'), d = _('.videobox i'); for (let i = 0; i < needs.length; i++) { needs[i].addEventListener('click', function () { c.src = needs[i].getAttribute('data-src'); d.innerHTML = needs[i].getAttribute('data-icon'); a.classList.add('active'); c.play(); scrollMarginRightTrue(); }); b.addEventListener('click', function () { c.load(); a.classList.remove('active'); scrollMarginRightFalse(); }); d.addEventListener('click', function () { c.load(); a.classList.remove('active'); scrollMarginRightFalse(); }); } } }; const needWechat = function () { function need() { let root = document.body, rootSection = document.createElement('section'), rootDiv = document.createElement('div'), rootP = document.createElement('p'), rootImg = document.createElement('img'); rootSection.className = 'wechat'; rootSection.appendChild(rootDiv); rootDiv.appendChild(rootImg); rootDiv.appendChild(rootP); let fragment = document.createDocumentFragment(); fragment.appendChild(rootSection); root.appendChild(fragment); }; let needs = _$('.needWechat'); if (needs.length > 0) { need(); let a = _('.wechat'), b = _('.wechat img'), c = _('.wechat p'); for (let i = 0; i < needs.length; i++) { needs[i].addEventListener(clickEvent, function (e) { e.preventDefault(); b.src = needs[i].getAttribute('data-src'); c.innerText = needs[i].getAttribute('data-text'); a.classList.add('active'); scrollMarginRightTrue(); }); a.addEventListener(clickEvent, function () { a.classList.remove('active'); scrollMarginRightFalse(); }); } } }; const popUp = function () { function init() { let root = document.body, rootSection = document.createElement('section'), rootbg = document.createElement('div'), rootBox = document.createElement('div'); rootSection.className = 'popUp'; rootbg.className = 'popUpBg'; rootBox.className = 'popUpBox'; rootSection.appendChild(rootbg); rootSection.appendChild(rootBox); let fragment = document.createDocumentFragment(); fragment.appendChild(rootSection); root.appendChild(fragment); } let need = _$('.xmlbox'); if (need.length > 0) { init(); Array.prototype.forEach.call(need, function (items) { let item = items.querySelectorAll('.xml'); for (let i = 0; i < item.length; i++) { item[i].addEventListener('click', function () { scrollMarginRightTrue(); _('.popUp').classList.add('active'); xmlHttp().requestFun( 'GET', item[i].getAttribute('data-url'), '', function (res) { if (res) { _('.popUpBox').innerHTML = res; } } ) }); }; }); _('.popUpBg').addEventListener('click', function () { _('.popUp').classList.remove('active'); scrollMarginRightFalse(); if (_(".calendar-wrap")) { document.body.removeChild(_(".calendar-wrap")); } }); } }; const NodeObserver = function (node, fn) { let MutationObserver = window.MutationObserver || window.WebKitMutationObserver || window.MozMutationObserver, target = node, observer = new MutationObserver(function (mutation) { mutation.forEach(function (mutation) { if (mutation.type === 'childList') { fn(); } else { return } }); }), config = { childList: true, //瀛愯妭鐐圭殑鍙樺姩 // attributes : true,//灞炴€х殑鍙樺姩 // characterData : true,//鑺傜偣鍐呭鎴栬妭鐐规枃鏈殑鍙樺姩 // subtree : true,//鎵€鏈夊悗浠h妭鐐圭殑鍙樺姩 // attributeOldValue : true,//琛ㄧず瑙傚療attributes鍙樺姩鏃讹紝鏄惁闇€瑕佽褰曞彉鍔ㄥ墠鐨勫睘鎬 // characterDataOldValue : true//琛ㄧず瑙傚療characterData鍙樺姩鏃讹紝鏄惁闇€瑕佽褰曞彉鍔ㄥ墠鐨勫€ }; observer.observe(target, config); }; const placeholder = function () { if (_('.placeholder') && _('header')) { setTimeout(function () { _('.placeholder').style.height = _('header').offsetHeight + 'px'; }, 50) }; }; const bannerimg = function () { Array.prototype.forEach.call(_$('.bannerimg img'), function (slider) { let ScrollY = document.body.scrollTop || document.documentElement.scrollTop; slider.style.transform = 'translate3d(0,' + ScrollY / 2.3 + 'px,0)'; }); }; const bindRaf = function (fn, throttle) { var isRunning; var that; var args; var run = function () { isRunning = false; fn.apply(that, args); }; return function () { that = this; args = arguments; if (isRunning && throttle) { return; } isRunning = true; requestAnimationFrame(run); }; }; const onlyActive = function (item, itemactive) { for (let i = 0; i < item.length; i++) { item[i].index = i; item[i].addEventListener('mouseover', function (e) { for (let i = 0; i < item.length; i++) { item[i].classList.remove('active'); } item[this.index].classList.add('active'); }); item[i].addEventListener('mouseout', function (e) { for (let i = 0; i < item.length; i++) { item[i].classList.remove('active'); } if (itemactive) { itemactive.classList.add('active'); } }); } }; const mouseCursorGradientTracking = function () { let btn = _('.mousegradient'); btn.addEventListener('mousemove', function (e) { let rect = e.target.getBoundingClientRect(); let x = (e.clientX - rect.left) / e.target.offsetWidth * 100; btn.style.setProperty('--x', x + '%'); }); }; const headerScroll = function () { let header = _('header'); if (w <= 1024) { active(header, 'noscroll'); } if (header.classList.contains('noscroll')) { active(header, 'scroll'); } else { if (window.pageYOffset > 0) { active(header, 'scroll'); } else { inactive(header, 'scroll'); } } }; const swiperSlider = function (itemClick, items, item, swiper, swipers) { for (let i = 0; i < itemClick.length; i++) { itemClick[0].classList.add('active'); itemClick[i].addEventListener(clickEvent, function () { for (let i = 0; i < itemClick.length; i++) { itemClick[i].classList.remove('active'); } itemClick[i].classList.add('active'); updatesliders(i); }); }; function updatesliders(i) { let index = i; let arr = Array.prototype.slice.call(item).filter(function (item) { return item.getAttribute('data-index') == index; }); items.innerHTML = ''; arr.forEach(function (item) { let fragment = document.createDocumentFragment(); fragment.appendChild(item); items.appendChild(fragment); items.classList.remove('active'); setTimeout(function () { items.classList.add('active'); swiper.update(); swiper.slideTo(0, 0, true); }, 100); }); }; updatesliders(0); }; const ifScroll = function (items, scrollLeft) { let parentNode, nodeAct; Array.prototype.forEach.call(items, function (item) { if (item.classList.contains('active')) { nodeAct = item; parentNode = item.parentNode; let leftDom = _('.sticky .head'); if (!scrollLeft) { parentNode.scrollLeft = nodeAct.offsetLeft - leftDom.offsetWidth -10; } else { parentNode.scrollTop = nodeAct.offsetTop; } } }); }; const IntersectionObserversImg = function (node) { const config = { rootMargin: '0px', threshold: 0, }; let observer = new IntersectionObserver(function (entries, self) { Array.prototype.forEach.call(entries, function (entry) { if (entry.isIntersecting) { let img = entry.target; let src = img.dataset.src; if (src) { img.src = src; img.removeAttribute('data-src'); } // 瑙i櫎瑙傚療 self.unobserve(entry.target); } }); }, config) Array.prototype.forEach.call(node, function (el) { observer.observe(el) }); }; const IntersectionObserversNode = function (node, flag) { const config = { rootMargin: '0px', threshold: 0, }; let observer = new IntersectionObserver(function (entries, self) { Array.prototype.forEach.call(entries, function (entry) { if (entry.isIntersecting) { entry.target.classList.add(flag); // 瑙i櫎瑙傚療 self.unobserve(entry.target); } }); }, config) Array.prototype.forEach.call(node, function (el) { observer.observe(el) }); }; const pohtoSliders = function () { if (!!window.ActiveXObject || "ActiveXObject" in window){ Array.prototype.forEach.call(_$('.photoSlides'), function (item) { active(item,'ifIe'); return }); } var parseColor = function (hexStr) { return hexStr.length === 4 ? hexStr.substr(1).split('').map(function (s) { return 0x11 * parseInt(s, 16); }) : [hexStr.substr(1, 2), hexStr.substr(3, 2), hexStr.substr(5, 2)].map(function (s) { return parseInt(s, 16); }) }; var pad = function (s) { return (s.length === 1) ? '0' + s : s; }; var gradientColors = function (start, end, steps, gamma) { var i, j, ms, me, output = [], so = []; gamma = gamma || 1; var normalize = function (channel) { return Math.pow(channel / 255, gamma); }; start = parseColor(start).map(normalize); end = parseColor(end).map(normalize); for (i = 0; i < steps; i++) { ms = i / (steps - 1); me = 1 - ms; for (j = 0; j < 3; j++) { so[j] = pad(Math.round(Math.pow(start[j] * me + end[j] * ms, 1 / gamma) * 255).toString(16)); } output.push('#' + so.join('')); } return output; }; const NodeObserverSlide = function (node, fn) { Array.prototype.forEach.call(node, function (item) { item.style.setProperty('--bg', gradientColors('#CC131D', '#ff3333', 100)[calculateDanage(0, 99)]); let MutationObserver = window.MutationObserver || window.WebKitMutationObserver || window.MozMutationObserver, target = item, observer = new MutationObserver(function (mutation) { mutation.forEach(function (mutation) { if (mutation.type === 'attributes') { fn(mutation.target); } else { return } }); }), config = { attributes: true, //灞炴€х殑鍙樺姩 }; observer.observe(target, config); }); }; NodeObserverSlide(_$('.photoSlides'), function (dom) { let photoFlag = true; dom.addEventListener('transitionend', function (e) { if(e.target === e.currentTarget && photoFlag){ dom.querySelector('img').style.opacity = '1'; dom.classList.add('reset'); } }); }); }; return { mobileMenu: mobileMenu, // 绉诲姩绔寜閽 split: splitlist, // 鍒嗗壊鏂囧瓧 //true 寮€濮嬮殢鏈洪€熷害 hasChild: hasChild, // 鍒ゆ柇鍏冪礌鏄惁鏈夊瓙鑺傜偣 isAutoHeight: isAutoHeight, // 鐢ㄤ簬'click'/'mouseover'浜嬩欢鏃跺姩鐢诲~鍏呴珮搴 true榛樿绂诲紑鏃堕珮搴﹀綊闆 needVideo: needvideo, // 寮瑰嚭瑙嗛 needWechat: needWechat, // 寮瑰嚭鍥剧墖 popUp: popUp, // XMLHttpRequest璇锋眰寮瑰嚭灞 placeholder: placeholder, // 鍗犱綅鍧 NodeObserver: NodeObserver, // 鐩戝惉dom鍙樺寲 bannerimg: bannerimg, // 椤堕儴banner婊氬姩妯℃嫙瀹氫綅 bindRaf: bindRaf, // 鍥炶皟 requestAnimationFrame onlyActive: onlyActive, // 浠呭厑璁稿嚭鐜颁竴涓縺娲诲潡 mouseCursorGradientTracking: mouseCursorGradientTracking, // 娓愬彉鑹叉寜閽牴鎹紶鏍囩Щ鍔 headerScroll: headerScroll, // 婊氬姩鏃跺鍔犲鑸牱寮 swiperSlider: swiperSlider, // swiper閰嶅悎鍒嗛〉 ifScroll: ifScroll, // 鑷€傚簲婊氬姩璺濈 IntersectionObserversImg: IntersectionObserversImg, //鎳掑姞杞藉浘鐗 IntersectionObserversNode: IntersectionObserversNode, //dom鑺傜偣杩涘叆鍙鍖哄煙鎵ц pohtoSliders : pohtoSliders //鐢熸垚钂欑増 鍥剧墖鍑虹幇鏁堟灉 } })(); chin.mobileMenu(); chin.split('.splitlist', true); chin.hasChild(_$('.mobilelinkitems')); chin.needVideo(); chin.needWechat(); chin.popUp(); // chin.bannerimg(); // chin.placeholder(); // chin.swiperSlider( // _$('item'), // _( '.swiper .swiper-wrapper'), // _$('.swiper .swiper-wrapper .swiper-slide'), // mySwiper // ); // chin.mouseCursorGradientTracking(); chin.isAutoHeight('click',_$('.mobileNavitems .item'),_$('.mobilelinkitems'),true); // chin.onlyActive(_$('.subnavBody .w1440 a'),_('.subnavBody .w1440 a.active')); // chin.headerScroll(); chin.onlyActive(_$('.feelChinNav .list a'),_('.feelChinNav .list a.active')); const yqlj = function(){ if(!_('.yqlj')){ return } let yqlj = _('.yqlj'), ul = _('.yqlj ul'); yqlj.addEventListener(clickEvent,function() { active(ul,'active'); }); document.addEventListener(clickEvent,function(e) { if(e.target == yqlj || yqlj.contains(e.target)){ }else{ inactive(ul,'active'); } }); }; yqlj(); window.onload = function () { chin.IntersectionObserversImg(_$('img[data-src]')); chin.IntersectionObserversNode(_$('.flags'), 'flag'); chin.IntersectionObserversNode(_$('.photoActives'), 'reset_photoActive'); chin.pohtoSliders(); chin.ifScroll(_$('.sticky .list a')); }; if(_('.comeback')){ const supportsNativeSmoothScroll = 'scrollBehavior' in document.documentElement.style; _('.comeback').addEventListener('click',function(){ if(userBrowser.userBrowserClient() == 'iOS'){ document.documentElement.scrollTop = 0; } if (userBrowser.userBrowserType() == 'wechat') { document.body.scrollTop = 0; }else if (userBrowser.userBrowserType() == 'uc') { document.body.scrollTop = 0; }else{ if(supportsNativeSmoothScroll){ window.scrollTo({ top: 0, behavior: "smooth" }); }else{ window.scrollTo({ top: 0 }); } } }); } window.addEventListener('scroll', function () { // chin.bindRaf(chin.bannerimg()); }); window.addEventListener('resize', function () { w = document.body.offsetWidth || document.body.clientWidth; h = window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight; // debounce(chin.placeholder(), 300) });