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

微信小程序?qū)崿F(xiàn)接收驗證碼

 更新時間:2022年05月24日 10:25:09   作者:keepfitt  
這篇文章主要為大家詳細介紹了微信小程序?qū)崿F(xiàn)接收驗證碼,文中示例代碼介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們可以參考一下

本文實例為大家分享了微信小程序?qū)崿F(xiàn)接收驗證碼的具體代碼,供大家參考,具體內(nèi)容如下

效果如下圖:

wxml部分如下:

<!--驗證碼-->
? <view class="mod t-name" style='position:relative'>
? ? <text class="key">驗證碼:</text>
? ? <input type="digit" bindinput="bindKeyInput" data-inputname="phoneCode" value='{{phoneCode}}' class="input" maxlength="100" placeholder="請輸入手機驗證碼" />
? ? <text class='logbook'></text>
? ? <text class='getkey' bindtap="clickGainCode">{{tipsCode}}</text>
</view>

css部分代碼如下:

.mod{
? display: flex;
? flex-direction: row;
? justify-content: space-between;
? align-items: center;
? height: 100rpx;
? padding: 0 20rpx;
? border-bottom:1rpx solid #ccc;
? box-sizing: border-box;
}
.mod .key{
? font-size: 28rpx;
? font-weight: bold;
? text-align: right;
? width: 160rpx;
}
.t-name{
? background-color: rgb(254,254,254);
? box-sizing: border-box;
}
.t-name .input{
? width: 540rpx;
? font-size: 28rpx;
? margin-left: 30rpx;
}
.logbook {
? font-size: 24rpx;
? width: 150rpx;
? text-align: right;
? font-weight: bold;
}

.getkey {
? width: 200rpx;
? position: absolute;
? right: 0rpx;
? text-align: center;
? color: rgb(31, 45, 210);
? font-size: 24rpx;
? border-left: 1px solid #f0f0f0;
}

js的data里定義如下內(nèi)容:

data: {
?? ??? ?tipsCode: "獲取驗證碼",
? ? ?? ?timeNum: 60,
? ? ?? ?clikType: false,
? ? ?? ?phone: null,
? ? ?? ?phoneCode: null,
? ? ? }

獲取驗證碼方法如下:

?bindKeyInput: function(e) {
? ? this.data[e.currentTarget.dataset.inputname] = e.detail.value;
? ? this.setData(this.data);
? },
? //獲取驗證碼時的顯示時間
? getTime() {
? ? var that = this;
? ? var timer = setInterval(function() {
? ? ? that.data.timeNum--;
? ? ? if (that.data.timeNum <= 0) {
? ? ? ? that.setData({
? ? ? ? ? tipsCode: "重新獲取驗證碼",
? ? ? ? ? timeNum: timeOut,
? ? ? ? ? clikType: false
? ? ? ? });
? ? ? ? clearInterval(timer);
? ? ? } else {
? ? ? ? that.setData({
? ? ? ? ? tipsCode: "重新發(fā)送" + that.data.timeNum + "秒",
? ? ? ? })
? ? ? }
? ? }, 1000)
? },

? //輸入手機號獲取驗證碼
? gainCode() {
? ? var that = this;
? ? if (this.data.phone == '' || this.data.phone == null) {
? ? ? wx.showToast({
? ? ? ? title: '手機號不能為空',
? ? ? ? icon: 'none',
? ? ? })
? ? } ?else {
? ? ? that.setData({
? ? ? ? clikType: true
? ? ? })
? ? ? if (this.data.timeNum < timeOut) {
? ? ? } else {
? ? ? ? wx.request({
? ? ? ? ? url: wxapp_api_url + '/common/getCode',
? ? ? ? ? header: {
? ? ? ? ? ? 'content-type': 'application/x-www-form-urlencoded'
? ? ? ? ? },
? ? ? ? ? method: "get",
? ? ? ? ? data: {
? ? ? ? ? ? phone: this.data.phone
? ? ? ? ? },
? ? ? ? ? success: function(res) {
? ? ? ? ? ? that.getTime();
? ? ? ? ? }
? ? ? ? })
? ? ? }
? ? }
? },
? // 點擊獲取手機驗證碼
? clickGainCode(e) {
? ? if (!this.data.clikType) {
? ? ? this.gainCode();
? ? }
? },

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

相關文章

  • JS獲取html對象的幾種方式介紹

    JS獲取html對象的幾種方式介紹

    這篇文章主要介紹了JS獲取html對象的幾種方式,有需要的朋友可以參考一下
    2013-12-12
  • js面向?qū)ο缶幊炭偨Y(jié)

    js面向?qū)ο缶幊炭偨Y(jié)

    本文主要介紹了js面向?qū)ο缶幊痰南嚓P知識,具有很好的參考價值,下面跟著小編一起來看下吧
    2017-02-02
  • JS查看對象功能代碼

    JS查看對象功能代碼

    通過JS查看到一個頁面有些什么對象的實現(xiàn)代碼
    2008-04-04
  • JS中substring與substr的用法

    JS中substring與substr的用法

    這篇文章主要介紹了JS中substring與substr的用法講解,非常不錯,具有參考借鑒價值,感興趣的朋友一起看看吧
    2016-11-11
  • 讓JavaScript 輕松支持函數(shù)重載 (Part 1 - 設計)

    讓JavaScript 輕松支持函數(shù)重載 (Part 1 - 設計)

    JavaScript支持函數(shù)重載嗎?可以說不支持,也可以說支持。說不支持,是因為JavaScript不能好像其它原生支持函數(shù)重載的語言一樣,直接寫多個同名函數(shù),讓編譯器來判斷某個調(diào)用對應的是哪一個重載。
    2009-08-08
  • llqrcode js識別二維碼解析二維碼信息實例

    llqrcode js識別二維碼解析二維碼信息實例

    這篇文章主要為大家介紹了llqrcode js識別二維碼解析二維碼信息實例詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進步,早日升職加薪
    2022-11-11
  • js中Generator函數(shù)的深入講解

    js中Generator函數(shù)的深入講解

    這篇文章主要給大家介紹了關于js中Generator函數(shù)的相關資料,文中通過示例代碼介紹的非常詳細,對大家學習或者使用Javascript具有一定的參考學習價值,需要的朋友們下面來一起學習學習吧
    2019-04-04
  • javascript html5 canvas實現(xiàn)可拖動省份的中國地圖

    javascript html5 canvas實現(xiàn)可拖動省份的中國地圖

    這篇文章主要介紹了javascript html5 canvas實現(xiàn)可拖動省份的中國地圖的相關資料,需要的朋友可以參考下
    2016-03-03
  • JS動態(tài)添加option和刪除option(附實例代碼)

    JS動態(tài)添加option和刪除option(附實例代碼)

    option的添加和刪除通過js實現(xiàn)及動態(tài)創(chuàng)建select,本例提供實例的完整代碼,感興趣的朋友可以參考下哈,希望可以幫助到你
    2013-04-04
  • 再談Javascript中的基本類型和引用類型(推薦)

    再談Javascript中的基本類型和引用類型(推薦)

    這篇文章主要介紹了Javascript中的基本類型和引用類型的相關資料,包括基本類型和引用類型的概念及區(qū)別,數(shù)據(jù)類型檢測給大家詳細介紹了js基本類型和引用類型,非常不錯,需要的朋友可以參考下
    2016-07-07

最新評論