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

微信小程序項(xiàng)目實(shí)踐之驗(yàn)證碼倒計(jì)時(shí)功能

 更新時(shí)間:2018年07月18日 14:55:00   作者:聽(tīng)著music睡  
這篇文章主要介紹了微信小程序項(xiàng)目實(shí)踐之驗(yàn)證碼倒計(jì)時(shí)功能,當(dāng)用戶點(diǎn)擊發(fā)送驗(yàn)證碼按鈕,按鈕背景變色,不可點(diǎn)擊,顯示倒計(jì)時(shí)文字,需要的朋友可以參考下

效果如下:點(diǎn)擊發(fā)送驗(yàn)證碼按鈕,按鈕背景變色,不可點(diǎn)擊,顯示倒計(jì)時(shí)文字

  首先js文件的data里面 聲明一個(gè)變量用于表示當(dāng)前是否可以點(diǎn)擊,codeIsCanClick = true,  默認(rèn)是可以點(diǎn)擊的

  寫(xiě)下界面代碼:

  wxml文件中

<view class='centerRow'>
 <view class='inputLabel'>動(dòng)態(tài)碼:</view>
 <input class='inputStyle' style="flex:1 " bindinput="bindKeyInput" placeholder="短信動(dòng)態(tài)碼" adjust-position='false'  confirm-type='search'></input>
 <button class="emailCode" hidden='{{!codeIsCanClick}}' size="mini" bindtap='clickCode'>獲取動(dòng)態(tài)碼</button>
 <button class="emailCodeSend" hidden='{{codeIsCanClick}}' size="mini">{{last_time}}秒后重新發(fā)送</button>
</view>

   對(duì)應(yīng)樣式 wxss文件:

.centerRow{
 display: flex;
 flex-direction: row;
 align-items: center;
 height: 44px;
 padding-left: 16px;
 padding-right: 16px;
 border-bottom: 1rpx solid #D9D9D9;
 border-top: 1rpx solid #D9D9D9;
}
.inputStyle{
 border-radius:4px;
 color:#D9D9D9;
 outline:0;
 padding-left: 4px;
 margin-left: 4px;
 margin-right: 20rpx;
 font-size: 14px;
}
.inputLabel{
 font-size: 16px;
 color: #33496D;
 width: 90px;
}
.emailCode{
 width: 118px;
 height: 28px;
 align-items: center;
 justify-content: center;
 display: flex;
 flex-direction: row;
 color:white;
 font-size: 14px;
 background-color: #50A2EC;
 border-radius: 14px;
}
.emailCodeSend{
 width: 118px;
 height: 28px;
 align-items: center;
 justify-content: center;
 display: flex;
 flex-direction: row;
 color:white;
 font-size: 14px;
 background-color: #B9DAF7;
 border-radius: 14px;
}

  以上構(gòu)成頁(yè)面靜態(tài)效果。

  注意button有兩個(gè),分別對(duì)應(yīng)的未點(diǎn)擊和點(diǎn)擊下的按鈕樣子,用js中的CodeIsCanClick控制顯示隱藏

  然后在js中寫(xiě)邏輯代碼:

// 倒計(jì)時(shí)事件 單位s
var countdown = 10;
var settime = function (that) {
 if (countdown == 0) {
 that.setData({
  codeIsCanClick: true
 })
 countdown = 10;
 return;
 } else {
 that.setData({
  codeIsCanClick: false,
  last_time: countdown
 })
 countdown--;
 }
 setTimeout(function () {
 settime(that)
 }, 1000
 )
}
Page({
 /**
 * 頁(yè)面的初始數(shù)據(jù)
 */
 data: {
 codeIsCanClick: true
 },
 /**
 * 點(diǎn)擊驗(yàn)證碼按鈕
 */
 clickCode: function () {
 var that = this;
 settime(that)
 },

總結(jié)

以上所述是小編給大家介紹的微信小程序項(xiàng)目實(shí)踐之驗(yàn)證碼倒計(jì)時(shí)功能,希望對(duì)大家有所幫助,如果大家有任何疑問(wèn)請(qǐng)給我留言,小編會(huì)及時(shí)回復(fù)大家的。在此也非常感謝大家對(duì)腳本之家網(wǎng)站的支持!

相關(guān)文章

最新評(píng)論