register.js 19 KB

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