index.js 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304
  1. // 顶部检索栏
  2. $(window).scroll(function (){
  3. var st = $(this).scrollTop();
  4. if(st >10){
  5. $('.w_top').addClass('w-top-bg');
  6. }else{
  7. $('.w_top').removeClass('w-top-bg');
  8. }
  9. });
  10. //轮播图片
  11. var mySwiper1= new Swiper(".swiper-container1",{
  12. loop : true,
  13. loopedSlides:4,
  14. autoplay:5500,
  15. autoplayDisableOnInteraction : false,
  16. // 如果需要分页器
  17. pagination: '.swiper-pagination',
  18. slidesPerView :"auto"
  19. });
  20. var regIon= new Swiper(".swiper-container2",{
  21. loop : false,
  22. loopedSlides:4,
  23. pagination: '.swiper-pagination',
  24. autoplayDisableOnInteraction : false,
  25. slidesPerView :"auto"
  26. });
  27. // 品牌馆
  28. var mySwiper1= new Swiper("#yw_swiper_5",{
  29. loop : false,
  30. // autoplay:5500,
  31. slidesPerGroup : 2,
  32. autoplayDisableOnInteraction : false,
  33. slidesPerView :"auto"
  34. });
  35. // 品房头条
  36. function autoScroll(obj){
  37. $(obj).find("ul").animate({
  38. marginTop : "-30px"
  39. },500,function(){
  40. $(this).css({marginTop : "0px"}).find("li:first").appendTo(this);
  41. })
  42. }
  43. $(function(){
  44. setInterval('autoScroll(".headle_right .content")',5000);
  45. })
  46. // 2018-10-11 轮播图
  47. var mySwiper1= new Swiper("#yw_swiper",{
  48. loop : true,
  49. loopedSlides:4,
  50. // autoplay:5500,
  51. autoplayDisableOnInteraction : false,
  52. // 如果需要分页器
  53. pagination: '.yw_swiper-pagination',
  54. slidesPerView :"auto"
  55. });
  56. $(window).scroll(function (){
  57. var st = $(this).scrollTop();
  58. if(st >196){
  59. $('.suspension').fadeIn().addClass('xungua');
  60. $('.header').fadeOut();
  61. }else{
  62. $('.suspension').fadeOut();
  63. $('.header').fadeIn();
  64. }
  65. });
  66. $('.suspension').on('click',function(){
  67. $('body,html').animate({ scrollTop: 0 }, 1000);
  68. return false;
  69. })
  70. var trend = $('.y_quyou_list ul.list_m li').eq(0).find('a').attr('CityData');
  71. index_trend ();
  72. $(function(){
  73. var Citya = $('.y_quyou_list ul.list_m li').eq(0).find('a').text();
  74. $('.y_quyou em a').text(Citya);
  75. $('.y_quyou_list ul.list_m li').eq(0).attr('class','on');
  76. $('.y_quyou em').on('click',function(){
  77. $('.y_quyou_list_bg').fadeIn();
  78. $('.y_quyou_list').slideDown("slow");
  79. })
  80. $('.y_quyou_list_bg').on('click',function(){
  81. $(this).fadeOut();
  82. $('.y_quyou_list').fadeOut();
  83. })
  84. $('.y_quyou_list').on('click',function(){
  85. $(this).fadeOut();
  86. $('.y_quyou_list_bg').fadeOut();
  87. });
  88. $('.y_quyou_list ul.list_m li a').on('click',function(){
  89. $(this).parent().addClass('on').siblings().removeClass('on');
  90. var oAtexe=$(this).text();
  91. $('.y_quyou em a').text(oAtexe);
  92. // console.log(oAtexe);
  93. trend = $(this).attr('CityData');
  94. index_trend ();
  95. })
  96. });
  97. function index_trend (){
  98. // var html = '';
  99. // var _html ='';
  100. // $.ajax({
  101. // url: "/index/cityprice",
  102. // data:{id:trend},
  103. // type: "POST",
  104. // dataType: "json",
  105. // success: function(data) {//请求成功完成后要执行的方法
  106. // if(data.code == 200){
  107. // html+= '<p class="y_jg"><span>'+data.data.price+'</span><em>元/m²</em></p>';
  108. // html+= '<p class="y_text">'+ data.data.city_name + data.data.price_at +'房价均价</p>';
  109. // if(data.data.trend == 1){
  110. // _html+= '<img src="/image/fall1.png" alt=""><span class="red">上升'+data.data.contrast+'</span>';
  111. // } else if(data.data.trend == 2){
  112. // _html+= '<img src="/image/fall.png" alt=""><span class="lr">下跌-'+data.data.contrast+'</span>'; //上升下跌
  113. // }
  114. // }
  115. // $('.y_houspic_text').html(html);
  116. // $('.fall').html(_html);
  117. // }
  118. // });
  119. }
  120. // function m_hotlp_hyh (rand = null){
  121. // var cityId = $('#feng_city_id').html();
  122. // var type = $('#stype').html();
  123. // var html = '';
  124. // $.ajax({
  125. // url: "/index/hothouses",
  126. // data:{rand:rand,csrf_token_m:csrfToken,city:cityId,type:type},
  127. // type: "POST",
  128. // dataType: "json",
  129. // success: function(data) {
  130. // // console.log(data);
  131. // if(data.code == 200){
  132. // $.each(data.data, function (i, data) {
  133. // var randomX = 300;
  134. // var randomY = 800;
  135. // var randvalue = parseInt(Math.random() * (randomX - randomY + 1) + randomY);
  136. // html+= '<li>';
  137. // html+= '<a href="/house/'+data.id+'/">';
  138. // html+= '<div class="sell_img"><img src="'+data.thumb+'/same" alt=""><i class="sell_img_i" style="display:none">视频</i></div>';
  139. // html+= '<div class="sell_conter_right">';
  140. // html+= '<p class="title">'+data.name+'</p>';
  141. // html+= '<p class="jg_ing">'+data.city_name+'</p>';
  142. // if(data.sale_price != 0 && data.sale_price != null && data.sale_price != ''){
  143. // html+= '<p class="jg_ing jg_ingdd" style="margin-top:6px"><span><em>'+data.sale_price+'</em>'+data.price_unit+'</span></p>';
  144. // }else{
  145. // html+= '<p class="jg_ing jg_ingdd" style="margin-top:6px"><span><em>待定</em></span></p>';
  146. // }
  147. // html+= '<p class="jg_ing">有效期:'+time_mina+'</p>';
  148. // html+= '<p class="jg_ing" style="display:none">80㎡(一居)、86㎡(二居)</p>';
  149. // html+= '</div>';
  150. // html+= '<div class="m_gzlx">';
  151. // html+= '<p class="attention">已有 <span>'+randvalue+'</span> 人关注</p>';
  152. // html+= '<div class="m_gzlx_style">';
  153. // for(k in data.characteristic){
  154. // html+= '<i>'+data.characteristic[k]+'</i>';
  155. // }
  156. // html+= '</div>';
  157. // html+= '</div>';
  158. // html+= '</a>';
  159. // html+= '<div class="cal_price"><a href="tel:'+data.tel+'"><img src="/image/search/w_t.png"></a></div>';
  160. // html+= '</li>';
  161. // });
  162. // $(".sell_conter ul").html(html);
  163. // }
  164. // }
  165. // });
  166. // }
  167. //
  168. //
  169. // m_hotlp_hyh();
  170. // console.log(hyh);
  171. $('.m_hotlp_hyh').on('click',function(){
  172. // hyh = $(this).attr('DataId');
  173. m_hotlp_hyh(1);
  174. })
  175. $('.y_hotnews_bk li').on('click',function(){
  176. var dataid=$(this).attr('data-id');
  177. })
  178. // 切换区域
  179. $('.y_city a').on('click',function(){
  180. $('#serachBox2').hide();
  181. $('.footer_copy').hide();
  182. $('.m_qhcs_box').show();
  183. });
  184. $('.m_head_qhcs .m_Return').on('click',function(){
  185. $('#serachBox2').show();
  186. $('.m_qhcs_box').hide();
  187. $('.footer_copy').show();
  188. });
  189. // $('.m_City_list li a').on('click',function(){
  190. // var Citytext = $(this).html();
  191. // $('.y_city a span').html(Citytext);
  192. // $('#serachBox2').show();
  193. // $('.m_qhcs_box').hide();
  194. // });
  195. // $('.m_City_ul_li a').on('click',function(){
  196. // var Citytext2 = $(this).html();
  197. // $('.y_city a span').html(Citytext2);
  198. // $('#serachBox2').show();
  199. // $('.m_qhcs_box').hide();
  200. // });
  201. // 有效期 时间加两个自然月
  202. function getNextMonth(date) {
  203. var arr = date.split('/');
  204. var year = arr[0]; //获取当前日期的年份
  205. var month = arr[1]; //获取当前日期的月份
  206. var day = arr[2]; //获取当前日期的日
  207. var days = new Date(year, month, 0);
  208. days = days.getDate(); //获取当前日期中的月的天数
  209. var year2 = year;
  210. var month2 = parseInt(month) + 2;
  211. if (month2 > 13) {
  212. year2 = parseInt(year2) + 1;
  213. if (parseInt(month)==11) {
  214. month2 = 1;
  215. }else if (parseInt(month)==12) {
  216. month2 = 2;
  217. };
  218. }
  219. var day2 = day;
  220. var days2 = new Date(year2, month2, 0);
  221. days2 = days2.getDate();
  222. if (day2 > days2) {
  223. day2 = days2;
  224. }
  225. if (month2 < 10) {
  226. month2 = '0' + month2;
  227. }
  228. var t2 = year2 + '/' + month2 + '/' + day2;
  229. return t2;
  230. }
  231. var myDate = new Date;
  232. var year = myDate.getFullYear(); //获取当前时间年份
  233. var yue = myDate.getMonth()+1;//获取当前时间月份
  234. if (yue<10) {
  235. yue= '0' + yue;
  236. };
  237. // 有效期时间 获取当前时间
  238. var time = year+'/'+yue+'/01';
  239. var time_mina= time+'-'+getNextMonth(time);
  240. var getNextMonth= getNextMonth(time);
  241. // $('.sell_conter_right .date').html('有效期 | '+ time_mina);
  242. //限制字符个数
  243. $(".y_style1_text .y_title").each(function(){
  244. var maxwidth=35;
  245. if($(this).text().length>maxwidth){ $(this).text($(this).text().substring(0,maxwidth)); $(this).html($(this).html()+'…');
  246. }
  247. });
  248. $('.m_region span').eq(1).click();
  249. $('.m_City_box[data-id="1"]').show();
  250. $('.m_region span').on('click',function(){
  251. var dataid = $(this).attr('data-id');
  252. $('.m_City_box').hide()
  253. $('.m_City_box[data-id="'+dataid+'"]').show();
  254. $(this).attr('class','on').siblings().attr('class','');
  255. })