$(function(){ // 轮播图 var mySwiper1 = new Swiper('#swiper1',{ autoplay:true, //自动切换 loop : true, //循环 pagination: '.swiper-pagination', // 如果需要分页器 }) // 导航 var mySwiper1 = new Swiper('#xgnav',{ autoplay:false, //自动切换 // loop : true, //循环 pagination: '.swiper-pagination', // 如果需要分页器 slidesPerView : 4, slidesPerGroup : 4, }) // 特价活动 new Swiper('.sale',{ slidesPerView :'auto', slidesPerView : 3, slidesPerGroup :3, spaceBetween : 5, pagination: '.saleb', // 如果需要分页器 }); // 资讯分类 var swiper2 = new Swiper('#swiper2',{ slidesPerView :'auto', slidesPerGroup : 2.2, }); // 房价一览 var mySwiper1 = new Swiper('#swiper3',{ autoplay:true, //自动切换 loop : true, //循环 pagination: '.swiper-pagination3', // 如果需要分页器 }) // 精选房源 var swiper4 = new Swiper('#swiper4',{ autoplay:true, //自动切换 // loop : true, //循环 slidesPerView :'auto', slidesPerGroup : 1, }); // 精选房源 var swiper5 = new Swiper('#swiper5',{ // autoplay:true, //自动切换 // loop : true, //循环 slidesPerView :'auto', slidesPerGroup : 1, }); // 精选房源 var swiper6 = new Swiper('#swiper6',{ // autoplay:true, //自动切换 // loop : true, //循环 slidesPerView :'auto', slidesPerGroup : 1, }); // 精选房源 var swiper7 = new Swiper('#swiper7',{ // autoplay:true, //自动切换 // loop : true, //循环 slidesPerView :'auto', slidesPerGroup : 1, }); $('.m_lp_list ul li').each(function(){ var _height = $(this).find('.m_lp_list_img p span').innerHeight() / 2; $(this).find('.m_lp_list_img p span').css('margin-top',- _height +'px'); // console.log(_height); }) // 精选房源 // var presentData = {"dataID":"0","type":""} // $('.m_title_nav a').on('click',function(){ // var that = $(this); // var oid = that.attr("data-id"); // var type = that.attr("data-type"); // that.addClass('on').siblings().removeClass('on'); // presentData.dataID = oid; // presentData.type = type; // fn_ajax(presentData) // }) function fn_ajax(obj){ // console.log(obj) var url = ''; if(obj.type == 'housing'){ url = './js/index.json'; }else if(obj.type == 'news'){ url = './js/index_news.json'; } $.ajax({ type: "post", url: url, data: obj, dataType: "json", success: function(data){ console.log(data.data); if(data.code == 200){ console.log(data.data); switch(obj.type) { case 'housing': sift(data.data) break; case 'news': fn_news(data.data) break; } } } }); } //精选楼盘 function sift(obj){ var li = ''; $.each(obj,function(k,v){ li += '
'+v.lp_name+'
'; li += ''+v.area+'
'; li += '¥'+v.price+v.uint+'
'; li += ''; li += '房子面积越大越好吗?看看 国外多大的房子最受欢...
'; _li +='2018-09-11
'; _li +='