knowledge.js 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236
  1. $(function(){
  2. // 热推看房团
  3. new Swiper('.hot-box',{
  4. slidesPerView :'auto',
  5. spaceBetween : 20,
  6. prevButton:'.hotprev',
  7. nextButton:'.hotnext',
  8. })
  9. var oid = false;
  10. var aClass = $('.widget-box');
  11. // 关闭按钮
  12. $('.widget-cls').on('click',function(){
  13. aClass.removeClass('adi');
  14. oid = aClass.hasClass('adi');
  15. aClass.animate({width:'8px',height:'8px',right:'100px',bottom:'325px'},function(){
  16. var _this = $(this);
  17. _this.animate({bottom:'280px'},function(){
  18. _this.hide();
  19. })
  20. })
  21. })
  22. // 点击按钮弹出报名窗口
  23. $('.alive').on('click',function(){
  24. if(!oid){
  25. aClass.show();
  26. aClass.animate({width:'8px',height:'8px',right:'100px',bottom:'325px'},function(){
  27. var _this = $(this);
  28. _this.animate({width:'240px',height:'312px',right:'20px',bottom:'350px'})
  29. })
  30. }
  31. aClass.addClass('adi');
  32. oid = aClass.hasClass('adi')
  33. })
  34. /*-------------------- 获取地址栏地址并拆分 --------------------------------*/
  35. function getParams(url) {
  36. var theRequest = new Object();
  37. if (!url)
  38. url = location.href;
  39. if (url.indexOf("?") !== -1)
  40. {
  41. var str = url.substr(url.indexOf("?") + 1) + "&";
  42. var strs = str.split("&");
  43. for (var i = 0; i < strs.length - 1; i++)
  44. {
  45. var key = strs[i].substring(0, strs[i].indexOf("="));
  46. var val = strs[i].substring(strs[i].indexOf("=") + 1);
  47. theRequest[key] = val;
  48. }
  49. }
  50. return theRequest;
  51. }
  52. var objUrl = {}; //获取get参数
  53. var url = window.location.href;
  54. var params = getParams(url);
  55. if(!$.isEmptyObject(params)){
  56. $.each(params,function(key,val){
  57. objUrl[key] = val;
  58. })
  59. }
  60. // console.log(objUrl['type']);
  61. if(objUrl['cid'] != undefined && objUrl['cid'] != 'undefined')
  62. {
  63. // console.log(222222);
  64. $('.genera-center-nav ul li').removeClass('on');
  65. $('li[data-city='+objUrl['cid']+']').addClass('on');
  66. }
  67. if(objUrl['type'] != undefined && objUrl['type'] != 'undefined')
  68. {
  69. // $('.top-nav-li ul li')
  70. $('.nav-center-nav ul li').removeClass('on');
  71. $('li[data-oid='+objUrl['type']+']').addClass('on');
  72. }
  73. if(objUrl['type'] == undefined){
  74. $('.top-nav-li ul li:eq(0)').addClass('on');
  75. }
  76. // 类目导航
  77. $('.top-nav-li ul li').on('click',function(){
  78. var that = $(this);
  79. var oid = that.attr('data-oid');
  80. that.addClass('on').siblings('li').removeClass('on');
  81. objUrl['type'] = oid;
  82. skipUrl(objUrl);
  83. })
  84. // 国家导航
  85. $('.genera-center-nav ul li').on('click',function(){
  86. var that = $(this);
  87. var cid = that.attr('data-city');
  88. that.addClass('on').siblings('li').removeClass('on');
  89. objUrl['cid'] = cid;
  90. skipUrl(objUrl);
  91. })
  92. function skipUrl(data){
  93. // console.log(data)
  94. var urlParams ="";
  95. $.each(data,function(key,val){
  96. if(data.cid != 0){
  97. if(key == 'page'){
  98. // urlParams += key+'='+0+'&';
  99. }else {
  100. urlParams += key+'='+val+'&';
  101. }
  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. // console.log(cityUrl)
  110. // console.log(urlParams)
  111. if(data.cid != 0){
  112. window.location.href = '/news/knowledge?'+urlParams;
  113. }else{
  114. window.location.href = '/news/knowledge';
  115. }
  116. }
  117. /*
  118. * 调用的方法
  119. * */
  120. PublicAction.AjaxSend(
  121. {
  122. CORID:'apply_submit', /*操作ID*/
  123. }
  124. );
  125. // 问答字数限制
  126. if ($('.faqs-box ul li').length > 2 ) {
  127. $('.faqs-box ul li').each(function(){
  128. var _that=$(this);
  129. var _txtm=_that.find('.fa span em').text();
  130. var _txtlength= _that.find('.fa span em').text().length;
  131. var num=105;
  132. var _m=1;
  133. if (_txtlength > num) {
  134. _that.find('.fa span a.zhanli').show();
  135. _that.find('.fa span em').html(_txtm.substring(0,num)+"...");
  136. }else{
  137. _that.find('.fa span em').html(_txtm);
  138. }
  139. _that.find('.fa span').on('click','a.zhanli',function(){
  140. if (_m==1) {
  141. $(this).find('i').text('收起');
  142. $(this).siblings('em').html(_txtm);
  143. $(this).parent().parent().css({'height':'auto'})
  144. console.log($(this).parent().parent())
  145. _m=2;
  146. }else if(_m==2){
  147. $(this).find('i').text('展开');
  148. $(this).siblings('em').html(_txtm.substring(0,num)+"...");
  149. $(this).parent().parent().css({'height':'44px'})
  150. console.log($(this).parent().parent())
  151. _m=1
  152. }
  153. })
  154. })
  155. }
  156. jQuery.fn.limit=function(){
  157. var self = $("[limit]");
  158. self.each(function(){
  159. var objString = $(this).text();
  160. var objLength = $(this).text().length;
  161. var num = $(this).attr("limit");
  162. if(objLength > num){
  163. $(this).attr("title",objString);
  164. objString = $(this).text(objString.substring(0,num)+"...");
  165. }
  166. $(this).attr("title"," ")
  167. })
  168. }
  169. // $(function(){
  170. // $(".list li a").attr("limit",18)
  171. // $("#last_show p").attr("limit",35)
  172. // $(".newsList li a").attr("limit",24)
  173. // $("[limit]").limit();
  174. // })
  175. $('.itmeBox').html('(有效期:'+whtmltimes+')');
  176. })