$(function () {
	var HcityId=$('.hotlist_nav a').eq(0).attr('data-city')
	$('.hotlist_nav a').eq(0).addClass('on');
	hotList(HcityId);
	$('.hotlist_nav').on('click','a',function(){
		$(this).addClass('on').siblings().removeClass('on')
		HcityId=$(this).attr('data-city')
		hotList(HcityId);
	})

	var WcityId=$('.hotwanquBox_nav a').eq(0).attr('data-city')
	$('.hotwanquBox_nav a').eq(0).addClass('on');
	hotwanqu(WcityId);
	$('.hotwanquBox_nav').on('click','a',function(){
		$(this).addClass('on').siblings().removeClass('on')
		WcityId=$(this).attr('data-city')
		hotwanqu(WcityId);
	})


	
	function hotList(id){
		var _list="";
		$.ajax({
	        url:"/zt/getprovince",
	        type:"POST",
	        dataType:"json",
	        data:{city:id},
	        success:function(data){
	            if(data.code == 200){
	                $('.hotlist_main ul').html('')
	                $.each(data.data,function(key,val){
	                	// console.log(val)
	                	if (key<8) {
							_list+='<li>';
							_list+='<div class="top_img">';
							_list+='<a href="/house/'+val['id']+'">';
							_list+='<p class="lpimg"><img src="'+val['thumb']+'" alt=""></p>';
							_list+='<p class="top">TOP'+(key+1)+'</p>';
							_list+='<div class="title_lp">';
							_list+='<p>'+val['name']+'</p>';
							_list+='<span><img src="/overseas/zt/hnbszt20200701/image/ico_m11.png" alt="">有效期 '+v3Time+'</span>';
							_list+='</div>';
							_list+='</a>';
							_list+='</div>';
							_list+='<div class="center_m">';
							if (val.sale_price!='' &&  val.sale_price!=null) {
							_list+='<p class="pric">均价<span>'+val['sale_price']+'</span>'+val['price_unit']+'</p>';
							}else{
							_list+='<p class="pric">均价<span>待定</span></p>';
							}
							if (val.preferential!='' && val.preferential!=null) {
							_list+='<p class="zk" title="'+val.preferential+'"><img src="/overseas/zt/hnbszt20200701/image/ico_m12.png" alt=""><span>'+val.preferential+'</span></p>';
							}else{
							_list+='<p class="zk"><img src="/overseas/zt/hnbszt20200701/image/ico_m12.png" alt=""><span>暂无优惠</span></p>';
							}
							_list+='</div>';
							_list+='<div class="bum_bm">';
							_list+='<a class="hq js_buttonHn" data-module="103" data-button="立即获取" data-text="获取项目新底价+项目详细资料+投资分析+升值空间评测,为您投资置业保驾护航" data-type="获取底价" data-id="'+val['id']+'" href="javascript:;"><img src="/overseas/zt/hnbszt20200701/image/ico_m13.png" alt="">获取底价</a>';
							_list+='<a class="lq js_buttonHn" data-module="104" data-button="立即领取" data-text="领取项目折扣+免费接机+酒店接送+专车看房,领取优惠,更享有购房立减优惠折扣" data-type="领取折扣" data-id="'+val['id']+'" href="javascript:;"><img src="/overseas/zt/hnbszt20200701/image/ico_m14.png" alt="">领取折扣</a>';
							_list+='</div>';
							_list+='</li>';
						}
	                })
					$('.hotlist_main ul').html(_list)
	            }
	        },
	        error:function(request){
	            console.log('加载失败!');
	        }
	    })
	};

	function hotwanqu(id){
		var _list="";
		$.ajax({
	        url:"/zt/getgulfcitygl",
	        type:"POST",
	        dataType:"json",
	        data:{id:id},
	        success:function(data){
	            if(data.code == 200){
	                $('.hotwanquBox_l ul').html('')
	                $.each(data.data,function(key,val){
	                	if (key<6) {
							_list+='<li>';
							_list+='<div class="top_ico">';
							_list+='<a href="/house/'+val['hid']+'">';
							_list+='<p><img src="'+val['thumb']+'" alt=""></p>';
							_list+='<span><img src="/overseas/zt/hnbszt20200701/image/ico_m11.png" alt="">有效期 '+v3Time+'</span>';
							_list+='</a>';
							_list+='</div>';
							_list+='<div class="bottom_text">';
							_list+='<p class="title"><a href="">'+val['name']+'</a></p>';
							if (val.sale_price!='' &&  val.sale_price!=null) {
							_list+='<p class="pric">均价<span>'+val['sale_price']+'</span>'+val['price_unit']+'</p>';
							}else{
							_list+='<p class="pric">均价<span>待定</span></p>';
							}
							_list+='<p class="zxzx"><a onclick="$53click()" href="javascript:;">在线咨询</a></p>';
							_list+='</div>';
							_list+='</li>';
						};
	                })
					$('.hotwanquBox_l ul').html(_list)
	            }
	        },
	        error:function(request){
	            console.log('加载失败!');
	        }
	    })
	};

	$('.myscroll').myScroll({
		speed: 40, //数值越大,速度越慢
		rowHeight: 30 //li的高度
	});
	$('.js_myscroll').myScroll({
		speed: 40, //数值越大,速度越慢
		rowHeight: 30 //li的高度
	});

	var c=1;
	$('.js_city_main').on('click',function(){
		if (c==1) {
			$('.js_city_main_list').show(20)
			c=2;
		}else if (c==2) {
			$('.js_city_main_list').hide()
			c=1;
		}
	})

	$('.js_city_main_list').on('click','a',function(){
		$(this).addClass('on').siblings().removeClass('on')
		var cityName=$(this).text();
		$('.js_city_main').find('span').text(cityName)
		$('.r_form_city input[name="intention_city"]').val(cityName);
		// console.log(cityName);
		$('.js_city_main_list').hide()
		c=1;
	})

	//调用方法二(传对象函数)
	var fun = {
	    "error" : function(){
	        PublicAction.hint("提交末成功!");        //编写需要操作的方法
	        
	    },
	    "success" : function(){
	        PublicAction.hint("提交成功!");            //编写需要操作的方法
	        $('.js_city_main').find('span').text('请选择意向城市')
			$('.r_form_city input[name="intention_city"]').val('');
			$('.r_form input[type="text"]').val('');
	    }
	}
	PublicAction.AjaxSend({CORID:'js_button_bnzf'},fun);




	var n=1;
	$('.js_pric_in_text').on('click',function(){
		if (n==1) {
			$('.js_pric_in_list').show(20)
			n=2;
		}else if (n==2) {
			$('.js_pric_in_list').hide()
			n=1;
		}
	})

	$('.js_pric_in_list').on('click','a',function(){
		$(this).addClass('on').siblings().removeClass('on')
		var cityName=$(this).text();
		$('.js_pric_in_text').find('span').text(cityName)
		$('.pric_in input[name="budget"]').val(cityName);
		// console.log(cityName);
		$('.js_pric_in_list').hide()
		n=1;
	})

	//调用方法二(传对象函数)
	var fun = {
	    "error" : function(){
	        PublicAction.hint("提交末成功!");        //编写需要操作的方法
	        
	    },
	    "success" : function(){
	        PublicAction.hint("提交成功!");            //编写需要操作的方法
	        $('.js_pric_in_text').find('span').text('请选择意向城市')
			$('.pric_in input[name="intention_city"]').val('');
			$('.adv_bottom_form_t input[type="text"]').val('');
	    }
	}
	PublicAction.AjaxSend({CORID:'js_button_pric'},fun);





	//调用方法二(传对象函数)
	var fun = {
	    "error" : function(){
	        PublicAction.hint("提交末成功!");        //编写需要操作的方法
	        $('.body input[type="text"]').val('');
	    },
	    "success" : function(){
	        PublicAction.hint("提交成功!");            //编写需要操作的方法
			$('.body input[type="text"]').val('');
	    }
	}
	PublicAction.AjaxSend({CORID:'js_pulice_button'},fun);



	tab ('.js_adv_left a','.js_adv_right ul','data-id')
	// 选项卡
	function tab (name1,name2,name3){;
	    $(name1).on('click',function(){
	        $(name2).hide();
	        var Idoption = $(this).attr(name3);
	        $(name2+'['+name3+''+'='+ Idoption +']').show();
	        $(this).addClass('on').siblings().removeClass('on');
	    })
	    $(name1).eq(0).addClass('on');
	    $(name2).eq(0).show();
	}
})


$(function(){
    $('body').on('click','.js_buttonHn',function(){
        var $that = $(this);                  //添加加载页面
        var _type = $that.attr('data-type');                        //把报名窗口 类型传向父级
        var _hid = $that.attr('data-id');                             //把楼盘ID传向父级
        var _text = $that.attr('data-text');                             //把报名 text文本传向父级
        var _module = $that.attr('data-module');                //来源模块ID
        var _title = $that.attr('data-name');                           //报名标题
        var _button = $that.attr('data-button');                           //提交按钮文案

        $('.applekf_title span').html(_type)
        $('.applekf_title .freehead p.text').html(_text)
        $('.applekf_form input[name="hid"]').val(_hid)
        $('.applekf_form input[name="source"]').val(_module)
        $('.applekf_form a.app_buttom').html(_button)
        $('.applekf').show(20);
        $('.applekfBG').show();
    });

    $('.applekfBG,.applekf_gb a').on('click',function(){
    	$('.applekf').hide();
        $('.applekfBG').hide();
    })


    

    //调用方法二(传对象函数)
	var fun = {
	    "error" : function(){
	        PublicAction.hint("提交失败");        //编写需要操作的方法
	        $('.applekfBG').click();
	    },
	    "success" : function(){
	        PublicAction.hint("提交成功!");            //编写需要操作的方法
	        $('.applekfBG').click();
	    }
	}
	PublicAction.AjaxSend({CORID:'m_app_buttom'},fun);
})