獲取驗證碼,倒數讀秒demo

sentYzm() {

? if (this.loginUser.email) {

? ? if (/^[a-zA-Z0-9_.-]+@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)*\.[a-zA-Z0-9]{2,6}$/.test(this.loginUser.email)) {

? ? ? let t;

? ? ? let that = this

? ? ? clearInterval(t)

? ? ? ? this.$axios.post('http://192.168.0.167:8084/risk/sm', {

? ? ? ? ? account: this.loginUser.email,

? ? ? ? ? type:0

? ? ? ? }).then((msg) => {

? ? ? ? ? console.log(msg.data)

? ? ? ? ? if (msg.data.code != 10002){

? ? ? ? ? ? console.log('msg.code != 0')

? ? ? ? ? }else {

? ? ? ? ? ? this.timesType=true

? ? ? ? ? ? t = setInterval(function () {

? ? ? ? ? ? ? if (that.times == 0) {

? ? ? ? ? ? ? ? that.timesType=false

? ? ? ? ? ? ? ? clearInterval(t)

? ? ? ? ? ? ? ? that.times = 60

? ? ? ? ? ? ? ? that.yzmTimes = '重新發送'

? ? ? ? ? ? ? ? return

? ? ? ? ? ? ? }

? ? ? ? ? ? ? that.times--

? ? ? ? ? ? ? that.yzmTimes = '剩余時間' + that.times + ' s'

? ? ? ? ? ? }, 1000)

? ? ? ? ? ? console.log('發送郵件成功,請留意郵箱!')

? ? ? ? ? }

? ? ? ? })

? ? }

? }

},

?著作權歸作者所有,轉載或內容合作請聯系作者
平臺聲明:文章內容(如有圖片或視頻亦包括在內)由作者上傳并發布,文章內容僅代表作者本人觀點,簡書系信息發布平臺,僅提供信息存儲服務。

推薦閱讀更多精彩內容