signinJs.jsp 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="utf-8" %>
  2. <%@include file="/WEB-INF/ehr/commons/jsp/commonInclude.jsp" %>
  3. <script>
  4. var signin = {
  5. init:function () {
  6. //判断是否自动登录
  7. var tenantName = '${tenantName}';
  8. var hash = window.location.hash;
  9. if(hash.indexOf("#access_token")>=0)
  10. {
  11. //获取accrss_token
  12. var tokenString =hash.substring(1,hash.indexOf("&"));
  13. debugger
  14. var token = tokenString.substr(hash.indexOf("="));
  15. //自动登录
  16. $.ajax({
  17. url: "${contextRoot}/oauth2/autoLogin",
  18. type: 'POST',
  19. dataType: 'json',
  20. data:{
  21. "token":token
  22. },
  23. success: function (data) {
  24. if(data.successFlg){
  25. debugger
  26. window.localStorage.setItem("ehrUser", token);
  27. location.href = '${contextRoot}/'+tenantName + '/oauth2/index?loginName='+data.obj.user;
  28. }else{
  29. location.href = '${contextRoot}/oauth2/tokenValidFail';
  30. }
  31. },
  32. error: function (data) {
  33. location.href = '${contextRoot}/oauth2/tokenValidFail';
  34. }
  35. });
  36. return;
  37. }
  38. }
  39. }
  40. $(function() {
  41. signin.init();
  42. });
  43. </script>