| | |
| | | }, |
| | | // 发送请求,通知后端给手机发验证码 |
| | | onCallPhoneCode: Function, |
| | | // 刷新cd后,通知父组件更新图片地址 |
| | | onRefreshCD: { |
| | | type: Function, |
| | | default: () => () => null, |
| | | }, |
| | | }, |
| | | data() { |
| | | return { |
| | | cd: 60, |
| | | holding: false, |
| | | timer: null, |
| | | }; |
| | | }, |
| | | computed: { |
| | |
| | | const startCD = () => { |
| | | this.holding = true; |
| | | this.cd = 60; |
| | | setInterval(() => { |
| | | clearInterval(this.timer); |
| | | this.timer = setInterval(() => { |
| | | this.cd -= 1; |
| | | if (this.cd === 0) { |
| | | this.holding = false; |
| | | this.cd = 60; |
| | | this.onRefreshCD(true); |
| | | } |
| | | }, 1000); |
| | | }; |
| | |
| | | }); |
| | | } |
| | | }, |
| | | // 重置holding |
| | | $resetHolding() { |
| | | this.holding = false; |
| | | }, |
| | | }, |
| | | }; |
| | | </script> |