feat(dealer): add submission prevention and loading state to registration
- Add submitting state to prevent duplicate form submissions - Show loading indicator during registration process - Display toast message on registration failure - Reset submitting state in error handling - Disable register button during submission - Update capital calculation logic with proper money aggregation
This commit is contained in:
@@ -29,6 +29,7 @@ interface InputEvent {
|
||||
const AddUserAddress = () => {
|
||||
const {user, loginUser} = useUser()
|
||||
const [loading, setLoading] = useState<boolean>(true)
|
||||
const [submitting, setSubmitting] = useState<boolean>(false)
|
||||
const [FormData, setFormData] = useState<User>()
|
||||
const formRef = useRef<any>(null)
|
||||
|
||||
@@ -129,6 +130,13 @@ const AddUserAddress = () => {
|
||||
|
||||
// 提交表单
|
||||
const submitSucceed = async (values: any) => {
|
||||
// 防止重复提交
|
||||
if (submitting) {
|
||||
console.log('正在提交中,请勿重复点击')
|
||||
return
|
||||
}
|
||||
|
||||
setSubmitting(true)
|
||||
try {
|
||||
// 验证必填字段
|
||||
if (!values.phone && !FormData?.phone) {
|
||||
@@ -229,6 +237,12 @@ const AddUserAddress = () => {
|
||||
|
||||
} catch (error) {
|
||||
console.error('验证邀请人失败:', error);
|
||||
Taro.showToast({
|
||||
title: '注册失败,请重试',
|
||||
icon: 'error'
|
||||
})
|
||||
} finally {
|
||||
setSubmitting(false)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -437,8 +451,9 @@ const AddUserAddress = () => {
|
||||
{/* 底部浮动按钮 */}
|
||||
<FixedButton
|
||||
icon={<Edit/>}
|
||||
text={'立即注册'}
|
||||
text={submitting ? '注册中...' : '立即注册'}
|
||||
onClick={handleFixedButtonClick}
|
||||
disabled={submitting}
|
||||
/>
|
||||
|
||||
</>
|
||||
|
||||
@@ -49,7 +49,11 @@ const DealerCapital: React.FC = () => {
|
||||
...item,
|
||||
orderNo: item.orderNo
|
||||
}))
|
||||
// 统计totayMoney
|
||||
// 通过result.list 返回的数据统计totalMoney
|
||||
setTotayMoney(newCapital.reduce((acc, cur) => acc + Number(cur.money), 0))
|
||||
|
||||
// 本月收益汇总
|
||||
// setTotayMoney(result.totalMoney)
|
||||
|
||||
|
||||
if (page === 1) {
|
||||
|
||||
Reference in New Issue
Block a user