applyVerify.upgrade.js 3.3 KB

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