1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859 |
- //注册获取验证码
- $("#getverificode").click(function () {
- var mobileValue = $.trim($('#telephone').val());
- if (mobileValue == '') {
- qsToast({type:2,context: '请输入手机号码'});
- return false;
- };
- if (mobileValue != "" && !regularMobile.test(mobileValue)) {
- qsToast({type:2,context: '请输入正确的手机号码'});
- return false;
- }
- $.ajax({
- headers: {'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')},
- url: codeUrl,
- type: 'POST',
- dataType: 'json',
- data: {
- mobile:mobileValue,
- type:1,
- },
- success: function (result) {
- console.log(result);
- // 开始倒计时
- var countdownZZ = 60;
- function settime() {
- if (countdownZZ == 0) {
- $('#getverificode').html('获取验证码');
- $('#getverificode').attr("disabled",false);
- countdownZZ = 100;
- return;
- } else {
- $("#getverificode").css('font-size','18px');
- $('#getverificode').html('重新发送' + countdownZZ + '秒');
- $('#getverificode').attr("disabled",true);
- countdownZZ--;
- }
- setTimeout(function() {
- settime()
- },1000)
- }
- settime();
- },
- error: function (errorData) {
- if (errorData.status==422) {//验证错误;
- $.each(errorData.responseJSON.errors,function (key,val) {
- qsToast({type:2,context: val[0]});
- });
- }
- else if(errorData.status==400) {//业务错误
- qsToast({type:2,context:errorData.responseJSON.message});
- }
- }
- })
- });
|