农燊高科官方网站
No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.

login.js 4.6 KiB

hace 4 años
hace 4 años
hace 4 años
hace 4 años
hace 4 años
hace 4 años
hace 4 años
hace 4 años
hace 4 años
hace 4 años
hace 4 años
hace 4 años
hace 4 años
hace 4 años
hace 4 años
hace 4 años
hace 4 años
hace 4 años
hace 4 años
hace 4 años
hace 4 años
hace 4 años
hace 4 años
hace 4 años
hace 4 años
hace 4 años
hace 4 años
hace 4 años
hace 4 años
hace 4 años
hace 4 años
hace 4 años
hace 4 años
hace 4 años
hace 4 años
hace 4 años
hace 4 años
hace 4 años
hace 4 años
hace 4 años
hace 4 años
hace 4 años
hace 4 años
hace 4 años
hace 4 años
hace 4 años
hace 4 años
hace 4 años
hace 4 años
hace 4 años
hace 4 años
hace 4 años
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. /**
  2. * Created by admin on 2021/4/5.
  3. *
  4. */
  5. define(['jquery', "Tools","user"], function ($, Tools) {
  6. //数据存储
  7. var module = {
  8. uuid: '' //验证码uuid
  9. };
  10. //自定义公共方法
  11. var tools = new Tools();
  12. //默认进入页面加载方法
  13. module.init = function (page) {
  14. //点击登录
  15. $('#login-submit').on('click', module.login)
  16. //点击图形验证码
  17. $('#graphicImg').on('click', module.verificationCode)
  18. //图形验证码加载
  19. module.verificationCode()
  20. //背景高度
  21. module.register()
  22. };
  23. /*-----------------------------自定义方法-------------------------------------*/
  24. //登录方式切换
  25. loginTab = function(type){
  26. document.getElementById('loginTab').style.display = 'none'
  27. document.getElementById('phoneTab').style.display = 'none'
  28. document.getElementById(type+'Tab').style.display = 'block'
  29. }
  30. //背景高度
  31. module.register = function(){
  32. document.getElementById('registerBody').style.height = (document.body.offsetHeight - 112) +'px';
  33. }
  34. //图形验证码
  35. module.verificationCode = function () {
  36. tools.doGet(captchaImage_get, {}, module.verificationAjax, true)
  37. }
  38. module.verificationAjax = function (data) {
  39. if (data.code == 200) {
  40. $('#graphicImg').attr('src', 'data:image/gif;base64,' + data.img)
  41. module.uuid = data.uuid;
  42. }
  43. }
  44. //用户登录
  45. module.login = function () {
  46. if (module.check()) {
  47. var data = {};
  48. var usernameVal = $('#username').val();
  49. var passwordVal = $('#password').val();
  50. var codeVal = $('#code').val();
  51. data['username'] = usernameVal;
  52. data['password'] = passwordVal;
  53. data['code'] = codeVal;
  54. data['uuid'] = module.uuid;
  55. tools.doPost(login_post, data, module.loginData, true)
  56. }
  57. };
  58. //手动验证表单
  59. module.check = function () {
  60. var usernameVal = $('#username').val();
  61. var passwordVal = $('#password').val();
  62. var codeVal = $('#code').val();
  63. /* 手机号 */
  64. if (usernameVal == '') {
  65. $('#username')[0].focus()
  66. tools.initTips('请输入用户名', 'right', $('#username')[0], 2000)
  67. return false;
  68. }
  69. /* 密码 */
  70. if (passwordVal == '') {
  71. $('#password')[0].focus()
  72. tools.initTips('请输入密码', 'right', $('#password')[0], 2000)
  73. return false;
  74. } else if (parseInt(passwordVal.length) < 6 || parseInt(passwordVal.length) > 18) {
  75. $('#password')[0].focus()
  76. tools.initTips('请输入正确格式密码', 'right', $('#password')[0], 2000)
  77. return false;
  78. }
  79. /*图形验证码*/
  80. if (module.uuid == '' || codeVal == '') {
  81. $('#code')[0].focus()
  82. tools.initTips('请输入图形验证码', 'right', $('#code')[0], 2000)
  83. return false;
  84. }
  85. return true;
  86. }
  87. //登录校验
  88. module.loginData = function (data) {
  89. console.log(data)
  90. if (data.code == 500) {
  91. module.verificationCode()
  92. } else {
  93. tools.setCookie('Admin-Token', data.token, 24 * 60 * 60)
  94. //用户资料
  95. tools.doGet(userData, {}, module.userData);
  96. //tools.skip('/')
  97. }
  98. }
  99. //个人中心用户信息
  100. module.userData = function(data){
  101. if (data.code == 200) {
  102. var content = data.user;
  103. console.log(content)
  104. tools.setCookie('userId', content.userId, 24 * 60 * 60);
  105. tools.doGet(userMember + '/' + content.userId, {}, module.userMember);//memberType 1个人 2单位
  106. }
  107. }
  108. //个人中心用户资料
  109. module.userMember = function(data){
  110. if (data.code == 200) {
  111. var content = data.data;
  112. console.log(data)
  113. console.log(content.realname)
  114. tools.setCookie('userName', content.realname, 24 * 60 * 60);
  115. tools.setCookie('memberId', content.id, 24 * 60 * 60);
  116. tools.setCookie('idCardNum',content.idCardNum,24 * 60 * 60)
  117. tools.setCookie('phone',content.phone,24 * 60 * 60)
  118. tools.setCookie('address',content.address,24 * 60 * 60)
  119. tools.setCookie('bankAddress',content.bankAddress,24 * 60 * 60)
  120. tools.setCookie('bankCardName',content.bankCardName,24 * 60 * 60)
  121. tools.setCookie('bankCardNum',content.bankCardNum,24 * 60 * 60)
  122. tools.skip('/')
  123. }
  124. }
  125. return module;
  126. });