农燊高科官方网站
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.
 
 
 

132 rindas
4.7 KiB

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