ProFormCaptcha获取验证码之前进行图形验证码校验


 <ProFormCaptcha
                                label="验证码"
                                placeholder={intl.formatMessage({
                                    id: 'pages.login.captcha.placeholder',
                                    defaultMessage: '请输入验证码',
                                })}
                                captchaTextRender={(timing, count) => {
                                    if (timing) {
                                        return `${count} ${intl.formatMessage({
                                            id: 'pages.getCaptchaSecondText',
                                            defaultMessage: '获取验证码',
                                        })}`;
                                    }
                                    return intl.formatMessage({
                                        id: 'pages.login.phoneLogin.getVerificationCode',
                                        defaultMessage: '获取验证码',
                                    });
                                }}
                                phoneName="phone"
                                name="code"
                                rules={[
                                    {
                                        required: true,
                                        message: (
                                            <FormattedMessage
                                                id="pages.login.captcha.required"
                                                defaultMessage="请输入验证码"
                                            />
                                        ),
                                    },
                                ]}
                                onGetCaptcha={onGetCaptcha}
                            />

  • 下边是onGetCaptcha
  const onGetCaptcha = async (phone) => {
        await waitTime();
    }

const waitTime = () => {
        return new Promise((resolve) => {
            dispatch({
                type: "openModal",
                payload: {
                    modalVisible: true
                }
            })
            window.resolve = resolve;  
        });
    };

这里有个关键的地方,把promise的resolve挂载到window上 然后弹窗操作完 再调用 window.resolve

        window.resolve && window.resolve();
              window.resolve = null;


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM