$(function(){ $('.sex').on('click','.asd',function(){ $('.asd').removeClass('active'); console.log($(this).attr('class')) //初始化 $('.sex-l > .toimg > img').attr("src", "../images/nan.png") $('.sex-r > .toimg> img').attr("src", "../images/wxnv.png") if ($(this).attr('class') == 'sex-l asd') { //点击为男切换男选中样式图片 $(this).children('.toimg').children('img').attr("src", "../images/xznan.png"); } else{ //点击为女切换女选中样式图片 $(this).children('.toimg').children('img').attr("src", "../images/nv.png"); } $(this).addClass('active'); }) }); function Ding(){ //获取当前到顶部距离 var Top = $('.qyjs-wrap').offset().top; //获取底部导航高度 var Height = $('.footer').height(); //判断滚动条是否大于距离顶部距离 $(window).scroll(function(){ //如果大于就定位 if ($(this).scrollTop() > Top) { $('.qyjs-wrap').addClass('ding') }else if($(this).scrollTop() < Top){ $('.qyjs-wrap').removeClass('ding'); } }) $(window).scroll(function(){ var Top = $('.qyjs-wrap').offset().top; var scrollTop=$(document).scrollTop(); var scrolld=$(document).height()-$(window).height()-$('.footer').height(); if(scrollTop>=scrolld){ console.log('daodil'); $('.qyjs-wrap').removeClass('ding'); } }) } //轮播 function history() { var _ind = 0; var _len = $(".his-top .swiper-slide").length; var histopbox_swiper = new Swiper('.his-top .swiper-container', { prevButton:'.his-top .swiper-button-prev', nextButton:'.his-top .swiper-button-next', slidesPerView:7, spaceBetween : 0, breakpoints: { 1023: { slidesPerView: 7, }, 767: { slidesPerView: 2, }, 320:{ slidesPerView: 1, } } }); btnJudge(); $(".his-top .swiper-button-prev").click(function() { _ind--; btnJudge() $(".his-top .swiper-slide").eq(_ind).addClass("onn").siblings().removeClass("onn"); $(".his-top .swiper-slide.onn").click(); }) $('.his-top .swiper-button-next').click(function() { _ind++; btnJudge() $(".his-top .swiper-slide").eq(_ind).addClass("onn").siblings().removeClass("onn"); $(".his-top .swiper-slide.onn").click(); }) $(".his-top .swiper-slide").click(function(){ _ind = $(this).index(); $(this).addClass("onn").siblings().removeClass("onn"); var url = $(this).data("src"); if(url == ""){ return false; }else{ caseAjax(".contentlun",url); console.log(url) } }) //caseAjax function caseAjax(str,url){ $.ajax({ url:url, success:function(msg){ $(str).html(""); $(str).append(msg); bottomswipet() //imgratio(); } }); } $(".his-top .swiper-slide").eq(0).click(); function btnJudge() { if(_ind >= _len - 1) { $('.his-top .swiper-button-next').addClass("disabled") _ind = _len - 1; } else { $('.his-top .swiper-button-next').removeClass("disabled") } if(_ind <= 0) { $(".his-top .swiper-button-prev").addClass("disabled") _ind = 0; } else { $(".his-top .swiper-button-prev").removeClass("disabled") } } } function bottomswipet(){ var hswiper = new Swiper('.his-bottom .swiper-container', { observer:true, //修改swiper自己或子元素时,自动初始化swiper // autoHeight: true, prevButton:'.his-bottom .swiper-button-prev', nextButton:'.his-bottom .swiper-button-next', slidesPerView:3, spaceBetween : 0, breakpoints: { 1023: { slidesPerView: 2, }, 767: { slidesPerView: 1, } } }); } function tapmap(x,y){ console.log('11') var map = new BMap.Map('mymap'); map.centerAndZoom(new BMap.Point(x, y), 12); map.enableScrollWheelZoom(true); // 创建点标记 var marker1 = new BMap.Marker(new BMap.Point(x, y)); // 在地图上添加点标记 map.addOverlay(marker1); }