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:
2025-11-17 12:08:29 +08:00
parent 23cca3cd3c
commit 7a8fca6702
2 changed files with 21 additions and 2 deletions

View File

@@ -29,6 +29,7 @@ interface InputEvent {
const AddUserAddress = () => { const AddUserAddress = () => {
const {user, loginUser} = useUser() const {user, loginUser} = useUser()
const [loading, setLoading] = useState<boolean>(true) const [loading, setLoading] = useState<boolean>(true)
const [submitting, setSubmitting] = useState<boolean>(false)
const [FormData, setFormData] = useState<User>() const [FormData, setFormData] = useState<User>()
const formRef = useRef<any>(null) const formRef = useRef<any>(null)
@@ -129,6 +130,13 @@ const AddUserAddress = () => {
// 提交表单 // 提交表单
const submitSucceed = async (values: any) => { const submitSucceed = async (values: any) => {
// 防止重复提交
if (submitting) {
console.log('正在提交中,请勿重复点击')
return
}
setSubmitting(true)
try { try {
// 验证必填字段 // 验证必填字段
if (!values.phone && !FormData?.phone) { if (!values.phone && !FormData?.phone) {
@@ -229,6 +237,12 @@ const AddUserAddress = () => {
} catch (error) { } catch (error) {
console.error('验证邀请人失败:', error); console.error('验证邀请人失败:', error);
Taro.showToast({
title: '注册失败,请重试',
icon: 'error'
})
} finally {
setSubmitting(false)
} }
} }
@@ -437,8 +451,9 @@ const AddUserAddress = () => {
{/* 底部浮动按钮 */} {/* 底部浮动按钮 */}
<FixedButton <FixedButton
icon={<Edit/>} icon={<Edit/>}
text={'立即注册'} text={submitting ? '注册中...' : '立即注册'}
onClick={handleFixedButtonClick} onClick={handleFixedButtonClick}
disabled={submitting}
/> />
</> </>

View File

@@ -49,7 +49,11 @@ const DealerCapital: React.FC = () => {
...item, ...item,
orderNo: item.orderNo orderNo: item.orderNo
})) }))
// 统计totayMoney // 通过result.list 返回的数据统计totalMoney
setTotayMoney(newCapital.reduce((acc, cur) => acc + Number(cur.money), 0))
// 本月收益汇总
// setTotayMoney(result.totalMoney)
if (page === 1) { if (page === 1) {