var cy = { init: function () { this.setdefault(); this.setheadernav(); this.setfooter(); this.setipcbanner(); this.setabout(); this.setproduct(); this.setmore(); this.setuser(); }, setdefault: function () { var txttf = $('.txt-tf'); if (txttf.length) { txttf.each(function () { var $this = $(this), text = $this.html(); $this.html( '' + text + '' + '' + text + '' ); }); } }, setheadernav: function () { var header = $("header"); var hmitem = header.find('.hn-item'); hmitem.each(function () { var $this = $(this), $text = $this.find('a'), text = $text.text(); $text.html( '' + text + '' + '' + text + '' ); }); /* 移动端导航栏 */ var snitem = header.find('.sn-item'), sname = snitem.find('.sn-name'); sname.on({ click: function (e) { var $this = $(this), $sni = $this.parents('.sn-item'), $subnav = $this.siblings('.sub-nav'); if ($sni.hasclass('sn-sub')) { e.preventdefault(); $sni.toggleclass('active'); $subnav.stop().slidetoggle(); } } }); var headerside = $('.header-side'), sideoverlay = $('.side-overlay'), hsmenu = $('.hs-menu'); hsmenu.on({ click: function () { var $this = $(this); hsmenu.toggleclass('active'); headerside.toggleclass('show'); sideoverlay.stop().fadetoggle(); $('html, body').toggleclass('overflow'); $('.cy-wrapper').toggleclass('go'); } }); sideoverlay.on({ click: function () { hsmenu.removeclass('active'); headerside.removeclass('show'); sideoverlay.stop().fadeout(); $('html, body').removeclass('overflow'); $('.cy-wrapper').removeclass('go'); } }); /* 导航滚动监听 */ 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 qrtnm(item, box) { var $item = $(item), $box = box; if ($(window).width() > 1024) { $item.off('click').on({ mouseenter: function () { var _this = $(this), _popup = _this.find($box); _popup.addclass('show'); }, mouseleave: function () { var _this = $(this), _popup = _this.find($box); _popup.removeclass('show'); } }); } else { $item.off('mouseenter mouseleave').on({ click: function (e) { e.stoppropagation(); var _this = $(this), _popup = _this.find($box); _this.siblings().find($box).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(); } }) } }); } } qrtnm('.tc-qr', '.popup'); $(window).resize(function () { qrtnm('.tc-qr', '.popup'); }); }, setipcbanner: function () { var ipcbanner = $('.ipc-banner'); if (ipcbanner.length) { var bannerpic = ipcbanner.find('.banner-pic'), bannerimg = ipcbanner.find('.banner-img'); var bannersrc = bannerimg.attr('src'); function bsrc() { bannerimg.attr({ src: ($(window).width() > 768) ? bannersrc : bannerimg.data('src') }); } bsrc(); $(window).resize(function () { bsrc(); }); var header = $('header'), speed = 2.5; function bannerscroll() { var headh = header.length ? header.height() : 0; var h = bannerpic.height() + headh; bannerpic.css({ "position": "relative", "top": $(window).scrolltop() > h ? "" : $(window).scrolltop() / speed }); } bannerscroll(); $(window).scroll(function () { bannerscroll(); }); } }, setabout: function () { var aboutprofile = $('.about-profile'); if (aboutprofile.length) { $('.pfs-video .vbbox .vicobox').click(function () { if ($(window).width() > 1024) { if($(".pfs-video .vbbox #videobox").length) { $('.pfs-video #videobox').remove(); $('.pfs-video .overlay, .pfs-video .vico').fadein(); $('.pfs-video .vicobox').css("zindex", ''); $('.pfs-video .close').fadeout(); } else { $('.pfs-video .vbbox').append('
'); $('.pfs-video .overlay, .pfs-video .vico').fadeout(); $('.pfs-video .vicobox').css("zindex", '3'); $('.pfs-video .close').fadein(); } } else { if ($(".videobox #videobox").length) { $('#videobox').remove(); } else { $('.videobox').append('
'); $(".vwrap").fadein(); } } cyplayer.load({ vcontainer: 'videobox', //视频容器 vfiles: $(this).data("video"), //视频地址 vfimg: $(this).data("img"), //视频缩略图(封面) repeat:"false", isautoplay: "true" }); }); $(".vwrap .close,.vwrap .videobtg").click(function () { $(".vwrap").hide(function () { $('#videobox').remove(); }); }); $('.pfs-video .close').click(function () { $('.pfs-video .overlay, .pfs-video .vico').fadein(function () { $('.pfs-video #videobox').remove(); $('.pfs-video .vicobox').css("zindex", ''); $('.pfs-video .close').hide(); }); }); $(window).resize(function () { if($(window).width() > 1024) { if ($(".videobox #videobox").length) { $(".vwrap").fadeout(function () { $('#videobox').remove(); }); } } else { if($(".pfs-video .vbbox #videobox").length) { $('.pfs-video #videobox').remove(); $('.pfs-video .overlay, .pfs-video .vico').fadein(); $('.pfs-video .vicobox').css("zindex", ''); } } }); } var abouthistory = $('.about-history'); if (abouthistory.length) { var historycarousel = abouthistory.find('.history-carousel'), hstcarousel = abouthistory.find('.carousel'), hstcrlitem = abouthistory.find('.carousel-item'), hstline = abouthistory.find('.history-line'); var hstcs = []; function hstccss() { hstcrlitem.each(function (index) { var $this = $(this), $info = $this.find('.info'), $date = $this.find('.date'), $line = $this.find('.l'); $info.css({ margintop: ($(window).width() > 1024) ? (index % 2 === 0) ? -$info.outerheight() : '' : '', marginleft: ($(window).width() > 1024) ? $date.width() : '' }); $line.css({ height: ($(window).width() > 1024) ? $info.outerheight() : '' }); hstcs[index] = (index % 2 === 0) ? $info.outerheight() : 0; $this.css({ paddingtop: ($(window).width() > 1024) ? math.max.apply(null,hstcs) : '' }); }); hstline.css({ top: ($(window).width() > 1024) ? math.max.apply(null,hstcs) : '' }); } function historyr() { if ($(window).width() > 1024) { if (!hstcarousel.hasclass('slick-slider')) { hstcarousel.slick({ slidestoshow: 4, infinite: false, adaptiveheight: true, prevarrow: hstline.find('.prev'), nextarrow: hstline.find('.next'), responsive: [ { breakpoint: 1241, settings: { slidestoshow: 3 } }, { breakpoint: 1025, settings: 'unslick' }] }).on({ 'afterchange': function (event, slick, currentslide) { var _item = $(this).find('.carousel-item.slick-active'), _itemcont = _item.find('.info, .l'), _sibcont = _item.siblings().find('.info, .l'); _sibcont.hide(); _itemcont.show(); } }); } } } hstccss(); hstcrlitem.on({ resize: function () { hstccss(); } }); historyr(); $(window).resize(function () { historyr(); }); } var abouthonor = $('.about-honor'); if (abouthonor.length) { var honorcarousel = abouthonor.find('.honor-carousel'), hcc = abouthonor.find('.carousel'); hcc.slick({ slidestoshow: 3, infinite: false, prevarrow: honorcarousel.find('.prev'), nextarrow: honorcarousel.find('.next'), responsive: [{ breakpoint: 1025, settings: { slidestoshow: 2 } }, { breakpoint: 577, settings: { slidestoshow: 1 } }] }); } var aboutduty = $('.about-duty'); if (aboutduty.length) { var dutyinfo = aboutduty.find('.duty-info'), dutycarousel = aboutduty.find('.carousel'); dutycarousel.slick({ fade: true, prevarrow: dutyinfo.find('.prev'), nextarrow: dutyinfo.find('.next') }); } var aboutconcern = $('.about-concern'); if (aboutconcern.length) { var concerninfo = aboutconcern.find('.concern-info'), concerncarousel = aboutconcern.find('.carousel'); concerncarousel.slick({ slidestoshow: 3, slidestoscroll: 3, infinite: false, prevarrow: concerninfo.find('.prev'), nextarrow: concerninfo.find('.next'), responsive: [{ breakpoint: 1025, settings: { slidestoshow: 2, slidestoscroll: 2 } }, { breakpoint: 577, settings: { slidestoshow: 1, slidestoscroll: 1 } }] }); } }, setproduct: function () { var productcomposition = $('.product-composition'); if (productcomposition.length) { var pcompc = productcomposition.find('.p-c-carousel'), pcompcarousel = productcomposition.find('.carousel'), pcompitem = productcomposition.find('.p-c-nav .p-cn-item'); pcompcarousel.find('.carousel-item').eq(0).find('.carousel-info').show(); pcompcarousel.slick({ prevarrow: pcompc.find('.prev'), nextarrow: pcompc.find('.next'), infinite: false }).on({ "beforechange": function (event, slick, currentslide, nextslide) { pcompitem.eq(nextslide).addclass('active').siblings().removeclass('active'); }, 'afterchange': function (event, slick, currentslide) { var _item = $(this).find('.carousel-item.slick-active'), _itemcont = _item.find('.carousel-info'), _sibcont = _item.siblings().find('.carousel-info'); _itemcont.slidedown(function () { _sibcont.slideup(); }); } }); pcompitem.on({ click: function () { var _this = $(this), _index = _this.index(); pcompcarousel.slick('slickgoto', _index); } }); } }, setmore: function () { var joinrecruit = $('.recruit-info'); 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 }); } } }); }); } }, setuser: function () { /* 2018.01.11 */ var $dialog = $('.cy-dialog'); $dialog.on({ click: function (ev) { if ($(ev.target).is('.cy-dialog .c-d') || $(ev.target).is('.cy-dialog .dialog-content')) { $dialog.fadeout(function () { $dialog.find('.dialog-content').empty(); }); } } }); var $userbtn = $('.user-center .more button'); $userbtn.on({ click: function () { var $this = $(this), $content = $dialog.find('.dialog-content'); $content.empty(); $.ajax({ url: $this.data('src'), datatype: "html", success: function (rel) { $content.append(rel); $dialog.fadein(); } }); } }); } }; $(function () { cy.init(); }); /* set full screen image */ /* * _item: 图片的盒子 * _width: 输入的宽度,默认为空 * _height: 输入的高度,默认为空 * */ (function ($) { 'use strict'; $.fn.cyifs = function (opts) { var _ifs = this; var defaults = { width: $(window).width(), height: $(window).height(), off: false }; var option = $.extend({}, defaults, opts); imgfullscreen(_ifs, option.width, option.height); if (option.off) { imgfullscreen(_ifs); _ifs.removeclass('cy-fs').find('img').unwrap().removeattr('style'); } return _ifs; }; 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 () {}; }; } } }(jquery)); /* 干掉注释 */ //兼容的获取简单方案 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