---vivi-file-Type-application/javascript---// ajaxPagination v1.0.0 // Copyright by 小雷 (function ( $ ) { $.fn.getCode = function( options ) { var btn = this; var $data = this.data(); var opt = $.extend({ targetMobile: $data.targetMobile || "", //targetCode: $data.targetCode || "", time: $data.time || 60, url: $data.url || "", captcha: $data.captcha || false, captchaImg: $data.captchaImg || "", captchaParam: $data.captchaParam || "code", }, options ); $(opt.targetMobile).on("input keyup",function() { var mobile = $(this).val() if(/^0?1[34578]\d{9}$/.test(mobile)){ btn.prop("disabled",false) }else{ btn.prop("disabled",true) } }) function getCode(data,dialog){ $.ajax({ url: opt.url, data: data, Type: "POST", dataType: "json", error: function(r,s){ var error = ""+r.status+" "+r.statusText; notify.error(error) }, success: function (e) { if(e.code == 1){ var success = notify.alert('', function(){}) setTimeout(function () { success.modal('hide') },2000) var w = btn.outerWidth() var title = btn.html() btn.css("width",w) btn.prop("disabled", true) setTimeout(function () { dialog.modal("hide") var time = opt.time var wait = setInterval(function () { btn.html(time); if(time == 0){ clearInterval(wait); btn.prop("disabled", false) btn.html(title) } time--; },1000) },800) }else{ var alert = notify.alert('', function(){ if(e.code == 2){ // var src = $(".notify-captcha .captcha-img").attr("src") // $(".notify-captcha .captcha-img").removeAttr("src") $(".notify-captcha .form-group").addClass("has-error") $(".notify-captcha input").val("") setTimeout(function() { $(".notify-captcha input").focus() }, 500); } }) } } }) } btn.on("click",function(){ var captchaValid = false if(opt.captcha == true){ var dialog = notify.dialog({ message: '

华体会体育·hth首页-官方网站图片验证码

'+ '

请输入图片验证码,获取手机验证码。

'+ '
'+ '
'+ ''+ '
'+ '
'+ '
' , closeButton: false, onEscape: false, className:"notify-captcha", buttons: { sendCode: { label: "发送验证码", className: 'btn-send btn-ok btn-primary', diasbled: true, callback: function(e){ if(!captchaValid) { $(".notify-captcha input").focus() $(".notify-captcha .form-group").addClass("has-error") return false; } var codeData = {} if(opt.targetMobile) codeData[$(opt.targetMobile).attr("name")] = $(opt.targetMobile).val() codeData[opt.captchaParam] = $(".notify-captcha input").val() getCode(codeData,dialog) return false; } }, cancel: { label: "取消", className: 'btn-cancel btn-default', callback: function(){ } }, } }) } else { var codeData = {} codeData[$(opt.targetMobile).attr("name")] = $(opt.targetMobile).val() getCode(codeData) } // $(".notify-captcha .captcha-img").on("click",function () { // var captcha = $(this).find("img") // var src = captcha.attr("src") // captcha.removeAttr("src").attr("src",src) // }) $(".notify-captcha .captcha-input").on("input keyup",function () { var v = $(this).val() if(v.length == 4){ $(this).closest(".form-group").removeClass("has-error") captchaValid = true }else{ $(this).closest(".form-group").addClass("has-error") captchaValid = false } }) }) }; if($("[data-toggle='getCode']").length > 0) $("[data-toggle='getCode']").getCode(); }(jQuery));