123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428 |
- $(window).scroll(function (){
- var st = $(this).scrollTop();
- if(st >50){
- $('.y_header').hide();
- $('.y_homelist_head').addClass('wtop');
- }else{
- $('.y_header').show();
- $('.y_homelist_head').removeClass('wtop');
- }
- });
- // function Qalert(num = 0) {
- // var M = {};
- // if(M.dialog1){
- // return M.dialog1.show();
- // }
- // M.dialog1 = jqueryAlert({
- // 'content' : '已为您找到<span style="color:#FF6926;font-size: 1.0rem;"> '+count+' </span>套房源',
- // 'closeTime' : 4000,
- // })
- //
- // }
- function getParams(url) {
- var theRequest = new Object();
- if (!url)
- url = location.href;
- if (url.indexOf("?") !== -1)
- {
- var str = url.substr(url.indexOf("?") + 1) + "&";
- var strs = str.split("&");
- for (var i = 0; i < strs.length - 1; i++)
- {
- var key = strs[i].substring(0, strs[i].indexOf("="));
- var val = strs[i].substring(strs[i].indexOf("=") + 1);
- theRequest[key] = val;
- }
- }
- return theRequest;
- }
- var objUrl = {}; //获取get参数
- var url = window.location.href;
- var searchParams = ''; //最后拼接的参数
- var urlParams = '';
- // 页数
- var page = 0;
- // 每页展示5个
- var size = 10;
- var params = getParams(url); //获取get请求的参数
- if(!$.isEmptyObject(params)){
- $.each(params,function(key,val){
- if(key == 'city') feng_cityTel = val;
- objUrl[key] = val;
- urlParams += key+'='+val+'&';
- })
- urlParams = urlParams.substring(0,urlParams.length - 1);
- searchParams = '&'+ urlParams;
- }
- $('.y_qylist_cnet_ind').on('click','a.link_click',function () {
- var _this = $(this);
- if(_this.attr('name') == 'city' && _this.attr('value') != 0){
- _this.parent().parent().hide();
- }
- _this.parent().hide();
- var nameattr = $(this).attr('name');
- $('.feng_'+nameattr).children('span').html(_this.html());
- if( _this.attr('name') == 'price'){
- var subject = price_deal(_this.find('span').text());
- if(subject != 1){
- $('.feng_'+nameattr).children('span').html(subject);
- }else{
- $('.feng_'+nameattr).children('span').html(_this.html());
- }
- }
- if(_this.attr('name') == 'city'){
- objUrl['py'] = _this.attr('pinyin');
- }
- var ParamsArr = ['city','type','sort','price','py']; //搜索字段
- var atrName = _this.attr('name');
- var _val = _this.attr('value');
- var urlParams = '';
- for (var k in ParamsArr){
- if(ParamsArr[k] == atrName){
- objUrl[atrName] = _val;
- delete objUrl.page;
- delete objUrl.name;
- }
- }
- $.each(objUrl,function(key,val){
- if(key == 'py') return true; //跳出当前循环
- urlParams += key+'='+val+'&';
- })
- var cityUrl = '';
- urlParams = urlParams.substring(0,urlParams.length - 1);
- if(typeof objUrl.py == 'string'){
- cityUrl = 'py='+objUrl.py+'&';
- }
- if(urlParams == '' && cityUrl != '')
- {
- cityUrl = cityUrl.substring(0,cityUrl.length - 1);
- }
- window.location.href = '/villa/villalist?'+ cityUrl+urlParams;
- })
- $(function(){
- var onoff=true;
- $('.y_homelist_list').dropload({
- scrollArea : window,
- loadDownFn : function(me,da){
- page++;
- // 拼接HTML
- var result = '';
- $.ajax({
- type: 'GET',
- url: '/house/searchdata?page='+page+'&limit='+size+searchParams+'&hao=1',
- dataType: 'json',
- async:false,
- success: function(data){
- // if(data.count){
- // // Qalert(data.count);
- // }
- var data = data.data;
- // console.log(data);
- if(data != null){
- $.each(data,function (key,val) {
- var randomX = 300;
- var randomY = 800;
- var randvalue = parseInt(Math.random() * (randomX - randomY + 1) + randomY);
- // var dataID = (key+1)+(page-1)*size;
- result += '<li class="c">';
- // result += '<a href="javascript:void(0);">';
- // result += '<a href="/house/'+val.id+'">';
- result += '<div class="picture">';
- result += '<a href="/house/'+val.id+'">';
- result += '<div class="picture_price">';
- result += '<h2>'+val.name+'</h2>';
- result += '</div>';
- result += '<img src='+val.hao_img+' alt="">';
- result += '</a>';
- result += '</div>';
- result += '<div class="picture_font">';
- result += '<a href="/house/'+val.id+'">';
- result += '<div class="picture_name">';
- result += '<label>荐</label>';
- result += '<p>'+val.reason+'</p>';
- result += '</div>';
- result += '<div class="price-bx">';
- result += '<p class="picture_price_font">';
- result += '¥';
- result += '<span>'+val.sale_price+'</span>';
- result += '<label>'+val.price_unit+'</label>';
- result += '</p>';
- result += '<p class="valid">有效期:'+getNextMonth(time)+'</p>';
- result += '</div>';
- result += '<div class="heroism-box">';
- var reg = parseInt(val.jingmi) + parseInt(val.haoqi);
- var reg1 = reg/2;
- result += '<div class="minute"> '+reg1+'分</div>';
- result += '<div class="precision">静密值:<span>';
- result += starFn(val.jingmi);
- result += '</span></div>';
- result += '<div class="heroism">豪气值:<span>';
- result += starFn(val.haoqi);
- result += '</span></div>';
- result += '</div>';
- result += '<p class="site"><img src="/image/icn-map.png" alt="">'+val.address+'</p>';
- result += '</a>';
- result += '<div class="trademark">';
- result += '<div class="trademark-logo">';
- result += '<img src='+val.logo+' alt="">';
- result += '</div>';
- result += '<a class="trademark-btn popup" href="javascript:void(0);" data-name="获取优惠" data-text="我们将为您保密个人信息!专业团队,一对一服务,让你全程无忧看房!" data-id="'+val.id+'" data-module="46">获取优惠</a>';
- result += '</div>';
- result += '</div>';
-
- // result += '</a>';
- result += '</li>';
- if((key+1)%5 == 0){
- result += apply();
- }
- })
- // 如果没有数据
- }else{
- // 锁定
- me.lock();
- // 无数据
- me.noData();
- }
- // 为了测试,延迟1秒加载
- setTimeout(function(){
- // 插入数据到页面,放到最后面
- $('.y_homelist_list ul').append(result);
- // 每次数据插入,必须重置
- me.resetload();
- },100);
- },
- error: function(xhr, type){
- // alert('Ajax error!');
- // 即使加载出错,也得重置
- me.resetload();
- }
- });
- }
- });
- });
- $.each($('.m_nav_qy').find('a'),function(){
- var each_name = $(this).attr('name');
- var each_val = $(this).attr('value');
- if(each_val == objUrl[each_name]){
- $(this).attr('id','nav');
- }
- })
- //
- $(".y_qylist_cnet_ind").on('click','a.link-item',function(){
- var _this = $(this);
- _this.addClass('on');
- _this.siblings().removeClass('on');
- $('.three_area').show();
- $.post('/villa/soncity',{pid:_this.attr('value')},function(data){
- $(".three_area").html('');
- if(data.code == 200){
- var str = '';
- str += '<a class="link_click" name="city" pinyin="'+_this.attr('pinyin')+'" value="'+_this.attr('value')+'" href="javascript:;">'+_this.find('span').html()+'</a>';
- $.each(data.data,function (k,v) {
- str += '<a class="link_click" name="city" pinyin="'+v.pinyin+'" value="'+v.id+'" href="javascript:;"><span>'+v.city_name+'</span></a>';
- })
- }
- $(".three_area").append(str);
- })
- $(".three_area").animate({left:"35%"});
- })
- $(".y_qylist_cnet_ind").on('click','a.actived-item',function(){
- $(".three_area").animate({left:"100%"});
- })
- function waptab(name1,name2,name3){
- $(name1).on('click',function(){
- $(name2).hide();
- var Idoption = $(this).attr(name3);
- var that = $(this);
- if($(this).hasClass('on')){ //判断css on 是否存在
- that.parents('.y_qylist').find(name2+'['+name3+''+'='+ Idoption +']').hide();
- $(this).removeClass('on');
- }else{
- $(this).addClass('on').siblings().removeClass('on');
- that.parents('.y_qylist').find(name2+'['+name3+''+'='+ Idoption +']').show();
- }
- })
- }
- waptab('.y_qylist_hoe .y_qylist_con','.y_qylist_cnet_ind','data-id');
- // 有效期 时间加两个自然月
- function getNextMonth(date) {
- var arr = date.split('/');
- var year = arr[0]; //获取当前日期的年份
- var month = arr[1]; //获取当前日期的月份
- var day = arr[2]; //获取当前日期的日
- var days = new Date(year, month, 0);
- days = days.getDate(); //获取当前日期中的月的天数
- var year2 = year;
- var month2 = parseInt(month) + 2;
- if (month2 > 13) {
- year2 = parseInt(year2) + 1;
- if (parseInt(month)==11) {
- month2 = 1;
- }else if (parseInt(month)==12) {
- month2 = 2;
- };
- }
- var day2 = day;
- var days2 = new Date(year2, month2, 0);
- days2 = days2.getDate();
- if (day2 > days2) {
- day2 = days2;
- }
- if (month2 < 10) {
- month2 = '0' + month2;
- }
- var t2 = year2 + '/' + month2 + '/' + day2;
- return t2;
- }
- var myDate = new Date;
- var year = myDate.getFullYear(); //获取当前时间年份
- var yue = myDate.getMonth()+1;//获取当前时间月份
- if (yue<10) {
- yue= '0' + yue;
- };
- // 有效期时间 获取当前时间
- var time = year+'/'+yue+'/01';
- // 处理选中价格
- function price_deal(subject){
- switch(subject){
- case '8000-10000元':
- subject = '8千-1万';
- break;
- case '6000-8000元':
- subject = '6-8千';
- break;
- case '4000-6000元':
- subject = '4-6千';
- break;
- case '4000元以下':
- subject = '4千以下';
- break;
- default:
- subject = 1;
- break;
- }
- return subject;
- }
- // 处理跳转过来选中价格
- var textspan=$('.y_qylist_con').eq(1).find('p.feng_price span').text();
- $('.y_qylist_con p.feng_price span').html(price_deal2(textspan))
- function price_deal2(subject2){
- switch(subject2){
- case '8000-10000元':
- subject2 = '8千-1万';
- break;
- case '6000-8000元':
- subject2 = '6-8千';
- break;
- case '4000-6000元':
- subject2 = '4-6千';
- break;
- case '4000元以下':
- subject2 = '4千以下';
- break;
- }
- return subject2;
- }
- // 添加报名窗口
- function apply(){
- var _div ="";
- _div +='<div class="w_apply">';
- // _div +='<div class="w_fn">设置楼盘动态提醒,加推开盘早知道</div>'
- _div +='<div class="w_apply_img"><img src="/image/icon-wbg01.png" alt=""></div>';
- _div +='<form class="submit_area">';
- _div +='<input type="hidden" name="hid" value="0"> <!-- 0 为公共报名,其它为楼盘ID-->';
- _div +='<input type="hidden" name="source" value="47"> <!--报名来源 具体查看applyVerify.js文件中SourceModule 标识说明-->';
- _div +='<input type="hidden" name="equipment" value="1"> <!--来源设备 ( PC端 2,手机端 1 )-->';
- _div +='<div class="import">';
- _div +='<img src="/image/icon-wtel.png" alt="" />';
- _div +='<input class="w_apply_txt" type="text" name="mobile" placeholder="请输入您的手机号码">';
- _div +='</div>';
- _div +='<a class="apply_submit" href="javascript:;">报名看房</a>';
- _div +='</form>';
- _div +='</div>';
-
- return _div;
- }
- // 判断数字是否为整数
- function isInt(obj) {
- return obj%1 === 0
- }
- function starFn(oi){
- var _i = '';
- if(oi)
- // 判断输入的数字是否为整数
- if(isInt(oi)){
- // 判断输入的数字是否为5
- if(oi-5==0){
- for(var i = 0; i < oi;i++){
- _i +='<i></i>';
- }
- }else{
- // 添加有颜色的星
- for(var i = 0 ;i < oi;i++){
- _i += '<i></i>';
- }
- // 添加没有颜色的星
- for(var i = 0 ;i < 5-oi;i++){
- _i += '<i class="colourless"></i>';
- }
- }
- }else{
- // 添加有颜色的星
- for(var i = 1 ;i < oi;i++){
- _i += '<i></i>';
- }
- // 添加半颗星
- _i += '<i class="half"></i>';
- // 添加没有颜色的星
- for(var i = 1 ;i < 5-oi;i++){
- _i += '<i class="colourless"></i>';
- }
- }
- return _i;
- }
|