diff --git a/pages/login/login.vue b/pages/login/login.vue index afdb65e..8ed416a 100644 --- a/pages/login/login.vue +++ b/pages/login/login.vue @@ -21,7 +21,8 @@ 验证码 - 发送 + 发送 + {{second}} 切换{{loginStatus?'验证码':'密码'}}登录 @@ -37,6 +38,8 @@ export default { data() { return { + showText:true, + second:60, loading:false, loginStatus:true, phone: '', //手机号码 @@ -47,30 +50,49 @@ export default { onLoad() {}, methods: { async send1(){ + if (!this.phone) { + uni.showToast({ title: '请输入您的手机号', icon: 'none' }); + return; + } const data={ telNum:this.phone } const res= await send(data) - console.log(res,'send') + if (res.code===200){ + let interval = setInterval(() => { + this.showText = false; + this.second = this.second - 1; + }, 1000); + setTimeout(() => { + clearInterval(interval); + this.second = 60; + this.showText = true; + }, 60000); + uni.showToast({ title:'发送成功', icon: 'none' }); + }else { + uni.showToast({ title:res.err, icon: 'none' }); + } + }, //当前登录按钮操作 async login1() { - this.loading=true if (!this.phone) { uni.showToast({ title: '请输入您的手机号', icon: 'none' }); return; } - /* if (!/^[1][3,4,5,7,8,9][0-9]{9}$/.test(this.phone)) { - uni.showToast({ title: '请输入正确手机号', icon: 'none' }); - return; - }*/ - if (!this.pwd) { + if (this.loginStatus&&!this.pwd) { uni.showToast({ title: '请输入您的密码', icon: 'none' }); return; } + if (!this.loginStatus&&!this.code) { + uni.showToast({ title: '请输入您的验证码', icon: 'none' }); + return; + } + this.loading=true const data={ + code:this.loginStatus?'':this.code, telNum:this.phone, - password:this.pwd + password:this.loginStatus?this.pwd:'' } const res=await login(data) if (res.code===0){