loginJs.jsp 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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 loginPage = {
  5. init:function(){
  6. var me = this;
  7. $('#txtPassword').keydown(function(event){
  8. if(event.which == "13")
  9. me.login();
  10. });
  11. $("#btnLogin").click(function(){
  12. me.login();
  13. });
  14. },
  15. login:function(){
  16. var user = $("#txtUser").val();
  17. var password = $("#txtPassword").val();
  18. if(user.length == 0 || password.length ==0)
  19. {
  20. $.ligerDialog.error("用户名或密码不能为空!");
  21. return;
  22. }
  23. $.ajax({ //获取表的字段列表
  24. type: "POST",
  25. url : "${contextRoot}/system/loginAction",
  26. dataType : "json",
  27. data:{user:user,password:password},
  28. cache:false,
  29. success :function(data){
  30. if(data.successFlg) {
  31. location.href = "${contextRoot}/indexPage";
  32. }
  33. else{
  34. $.ligerDialog.error(data.message);
  35. }
  36. },
  37. error :function(data){
  38. $.ligerDialog.error("Status:"+data.status +"(" +data.statusText+")");
  39. }
  40. });
  41. }
  42. };
  43. $(function(){
  44. //session过期
  45. if(location.href.indexOf('loginPage')<0)
  46. {
  47. location.href = "${contextRoot}/loginPage";
  48. }
  49. //内嵌页面
  50. if(self.location!=top.location)
  51. {
  52. top.location.href = "${contextRoot}/loginPage";
  53. }
  54. loginPage.init();
  55. });
  56. </script>