发布时间:2023-05-17 10:30
本文实例为大家分享了微信小程序实现验证码倒计时的具体代码,供大家参考,具体内容如下
wxml代码:
js代码:
const app = getApp() Page({ /** * 页面的初始数据 */ data: { countdown: 60, isShow:true }, //倒计时 count:function(that){ var interval = setInterval(function () { var countdown = that.data.countdown; if (countdown == 0) { that.setData({ isShow: true, countdown: 60 }) clearInterval(interval) } else { countdown--; that.setData({ isShow: false, countdown: countdown }) } }, 1000) }, //设置手机号 shj: function (e) { this.setData({ tel: e.detail.value }) }, //获取验证码 send: function () { var that=this; wx.showToast({ title: \'验证码发送成功\', icon: \'none\', duration: 1000, success: function () { that.count(that) } }) }, //登录 denglu:function(e){ console.log(e.detail.value) }, /** * 生命周期函数--监听页面加载 */ onLoad: function (options) { }, })
wxss代码:
.list{ background-color: white; font-size: 32rpx; padding: 20rpx 30rpx; display: flex; justify-content: space-between; align-content: center; align-items: center } .border{ border-top: 1rpx solid #f4f4f4 } .left{ display: flex; align-content: center; align-items: center } .left>label{ width: 140rpx } .left>input{ font-size: 30rpx } .right{ width:240rpx; text-align: right; color: #ff9900; font-size: 30rpx } .send{ background-color: #3296fa; color: white; line-height: 60rpx; font-size: 30rpx; border-radius: 0; padding-left: 0; padding-right: 0 } .btn{ background-color: #3296fa; color: white; line-height: 90rpx; font-size: 32rpx; border-radius: 0; margin-top: 100rpx; }
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持脚本之家。