var cy = { init: function () { this.setHeaderNav(); this.setFooter(); this.setIpcBanner(); this.setMore(); }, setHeaderNav: function () { var header = $("header"); /* 移动端导航栏 */ var htMenu = header.find('.header-menu'), htmBtn = header.find('.header-menu .menu-btn'), headerNav = header.find('.header-nav'), hmItem = header.find('.hn-item'), sideOverlay = header.find('.side-overlay'); htmBtn.on({ 'click': function () { htMenu.toggleClass('show'); headerNav.toggleClass('show'); sideOverlay.stop().fadeToggle(); } }); cy.setSubLink(hmItem, '.sub-nav', 991); hmItem.find('.hn-link').on({ click: function () { var $this = $(this), $subNav = $this.siblings('.sub-nav'); if ($(window).width() < 992) { $this.toggleClass('active'); $subNav.stop().slideToggle(); } } }) sideOverlay.on({ 'click': function () { htMenu.removeClass('show'); headerNav.removeClass('show'); sideOverlay.stop().fadeOut(); } }); /* 导航滚动监听 */ function navScroll() { if ($(window).scrollTop() > (header.height())) { header.addClass('scroll'); } else { header.removeClass('scroll'); } } navScroll(); $(window).scroll(function () { navScroll(); }); }, setFooter: function () { var wrapper = $('.cy-wrapper'); var footer = $('footer'); wrapper.imagesLoaded({background: '.img'}, function () { var wrapperH = wrapper.height() + $('header').height(); footerBtm(wrapperH); $(window).resize(function () { footerBtm(wrapperH); }); }); function footerBtm(wrapperH) { var winH = $(window).height(); if (wrapperH < winH) { footer.addClass('btm'); } else { footer.removeClass('btm'); } } function ewmtnm() { if ($(window).width() > 991) { $('.tc-ewm').off('click').on({ mouseenter: function () { var _this = $(this), _popup = _this.find('.popup'); _popup.addClass('show'); }, mouseleave: function () { var _this = $(this), _popup = _this.find('.popup'); _popup.removeClass('show'); } }); $('.address-win').on({ click: function (e) { var $this = $(this); e.preventDefault(); newWindow($this.attr('href'), $this.text()); } }); } else { $('.tc-ewm').off('mouseenter mouseleave').on({ click: function (e) { e.stopPropagation(); var _this = $(this), _popup = _this.find('.popup'); _this.siblings().find('.popup').removeClass('show'); _popup.toggleClass('show'); var $hbody = $('html,body'); if (_popup.hasClass('show')) { $hbody.css('cursor', 'pointer').on({ click: function () { _popup.removeClass('show'); $hbody.css('cursor', '').off('click'); } }); } else { $hbody.css('cursor', '').off('click'); } _popup.on({ click: function (e) { e.stopPropagation(); } }) } }); $('.address-win').off('click'); } } function newWindow(_href, _name) { var href = _href || '', name = _name || ''; window.open( href, name, "height=600," + "width=800," + "top=200," + "left=200," + "toolbar=no," + "menubar=no," + "scrollbars=no," + "resizable=no," + "location=no," + "status=no" ); } ewmtnm(); $(window).resize(function () { ewmtnm(); }); }, setSubLink: function (_navItem, _subItem, _size) { /* * 监听导航栏一级栏目的链接 * _navItem:一级栏目 * _subItem:二级栏目 * _size:屏幕大小 * */ var arr = []; var size = _size || 1024; _navItem.each(function (index) { var _this = $(this), _menu = _this.find(_subItem); arr.push(_menu.siblings("a").attr("href")); if ($(window).width() > size) { _menu.css("display", "").siblings("a").attr("href", arr[index]); } else { _menu.siblings("a").attr("href", "javascript:"); } $(window).resize(function () { if ($(window).width() > size) { _menu.css("display", "").siblings("a").attr("href", arr[index]); } else { _menu.siblings("a").attr("href", "javascript:"); } }); }); }, setIpcBanner: function () { if ($('.ipc-banner').length) { var bannerPic = $('.banner-pic'), _head = 'header', speed = 2; function bannerScroll() { var headH = $(_head).length ? $(_head).height() : 0; var h = bannerPic.height() + headH; bannerPic.css({ "position": "relative", "top": $(window).scrollTop() > h ? "" : $(window).scrollTop() / speed }).find(".title").css({ "top": $(window).scrollTop() > h ? "" : -$(window).scrollTop() / speed }); } bannerScroll(); $(window).scroll(function () { bannerScroll(); }); } }, setMore: function () { var cultureDuty = $('.culture-duty'); if (cultureDuty.length) { var dutyCarousel = cultureDuty.find('.carousel'); dutyCarousel.slick({ autoplay: true, autoplaySpeed: 3000, speed: 500, fade: true, arrows: false, dots: true, appendDots: dutyCarousel, customPaging: function() {return $('');} }); } var aboutMember = $('.about-member'); if (aboutMember.length) { var memberItem = aboutMember.find('.member-item'); memberItem.on({ click: function () { var $this = $(this), $name = $this.find('.member-name'), $cont = $this.find('.member-cont'); $name.toggleClass('show'); $cont.stop().slideToggle(); if ($name.hasClass('show')) { $('html, body').animate({ scrollTop: $this.offset().top - $('.header').height() - $('.ipc-nav').height() }); } } }); } var joinRecruit = $('.join-recruit'); if (joinRecruit.length) { var recruitItem = $('.recruit-item'); recruitItem.each(function () { var _this = $(this), head = _this.find('.zp-head'), body = _this.find('.zp-body'), headS = _this.siblings('.recruit-item').find('.zp-head'), bodyS = _this.siblings('.recruit-item').find('.zp-body'); head.click(function () { if (head.length && body.length) { var _current = recruitItem.find('.zp-head').hasClass('active') ? _this.siblings('.recruit-item').children('.zp-head.active').parent() : _this; var nowIndex = _this.index(), currentIndex = _current.index(); var nowTop = _this.offset().top - $('.header').height() - $('.ipc-nav').height() - 2, currentContHeight = _current.find('.zp-body').outerHeight(); console.log($('.ipc-nav').height()) head.toggleClass('active'); body.slideToggle(); headS.removeClass('active'); bodyS.slideUp(); if (head.hasClass('active')) { $('html, body').animate({ scrollTop: (nowIndex > currentIndex) ? nowTop - currentContHeight : nowTop }); } } }); }); } var $investor = $('.investor-banner'); if ($investor.length) { var $url = $('.stock-data').attr('src'); function getStockData() { var stock_str = v_sh600321.split('~'); var stock_info = { price: stock_str[3] || '--', highest: stock_str[33] || '--', bottom: stock_str[34] || '--', volume: (stock_str[36] / 10000).toFixed(2) || '--', turnover: (stock_str[37] / 10000).toFixed(2) || '--', date: stock_str[30].replace(/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})/,"$1-$2-$3 $4:$5:$6") || '--', uad: stock_str[31] || '--' }; $('.s-price').text(stock_info.price); $('.s-highest').text(stock_info.highest); $('.s-bottom').text(stock_info.bottom); $('.s-volume').text(stock_info.volume).attr('title', stock_str[36]); $('.s-turnover').text(stock_info.turnover).attr('title', stock_str[37]); $('.investor-banner-m .s-date').text(stock_info.date); if (stock_info.uad > 0) { $('.s-state').removeClass('up down').addClass('up'); } else { $('.s-state').removeClass('up down').addClass('down'); } // console.log(stock_info.date) } function getAjaxData() { var date = new Date(); var currentDate = Number(date.toTimeString().split(' ')[0].split(':').join('')); var t; $('.s-state').removeClass('noshow'); clearTimeout(t); $.ajax({ url: $url, cache: true, dataType: 'script', success: function () { getStockData(); if ((currentDate >= 93000 && currentDate <= 113000) || (currentDate >= 130000 && currentDate <= 150000)) { t = setTimeout(getAjaxData, 3000); } else { clearTimeout(t); $('.s-state').addClass('noshow'); } }, error: function () { return; } }); } getAjaxData(); } } }; $(function () { cy.init(); }); /* Set Full Screen Image */ /* * _item: 图片的盒子 * _width: 输入的宽度,默认为空 * _height: 输入的高度,默认为空 * */ function imgFullScreen(_item, _width, _height) { if (_item) { /* 判断是否存在 img-fs 类,没有则添加 */ if (!_item.hasClass("cy-fs")) { _item.addClass("cy-fs"); if (_item.children("img").length) { _item.children("img").wrap("
"); } else { _item.removeClass('cy-fs'); } } var _fs=_item,/*盒子*/ _fs_c=_fs.find(".fs-c"),/*内容*/ _img=_fs.find("img"); /* 判断是否 有输入的宽高 */ var inputW=_width||'',inputH=_height||''; /* 设置盒子的宽高 */ _fs.css({"width": inputW,"height": inputH}); LoadImage(_img.attr("src"),function(img){ var imageW=img.width,imageH=img.height; /* 获取缩放后的图片宽高 */ var scaleW=imageW*inputH/imageH,scaleH=imageH*inputW/imageW; /* 计算 输入宽高比,图片比 */ var imageR=imageW/imageH,inputR=inputW/inputH; /* 判断 输入宽高比与缩放后的宽高比 */ if (imageR > inputR) { _fs_c.css({ "width": '', /* 以输入的高为标准 缩放图片 */ "height": inputH }); /* 设置图片的响应高度 */ _img.css({ "position": "relative", "top": '', /* 设置图片相对位移 */ "left": -(scaleW - inputW) / 2, "width": "", "height": "100%" }); } else { _fs_c.css({ /* 以输入的宽为标准 缩放图片 */ "width": inputW, "height": '' }); /* 设置图片的响应宽度 */ _img.css({ "position": "relative", /* 设置图片相对位移 */ "top": -(scaleH - inputH) / 2, "left": '', "width": "100%", "height": "" }); } }); } } function LoadImage(imgSrc, callback) { var image = new Image(); image.src = imgSrc; if (image.complete) { callback(image); image.onload = function () { }; } else { image.onload = function () { callback(image); image.onload = function () { }; }; } } /* 干掉注释 */ //兼容的获取简单方案 var getCommentNodes=window.NodeFilter?function(e){ //支持TreeWalker的浏览器 var r=[],o,s; s=document.createTreeWalker(e,NodeFilter.SHOW_COMMENT,null,null); while(o=s.nextNode())r.push(o); //遍历迭代器 return r; }:function(e){ //不支持的需要遍历 switch(e.nodeType){ case 8:return [e]; //注释节点直接返回 case 1:case 9: //文档或元素需要遍历子节点 var i,s=e.childNodes,l=s.length,result=[]; for(i=0;i