register.js 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520
  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. }
  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(!/^[\u4e00-\u9fa5]{1,100}$/.test(name)){
  127. Feng.info("单位名称只能输入中文 !");
  128. return;
  129. }
  130. if (name.length > 100) {
  131. Feng.info("单位名称最多100个字符!");
  132. return;
  133. }
  134. if (idCard==null || idCard=='') {
  135. Feng.info("请填写社会信用代码!");
  136. return;
  137. }
  138. if (type==null || type=='') {
  139. Feng.info("请选择申报类型!");
  140. return;
  141. }
  142. if (idCard.length > 40) {
  143. Feng.info("社会信用代码最多40个字符!");
  144. return;
  145. }
  146. if (agentName==null || agentName=='') {
  147. Feng.info("请填写人才联络员!");
  148. return;
  149. }
  150. if (agentName.length > 30) {
  151. Feng.info("人才联络员最多30个字符!");
  152. return;
  153. }
  154. if (agentPhone==null || agentPhone=='') {
  155. Feng.info("请填写人才联络员电话!");
  156. return;
  157. }
  158. if(ephone == null || ephone==''){
  159. Feng.info("请填写单位电话");
  160. return;
  161. }
  162. if (verificationCode==null || verificationCode=='') {
  163. Feng.info("请填写手机验证码!");
  164. return;
  165. }
  166. if (legal==null || legal=='') {
  167. Feng.info("请填写法人代表!");
  168. return;
  169. }
  170. if(!/^[\u4e00-\u9fa5]{1,50}$/.test(legal)){
  171. Feng.info("法人代表只能输入中文 !");
  172. return;
  173. }
  174. if (street==null || street=='') {
  175. Feng.info("请选择所属街道!");
  176. return;
  177. }
  178. if (address==null || address=='') {
  179. Feng.info("请填写单位地址!");
  180. return;
  181. }
  182. if(type==null || type==''){
  183. Feng.info("请选择企业类别");
  184. return ;
  185. }
  186. if (agentEmail==null || agentEmail=='') {
  187. Feng.info("请填写电子邮箱!");
  188. return;
  189. }
  190. if (bankCard==null || bankCard=='') {
  191. Feng.info("请填写企业银行账号!");
  192. return;
  193. }
  194. if (bank==null || bank=='') {
  195. Feng.info("请填写企业开户银行!");
  196. return;
  197. }
  198. if (bankNetwork==null || bankNetwork=='') {
  199. Feng.info("请填写企业开户银行网点");
  200. return;
  201. }
  202. if(type==1 ){
  203. if(enterpriseTag==null||enterpriseTag==''){
  204. Feng.info("请选择单位标签!");
  205. return;
  206. }
  207. if(industryFieldNew == null || industryFieldNew ==''){
  208. Feng.info("请选择产业领域");
  209. return ;
  210. }
  211. }
  212. var x=document.getElementById("imgurl").value;
  213. if(x==""){
  214. Feng.info("请上传营业执照照片!");
  215. return;
  216. }
  217. 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)){
  218. Feng.info("单位电话格式不合法!");
  219. return;
  220. }
  221. 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)){
  222. Feng.info("人才联络员电话格式不合法!");
  223. return;
  224. }
  225. if(!/[\w!#$%&'*+/=?^_`{|}~-]+(?:\.[\w!#$%&'*+/=?^_`{|}~-]+)*@(?:[\w](?:[\w-]*[\w])?\.)+[\w](?:[\w-]*[\w])?/.test(agentEmail)){
  226. Feng.info("电子邮箱格式不合法!");
  227. return;
  228. }
  229. if(!lock){
  230. lock = true;
  231. }else{
  232. Feng.info("不能重复点击");
  233. return;
  234. }
  235. $("#ep_form")[0].submit();
  236. };
  237. Register.personUserRegister = function() {
  238. var source = $("#ps_source").val();
  239. var username = $("#ps_username").val();
  240. var password = $("#ps_password").val();
  241. var rePassword = $("#ps_re_password").val();
  242. var name = $("#ps_name").val();
  243. var sex = $("#ps_sex").val();
  244. var idCard = $("#ps_idCard").val();
  245. var phone = $("#ps_phone").val();
  246. var verificationCode = $("#ps_verificationCode").val();
  247. if (username==null || username=='') {
  248. Feng.info("请填写账号!");
  249. return;
  250. }
  251. if (username.length > 50) {
  252. Feng.info("账号最多20个字符!");
  253. return;
  254. }
  255. if(source !=2 ){
  256. if (password==null || password=='') {
  257. Feng.info("请填写密码!");
  258. return;
  259. }
  260. if (rePassword==null || rePassword=='') {
  261. Feng.info("请填写重复密码!");
  262. return;
  263. }
  264. if (password != rePassword) {
  265. Feng.info("两次密码填写不一致!");
  266. return;
  267. }
  268. }
  269. if (name==null || name=='') {
  270. Feng.info("请填写姓名!");
  271. return;
  272. }
  273. if (name.length > 20) {
  274. Feng.info("姓名最多20个字符!");
  275. return;
  276. }
  277. if (sex==null || sex=='') {
  278. Feng.info("请选择性别!");
  279. return;
  280. }
  281. if (idCard==null || idCard=='') {
  282. Feng.info("请填写身份证号!");
  283. return;
  284. }
  285. if (phone==null || phone=='') {
  286. Feng.info("请填写手机号!");
  287. return;
  288. }
  289. if (verificationCode==null || verificationCode=='') {
  290. Feng.info("请填写手机验证码!")
  291. return;
  292. }
  293. if(!/0?(13|14|15|17|18|19)[0-9]{9}/.test(phone)){
  294. Feng.info("手机号格式不合法!");
  295. return;
  296. }
  297. var da = {"source":source,"username":username, "password":password, "name":name, "sex":sex, "idCard":idCard, "phone":phone, "verificationCode":verificationCode};
  298. var ajax = new $ax(Feng.ctxPath + "/api/personalUser/register", function(data){
  299. Feng.info(data.msg);
  300. if (data.code == 200) {
  301. parent.layer.close(window.parent.Login.layerIndex);
  302. }
  303. },function(data){
  304. Feng.error("操作失败!" + data.responseJSON.message + "!");
  305. });
  306. ajax.set(da);
  307. ajax.start();
  308. };
  309. Register.getEnterpriseSms = function() {
  310. var agentPhone = $("#agentPhone").val();
  311. if (agentPhone==null || agentPhone=="") {
  312. Feng.info("请填写人才联络员手机号!");
  313. return;
  314. }
  315. agentPhone = $.trim(agentPhone);
  316. if (!Feng.checkMobilePhoneNum(agentPhone)) {
  317. Feng.info("手机号格式有误,请填写正确的手机号码!");
  318. return;
  319. }
  320. Register.enterpriseBtnCountDown();
  321. var ajax = new $ax(Feng.ctxPath + "/common/auth/verificationCode?phone="+agentPhone+"&type=1", function(data){
  322. Feng.info(data.msg);
  323. },function(data){
  324. Feng.error("操作失败!" + data.responseJSON.message + "!");
  325. });
  326. ajax.set(null);
  327. ajax.start();
  328. };
  329. Register.enterpriseBtnCountDown = function() {
  330. if (enterpriseCountDown == 0) {
  331. enterpriseCountDown = 60;
  332. } else if (enterpriseCountDown == 1) {
  333. enterpriseSmsBtn.removeAttr("disabled");
  334. enterpriseSmsBtn.html("获取验证码");
  335. enterpriseCountDown = 0;
  336. return;
  337. }
  338. enterpriseSmsBtn.attr("disabled", true);
  339. enterpriseSmsBtn.html(enterpriseCountDown + "秒");
  340. enterpriseCountDown--;
  341. setTimeout("Register.enterpriseBtnCountDown()", 1000);
  342. };
  343. Register.getPersionSms = function() {
  344. var phone = $("#ps_phone").val();
  345. if (phone==null || phone=="") {
  346. Feng.info("请填写手机号!");
  347. return;
  348. }
  349. phone = $.trim(phone);
  350. if (!Feng.checkMobilePhoneNum(phone)) {
  351. Feng.info("手机号格式有误,请填写正确的手机号码!");
  352. return;
  353. }
  354. Register.getPersionBtnCountDown();
  355. var ajax = new $ax(Feng.ctxPath + "/common/auth/verificationCode?phone="+phone+"&type=1", function(data){
  356. Feng.info(data.msg);
  357. },function(data){
  358. Feng.error("操作失败!" + data.responseJSON.message + "!");
  359. });
  360. ajax.set(null);
  361. ajax.start();
  362. };
  363. Register.getPersionBtnCountDown = function() {
  364. if (persionCountDown == 0) {
  365. persionCountDown = 60;
  366. } else if (persionCountDown == 1) {
  367. psSmsBtn.removeAttr("disabled");
  368. psSmsBtn.html("获取验证码");
  369. persionCountDown = 0;
  370. return;
  371. }
  372. psSmsBtn.attr("disabled", true);
  373. psSmsBtn.html(persionCountDown + "秒");
  374. persionCountDown--;
  375. setTimeout("Register.getPersionBtnCountDown()", 1000);
  376. };
  377. /**
  378. * 企业用户注册回调
  379. */
  380. Register.epCallBack = function(data) {
  381. lock = false;
  382. var nowDis = $("#type").prop("disabled");
  383. if(isDis!=nowDis){
  384. $("#type").attr("disabled","disabled");
  385. }
  386. Feng.info(data.msg);
  387. if (data.code == 200) {
  388. parent.layer.close(window.parent.Login.layerIndex);
  389. }
  390. };
  391. Register.typeChange = function(){
  392. $("#type").removeAttr("disabled");
  393. var type = $("#type").val();
  394. if(type==1){
  395. $("#typeGroup").attr("style","display:block");
  396. }else{
  397. $("typeGroup").attr("style","display:none");
  398. $("#enterpriseTag,#industryFieldNew,#industryFieldOld").val("");
  399. }
  400. }
  401. Register.industryChange = function(){
  402. var industryNew = $("#industryFieldNew").val();
  403. var arr = [{"name":"industryFieldOld","code":industryNew+"_field"}];
  404. Feng.findChildDictBatch(JSON.stringify(arr));
  405. }
  406. $(function(){
  407. $('#ep_form').bootstrapValidator({
  408. feedbackIcons: {
  409. valid: 'glyphicon glyphicon-ok',
  410. invalid: 'glyphicon glyphicon-remove',
  411. validating: 'glyphicon glyphicon-refresh'
  412. },
  413. group:'.rowGroup',
  414. fields: Register.validateFields,
  415. live: 'enabled',
  416. message: '该字段不能为空'
  417. });
  418. var userType = Feng.getUrlValue("userType");
  419. var username = Feng.getUrlValue("username");
  420. var name = Feng.getUrlValue("name");
  421. var idCard = Feng.getUrlValue("idCard");
  422. var type = Feng.getUrlValue("type");
  423. if(userType == 1){ //企业用户trigger
  424. $("#source").val(2);
  425. $("#username").val(username).attr("readonly","readonly");
  426. $("#name").val(name).attr("readonly","readonly");
  427. $("#idCard").val(idCard).attr("readonly","readonly");
  428. $("#type").val(type).trigger("change");
  429. $("#type").attr("disabled","disabled");
  430. $("#password").val("").attr("placeholder","密码为聚才网账号密码").attr("readonly","readonly");
  431. $("#re_password").val("").attr("placeholder","密码为聚才网账号密码").attr("readonly","readonly");
  432. $("#personTab").css("pointer-events","none");
  433. } else if(userType == 2){ //个人用户
  434. $("#personTab").css("pointer-events","block");
  435. $("#personTab").children().click();
  436. $("#ps_source").val(2);
  437. $("#ps_username").val(name).attr("readonly","readonly");
  438. $("#ps_idCard").val(idCard).attr("readonly","readonly");
  439. $("#ps_password").val("").attr("placeholder","密码为聚才网账号密码").attr("readonly","readonly");
  440. $("#ps_re_password").val("").attr("placeholder","密码为聚才网账号密码").attr("readonly","readonly");
  441. $("#enTab").css("pointer-events","none");
  442. } else{ //无
  443. }
  444. var arr = [
  445. {"name":"street","code":"street"},
  446. {"name":"enterpriseTag","code":"enterprise_tag"},
  447. {"name":"industryFieldNew","code":"industry_field"},
  448. {"name":"enterpriseType","code":"enterprise_type"}];
  449. Feng.findChildDictBatch(JSON.stringify(arr));
  450. $("#imgurl").change(function (e) {
  451. var tag = e.target;
  452. var file = tag.files[0];
  453. var imgSrc;
  454. var reader = new FileReader();
  455. reader.readAsDataURL(file);
  456. reader.onload = function() {
  457. var src = $("#imgurl").val();
  458. var sn = src.lastIndexOf(".");
  459. var suffix = src.substring(sn+1,src.length);
  460. if(suffix == 'pdf' || suffix == 'PDF'){
  461. $("#photoImg").attr("src", Feng.ctxPath + "/static/img/Pdf.png");
  462. }else{
  463. imgSrc = this.result;
  464. $("#photoImg").attr("src", imgSrc);
  465. }
  466. };
  467. });
  468. $("#bankImg").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 = $("#bankImg").val();
  476. var sn = src.lastIndexOf(".");
  477. var suffix = src.substring(sn+1,src.length);
  478. if(suffix == 'pdf' || suffix == 'PDF'){
  479. $("#photoImg1").attr("src", Feng.ctxPath + "/static/img/Pdf.png");
  480. }else{
  481. imgSrc = this.result;
  482. $("#photoImg1").attr("src", imgSrc);
  483. }
  484. };
  485. });
  486. $("#domainImg").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 = $("#domainImg").val();
  494. var sn = src.lastIndexOf(".");
  495. var suffix = src.substring(sn+1,src.length);
  496. if(suffix == 'pdf' || suffix == 'PDF'){
  497. $("#photoImg2").attr("src", Feng.ctxPath + "/static/img/Pdf.png");
  498. }else{
  499. imgSrc = this.result;
  500. $("#photoImg2").attr("src", imgSrc);
  501. }
  502. };
  503. });
  504. });