$(function(){
// 轮播图
var mySwiper1 = new Swiper('#swiper6',{
    autoplay:5000,  //自动切换
    loop : true,    //循环
    pagination: '.swiper-pagination',   // 如果需要分页器
})

// 推荐楼盘
var mySwiper1 = new Swiper('.tuijianBox_list',{
    autoplay:5000,  //自动切换
    loop : true,    //循环
    slidesPerView : 1.3,
})

// 获取浏览器可见区域的宽高
    var h = $(window).height();
    var w = $(window).width();

// 点击展示侧边栏
$('.right_m').on('click',function(){
    $('.HotInvest_nav2 a.right_m').css({'transform':'rotate(90deg)'})
     $(".sidebarBox").animate({right:"0"});
})
// 点击隐藏侧边栏
$('.sidebarBox').on('click',function(){
    $('.HotInvest_nav2 a.right_m').css({'transform':'rotate(0deg)'})
    $(this).animate({right:"-100%"});
})

 /*
 *   获取 DOC 超出可视区域的高度
 */

 $(window).scroll(function (){
    var ster = $(this).scrollTop();
    navign1(ster);
});

 var dir1 = $(document).scrollTop();  
 navign1(dir1);

function navign1(st){
    if(st >180){
        $('.HotInvest_nav').addClass('HotInvest_nav2')
    }else{
        $('.HotInvest_nav').removeClass('HotInvest_nav2')
    }
}

var obj= new Object();
    obj.page=1;             //页码
    obj.limit=6;            //条数
    obj.upload=0;           //用于更多加载问题
    obj.city=0;

var listle=0;


$('.main_nav a').on('click',function(){
	if ($(this).attr('data-name')=='city') {
        $(this).addClass('on').siblings().removeClass('on');
        obj.type=$(this).attr('data-type');
        obj.city=0;
        NavAjax();
		$('.main_city').show();
	}else{
        obj.type=$(this).attr('data-type');
        obj.city=0;
        $('.main_city').hide();
        $(this).addClass('on').siblings().removeClass('on');
        listAjax()
	}
})



$('.main_city').on('click','a',function(){
    obj.city=$(this).attr('data-id');
    $(this).addClass('on').siblings().removeClass('on');
    $(this).parent().hide();
    obj.page=1;
    listAjax()
})

function NavAjax(){
    var _nav=''
    $.ajax({
        url:'/investhot/city',
        type:'get',
        data:{name:obj.name,type:obj.type,page:1,limit:6},
        dataType:"json",
        success:function(data){
            $('.main_city').html('');
            if(data.code == 200){
                $.each(data.data,function(i,v){
                    _nav+='<a href="javascript:;" data-id="'+v.id+'">'+v.city_name+'</a>'
                })
                $('.main_city').html(_nav);
            }
        }
    });
}


function listAjax(){
    var _list=''
    $.ajax({
        url:'/investhot/getlistdata',
        type:'get',
        data:{name:obj.name,city:obj.city,type:obj.type,page:obj.page,limit:obj.limit},
        dataType:"json",
        success:function(data){
            $('.mainList ul').html('');
            if(data.code == 200){
                $.each(data.data,function(i,v){
                    if (i>5) {
                    _list+='<li style="display:none">';
                    }else{
                    _list+='<li>';
                    }
                    _list+='<a href="'+v.url+'">';
                    _list+='<p class="m_img">';
                    _list+='<span><img src="http://qwimg.qianwuwang.com/pc/special/'+v.img+'" alt=""></span>';
                    if ( i < 2 ) {
                            _list+='<i><img src="/image/investhot/ico_hot13.png" alt=""></i>';  
                        }else if ( i > 2 && v.is_push == 2) {
                            _list+='<i><img src="/image/investhot/ico_hot14.png" alt=""></i>';  
                        }                        
                    _list+='</p>';
                    _list+='<div class="m_text">';
                    _list+='<p class="title">'+v.title+'</p>';
                    // _list+='<p class="title_v">(Cambodia)</p>';
                    _list+='<p class="shijian">'+time_yxq+'</p>';
                    _list+='</div>';
                    _list+='</a>';
                    _list+='</li>';
                })
                $('.mainList ul').html(_list);
                listle=data.data.length;
                if ( listle <= 6) {
                    $('.gengduo').hide();
                }else{
                    $('.gengduo').show();
                }
            }

        }
    });
}
listAjax()

var c=1;
$('.gengduo a').on('click',function(){
    if (c==1) {
        $('.mainList ul li').each(function(){
            if ($(this).index()>5) {
                $(this).show();
            };
        })
        $(this).addClass('on')
        c=2
    }else if(c==2){
        $('.mainList ul li').each(function(){
            if ($(this).index()>5) {
                $(this).hide();
            };
        })
        $(this).removeClass('on');
        c=1;
    }
})







})