123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627 |
- 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 = '';
- // 页数 进入页面php渲染了10条数据,分页从1开始,请求的时候 page++ 就是从第二页开始请求
- var page = 1;
- // 每页展示10个
- var size = 10;
- var Wxdata = new Object(); // 用于处理选中问题
- 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;
- }
- // 为了解决选中问题
- if (!$.isEmptyObject(params)) {
- $.each(params, function (k, v) {
- if (k != 'price' && k != 'py') {
- $('.y_qylist_cnet a[name="' + k + '"][value="' + v + '"]').addClass('ki');
- }
- })
- }
- function AlertMsg(msg) {
- var vir = '<div class="main">';
- vir += '<div class="slice">';
- vir += '<div data-loader="circle"></div>';
- vir += '<div>' + msg + '</div>';
- vir += '</div>';
- vir += '</div>';
- $('body').append(vir);
- }
- function AlertMsgDel(clearTime = 1000) {
- if ($('.main')) {
- setTimeout(function () {
- $('.main').remove(); //删除加载转圈
- }, clearTime);
- }
- }
- $(function () {
- $('.y_homelist_list').dropload({
- scrollArea: window,
- domDown: {
- domClass: 'dropload-down',
- domRefresh: '<div class="dropload-refresh">↑上拉加载更多</div>',
- domLoad: '<div class="dropload-load"><span class="loading"></span>加载中...</div>',
- domNoData: '<div class="dropload-noData">我也是有底线的...</div>'
- },
- loadDownFn: function (me, da) {
- page++;
- // 拼接HTML
- var result = '';
- $.ajax({
- type: 'GET',
- url: '/json/searchdata?page=' + page + '&limit=' + size + searchParams,
- dataType: 'json',
- // async:false, //去掉同步,要不然会出来卡的感觉
- beforeSend: function () {
- // AlertMsg('数据加载中...');
- },
- success: function (data) {
- var lpsun = data.count;
- // 2019-5-8 删除加载转圈效果
- // AlertMsgDel(500);
- if (data.code == 200) {
- var data = data.data;
- if (data != null) {
- $.each(data, function (key, val) {
- var randomX = 300;
- var randomY = 800;
- var randvalue = parseInt(Math.random() * (randomX - randomY + 1) + randomY);
- result += '<li>';
- result += '<div class="sell_conterBox">';
- result += '<a href="/house/' + val.id + '">';
- result += '<div class="sell_conterBox_l">';
- result += '<p class="img"><img src="' + val.thumb + '/same" alt=""></p>';
- result += '<p class="city">' + val.city_name + '</p>';
- result += '<div class="sdin">';
- if (val.vr_path != 0 && val.vr_path != '' && val.vr_path != null && val.vr_path != undefined) {
- result += '<div class="vvid_pic_ico vr-animation-forever"></div>';
- }
- if(val.video_url != 0 && val.video_url != '' && val.video_url != null && val.video_url != undefined){
- result += '<p class="vid_ico"><img src="/overseas/img/v2image/v2_ico5.png" alt=""></p>';
- }
- result += '</div>';
- if (val.panorama != 0 && val.panorama != '' && val.panorama != null && val.panorama != undefined) {
- result += '<p class="hangpai">航拍实景</p>';
- }
- result += '</div>';
- result += '<div class="sell_conterBox_r">';
- result += '<h2 class="title">' + val.name + '</h2>';
- if (val.sale_price != 0 && val.sale_price != null && val.sale_price != '') {
- result += '<p class="pric"><span>' + val.sale_price + '</span>' + val.price_unit + '</p>';
- } else {
- result += '<p class="pric"><span>待定</span></p>';
- }
- result += '<p class="time">有效期至:'+htmltime+'</p>';
- result += '<p class="style">';
- result += '<i>'+val.state+'</i>';
- if (val.characteristic) {
- $.each(val.characteristic, function (k, v) {
- if(k<2){
- result += '<span>' + v + '</span>';
- }
- })
- }
- result += '</p>';
- result += '</div>';
- result += '</a>';
- if(val.preferential){
- result += '<div class="lp_zk">';
- result += '<span>';
- result += '<img src="/overseas/img/v2image/v2_ico6.png" alt="">';
- result += '<b>优惠活动</b>';
- result += '<i>|</i>';
- var zhTxt= val.preferential;
- var maxwidth=21;
- if(zhTxt.length>maxwidth){
- result += '<em>'+zhTxt.substring(0,maxwidth)+'...</em>';
- }else{
- result += '<em>'+zhTxt+'</em>';
- }
- result += '</span>';
- result += '</div>';
- }
- result += '</div>';
- result += '<div class="lp_tell">';
- if (val.is_tel != null && val.is_tel != '') {
- result += '<a href="tel:' + val.is_tel + '"><img src="/overseas/img/pulic_ico3.png" alt="">免费电话</a>';
- } else {
- result += '<a href="tel:' + val.citytel + '"><img src="/overseas/img/pulic_ico3.png" alt="">免费电话</a>';
- }
-
- result += '</div>';
- result += '</li>';
- })
- $('.y_homelist_list ul').append(result);
- // 每次数据插入,必须重置
- // me.resetload();
- // 如果没有数据
- }
- } else {
- // 锁定
- me.lock();
- // 无数据
- me.noData();
- }
- me.resetload(); //重置
- },
- error: function (xhr, type) {
- // AlertMsgDel(500);
- // alert('Ajax error!');
- // 即使加载出错,也得重置
- me.resetload();
- }
- });
- },
- threshold: 80 //升高底部触发加载的距离;
- });
- });
- $.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();
- // _this.show();
- // $.post('/house/soncity',{pid:_this.attr('value')},function(data){
- $.post('/json/soncity', {pid: _this.attr('value')}, function (data) {
- $(".three_area").html('');
- if (data.code == 200) {
- var str = '';
- // str += '<a class="link_click" name="city" value="'+_this.attr('value')+'" href="javascript:;">全部</a>';
- 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);
- // 为了解决AJAX请求数据选中
- if (!$.isEmptyObject(params)) {
- $.each(params, function (k, v) {
- if (k != 'price' && k != 'py') {
- $('.y_qylist_cnet a[name="' + k + '"][value="' + v + '"]').addClass('ki');
- }
- })
- }
- })
- $(".three_area").animate({left: "110px"});
- })
- $('.y_qylist_cnet_ind[data-id="1"] a').eq(1).click();
- $(".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);
- if ($(this).hasClass('on')) { //判断css on 是否存在
- $(name2 + '[' + name3 + '' + '=' + Idoption + ']').hide();
- $(this).removeClass('on');
- } else {
- $(this).addClass('on').siblings().removeClass('on');
- $(name2 + '[' + name3 + '' + '=' + Idoption + ']').show();
- }
- })
- }
- waptab('.y_qylist_hoe .y_qylist_con', '.y_qylist_cnet_ind', 'data-id');
- var mySwiper1 = new Swiper(".swiper-container1", {
- loop: true,
- loopedSlides: 4,
- autoplay: 5500,
- autoplayDisableOnInteraction: false,
- // 如果需要分页器
- pagination: '.swiper-pagination',
- slidesPerView: "auto"
- });
- // 处理资讯详情页面的底部一个月的有效日期
- var myDate = new Date;
- var year = myDate.getFullYear(); //获取当前时间年份
- var yue = myDate.getMonth() + 1;//获取当前时间月份
- if (yue < 10) {
- yue = '0' + yue;
- } else if (yue == 13) {
- yue = '01';
- }
- ;
- // 返回下个月有多少天数
- function mGetDate(yue) {
- var date = new Date();
- var year = date.getFullYear();
- var d = new Date(year, parseInt(yue), 0);
- return d.getDate();
- }
- var htmltime = year + '.' + yue + '.' + mGetDate(yue);
- $('.js_time').html('有效期至:' + htmltime + ''); //有效期
- // 处理选中价格
- 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 p.feng_price span').text();
- $('.y_qylist_con p.feng_price span').text(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 Qalert(num = 0) {
- var M = {};
- if (M.dialog1) {
- return M.dialog1.show();
- }
- M.dialog1 = jqueryAlert({
- 'content': '已为您找到<span style="color:#FF6926;font-size: 1.0rem;"> ' + num + ' </span>套房源',
- 'closeTime': 4000,
- })
- }
- var house_total = $('.feng_house_total').html();
- if (house_total) {
- Qalert(house_total);
- }
- var SearchParams = {};
- SearchParams=urlParams;
- $(function () {
- //转换价格格式
- $('.wx_btn a').each(function () {
- var _this = $(this);
- var txt = _this.text();
- _this.html(price_deal2(txt));
- })
- // 筛选确定按钮
- $('.wx_confirm').on('click', function () {
- var _this = $(this);
- var oi = _this.attr('data-id');
- var pthis = $('.y_qylist_cnet_ind[data-id="' + oi + '"]');
- if (pthis.find('a.in').attr('name') == 'city') {
- objUrl['py'] = pthis.find('a.in').attr('pinyin');
- }
- var ParamsArr = ['city', 'type', 'brand', 'characteristic', 'price', 'py']; //搜索字段
- var atrName = pthis.find('a.in').attr('name');
- var _val = pthis.find('a.in').attr('value');
- var urlParams = '';
- for (var k in ParamsArr) {
- if (ParamsArr[k] == atrName) {
- objUrl[atrName] = _val;
- delete objUrl.page;
- delete objUrl.name;
- //数据存储
- }
- // if(atrName == 'price'){ //处理价格
- // Wxdata[atrName] = _val; //楼盘名称存储格式
- // var odata = JSON.stringify(Wxdata); //对象转换为字符串
- // window.localStorage.setItem("data",odata);
- // }
- }
- $.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);
- }
- // console.log('/house/search?'+ cityUrl+urlParams);
- window.location.href = '/house/search?' + cityUrl + urlParams;
- })
- // 筛选取消按钮
- $('.wx_cls').on('click', function () {
- $('.w_barrier').fadeOut();
- $('.wx_screen_box').animate({top: '-500px'});
- // p()
- })
- // 筛选框展示
- var condition = ['区域', '价格', '户型', '特色'];
- $('.y_qylist_con').on('click', function () {
- var oi = $(this).attr('data-id');
- $('.wx_screen_box').animate({top: '0'});
- $('.wx_screen_btn').find('i').html(condition[oi - 1]);
- $('.wx_screen_btn .wx_confirm').attr('data-id', oi);
- $('.w_barrier').fadeIn();
- $('.y_qylist_cnet .y_qylist_cnet_ind[data-id="' + oi + '"]').show();
- // s();
- // console.log(oi);
- $('.js_wx_screen_btn').show();
- if (oi == 2) {
- /*用于处理选中问题*/
- var txt = $(this).find('span').text();
- if (txt != condition[oi - 1]) {
- $('.wx_btn[data-id="2"] a').each(function () {
- var _this = $(this)
- if (txt == _this.text()) {
- _this.addClass('ki');
- }
- })
- }
- }else if (oi== 4) {
- $('.js_wx_screen_btn').hide();
- $('.yv3_revamp').height(360)
- }
- })
- // 点击遮层隐藏
- $('.w_barrier').on('click', function () {
- $('.wx_screen_box').animate({top: '-500px'});
- $('.w_barrier').fadeOut();
- // p()
- })
- // 点击选中
- $('.wx_sreen_con').on('click', 'a.link_click', function () {
- $(this).addClass('in').siblings().removeClass('in');
- $(this).siblings().removeClass('ki');
- })
- $('.link_click_a').on('click', function () {
- $(this).attr('id', 'on')
- $('.link-item').removeClass('on');
- $('.three_area').html('');
- })
- $(document).bind("click", function (e) {
- var target = $(e.target);
- if (target.closest(".link_click_a").length == 0) { //点击 .inputxz 之外的地方触发
- $('.link_click_a').attr('id', '');
- }
- })
- // 筛选-------------
- var url = window.location.href;
- var searchParamsv2 = ''; //最后拼接的参数
- var urlParamsv2 = '';
- var cityUrlv2 = '';
- var objUrlv2 = {}; //获取get参数
- var paramsv2 = getParams(url); //获取get请求的参数
- if(!$.isEmptyObject(paramsv2)){
- $.each(paramsv2,function(key,val){
- if(key == 'city') feng_cityTel = val;
- objUrlv2[key] = val;
- urlParamsv2 += key+'='+val+'&';
- })
- urlParamsv2 = urlParamsv2.substring(0,urlParamsv2.length - 1);
- searchParamsv2 = '&'+ urlParamsv2;
- }
- var atrNamev2 ='';
- var _valv2 ='';
- $('.js_screen_box').on('click','a.js_filtrateBut',function(){
- var _this = $(this);
- var ParamsArrv2 = ['l','brand']; //搜索字段
- atrNamev2 = _this.attr('name');
- _valv2 = _this.attr('value');
- urlParamsv2 = '';
- for (var k in ParamsArrv2){
- if(ParamsArrv2[k] == atrNamev2){
- objUrlv2[atrNamev2] = _valv2;
- delete objUrlv2.page;
- delete objUrlv2.name;
- }
- }
- $.each(objUrlv2,function(key,val){
- urlParamsv2 += key+'='+val+'&';
- })
- cityUrlv2 = '';
- urlParamsv2 = urlParamsv2.substring(0,urlParamsv2.length - 1);
- _this.addClass('on').siblings().removeClass('on');
- })
- // 清空
- $('.js_unlimited').on('click',function(){
- var ParamsArrv2 = ['l','brand']; //搜索字段
- urlParamsv2 = '';
- for (var k in ParamsArrv2){
- objUrlv2[ParamsArrv2[k]]=0;
- }
- $.each(objUrlv2,function(key,val){
- urlParamsv2 += key+'='+val+'&';
- })
- // console.log(urlParamsv2)
- cityUrlv2 = '';
- urlParamsv2 = urlParamsv2.substring(0,urlParamsv2.length - 1);
- $('.js_screen_box a.js_filtrateBut').removeClass('on');
- window.location.href = '/house/search?'+ cityUrlv2+urlParamsv2;
- })
- // 确认
- $('.js_confirm').on('click',function(){
- if(_valv2 != '' && atrNamev2 !=''){
- window.location.href = '/house/search?'+ cityUrlv2+urlParamsv2;
- // console.log( cityUrlv2+urlParamsv2)
- }else{
- var M = {};
- if(M.dialog1){
- return M.dialog1.show();
- }
- M.dialog1 = jqueryAlert({
- 'content' : '请选择', //txt 提示内容
- 'closeTime' : 2000,
- })
- }
- })
- //获取url中的参数----选中效果--------
- function getUrlParam(name) {
- var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)"); //构造一个含有目标参数的正则表达式对象
- var r = window.location.search.substr(1).match(reg); //匹配目标参数
- if (r != null) return unescape(r[2]); return null; //返回参数值
- }
- var _label = getUrlParam('l');
- var _brand = getUrlParam('brand');
- // 筛选条件展示 ---------------
- var _hi=''
- // console.log(objUrlv2)
- $.each(objUrlv2,function(key,val){
- // console.log(key)
- if (val!=0 && val!='') {
- if (key=='l') {
- _hi=$('.y_v3filtrateList a[name="'+key+'"][value="'+val+'"]').text();
- $('.js_conditionBox').append('<span class="js_conditionLi" value="0" name="'+key+'"><em>'+_hi+'</em><i><img src="/image/lptj03.png" alt=""></i></span>')
- }else if (key=='brand') {
- _hi=$('.y_v3filtrateList a[name="'+key+'"][value="'+val+'"]').text();
- $('.js_conditionBox').append('<span class="js_conditionLi" value="0" name="'+key+'"><em>'+_hi+'</em><i><img src="/image/lptj03.png" alt=""></i></span>')
- }
- }
- })
- // 点击展示筛选条件------------------
- $('.js_conditionBox').on('click','span.js_conditionLi',function(){
- var urlParamsv3=''
- $(this).remove();
- var _CondId=$(this).attr('value');
- var _CondName=$(this).attr('name');
- $.each(objUrlv2,function(key,val){
- objUrlv2[_CondName]=_CondId;
- })
- $.each(objUrlv2,function(key,val){
- urlParamsv3 += key+'='+val+'&';
- })
-
- cityUrlv2 = '';
- urlParamsv3 = urlParamsv3.substring(0,urlParamsv3.length - 1);
- window.location.href = '/house/search?'+ cityUrlv2+urlParamsv3;
- })
- })
|