欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

微信小程序?qū)崿F(xiàn)驗證碼倒計時

 更新時間:2022年05月24日 09:02:29   作者:小丫么小菜菜  
這篇文章主要為大家詳細介紹了微信小程序?qū)崿F(xiàn)驗證碼倒計時,文中示例代碼介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們可以參考一下

本文實例為大家分享了微信小程序?qū)崿F(xiàn)驗證碼倒計時的具體代碼,供大家參考,具體內(nèi)容如下

wxml代碼:

<view class='container'>
? <form bindsubmit='denglu'>
? ? <view class='list'>
? ? ? <view class='left'>
? ? ? ? <label>手機號:</label>
? ? ? ? <input type='number' name="tel" bindinput='shj' maxlength='11' placeholder='請輸入手機號'></input>
? ? ? </view>
? ? ? <view class='right'></view>
? ? </view>
? ? <view class='list border'>
? ? ? <view class='left'>
? ? ? ? <label>驗證碼:</label>
? ? ? ? <input type='number' name="code" placeholder='請輸入驗證碼'></input>
? ? ? </view>
? ? ? <view class='right'>
? ? ? ? <button class='send' wx:if="{{isShow}}" catchtap='send'>發(fā)送驗證碼</button>
? ? ? ? <button class='send' disabled='{{true}}' wx:else>{{countdown}}秒后重新發(fā)送</button>
? ? ? </view>
? ? </view>
? ? <button form-type='submit' class='btn'>登錄</button>
? </form>
</view>

js代碼:

const app = getApp()
Page({
?
? /**
? ?* 頁面的初始數(shù)據(jù)
? ?*/
? 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: '驗證碼發(fā)送成功',
? ? ? icon: 'none',
? ? ? duration: 1000,
? ? ? success: function () {
? ? ? ? that.count(that)
? ? ? }
? ? })
? },?
? //登錄
? denglu:function(e){
? ? ?console.log(e.detail.value)
? },
? /**
? ?* 生命周期函數(shù)--監(jiān)聽頁面加載
? ?*/
? 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;
}

以上就是本文的全部內(nèi)容,希望對大家的學習有所幫助,也希望大家多多支持腳本之家。

相關文章

最新評論