




版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡(jiǎn)介
第微信小程序?qū)崿F(xiàn)驗(yàn)證碼倒計(jì)時(shí)效果本文實(shí)例為大家分享了微信小程序驗(yàn)證碼倒計(jì)時(shí)效果的具體代碼,供大家參考,具體內(nèi)容如下
如果寫過js的倒計(jì)時(shí),那么小程序中使用也是差不多的;
代碼:
data:{
daojishi:60,
inter:''
},
daojishi:function(){
er=setInterval((res)={
this.fun();
},1000);
fun:function(){
lett=this.data.daojishi;
t--;
this.setData({
daojishi:t
})
if(t=0){
//location.href="";
clearInterval(er);
this.setData({
isyanzhengma:true
})
}
},
手機(jī)登錄、填手機(jī)號(hào)獲取驗(yàn)證碼,倒計(jì)時(shí)后重新獲取效果
描述:
輸入正確的手機(jī)號(hào)并且輸入驗(yàn)證碼后,手機(jī)登錄按鈕變?yōu)榧t色可點(diǎn)擊狀態(tài);自動(dòng)驗(yàn)證輸入的手機(jī)號(hào)是否為合法手機(jī)號(hào);點(diǎn)擊獲取動(dòng)態(tài)碼后開始60秒倒計(jì)時(shí)后才可以再次獲取動(dòng)態(tài)碼;
效果圖:
代碼:
html:
view
view手機(jī)快捷登錄/view
view
inputplaceholder="請(qǐng)輸入手機(jī)號(hào)"type='number'maxlength="11"value="{{mobile}}"bindinput='blurPhone'/
textclass="dongtaima{{hui'hui':'red'}}"wx:if="{{isyanzhengma}}"bindtap="dongtaima"獲取動(dòng)態(tài)碼/text
textwx:else重發(fā)({{daojishi}})/text
/view
view
inputplaceholder="請(qǐng)輸入驗(yàn)證碼"value="{[code]}"maxlength="6"bindinput="codetap"
/
/view
viewclass="teldl{{dlno'tou50':''}}"bindtap="teldltap"
text手機(jī)登錄/text
/view
/view
js:
//pages/dltel/dltel.js
import{
sendCode,
mobileLogin
}from"../../utils/requst/api.js";
Page({
/**
*頁(yè)面的初始數(shù)據(jù)
*/
data:{
navbarData:{
isfixed:false,
iswhite:false,//iconcolor
showCapsule:1,//是否顯示左上角圖標(biāo)1表示顯示0表示不顯示
title:'登錄',//導(dǎo)航欄中間的標(biāo)題
backgroundcolor:'#fff',
isintercept:false//返回?cái)r截
},
mobile:'',
code:'',
isyanzhengma:true,
hui:true,
dlno:true,
daojishi:60,
teltrue:false,
inter:'',
//手機(jī)號(hào)驗(yàn)證
blurPhone:function(e){
this.setData({
mobile:e.detail.value
})
letphone=this.data.mobile;
if(!(/^1[34578]\d{9}$/.test(phone))){
this.setData({
teltrue:false,
hui:true,
})
if(phone.length=11){
wx.showToast({
title:'手機(jī)號(hào)有誤',
icon:'none',
duration:2000
})
}
}else{
this.setData({
teltrue:true,
hui:false,
})
console.log('驗(yàn)證成功',this.data.teltrue)
}
dongtaima:function(e){
if(this.data.teltrue!this.data.hui){
letparams={
mobile:this.data.mobile
}
sendCode(params).then((res)={
console.log(res);
if(res.data.msg=='發(fā)送成功!'){
wx.showToast({
title:res.data.msg,
icon:"none",
duration:2000
})
this.setData({
isyanzhengma:false
})
this.daojishi();
}else{
wx.showToast({
title:"發(fā)送失敗,請(qǐng)重發(fā)!",
icon:"none",
duration:2000
})
}
})
}elseif(!this.data.teltrue){
wx.showToast({
title:"請(qǐng)?zhí)顚懻_的手機(jī)號(hào)!",
icon:"none",
duration:2000
})
}
codetap:function(e){
//console.log(e);
this.setData({
code:e.detail.value
})
if(this.data.teltruethis.data.code!=''){
this.setData({
dlno:false
})
}
daojishi:function(){
er=setInterval((res)={
this.fun();
},1000);
fun:function(){
lett=this.data.daojishi;
t--;
this.setData({
daojishi:t
})
if(t=0){
//location.href="";
clearInterval(er);
this.setData({
isyanzhengma:true
})
}
teldltap:function(){
letparams={
code:this.data.code,
mobile:this.data.mobile
}
if(this.data.teltruethis.data.code!=''){
mobileLogin(params).then((res)={
//console.log(params);
//console.log(res);
if(res.data.message=="ok"){//登錄成功修改參數(shù)
//getApp().globalData.token=res.data.data.token;
//getApp().globalData.type=res.data.data.type;
//getApp().globalData.telnum=res.data.data.mobile;
//wx.setStorageSync('token',res.data.data.token);
//wx.setStorageSync('type',res.data.data.type);
//wx.setStorageSync('telnum',res.data.data.mobile);
//letpages=getCurrentPages();//當(dāng)前頁(yè)的數(shù)據(jù),
//letprevPage=pages[pages.length-3];//上上頁(yè)的數(shù)據(jù)
//console.log(pages);
//prevPage.setData({
//token:res.data.data.token,
//type:res.data.data.type,
//telnum:res.data.data.mobile
//})
//wx.navigateBack({
//delta:2
//})
}else{
wx.showToast({
title:res.data.msg,//未成功原因
icon:"none",
duration:2000
})
}
})
}elseif(!this.data.teltrue){
wx.showToast({
title:"請(qǐng)?zhí)顚懻_的手機(jī)號(hào)!",
icon:"none",
duration:2000
})
}else{
wx.showToast({
title:"請(qǐng)?zhí)顚戲?yàn)證碼!",
icon:"none",
duration:2000
})
}
})
css:(less)
@fontcolor:#353535;
@red:#ff2b0a;
.dltel{
position:relative;
width:100%;
height:100vh;
padding:040rpx;
box-sizing:border-box;
.teltit{
font-size:50rpx;
color:@fontcolor;
line-height:90rpx;
margin-top:35rpx;
margin-left:20rpx;
.inpbox{
position:relative;
width:100%;
height:100rpx;
line-height:100rpx;
font-size:28rpx;
color:@fontcolor;
display:flex;
flex-direction:row;
border-bottom:1pxsolid#eee;
.dongtaima{
}
.inpbtn{
width:430rpx;
height:100%;
margin:030rpx;
}
.hui{
color:#888
}
.red{
color:@red;
}
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁(yè)內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫(kù)網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。
最新文檔
- 襄陽收費(fèi)車位管理辦法
- 西平縣流動(dòng)攤位管理辦法
- 訂單信息化系統(tǒng)管理辦法
- 證監(jiān)會(huì)新型犯罪管理辦法
- 財(cái)務(wù)不相容崗位管理辦法
- 質(zhì)量巡檢專家?guī)旃芾磙k法
- 貴州省電力補(bǔ)貼管理辦法
- 資產(chǎn)管理與產(chǎn)權(quán)管理辦法
- 超齡農(nóng)民工用工管理辦法
- 車輛gps日常管理辦法
- 住院醫(yī)師規(guī)范化培訓(xùn)匯報(bào)
- 2025至2030中國(guó)電動(dòng)踏板車行業(yè)項(xiàng)目調(diào)研及市場(chǎng)前景預(yù)測(cè)評(píng)估報(bào)告
- 中國(guó)公安信息化市場(chǎng)前景預(yù)測(cè)及未來發(fā)展趨勢(shì)報(bào)告
- 糧食機(jī)收減損培訓(xùn)課件
- 2025至2030中國(guó)耐腐蝕高溫合金行業(yè)發(fā)展趨勢(shì)分析與未來投資戰(zhàn)略咨詢研究報(bào)告
- 人文關(guān)懷病區(qū)管理制度
- 2025年山西省中考數(shù)學(xué)試卷真題(含標(biāo)準(zhǔn)答案)
- 中華詩(shī)詞大賽1-3年級(jí)題庫(kù)(含答案)
- 中國(guó)軍魂課件
- 油田調(diào)度匯報(bào)管理制度
- 2025至2030中國(guó)汽車線束與連接器行業(yè)發(fā)展趨勢(shì)分析與未來投資戰(zhàn)略咨詢研究報(bào)告
評(píng)論
0/150
提交評(píng)論