loginjs.js 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. $(document).ready(function(){
  2. var Webdir="/system/";
  3. var msg_error="<img src=\""+Webdir+"images/msg_error.gif\" align=\"absmiddle\" /> ";
  4. var msg_load="<img src=\""+Webdir+"images/msg_load.gif\" align=\"absmiddle\" /> "
  5. function loadbmpcode(){document.getElementById("logincodebmp").src = Webdir+"bmpcode.php?t1=16&temp=" + (new Date().getTime().toString(36));}
  6. $("#loginuser").focus();
  7. $("#logincode").focus(function(){
  8. if($("#showlogincode").html()==""){
  9. $("#showlogincode").html("<img id=\"logincodebmp\" align=\"absmiddle\" style=\"cursor:pointer\" onClick=\"$('#logincode').val('');$('#logincode').focus();this.src+='?'+Math.random();\" />");
  10. loadbmpcode();
  11. }
  12. });
  13. $("#loginform").submit(function(){
  14. var loginuser=$("#loginuser").val();
  15. var loginpwd=$("#loginpwd").val();
  16. var logincode=$("#logincode").val();
  17. if (loginuser == "") {
  18. $("#formmsg").html(msg_error+"请输入用户帐号");
  19. $("#loginuser").focus();
  20. return false;
  21. }
  22. if (loginpwd == "") {
  23. $("#formmsg").html(msg_error+"请输入用户密码");
  24. $("#loginpwd").focus();
  25. return false;
  26. }
  27. if (logincode == "") {
  28. $("#formmsg").html(msg_error+"请输入正确的验证码");
  29. $("#logincode").focus();
  30. return false;
  31. }
  32. var url=Webdir+"login.php?act=login";
  33. var param="loginuser="+encodeURIComponent(loginuser)+"&loginpwd="+escape(loginpwd)+"&logincode="+escape(logincode);
  34. jqajax(url,param);
  35. return false;
  36. });
  37. function jqajax(url,param){
  38. $.ajax({
  39. type: "POST",url: url,data: param,timeout:20000,
  40. beforeSend: function(){$("#formmsg").html(msg_load+"正在验证登陆信息...");},
  41. error:function(){$("#formmsg").html(msg_error+"对不起,服务器繁忙,请稍后再试.");},
  42. success:function(ajaxmsg){
  43. switch(ajaxmsg){
  44. case "1":
  45. $("#formmsg").html(msg_error+"请输入用户帐号");
  46. $("#loginuser").focus();
  47. break;
  48. case "2":
  49. $("#formmsg").html(msg_error+"请输入用户密码");
  50. $("#loginpwd").focus();
  51. break;
  52. case "3":
  53. $("#formmsg").html(msg_error+"请输入正确的验证码");
  54. $("#logincode").val("");
  55. $("#logincode").focus();
  56. break;
  57. case "4":
  58. $("#formmsg").html(msg_error+"用户帐号不存在");
  59. loadbmpcode();
  60. $("#loginuser").val("");
  61. $("#loginuser").focus();
  62. break;
  63. case "5":
  64. $("#formmsg").html(msg_error+"用户密码错误");
  65. loadbmpcode();
  66. $("#loginpwd").val("");
  67. $("#loginpwd").focus();
  68. break;
  69. case "6":
  70. $("#formmsg").html(msg_error+"该帐号已被停用!");
  71. loadbmpcode();
  72. $("#logincode").focus();
  73. break;
  74. case "7":
  75. location.replace("index.php");
  76. break;
  77. default:
  78. $("#formmsg").html(ajaxmsg);
  79. }
  80. }
  81. });
  82. }
  83. });