login.js 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. define(["jquery", "easy-admin"], function ($, ea) {
  2. return {
  3. index: function () {
  4. if (top.location !== self.location) {
  5. top.location = self.location;
  6. }
  7. $(function () {
  8. if (backgroundUrl) {
  9. $('body').css('background', 'url(' + backgroundUrl + ') 0% 0% / cover no-repeat')
  10. }
  11. $('.bind-password').on('click', function () {
  12. if ($(this).hasClass('icon-5')) {
  13. $(this).removeClass('icon-5');
  14. $("input[name='password']").attr('type', 'password');
  15. } else {
  16. $(this).addClass('icon-5');
  17. $("input[name='password']").attr('type', 'text');
  18. }
  19. });
  20. $('.icon-nocheck').on('click', function () {
  21. if ($(this).hasClass('icon-check')) {
  22. $(this).removeClass('icon-check');
  23. } else {
  24. $(this).addClass('icon-check');
  25. }
  26. });
  27. document.addEventListener('keydown', function (event) {
  28. if (event.key === 'Enter' || event.keyCode === 13) {
  29. $('.login-btn').trigger('click')
  30. }
  31. });
  32. $('.login-tip').on('click', function () {
  33. $('.icon-nocheck').click();
  34. });
  35. ea.listen(function (data) {
  36. data['keep_login'] = $('.icon-nocheck').hasClass('icon-check') ? 1 : 0;
  37. return data;
  38. }, function (res) {
  39. ea.msg.success(res.msg, function () {
  40. window.location = ea.url('index');
  41. })
  42. }, function (res) {
  43. let data = res.data
  44. if (data?.is_ga_code || false) {
  45. let elem = $('#gaCode')
  46. elem.removeClass('layui-hide');
  47. elem.find('input').focus()
  48. }
  49. ea.msg.error(res.msg, function () {
  50. $('#refreshCaptcha').trigger("click");
  51. });
  52. });
  53. });
  54. },
  55. };
  56. });