knowledge.js 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  1. // 处理顶部导航显示、隐藏
  2. var dir = $(document).scrollTop();
  3. navign(dir);
  4. $(window).scroll(function (){
  5. dir= $(this).scrollTop();
  6. navign(dir);
  7. });
  8. function navign(st){
  9. if(st >70){
  10. $('.m_topw').hide();
  11. $('.m_top').show();
  12. $('.m_title').show();
  13. }else{
  14. $('.m_topw').show();
  15. $('.m_top').hide();
  16. $('.m_title').hide();
  17. }
  18. }
  19. /*--------------end----------------------*/
  20. $(function(){
  21. // 热推看房团
  22. var m_Huxing_lunbo = new Swiper('.asw', {
  23. loop : true,
  24. spaceBetween: 10,
  25. centeredSlides: true,
  26. slidesPerView: 'auto',
  27. touchRatio: 0.5,
  28. slideToClickedSlide: true
  29. });
  30. var m_Huxing_lunbo = new Swiper('.hothouses', {
  31. loop : true,
  32. spaceBetween: 10,
  33. centeredSlides: true,
  34. slidesPerView: 'auto',
  35. touchRatio: 0.5,
  36. slideToClickedSlide: true
  37. });
  38. // 地区分类
  39. new Swiper('.nation-re', {
  40. slidesPerView :'auto',
  41. slidesOffsetAfter:10,
  42. nextButton:'.bntr',
  43. })
  44. /*-------------------- 获取地址栏地址并拆分 --------------------------------*/
  45. function getParams(url) {
  46. var theRequest = new Object();
  47. if (!url)
  48. url = location.href;
  49. if (url.indexOf("?") !== -1)
  50. {
  51. var str = url.substr(url.indexOf("?") + 1) + "&";
  52. var strs = str.split("&");
  53. for (var i = 0; i < strs.length - 1; i++)
  54. {
  55. var key = strs[i].substring(0, strs[i].indexOf("="));
  56. var val = strs[i].substring(strs[i].indexOf("=") + 1);
  57. theRequest[key] = val;
  58. }
  59. }
  60. return theRequest;
  61. }
  62. var objUrl = {}; //获取get参数
  63. var url = window.location.href;
  64. var params = getParams(url);
  65. if(!$.isEmptyObject(params)){
  66. $.each(params,function(key,val){
  67. objUrl[key] = val;
  68. })
  69. }
  70. // if(objUrl['cid'] == undefined || objUrl['cid'] == 'undefined'){
  71. // $('.nation-conter-nav ul li').css('pointer-events','none');//没有选择city禁止点击
  72. // }
  73. //
  74. // if(objUrl['cid']== 0){
  75. // $('.nation-conter-nav ul li').css('pointer-events','none');//没有选择city禁止点击
  76. // }
  77. // 类目导航
  78. $('.nation-conter-nav ul li').on('click',function(){
  79. var that = $(this);
  80. var oid = that.attr('data-oid');
  81. that.addClass('on').siblings('li').removeClass('on');
  82. objUrl['type'] = oid;
  83. skipUrl(objUrl);
  84. })
  85. // 国家导航
  86. $('.nation-re ul li').on('click',function(){
  87. var that = $(this);
  88. var cid = that.attr('data-city');
  89. that.addClass('on').siblings('li').removeClass('on');
  90. objUrl['cid'] = cid;
  91. skipUrl(objUrl);
  92. })
  93. function skipUrl(data){
  94. var urlParams ="";
  95. if(data.cid == 0){
  96. window.location.href = '/news/knowledge';
  97. return false;
  98. }
  99. $.each(data,function(key,val){
  100. if(key != 'page'){
  101. urlParams += key+'='+val+'&';
  102. }
  103. })
  104. var cityUrl = '';
  105. urlParams = urlParams.substring(0,urlParams.length - 1);
  106. if(urlParams == '' && cityUrl != ''){
  107. cityUrl = cityUrl.substring(0,cityUrl.length - 1);
  108. }
  109. window.location.href = '/news/knowledge?'+urlParams;
  110. }
  111. if ($('.js_daqsClick ul li').length > 1) {
  112. $('.js_daqsClick ul li').addClass('hide')
  113. $('.js_daqsClick ul').on('click','li',function(){
  114. var _this=$(this)
  115. var _Qhtml= _this.find('.qs span').text();
  116. var _Ahtml= _this.find('.fa span').text();
  117. var _City= $('.js_nation_re ul li.on').text();
  118. var _Navhtml= $('.js_nationNav ul li.on').text();
  119. $('.js_faqsBox_title span').html(_City);
  120. $('.js_faqsBox_title em').html(_Navhtml);
  121. $('.js_faqsBox_html .y_boxq span').html(_Qhtml);
  122. $('.js_faqsBox_html .y_boxa span').html(_Ahtml);
  123. $('.js_faqsBox').show(30);
  124. $('.y_faqsBox_bg').show();
  125. })
  126. $('.y_faqsBox_bg,.y_faqsBox_gb').on('click',function(){
  127. $('.y_faqsBox_bg,.js_faqsBox').hide();
  128. })
  129. }
  130. $('.time_box').html('(有效期:'+whtmltimes+')');
  131. })