這篇文章主要介紹了微信小程式之發送簡訊倒數功能,需要的朋友可以參考下
#點擊後
#程式碼
<form bindsubmit="formSubmit" bindreset="formReset"> <view class="fidpas"> <input type="number" class="fidpas_inp"placeholder-class="lgin_place" placeholder="请输入手机号" name="phonenumber" /> <input type="number" class="fidpas_inp2"placeholder-class="lgin_place" placeholder="请输入短信验证码" name="msg" /> <button class="{{sendmsg}}" bindtap="sendmessg">{{getmsg}}</button> </view> <button class="lgbut" formType="submit">下一步</button> </form> data: { sendmsg: "sendmsg", getmsg:"获取短信验证码", }, /** * 获取短信验证码 */ sendmessg:function(e){ if (timer==1){ timer=0 var that=this var time=60 that.setData({ sendmsg:"sendmsgafter", }) var inter=setInterval(function(){ that.setData({ getmsg: time + "s后重新发送", }) time-- if(time<0){ timer=1 clearInterval(inter) that.setData({ sendmsg: "sendmsg", getmsg: "获取短信验证码", }) } },1000)} },
以上是微信小程式實作發送簡訊倒數功能的範例程式碼的詳細內容。更多資訊請關注PHP中文網其他相關文章!