网站
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.
 
 
 

245 linhas
8.9 KiB

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