网站
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

registerFrom.js 6.9 KiB

il y a 4 ans
il y a 4 ans
il y a 4 ans
il y a 4 ans
il y a 4 ans
il y a 4 ans
il y a 4 ans
il y a 4 ans
il y a 4 ans
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  1. /**
  2. * Created by Administrator on 2021/4/5.
  3. */
  4. define(['jquery', "template", "Tools", "echarts", 'register', 'swiper'], function ($, template, Tools, echarts, swiper) {
  5. //数据存储
  6. var module = {
  7. data: {
  8. type: 1
  9. },
  10. };
  11. var tools = new Tools();
  12. module.init = function (page) {
  13. //点击注册
  14. $('#register-submit').on('click', module.register)
  15. //点击图形验证码
  16. $('#graphicImgBtn').on('click', module.verificationCode)
  17. //图形验证码加载
  18. module.verificationCode()
  19. //网站配置信息(网站名称 底部联系方式 公安备案号 网站备案号)
  20. tools.getWebConfig();
  21. module.getType();
  22. };
  23. //获取地址栏参数
  24. function getQueryVariable(variable){
  25. var query = window.location.search.substring(1);
  26. var vars = query.split("&");
  27. for (var i=0;i<vars.length;i++) {
  28. var pair = vars[i].split("=");
  29. if(pair[0] == variable){return pair[1];}
  30. }
  31. return(false);
  32. }
  33. module.getType = function(){
  34. var type = getQueryVariable("type");
  35. if (type == 1){
  36. document.getElementById("userBtn").className = "active";
  37. document.getElementById("companyBtn").className = "";
  38. tabCheck('user');
  39. module.data.type = type;
  40. }else if(type == 2){
  41. document.getElementById("userBtn").className = "";
  42. document.getElementById("companyBtn").className = "active";
  43. tabCheck('company');
  44. module.data.type = type;
  45. }
  46. }
  47. tabCheck = function(type,typeNum){
  48. document.getElementById("userBtn").className = "";
  49. document.getElementById("companyBtn").className = "";
  50. document.getElementById("userTable").style.display = "none";
  51. document.getElementById("companyTable").style.display = "none";
  52. module.data.type = typeNum;
  53. document.getElementById(type+'Btn').className = 'active';
  54. document.getElementById(type+'Table').style.display = 'block';
  55. }
  56. //图形验证码
  57. module.verificationCode = function () {
  58. tools.doGet(captchaImage_get, {}, module.verificationAjax, true)
  59. }
  60. module.verificationAjax = function (data) {
  61. if (data.code == 200) {
  62. $('#graphicImg').attr('src', 'data:image/gif;base64,' + data.img)
  63. module.uuid = data.uuid;
  64. }
  65. }
  66. //用户注册
  67. module.register = function (data) {
  68. var data = {};
  69. if(module.check()){
  70. if (module.data.type == 1){
  71. var phone = $('#phone').val();
  72. var passwordVal = $('#password').val();
  73. var codeVal = $('#code').val();
  74. var realName = $('#realName').val();
  75. var idCardNum = $('#idCardNum').val();
  76. var address = $('#address').val();
  77. var memberType = 1 ;
  78. data['phone'] = phone;
  79. data['password'] = passwordVal;
  80. data['code'] = codeVal;
  81. data['realname'] = realName;
  82. data['idCardNum'] = idCardNum;
  83. data['address'] = address;
  84. data['economicType'] = 1;
  85. }
  86. if (module.data.type == 2){
  87. var phone = $('#phone').val();
  88. var passwordVal = $('#password').val();
  89. var codeVal = $('#code').val();
  90. var companyName = $('#companyName').val();
  91. var realName = $('#companyRealName').val();
  92. var idCardNum = $('#companyIdCardNum').val();
  93. var address = $('#companyAddress').val();
  94. var companyLicense = $('#companyLicense').val();
  95. var companyCode = $('#companyCode').val();
  96. data['phone'] = phone;
  97. data['password'] = passwordVal;
  98. data['code'] = codeVal;
  99. data['realname'] = realName;
  100. data['idCardNum'] = idCardNum;
  101. data['address'] = address;
  102. data['companyName'] = companyName;
  103. data['companyLicense'] = companyLicense;
  104. data['companyCode'] = companyCode;
  105. }
  106. data['memberType'] = module.data.type;
  107. tools.doPost(userRegister, data, module.registerData, true)
  108. }
  109. }
  110. //注册校验
  111. module.registerData = function (data) {
  112. console.log(data)
  113. if (data.code == 500) {
  114. module.verificationCode()
  115. }
  116. if (data.code == 200){
  117. tools.initError("注册成功");
  118. setTimeout(function(){
  119. tools.skip('login.html')
  120. },2000)
  121. }
  122. }
  123. //手动验证表单
  124. module.check = function () {
  125. var phone = $('#phone').val();
  126. var passwordVal = $('#password').val();
  127. var codeVal = $('#code').val();
  128. var realName = $('#realName').val();
  129. var idCardNum = $('#idCardNum').val();
  130. var address = $('#address').val();
  131. /* 手机号 */
  132. if (phone == '') {
  133. $('#phone')[0].focus()
  134. tools.initTips('请输入手机号', 'right', $('#phone')[0], 2000)
  135. return false;
  136. }
  137. /* 姓名 */
  138. if (realName == '') {
  139. $('#realName')[0].focus()
  140. tools.initTips('请输入姓名', 'right', $('#realName')[0], 2000)
  141. return false;
  142. }
  143. /* 身份证号 */
  144. if (idCardNum == '') {
  145. $('#idCardNum')[0].focus()
  146. tools.initTips('请输入身份证号', 'right', $('#idCardNum')[0], 2000)
  147. return false;
  148. }
  149. /* 地址 */
  150. if (address == '') {
  151. $('#address')[0].focus()
  152. tools.initTips('请输入地址', 'right', $('#address')[0], 2000)
  153. return false;
  154. }
  155. /* 密码 */
  156. if (passwordVal == '') {
  157. $('#password')[0].focus()
  158. tools.initTips('请输入密码', 'right', $('#password')[0], 2000)
  159. return false;
  160. } else if (parseInt(passwordVal.length) < 6 || parseInt(passwordVal.length) > 18) {
  161. $('#password')[0].focus()
  162. tools.initTips('请输入正确格式密码', 'right', $('#password')[0], 2000)
  163. return false;
  164. }else if($('#password').val() != $('#passwordAgain').val()){
  165. $('#password')[0].focus()
  166. tools.initTips('两次密码输入不一致', 'right', $('#password')[0], 2000)
  167. return false;
  168. }
  169. /*图形验证码*/
  170. if (module.uuid == '' || codeVal == '') {
  171. $('#code')[0].focus()
  172. tools.initTips('请输入图形验证码', 'right', $('#code')[0], 2000)
  173. return false;
  174. }
  175. console.log($('#iAgree:checked').val())
  176. if ($('#iAgree:checked').val() == undefined){
  177. tools.initTips('请选择我已同意', 'right', $('#iAgree')[0], 2000)
  178. return false;
  179. }
  180. return true;
  181. }
  182. return module;
  183. });