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

小程序短信驗(yàn)證碼頁(yè)面實(shí)現(xiàn)demo

 更新時(shí)間:2023年11月29日 10:11:15   作者:freeman_Tian  
這篇文章主要為大家介紹了小程序短信驗(yàn)證碼頁(yè)實(shí)現(xiàn)demo,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪

小程序短信驗(yàn)證碼

難點(diǎn)主要是樣式設(shè)計(jì),以及bindinput="Focus" 事件的控制

頁(yè)面結(jié)構(gòu)

<view class="container">
  <nav-bar bind:left="goBack" />
  <view class='login-form-page'>
    <view class="title">
      輸入短信驗(yàn)證碼
    </view>
    <view class="tittxt">短信驗(yàn)證碼已發(fā)送至{{phone}}</view>
    <view class="content">
      <view>
        <form>
          <view class='inpcontent'>
            <block wx:for="{{Length}}" wx:key="item">
              <input
                class='iptbox'
                style="background-color: {{inpVal.length==index?'#1194FB':''}}; box-shadow:{{inpVal.length==index?'0rpx 3rpx 10rpx 3rpx rgba(17,148,251,0.17)':''}};background-color: {{inpVal.length+1==index?'#FFFFFF':''}}; box-shadow:{{inpVal.length+1==index?'0rpx 3rpx 10rpx 3rpx #E1E1E1':''}};background-color:{{whether?'#FF3334':''}}; box-shadow:{{whether?'0rpx 3rpx 10rpx 3rpx rgba(254,54,49,0.26)':''}};clear: {{whether?'#FFFFFF':''}}; "
                value="{{inpVal.length>=index+1?inpVal[index]:''}}"
                disabled
                password='{{ispassword}}'
                catchtap='Tap'
              ></input>
              ?
            </block>
            ?
          </view>
          ?
          <input
            name="password"
            password="{{true}}"
            class='ipt'
            maxlength="{{Length}}"
            focus="{{isFocus}}"
            bindinput="Focus"
          ></input>
          ?
        </form>
      </view>
      <view class="mistake" wx:if="{{whether}}">
        驗(yàn)證碼有誤,請(qǐng)重新輸入
      </view>
      <button class='btn' wx:if="{{coding==0}}">
        {{time}}秒后重新發(fā)送
      </button>
      <button
        class="btn btn-active"
        wx:if="{{coding==1}}"
        bindtap="resetCode"
      >
        重新發(fā)送
      </button>
    </view>
  </view>
</view>

js代碼

import { phonePwd } from '../../utils/common';
import { mobileSms } from '../../api/me/index';
Page({
    /**
     \* 頁(yè)面的初始數(shù)據(jù)
     */
    data: {
        phone: '',
        Length: 4, // 輸入框個(gè)數(shù)
        isFocus: true, // 聚焦
        inpVal: '', // 輸入的內(nèi)容
        ispassword: false, // 是否密文顯示 true為密文, false為明文。
        time: 60,
        // 顯示是否重新發(fā)送
        coding: 0,
        reqCode: '', // 驗(yàn)證碼
        // 手機(jī)號(hào)
        cell: '',
        // 驗(yàn)證成功與否
        whether: false
    },
    // 60秒倒計(jì)時(shí)結(jié)束后可再次發(fā)送驗(yàn)證碼
    async resetCode() {
        const info = wx.getStorageSync('userInfo');
        let params = {
            phone: info.phone,
            smsType: 'CHANGE_PASSWORD'
        };
        await mobileSms(params).then(res => {
            console.log(res);
            this.setData({
                reqCode: Number(res),
                coding: 0
            });
            // 計(jì)時(shí)60秒結(jié)束可返回上一個(gè)頁(yè)面重新發(fā)送驗(yàn)證碼
            let second = setInterval(() => {
                this.data.time--;
                this.setData({
                    time: this.data.time
                });
                if (this.data.time <= 0) {
                    clearInterval(second);
                    this.setData({
                        coding: 1,
                        time: 60
                    });
                }
            }, 1000);
        });
    },
    // input事件位置
    Focus(e) {
        const inputValue = e.detail.value;
        this.setData({
            inpVal: inputValue
        });
        // 驗(yàn)證碼輸入完畢會(huì)進(jìn)行判斷
        console.log(this.data.inpVal, this.data.reqCode);
        if (this.data.inpVal.length === 4) {
            // 在這里判斷輸入的是否錯(cuò)誤如果錯(cuò)誤的話就讓whether=true,否則false
            if (this.data.inpVal === this.data.reqCode) {
                this.setData({
                    whether: false
                });
                wx.$wxApi.navigate(`/me/pwd/index?smsCode=${this.data.reqCode}`);
            } else {
                this.setData({
                    whether: true
                });
            }
        }
    },
    Tap() {
        const that = this;
        that.setData({
            isFocus: true
        });
    },
    onReady() {
        this.init();
    },
    /* 初始化數(shù)據(jù) */
    async init() {
        const pho = wx.getStorageSync('userInfo').phone;
        this.setData({ phone: phonePwd(pho) });
        let params = {
            phone: pho,
            smsType: 'CHANGE_PASSWORD'
        };
        await mobileSms(params).then(res => {
            console.log(res);
            this.setData({
                reqCode: String(res)
            });
        });
    },
    /**
     * 生命周期函數(shù)--監(jiān)聽(tīng)頁(yè)面加載
     */
    onLoad() {
        // this.setData({
        //     cell: options.cell
        // });
        // 計(jì)時(shí)60秒結(jié)束可返回上一個(gè)頁(yè)面重新發(fā)送驗(yàn)證碼
        let second = setInterval(() => {
            this.data.time--;
            this.setData({
                time: this.data.time
            });
            if (this.data.time <= 0) {
                clearInterval(second);
                this.setData({
                    coding: 1,
                    time: 60
                });
            }
        }, 1000);
    },
    goBack() {
        wx.navigateBack();
    },
    /**
     \* 生命周期函數(shù)--監(jiān)聽(tīng)頁(yè)面顯示
     */
    onShow() {},
    /**
     \* 生命周期函數(shù)--監(jiān)聽(tīng)頁(yè)面隱藏
     */
    onHide() {},
    /**
     \* 生命周期函數(shù)--監(jiān)聽(tīng)頁(yè)面卸載
     */
    onUnload() {},
    /**
     \* 頁(yè)面相關(guān)事件處理函數(shù)--監(jiān)聽(tīng)用戶下拉動(dòng)作
     */
    onPullDownRefresh() {},
    /**
     \* 頁(yè)面上拉觸底事件的處理函數(shù)
     */
    onReachBottom() {},
    /**
     \* 用戶點(diǎn)擊右上角分享
     */
    onShareAppMessage() {}
});

css樣式

.container {
    height: 100vh;
    background: #d8d8d8 linear-gradient(180deg, #ffffff 0%, #e0e3e9 100%);
    position: relative;

    .login-form-page {
        position: relative;
        padding: 118rpx 40rpx 0;
        height: 100vh;
        box-sizing: border-box;
        background: linear-gradient(180deg, #F2F2F2 0%, #FFFFFF 100%), linear-gradient(180deg, #FFFFFF 0%, #E0E3E9 100%);
    }
    .title {
        margin-top: 104rpx;
        line-height: 80rpx;
        font-size: 56rpx;
        font-family: PingFangSC-Semibold, PingFang SC;
        font-weight: 600;
        color: #1a1b1c;
    }
    .tittxt {
        font-size: 28rpx;
        font-family: PingFangSC-Regular, PingFang SC;
        font-weight: 400;
        color: #676e6f;
        line-height: 40rpx;
    }
    .btn {
        // margin-top: 80rpx;
        height: 96rpx;
        line-height: 96rpx;
        font-size: 28rpx;
        font-family: PingFangSC-Medium, PingFang SC;
        font-weight: 500;
        color: #ffffff;
        background: #dadee1;
        border-radius: 16rpx;
        border: 0 none;
        &-active {
            background: #1d2129;
        }
    }
}
.content_time {
    font-size: 24rpx;
    font-weight: 400;
    color: #858585;
    letter-spacing: 1px;
    text-align: center;
    margin-top: 30rpx;
}
.inpcontent {
    margin: 0 auto;
    display: flex;
    justify-content: space-around;
    align-items: center;
    margin-top: 100rpx;
    padding: 0 62rpx;
}
.iptbox {
    width: 100rpx;
    height: 100rpx;
    border: 1rpx solid #ddd;
    border-radius: 20rpx;
    display: flex;
    justify-content: center;
    align-items: center;
    text-align: center;
    background: #fff;
    font-weight: 400;
    font-size: 30rpx;
    color: #202020;
}
.ipt {
    width: 0;
    height: 0;
}
.btn-area {
    width: 80%;
    background-color: orange;
    color: white;
}
.mistake {
    font-size: 22rpx;
    font-weight: 400;
    color: #c34d55;
    line-height: 30rpx;
    letter-spacing: 1px;
    text-align: center;
}

以上就是小程序短信驗(yàn)證碼頁(yè)面實(shí)現(xiàn)demo的詳細(xì)內(nèi)容,更多關(guān)于小程序短信驗(yàn)證碼頁(yè)的資料請(qǐng)關(guān)注腳本之家其它相關(guān)文章!

相關(guān)文章

  • js實(shí)現(xiàn)帶緩沖效果的仿QQ面板折疊菜單代碼

    js實(shí)現(xiàn)帶緩沖效果的仿QQ面板折疊菜單代碼

    這篇文章主要介紹了js實(shí)現(xiàn)帶緩沖效果的仿QQ面板折疊菜單代碼,通過(guò)JavaScript定時(shí)函數(shù)遞歸調(diào)用實(shí)現(xiàn)折疊菜單的緩沖效果,具有一定參考借鑒價(jià)值,需要的朋友可以參考下
    2015-09-09
  • JavaScript九九乘法口訣表的簡(jiǎn)單實(shí)現(xiàn)

    JavaScript九九乘法口訣表的簡(jiǎn)單實(shí)現(xiàn)

    這篇文章主要介紹了JavaScript乘法口訣表的簡(jiǎn)單實(shí)現(xiàn),文中給出了詳細(xì)的示例代碼,這樣對(duì)大家的理解和學(xué)習(xí)更有幫助,有需要的朋友們可以參考借鑒,下面來(lái)一起看看吧。
    2016-10-10
  • 如何在TypeScript使用模塊化以及注意事項(xiàng)詳解

    如何在TypeScript使用模塊化以及注意事項(xiàng)詳解

    在TypeScript中就像在EC5中一樣,任何包含頂級(jí)import或export的文件都被認(rèn)為是一個(gè)模塊,下面這篇文章主要給大家介紹了關(guān)于如何在TypeScript使用模塊化以及注意事項(xiàng)的相關(guān)資料,需要的朋友可以參考下
    2022-10-10
  • js 一個(gè)關(guān)于圖片onload加載的事

    js 一個(gè)關(guān)于圖片onload加載的事

    前幾天一個(gè)項(xiàng)目讓我頭疼了很久,一個(gè)關(guān)于圖片加載時(shí)的loading效果,因?yàn)椴皇翘甹s,所以在網(wǎng)上各種找資料,但還是不理想,無(wú)賴苦心研究,終于有了一點(diǎn)眉目了,雖然個(gè)中還有一些道理不懂,至少目的達(dá)到了
    2013-11-11
  • JS 按鈕點(diǎn)擊觸發(fā)(兼容IE、火狐)

    JS 按鈕點(diǎn)擊觸發(fā)(兼容IE、火狐)

    這篇文章介紹了JS 按鈕點(diǎn)擊觸發(fā),有需要的朋友可以參考一下
    2013-08-08
  • js實(shí)現(xiàn)select二級(jí)聯(lián)動(dòng)下拉菜單

    js實(shí)現(xiàn)select二級(jí)聯(lián)動(dòng)下拉菜單

    這個(gè)是簡(jiǎn)單也是最基本的下拉框聯(lián)動(dòng)的示例,這個(gè)示例主要針對(duì)那些只有二級(jí)聯(lián)動(dòng),且第一級(jí)是固定的選項(xiàng),第二級(jí)的內(nèi)容也比較簡(jiǎn)單,不刷新的聯(lián)動(dòng),感興趣的小伙伴們可以參考一下
    2016-04-04
  • jQuery中選擇查找自定義屬性具有特定值的所有元素

    jQuery中選擇查找自定義屬性具有特定值的所有元素

    同樣在HTML5可以通過(guò)data-自定義屬性名來(lái)給元素添加自定義的屬性名。一旦添加完成之后。通過(guò)JS可以獲取以及設(shè)置自定義屬性。這篇文章主要介紹了jQuery中選擇查找自定義屬性具有特定值的所有元素
    2023-02-02
  • 一步步教你利用Canvas對(duì)圖片進(jìn)行處理

    一步步教你利用Canvas對(duì)圖片進(jìn)行處理

    這篇文章主要給大家介紹了關(guān)于利用Canvas對(duì)圖片進(jìn)行處理的相關(guān)資料,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧。
    2017-09-09
  • JavaScript獲得頁(yè)面base標(biāo)簽中url的方法

    JavaScript獲得頁(yè)面base標(biāo)簽中url的方法

    這篇文章主要介紹了JavaScript獲得頁(yè)面base標(biāo)簽中url的方法,涉及javascript中元素的獲取及href屬性的使用技巧,需要的朋友可以參考下
    2015-04-04
  • js如何讀取csv內(nèi)容拼接成json

    js如何讀取csv內(nèi)容拼接成json

    這篇文章主要介紹了js如何讀取csv內(nèi)容拼接成json,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教
    2022-09-09

最新評(píng)論

陆良县| 望城县| 白河县| 隆林| 荆州市| 西平县| 渑池县| 林口县| 廊坊市| 贡觉县| 蓝山县| 黑河市| 福建省| 遂川县| 凤山市| 江西省| 云龙县| 黄山市| 丰顺县| 东乡族自治县| 巩留县| 安达市| 崇左市| 阆中市| 芜湖市| 宝丰县| 翁源县| 兰溪市| 孝义市| 延庆县| 日喀则市| 木里| 伊宁县| 丽水市| 阿拉善右旗| 宁陕县| 库伦旗| 府谷县| 太康县| 宜兴市| 鹤庆县|