space.login.js 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. var uncompileStr = function (str) {
  2. str = unescape(str);
  3. var c = String.fromCharCode(str.charCodeAt(0) - str.length);
  4. for (var i = 1; i < str.length; i++) {
  5. c += String.fromCharCode(str.charCodeAt(i) - c.charCodeAt(i - 1));
  6. }
  7. return c;
  8. }
  9. var x;
  10. $(document).ready(function () {
  11. var d = layui.data("586537");
  12. x = d.x;
  13. if (x != undefined) {
  14. $("#b").hide();
  15. $("#content .login-account").addClass("has-img");
  16. $("#b").attr("src", uncompileStr(d.z));
  17. $("#c").html("欢迎您," + uncompileStr(d.y));
  18. $("#b").show();
  19. }
  20. })
  21. $(".user-img-cover").click(function () {
  22. layui.data('586537', null);
  23. location.reload();
  24. })
  25. var len = $(".login-write input").length;
  26. $(".login-write input").focus(function () {
  27. $(this).siblings(".iconfont").removeClass("iconfont-error");
  28. $(this).siblings(".iconfont").addClass("iconfont-focus");
  29. $(".login-warn").html("");
  30. })
  31. $(".login-write input").blur(function () {
  32. $(this).siblings(".iconfont").removeClass("iconfont-focus");
  33. })
  34. $(".submit").click(function () {
  35. $(this).attr("disabled", "disabled");
  36. if (x) {
  37. $("#uname").val(uncompileStr(x));
  38. }
  39. var loginText = [];
  40. for (var i = 0; i < len; i++) {
  41. if ($(".login-write input").eq(i).val() == "" || $(".login-write input").eq(i).val() == undefined) {
  42. $(".login-write input").eq(i).siblings(".iconfont").addClass("iconfont-error");
  43. loginText.push($(".login-write input").eq(i).attr("placeholder"));
  44. }
  45. }
  46. if ($("#uname").val().trim().length == 0) {
  47. $("#uname").focus();
  48. $(".login-warn").html("请输入账号");
  49. $(".submit").removeAttr("disabled");
  50. } else if ($("#upwd").val().trim().length == 0) {
  51. $("#upwd").focus();
  52. $(".login-warn").html("请输入密码");
  53. $(".submit").removeAttr("disabled");
  54. } else {
  55. var svc = layui.data('SVC');
  56. // if (svc.SliderVerificationCode && svc.SliderVerificationCode == "success") {
  57. // $(this).val("正 在 跳 转");
  58. // $("#appForm").submit();
  59. // return;
  60. // }
  61. if (true) {
  62. $(this).val("正 在 跳 转");
  63. // $("#appForm").submit();
  64. space.utils.ajax({
  65. type: "post",
  66. url: loginUrl,
  67. data: {
  68. uname: $("#uname").val().trim(),
  69. upwd: $("#upwd").val().trim()
  70. },
  71. dataType: 'json',
  72. loadLayer: false,
  73. callback: function (data) {
  74. if (data.code == 'success') {
  75. if (data.data.resultCode == 1000) {
  76. $(".login-warn").html(data.data.msg);
  77. $(".submit").removeAttr("disabled");
  78. $(".submit").val("登 录");
  79. }
  80. else if (data.data.resultCode == 1010) {
  81. top.location.href = "/apps/workbench/";
  82. }
  83. } else {
  84. $(".submit").removeAttr("disabled");
  85. $(".submit").val("登 录");
  86. }
  87. }
  88. });
  89. return;
  90. }
  91. var o = $(".submit").offset();
  92. var w = $(".submit").width();
  93. var l = o.left;
  94. if (w > 260) {
  95. l += (w - 260) / 2;
  96. }
  97. $("#verify").css({
  98. "left": l + "px",
  99. "top": (o.top - (160 + 20)) + "px"
  100. });
  101. var imgPath = function () {
  102. return "/apps/space/images/login/imgs/" + (Math.floor(Math.random() * 7) + 1) + ".jpg";
  103. }
  104. layui.link("/apps/space/plug-in/sprite/css/Sprite.css");
  105. sprite.init({
  106. el: $("#verify"),
  107. width: '260',
  108. height: '160',
  109. img: imgPath,
  110. success: function () {
  111. $(this).val("正 在 跳 转");
  112. layui.data('SVC', {
  113. key: 'SliderVerificationCode',
  114. value: 'success'
  115. });
  116. // setTimeout(function() {
  117. // $("#appForm").submit();
  118. // }, 500)
  119. },
  120. close: function () {
  121. $(".submit").removeAttr("disabled");
  122. }
  123. });
  124. $("#verify").show();
  125. $("#verify").addClass("animated flipInY");
  126. setTimeout(function () {
  127. $("#verify").removeClass("animated flipInY")
  128. }, 600)
  129. }
  130. })