fix(kyc): 修复更换手机号页面发送验证码按钮可重复点击的问题

- 添加 _isSendingCode 状态检查,防止发送中重复点击
- 发送中显示 loading 指示器
- 倒计时期间和发送中均禁用按钮

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
hailin 2025-12-24 07:38:26 -08:00
parent 0f745a17fd
commit 0a4ec49c8a
1 changed files with 20 additions and 10 deletions

View File

@ -587,9 +587,10 @@ class _ChangePhonePageState extends ConsumerState<ChangePhonePage> {
} }
Widget _buildSendCodeButton(Future<void> Function() onSend) { Widget _buildSendCodeButton(Future<void> Function() onSend) {
final canSend = _countdown == 0 && !_isSendingCode;
return Center( return Center(
child: GestureDetector( child: GestureDetector(
onTap: _countdown > 0 ? null : () async { onTap: canSend ? () async {
try { try {
await onSend(); await onSend();
} catch (e) { } catch (e) {
@ -599,15 +600,24 @@ class _ChangePhonePageState extends ConsumerState<ChangePhonePage> {
}); });
} }
} }
}, } : null,
child: Text( child: _isSendingCode
_countdown > 0 ? '$_countdown秒后重新发送' : '发送验证码', ? SizedBox(
style: TextStyle( width: 20.sp,
fontSize: 14.sp, height: 20.sp,
fontWeight: FontWeight.w500, child: const CircularProgressIndicator(
color: _countdown > 0 ? const Color(0xFF999999) : const Color(0xFF2E7D32), strokeWidth: 2,
), valueColor: AlwaysStoppedAnimation<Color>(Color(0xFF999999)),
), ),
)
: Text(
_countdown > 0 ? '$_countdown秒后重新发送' : '发送验证码',
style: TextStyle(
fontSize: 14.sp,
fontWeight: FontWeight.w500,
color: canSend ? const Color(0xFF2E7D32) : const Color(0xFF999999),
),
),
), ),
); );
} }