微信小程序?qū)崿F(xiàn)驗(yàn)證碼倒計(jì)時(shí)
本文實(shí)例為大家分享了微信小程序?qū)崿F(xiàn)驗(yàn)證碼倒計(jì)時(shí)的具體代碼,供大家參考,具體內(nèi)容如下
wxml代碼:
<view class='container'>
? <form bindsubmit='denglu'>
? ? <view class='list'>
? ? ? <view class='left'>
? ? ? ? <label>手機(jī)號(hào):</label>
? ? ? ? <input type='number' name="tel" bindinput='shj' maxlength='11' placeholder='請(qǐng)輸入手機(jī)號(hào)'></input>
? ? ? </view>
? ? ? <view class='right'></view>
? ? </view>
? ? <view class='list border'>
? ? ? <view class='left'>
? ? ? ? <label>驗(yàn)證碼:</label>
? ? ? ? <input type='number' name="code" placeholder='請(qǐng)輸入驗(yàn)證碼'></input>
? ? ? </view>
? ? ? <view class='right'>
? ? ? ? <button class='send' wx:if="{{isShow}}" catchtap='send'>發(fā)送驗(yàn)證碼</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
? },
? //倒計(jì)時(shí)
? 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)
? },
? //設(shè)置手機(jī)號(hào)
? shj: function (e) {
? ? this.setData({
? ? ? tel: e.detail.value
? ? })
? },
? //獲取驗(yàn)證碼
? send: function () {
? ? var that=this;
? ? wx.showToast({
? ? ? title: '驗(yàn)證碼發(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)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。
- 微信小程序?qū)崿F(xiàn)短信驗(yàn)證碼倒計(jì)時(shí)
- 微信小程序?qū)崿F(xiàn)驗(yàn)證碼倒計(jì)時(shí)效果
- 微信小程序?qū)崿F(xiàn)手機(jī)獲取驗(yàn)證碼倒計(jì)時(shí)60s
- 微信小程序?qū)崿F(xiàn)發(fā)送短信驗(yàn)證碼倒計(jì)時(shí)
- 微信小程序的注冊頁面包含倒計(jì)時(shí)驗(yàn)證碼、獲取用戶信息
- 微信小程序項(xiàng)目實(shí)踐之驗(yàn)證碼倒計(jì)時(shí)功能
- 微信小程序?qū)崿F(xiàn)驗(yàn)證碼獲取倒計(jì)時(shí)效果
- 微信小程序?qū)崿F(xiàn)倒計(jì)時(shí)60s獲取驗(yàn)證碼
- 小程序?qū)崿F(xiàn)簡單驗(yàn)證碼倒計(jì)時(shí)
相關(guān)文章
JS中typeof與instanceof之間的區(qū)別總結(jié)
本文是對(duì)JS中typeof與instanceof之間的區(qū)別進(jìn)行了詳細(xì)的總結(jié)介紹,需要的朋友可以過來參考下,希望對(duì)大家有所幫助2013-11-11
javascript簡單寫的判斷電話號(hào)碼實(shí)例
這篇文章主要介紹了javascript簡單寫的判斷電話號(hào)碼實(shí)例的相關(guān)資料,需要的朋友可以參考下2017-05-05
JS 巧妙獲取剪貼板數(shù)據(jù) Excel數(shù)據(jù)的粘貼
最近需要在瀏覽器端實(shí)現(xiàn)excel數(shù)據(jù)的粘貼,一開始去找獲取剪貼板數(shù)據(jù)的方法。但是在瀏覽器端,JS去取是受安全限制的。2009-07-07
JavaScript導(dǎo)航腳本判斷當(dāng)前導(dǎo)航
這篇文章主要介紹了JavaScript導(dǎo)航腳本判斷當(dāng)前導(dǎo)航的相關(guān)資料,非常不錯(cuò),具有參考借鑒價(jià)值,需要的朋友可以參考下2016-07-07
js使用數(shù)組判斷提交數(shù)據(jù)是否存在相同數(shù)據(jù)
判斷提交數(shù)據(jù)是否存在相同數(shù)據(jù),在本文將為大家介紹使用數(shù)組做到這一點(diǎn),感興趣的朋友可以參考下2013-11-11
Javascript實(shí)現(xiàn)圖片懶加載的示例代碼
最近公司和第三方材料供應(yīng)商對(duì)接開發(fā)了物資集采平臺(tái),其中有個(gè)功能需求需要展示數(shù)百張材料信息圖片,有時(shí)頁面會(huì)出現(xiàn)卡頓的情況,并使用了圖片懶加載的方式進(jìn)行了優(yōu)化,下面把方法分享給大家一起學(xué)習(xí),感興趣的小伙伴跟著小編一起來看看吧2024-12-12

