From 05040b3495626b719b4037f3af92528297ed1f0f Mon Sep 17 00:00:00 2001 From: hailin Date: Wed, 10 Dec 2025 20:13:52 -0800 Subject: [PATCH] feat(mobile): integrate community hierarchy API in profile page MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Call getMyCommunityHierarchy() to get parent/child community info - Display parent community name (defaults to 总部社区 if none) - Display child communities count and first name 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 --- .../presentation/pages/profile_page.dart | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/frontend/mobile-app/lib/features/profile/presentation/pages/profile_page.dart b/frontend/mobile-app/lib/features/profile/presentation/pages/profile_page.dart index 58ba5244..be692b65 100644 --- a/frontend/mobile-app/lib/features/profile/presentation/pages/profile_page.dart +++ b/frontend/mobile-app/lib/features/profile/presentation/pages/profile_page.dart @@ -295,13 +295,28 @@ class _ProfilePageState extends ConsumerState { debugPrint('[ProfilePage] 市公司授权: ${summary.cityCompany != null}'); debugPrint('[ProfilePage] 省公司授权: ${summary.provinceCompany != null}'); + // 获取社区层级数据 + try { + final hierarchy = await authorizationService.getMyCommunityHierarchy(); + if (mounted) { + setState(() { + _parentCommunity = hierarchy.parentCommunity.communityName; + _childCommunity = hierarchy.childCommunityCount > 0 + ? '${hierarchy.childCommunities.first.communityName}${hierarchy.childCommunityCount > 1 ? " 等${hierarchy.childCommunityCount}个" : ""}' + : '--'; + }); + } + debugPrint('[ProfilePage] 社区层级: 上级=${hierarchy.parentCommunity.communityName}, 下级数量=${hierarchy.childCommunityCount}'); + } catch (e) { + debugPrint('[ProfilePage] 获取社区层级失败: $e'); + // 失败时保持默认值 + } + if (mounted) { setState(() { _community = summary.communityName ?? '--'; _cityCompany = summary.cityCompanyName ?? '--'; _provinceCompany = summary.provinceCompanyName ?? '--'; - // 上级社区和下级社区暂时无法从当前API获取 - // 后续需要扩展API或从推荐链中计算 // 更新社区考核数据 if (summary.community != null) {