register.js 15 KB

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