applyVerify.min.js 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. /*
  2. * 2020.5.4
  3. * 对报名提交方法进行改进,此报名文件以后不能在这里添加其它的方法函数,
  4. * 如需要添加时,在调时进行添加即可,添加调用的格式请参考 ShowDoc 在线文档内有标明调用的方法格式
  5. */
  6. /*·······································································*/
  7. var PublicAction = {
  8. /* AjaxSend-----Ajax发送*/
  9. "AjaxSend" :function(e,fnEnd){
  10. var _this = this, result;
  11. // 获取
  12. var urlstr = window.location.href;
  13. console.log(urlstr)
  14. var searchurl = urlstr.substring(0,urlstr.indexOf('?')+1);
  15. // var matchdata = urlstr.match(/\.com(\/\w+)/)[1];
  16. var i = e.CORID, //ID
  17. _url = '/enroll/signup', //提交地址
  18. _post = "POST", //提交方式
  19. _async = true; //同步或异步
  20. // var i = e.CORID,_url = './signup.php',_post = "POST",_async = true;
  21. $('.'+ i).on('click',function(){
  22. var $this = $(this);
  23. var _getData = _this.getData($this);
  24. if(_getData.ControlSwitch){
  25. $.ajax({type:_post,url:_url,data:_getData,async:_async,dataType:'json',
  26. error : function(request) {
  27. if(fnEnd){
  28. if(typeof fnEnd === 'object'){fnEnd.error();}
  29. }else{
  30. _this.hint('未提交成功!');
  31. }
  32. },
  33. success : function(data) {
  34. if(data.code == 200){
  35. if(fnEnd){
  36. if(typeof fnEnd === 'object'){
  37. fnEnd.success();
  38. }else{
  39. fnEnd();
  40. }
  41. }else{
  42. _this.hint(data.msg);
  43. }
  44. }else if(data.code == 300){
  45. _this.hint(data.msg);
  46. }
  47. }
  48. });
  49. event.preventDefault();
  50. return false;
  51. }
  52. })
  53. },
  54. // 获取参数
  55. "getData" : function($this){
  56. var _this = this;
  57. var that = $this.parents('form.submit_area');
  58. var data = {};
  59. data.ControlSwitch = true;
  60. that.find('input').each(function () {
  61. var name = $(this).attr('name');
  62. if(typeof name == 'string'){
  63. var txt = $(this).val();
  64. var InputName = $(this).attr('name');
  65. txt = _this.FilterHTMLTag(txt);
  66. if(InputName == 'mobile'){
  67. if(txt != ""){
  68. if(! _this.PhoneVerification(txt)){
  69. _this.hint('请输入正确的手机号码!');
  70. data.ControlSwitch = false;
  71. return false;
  72. }
  73. }else {
  74. _this.hint('电话号码不能为空!');
  75. data.ControlSwitch = false;
  76. return false;
  77. }
  78. }
  79. data[InputName]=txt;
  80. }
  81. })
  82. return data;
  83. },
  84. //过滤代码标签
  85. "FilterHTMLTag" : function(htmlStr){
  86. var msg = htmlStr.replace(/<\/?[^>]*>/g, '');
  87. return msg;
  88. },
  89. //电话验证
  90. "PhoneVerification" : function (tel) {
  91. var pattern = /(13\d|14[57]|15[^4,\D]|17[678]|18\d)\d{8}$|170[059]\d{7}$/,
  92. str = tel;
  93. return pattern.test(tel);
  94. },
  95. //提示
  96. "hint":function(txt){
  97. if($('body .alert-container')){
  98. $('body .alert-container').remove();
  99. }
  100. var M = {};
  101. if(M.dialog1){
  102. return M.dialog1.show();
  103. }
  104. M.dialog1 = jqueryAlert({
  105. 'content' : txt,
  106. 'closeTime' : 2000,
  107. })
  108. },
  109. }