| | |
| | | <template> |
| | | <view class="c-input-phone-code"> |
| | | <AtInput |
| | | :name="itemData.name" |
| | | :title="itemData.label" |
| | | :name="itemRes.name" |
| | | :title="itemRes.label" |
| | | type="text" |
| | | :placeholder="placeholder" |
| | | :required="itemData.required" |
| | | :error="itemData.error" |
| | | :value="itemData.formData[itemData.name]" |
| | | :onChange="evt=>itemData.onChange(evt)" |
| | | :required="itemRes.required" |
| | | :error="itemRes.error" |
| | | :value="itemRes.formData[itemRes.name]" |
| | | :onChange="evt=>itemRes.onChange(evt)" |
| | | > |
| | | <AtButton |
| | | class="c-input-phone-btn" |
| | |
| | | }, |
| | | props: { |
| | | placeholder: String, |
| | | itemData: Object, |
| | | itemRes: Object, |
| | | autoStart: { type: Boolean, default: true }, |
| | | onCallPhoneCode: Function, |
| | | }, |
| | | data() { |
| | |
| | | if (this.holding) { |
| | | return; |
| | | } |
| | | this.holding = true; |
| | | this.cd = 60; |
| | | this.onCallPhoneCode(); |
| | | const timer = setInterval(() => { |
| | | this.cd -= 1; |
| | | if (this.cd === 0) { |
| | | this.holding = false; |
| | | this.cd = 60; |
| | | } |
| | | }, 1000); |
| | | const startCD = () => { |
| | | this.holding = true; |
| | | this.cd = 60; |
| | | setInterval(() => { |
| | | this.cd -= 1; |
| | | if (this.cd === 0) { |
| | | this.holding = false; |
| | | this.cd = 60; |
| | | } |
| | | }, 1000); |
| | | }; |
| | | if (this.autoStart) { |
| | | startCD(); |
| | | this.onCallPhoneCode(() => null); |
| | | } else { |
| | | this.onCallPhoneCode(() => { |
| | | startCD(); |
| | | }); |
| | | } |
| | | }, |
| | | }, |
| | | }; |