Commit 8957e28898763dae9f4064d5b4522cc737305d9b
1 parent
8cb58a4c
停车服务登录 重复发送验证码 bug修复
Showing
2 changed files
with
37 additions
and
16 deletions
src/utils/request.js
@@ -46,13 +46,17 @@ service.interceptors.response.use( | @@ -46,13 +46,17 @@ service.interceptors.response.use( | ||
46 | const res = response.data; | 46 | const res = response.data; |
47 | // if the custom code is not 20000, it is judged as an error. | 47 | // if the custom code is not 20000, it is judged as an error. |
48 | if (res.code !='8888') { | 48 | if (res.code !='8888') { |
49 | - Message({ | ||
50 | - message: res.msg || 'Error', | ||
51 | - type: 'error', | ||
52 | - duration: 5 * 1000 | ||
53 | - }) | 49 | + if(res.code!='1011'){ |
50 | + Message({ | ||
51 | + message: res.msg || 'Error', | ||
52 | + type: 'error', | ||
53 | + duration: 5 * 1000 | ||
54 | + }) | ||
55 | + return Promise.reject(res.msg || 'error') | ||
56 | + }else{ | ||
57 | + return res | ||
58 | + } | ||
54 | 59 | ||
55 | - return Promise.reject(res.msg) | ||
56 | } else { | 60 | } else { |
57 | return res | 61 | return res |
58 | } | 62 | } |
src/views/login/index.vue
@@ -39,7 +39,7 @@ | @@ -39,7 +39,7 @@ | ||
39 | onkeyup = "value=value.replace(/[^\d]/g,'')" | 39 | onkeyup = "value=value.replace(/[^\d]/g,'')" |
40 | @keyup.enter.native="handleLogin" | 40 | @keyup.enter.native="handleLogin" |
41 | /> | 41 | /> |
42 | - <el-button type="primary" @click="getVerifyCode" :disabled="disabled" style="float:right;margin-top:6px;margin-right:10px;">{{btnTitle}}</el-button> | 42 | + <el-button type="primary" @click="getVerifyCode" :disabled="isDisable" style="float:right;margin-top:6px;margin-right:10px;">{{btnTitle}}</el-button> |
43 | </el-form-item> | 43 | </el-form-item> |
44 | 44 | ||
45 | <el-button :loading="loading" type="primary" style="width:100%;margin-bottom:30px;" | 45 | <el-button :loading="loading" type="primary" style="width:100%;margin-bottom:30px;" |
@@ -85,7 +85,7 @@ export default { | @@ -85,7 +85,7 @@ export default { | ||
85 | password: [{ required: true, trigger: 'blur', validator: validatePassword }] | 85 | password: [{ required: true, trigger: 'blur', validator: validatePassword }] |
86 | }, | 86 | }, |
87 | loading: false, | 87 | loading: false, |
88 | - disabled: false, | 88 | + isDisable: false, |
89 | btnTitle: '发送验证码', | 89 | btnTitle: '发送验证码', |
90 | redirect: undefined | 90 | redirect: undefined |
91 | } | 91 | } |
@@ -100,13 +100,16 @@ export default { | @@ -100,13 +100,16 @@ export default { | ||
100 | }, | 100 | }, |
101 | methods: { | 101 | methods: { |
102 | getVerifyCode(){ | 102 | getVerifyCode(){ |
103 | + this.isDisable = true; | ||
103 | let phone = this.loginForm.phone; | 104 | let phone = this.loginForm.phone; |
104 | if (!this.loginForm.phone) { | 105 | if (!this.loginForm.phone) { |
106 | + this.isDisable = false; | ||
105 | this.$message({ | 107 | this.$message({ |
106 | type: 'error', | 108 | type: 'error', |
107 | message: '请输入正确的手机号!' | 109 | message: '请输入正确的手机号!' |
108 | }); | 110 | }); |
109 | } else if(!/^1[345678]\d{9}$/.test(this.loginForm.phone)) { | 111 | } else if(!/^1[345678]\d{9}$/.test(this.loginForm.phone)) { |
112 | + this.isDisable = false; | ||
110 | this.$message({ | 113 | this.$message({ |
111 | type: 'error', | 114 | type: 'error', |
112 | message: '请输入正确的手机号!' | 115 | message: '请输入正确的手机号!' |
@@ -114,39 +117,53 @@ export default { | @@ -114,39 +117,53 @@ export default { | ||
114 | } | 117 | } |
115 | //获取验证码 | 118 | //获取验证码 |
116 | else { | 119 | else { |
120 | + | ||
117 | sendValidatorCode(phone).then(response =>{ | 121 | sendValidatorCode(phone).then(response =>{ |
118 | let data = response; | 122 | let data = response; |
119 | if(data.code=='8888'){ | 123 | if(data.code=='8888'){ |
124 | + console.log(111); | ||
125 | + this.validateBtn(); | ||
120 | this.$message({ | 126 | this.$message({ |
121 | type: 'success', | 127 | type: 'success', |
122 | message: '验证码发送成功!' | 128 | message: '验证码发送成功!' |
123 | }); | 129 | }); |
124 | - this.validateBtn(); | ||
125 | }else{ | 130 | }else{ |
131 | + this.isDisable = false; | ||
126 | this.$message({ | 132 | this.$message({ |
127 | type: 'error', | 133 | type: 'error', |
128 | message: data.msg | 134 | message: data.msg |
129 | }); | 135 | }); |
130 | } | 136 | } |
131 | }); | 137 | }); |
132 | - | ||
133 | - | ||
134 | } | 138 | } |
135 | }, | 139 | }, |
136 | validateBtn(){ | 140 | validateBtn(){ |
137 | //倒计时 | 141 | //倒计时 |
142 | + let that = this, time = 60; | ||
143 | + let sendTimer = setInterval(function(){ | ||
144 | + that.isDisable = true; | ||
145 | + time--; | ||
146 | + that.btnTitle = time + '秒后重试'; | ||
147 | + if(time <=0){ | ||
148 | + that.isDisable = false; | ||
149 | + clearInterval(sendTimer); | ||
150 | + that.btnTitle = "获取验证码"; | ||
151 | + } | ||
152 | + },1000) | ||
153 | + | ||
154 | + /* | ||
138 | let time = 60; | 155 | let time = 60; |
139 | let timer = setInterval(() => { | 156 | let timer = setInterval(() => { |
140 | if(time == 0) { | 157 | if(time == 0) { |
141 | clearInterval(timer); | 158 | clearInterval(timer); |
142 | - this.disabled = false; | ||
143 | - this.btnTitle = "获取验证码"; | 159 | + that.disabled = false; |
160 | + that.btnTitle = "获取验证码"; | ||
144 | } else { | 161 | } else { |
145 | - this.btnTitle =time + '秒后重试'; | ||
146 | - this.disabled = true; | 162 | + that.btnTitle =time + '秒后重试'; |
163 | + that.disabled = true; | ||
147 | time-- | 164 | time-- |
148 | } | 165 | } |
149 | - },1000) | 166 | + },1000)*/ |
150 | }, | 167 | }, |
151 | handleLogin() { | 168 | handleLogin() { |
152 | this.$refs.loginForm.validate(valid => { | 169 | this.$refs.loginForm.validate(valid => { |