澳门皇冠金沙网站▎在线官网
做最好的网站

微信小程序之发送短信倒计时功能_javascript技巧

2019-12-23 作者:网络服务   |   浏览(116)

微信小程序之发送短信倒计时功能,小程序倒计时

澳门皇冠金沙网站,在线官网 1

点击后

澳门皇冠金沙网站,在线官网 2

代码

<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)} 
 }, 

思路:将BUTTON后样式和内容设为变量,点击之后setData将其改变即可

总结

以上所述是小编给大家介绍的微信小程序之发送短信倒计时功能,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对帮客之家网站的支持!

http://www.bkjia.com/Javascript/1224892.htmlwww.bkjia.comtruehttp://www.bkjia.com/Javascript/1224892.htmlTechArticle微信小程序之发送短信倒计时功能,小程序倒计时 点击后 代码 form bindsubmit="formSubmit" bindreset="formReset" view class="fidpas" input type="number" class...

 data: { sendmsg: "sendmsg", getmsg:"获取短信验证码", }, /** * 获取短信验证码 */ sendmessg:function{ timer=0 var that=this var time=60 that.setData({ sendmsg:"sendmsgafter", }) var inter=setInterval{ that.setData({ getmsg: time + "s后重新发送", }) time-- if{ timer=1 clearInterval that.setData({ sendmsg: "sendmsg", getmsg: "获取短信验证码", }) } },1000)} }, 

思路:将BUTTON后样式和内容设为变量,点击之后setData将其改变即可

本文由澳门皇冠金沙网站发布于网络服务,转载请注明出处:微信小程序之发送短信倒计时功能_javascript技巧

关键词: