验证码(倒计时)
来源:互联网 发布:java考试系统源代码 编辑:程序博客网 时间:2024/06/04 00:42
<!--验证码 --> <form bindsubmit='regist'> <view class='input-container'> <input type='text' placeholder='验证码' name="vertifyCode" value='{{verifyCode}}'></input> <button class='captcha' bindtap='captcha' disabled='{{captchaDisable}}' plain='true'>{{captchaLabel}}</button> </view> </form>
/*文本框容器*/.input-container{ margin: 20px 30px; display: flex; flex-direction: row; justify-content: space-between; align-items: center; border-bottom: 1px solid #ddd;padding-bottom: 3px;}/*提交按钮*/form button{margin: 30px;background: #09f;color: white;}/*文本框本身*/.input-container input {color: #999;flex: 1; height: 40px;}/*占位符样式*/.input-placeholder {color: #999;}/*清空按钮*/.input-container image {width: 22px;height: 22px;}/*获取验证码*/.captcha {margin: 0 4px;color: #fff;font-size: 14px;}button[plain] {color: peru;border: 0;}button[plain][disabled] {color: gray;background: transparent;}
//js文件
data: { captchaLabel:"获取验证码", seconds:10, captchaDisable:false, vertifyCode:'' }, //短信验证码点击 captcha:function(){ console.log('click') this.setData({ captchaDisable:true }) // 立刻显示重发提示,不必等待倒计时启动 this.setData({ captchaLabel: timer.length + '秒后重新发送' }); // 启动以1s为步长的倒计时 var interval = setInterval(() => { timer.countdown(this); }, 1000); // 停止倒计时 setTimeout(function () { clearInterval(interval); }, timer.length * 1000); //提示 if (timer.length == this.data.seconds){ wx.showToast({ title: '发送成功' }) }
timer.js
var length = 10;function countdown(that) { console.log('count down'); var seconds = that.data.seconds; console.log(seconds); var captchaLabel = that.data.captchaLabel; if (seconds <= 1) { captchaLabel = '获取验证码'; seconds = length; that.setData({ captchaDisable: false }); } else { captchaLabel = --seconds + '秒后重新发送' } that.setData({ seconds: seconds, captchaLabel: captchaLabel });}module.exports = { countdown: countdown, length: length}
阅读全文
0 0
- 获取验证码倒计时
- 短信验证码倒计时
- 验证码倒计时效果
- 验证码倒计时发送
- Android验证码倒计时
- JS验证码倒计时
- 验证码倒计时函数
- 验证码倒计时代码
- 验证码倒计时
- 验证码倒计时
- ios 验证码倒计时
- Android 验证码倒计时
- Android验证码倒计时
- 获取验证码倒计时
- 验证码倒计时
- 验证码倒计时 实现
- ios 验证码倒计时
- 验证码倒计时
- MongoDB中对数组元素进行查询
- Android属性动画简单实现图片的伸缩
- 笨方法学习Python-习题22:到现在你学到了哪些东西?
- 要把鸡肋变排骨?马云之后刘强东也做无人超市
- NSMutableAttributedString文本样式设置以及富文本展示
- 验证码(倒计时)
- mybatis,XMl文件判断条件出错
- http://www.3edu.net/ 3edu教育网
- Flask Web中的 url_for 函数
- TOP100summit:【分享实录】Twitter 新一代实时计算平台Heron
- python使用pip安装SciPy、SymPy、matplotlib
- leetcode 355. Design Twitter
- Redis安装及主从配置
- 根据json生成建表语句