vue實(shí)現(xiàn)通過手機(jī)號發(fā)送短信驗(yàn)證碼登錄的示例代碼
本文主要介紹了vue實(shí)現(xiàn)通過手機(jī)號發(fā)送短信驗(yàn)證碼登錄的示例代碼,分享給大家,具體如下:

<template>
<div class="get-mobile" @touchmove.prevent>
<div class="main">
<div class="pt-20 pr-15 pl-15 pb-20">
<input class="input mb-15" v-model="form.tel" placeholder="請輸入手機(jī)號" type="number">
<div class="box">
<input class="input" v-model="form.telVerificationCode" placeholder="請輸入短信驗(yàn)證碼" type="number">
<div class="el-button" @click="send">{{ countDown }}</div>
</div>
</div>
<div class="btn" @click="sumbit">提交</div>
</div>
</div>
</template>
<script>
import { sendLoginMsgCode, login } from 'xx';
export default {
name: 'GetMobile',
data() {
return {
form: {
telVerificationCode: '',
tel: '',
},
countDown: "發(fā)送驗(yàn)證碼", // 倒計(jì)時(shí)
bVerification: false // 節(jié)流
}
},
methods: {
async sumbit() {
const { telVerificationCode, tel } = this.form
if (!telVerificationCode || !tel) return this.$toast("請輸入手機(jī)號和驗(yàn)證碼");
let { code, data } = await login({
tel,
telVerificationCode,
isOffline: false
});
if (code === 200) {
this.$toast('登錄成功');
this.$emit('sumbit', data.userInfo);
this.$emit('update:dialog', false)
}
},
async send() {
if (!/^\d{11}$/.test(this.form.tel)) return this.$toast("請先輸入正確的手機(jī)號");
if (this.bVerification) return;
this.bVerification = true;
const { code } = await sendLoginMsgCode({
tel: this.form.tel
});
if (code === 200) {
this.$toast("發(fā)送驗(yàn)證碼...");
}
let countDown = 59;
const auth_time = setInterval(() => {
this.countDown = countDown--;
if (this.countDown <= 0) {
this.bVerification = false;
this.countDown = "發(fā)送驗(yàn)證碼";
clearInterval(auth_time);
}
}, 1000);
}
}
}
</script>
<style lang='scss' scoped>
.get-mobile {
height: 100vh;
width: 100vw;
background-color: rgba(0, 0, 0, .6);
display: flex;
justify-content: center;
align-items: center;
.main {
width: 280px;
height: 178px;
background: #FFFFFF;
border-radius: 5px;
.input {
border: 1px solid #EBEBEF;
border-radius: 5px;
height: 40px;
padding-left: 10px;
}
.el-button {
margin-left: 10px;
border-radius: 5px;
background: #5F93FD;
color: #fff;
width: 140px;
display: flex;
justify-content: center;
align-items: center;
}
.btn {
height: 45px;
color: #5F93FD;
display: flex;
justify-content: center;
align-items: center;
border-top: 1px solid #EBEBEF;
}
}
}
</style>
到此這篇關(guān)于vue實(shí)現(xiàn)通過手機(jī)號發(fā)送短信驗(yàn)證碼登錄的示例代碼的文章就介紹到這了,更多相關(guān)vue 驗(yàn)證碼登錄內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
相關(guān)文章
如何在ElementUI的上傳組件el-upload中設(shè)置header
這篇文章主要介紹了如何在ElementUI的上傳組件el-upload中設(shè)置header,具有很好的參考價(jià)值,希望對大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教2022-09-09
關(guān)于Vue中使用alibaba的iconfont矢量圖標(biāo)的問題
這篇文章主要介紹了Vue使用alibaba的iconfont矢量圖標(biāo)的問題,本文通過實(shí)例代碼給大家介紹的非常詳細(xì),對大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2021-12-12
vue+vue-fullpage實(shí)現(xiàn)整屏滾動(dòng)頁面的示例代碼(直播平臺(tái)源碼)
這篇文章主要介紹了vue+vue-fullpage實(shí)現(xiàn)整屏滾動(dòng)頁面,本文通過示例代碼給大家介紹的非常詳細(xì),對大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2022-06-06
Vue?響應(yīng)式系統(tǒng)依賴收集過程原理解析
Vue 初始化時(shí)就會(huì)通過 Object.defineProperty 攔截屬性的 getter 和 setter ,為對象的每個(gè)值創(chuàng)建一個(gè) dep 并用 Dep.addSub() 來存儲(chǔ)該屬性值的 watcher 列表,這篇文章主要介紹了Vue?響應(yīng)式系統(tǒng)依賴收集過程分析,需要的朋友可以參考下2022-06-06
vue+openlayers+nodejs+postgis實(shí)現(xiàn)軌跡運(yùn)動(dòng)效果
使用postgres(postgis)數(shù)據(jù)庫以及nodejs作為后臺(tái),vue和openlayers做前端,openlayers使用http請求通過nodejs從postgres數(shù)據(jù)庫獲取數(shù)據(jù),這篇文章主要介紹了vue+openlayers+nodejs+postgis實(shí)現(xiàn)軌跡運(yùn)動(dòng),需要的朋友可以參考下2024-05-05

