applyVerify.min.js 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  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. var searchurl = urlstr.substring(0,urlstr.indexOf('?')+1);
  14. // var matchdata = urlstr.match(/\.com(\/\w+)/)[1];
  15. var i = e.CORID, //ID
  16. _url = '/enroll/signup', //提交地址
  17. _post = "POST", //提交方式
  18. _async = true;
  19. $('.'+ i).on('click',function(){
  20. var $this = $(this);
  21. var _getData = _this.getData($this);
  22. if(_getData.ControlSwitch){
  23. $.ajax({type:_post,url:_url,data:_getData,async:_async,dataType:'json',
  24. error : function(request) {
  25. if(fnEnd){
  26. if(typeof fnEnd === 'object'){fnEnd.error();}
  27. }else{
  28. _this.hint('未提交成功!');
  29. }
  30. },
  31. success : function(data) {
  32. if(data.code == 200){
  33. if(fnEnd){
  34. if(typeof fnEnd === 'object'){
  35. fnEnd.success();
  36. }else{
  37. fnEnd();
  38. }
  39. }else{
  40. _this.hint(data.msg);
  41. }
  42. }else if(data.code == 300){
  43. _this.hint(data.msg);
  44. }
  45. }
  46. });
  47. event.preventDefault();
  48. return false;
  49. }
  50. })
  51. },
  52. // 获取参数
  53. "getData" : function($this){
  54. var _this = this;
  55. var that = $this.parents('form.submit_area');
  56. var data = {};
  57. data.ControlSwitch = true;
  58. that.find('input').each(function () {
  59. var name = $(this).attr('name');
  60. if(typeof name == 'string'){
  61. var txt = $(this).val();
  62. var InputName = $(this).attr('name');
  63. txt = _this.FilterHTMLTag(txt);
  64. if(InputName == 'mobile'){
  65. if(txt != ""){
  66. if(! _this.PhoneVerification(txt)){
  67. _this.hint('请输入正确的手机号码!');
  68. data.ControlSwitch = false;
  69. return false;
  70. }
  71. }else {
  72. _this.hint('电话号码不能为空!');
  73. data.ControlSwitch = false;
  74. return false;
  75. }
  76. }
  77. data[InputName]=txt;
  78. }
  79. })
  80. return data;
  81. },
  82. //过滤代码标签
  83. "FilterHTMLTag" : function(htmlStr){
  84. var msg = htmlStr.replace(/<\/?[^>]*>/g, '');
  85. return msg;
  86. },
  87. //电话验证
  88. "PhoneVerification" : function (tel) {
  89. var pattern = /(13\d|14[57]|15[^4,\D]|17[678]|18\d)\d{8}$|170[059]\d{7}$/,
  90. str = tel;
  91. return pattern.test(tel);
  92. },
  93. //提示
  94. "hint":function(txt){
  95. if($('body .alert-container')){
  96. $('body .alert-container').remove();
  97. }
  98. var M = {};
  99. if(M.dialog1){
  100. return M.dialog1.show();
  101. }
  102. M.dialog1 = jqueryAlert({
  103. 'content' : txt,
  104. 'closeTime' : 2000,
  105. })
  106. },
  107. }