最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

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

 更新時間:2022年05月24日 10:03:53   作者:幽幽靖  
這篇文章主要介紹了微信小程序?qū)崿F(xiàn)驗證碼倒計時效果,手機登錄、填手機號獲取驗證碼,倒計時后重新獲取效果,文中示例代碼介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們可以參考一下

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

如果寫過js的倒計時,那么小程序中使用也是差不多的;

代碼:

data: {
? ?? ?daojishi:60,
?? ?inter:''
?? ?},
? daojishi: function () {
? ? this.data.inter = setInterval((res) => {
? ? ? this.fun();
? ? }, 1000);
? },
? fun: function () {
? ? let t = this.data.daojishi;
? ? t--;
? ? this.setData({
? ? ? daojishi: t
? ? })
? ? if (t <= 0) {
? ? ? // location.;
? ? ? clearInterval(this.data.inter);
? ? ? this.setData({
? ? ? ? isyanzhengma: true
? ? ? })
? ? }
? },

手機登錄、填手機號獲取驗證碼,倒計時后重新獲取效果

描述:

輸入正確的手機號并且輸入驗證碼后,手機登錄按鈕變?yōu)榧t色可點擊狀態(tài);自動驗證輸入的手機號是否為合法手機號;點擊獲取動態(tài)碼后開始60秒倒計時后才可以再次獲取動態(tài)碼;

效果圖:

代碼:

html:

<view class="dltel">
? <view class="teltit">手機快捷登錄</view>
? <view class="inpbox">
? ? <input placeholder="請輸入手機號" class="inpbtn" type='number' maxlength="11" value="{{mobile}}" bindinput='blurPhone' />
? ? <text class="dongtaima {{hui?'hui':'red'}}" wx:if="{{isyanzhengma}}" bindtap="dongtaima">獲取動態(tài)碼</text>
? ? <text class="dongtaima" wx:else>重發(fā)({{daojishi}})</text>
? </view>
? <view class="inpbox">
? ? <input placeholder="請輸入驗證碼" value="{[code]}" maxlength="6" class="inpbtn" bindinput="codetap" ?/>
? </view>

? <view class="teldl {{dlno ? 'tou50':''}}" bindtap="teldltap">
? ? <text class="icontxt">手機登錄</text>
? </view>
</view>

js:

// pages/dltel/dltel.js

import {
? sendCode,
? mobileLogin
} from "../../utils/requst/api.js";

Page({

? /**
? ?* 頁面的初始數(shù)據(jù)
? ?*/
? data: {
? ? navbarData: {
? ? ? isfixed: false,
? ? ? iswhite: false, //icon color
? ? ? showCapsule: 1, //是否顯示左上角圖標 1表示顯示 0表示不顯示
? ? ? title: '登錄', //導航欄 中間的標題
? ? ? backgroundcolor: '#fff',
? ? ? isintercept: false //返回攔截
? ? },

? ? mobile: '',
? ? code: '',
? ? isyanzhengma: true,
? ? hui: true,
? ? dlno: true,
? ? daojishi: 60,
? ? teltrue: false,
? ? inter: '',
? },
? // 手機號驗證
? blurPhone: function (e) {
? ? this.setData({
? ? ? mobile: e.detail.value
? ? })
? ? let phone = this.data.mobile;
? ? if (!(/^1[34578]\d{9}$/.test(phone))) {
? ? ? this.setData({
? ? ? ? teltrue: false,
? ? ? ? hui: true,
? ? ? })
? ? ? if (phone.length >= 11) {
? ? ? ? wx.showToast({
? ? ? ? ? title: '手機號有誤',
? ? ? ? ? icon: 'none',
? ? ? ? ? duration: 2000
? ? ? ? })
? ? ? }
? ? } else {
? ? ? this.setData({
? ? ? ? teltrue: true,
? ? ? ? hui: false,
? ? ? })
? ? ? console.log('驗證成功', this.data.teltrue)
? ? }
? },
? dongtaima: function (e) {
? ? if (this.data.teltrue & !this.data.hui) {
? ? ? let params = {
? ? ? ? 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ā)送失敗,請重發(fā)!",
? ? ? ? ? ? icon: "none",
? ? ? ? ? ? duration: 2000
? ? ? ? ? })
? ? ? ? }
? ? ? })
? ? } else if (!this.data.teltrue) {
? ? ? wx.showToast({
? ? ? ? title: "請?zhí)顚懻_的手機號!",
? ? ? ? icon: "none",
? ? ? ? duration: 2000
? ? ? })
? ? }
? },
? codetap: function (e) {
? ? // console.log(e);
? ? this.setData({
? ? ? code: e.detail.value
? ? })
? ? if (this.data.teltrue & this.data.code != '') {
? ? ? this.setData({
? ? ? ? dlno: false
? ? ? })
? ? }
? },
? daojishi: function () {
? ? this.data.inter = setInterval((res) => {
? ? ? this.fun();
? ? }, 1000);
? },
? fun: function () {
? ? let t = this.data.daojishi;
? ? t--;
? ? this.setData({
? ? ? daojishi: t
? ? })
? ? if (t <= 0) {
? ? ? // location.;
? ? ? clearInterval(this.data.inter);
? ? ? this.setData({
? ? ? ? isyanzhengma: true
? ? ? })
? ? }
? },

? teldltap: function () {
? ? let params = {
? ? ? code: this.data.code,
? ? ? mobile: this.data.mobile
? ? }
? ? if (this.data.teltrue & this.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);

? ? ? ? ? //let pages = getCurrentPages(); // 當前頁的數(shù)據(jù),
? ? ? ? ? //let prevPage = pages[pages.length - 3]; // 上上頁的數(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
? ? ? ? ? })
? ? ? ? }
? ? ? })
? ? } else if (!this.data.teltrue) {
? ? ? wx.showToast({
? ? ? ? title: "請?zhí)顚懻_的手機號!",
? ? ? ? icon: "none",
? ? ? ? duration: 2000
? ? ? })
? ? } else {
? ? ? wx.showToast({
? ? ? ? title: "請?zhí)顚戲炞C碼!",
? ? ? ? icon: "none",
? ? ? ? duration: 2000
? ? ? })
? ? }

? },
??
})

css:(less)

@fontcolor:#353535;
@red:#ff2b0a;
.dltel{?
? position: relative;
? width: 100%;
? height: 100vh;
? padding:0 40rpx;
? 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: 1px solid #eee;
? ? .dongtaima{
? ? ??
? ? }
? ? .inpbtn{
? ? ? width: 430rpx;
? ? ? height: 100%;
? ? ? margin:0 30rpx;
? ? }
? ? .hui{
? ? ? color: #888
? ? }
? ? .red{
? ? ? color: @red;
? ? }
? }
? .teldl{
? ? position: relative;
? ? width: 100%;
? ? height: 94rpx;
? ? border-radius: 15rpx;
? ? line-height: 94rpx;
? ? text-align: center;
? ? font-size: 36rpx;
? ? margin-top:60rpx;
? ? color: #fff;
? ? background: @red;
? }
? .tou50{
? ? background:#ff9584;
? }
}

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

相關(guān)文章

  • 基于JS代碼實現(xiàn)實時顯示系統(tǒng)時間

    基于JS代碼實現(xiàn)實時顯示系統(tǒng)時間

    這篇文章主要介紹了基于JS代碼實現(xiàn)實時顯示系統(tǒng)時間的相關(guān)資料,非常不錯,具有參考借鑒價值,需要的朋友可以參考下
    2016-06-06
  • CodeMirror js代碼加亮使用總結(jié)

    CodeMirror js代碼加亮使用總結(jié)

    一個基于JavaScript的代碼編輯器,CodeMirror支持大量語言的語法高亮,也包括css,html,js等的高亮顯示。此外,CodeMirror還支持代碼自動完成、搜索/替換、HTML預覽、行號、選擇/搜索結(jié)果高亮、可視化tab、代碼自動格式等
    2017-03-03
  • JS匿名函數(shù)類生成方式實例分析

    JS匿名函數(shù)類生成方式實例分析

    這篇文章主要介紹了JS匿名函數(shù)類生成方式,結(jié)合實例形式分析了javascript匿名函數(shù)類相關(guān)屬性與方法定義與使用技巧,需要的朋友可以參考下
    2016-11-11
  • JS實現(xiàn)漂亮的時間選擇框效果

    JS實現(xiàn)漂亮的時間選擇框效果

    這篇文章主要介紹了JS實現(xiàn)漂亮的時間選擇框效果,結(jié)合實例形式分析了javascript時間選擇框插件的實現(xiàn)與使用方法,需要的朋友可以參考下
    2016-08-08
  • Bootstrap模態(tài)框插件使用詳解

    Bootstrap模態(tài)框插件使用詳解

    這篇文章主要為大家詳細介紹了Bootstrap模態(tài)框插件的使用方法,具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2017-05-05
  • javascript json對象小技巧之鍵名作為變量用法分析

    javascript json對象小技巧之鍵名作為變量用法分析

    這篇文章主要介紹了javascript json對象小技巧之鍵名作為變量用法,結(jié)合實例形式分析了json對象變量操作相關(guān)使用技巧,需要的朋友可以參考下
    2019-11-11
  • 淺談JS中json數(shù)據(jù)的處理

    淺談JS中json數(shù)據(jù)的處理

    下面小編就為大家?guī)硪黄獪\談JS中json數(shù)據(jù)的處理。小編覺得挺不錯的,現(xiàn)在就分享給大家,也給大家做個參考。一起跟隨小編過來看看吧
    2016-06-06
  • JavaScript學習筆記之圖片庫案例分析

    JavaScript學習筆記之圖片庫案例分析

    這篇文章主要介紹了JavaScript學習筆記之圖片庫案例,結(jié)合具體實例形式分析了javascript圖片庫相關(guān)的頁面元素動態(tài)操作實現(xiàn)技巧,需要的朋友可以參考下
    2019-01-01
  • Bootstrap表單控件使用方法詳解

    Bootstrap表單控件使用方法詳解

    Bootstrap讓Web開發(fā)更迅速、更簡單,這篇文章主要為大家詳細介紹了Bootstrap表單控件,用來與用戶做交流的一個網(wǎng)頁控件,具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2017-01-01
  • 教學演示-UBB,剪貼板,textRange及其他

    教學演示-UBB,剪貼板,textRange及其他

    教學演示-UBB,剪貼板,textRange及其他...
    2006-07-07

最新評論

绥化市| 文成县| 虞城县| 西和县| 麟游县| 江华| 惠东县| 华坪县| 武川县| 名山县| 莒南县| 娱乐| 定陶县| 望江县| 嘉义市| 望奎县| 海南省| 寻甸| 泰宁县| 贵德县| 丰宁| 微博| 隆化县| 昌图县| 山西省| 灵丘县| 杭锦后旗| 伽师县| 专栏| 平定县| 邻水| 栖霞市| 浮梁县| 普陀区| 南投市| 汉川市| 卓资县| 崇信县| 绥中县| 宾川县| 图们市|