微信小程序?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({ ? ? /** ? ?* 頁(yè)面的初始數(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)聽(tīng)頁(yè)面加載 ? ?*/ ? 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; }
以上就是本文的全部?jī)?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í)
- 微信小程序的注冊(cè)頁(yè)面包含倒計(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)簡(jiǎn)單驗(yàn)證碼倒計(jì)時(shí)
相關(guān)文章
微信小程序 wx.getUserInfo引導(dǎo)用戶授權(quán)問(wèn)題實(shí)例分析
這篇文章主要介紹了微信小程序 wx.getUserInfo引導(dǎo)用戶授權(quán)問(wèn)題,結(jié)合實(shí)例形式分析了微信小程序使用wx.getUserInfo引導(dǎo)用戶授權(quán)問(wèn)題的具體操作步驟與實(shí)現(xiàn)方法,需要的朋友可以參考下2020-03-03javascript 網(wǎng)頁(yè)進(jìn)度條簡(jiǎn)單實(shí)例
這篇文章主要介紹了javascript 網(wǎng)頁(yè)進(jìn)度條簡(jiǎn)單實(shí)例的相關(guān)資料,需要的朋友可以參考下2017-02-02javascript監(jiān)聽(tīng)頁(yè)面刷新和頁(yè)面關(guān)閉事件方法詳解
本文主要介紹了javascript監(jiān)聽(tīng)頁(yè)面刷新和頁(yè)面關(guān)閉事件的方法,具有一定的參考價(jià)值,下面跟著小編一起來(lái)看下吧2017-01-01微信小程序前后端數(shù)據(jù)交互的詳細(xì)圖文教程
這篇文章主要給大家介紹了關(guān)于微信小程序前后端數(shù)據(jù)交互的相關(guān)資料,通過(guò)小程序向后端發(fā)送請(qǐng)求,然后后端從數(shù)據(jù)庫(kù)獲取車源和求購(gòu)的數(shù)量反饋給小程序,最后將這兩個(gè)數(shù)據(jù)顯示出來(lái),需要的朋友可以參考下2022-10-10uni-app網(wǎng)絡(luò)請(qǐng)求、數(shù)據(jù)緩存實(shí)例詳解
這篇文章主要介紹了uni-app網(wǎng)絡(luò)請(qǐng)求、數(shù)據(jù)緩存的相關(guān)知識(shí),本文通過(guò)實(shí)例代碼給大家講解的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2022-11-11JavaScript聲明變量的這四兄弟(var、let、function、const)
這篇文章主要介紹了JavaScript聲明變量的這四兄弟,主要就是介紹var、let、function、const區(qū)別,需要的朋友可以參考下2023-02-02