homelist.js 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588
  1. // 显示楼盘条数 ----------
  2. function Qalert(num = 0) {
  3. var M = {};
  4. if(M.dialog1){
  5. return M.dialog1.show();
  6. }
  7. M.dialog1 = jqueryAlert({
  8. 'content' : '共<span style="color:#FF6926;font-size: 1.0rem;"> '+num+' </span>个楼盘',
  9. 'closeTime' : 4000,
  10. });
  11. }
  12. Qalert($('.feng_count').attr('house_data'));
  13. // ---------------------------------
  14. // 列表加载js----------------------
  15. // 页数 -----
  16. var page = 1;
  17. // 每页展示5个
  18. var size = 10;
  19. var SearchParams = {};
  20. var urlParams = '';
  21. var wUrl =""
  22. // 用于繁体、简体切换
  23. var ttf = {}
  24. ttf.txt = $('.y_homelist_list').attr('data-rent');
  25. ttf.txt2 = $('.y_homelist_list').attr('data-proportion');
  26. var dht =0;
  27. $(function(){
  28. //获取GET请求参数
  29. function getParams(url) {
  30. var theRequest = new Object();
  31. if (!url)
  32. url = location.href;
  33. if (url.indexOf("?") !== -1)
  34. {
  35. var str = url.substr(url.indexOf("?") + 1) + "&";
  36. var strs = str.split("&");
  37. for (var i = 0; i < strs.length - 1; i++)
  38. {
  39. var key = strs[i].substring(0, strs[i].indexOf("="));
  40. var val = strs[i].substring(strs[i].indexOf("=") + 1);
  41. theRequest[key] = decodeURI(val) ; // decodeURI 解决中文字符乱码问题
  42. }
  43. }
  44. return theRequest;
  45. }
  46. var url = window.location.href;
  47. var params = getParams(url); //获取get请求的参数
  48. if(!$.isEmptyObject(params)){
  49. $.each(params,function(key,val){
  50. if(key == 'city') feng_cityTel = val;
  51. SearchParams[key] = val;
  52. })
  53. }
  54. // console.log(SearchParams)
  55. $('.y_qylist_hoe .y_qylist_con').on('click',function(){
  56. var Idoption = $(this).attr('data-id');
  57. $('.y_qylist_cnet_ind').hide();
  58. $('.y_qylist_con').attr('id','');
  59. if($(this).hasClass('on')){ //判断css on 是否存在
  60. $('.y_qylist_cnet_ind[data-id="'+Idoption+'"]').hide();
  61. $(this).removeClass('on');
  62. $('.m_homelistzz').hide();
  63. var _ster = $(window).scrollTop();
  64. if (_ster < 180) {_hide()}
  65. $('#LRdiv3').show();
  66. $('.qwpuic').show();
  67. }else{
  68. $(this).addClass('on').siblings().removeClass('on');
  69. $('.y_qylist_cnet_ind[data-id="'+Idoption+'"]').show();
  70. $(this).attr('id','m_color');
  71. $('.m_homelistzz').show();
  72. _show();
  73. $('#LRdiv3').hide();
  74. $('.qwpuic').hide();
  75. }
  76. })
  77. $('.m_homelistzz').on('click',function(){
  78. $('.m_homelistzz').hide();
  79. $('.y_qylist_hoe .y_qylist_con').removeClass('on');
  80. $('.y_qylist_cnet_ind').hide();
  81. $('.y_qylist_con').attr('id','');
  82. })
  83. $(".area").on('click','li.link_click',function(){
  84. $(".dcity").animate({right:"-35%"});
  85. })
  86. $('.m_f_search_click').on('click',function(){
  87. $('.feng_city_click').removeClass('on');
  88. })
  89. //获取子类区域
  90. $(".feng_city_click").on('click',function(){
  91. var _this = $(this);
  92. $('.m_f_search_click').removeClass('in');
  93. _this.addClass('on');
  94. _this.siblings().removeClass('on');
  95. $('.three_area').show();
  96. $.post('/house/soncity',{csrf_token_m:csrfToken,id:_this.attr('value')},function(data){
  97. $(".dcity").html('');
  98. if(data.code == 200){
  99. var str = '';
  100. str += '<li class="feng_search"><a class="f_search_click" name="city" value="'+_this.attr('value')+'" href="javascript:;">'+_this.find('a').html()+'</a></li>';
  101. $.each(data.data,function (k,v) {
  102. str += '<li class="feng_search"><a class="f_search_click" name="city" value="'+v.id+'" href="javascript:;">'+v.city_name+'</a></li>';
  103. })
  104. }
  105. $(".dcity").append(str);
  106. })
  107. $(".dcity").animate({right:"0"});
  108. })
  109. //获取子类区域
  110. $(".y_qylist_cnet_ind").on('click','a.f_search_click',function(){
  111. _hide();
  112. $('.m_homelistzz').hide();
  113. $('#LRdiv3').show();
  114. $('.qwpuic').show();
  115. $('.y_qylist_con').attr('id','');
  116. $('.y_qylist_con').removeClass('on');
  117. var _this = $(this);
  118. var name = _this.attr('name');
  119. $('.m_qylist_cnet_ind li a').removeClass('in');
  120. delete SearchParams.name; //当点击搜索的时候 删除掉搜索的参数
  121. _this.addClass('in').siblings().removeClass('in');
  122. $('.y_qylist_cnet_ind').css("display","none");
  123. SearchParams[_this.attr('name')] = _this.attr('value');
  124. if (_this.attr('name')=='city') {
  125. feng_cityTel=_this.attr('value');
  126. };
  127. //**************************
  128. // console.log(SearchParams)
  129. $.each(SearchParams,function(key,val){
  130. // if(key == 'py') return true; //跳出当前循环
  131. urlParams += key+'='+val+'&';
  132. })
  133. var cityUrl = '';
  134. urlParams = urlParams.substring(0,urlParams.length - 1);
  135. // console.log(urlParams)
  136. if(urlParams == '' && cityUrl != '')
  137. {
  138. cityUrl = cityUrl.substring(0,cityUrl.length - 1);
  139. }
  140. window.location.href = '/house/search?'+ cityUrl+urlParams;
  141. })
  142. // 输入价格区间 确定-----------------------------
  143. $('.js_pricConfirm').on('click',function(){
  144. var _Prictype=$(this).attr('name');
  145. var pmin = $('input.js_pricMin').val();
  146. var pmax = $('input.js_pricMax').val();
  147. if(pmax != '' && pmax != null){
  148. if(pmin == '' || pmin == null || pmin == NaN){
  149. pmin = 0;
  150. }
  151. }else{
  152. var M = {};
  153. if(M.dialog1){
  154. return M.dialog1.show();
  155. }
  156. M.dialog1 = jqueryAlert({
  157. 'content' : '请输入价格区间!',
  158. 'closeTime' : 2000,
  159. });
  160. }
  161. delete SearchParams.name; //当点击搜索的时候 删除掉搜索的参数
  162. SearchParams[_Prictype] = pmin+'-'+pmax;
  163. if (_Prictype=='city') {
  164. feng_cityTel=_this.attr('value');
  165. };
  166. //**************************
  167. // console.log(SearchParams)
  168. $.each(SearchParams,function(key,val){
  169. // if(key == 'py') return true; //跳出当前循环
  170. urlParams += key+'='+val+'&';
  171. })
  172. var cityUrl = '';
  173. urlParams = urlParams.substring(0,urlParams.length - 1);
  174. if(urlParams == '' && cityUrl != '')
  175. {
  176. cityUrl = cityUrl.substring(0,cityUrl.length - 1);
  177. }
  178. // console.log(cityUrl)
  179. // console.log(urlParams)
  180. window.location.href = '/house/search?'+ cityUrl+urlParams;
  181. })
  182. // 筛选-------------
  183. var url = window.location.href;
  184. var searchParamsv2 = ''; //最后拼接的参数
  185. var urlParamsv2 = '';
  186. var cityUrlv2 = '';
  187. var objUrlv2 = {}; //获取get参数
  188. var paramsv2 = getParams(url); //获取get请求的参数
  189. if(!$.isEmptyObject(paramsv2)){
  190. $.each(paramsv2,function(key,val){
  191. if(key == 'city') feng_cityTel = val;
  192. objUrlv2[key] = val;
  193. urlParamsv2 += key+'='+val+'&';
  194. })
  195. urlParamsv2 = urlParamsv2.substring(0,urlParamsv2.length - 1);
  196. searchParamsv2 = '&'+ urlParamsv2;
  197. }
  198. var atrNamev2 ='';
  199. var _valv2 ='';
  200. $('.js_screen_box').on('click','a.js_filtrateBut',function(){
  201. var _this = $(this);
  202. var ParamsArrv2 = ['l','y','sub']; //搜索字段
  203. atrNamev2 = _this.attr('name');
  204. _valv2 = _this.attr('value');
  205. urlParamsv2 = '';
  206. for (var k in ParamsArrv2){
  207. if(ParamsArrv2[k] == atrNamev2){
  208. objUrlv2[atrNamev2] = _valv2;
  209. delete objUrlv2.page;
  210. delete objUrlv2.name;
  211. }
  212. }
  213. $.each(objUrlv2,function(key,val){
  214. urlParamsv2 += key+'='+val+'&';
  215. })
  216. cityUrlv2 = '';
  217. urlParamsv2 = urlParamsv2.substring(0,urlParamsv2.length - 1);
  218. _this.addClass('on').siblings().removeClass('on');
  219. })
  220. // 清空
  221. $('.js_unlimited').on('click',function(){
  222. var ParamsArrv2 = ['l','y','sub']; //搜索字段
  223. urlParamsv2 = '';
  224. for (var k in ParamsArrv2){
  225. objUrlv2[ParamsArrv2[k]]=0;
  226. }
  227. $.each(objUrlv2,function(key,val){
  228. urlParamsv2 += key+'='+val+'&';
  229. })
  230. // console.log(urlParamsv2)
  231. cityUrlv2 = '';
  232. urlParamsv2 = urlParamsv2.substring(0,urlParamsv2.length - 1);
  233. $('.js_screen_box a.js_filtrateBut').removeClass('on');
  234. window.location.href = '/house/search?'+ cityUrlv2+urlParamsv2;
  235. })
  236. // 确认
  237. $('.js_confirm').on('click',function(){
  238. if(_valv2 != '' && atrNamev2 !=''){
  239. window.location.href = '/house/search?'+ cityUrlv2+urlParamsv2;
  240. }else{
  241. var M = {};
  242. if(M.dialog1){
  243. return M.dialog1.show();
  244. }
  245. M.dialog1 = jqueryAlert({
  246. 'content' : '请选择', //txt 提示内容
  247. 'closeTime' : 2000,
  248. })
  249. }
  250. })
  251. //获取url中的参数----选中效果--------
  252. function getUrlParam(name) {
  253. var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)"); //构造一个含有目标参数的正则表达式对象
  254. var r = window.location.search.substr(1).match(reg); //匹配目标参数
  255. if (r != null) return unescape(r[2]); return null; //返回参数值
  256. }
  257. var _label = getUrlParam('l');
  258. var _y = getUrlParam('y');
  259. var _sub = getUrlParam('sub');
  260. var _rank = getUrlParam('rank');
  261. var _pric = getUrlParam('p');
  262. // 选中效果 -------------------
  263. $('.js_screen_box[name="l"] .js_filtrateBut[value="'+_label+'"]').addClass('on');
  264. $('.js_screen_box[name="y"] .js_filtrateBut[value="'+_y+'"]').addClass('on');
  265. $('.js_screen_box[name="sub"] .js_filtrateBut[value="'+_sub+'"]').addClass('on');
  266. $('.js_rankHover .f_search_click[value="'+_rank+'"]').addClass('on');
  267. $('.js_privHover .f_search_click[value="'+_pric+'"]').addClass('on');
  268. // 筛选条件展示 ---------------
  269. var _hi=''
  270. // console.log(SearchParams)
  271. $.each(SearchParams,function(key,val){
  272. // console.log(key)
  273. if (val!=0 && val!='') {
  274. $('.y_condition').show();
  275. if (key=='p') {
  276. $('.js_conditionBox').append('<a class="js_conditionLi" value="0" name="'+key+'" href="javascript:;"><span>'+val+'万</span><i><img src="/image/v3_ico19.png" alt=""></i></a>')
  277. }else if(key=='city'){
  278. $('.js_conditionBox').append('<a class="js_conditionLi" value="0" name="'+key+'" href="javascript:;"><span>'+$('.js_cityBot').text()+'</span><i><img src="/image/v3_ico19.png" alt=""></i></a>')
  279. }else{
  280. _hi=$('.js_showList[name="'+key+'"][value="'+val+'"]').text();
  281. $('.js_conditionBox').append('<a class="js_conditionLi" value="0" name="'+key+'" href="javascript:;"><span>'+_hi+'</span><i><img src="/image/v3_ico19.png" alt=""></i></a>')
  282. }
  283. }
  284. })
  285. // 点击展示筛选条件------------------
  286. $('.js_conditionBox').on('click','a.js_conditionLi',function(){
  287. $(this).remove();
  288. var _CondId=$(this).attr('value');
  289. var _CondName=$(this).attr('name');
  290. $.each(SearchParams,function(key,val){
  291. SearchParams[_CondName]=_CondId;
  292. })
  293. $.each(SearchParams,function(key,val){
  294. urlParams += key+'='+val+'&';
  295. })
  296. cityUrlv2 = '';
  297. urlParams = urlParams.substring(0,urlParams.length - 1);
  298. console.log(urlParams)
  299. // window.location.href = '/house/search?'+ cityUrlv2+urlParams;
  300. })
  301. })
  302. $(function(){
  303. $.each(SearchParams,function(key,val){
  304. // if(key == 'py') return true; //跳出当前循环
  305. wUrl += key+'='+val+'&';
  306. })
  307. var cityUrl = '';
  308. wUrl = wUrl.substring(0,wUrl.length - 1);
  309. // console.log(wUrl)
  310. dropload_m();
  311. })
  312. function dropload_m(){
  313. // dropload
  314. $('.y_homelist_list').dropload({
  315. scrollArea : window,
  316. loadDownFn : function(me,da){
  317. page++;
  318. // 拼接HTML
  319. var result = '';
  320. $.ajax({
  321. type: 'GET',
  322. // url: '/house/searchdata',
  323. url: '/house/searchdata?page='+page+'&limit='+size+'&'+wUrl,
  324. // data:{page:page,size:size,all:SearchParams,csrf_token_m:csrfToken},
  325. dataType: 'json',
  326. success: function(data){
  327. // var arrLen = data.length;
  328. var _html="";
  329. if(data.code == 200){
  330. $.each(data.data.data,function (k,v) {
  331. _html+='<li class="c">';
  332. _html+='<div class="list_mian">';
  333. _html+='<a href="/house/'+v.id+'/">';
  334. _html+='<div class="y_img">';
  335. _html+='<p class="y_tu"><img src="'+v.thumb+'" alt=""></p>';
  336. _html+='<p class="y_vid c"><img src="/image/v2/search2.png" alt="">'+v.city_name+'</p>';
  337. if(v.video_url != null && v.video_url != ''){
  338. _html+='<p class="puic_video"><img src="/image/puic_vid.png" alt=""></p>';
  339. }
  340. _html+='</div>';
  341. _html+='<div class="y_text">';
  342. _html+='<div class="y_text_main">';
  343. _html+='<p class="y_title">'+v.name+'</p>';
  344. _html+='<p class="y_jiage"><span>'+house_price(v.price,v.price_nuit)+'</span><i class="u"></i><em></em></p>';
  345. _html+='<p style="font-size:0.6rem; color:#999;text-overflow:ellipsis;white-space:nowrap;overflow:hidden;">有效期:'+time_yxq+'</p>';
  346. if(v.push_reason != null && v.push_reason != ""){
  347. _html+='<p class="m_Recommend c">';
  348. _html+='<span class="c"><img src="/image/v2/search1.png" alt="">'+v.push_reason+'</span>';
  349. _html+='</p>';
  350. }
  351. _html+='</div>';
  352. _html+='</div>';
  353. _html+='</a>';
  354. _html+='</div>';
  355. // _html+='<div class="list_tel"><a href="tel:'+v.tel+'"><img src="/image/edition/icon_tel.png" alt=""></a></div>';
  356. // if(v.push_reason != null && v.push_reason != ""){
  357. // _html+='<div class="xl_click"><img src="/image/lplsitv2_2.png" alt=""></div>';
  358. // _html+='<div class="m_Recommend_list c">';
  359. // _html+='<span>推荐:</span>';
  360. // _html+='<p>'+v.push_reason+'</p>';
  361. // _html+='</div>';
  362. // }
  363. _html+='</li>';
  364. _html+='<div class="m_bx"></div>';
  365. // 插入热销楼盘
  366. if(k == 3 && dht <2){
  367. if(data.data.hotsale.length != 0){
  368. _html += aiah(data.data.hotsale);
  369. _html+='<div class="m_bx"></div>';
  370. dht += 2;
  371. }
  372. }
  373. // 插入资讯
  374. if(k == 7 && dht <3){
  375. if(data.data.news.length != 0){
  376. _html += nawie(data.data.news);
  377. _html+='<div class="m_bx"></div>';
  378. dht += 2;
  379. }
  380. }
  381. })
  382. // 如果没有数据
  383. }else{
  384. // 锁定
  385. me.lock();
  386. // 无数据
  387. me.noData();
  388. $('.dropload-down').hide();
  389. $('.dropload-down').eq(0).show();
  390. }
  391. // 为了测试,延迟1秒加载
  392. setTimeout(function(){
  393. // 插入数据到页面,放到最后面
  394. $('.y_homelist_list ul').append(_html);
  395. $('.xl_click').on('click',function(){
  396. var _mthis = $(this).parent();
  397. _mthis.find('.m_Recommend_list').toggle();
  398. console.log(1);
  399. })
  400. // 每次数据插入,必须重置
  401. me.resetload();
  402. $('.dropload-down').hide();
  403. $('.dropload-down').eq(0).show();
  404. // 特价活动
  405. new Swiper('.whot',{
  406. slidesPerView :'auto',
  407. slidesPerView : 3,
  408. slidesPerGroup :3,
  409. spaceBetween : 12,
  410. pagination: '.whotb', // 如果需要分页器
  411. });
  412. },1000);
  413. },
  414. error: function(xhr, type){
  415. // alert('Ajax error!');
  416. // 即使加载出错,也得重置
  417. me.resetload();
  418. }
  419. });
  420. }
  421. });
  422. }
  423. // $(function(){
  424. // var swiper = new Swiper('#swiper1', {
  425. // pagination: '.swiper-pagination',
  426. // effect: 'coverflow',
  427. // paginationType:'fraction',
  428. // grabCursor: true,
  429. // centeredSlides: true,
  430. // slidesPerView: 'auto',
  431. // loop: true,
  432. // coverflow: {
  433. // rotate: 0,
  434. // stretch: 100.5,
  435. // depth: 45,
  436. // modifier:3,
  437. // slideShadows : true
  438. // }
  439. // });
  440. // })
  441. /*
  442. * 获取 DOC 超出可视区域的高度
  443. */
  444. $(window).scroll(function (){
  445. var ster = $(this).scrollTop();
  446. var _hasClass = $('.y_qylist_hoe .y_qylist_con').hasClass('on');
  447. if (ster < 180 && _hasClass == false) {
  448. _hide()
  449. }else{
  450. _show();
  451. }
  452. });
  453. //列表插入热销楼盘
  454. function aiah(data){
  455. var _h = '<div class="whot">';
  456. _h +='<dl class="swiper-wrapper">';
  457. $.each(data,function(k,v){
  458. _h +='<dd class="swiper-slide">';
  459. _h +='<a href="/house/'+v.id+'/">';
  460. _h +='<div class="whot-img">';
  461. _h +='<div class="wtop"><img src="/image/edition/top_'+(k+1)+'.png" alt="" /></div>'
  462. _h +='<img src="'+v.thumb+'" alt="">';
  463. _h +='</div>';
  464. _h +='<h2>'+v.name+'</h2>';
  465. _h +='<p>'+house_price(v.price,v.price_nuit)+'</p>';
  466. _h +='</a>';
  467. _h +='</dd>';
  468. })
  469. _h +='</dl>';
  470. _h +='<div class="whotb"></div>';
  471. _h +='</div>';
  472. return _h;
  473. }
  474. //列表插入资讯
  475. function nawie(data){
  476. var n = '<div class="wsek_news" style="display: none;">';
  477. n += '<a href="/news/details/'+data[0].id+'/">';
  478. n += '<h2>'+data[0].subject+'</h2>';
  479. n += '<div class="wsek_news-img">';
  480. $.each(data[0].thumb,function(k,v){
  481. n += '<i><img src="'+v+'" alt=""></i>';
  482. })
  483. n += '</div>';
  484. n += '</a>';
  485. n += '</div>';
  486. return n;
  487. }
  488. function _show(){
  489. $('.m_top').css('background','#FFF');
  490. $('.header_menu img').attr('src','/image/indexv2_19.png');
  491. $('.header_back img').attr('src','/image/indexv2_17.png');
  492. $('.header_menu').attr('id','header_menu');
  493. $('.header_back').attr('id','header_back');
  494. $('.y_input input').attr('id','y_inputinput');
  495. $('.y_qylist_hoe').attr('id','y_qylist_hoe');
  496. $('.y_qylist_height').show();
  497. $('.y_qylist_cnet').attr('id','y_qylist_cnet');
  498. }
  499. function _hide(){
  500. $('.m_top').css('background','#fff');
  501. $('.header_menu img').attr('src','/image/indexv2_19.png');
  502. $('.header_back img').attr('src','/image/indexv2_17.png');
  503. $('.header_menu').attr('id','');
  504. $('.header_back').attr('id','');
  505. $('.y_input input').attr('id','');
  506. $('.y_qylist_hoe').attr('id','');
  507. $('.y_qylist_height').hide();
  508. $('.y_qylist_cnet').attr('id','');
  509. }