Commit 7ce0b7cc authored by 前端-许佳敏's avatar 前端-许佳敏

feat:新增短信验证码接口

parent e5a4b529
import React from 'react'
import React, { useState } from 'react'
import { Row, Input, Col, Button } from 'antd';
import useCountDown from '@/utils/hooks';
import { PublicApi } from '@/services/api';
const Phone = (props) => {
const {text, isActive, start} = useCountDown({
......@@ -12,7 +13,22 @@ const Phone = (props) => {
delay: 1 * 1000
})
const { value } = props
const { value, form } = props
const [loading, setLoading] = useState(false)
const handleClickSms = () => {
form.validate('phone').then(result => {
// 暂时写死, 需优化该组件
setLoading(true)
PublicApi.postMemberRegisterSms({
countryCode: '+86',
phone: form.getFieldValue('phone')
}).finally(() => {
start()
setLoading(false)
})
})
}
return (
<Row style={{width: '100%'}}>
<Col flex={1}>
......@@ -23,7 +39,7 @@ const Phone = (props) => {
/>
</Col>
<Col style={{marginLeft: 8}}>
<Button disabled={isActive} style={{minWidth: 110, marginLeft: 8}} size='large' onClick={start}>{text}</Button>
<Button disabled={isActive} style={{minWidth: 110, marginLeft: 8}} loading={loading} size='large' onClick={handleClickSms}>{text}</Button>
</Col>
</Row>
)
......
......@@ -178,6 +178,18 @@ const UserRegistry = () => {
delay: 1 * 1000
})
const handleSendSMS = () => {
actions.validate('phone').then(result => {
console.log(result)
})
// actions.getFieldState('phone', state => {
// console.
// if (state.valid) {
// start()
// }
// })
}
const handleActionBtn = () => {
// 校验后触发跳转
actions.submit(data => {
......@@ -260,7 +272,7 @@ const UserRegistry = () => {
expressionScope={{
current: false,
phoneBefore: <div className={'formBefore'}>+86</div>,
smsCodeAfter: <Button disabled={isActive} style={{ minWidth: 110, marginLeft: 8 }} size='large' onClick={start}>{text}</Button>,
smsCodeAfter: <Button disabled={isActive} style={{ minWidth: 110, marginLeft: 8 }} size='large' onClick={handleSendSMS}>{text}</Button>,
checkBoxChildren: <span style={{ fontSize: 12 }}>阅读并同意<span className='commonPickColor'>
{
agreementList && agreementList.map(item => (<a key={`aggreem_${item.id}`} href={`/user/agreement?id=${item.id}`} target="_blank">{item.title}</a>))
......@@ -269,6 +281,7 @@ const UserRegistry = () => {
</span>,
memberTypeTitle: <span className={'commonPanelTitle'}>请选择您的身份</span>,
businessTypeTitle: <span className={'commonPanelTitle'}>请选择您要开展的业务</span>,
memberChooseList: []
}}
/>
<div className={cx('registerForm', 'global-block-center')}>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment