$(function(){ $('#owl1').owlcarousel({ items: 1, navigation: true, navigationtext: ["上一个","下一个"], autoplay: true, stoponhover: true }).hover(function(){ $('.owl-buttons').show(); }, function(){ $('.owl-buttons').hide(); }); $('#owl2').owlcarousel({ items: 1, navigation: true, navigationtext: ["上一个","下一个"], autoplay: true, stoponhover: true }).hover(function(){ $('.owl-buttons').show(); }, function(){ $('.owl-buttons').hide(); }); }); $(document).ready(function() { //首页栏目标题切换 var listheadernames = $(".list-header .name"); listheadernames.on("mouseenter", function () { var names = $(this).parent().children(".name"); if (names.length === 1) { return; } names.removeclass("cur"); $(this).addclass("cur"); var index = $(this).index(); //更多链接地址切换 var as = $(this).parent().children(".more").children("a"); if (as.length < index + 1) { return; } as.hide(); $(as[index]).show(); //下方文章列表切换 var lists = $(this).parent().parent().children(".list"); if (lists.length < index + 1) { return; } lists.hide(); $(lists[index]).show(); }); var xwjtlist = $(".block5 .container .list "); var xwjteles = $(".block5 .container .list .element"); xwjtlist.css("width", xwjteles.length * 305); var canscroll = true; setinterval(function(){ if(canscroll){ xwjtlist.animate( {marginleft: -305} , function (){ xwjteles = $(".block5 .container .list .element"); var first = $(xwjteles[0]).clone(true); $(xwjteles[xwjteles.length - 1]).after(first); $(xwjteles[0]).remove(); xwjtlist.css("margin-left", 0); } ); } }, 3000); //新闻镜头切换效果 xwjteles.on("mouseenter", function () { if (xwjteles.length === 0) { return; } xwjteles.removeclass("cur"); $(this).addclass("cur"); canscroll = false; }); xwjteles.on("mouseleave", function () { xwjteles = $(".block5 .container .list .element"); xwjteles.removeclass("cur"); canscroll = true; }); //初始化幸福大唐图片 var pics = $(".xfdt .pics img"); var activepicindex = 0; { if (pics.length > 2) { $(pics[2]).css("left", 0); $(pics[2]).css("top", "14px"); $(pics[2]).css("width", "auto"); $(pics[2]).css("height", "130px"); } } var moving = false; $(".xfdt .list .left .button").on("click", function () { var leftindex = activepicindex; toleft(pics[leftindex]); var centerindex = leftindex + 1 > pics.length - 1 ? 0 : leftindex + 1; $(pics[centerindex]).css("z-index", 1); tocenter(pics[centerindex]); var rightindex = centerindex + 1 > pics.length - 1 ? 0 : centerindex + 1; toright(pics[rightindex]); activepicindex = centerindex; changexfdttitle(); }); $(".xfdt .list .right .button").on("click", function () { var rightindex = activepicindex; toright(pics[rightindex]); var centerindex = rightindex - 1 < 0 ? pics.length - 1 : rightindex - 1; $(pics[centerindex]).css("z-index", 1); tocenter(pics[centerindex]); var leftindex = centerindex - 1 < 0 ? pics.length - 1 : centerindex - 1; toleft(pics[leftindex]); activepicindex = centerindex; changexfdttitle(); }); { var fixed = $(".fixed"); var close = $(".fixed .close"); var windowwidth = $(window).width(); var windowheight = $(window).height(); var elementwidth = 440; var elementheight = 370; var fixedright = 20; var fixedtop = 20; var fixedmoving = true; var totaltime = 20;//以秒为单位 var timeout = 10; var tps = (windowheight - elementheight - 20 - fixedtop) / (totaltime * 1000 / timeout); var rps = (windowwidth - elementwidth - 20 - fixedright) / (totaltime * 1000 / timeout); close.on("click", function (e) { fixed.hide(); }) fixed.on("mouseover", function (e) { fixedmoving = false; }); fixed.on("mouseout", function (e) { fixedmoving = true; }); setinterval(function () { if (fixedmoving) { fixedtop += tps; fixedright += rps; if (windowwidth - elementwidth - fixedright < 20) { fixedright = windowwidth - elementwidth - 20; } if (windowheight - elementheight - fixedtop < 20) { fixedtop = windowheight - elementheight - 20; } fixed.css("top", fixedtop); fixed.css("right", fixedright); } }, timeout); } { var sfcontainer = $(".spring-festival"); sfcontainer.on("mouseover", function(){ $(".spring-festival .close").show(); }) sfcontainer.on("mouseout", function(){ $(".spring-festival .close").hide(); }) $(".spring-festival .close").on("click", function(){ $(".spring-festival").hide(); }) } function changexfdttitle(){ var xfdtas = $(".xfdt .list .links a"); $(".xfdt .title a").text($(xfdtas[activepicindex]).text()).attr("href", $(xfdtas[activepicindex]).attr("href")); } function tocenter(element){ $(element).animate({ left:'33px', top: '0', height:'170px', width:'226px', zindex: '5' }); } function toleft(element){ $(element).animate({ left:'0', top: '14px', height:'130px', width:'174px', zindex: '0' }); } function toright(element){ $(element).animate({ left: '118px', top: '14px', height:'130px', width:'174px', zindex: '0' }); } //股票信息 { // var sh = hq_str_sh601991.split(","); // var hk = hq_str_hk00991.split(","); // var sh_p = '-', hk_p = '-'; // var sh_cha = sh[3] - sh[2]; // var hk_cha = hk[7]; // sh_cha = sh_cha.tofixed(2); // if (sh_cha > 0) { // sh_p = '↑'; // } else if (sh_cha < 0) { // sh_p = '↓'; // } // sh_cha = math.abs(sh_cha); // if (hk_cha > 0) { // hk_p = '↑'; // } else if (hk_cha < 0) { // hk_p = '↓'; // } // hk_cha = math.abs(hk_cha); // $('#gp1').html(sh[3] + '    ' + sh_p + sh_cha); // $('#gp2').html(hk[6] + '    ' + hk_p + hk_cha); } });