$(function(){ // 热推看房团 new Swiper('.hot-box',{ slidesPerView :'auto', spaceBetween : 20, prevButton:'.hotprev', nextButton:'.hotnext', }) var oid = false; var aClass = $('.widget-box'); // 关闭按钮 $('.widget-cls').on('click',function(){ aClass.removeClass('adi'); oid = aClass.hasClass('adi'); aClass.animate({width:'8px',height:'8px',right:'100px',bottom:'325px'},function(){ var _this = $(this); _this.animate({bottom:'280px'},function(){ _this.hide(); }) }) }) // 点击按钮弹出报名窗口 $('.alive').on('click',function(){ if(!oid){ aClass.show(); aClass.animate({width:'8px',height:'8px',right:'100px',bottom:'325px'},function(){ var _this = $(this); _this.animate({width:'240px',height:'312px',right:'20px',bottom:'350px'}) }) } aClass.addClass('adi'); oid = aClass.hasClass('adi') }) /*-------------------- 获取地址栏地址并拆分 --------------------------------*/ 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 params = getParams(url); if(!$.isEmptyObject(params)){ $.each(params,function(key,val){ objUrl[key] = val; }) } // console.log(objUrl['type']); if(objUrl['cid'] != undefined && objUrl['cid'] != 'undefined') { // console.log(222222); $('.genera-center-nav ul li').removeClass('on'); $('li[data-city='+objUrl['cid']+']').addClass('on'); } if(objUrl['type'] != undefined && objUrl['type'] != 'undefined') { // $('.top-nav-li ul li') $('.nav-center-nav ul li').removeClass('on'); $('li[data-oid='+objUrl['type']+']').addClass('on'); } if(objUrl['type'] == undefined){ $('.top-nav-li ul li:eq(0)').addClass('on'); } // 类目导航 $('.top-nav-li ul li').on('click',function(){ var that = $(this); var oid = that.attr('data-oid'); that.addClass('on').siblings('li').removeClass('on'); objUrl['type'] = oid; skipUrl(objUrl); }) // 国家导航 $('.genera-center-nav ul li').on('click',function(){ var that = $(this); var cid = that.attr('data-city'); that.addClass('on').siblings('li').removeClass('on'); objUrl['cid'] = cid; skipUrl(objUrl); }) function skipUrl(data){ // console.log(data) var urlParams =""; $.each(data,function(key,val){ if(data.cid != 0){ if(key == 'page'){ // urlParams += key+'='+0+'&'; }else { urlParams += key+'='+val+'&'; } } }) var cityUrl = ''; urlParams = urlParams.substring(0,urlParams.length - 1); if(urlParams == '' && cityUrl != ''){ cityUrl = cityUrl.substring(0,cityUrl.length - 1); } // console.log(cityUrl) // console.log(urlParams) if(data.cid != 0){ window.location.href = '/news/knowledge?'+urlParams; }else{ window.location.href = '/news/knowledge'; } } /* * 调用的方法 * */ PublicAction.AjaxSend( { CORID:'apply_submit', /*操作ID*/ } ); // 问答字数限制 if ($('.faqs-box ul li').length > 2 ) { $('.faqs-box ul li').each(function(){ var _that=$(this); var _txtm=_that.find('.fa span em').text(); var _txtlength= _that.find('.fa span em').text().length; var num=105; var _m=1; if (_txtlength > num) { _that.find('.fa span a.zhanli').show(); _that.find('.fa span em').html(_txtm.substring(0,num)+"..."); }else{ _that.find('.fa span em').html(_txtm); } _that.find('.fa span').on('click','a.zhanli',function(){ if (_m==1) { $(this).find('i').text('收起'); $(this).siblings('em').html(_txtm); $(this).parent().parent().css({'height':'auto'}) console.log($(this).parent().parent()) _m=2; }else if(_m==2){ $(this).find('i').text('展开'); $(this).siblings('em').html(_txtm.substring(0,num)+"..."); $(this).parent().parent().css({'height':'44px'}) console.log($(this).parent().parent()) _m=1 } }) }) } jQuery.fn.limit=function(){ var self = $("[limit]"); self.each(function(){ var objString = $(this).text(); var objLength = $(this).text().length; var num = $(this).attr("limit"); if(objLength > num){ $(this).attr("title",objString); objString = $(this).text(objString.substring(0,num)+"..."); } $(this).attr("title"," ") }) } // $(function(){ // $(".list li a").attr("limit",18) // $("#last_show p").attr("limit",35) // $(".newsList li a").attr("limit",24) // $("[limit]").limit(); // }) $('.itmeBox').html('(有效期:'+whtmltimes+')'); })