var check_id = null; $(function() { if(loginName!=null&&loginName!="null"){ $('#_superUserName').html(loginName); }else{ $('#_superUserName').html(getCookie("superUserName")); loginUserId = getCookie("superUserId"); loginName = decodeURIComponent(getCookie("superUserName")); } checkCookie(); if(check_id!=null){ clearInterval(check_id); } check_id = setInterval(function(){ console.log("checkCookie"); checkCookie(); }, 10000); }); function checkCookie(){ //如果登录id不为null,直接进入 if(loginUserId!=null&&loginUserId!="null"){ return; } var id = getCookie("superUserId"); if(id!=null&&id!="-1"){ return; } window.location.href = '../admin/sign-in'; } function loginOut(){ $.post( "../super/logout", function (returndata, status) { if ("success" == status) { if(returndata.success){ window.location.href = '../admin/sign-in'; }else{ alert(returndata.error); } } }); }