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

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

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

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

效果如下圖:

wxml部分如下:

<!--驗(yàn)證碼-->
? <view class="mod t-name" style='position:relative'>
? ? <text class="key">驗(yàn)證碼:</text>
? ? <input type="digit" bindinput="bindKeyInput" data-inputname="phoneCode" value='{{phoneCode}}' class="input" maxlength="100" placeholder="請(qǐng)輸入手機(jī)驗(yàn)證碼" />
? ? <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: "獲取驗(yàn)證碼",
? ? ?? ?timeNum: 60,
? ? ?? ?clikType: false,
? ? ?? ?phone: null,
? ? ?? ?phoneCode: null,
? ? ? }

獲取驗(yàn)證碼方法如下:

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

? //輸入手機(jī)號(hào)獲取驗(yàn)證碼
? gainCode() {
? ? var that = this;
? ? if (this.data.phone == '' || this.data.phone == null) {
? ? ? wx.showToast({
? ? ? ? title: '手機(jī)號(hào)不能為空',
? ? ? ? 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();
? ? ? ? ? }
? ? ? ? })
? ? ? }
? ? }
? },
? // 點(diǎn)擊獲取手機(jī)驗(yàn)證碼
? clickGainCode(e) {
? ? if (!this.data.clikType) {
? ? ? this.gainCode();
? ? }
? },

以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

最新評(píng)論

丹棱县| 新民市| 永川市| 玉田县| 宜兴市| 深圳市| 天全县| 醴陵市| 甘泉县| 尚志市| 金山区| 溧阳市| 通道| 安图县| 习水县| 象州县| 富裕县| 龙州县| 襄城县| 吕梁市| 武宣县| 绩溪县| 日土县| 岳池县| 青冈县| 云浮市| 旅游| 从江县| 德清县| 乌兰浩特市| 嘉黎县| 宣城市| 越西县| 棋牌| 大悟县| 西青区| 蒙城县| 光山县| 同心县| 阳泉市| 卢湾区|