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