直接贴代码:

HTML

<div class="phone">
<div class="number">
<p class="tip">手机号码<span style="color: #ff0000;">*</span></p>
<input type="number" class="info" :placeholder="question.prompt_content" v-model="phoneObj"/>
</div>
<div class="number">
<p class="tip">&nbsp;</p>
<input type="number" class="checkPhone" placeholder="请输入验证码" v-model="checkNumberObj"/>
<button :disabled="fetchCodeMsg || false" class="getCheckNumber" :class="{unselected: fetchCodeMsg}" @click="getCheckNumber(question.question_id)">{{timerCodeMsg||'获取验证码'}}</button>
</div>
</div>

CSS

.number{
height: torem(100px);
line-height: torem(100px);
padding-left: torem(20px);
position: relative;
float: left;
width: %;
border-bottom: 1px solid #dddddd;
.unselected{
background-color: #cccccc !important;
}

      .tip{
        font-size: torem(28px);
        color: #000000;
        width: torem(260px);
        position: relative;
        float: left;
        overflow: hidden;
        white-space: nowrap;
        text-overflow: ellipsis;
      }

      .info{
        font-size: torem(28px);
        color: #000000;
        width: torem(450px);
      }

      .checkPhone{
        width: torem(220px);
        font-size: torem(28px);
        color: #000000;
        padding-right: torem(30px);
      }

        .getCheckNumber{
width: torem(180px);
height: torem(54px);
color: #ffffff;
background-color: #2E97DD;
font-size: torem(28px);
position: relative;
float: right;
border-radius: torem(6px);
text-align: center;
line-height: torem(54px);
margin-top: torem(24px);
margin-right: torem(30px);
}
}

JS

data(){

  return {

    phoneObj: '',             // phoneOb

    timerCodeMsg: '',         // timerCodeMsg

    fetchCodeMsg: '',         // fetchCodeMsg

  }

}

    getCheckNumber () {
let newPhone = this.phoneObj
if (!(/^[]\d{}$/.test(newPhone))) {
Toast('手机号码有误,请重填')
return false
} else {
this.$root._axios('post', 'CheckCodeApi/sendSmSodeReserve', {phone: newPhone})
.then(res => {
if (res.data.errcode === ) {
let sec =
for (let i = ; i <= ; i++) {
window.setTimeout(() => {
if (sec != ) {
this.timerCodeMsg = sec + '秒后重发'
this.fetchCodeMsg = true
sec--
} else {
sec = // 如果倒计时结束就让 获取验证码显示出来
this.timerCodeMsg = '重新发送'
this.fetchCodeMsg = false
}
}, i * )
}
}
})
}
}

vue 短信验证的更多相关文章

  1. vue短信验证性能优化写入localstorage中

    平时我们在项目中进行注册等的时候,会经常用到短信验证的功能,但是现在现在很多短信验证都是存在下面几个问题,例如短信验证时间为60s的时候, 1. 当点击完按钮时,倒计时还没到60s过完时,刷新浏览器, ...

  2. Luffy之注册认证(容联云通讯短信验证)

    用户的注册认证 前端显示注册页面并调整首页头部和登陆页面的注册按钮的链接. 注册页面Register,主要是通过登录页面进行改成而成. 先构造前端页面 <template> <div ...

  3. 注册登录页面修订-Python使用redis-手机验证接口-发送短信验证

    登录页面修订 views.Login.vue <template> <div class="login box"> <img src="@/ ...

  4. Mob.com 短信验证的简单使用

    1.环境配置 http://wiki.sharesdk.cn/android-短信sdk集成文档/ a.sdk下载 http://www.mob.com/#/downloadDetail/SMS/an ...

  5. python基于LeanCloud的短信验证

    python基于LeanCloud的短信验证 1. 获取LeanCloud的Id.Key 2. 安装Flask框架和Requests库 pip install flask pip install re ...

  6. thinkphp实现短信验证注册

    前言 注册时经常需要用到短信验证码,本文记录一下思路和具体实现. 短信验证平台使用云片,短信验证码的生成使用thinkphp. 思路 1.用户输入手机号,请求获取短信验证码. 2.thinkphp生成 ...

  7. Mob短信验证的具体使用

    原文著作权地址:http://www.jb51.net/article/84946.htm demo地址:http://git.oschina.net/lizhanqi/MobSMSDemo 一.前言 ...

  8. Mob短信验证的配置的解释

    原文地址:http://www.jb51.net/article/84946.htm 关于mob短信验证的解释: mob官方是这样写的: repositories{ flatDir{ dirs 'li ...

  9. 完整的Android手机短信验证源码

    短信验证功能我分两个模块来说,短信验证码的后台和代码实现短信验证码的功能. 一.短信验证码的后台      1.注册Mob账号:http://www.mob.com/#/login 2.注册成功之后, ...

随机推荐

  1. java操作elasticsearch实现查询删除和查询所有

    后期博客本人都只给出代码,具体的说明在代码中也有注释. 1.查询删除 //查询删除:将查询到的数据进行删除 @Test public void test8() throws UnknownHostEx ...

  2. JavaScript显示文本框后自动获取焦点

    废话少说,见官方文档: 他的用法是:document.getElementById('username').focus();                   这样写在display:block;显 ...

  3. python 反射、md5加密

    一.issubclass,type,isinstance 1.issubclass :判断xx类是否是yyy类型(包括子类),用于类之间的判定 class GrandF: pass class Fat ...

  4. [docker][win10]安装的坑

    右键这个小图标,先signin,注意这里是ID 不是邮箱   image.png 可能starting 时候就报错说 “Containers feature is not enabled” 或者   ...

  5. Linux之命令初识

    Linux与windows目录结构对比 命令mkdir.ls.ls -l.cd .pwd [root@oldboyedu-01 ~]# #创建目录 make directory mkdir [root ...

  6. 7.01-beautiful_soup

    # pip install beautifulsoup4 from bs4 import BeautifulSoup html_doc = """ <html> ...

  7. (4)HomeAssistant 语言控制

    中文教程:https://www.hachina.io/docs/2073.html 英文网教程:https://www.home-assistant.io/components/conversati ...

  8. Spring Security(十一):4. Samples and Guides (Start Here)

    If you are looking to get started with Spring Security, the best place to start is our Sample Applic ...

  9. mysql远程连接 Host * is not allowed to connect to this MySQL server

    mysql -u root -p mysql>use mysql; mysql>update user set host =’%'where user =’root’; mysql> ...

  10. linux安装jdk1.8(rpm方式)

    在Oracle官网下载64位的jdk1.8版本 jdk1.8: http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloa ...