From 7a8fca67023e35bac07a7384c4d46d3e98ebb23c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B5=B5=E5=BF=A0=E6=9E=97?= <170083662@qq.com> Date: Mon, 17 Nov 2025 12:08:29 +0800 Subject: [PATCH] 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 --- src/dealer/apply/add.tsx | 17 ++++++++++++++++- src/dealer/capital/index.tsx | 6 +++++- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/src/dealer/apply/add.tsx b/src/dealer/apply/add.tsx index 87c2656..674ed61 100644 --- a/src/dealer/apply/add.tsx +++ b/src/dealer/apply/add.tsx @@ -29,6 +29,7 @@ interface InputEvent { const AddUserAddress = () => { const {user, loginUser} = useUser() const [loading, setLoading] = useState(true) + const [submitting, setSubmitting] = useState(false) const [FormData, setFormData] = useState() const formRef = useRef(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 = () => { {/* 底部浮动按钮 */} } - text={'立即注册'} + text={submitting ? '注册中...' : '立即注册'} onClick={handleFixedButtonClick} + disabled={submitting} /> diff --git a/src/dealer/capital/index.tsx b/src/dealer/capital/index.tsx index cbb458c..03aea19 100644 --- a/src/dealer/capital/index.tsx +++ b/src/dealer/capital/index.tsx @@ -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) {