register.js 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476
  1. var Register = {
  2. registData: {},
  3. validateFields: {
  4. username: {validators: {notEmpty: {message: '登录账号不能为空'}}},
  5. name: {validators: {notEmpty: {message: '单位名称不能为空'}}},
  6. idCard: {validators: {notEmpty: {message: '社会信用代码不能为空'}}},
  7. agentName: {validators: {notEmpty: {message: '经办人不能为空'}}},
  8. agentPhone: {
  9. validators: {
  10. notEmpty: {
  11. message: '经办人手机号不能为空'
  12. }, regexp: {
  13. regexp: /((\d{11})|^((\d{7,8})|(\d{4}|\d{3})-(\d{7,8})|(\d{4}|\d{3})-(\d{7,8})-(\d{4}|\d{3}|\d{2}|\d{1})|(\d{7,8})-(\d{4}|\d{3}|\d{2}|\d{1}))$)/,
  14. message: "经办人手机号格式不合法"
  15. }
  16. }
  17. },
  18. verificationCode: {validators: {notEmpty: {message: '手机验证码不能为空'}}},
  19. legal: {validators: {notEmpty: {message: '法人代表不能为空'}}},
  20. street: {validators: {notEmpty: {message: '所属街道不能为空'}}},
  21. address: {validators: {notEmpty: {message: '单位地址不能为空'}}},
  22. ephone: {
  23. validators: {
  24. notEmpty: {
  25. message: '单位电话不能为空'
  26. }, regexp: {
  27. regexp: /((\d{11})|^((\d{7,8})|(\d{4}|\d{3})-(\d{7,8})|(\d{4}|\d{3})-(\d{7,8})-(\d{4}|\d{3}|\d{2}|\d{1})|(\d{7,8})-(\d{4}|\d{3}|\d{2}|\d{1}))$)/,
  28. message: "单位电话格式不合法"
  29. }
  30. }
  31. },
  32. agentEmail: {
  33. validators: {
  34. notEmpty: {
  35. message: '电子邮箱不能为空'
  36. },
  37. regexp: {
  38. regexp: /[\w!#$%&'*+/=?^_`{|}~-]+(?:\.[\w!#$%&'*+/=?^_`{|}~-]+)*@(?:[\w](?:[\w-]*[\w])?\.)+[\w](?:[\w-]*[\w])?/,
  39. message: "电子邮箱格式不正确"
  40. }
  41. }
  42. }
  43. }
  44. };
  45. var enterpriseCountDown = 0;
  46. var enterpriseSmsBtn = $("#enterprise_sms_btn");
  47. var persionCountDown = 0;
  48. var psSmsBtn = $("#ps_sms_btn");
  49. var lock = false;
  50. Register.addSubmit = function() {
  51. var regType = $(".active").attr("regType");
  52. if (regType == "en") { //企业用户注册
  53. Register.enterpriseUserRegister();
  54. } else if (regType == "ps") { //个人用户注册
  55. Register.personUserRegister();
  56. }
  57. };
  58. /**
  59. * 验证数据
  60. */
  61. Register.validate = function () {
  62. $('#ep_form').data("bootstrapValidator").resetForm();
  63. $('#ep_form').bootstrapValidator('validate');
  64. return $("#ep_form").data('bootstrapValidator').isValid();
  65. }
  66. var isDis = false;
  67. Register.enterpriseUserRegister = function() {
  68. if(!Register.validate()){
  69. return ;
  70. }
  71. isDis = $("#type").prop("disabled");
  72. var source = $("#source").val();
  73. var username = $("#username").val();
  74. var password = $("#password").val();
  75. var rePassword = $("#re_password").val();
  76. var name = $("#name").val();
  77. var idCard = $("#idCard").val();
  78. var agentName = $("#agentName").val();
  79. var agentPhone = $("#agentPhone").val();
  80. var verificationCode = $("#verificationCode").val();
  81. var legal = $("#legal").val();
  82. var street = $("#street").val();
  83. var address = $("#address").val();
  84. if(isDis){
  85. $("#type").removeAttr("disabled");
  86. }
  87. var type = $("#type").val();
  88. var agentEmail = $("#agentEmail").val();
  89. var talentType = $("#talentType").val();
  90. var enterpriseTag = $("#enterpriseTag").val();
  91. var ephone = $("#ephone").val();
  92. var industryFieldNew = $("#industryFieldNew").val();
  93. var bankCard = $("#bankCard").val();
  94. var bank = $("#bank").val();
  95. var bankNetwork = $("#bankNetwork").val();
  96. if (username==null || username=='') {
  97. Feng.info("请填写账号!");
  98. return;
  99. }
  100. if (username.length > 50) {
  101. Feng.info("账号最多50个字符!");
  102. return;
  103. }
  104. if(source != 2){
  105. if (password==null || password=='') {
  106. Feng.info("请填写密码!");
  107. return;
  108. }
  109. if (!/^(?=.*\d)(?=.*[a-zA-Z]).{8,20}$/.test(password)){
  110. Feng.info("密码格式错误,密码由字母、数字及特殊字符且8-20个字符组成!");
  111. return;
  112. }
  113. if (rePassword==null || rePassword=='') {
  114. Feng.info("请填写重复密码!");
  115. return;
  116. }
  117. if (password != rePassword) {
  118. Feng.info("两次密码填写不一致!");
  119. return;
  120. }
  121. }
  122. if (name==null || name=='') {
  123. Feng.info("请填写单位名称!");
  124. return;
  125. }
  126. if (name.length > 100) {
  127. Feng.info("单位名称最多100个字符!");
  128. return;
  129. }
  130. if (idCard==null || idCard=='') {
  131. Feng.info("请填写社会信用代码!");
  132. return;
  133. }
  134. if (type==null || type=='') {
  135. Feng.info("请选择申报类型!");
  136. return;
  137. }
  138. if (idCard.length > 40) {
  139. Feng.info("社会信用代码最多40个字符!");
  140. return;
  141. }
  142. if (agentName==null || agentName=='') {
  143. Feng.info("请填写经办人!");
  144. return;
  145. }
  146. if (agentName.length > 30) {
  147. Feng.info("经办人最多30个字符!");
  148. return;
  149. }
  150. if (agentPhone==null || agentPhone=='') {
  151. Feng.info("请填写经办人电话!");
  152. return;
  153. }
  154. if(ephone == null || ephone==''){
  155. Feng.info("请填写单位电话");
  156. return;
  157. }
  158. if (verificationCode==null || verificationCode=='') {
  159. Feng.info("请填写手机验证码!");
  160. return;
  161. }
  162. if (legal==null || legal=='') {
  163. Feng.info("请填写法人代表!");
  164. return;
  165. }
  166. if (street==null || street=='') {
  167. Feng.info("请选择所属街道!");
  168. return;
  169. }
  170. if (address==null || address=='') {
  171. Feng.info("请填写单位地址!");
  172. return;
  173. }
  174. if(type==null || type==''){
  175. Feng.info("请选择企业类别");
  176. return ;
  177. }
  178. if (agentEmail==null || agentEmail=='') {
  179. Feng.info("请填写电子邮箱!");
  180. return;
  181. }
  182. if (bankCard==null || bankCard=='') {
  183. Feng.info("请填写企业银行账号!");
  184. return;
  185. }
  186. if (bank==null || bank=='') {
  187. Feng.info("请填写企业开户银行!");
  188. return;
  189. }
  190. if (bankNetwork==null || bankNetwork=='') {
  191. Feng.info("请填写企业开户银行网点");
  192. return;
  193. }
  194. if(type==1 ){
  195. if(enterpriseTag==null||enterpriseTag==''){
  196. Feng.info("请选择单位标签!");
  197. return;
  198. }
  199. if(industryFieldNew == null || industryFieldNew ==''){
  200. Feng.info("请选择产业领域");
  201. return ;
  202. }
  203. }
  204. var x=document.getElementById("imgurl").value;
  205. if(x==""){
  206. Feng.info("请上传营业执照照片!");
  207. return;
  208. }
  209. if(!/((\d{11})|^((\d{7,8})|(\d{4}|\d{3})-(\d{7,8})|(\d{4}|\d{3})-(\d{7,8})-(\d{4}|\d{3}|\d{2}|\d{1})|(\d{7,8})-(\d{4}|\d{3}|\d{2}|\d{1}))$)/.test(ephone)){
  210. Feng.info("单位电话格式不合法!");
  211. return;
  212. }
  213. if(!/((\d{11})|^((\d{7,8})|(\d{4}|\d{3})-(\d{7,8})|(\d{4}|\d{3})-(\d{7,8})-(\d{4}|\d{3}|\d{2}|\d{1})|(\d{7,8})-(\d{4}|\d{3}|\d{2}|\d{1}))$)/.test(agentPhone)){
  214. Feng.info("经办人电话格式不合法!");
  215. return;
  216. }
  217. if(!/[\w!#$%&'*+/=?^_`{|}~-]+(?:\.[\w!#$%&'*+/=?^_`{|}~-]+)*@(?:[\w](?:[\w-]*[\w])?\.)+[\w](?:[\w-]*[\w])?/.test(agentEmail)){
  218. Feng.info("电子邮箱格式不合法!");
  219. return;
  220. }
  221. if(!lock){
  222. lock = true;
  223. }else{
  224. Feng.info("不能重复点击");
  225. return;
  226. }
  227. $("#ep_form")[0].submit();
  228. };
  229. Register.personUserRegister = function() {
  230. var source = $("#ps_source").val();
  231. var username = $("#ps_username").val();
  232. var password = $("#ps_password").val();
  233. var rePassword = $("#ps_re_password").val();
  234. var name = $("#ps_name").val();
  235. var sex = $("#ps_sex").val();
  236. var idCard = $("#ps_idCard").val();
  237. var phone = $("#ps_phone").val();
  238. var verificationCode = $("#ps_verificationCode").val();
  239. if (username==null || username=='') {
  240. Feng.info("请填写账号!");
  241. return;
  242. }
  243. if (username.length > 50) {
  244. Feng.info("账号最多20个字符!");
  245. return;
  246. }
  247. if(source !=2 ){
  248. if (password==null || password=='') {
  249. Feng.info("请填写密码!");
  250. return;
  251. }
  252. if (rePassword==null || rePassword=='') {
  253. Feng.info("请填写重复密码!");
  254. return;
  255. }
  256. if (password != rePassword) {
  257. Feng.info("两次密码填写不一致!");
  258. return;
  259. }
  260. }
  261. if (name==null || name=='') {
  262. Feng.info("请填写姓名!");
  263. return;
  264. }
  265. if (name.length > 20) {
  266. Feng.info("姓名最多20个字符!");
  267. return;
  268. }
  269. if (sex==null || sex=='') {
  270. Feng.info("请选择性别!");
  271. return;
  272. }
  273. if (idCard==null || idCard=='') {
  274. Feng.info("请填写身份证号!");
  275. return;
  276. }
  277. if (phone==null || phone=='') {
  278. Feng.info("请填写手机号!");
  279. return;
  280. }
  281. if (verificationCode==null || verificationCode=='') {
  282. Feng.info("请填写手机验证码!")
  283. return;
  284. }
  285. if(!/0?(13|14|15|17|18|19)[0-9]{9}/.test(phone)){
  286. Feng.info("手机号格式不合法!");
  287. return;
  288. }
  289. var da = {"source":source,"username":username, "password":password, "name":name, "sex":sex, "idCard":idCard, "phone":phone, "verificationCode":verificationCode};
  290. var ajax = new $ax(Feng.ctxPath + "/api/personalUser/register", function(data){
  291. Feng.info(data.msg);
  292. if (data.code == 200) {
  293. parent.layer.close(window.parent.Login.layerIndex);
  294. }
  295. },function(data){
  296. Feng.error("操作失败!" + data.responseJSON.message + "!");
  297. });
  298. ajax.set(da);
  299. ajax.start();
  300. };
  301. Register.getEnterpriseSms = function() {
  302. var agentPhone = $("#agentPhone").val();
  303. if (agentPhone==null || agentPhone=="") {
  304. Feng.info("请填写经办人手机号!");
  305. return;
  306. }
  307. agentPhone = $.trim(agentPhone);
  308. if (!Feng.checkMobilePhoneNum(agentPhone)) {
  309. Feng.info("手机号格式有误,请填写正确的手机号码!");
  310. return;
  311. }
  312. Register.enterpriseBtnCountDown();
  313. var ajax = new $ax(Feng.ctxPath + "/common/auth/verificationCode?phone="+agentPhone+"&type=1", function(data){
  314. Feng.info(data.msg);
  315. },function(data){
  316. Feng.error("操作失败!" + data.responseJSON.message + "!");
  317. });
  318. ajax.set(null);
  319. ajax.start();
  320. };
  321. Register.enterpriseBtnCountDown = function() {
  322. if (enterpriseCountDown == 0) {
  323. enterpriseCountDown = 60;
  324. } else if (enterpriseCountDown == 1) {
  325. enterpriseSmsBtn.removeAttr("disabled");
  326. enterpriseSmsBtn.html("获取验证码");
  327. enterpriseCountDown = 0;
  328. return;
  329. }
  330. enterpriseSmsBtn.attr("disabled", true);
  331. enterpriseSmsBtn.html(enterpriseCountDown + "秒");
  332. enterpriseCountDown--;
  333. setTimeout("Register.enterpriseBtnCountDown()", 1000);
  334. };
  335. Register.getPersionSms = function() {
  336. var phone = $("#ps_phone").val();
  337. if (phone==null || phone=="") {
  338. Feng.info("请填写手机号!");
  339. return;
  340. }
  341. phone = $.trim(phone);
  342. if (!Feng.checkMobilePhoneNum(phone)) {
  343. Feng.info("手机号格式有误,请填写正确的手机号码!");
  344. return;
  345. }
  346. Register.getPersionBtnCountDown();
  347. var ajax = new $ax(Feng.ctxPath + "/common/auth/verificationCode?phone="+phone+"&type=1", function(data){
  348. Feng.info(data.msg);
  349. },function(data){
  350. Feng.error("操作失败!" + data.responseJSON.message + "!");
  351. });
  352. ajax.set(null);
  353. ajax.start();
  354. };
  355. Register.getPersionBtnCountDown = function() {
  356. if (persionCountDown == 0) {
  357. persionCountDown = 60;
  358. } else if (persionCountDown == 1) {
  359. psSmsBtn.removeAttr("disabled");
  360. psSmsBtn.html("获取验证码");
  361. persionCountDown = 0;
  362. return;
  363. }
  364. psSmsBtn.attr("disabled", true);
  365. psSmsBtn.html(persionCountDown + "秒");
  366. persionCountDown--;
  367. setTimeout("Register.getPersionBtnCountDown()", 1000);
  368. };
  369. /**
  370. * 企业用户注册回调
  371. */
  372. Register.epCallBack = function(data) {
  373. lock = false;
  374. var nowDis = $("#type").prop("disabled");
  375. if(isDis!=nowDis){
  376. $("#type").attr("disabled","disabled");
  377. }
  378. Feng.info(data.msg);
  379. if (data.code == 200) {
  380. parent.layer.close(window.parent.Login.layerIndex);
  381. }
  382. };
  383. Register.typeChange = function(){
  384. $("#type").removeAttr("disabled");
  385. var type = $("#type").val();
  386. if(type==1){
  387. $("#typeGroup").attr("style","display:block");
  388. }else{
  389. $("typeGroup").attr("style","display:none");
  390. $("#enterpriseTag,#industryFieldNew,#industryFieldOld").val("");
  391. }
  392. }
  393. Register.industryChange = function(){
  394. var industryNew = $("#industryFieldNew").val();
  395. var arr = [{"name":"industryFieldOld","code":industryNew}];
  396. Feng.findChildDictBatch(JSON.stringify(arr));
  397. }
  398. $(function(){
  399. $('#ep_form').bootstrapValidator({
  400. feedbackIcons: {
  401. valid: 'glyphicon glyphicon-ok',
  402. invalid: 'glyphicon glyphicon-remove',
  403. validating: 'glyphicon glyphicon-refresh'
  404. },
  405. group:'.rowGroup',
  406. fields: Register.validateFields,
  407. live: 'enabled',
  408. message: '该字段不能为空'
  409. });
  410. var userType = Feng.getUrlValue("userType");
  411. var username = Feng.getUrlValue("username");
  412. var name = Feng.getUrlValue("name");
  413. var idCard = Feng.getUrlValue("idCard");
  414. var type = Feng.getUrlValue("type");
  415. if(userType == 1){ //企业用户trigger
  416. $("#source").val(2);
  417. $("#username").val(username).attr("readonly","readonly");
  418. $("#name").val(name).attr("readonly","readonly");
  419. $("#idCard").val(idCard).attr("readonly","readonly");
  420. $("#type").val(type).trigger("change");
  421. $("#type").attr("disabled","disabled");
  422. $("#password").val("").attr("placeholder","密码为聚才网账号密码").attr("readonly","readonly");
  423. $("#re_password").val("").attr("placeholder","密码为聚才网账号密码").attr("readonly","readonly");
  424. $("#personTab").css("pointer-events","none");
  425. } else if(userType == 2){ //个人用户
  426. $("#personTab").css("pointer-events","block");
  427. $("#personTab").children().click();
  428. $("#ps_source").val(2);
  429. $("#ps_username").val(name).attr("readonly","readonly");
  430. $("#ps_idCard").val(idCard).attr("readonly","readonly");
  431. $("#ps_password").val("").attr("placeholder","密码为聚才网账号密码").attr("readonly","readonly");
  432. $("#ps_re_password").val("").attr("placeholder","密码为聚才网账号密码").attr("readonly","readonly");
  433. $("#enTab").css("pointer-events","none");
  434. } else{ //无
  435. }
  436. var arr = [
  437. {"name":"street","code":"street"},
  438. {"name":"enterpriseTag","code":"enterprise_tag"},
  439. {"name":"industryFieldNew","code":"industry_field"},
  440. {"name":"enterpriseType","code":"enterprise_type"}];
  441. Feng.findChildDictBatch(JSON.stringify(arr));
  442. $("#imgurl").change(function (e) {
  443. var tag = e.target;
  444. var file = tag.files[0];
  445. var imgSrc;
  446. var reader = new FileReader();
  447. reader.readAsDataURL(file);
  448. reader.onload = function() {
  449. var src = $("#imgurl").val();
  450. var sn = src.lastIndexOf(".");
  451. var suffix = src.substring(sn+1,src.length);
  452. if(suffix == 'pdf' || suffix == 'PDF'){
  453. $("#photoImg").attr("src", Feng.ctxPath + "/static/img/Pdf.png");
  454. }else{
  455. imgSrc = this.result;
  456. $("#photoImg").attr("src", imgSrc);
  457. }
  458. };
  459. });
  460. });