123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114 |
- /*
- * 2020.5.4
- * 对报名提交方法进行改进,此报名文件以后不能在这里添加其它的方法函数,
- * 如需要添加时,在调时进行添加即可,添加调用的格式请参考 ShowDoc 在线文档内有标明调用的方法格式
- */
- /*·······································································*/
- var PublicAction = {
- /* AjaxSend-----Ajax发送*/
- "AjaxSend" :function(e,fnEnd){
- var _this = this, result;
- // 获取
- var urlstr = window.location.href;
- var searchurl = urlstr.substring(0,urlstr.indexOf('?')+1);
- // var matchdata = urlstr.match(/\.com(\/\w+)/)[1];
- var i = e.CORID, //ID
- _url = '/enroll/signup', //提交地址
- _post = "POST", //提交方式
- _async = true;
- $('.'+ i).on('click',function(){
- var $this = $(this);
- var _getData = _this.getData($this);
- if(_getData.ControlSwitch){
- $.ajax({type:_post,url:_url,data:_getData,async:_async,dataType:'json',
- error : function(request) {
- if(fnEnd){
- if(typeof fnEnd === 'object'){fnEnd.error();}
- }else{
- _this.hint('未提交成功!');
- }
- },
- success : function(data) {
- if(data.code == 200){
- if(fnEnd){
- if(typeof fnEnd === 'object'){
- fnEnd.success();
- }else{
- fnEnd();
- }
- }else{
- _this.hint(data.msg);
- }
- }else if(data.code == 300){
- _this.hint(data.msg);
- }
- }
- });
- event.preventDefault();
- return false;
- }
- })
- },
- // 获取参数
- "getData" : function($this){
- var _this = this;
- var that = $this.parents('form.submit_area');
- var data = {};
- data.ControlSwitch = true;
- that.find('input').each(function () {
- var name = $(this).attr('name');
- if(typeof name == 'string'){
- var txt = $(this).val();
- var InputName = $(this).attr('name');
- txt = _this.FilterHTMLTag(txt);
- if(InputName == 'mobile'){
- if(txt != ""){
- if(! _this.PhoneVerification(txt)){
- _this.hint('请输入正确的手机号码!');
- data.ControlSwitch = false;
- return false;
- }
- }else {
- _this.hint('电话号码不能为空!');
- data.ControlSwitch = false;
- return false;
- }
- }
- data[InputName]=txt;
- }
- })
- return data;
- },
- //过滤代码标签
- "FilterHTMLTag" : function(htmlStr){
- var msg = htmlStr.replace(/<\/?[^>]*>/g, '');
- return msg;
- },
- //电话验证
- "PhoneVerification" : function (tel) {
- var pattern = /(13\d|14[57]|15[^4,\D]|17[678]|18\d)\d{8}$|170[059]\d{7}$/,
- str = tel;
- return pattern.test(tel);
- },
- //提示
- "hint":function(txt){
- if($('body .alert-container')){
- $('body .alert-container').remove();
- }
- var M = {};
- if(M.dialog1){
- return M.dialog1.show();
- }
- M.dialog1 = jqueryAlert({
- 'content' : txt,
- 'closeTime' : 2000,
- })
- },
- }
|