getcode() {
let _tip = this.i18n.obtain
console.log(_tip)
console.log(this.codemessage)
var reg = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
if (this.codemessage != _tip) {
return
}
if (this.formdata.userEmail && reg.test(this.formdata.userEmail)) {
this._sendEmailCode(this.formdata.userEmail) //发送邮件方法
} else {
// this.$Message.warning(this.$t('login.pleaseEnterMailbox'))
this.confirmwords = this.i18n.inputrealemail
return
}
let count = 60
var timer = setInterval(() => {
if (count > 1) {
this.codemessage = `${count}s`
count--
} else {
clearInterval(timer)
this.codemessage = this.i18n.obtain // 点击获取 || this.$t('message').obtain
}
}, 1000)
},
//发送验证码另一种写法
getCode(){ //获取验证码
console.log(this.isPhone,this.phoneNum)
if(!(/^1[3456789]\d{9}$/.test(this.phoneNum))&&this.isPhone){
uni.showToast({
icon:'none',
title:'手机号格式错误',
duration:2000
})
return
}
var reg = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
if (this.phoneNum && !reg.test(this.phoneNum)&&!this.isPhone) {
uni.showToast({
icon:'none',
title:this.i18n.inputrealemail,
duration:2000
})
return
}
if(this.getWord!=this.$t('message').VerificationCode&&this.getWord!='重新获取'){
return
}
if(this.isPhone){
uni.request({
url: this.$config.accounturl +`authority/app/code/${this.codeType}`,
data: {
phone:this.phoneNum
},
method: 'get',
success: (res) => {
if (res.data.code == 1) {
uni.showToast({
icon: 'none',
title: this.i18n.nomalsuccess,
});
} else {
uni.showToast({
icon: 'none',
title: res.data.message,
});
}
}
})
}else{
this.$emit('sendemail')
}
//倒计时
// let num = 60
this.num = 60
// this.getWord =
let timer = setInterval(()=>{
this.num--
// this.getWord = num +' s'
if(this.num<=0){
clearInterval(timer)
// this.getWord =this.$t('message').VerificationCode
}
},1000)
},
watch 监听data里的某一变量
watch: {
upgradeFlag () {
this.eqUpgrade.files = null
this.$refs.upgradeDom.resetFields()
},
'query.deviceSn' (val) {
console.log(val, 'valval')
if (!val) {
this._getdevicePage()
}
}
},