农燊高科官方网站
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.
 
 
 

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