#1.點擊- >取得驗證碼呼叫後端取得驗證碼api介面
2.驗證碼59秒倒數
3.重複點選取得驗證碼,判斷驗證碼倒數計時是否大於0:
如果大於0,取得驗證碼按鈕不可觸碰
#如果等於0,取得驗證碼呼叫後端取得驗證碼api介面
var serverUrl = app.globalData.serverUrl; // 调用后端发送验证码 uni.request({ method: "POST", url: serverUrl + "/passport/getSMSCode?mobile=" + mobile, success(result) { var status = result.data.status; if (status != 200) { uni.showToast({ title: result.data.msg, icon: "none" }); } // 开始倒数60秒限制 if(me.codeTimes == 0) { me.doTimer(59); } } }); }, // 发送验证码的倒计时方法 doTimer(times) { var me = this; // 倒计时定时器 var sendCodeBtnFunction = function(){ var left = times--; if (left <= 0) { me.codeTouched = false; me.codeBtnText = "发送验证码"; clearInterval(smsTimer); } else { me.codeBtnText = left + "s"; } me.codeTimes = left; }; var smsTimer = setInterval(sendCodeBtnFunction, 1000); },
#3.2. 攔截器新增
#7 .返回驗證碼
以上是Java與JavaScript前後端怎麼實現手機號碼驗證碼一鍵註冊登陸的詳細內容。更多資訊請關注PHP中文網其他相關文章!