农燊高科官方网站
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

registerFrom.js 8.6 KiB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237
  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. tools.doGet(Dictionaries+'/economic_type', {}, module.economicTypeDictionaries,true);
  23. };
  24. //获取地址栏参数
  25. function getQueryVariable(variable){
  26. var query = window.location.search.substring(1);
  27. var vars = query.split("&");
  28. for (var i=0;i<vars.length;i++) {
  29. var pair = vars[i].split("=");
  30. if(pair[0] == variable){return pair[1];}
  31. }
  32. return(false);
  33. }
  34. //经济类型
  35. module.economicTypeDictionaries = function (data) {
  36. if (data.code == 200) {
  37. var content = data.data;
  38. console.log(content)
  39. module.data.outProjectInformationDetail = content;
  40. var outProjectInformationData = template('outProjectInformationData', module.data);
  41. $("#economicType").html(outProjectInformationData);
  42. }
  43. }
  44. module.getType = function(){
  45. var type = getQueryVariable("type");
  46. if (type == 1){
  47. document.getElementById("userBtn").className = "active";
  48. document.getElementById("companyBtn").className = "";
  49. tabCheck('user');
  50. module.data.type = type;
  51. }else if(type == 2){
  52. document.getElementById("userBtn").className = "";
  53. document.getElementById("companyBtn").className = "active";
  54. tabCheck('company');
  55. module.data.type = type;
  56. }
  57. }
  58. tabCheck = function(type,typeNum){
  59. document.getElementById("userBtn").className = "";
  60. document.getElementById("companyBtn").className = "";
  61. document.getElementById("userTable").style.display = "none";
  62. document.getElementById("companyTable").style.display = "none";
  63. module.data.type = typeNum;
  64. document.getElementById(type+'Btn').className = 'active';
  65. document.getElementById(type+'Table').style.display = 'block';
  66. }
  67. //图形验证码
  68. module.verificationCode = function () {
  69. tools.doGet(captchaImage_get, {}, module.verificationAjax, true)
  70. }
  71. module.verificationAjax = function (data) {
  72. if (data.code == 200) {
  73. $('#graphicImg').attr('src', 'data:image/gif;base64,' + data.img)
  74. module.uuid = data.uuid;
  75. }
  76. }
  77. //用户注册
  78. module.register = function (data) {
  79. var data = {};
  80. if(module.check()){
  81. if (module.data.type == 1){
  82. var phone = $('#phone').val();
  83. var passwordVal = $('#password').val();
  84. var codeVal = $('#code').val();
  85. var realName = $('#realName').val();
  86. var idCardNum = $('#idCardNum').val();
  87. var address = $('#address').val();
  88. var memberType = 1 ;
  89. data['phone'] = phone;
  90. data['password'] = passwordVal;
  91. data['code'] = codeVal;
  92. data['realname'] = realName;
  93. data['idCardNum'] = idCardNum;
  94. data['address'] = address;
  95. data['economicType'] = 1;
  96. }
  97. if (module.data.type == 2){
  98. var phone = $('#phone').val();
  99. var passwordVal = $('#password').val();
  100. var codeVal = $('#code').val();
  101. var companyName = $('#companyName').val();
  102. var realName = $('#companyRealName').val();
  103. var idCardNum = $('#companyIdCardNum').val();
  104. var address = $('#companyAddress').val();
  105. var companyLicense = $('#companyLicense').val();
  106. var companyCode = $('#companyCode').val();
  107. var economicType = $('#economicType').val();
  108. data['phone'] = phone;
  109. data['password'] = passwordVal;
  110. data['code'] = codeVal;
  111. data['realname'] = realName;
  112. data['idCardNum'] = idCardNum;
  113. data['address'] = address;
  114. data['companyName'] = companyName;
  115. data['companyLicense'] = companyLicense;
  116. data['companyCode'] = companyCode;
  117. data['economicType'] = economicType;
  118. }
  119. data['memberType'] = module.data.type;
  120. tools.doPost(userRegister, data, module.registerData, true)
  121. }
  122. }
  123. //注册校验
  124. module.registerData = function (data) {
  125. console.log(data)
  126. if (data.code == 500) {
  127. module.verificationCode()
  128. }
  129. if (data.code == 200){
  130. tools.initError("注册成功");
  131. setTimeout(function(){
  132. tools.skip('login.html')
  133. },2000)
  134. }
  135. }
  136. //手动验证表单
  137. module.check = function () {
  138. var phone = $('#phone').val();
  139. var passwordVal = $('#password').val();
  140. var codeVal = $('#code').val();
  141. var realName = $('#realName').val();
  142. var idCardNum = $('#idCardNum').val();
  143. var address = $('#address').val();
  144. var companyRealName = $('#companyRealName').val();
  145. var companyIdCardNum = $('#companyIdCardNum').val();
  146. var companyAddress = $('#companyAddress').val();
  147. /* 手机号 */
  148. if (phone == '') {
  149. $('#phone')[0].focus()
  150. tools.initTips('请输入手机号', 'right', $('#phone')[0], 2000)
  151. return false;
  152. }
  153. if (module.data.type == 1) {
  154. /* 姓名 */
  155. if (realName == '') {
  156. $('#realName')[0].focus()
  157. tools.initTips('请输入姓名', 'right', $('#realName')[0], 2000)
  158. return false;
  159. }
  160. /* 身份证号 */
  161. if (idCardNum == '') {
  162. $('#idCardNum')[0].focus()
  163. tools.initTips('请输入身份证号', 'right', $('#idCardNum')[0], 2000)
  164. return false;
  165. }
  166. /* 地址 */
  167. if (address == '') {
  168. $('#address')[0].focus()
  169. tools.initTips('请输入地址', 'right', $('#address')[0], 2000)
  170. return false;
  171. }
  172. }
  173. if (module.data.type == 2){
  174. /* 姓名 */
  175. if (companyRealName == '') {
  176. $('#companyRealName')[0].focus()
  177. tools.initTips('请输入姓名', 'right', $('#companyRealName')[0], 2000)
  178. return false;
  179. }
  180. /* 身份证号 */
  181. if (companyIdCardNum == '') {
  182. $('#companyIdCardNum')[0].focus()
  183. tools.initTips('请输入身份证号', 'right', $('#companyIdCardNum')[0], 2000)
  184. return false;
  185. }
  186. /* 地址 */
  187. if (companyAddress == '') {
  188. $('#companyAddress')[0].focus()
  189. tools.initTips('请输入地址', 'right', $('#companyAddress')[0], 2000)
  190. return false;
  191. }
  192. }
  193. /* 密码 */
  194. if (passwordVal == '') {
  195. $('#password')[0].focus()
  196. tools.initTips('请输入密码', 'right', $('#password')[0], 2000)
  197. return false;
  198. } else if (parseInt(passwordVal.length) < 6 || parseInt(passwordVal.length) > 18) {
  199. $('#password')[0].focus()
  200. tools.initTips('请输入正确格式密码', 'right', $('#password')[0], 2000)
  201. return false;
  202. }else if($('#password').val() != $('#passwordAgain').val()){
  203. $('#password')[0].focus()
  204. tools.initTips('两次密码输入不一致', 'right', $('#password')[0], 2000)
  205. return false;
  206. }
  207. /*图形验证码*/
  208. if (module.uuid == '' || codeVal == '') {
  209. $('#code')[0].focus()
  210. tools.initTips('请输入图形验证码', 'right', $('#code')[0], 2000)
  211. return false;
  212. }
  213. console.log($('#iAgree:checked').val())
  214. if ($('#iAgree:checked').val() == undefined){
  215. tools.initTips('请选择我已同意', 'right', $('#iAgree')[0], 2000)
  216. return false;
  217. }
  218. return true;
  219. }
  220. return module;
  221. });