From 1d1e327a1cbf8bd822078a9f71894f25ddcee437 Mon Sep 17 00:00:00 2001 From: queenwuli <942534046@qq.com> Date: Mon, 11 Jan 2021 10:32:49 +0800 Subject: [PATCH] gx --- hive-app/pages/login/forgetPassword.vue | 82 +++++++++++++++++++++++++++++++++++++---- 1 files changed, 74 insertions(+), 8 deletions(-) diff --git a/hive-app/pages/login/forgetPassword.vue b/hive-app/pages/login/forgetPassword.vue index 97be2bf..22a3784 100644 --- a/hive-app/pages/login/forgetPassword.vue +++ b/hive-app/pages/login/forgetPassword.vue @@ -2,21 +2,87 @@ <!-- 忘记密码 --> <view> <view class="input-box"> - <input placeholder="请输入手机号码" placeholder-class="placeholder" class="input-group-row"/> + <input type="text" v-model="phone" placeholder="请输入手机号码" placeholder-class="placeholder" class="input-group-row"/> <view class="flex mt-10 "> - <input placeholder="请输入验证码" placeholder-class="placeholder" class="input-group-row flex-1 mr-10"/> - <navigator url="" hover-class="none" class="btn-box"> - <button class="btn blue-btn">获取验证码</button> - </navigator> + <input type="text" v-model="code" value="" placeholder="请输入验证码" placeholder-class="placeholder" class="input-group-row flex-1 mr-10"/> + <view url="" hover-class="none" class="btn-box"> + <button class="btn blue-btn" :disabled="btnDisabled" @click="sendCode">{{btnTxt}}</button> + </view> </view> </view> - <navigator url="./newPassword" hover-class="none" class="sticky-footer"> - <button class="blue-btn">下一步</button> - </navigator> + <button class="blue-btn sticky-footer" @click="next">下一步</button> </view> </template> <script> + export default { + data() { + return { + phone:'', + code: '', + btnTxt: '获取验证码', + btnDisabled: false + } + }, + methods: { + sendCode(){ + if (!this.$utils.checkPhone(this.phone)){ + this.$toast.info('请输入正确的手机号'); + return false; + } + this.btnDisabled = true; + let second = 120; + this.$httpUtils.request('/api/common/sendSmsCode',{ + telphone: this.phone.trim() + },'POST').then((res)=>{ + console.log(res) + if(res.status==200){ + this.btnTxt = second + 's'; + this.timer = setInterval(() => { + if(second<=1){ + this._reset() + }else{ + second--; + this.btnTxt = second + 's'; + } + }, 1000); + this.$toast.info(res.info); + } else { + this.$toast.info(res.info); + this.btnDisabled = false; + } + }).catch((err) => { + this.$toast.info('发送失败'); + this._reset() + }) + }, + _reset(){ + this.timer && clearInterval(this.timer); + this.timer = null; + this.btnTxt = '发送验证码'; + this.btnDisabled = false; + }, + valid(){ + if(!this.phone.trim()){ + this.$toast.info('请输入手机号'); + return false; + } + if(!this.code.trim()){ + this.$toast.info('请输入验证码'); + return false; + } + }, + next(){ + if(this.valid() === false){ + return; + }else{ + uni.navigateTo({ + url:'./newPassword?code=123456&phone='+this.phone + }) + } + } + } + } </script> <style> -- Gitblit v1.9.1