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 { Row, Input, Col, Button } from 'antd';
import useCountDown from '@/utils/hooks'; import useCountDown from '@/utils/hooks';
import { PublicApi } from '@/services/api';
const Phone = (props) => { const Phone = (props) => {
const {text, isActive, start} = useCountDown({ const {text, isActive, start} = useCountDown({
...@@ -12,7 +13,22 @@ const Phone = (props) => { ...@@ -12,7 +13,22 @@ const Phone = (props) => {
delay: 1 * 1000 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 ( return (
<Row style={{width: '100%'}}> <Row style={{width: '100%'}}>
<Col flex={1}> <Col flex={1}>
...@@ -23,7 +39,7 @@ const Phone = (props) => { ...@@ -23,7 +39,7 @@ const Phone = (props) => {
/> />
</Col> </Col>
<Col style={{marginLeft: 8}}> <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> </Col>
</Row> </Row>
) )
......
...@@ -178,6 +178,18 @@ const UserRegistry = () => { ...@@ -178,6 +178,18 @@ const UserRegistry = () => {
delay: 1 * 1000 delay: 1 * 1000
}) })
const handleSendSMS = () => {
actions.validate('phone').then(result => {
console.log(result)
})
// actions.getFieldState('phone', state => {
// console.
// if (state.valid) {
// start()
// }
// })
}
const handleActionBtn = () => { const handleActionBtn = () => {
// 校验后触发跳转 // 校验后触发跳转
actions.submit(data => { actions.submit(data => {
...@@ -260,7 +272,7 @@ const UserRegistry = () => { ...@@ -260,7 +272,7 @@ const UserRegistry = () => {
expressionScope={{ expressionScope={{
current: false, current: false,
phoneBefore: <div className={'formBefore'}>+86</div>, 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'> 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>)) 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 = () => { ...@@ -269,6 +281,7 @@ const UserRegistry = () => {
</span>, </span>,
memberTypeTitle: <span className={'commonPanelTitle'}>请选择您的身份</span>, memberTypeTitle: <span className={'commonPanelTitle'}>请选择您的身份</span>,
businessTypeTitle: <span className={'commonPanelTitle'}>请选择您要开展的业务</span>, businessTypeTitle: <span className={'commonPanelTitle'}>请选择您要开展的业务</span>,
memberChooseList: []
}} }}
/> />
<div className={cx('registerForm', 'global-block-center')}> <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