fix(payment-password): 优化未设置支付密码时的错误提示

- 识别后端"尚未设置支付密码"异常,显示明确引导语
  "请先前往「我的」→「支付密码」完成设置",替代误导性的"请检查网络"
- 简化空输入提示逻辑(直接使用 widget.hint)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
hailin 2026-03-05 06:21:25 -08:00
parent cad7ebe832
commit 71774f301d
1 changed files with 10 additions and 5 deletions

View File

@ -92,13 +92,14 @@ class _PasswordVerifyDialogState extends State<PasswordVerifyDialog> {
/// ///
/// 1. /// 1.
/// 2. [onVerify] /// 2. [onVerify]
/// 3. valid=true true /// 3. valid=true true
/// 4. valid=false "密码错误" /// 4. valid=false "密码错误"
/// 5. /// 5. "尚未设置支付密码"
/// 6.
Future<void> _handleConfirm() async { Future<void> _handleConfirm() async {
final password = _passwordController.text.trim(); final password = _passwordController.text.trim();
if (password.isEmpty) { if (password.isEmpty) {
setState(() => _errorMessage = '请输入${widget.hint.replaceAll('请输入', '')}'); setState(() => _errorMessage = widget.hint);
return; return;
} }
@ -121,11 +122,15 @@ class _PasswordVerifyDialogState extends State<PasswordVerifyDialog> {
}); });
} }
} catch (e) { } catch (e) {
// /
if (!mounted) return; if (!mounted) return;
final msg = e.toString();
// "网络错误"
final isNotSet = msg.contains('尚未设置支付密码') || msg.contains('payment password not set');
setState(() { setState(() {
_isVerifying = false; _isVerifying = false;
_errorMessage = '验证失败,请检查网络后重试'; _errorMessage = isNotSet
? '请先前往「我的」→「支付密码」完成设置'
: '验证失败,请检查网络后重试';
}); });
} }
} }