register.js 16 KB

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