fix(mobile-app): 不依赖本地状态,直接显示序列号

问题:用户有序列号但 isAccountCreated 为 false 时显示"审核中"

修复:
1. _buildSerialNumberOrStatus(): 只要有有效序列号就直接显示
2. _checkAndStartWalletPolling(): 只要有序列号就调用 API 检查钱包状态
3. 不再依赖本地的 isAccountCreated/isWalletReady 状态

🤖 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-22 02:05:27 -08:00
parent 8fa975a19e
commit fefaeb29d6
1 changed files with 38 additions and 46 deletions

View File

@ -801,47 +801,48 @@ class _ProfilePageState extends ConsumerState<ProfilePage> {
debugPrint('[ProfilePage] authState.isAccountCreated: ${authState.isAccountCreated}');
debugPrint('[ProfilePage] _serialNumber: $_serialNumber');
//
if (authState.isWalletReady) {
debugPrint('[ProfilePage] Wallet already ready (local), skip polling');
// serialNumber API
// isAccountCreated
if (_serialNumber.isEmpty || _serialNumber == '--') {
debugPrint('[ProfilePage] Skip wallet check - no valid serialNumber');
return;
}
// API
if (authState.isAccountCreated && _serialNumber.isNotEmpty && _serialNumber != '--') {
debugPrint('[ProfilePage] Checking wallet status from API...');
try {
final accountService = ref.read(accountServiceProvider);
final walletInfo = await accountService.getWalletInfo(_serialNumber);
// API
debugPrint('[ProfilePage] Checking wallet status from API...');
try {
final accountService = ref.read(accountServiceProvider);
final walletInfo = await accountService.getWalletInfo(_serialNumber);
if (walletInfo.isReady) {
//
debugPrint('[ProfilePage] Wallet is ready, updating local storage');
final secureStorage = ref.read(secureStorageProvider);
await secureStorage.write(key: StorageKeys.isWalletReady, value: 'true');
debugPrint('[ProfilePage] Wallet status from API: isReady=${walletInfo.isReady}, isGenerating=${walletInfo.isGenerating}');
// authProvider
await ref.read(authProvider.notifier).checkAuthStatus();
if (walletInfo.isReady) {
//
debugPrint('[ProfilePage] Wallet is ready, updating local storage');
final secureStorage = ref.read(secureStorageProvider);
await secureStorage.write(key: StorageKeys.isWalletReady, value: 'true');
await secureStorage.write(key: StorageKeys.isAccountCreated, value: 'true');
// walletStatusProvider
ref.read(walletStatusProvider.notifier).stopPolling();
// authProvider
await ref.read(authProvider.notifier).checkAuthStatus();
// UI
if (mounted) {
setState(() {});
}
return;
// walletStatusProvider
ref.read(walletStatusProvider.notifier).stopPolling();
// UI
if (mounted) {
setState(() {});
}
} catch (e) {
debugPrint('[ProfilePage] Failed to check wallet status: $e');
return;
}
//
debugPrint('[ProfilePage] Wallet not ready, starting polling');
await ref.read(walletStatusProvider.notifier).startPolling();
} else {
debugPrint('[ProfilePage] Skip wallet check - conditions not met');
debugPrint('[ProfilePage] isAccountCreated=${authState.isAccountCreated}, serialNumber=$_serialNumber');
} catch (e) {
debugPrint('[ProfilePage] Failed to check wallet status: $e');
// API
await ref.read(walletStatusProvider.notifier).startPolling();
}
}
@ -4073,8 +4074,9 @@ class _ProfilePageState extends ConsumerState<ProfilePage> {
final walletStatus = ref.watch(walletStatusProvider);
final authState = ref.watch(authProvider);
//
if (authState.isWalletReady || walletStatus.isReady) {
//
// isWalletReady/isAccountCreated
if (_serialNumber.isNotEmpty && _serialNumber != '--') {
return Row(
children: [
Text(
@ -4099,8 +4101,8 @@ class _ProfilePageState extends ConsumerState<ProfilePage> {
);
}
// "账号创建审核中"
if (authState.isAccountCreated && !authState.isWalletReady) {
// walletStatus API
if (walletStatus.isGenerating) {
return Row(
children: [
const SizedBox(
@ -4113,7 +4115,7 @@ class _ProfilePageState extends ConsumerState<ProfilePage> {
),
const SizedBox(width: 8),
Text(
'账号创建审核中',
'钱包生成中...',
style: const TextStyle(
fontSize: 14,
fontFamily: 'Inter',
@ -4126,26 +4128,16 @@ class _ProfilePageState extends ConsumerState<ProfilePage> {
);
}
// unknown/generating状态"创建账号审核中..."
// "--"
return Row(
children: [
const SizedBox(
width: 12,
height: 12,
child: CircularProgressIndicator(
strokeWidth: 2,
valueColor: AlwaysStoppedAnimation<Color>(Color(0xFFD4AF37)),
),
),
const SizedBox(width: 8),
Text(
'创建账号审核中...',
'序列号: --',
style: const TextStyle(
fontSize: 14,
fontFamily: 'Inter',
height: 1.5,
color: Color(0xFFD4AF37),
fontStyle: FontStyle.italic,
color: Color(0xCC5D4037),
),
),
],