$(function(){ $('.nav_box li').mouseover(function(){ $('.menu_list',this).css('display','block'); $('.nav_1',this).addclass('focus'); $('.menu_list',this).stop().animate({opacity:1},{queue:false,duration:500}); }); $('.nav_box li').mouseout(function(){ $('.nav_1',this).removeclass('focus'); $('.menu_list',this).fadeto(500,0,function(){$(this).css('display','none');}); }); }) function chk_search_frm(frm_obj){ if($.trim(frm_obj.keyword.value)==''){ alert('请输入要搜索的关键词。'); return false; } return true; } /***提示窗口*********************************** **********************************************/ function tips(tit,type,fn){ var type_arr = {warning:5,success:1,error:2,loading:16}; if(typeof(type)=='undefined'){ var _type = 0; }else{ var _type = type_arr[type]; } if(typeof(fn)=='undefined'){ var fn=function(){ //layer.closeall();//关闭弹出窗口 } } if(type=='loading'){ //弹出等待层 风格1 //layer.load(); //弹出等待层 风格2 layer.msg(tit, { skin:'layui-layer-molv', icon: _type, shade:0.1, time: 600000 },fn); }else{ var _anim = 6; var _time = 2000; if(_type==1){ _anim = 1; _time = 1000; } layer.msg(tit, { skin:'layui-layer-molv', icon: _type, anim: _anim, time: _time //2秒关闭(如果不配置,默认是3秒) },fn); } } /* 弹出窗口 type为弹出窗口类型 warning 0 警告 success 1 成功 error 2 失败 */ function alt(tit,type,fn){ var type_arr = {warning:5,success:1,error:2}; if(typeof(type)=='undefined'){ var _type = 0; }else{ var _type = type_arr[type]; } if(typeof(fn)=='undefined'){ var fn=function(){ layer.closeall();//关闭弹出窗口 } } layer.alert(tit,{icon:_type,anim:6,cancel:function(index, layero){fn()}},fn); } //确认窗口 function cfm(tit,fn1,fn2,type){ if(typeof(fn1)=='undefined'){ var fn1=function(){} } if(typeof(fn2)=='undefined'){ var fn2=function(){} } //确认框按钮名称 var cfm_arr = {'pay':['支付完成','重新支付'],'default':['确定','取消'],'pj':['去评价','不想评']}; if(typeof(type)=='undefined'){ var type = 'default' } layer.confirm(tit, { btn: [cfm_arr[type][0],cfm_arr[type][1]] //按钮 }, function(){ fn1(); }, function(){ fn2(); }); } //是否存在数组中 function in_array(val,array){ for(var i in array){ if(array[i]==val){ return true; } } return false; } //键值是否存在数组中 function in_key_array(val,array){ for(var i in array){ if(i==val){ return true; } } return false; } //手机号验证 function is_mobile(mobile){ rgexp=/^[1][0-9]{10}$/; return rgexp.test(mobile) } //发送手机短信 function post_yzm(mobile,type){ //如果发送短信等待时间大于0,则不允许发送 if(typeof(window.s)!='undefined' && window.s>0){ //tips('正在发送短信,请稍后!'); return false; } //设置验证码按钮不可用 set_yzm_but('','false'); //发送短信 if(!is_mobile(mobile)){ // tips('请输入手正确的手机号码!'); } data={mobile:mobile,type:type,kinajaxform:js_code} $.ajax({ beforesend:function(){ tips('正在发送验证码,请稍后...','loading'); }, type:'post', url:js_app+"/public/yzm_post", data:data, datatype:'json', success:function(response){ if(response.status==1){ tips(response.info,'success'); window.s = 60; window.int = setinterval('yzm_time()',1000); }else{ tips(response.info,'error'); set_yzm_but('','true'); } }, error:function(){ tips('网络故障,请重试。','error'); set_yzm_but('','true'); } }) } //验证码按钮状态修改 function set_yzm_but(mobile,act){ //如果发送短信等待时间大于0,则不允许发送 if(typeof(window.s)!='undefined' && window.s>0){ return false; } if(typeof(act)=='undefined'){act='';} if(is_mobile(mobile) || act=='true'){ $('#get_yzm').css('background-color','#0170c1'); $('#get_yzm').prop('disabled',false); $('#get_yzm').val('获取验证码'); }else{ $('#get_yzm').css('background-color','#ccc'); $('#get_yzm').prop('disabled',true); } } //发送短信按钮倒计时 function yzm_time(){ --window.s; if(window.s<0){ clearinterval(window.int); //设置验证码按钮可用 set_yzm_but('','true'); return ; } $('#get_yzm').val('已发送('+window.s+'秒)'); } /* 向下滑屏时,ajax获取分页数据 调用方法 url_data="&cid=1"; $(".center_box").scroll(function(){ load_scroll_data(this,'advice') }); _this : 允许列表上下滚动box */ function load_scroll_data(_this,type){ if(typeof(window.page)=='undefined'){window.page=1;}//设置默认值为0 if(typeof(window.is_over)=='undefined'){window.is_over=true;}//设置默认值为0 if(typeof(url_data)=='undefined'){url_data='';} //console.log("返回值 :scrollheight="+$(_this)[0].scrollheight+' *scrolltop='+$(_this).scrolltop()+' *height='+$(_this).height()+' *计算结果='+($(_this)[0].scrollheight-$(_this).scrolltop()-$(_this).height())); if(!window.is_over){ return '';} var _scrollheight = $(_this)[0].scrollheight; if(!_scrollheight){ _scrollheight = $(document.body).height(); } totalheight = _scrollheight-$(_this).scrolltop()-$(_this).height(); var tmp_arr = new array(); tmp_arr['comment'] = new array('.comment_list',js_app+'/comment/comment_ajax',300); //console.log(totalheight); if (totalheight<=tmp_arr[type][2]){ window.is_over = false; data = "page="+page+url_data; $.ajax({ beforesend:function(){$(tmp_arr[type][0]).parent().append('