// +---------------------------------------------------------------------- // | desc: layout js // +---------------------------------------------------------------------- // | Author:张亮 // +---------------------------------------------------------------------- var times = 120; var timerInterval = null; /** *desc:初始化加载 *@param void; *@return void; */ $(function(){ func.kefuIsShow(); func.timeoutKefu(); func.scrollkefu(); func.clickkefu(); func.dot(); func.anchor(); }); /** *desc:构造函数 *@param void; *@return void; */ function Func(){}; Func.prototype.scrollkefu = function(){ $(window).scroll(function(){ var cookie = func.getCookie("close"); if(cookie != ""){ times = 120; } }) } Func.prototype.clickkefu = function(){ $('body').click(function(event) { var cookie = func.getCookie("close"); if(cookie != ""){ times = 120; } }); } Func.prototype.timeoutKefu = function(){ var cookie = func.getCookie("close"); if(cookie != ""){ timerInterval = setInterval(function(){ times-- if(times<0){ func.delCookie("close"); $('.close-kefu-btn').parent().show(); clearInterval(timerInterval); } },1000) } } Func.prototype.kefuIsShow = function(){ var cookie = func.getCookie("close"); if(cookie == ""){ $('.close-kefu-btn').parent().show(); }else{ $('.close-kefu-btn').parent().hide(); func.setCookie('close',1,1); } } Func.prototype.clostKefu = function(_this){ $(_this).parent().hide(); func.setCookie('close',1,1); func.timeoutKefu(); } Func.prototype.setCookie = function(name,value,days){ var Days = days; var exp = new Date(); exp.setTime(exp.getTime() + Days*24*60*60*1000); document.cookie = name + "="+ escape (value) + ";expires=" + exp.toGMTString(); } Func.prototype.getCookie = function(name){ var arr,reg=new RegExp("(^| )"+name+"=([^;]*)(;|$)"); if(arr=document.cookie.match(reg)){ return unescape(arr[2]); }else{ return ""; } } Func.prototype.delCookie=function(name){ var exp = new Date(); exp.setTime(exp.getTime() - 1); var cval=func.getCookie(name); if(cval!=null) document.cookie= name + "="+cval+";expires="+exp.toGMTString(); } /** *desc:员工获取查看大图轮播 *@param void; *@return void; */ Func.prototype.xiangce=function(){ $(document).ready(function(){ var index=0; var length; var i = $(this).attr("data_id"); $("body .active").append("
"); $(".huodongbigpic").fadeIn(100); length=$(".picimg li").length; $(".picimg li").eq(0).show(); $(".cbtn li").eq(0).addClass("hov"); var index_tot =$(".cbtn li").length; $(".num_total").html(index_tot); var index_cur =$(".cbtn li.hov").index() + 1; $(".num_current").html(index_cur); $(".cbtn").delegate("li","click",function(){ index = $(".cbtn li").index(this); showImg(index); }); $(".picSildeRight,.nextxx").click(function(){ var index =$(".cbtn li.hov").index(); console.log(index); slideNext(index); }) $(".picSildeLeft,.front").click(function(){ var index =$(".cbtn li.hov").index(); slideFront(index); }) $(".pic-btn-close").click(function(){ $(".darkbg").remove(); $(".huodongbigpic").fadeOut(100); index = 0; $(".cSlideUl ul").animate({ "left": "0" },200); }); var i=1; //关键函数:通过控制i ,来显示图片 function showImg(i){ $(".picimg li").eq(i).stop(true,true).fadeIn(800).siblings("li").hide(); $(".cbtn li").eq(i).addClass("hov").siblings().removeClass("hov"); var index_cur =$(".cbtn li.hov").index() + 1; $(".num_current").html(index_cur); } function slideNext(){ if(index >= 0 && index < length-1) { ++index; showImg(index); }else{ if(confirm("已经是最后一张,点击确定重新浏览!")){ showImg(0); index=0; aniPx=(length-9)*110+'px'; //所有图片数 - 可见图片数 * 每张的距离 = 最后一张滚动到第一张的距离 $(".cSlideUl ul").animate({ "left": "0" },200); i=1; } return false; } if(i<0 || i>length-5) {return false;} $(".cSlideUl ul").animate({ "left": "-=107px" },200) i++; } function slideFront(){ if(index==0){ alert("没有上一页了,请点击下一页"); return false; }; if(index >= 1 ) { --index; showImg(index); } if(i<2 || i>length+5) {return false;} $(".cSlideUl ul").animate({ "left": "+=107px" },200) i--; } }) } //商务通 Func.prototype.invite = function(){ if ($('#nb_icon_wrap').length > 0) { $('#nb_icon_wrap').click(); } } //tab 切换 Func.prototype.tabs = function(_this,parents,find){ $(_this).parent().find('a').removeClass('on'); $(_this).addClass('on'); var index = $(_this).index(); $(_this).parents(parents).find(find).hide(); $(_this).parents(parents).find(find).eq(index).show(); } // 锚点跳转 Func.prototype.anchor = function(){ $('a[href*=#]').click(function() { $(this).parent().find('a').removeClass('on'); $(this).addClass('on') if (location.pathname.replace(/^\//, '') == this.pathname.replace(/^\//, '') && location.hostname == this.hostname) { var $target = $(this.hash); $target = $target.length && $target || $('[name=' + this.hash.slice(1) + ']'); if ($target.length) { var targetOffset = $target.offset().top; $('html,body').animate({ scrollTop: targetOffset }, 500); return false; } } }); } // 数据提交 Func.prototype.msgSubmit = function(_this){ var name = $(_this).find('input[name=title]').val(); var mobile = $(_this).find('input[name=mobile]').val(); var cityname = $(_this).find('input[name=cityname]').val(); var tenure = $(_this).find('input[name=tenure]').val(); if(name == ""){ layer.msg('姓名不能为空'); return false; } var myreg= /^[1][3,4,5,7,8][0-9]{9}$/; if (!myreg.test(mobile)) { layer.msg('手机号不正确'); return false; } if(cityname == ""){ layer.msg('展厅位置不能为空'); return false; } if(tenure == ""){ layer.msg('展厅面积不能为空'); return false; } var urls = $(_this).attr('action'); func.post(urls,$(_this).serialize(),window.location.href); return false; } /** * 封装POST方法 */ Func.prototype.post = function(url,objc,gourl,msg){ msg = msg || "提交成功"; gourl = gourl || ""; var loading = layer.load(3, {time: 10*1000,shade: [0.2,'#000']}); $.ajax({ url: url, type: 'POST', timeout : 10000, dataType: 'json', data: objc, complete: function(xhr, textStatus) { if(textStatus=='timeout'){ layer.close(loading); layer.msg('请求超时,请刷新重试');     } }, success: function(data, textStatus, xhr) { setTimeout(function(){ layer.close(loading); if(data.code != 200){ layer.msg('请求错误,请刷新重试'); }else{ layer.alert(msg,{closeBtn:0},function(){ if (gourl == ''){ return; }else{ window.location.href = gourl } }); } }, 500) }, error: function(xhr, textStatus, errorThrown) { layer.close(loading); layer.msg('网络错误,请刷新重试'); } }); } /** *desc:多行超过隐藏 *@param void; *@return void; */ Func.prototype.dot = function () { if (typeof(jQuery.fn.dotdotdot) != "function") { return; }; $(".dot").dotdotdot({ wrap: 'letter', after: 'a' }); }; Func.prototype.top = function() { $('html,body').animate( { scrollTop: 0 }, 800 ) } Func.prototype.close = function() { $(".teamdets").hide(); } Func.prototype.open = function(eq) { $(".teamdets").show(); jQuery(".teamdets").slide({mainCell:".teamd1",mainCell:".teamd2bot ul",autoPage:true,effect:"left",autoPlay:true,vis:1,trigger:"click",defaultIndex:eq}); } /** *desc:构造函数实例化 */ var func = new Func();