1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980 |
- var app = getApp()
- const util = require('../../utils/utils.js');
- let countTime = null//定时器
- Page({
- data: {
- currentTime: 60,//倒计时时间
- number: '',
- },
- onLoad: function (options) {
- console.log(options)
- let that = this
- that.setData({
- number: options.number
- })
- that.countDown()
- },
- //重新获取验证码
- getCodeno: util.throttle(function () {
- let that = this
- // 调用短信验证码接口
- let data = {
- mobile: that.data.number,
- type: 2
- }
- app.request('/verification-code', data, 'POST').then(res => {
- that.setData({
- currentTime:60
- })
- if (res.status == 200) {
- that.countDown()
-
- }
- })
- //60秒倒计时
- }, 1000),
- //倒计时
- countDown:function(){
- let that=this
- let currentTime = that.data.currentTime
- countTime = setInterval(function () {
- currentTime--
- that.setData({
- currentTime: currentTime
- })
- if (currentTime == 0) {
- clearInterval(countTime)
- }
- }, 1000)
- },
- onReady: function () {
- },
- onShow: function () {
- },
- onHide: function () {
- },
- onUnload: function () {
- },
- onPullDownRefresh: function () {
- },
- onReachBottom: function () {
- },
- onShareAppMessage: function () {
- }
- })
|