Home > Article > WeChat Applet > Sample code for WeChat applet to implement countdown function for sending text messages
This article mainly introduces the countdown function of sending text messages in the WeChat applet. Friends who need it can refer to it
After clicking
Code
<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)} },
Idea: Set the style and content after BUTTON as variables, click setData to change them
Summarize
The above is the detailed content of Sample code for WeChat applet to implement countdown function for sending text messages. For more information, please follow other related articles on the PHP Chinese website!