微信小程序获取验证码,倒计时60秒!这个在微信中也经常遇到,因此给大家分享出来,逻辑就不过多的解释。这个是自定义的方法,大家在调用的时候,直接绑定在按钮上,直接this.getcode()一下就可以调用了
getcode: function (e) { var that = this; var mobile = that.data.mobile; var reg_mobile = /^(((13[0-9]{1})|(15[0-9]{1})|(18[0-9]{1})|(17[0-9]{1}))+\d{8})$/; if (!reg_mobile.test(mobile)) { wx.showToast({ title: '请输入正确的手机号', icon: 'none' }) } else { this.getCode(); var date = { phone: mobile, sendWay: 1, type: 2 }; http.httpPost('user/send', date, function (res) { console.log(res) }) } },复制代码