checkSign.js 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. var check_id = null;
  2. $(function() {
  3. if(loginName!=null&&loginName!="null"){
  4. $('#_superUserName').html(loginName);
  5. }else{
  6. $('#_superUserName').html(getCookie("superUserName"));
  7. loginUserId = getCookie("superUserId");
  8. loginName = decodeURIComponent(getCookie("superUserName"));
  9. }
  10. checkCookie();
  11. if(check_id!=null){
  12. clearInterval(check_id);
  13. }
  14. check_id = setInterval(function(){
  15. console.log("checkCookie");
  16. checkCookie();
  17. }, 10000);
  18. });
  19. function checkCookie(){
  20. //如果登录id不为null,直接进入
  21. if(loginUserId!=null&&loginUserId!="null"){
  22. return;
  23. }
  24. var id = getCookie("superUserId");
  25. if(id!=null&&id!="-1"){
  26. return;
  27. }
  28. window.location.href = '../admin/sign-in';
  29. }
  30. function loginOut(){
  31. $.post(
  32. "../super/logout",
  33. function (returndata, status) {
  34. if ("success" == status) {
  35. if(returndata.success){
  36. window.location.href = '../admin/sign-in';
  37. }else{
  38. alert(returndata.error);
  39. }
  40. }
  41. });
  42. }