效果图
// 获取验证码
getCode() {
var that = this
if (that.checkPhone()) {
uni.request({
url: getApp().globalData.url + '接口地址',
method: 'POST',
data: {
telNum: that.phone
},
success(res) {
that.captcha = res.data.data
that.codeTime = 60
let timer = setInterval(() => {
that.codeTime--;
if (that.codeTime < 1) {
clearInterval(timer);
that.codeTime = 0
}
}, 1000)
}
})
} else {
uni.showToast({
title: '手机号码有误!',
icon: "error"
})
}
},