//页面加载完成 $(document).ready(function(){ subnav() headerbtn() videoevent(); milestone(); comap(); responsbility() business() indexbanner() indexnews() directorslist() //mangerlist() indexstock() indexbannerreset() businesszoom() indexbusiness() }); //当改变宽度时 $(window).resize(function(){ subnav(); milestone(); responsbility() business() directorslist() indexbannerreset() $(".index-stock .swiper-slide").width($(".index-stock .swiper-container").width()) $(".index-stock .str_move").width($(".index-stock .swiper-container").width()*2) }); function businesszoom(){ $(".business .item3 .zoom-btn").click(function(){ $(this).siblings("img").trigger("click"); }); $(".business .item3 img").click(function(){ $(this).src=$(this).attr("bigsrc"); }); if($('.zoom-img').length > 0){ $('.zoom-img').viewer({ navbar:false, title:false, toolbar:false }); } } function indexbusiness(){ new swiper ('.index-business .swiper-container', { pagination: '.index-business .swiper-pagination', autoplay : 5000, loop : true, }) /* $(".index-business .swiper-container").each(function(e){ $(this).addclass("ib"+e) new swiper ('.index-business .ib'+e, { pagination: '.index-business .ib'+e+' .swiper-pagination', }) }) */ } function indexstock(){ var stockswiper; var init = function(){ // initswiper(); if($(".index-stock").length > 0){ superslide(); } } var superslide = function(){ $(".str_move").append(getdata()+getdata()) $('.dowebok').limarquee(); $(".index-stock .swiper-slide").width($(".index-stock .swiper-container").width()) $(".index-stock .str_move").width($(".index-stock .swiper-container").width()*2) setinterval(function(){ $(".str_move").append(getdata()) $(".index-stock .swiper-slide").width($(".index-stock .swiper-container").width()) w = parseint($(".index-stock .str_move").width())+parseint($(".index-stock .str_move").width()) $(".index-stock .str_move").width(w) },4000) setinterval(function () { $(".str_move .swiper-slide").eq(0).remove(); },6100) } var initswiper = function(){ stockswiper = new swiper ('.index-stock .swiper-container', { direction: 'vertical', oninit: function(swiper){ swiper.appendslide(getdata()); setinterval(function(){ swiper.appendslide(getdata()); swiper.slidenext(); },2000) setinterval(function () { swiper.removeslide(0); },2100) } }) } var getdata = function(){ $(".stock").attr("src","https://hq.sinajs.cn/list=s_sh600622") var data =hq_str_s_sh600622.split(","); var _html = sethtml(data); return _html; //stockswiper.appendslide(_html); //加到swiper的最后 //stockswiper.removeslide(0); //移除第二个slide } var sethtml = function(data){ var hq_str = '
' + '
光大嘉宝:代码600622
' + '
'; hq_str += '
' + parsefloat(data[1]).tofixed(2) + '' + '' + parsefloat(data[2]).tofixed(2) + '' + '' + data[3] + '%
'; if ( parsefloat(data[3]) > 0 ) { hq_str += '
'; } else { hq_str += '
'; } hq_str += '
成交量:' + data[4] + '(手) 成交额:' + data[5] + '(万元)
'; return hq_str; } init(); } function mangerlist(){ $(".manger-list ul li").each(function(){ new image().src = $(this).find("img").attr("csrc"); }); $(".manger-list ul li").hover(function(){ var i = $(this).find("img"); i.attr("src",i.attr("csrc")); },function(){ var i = $(this).find("img"); i.attr("src",i.attr("bsrc")); }); } function directorslist(){ if($(window).width() > 768){ var _h = 0 $(".directors-list ul li").each(function(){ if($(this).height() > _h){ _h = $(this).height() } }); }else{ _h = 'auto' } $(".directors-list ul li").height(_h); } function indexnews(){ var inswiper = new swiper ('.index-news .swiper-container', { oninit: function(swiper){ $(".index-news .index-news-tab ul li").click(function(){ inswiper.slideto($(this).index()) }); }, onslidechangestart: function(swiper){ $(".index-news .index-news-tab ul li").eq(swiper.activeindex).addclass("on").siblings("li").removeclass("on") } }) // $(".index-news .index-news-tab ul li").each(function(index) { //带参数遍历各个选项卡 // $(this).click(function() { //注册每个选卡的单击事件 // $(".index-news .index-news-tab ul li.on").removeclass("on"); //移除已选中的样式 // $(this).addclass("on"); //增加当前选中项的样式 // //显示选项卡对应的内容并隐藏未被选中的内容 // $(".index-news .container .swiper-slide:eq(" + index + ")").show() // .siblings().hide(); // }); // }); } function responsbility(){ if($(".responsbility").length > 0){ if($(window).width() > 768){ $(".responsbility .item3 .text").height($(".responsbility .item3 .pic").height()) }else{ $(".responsbility .item3 .text").height("auto") } } } function business(){ if($(".business .item3").length > 0){ if($(window).width() > 768){ isimgload($(".business .item3 .text img").eq(0),function(){ $(".business .item3 .text").height($(".business .item3 .pic").height()) }); settimeout(function(){ $(".business .item3 .text").height($(".business .item3 .pic").height()) },3000) }else{ $(".business .item3 .text").height("auto") } } } var t_img; // 定时器 var isload = true; // 控制变量 // 判断图片加载的函数 function isimgload(obj,callback){ // 注意我的图片类名都是cover,因为我只需要处理cover。其它图片可以不管。 // 查找所有封面图,迭代处理 obj.each(function(){ // 找到为0就将isload设为false,并退出each if(this.height === 0){ isload = false; return false; } }); // 为true,没有发现为0的。加载完毕 if(isload){ cleartimeout(t_img); // 清除定时器 // 回调函数 callback(); // 为false,因为找到了没有加载完成的图,将调用定时器递归 }else{ isload = true; t_img = settimeout(function(){ isimgload(callback); // 递归扫描 },500); // 我这里设置的是500毫秒就扫描一次,可以自己调整 } } function comap(){ if($("#map").length > 0){ // 百度地图api功能 var map = new bmap.map("map"); // 创建map实例 var point = new bmap.point(121.255608,31.358152); map.centerandzoom(new bmap.point(121.257421,31.358146), 19); // 初始化地图,设置中心点坐标和地图级别 map.enablescrollwheelzoom(true); //开启鼠标滚轮缩放 var marker = new bmap.marker(point); // 创建标注 map.addoverlay(marker); // 将标注添加到地图中 var map2 = new bmap.map("map2"); // 创建map实例 var point2 = new bmap.point(121.421042,31.222587); map2.centerandzoom(new bmap.point(121.420003,31.223398), 19); // 初始化地图,设置中心点坐标和地图级别 map2.enablescrollwheelzoom(true); //开启鼠标滚轮缩放 var marker2 = new bmap.marker(point2); // 创建标注 map2.addoverlay(marker2); // 将标注添加到地图中 var map3 = new bmap.map("map3"); // 创建map实例 var point3 = new bmap.point(116.364206,39.937528); map3.centerandzoom(new bmap.point(116.361061,39.938601), 18); // 初始化地图,设置中心点坐标和地图级别 map3.enablescrollwheelzoom(true); //开启鼠标滚轮缩放 var marker3 = new bmap.marker(point3); // 创建标注 map3.addoverlay(marker3); // 将标注添加到地图中 $(".contact-us .swiper-slide").each(function(index) { //带参数遍历各个选项卡 $(this).click(function() { //注册每个选卡的单击事件 $(".contact-us .swiper-slide.on").removeclass("on"); //移除已选中的样式 $(this).addclass("on"); //增加当前选中项的样式 //显示选项卡对应的内容并隐藏未被选中的内容 $(".container .contact-box:eq(" + index + ")").show() .siblings().hide(); }); }); $(".contact-box .right").click(function(){ console.log("1"); if($(this).hasclass("close")){ $(this).removeclass("close"); $(this).parents(".tip-box").removeclass("close"); }else{ $(this).addclass("close"); $(this).parents(".tip-box").addclass("close"); } }); } } function headerbtn(){ $(".header .mobile-btn").click(function(){ if($(this).hasclass("on")){ //$(".nav").slideup(); $(".nav").fadeout(); $(this).removeclass("on") }else{ //$(".nav").slidedown(); $(".nav").fadein(); $(this).addclass("on") } }); } function subnav(){ if($(window).width()<=1024){ swiperconfig = { slidesperview:'auto', initialslide :$(".sub-nav .swiper-slide.on").index() } if($(".sub-nav").hasclass("loaded")){ window.subnavswiper.destroy(false); $(".sub-nav").removeclass("loaded") }else{ window.subnavswiper = new swiper ('.sub-nav .swiper-container', swiperconfig) $(".sub-nav").addclass("loaded") } }else{ if($(".sub-nav").hasclass("loaded")){ window.subnavswiper.destroy(false); $(".sub-nav").removeclass("loaded") } } } function videoevent(){ var init = function(){ $(".video-box img").load(function(){ var url = $(".video-box").find("#video-container").data("src") var vwidth = $(".video-box").find("img").width(); var vheight = $(".video-box").find("img").height(); dojwplayer(url,vwidth,vheight,false); }); var url = $(".video-box").find("#video-container").data("src") var vwidth = $(".video-box").find("img").width(); var vheight = $(".video-box").find("img").height(); dojwplayer(url,vwidth,vheight); } var dojwplayer = function(url,vwidth,vheight){ initjwplayer(url,vwidth,vheight,false); } /** * jwplayer 初始化 * @param videosrc 视频地址 * @param vwidth 视频宽度 * @param vheight 视频高度 * @param isautoplay 是否自动播放 */ var initjwplayer = function(videosrc,vwidth,vheight,isautoplay){ var tplayer = jwplayer('video-container').setup({ file: videosrc, width:vwidth, height:vheight, events: { onready: function () { $('.video-hover .play').click(function(){ $('.video-hover').fadeout(); tplayer.play(); }); }, oncomplete: function () { settimeout(function(){ $('.video-hover').fadein(); },1000) } } }); if(isautoplay){ $('.hover-box').fadeout(); tplayer.play(); } } if($(".video-box img").length > 0){ init(); } } function milestone(){ var _h = $(".milestone-con .top .left").outerheight(); $(".milestone-con .top .right").css("height",_h); } function indexbanner(){ new swiper ('.index-banner .swiper-container', { pagination : '.index-banner .swiper-pagination', autoplay : 5000, loop : true, }) console.log(111111) } function indexbannerreset(){ var winw = $(window).width() var _src; $(".index-banner .swiper-slide").each(function(){ if(winw > 768){ _src = $(this).data("pc-bg") }else{ _src = $(this).data("mobile-bg") } $(this).css("background-image","url('"+_src+"')") }); } (function($){ $.fn.extend({ rolltitle: function(opt,callback){ if(!opt) var opt={}; var _this = this; _this.timer = null; _this.lineh = _this.find("li:first").height(); _this.line=opt.line?parseint(opt.line,15):parseint(_this.height()/_this.lineh,10); _this.speed=opt.speed?parseint(opt.speed,10):3000, //卷动速度,数值越大,速度越慢(毫秒 _this.timespan=opt.timespan?parseint(opt.timespan,13):5000; //滚动的时间间隔(毫秒 if(_this.line==0) this.line=1; _this.upheight=0-_this.line*_this.lineh; _this.scrollup=function(){ _this.animate({ margintop:_this.upheight },_this.speed,function(){ for(i=1;i<=_this.line;i++){ _this.find("li:first").appendto(_this); } _this.css({margintop:0}); }); } _this.hover(function(){ clearinterval(_this.timer); },function(){ _this.timer=setinterval(function(){_this.scrollup();},_this.timespan); }).mouseout(); } }) })(jquery);