login.js 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. var show_num = [];
  2. layui.use(['form'], function () {
  3. var form = layui.form,
  4. layer = layui.layer;
  5. // 登录过期的时候,跳出ifram框架
  6. if (top.location != self.location) top.location = self.location;
  7. // 进行登录操作
  8. form.on('submit(login)', function (data) {
  9. data = data.field;
  10. if (data.username == '') {
  11. layer.msg('用户名不能为空');
  12. return false;
  13. }
  14. if (data.password == '') {
  15. layer.msg('密码不能为空');
  16. return false;
  17. }
  18. if (data.captcha == '') {
  19. layer.msg('验证码不能为空');
  20. return false;
  21. }
  22. // 验证码 校验
  23. // var val = $(".input-val").val().toLowerCase();
  24. // var num = show_num.join("");
  25. // if(val != num){
  26. // layer.msg('验证码错误!请重新输入!');
  27. // draw(show_num);
  28. // return false;
  29. // }
  30. // window.location = '../index.html';
  31. // return false;
  32. $(".input-val").val('');
  33. let url = '/admin/login/check';
  34. $.ajax({
  35. url,
  36. data,
  37. type: "POST",
  38. success(res) {
  39. if (res.status == 1) {
  40. layer.msg('登录成功', function () {
  41. window.location = '/admin/index/index.html';
  42. });
  43. } else {
  44. layer.msg(res.message);
  45. return false;
  46. }
  47. }
  48. })
  49. return false;
  50. });
  51. });
  52. $(function(){
  53. // location.href = "http://www.baidu.com";
  54. draw(show_num);
  55. $("#canvas").on('click',function(){
  56. draw(show_num);
  57. })
  58. })