$(function () { $(".nav_sub").each(function(){ var id =$(this).attr("id"); if(id !=null ||id !=""){ $("#"+id).html(""); $("p[group_pid='"+id+"']").each(function(){ $("#"+id).css("display",""); $("#"+id).append($(this).prop("outerhtml")); }) } }); // 手机端效果 $(".m_more").click(function () { $(".nav").css({ 'display': 'flex' }) $('body').css("overflow", 'hidden') }) $(".m_close").click(function () { $(".nav").css({ 'display': 'none' }) $('body').css("overflow", 'auto') }) var win_width = $(window).width(); var html_moble sz() function sz() { if (win_width <= 980) { // console.log(1) win_width = $(window).width(); html_moble = win_width / 390 * 100; $("html").css('font-size', html_moble) } } $(window).resize(() => { sz() }) // 导航下拉——效果 var now_index = $(".nav li").filter(".on").index(); console.log($(".nav li").filter(".on").index()); if(now_index==-1){ $(".nav").find('li').eq(0).addclass("on"); now_index=0; } nav_feffect(now_index); }) // 导航效果 function nav_feffect(now_nav) { nav_unline_move($(".nav").find('li').eq(now_nav), 0) var dsq_nav $(".nav").find('li').mouseenter(function () { cleartimeout(dsq_nav) nav_unline_move($(this)) }) function back_inline(bk_nav_li) { let li_left = bk_nav_li.position().left; let li_width = bk_nav_li.outerwidth(true); bk_nav_li.addclass("on").siblings().removeclass("on") $('.nav_unline').css({ 'left': li_left + (li_width / 2) }) $('.nav_unline').css({ 'width': 80 }) } function nav_unline_move(nav_li, csh = 1) { let li_left = nav_li.position().left; let li_width = nav_li.outerwidth(true); nav_li.addclass("on").siblings().removeclass("on") $('.nav_unline').css({ 'left': li_left + (li_width / 2) }) settimeout(function () { $('.nav_unline').css({ 'width': 80 }) }, 150) let sub_li = nav_li.find(".nav_sub p").length nav_li.find(".nav_sub").width(sub_li * 120) nav_li.siblings().find(".nav_sub").hide() if (csh == 0) { nav_li.find(".nav_sub").hide() } else { nav_li.find(".nav_sub").stop(true).fadein() } } $(".search_box").mouseenter(function () { back_inline($(".nav").find('li').eq(now_nav)) }) $(".nav").find('li').mouseleave(function () { $('.nav_unline').css({ 'width': 10 }) cleartimeout(dsq_nav) }) $(".top").mouseleave(function () { dsq_nav = settimeout(function () { $(".nav_sub").hide(); back_inline($(".nav").find('li').eq(now_nav)) }, 500) }) $(".nav_sub").mouseenter(function () { $(".nav_sub").show() cleartimeout(dsq_nav) }) } //企业排列 function qypl_f(domid, col, row, control) { control.hide() let box_w = domid.parent().parent().width() / col //单个节点宽度 let li_num = domid.find('li').length;//节点个数 let li_height = domid.find('li').outerheight(true);//节点个数 console.log(domid.parent().outerwidth(true)) domid.find('li').css({ width: box_w - 20, 'box-sizing': 'border-box' }) domid.css({ height: li_height * row, width: math.ceil(li_num / (col * row)) * domid.parent().outerwidth(true) }) var com = 0 // 横向重复显示参数 for (let i = 0; i < li_num; i++) { let o = math.floor((i % (row * col)) / col) //节点所在第几行 if (i % (row * col) == 0 && i != 0) { //判断节点超过显示区域后排列 com += col } domid.find('li').eq(i).css({ top: o * li_height, left: (i % col) * box_w + (com * box_w) }) //(i % col) * box_w 是按列计算left ,+ (com * box_w)超出后的left } if (li_num > col * row) { control.show() let move_l = 0 let max_box = math.ceil(li_num / (col * row)) for (let i = 0; i < max_box; i++) { $(".qylist_dot").append('
') } $(".qylist_dot").find(".dot").click(function () { let this_now = $(this).index() move_l=this_now moves() }) $(".qylist_dot").find('.dot').eq(move_l).addclass("on").siblings().removeclass("on") control.find('p').click(function () { let ck_now = $(this).index() switch (ck_now) { case 0: moves(move_l--) break; case 2: moves(move_l++) break; default: break; } }) function moves() { if (move_l <= 0) { move_l = 0 } else if (move_l >= max_box) { move_l = max_box - 1 } $(".qylist_dot").find('.dot').eq(move_l).addclass("on").siblings().removeclass("on") domid.stop(true, true).animate({ left: move_l * -box_w * col }, 1000) } } }