fix(security): 修复支付密码页面加载失败时静默降级为设置模式的 bug

加载状态失败时改为显示错误提示和重试按钮,避免误导用户认为未设置支付密码。

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
hailin 2026-03-05 08:19:44 -08:00
parent a1d284b6b5
commit 405e7e407e
1 changed files with 20 additions and 2 deletions

View File

@ -31,6 +31,7 @@ class _ChangePaymentPasswordPageState
bool _isSubmitting = false; bool _isSubmitting = false;
bool _hasPaymentPassword = false; bool _hasPaymentPassword = false;
bool _isLoading = true; bool _isLoading = true;
bool _isLoadError = false;
@override @override
void initState() { void initState() {
@ -60,7 +61,7 @@ class _ChangePaymentPasswordPageState
} catch (e) { } catch (e) {
if (mounted) { if (mounted) {
setState(() { setState(() {
_hasPaymentPassword = false; _isLoadError = true;
_isLoading = false; _isLoading = false;
}); });
} }
@ -160,7 +161,24 @@ class _ChangePaymentPasswordPageState
Color(0xFFD4AF37)), Color(0xFFD4AF37)),
), ),
) )
: SingleChildScrollView( : _isLoadError
? Center(
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
const Icon(Icons.error_outline, color: Colors.red, size: 48),
const SizedBox(height: 12),
const Text('加载失败,请重试', style: TextStyle(color: Colors.red)),
const SizedBox(height: 16),
ElevatedButton(
onPressed: _loadStatus,
style: ElevatedButton.styleFrom(backgroundColor: const Color(0xFFD4AF37)),
child: const Text('重试', style: TextStyle(color: Colors.white)),
),
],
),
)
: SingleChildScrollView(
padding: const EdgeInsets.all(16), padding: const EdgeInsets.all(16),
child: Column( child: Column(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,