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)文章
VUE中如何優(yōu)雅實(shí)現(xiàn)爺孫組件的數(shù)據(jù)通信
所謂祖孫組件,也就是3層嵌套的組件,下面這篇文章主要給大家介紹了關(guān)于VUE中如何優(yōu)雅實(shí)現(xiàn)爺孫組件的數(shù)據(jù)通信的相關(guān)資料,需要的朋友可以參考下2022-04-04
Vue組件庫ElementUI實(shí)現(xiàn)表格加載樹形數(shù)據(jù)教程
這篇文章主要為大家詳細(xì)介紹了Vue組件庫ElementUI實(shí)現(xiàn)表格加載樹形數(shù)據(jù)教程,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2021-06-06
Vue項(xiàng)目中接口調(diào)用的詳細(xì)講解
應(yīng)公司需求,接口需要對接vue,記錄一下碰到的問題,下面這篇文章主要給大家介紹了關(guān)于Vue項(xiàng)目中接口調(diào)用的詳細(xì)講解,文中通過實(shí)例代碼介紹的非常詳細(xì),需要的朋友可以參考下2022-07-07
Vue.js實(shí)現(xiàn)無限加載與分頁功能開發(fā)
這篇文章主要為大家詳細(xì)介紹了Vue.js實(shí)現(xiàn)無限加載與分頁功能開發(fā)實(shí)踐,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2016-11-11
Vue使用Three.js創(chuàng)建交互式3D場景的全過程
在現(xiàn)代Web開發(fā)中,通過在頁面中嵌入3D場景,可以為用戶提供更加豐富和交互性的體驗(yàn),Three.js是一款強(qiáng)大的3D JavaScript庫,它簡化了在瀏覽器中創(chuàng)建復(fù)雜3D場景的過程,本文將介紹如何在Vue中使用Three.js,創(chuàng)建一個(gè)簡單的交互式3D場景,需要的朋友可以參考下2023-11-11
Vue項(xiàng)目自動轉(zhuǎn)換 px 為 rem的實(shí)現(xiàn)方法
這篇文章主要介紹了Vue項(xiàng)目自動轉(zhuǎn)換 px 為 rem的實(shí)現(xiàn)方法,本文是通過一系列的配置后,轉(zhuǎn)換成熱門,具體內(nèi)容詳情大家跟隨小編一起通過本文學(xué)習(xí)吧2018-10-10

