/*
*  楼盘预售许可证弹窗
*  
*/

$(function(){
    var lic_id;  //为了这些变量在其它地方用;
    $('.y_ckysz').on('click',function(){
        var $that = $(this);
        var height =  $('.y_licence').outerHeight();
        var width =  $('.y_licence').outerWidth();
        CreatePopLayerDiv2(width,width,'/public/licence');
        $('#offDiv1').css({'top':height+'px'}).animate({top:'20%'})
        // 向弹窗传数据
        parent.lic_id = $that.attr('data-id');                        //把楼盘名称传向父级
    })

})
//创建一个弹出层,width 宽度,height 高度,url
function CreatePopLayerDiv2(width,height,url){
    var Iheight=$(window).outerHeight(); 
    var Iwidth =$(window).outerWidth(); 
    var heights = height || 300; 
    var widths = width || 500; 
    var Oheight= (Iheight -heights) / 2; 
    var Owidth = (Iwidth - widths) /2;
    var div ='<div id="InDiv1" style="width:'+Iwidth+'px;height:'+Iheight+'px;background:rgba(0,0,0,0.6);position:fixed;z-index:10000;top:0;left:0;">';
        div+='<div id="offDiv1" style=" width:100%; height:100%; left:0px; top:30%; position:fixed;z-index:100003;">';
        div+='<div id="Content1"></div>';
        div+='</div>';
        div+='</div>';
    $(document.body).append(div); 
    if(url != ""){ 
        $("#Content1").load(url); 
    } 
} 
//移除弹出层 
function RemoveDiv1(){
    $("#InDiv1").remove();
    $("#offDiv1").remove();
} 
function btnCloses1(){ 
    RemoveDiv1(); 
}


var page=0;
var limit = 6;
lpindexdetails(page,limit);
$('.w_guess .w_ti a').on('click',function(){
    if (page < 6) {
        page++;
    }else{
        page=0;
    };
    lpindexdetails(page,limit);
})


// 猜你喜欢
function lpindexdetails(page,limit){
    var city = $('.swiper-container .hot-house').attr('data-city');
    var price = '';
    var html = '';
    $.ajax({
        url: "/house/tall",
        data:{city:city,price:price,page:page,limit:limit},
        type: "POST",
        dataType: "json",
        success: function(data) {//请求成功完成后要执行的方法
            if (data.code == 200) {
                $.each(data.data, function (i, data) {
                    var randomX = 300;
                    var randomY = 800;
                    var randvalue = parseInt(Math.random() * (randomX - randomY + 1) + randomY);
                    html+=  '<div class="swiper-slide" data-swiper-autoplay="3300">';
                    html+=  '<a href="/house/'+data.id+'/" alt="">';
                    html+=  '<div class="h_img">';
                    html+=  '<img src="'+ data.thumb +'/same" alt="">';
                    html+=  '</div>';
                    html+=  '<p class="h_name">'+data.name+'</p>';
                    if(data.sale_price != "" && data.sale_price != 0 && data.sale_price != null){
                    html+=  '<p class="h_p"><span>'+ data.sale_price +'<i>'+data.price_unit+'</i></span><em>'+data.city_name+'</em></p>';
                    }else{
                    html+=  '<p class="h_p"><span>待定</span><em>'+data.city_name+'</em></p>';
                    }
                    html+=  '</a>';
                    html+=  '<p>有效日期:2018/12/01-2019/02/01</p>';
                    html+=  '</div> ';

                });
                $('.swiper-container .hot-house').html(html);

                var mySwiper1= new Swiper("#yw_swiper",{
                    loop : true,
                    autoplay:5000,
                    slidesPerView :2.1,
                    slidesPerGroup : 1,
                });
                
            }
        }
    });
}



var _dataid = $('.m_hq li.cur').attr('dataid');
//demo示例六 通过id调取    底部菜单插件
$('#mdemo06').navbarscroll({
    defaultSelect:_dataid,
    scrollerWidth:6,
    fingerClick:1,
    endClickScroll:function(obj){
        // console.log(obj.text())
    }
});