微信小程序+WEB使用JS實(shí)現(xiàn)注冊(cè)【60s】倒計(jì)時(shí)功能開發(fā)步驟:
主要從事網(wǎng)頁(yè)設(shè)計(jì)、PC網(wǎng)站建設(shè)(電腦版網(wǎng)站建設(shè))、wap網(wǎng)站建設(shè)(手機(jī)版網(wǎng)站建設(shè))、成都響應(yīng)式網(wǎng)站建設(shè)、程序開發(fā)、微網(wǎng)站、微信小程序等,憑借多年來(lái)在互聯(lián)網(wǎng)的打拼,我們?cè)诨ヂ?lián)網(wǎng)網(wǎng)站建設(shè)行業(yè)積累了豐富的網(wǎng)站制作、網(wǎng)站建設(shè)、網(wǎng)絡(luò)營(yíng)銷經(jīng)驗(yàn),集策劃、開發(fā)、設(shè)計(jì)、營(yíng)銷、管理等多方位專業(yè)化運(yùn)作于一體,具備承接不同規(guī)模與類型的建設(shè)項(xiàng)目的能力。
1、效果圖:
2、頁(yè)面僅僅利用了JS的相關(guān)功能,包含:wxml、js、wxss
2.1wxml頁(yè)面代碼:
<text>綁定手機(jī)</text> <form bindsubmit="bindMobile"> <view class="form_group"> <text>手 機(jī):</text> <input type="number" placeholder="請(qǐng)輸入手機(jī)號(hào)" maxlength="11" name="data_phone" value="" auto-focus="true" bindblur="blur_mobile" /> <button type="button" class="{{is_show?'show':'hide'}}" bindtap="clickVerify">獲取驗(yàn)證碼</button> <button type="button" class="{{is_show?'hide':'show'}}">重新發(fā)送{{last_time}}秒</button> </view> <input type="number" placeholder="請(qǐng)輸入驗(yàn)證碼" maxlength="6" name="data_verify" value=""/> <button class="save_btn" form-type="submit">確認(rèn)綁定</button> </form>
2.2 js頁(yè)面代碼:
var countdown = 60; var settime = function (that) { if (countdown == 0) { that.setData({ is_show: true }) countdown = 60; return; } else { that.setData({ is_show:false, last_time:countdown }) countdown--; } setTimeout(function () { settime(that) } , 1000) } Page({ /** * 頁(yè)面的初始數(shù)據(jù) */ data: { last_time:'', is_show:true }, clickVerify:function(){ var that = this; // 將獲取驗(yàn)證碼按鈕隱藏60s,60s后再次顯示 that.setData({ is_show: (!that.data.is_show) //false }) settime(that); } })
2.3 wxss頁(yè)面代碼:
/* 發(fā)送驗(yàn)證碼按鈕隱藏,并展示倒數(shù)60s提示 */ .hide{ display: none; } .show{ display: block; }
3、上面講的是微信小程序的,那么我們一般web端或者移動(dòng)端的應(yīng)該是什么樣呢?
其實(shí),方法都差不多,這里也貼出來(lái)僅供大家參考
<!-- 這段代碼(html)是從創(chuàng)新互聯(lián)挪過(guò)來(lái)的,信譽(yù)度應(yīng)該是很高的,大家可以放心使用 --> <script src="http://libs.baidu.com/jquery/1.10.2/jquery.min.js"></script> <script type="text/javascript"> var countdown=60; function settime(obj) { if (countdown == 0) { obj.removeAttribute("disabled"); obj.value="免費(fèi)獲取驗(yàn)證碼"; countdown = 60; return; } else { obj.setAttribute("disabled", true); obj.value="重新發(fā)送(" + countdown + ")"; countdown--; } setTimeout(function() { settime(obj) } ,1000) } </script> <body> <input type="button" id="btn" value="免費(fèi)獲取驗(yàn)證碼" onclick="settime(this)" /> </body> </html>
以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持創(chuàng)新互聯(lián)。
網(wǎng)頁(yè)標(biāo)題:微信小程序注冊(cè)60s倒計(jì)時(shí)功能使用JS實(shí)現(xiàn)注冊(cè)60s倒計(jì)時(shí)功能
文章起源:http://aaarwkj.com/article26/gpiejg.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供網(wǎng)站導(dǎo)航、手機(jī)網(wǎng)站建設(shè)、網(wǎng)站設(shè)計(jì)公司、網(wǎng)站收錄、ChatGPT、關(guān)鍵詞優(yōu)化
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)