feat(mobile): add auth-province and auth-city company display in profile page
- Add authProvinceCompany and authCityCompany to RoleType enum - Update UserAuthorizationSummary to support all role types - Update profile page to display all authorization types 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
4bf4efb1f4
commit
26427443fe
|
|
@ -5,8 +5,10 @@ import '../constants/api_endpoints.dart';
|
||||||
/// 角色类型
|
/// 角色类型
|
||||||
enum RoleType {
|
enum RoleType {
|
||||||
community,
|
community,
|
||||||
provinceCompany,
|
authProvinceCompany, // 省团队
|
||||||
cityCompany,
|
provinceCompany, // 省区域
|
||||||
|
authCityCompany, // 市团队
|
||||||
|
cityCompany, // 市区域
|
||||||
}
|
}
|
||||||
|
|
||||||
extension RoleTypeExtension on RoleType {
|
extension RoleTypeExtension on RoleType {
|
||||||
|
|
@ -14,8 +16,12 @@ extension RoleTypeExtension on RoleType {
|
||||||
switch (this) {
|
switch (this) {
|
||||||
case RoleType.community:
|
case RoleType.community:
|
||||||
return 'COMMUNITY';
|
return 'COMMUNITY';
|
||||||
|
case RoleType.authProvinceCompany:
|
||||||
|
return 'AUTH_PROVINCE_COMPANY';
|
||||||
case RoleType.provinceCompany:
|
case RoleType.provinceCompany:
|
||||||
return 'PROVINCE_COMPANY';
|
return 'PROVINCE_COMPANY';
|
||||||
|
case RoleType.authCityCompany:
|
||||||
|
return 'AUTH_CITY_COMPANY';
|
||||||
case RoleType.cityCompany:
|
case RoleType.cityCompany:
|
||||||
return 'CITY_COMPANY';
|
return 'CITY_COMPANY';
|
||||||
}
|
}
|
||||||
|
|
@ -25,10 +31,14 @@ extension RoleTypeExtension on RoleType {
|
||||||
switch (this) {
|
switch (this) {
|
||||||
case RoleType.community:
|
case RoleType.community:
|
||||||
return '社区';
|
return '社区';
|
||||||
|
case RoleType.authProvinceCompany:
|
||||||
|
return '省团队';
|
||||||
case RoleType.provinceCompany:
|
case RoleType.provinceCompany:
|
||||||
return '省公司';
|
return '省区域';
|
||||||
|
case RoleType.authCityCompany:
|
||||||
|
return '市团队';
|
||||||
case RoleType.cityCompany:
|
case RoleType.cityCompany:
|
||||||
return '市公司';
|
return '市区域';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -37,8 +47,12 @@ extension RoleTypeExtension on RoleType {
|
||||||
switch (value.toUpperCase()) {
|
switch (value.toUpperCase()) {
|
||||||
case 'COMMUNITY':
|
case 'COMMUNITY':
|
||||||
return RoleType.community;
|
return RoleType.community;
|
||||||
|
case 'AUTH_PROVINCE_COMPANY':
|
||||||
|
return RoleType.authProvinceCompany;
|
||||||
case 'PROVINCE_COMPANY':
|
case 'PROVINCE_COMPANY':
|
||||||
return RoleType.provinceCompany;
|
return RoleType.provinceCompany;
|
||||||
|
case 'AUTH_CITY_COMPANY':
|
||||||
|
return RoleType.authCityCompany;
|
||||||
case 'CITY_COMPANY':
|
case 'CITY_COMPANY':
|
||||||
return RoleType.cityCompany;
|
return RoleType.cityCompany;
|
||||||
default:
|
default:
|
||||||
|
|
@ -154,16 +168,22 @@ class AuthorizationResponse {
|
||||||
class UserAuthorizationSummary {
|
class UserAuthorizationSummary {
|
||||||
/// 社区授权 (如果有)
|
/// 社区授权 (如果有)
|
||||||
final AuthorizationResponse? community;
|
final AuthorizationResponse? community;
|
||||||
/// 省公司授权 (如果有)
|
/// 省团队授权 (如果有)
|
||||||
|
final AuthorizationResponse? authProvinceCompany;
|
||||||
|
/// 省区域授权 (如果有)
|
||||||
final AuthorizationResponse? provinceCompany;
|
final AuthorizationResponse? provinceCompany;
|
||||||
/// 市公司授权 (如果有)
|
/// 市团队授权 (如果有)
|
||||||
|
final AuthorizationResponse? authCityCompany;
|
||||||
|
/// 市区域授权 (如果有)
|
||||||
final AuthorizationResponse? cityCompany;
|
final AuthorizationResponse? cityCompany;
|
||||||
/// 所有授权列表
|
/// 所有授权列表
|
||||||
final List<AuthorizationResponse> allAuthorizations;
|
final List<AuthorizationResponse> allAuthorizations;
|
||||||
|
|
||||||
UserAuthorizationSummary({
|
UserAuthorizationSummary({
|
||||||
this.community,
|
this.community,
|
||||||
|
this.authProvinceCompany,
|
||||||
this.provinceCompany,
|
this.provinceCompany,
|
||||||
|
this.authCityCompany,
|
||||||
this.cityCompany,
|
this.cityCompany,
|
||||||
required this.allAuthorizations,
|
required this.allAuthorizations,
|
||||||
});
|
});
|
||||||
|
|
@ -174,15 +194,23 @@ class UserAuthorizationSummary {
|
||||||
/// 社区名称
|
/// 社区名称
|
||||||
String? get communityName => community?.displayTitle;
|
String? get communityName => community?.displayTitle;
|
||||||
|
|
||||||
/// 省公司名称
|
/// 省团队名称
|
||||||
|
String? get authProvinceCompanyName => authProvinceCompany?.displayTitle;
|
||||||
|
|
||||||
|
/// 省区域名称
|
||||||
String? get provinceCompanyName => provinceCompany?.displayTitle;
|
String? get provinceCompanyName => provinceCompany?.displayTitle;
|
||||||
|
|
||||||
/// 市公司名称
|
/// 市团队名称
|
||||||
|
String? get authCityCompanyName => authCityCompany?.displayTitle;
|
||||||
|
|
||||||
|
/// 市区域名称
|
||||||
String? get cityCompanyName => cityCompany?.displayTitle;
|
String? get cityCompanyName => cityCompany?.displayTitle;
|
||||||
|
|
||||||
factory UserAuthorizationSummary.fromList(List<AuthorizationResponse> authorizations) {
|
factory UserAuthorizationSummary.fromList(List<AuthorizationResponse> authorizations) {
|
||||||
AuthorizationResponse? community;
|
AuthorizationResponse? community;
|
||||||
|
AuthorizationResponse? authProvinceCompany;
|
||||||
AuthorizationResponse? provinceCompany;
|
AuthorizationResponse? provinceCompany;
|
||||||
|
AuthorizationResponse? authCityCompany;
|
||||||
AuthorizationResponse? cityCompany;
|
AuthorizationResponse? cityCompany;
|
||||||
|
|
||||||
for (final auth in authorizations) {
|
for (final auth in authorizations) {
|
||||||
|
|
@ -190,9 +218,15 @@ class UserAuthorizationSummary {
|
||||||
case RoleType.community:
|
case RoleType.community:
|
||||||
community = auth;
|
community = auth;
|
||||||
break;
|
break;
|
||||||
|
case RoleType.authProvinceCompany:
|
||||||
|
authProvinceCompany = auth;
|
||||||
|
break;
|
||||||
case RoleType.provinceCompany:
|
case RoleType.provinceCompany:
|
||||||
provinceCompany = auth;
|
provinceCompany = auth;
|
||||||
break;
|
break;
|
||||||
|
case RoleType.authCityCompany:
|
||||||
|
authCityCompany = auth;
|
||||||
|
break;
|
||||||
case RoleType.cityCompany:
|
case RoleType.cityCompany:
|
||||||
cityCompany = auth;
|
cityCompany = auth;
|
||||||
break;
|
break;
|
||||||
|
|
@ -201,7 +235,9 @@ class UserAuthorizationSummary {
|
||||||
|
|
||||||
return UserAuthorizationSummary(
|
return UserAuthorizationSummary(
|
||||||
community: community,
|
community: community,
|
||||||
|
authProvinceCompany: authProvinceCompany,
|
||||||
provinceCompany: provinceCompany,
|
provinceCompany: provinceCompany,
|
||||||
|
authCityCompany: authCityCompany,
|
||||||
cityCompany: cityCompany,
|
cityCompany: cityCompany,
|
||||||
allAuthorizations: authorizations,
|
allAuthorizations: authorizations,
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -35,8 +35,10 @@ class _ProfilePageState extends ConsumerState<ProfilePage> {
|
||||||
String _community = '--';
|
String _community = '--';
|
||||||
String _parentCommunity = '--';
|
String _parentCommunity = '--';
|
||||||
String _childCommunity = '--';
|
String _childCommunity = '--';
|
||||||
String _cityCompany = '--';
|
String _authCityCompany = '--'; // 市团队
|
||||||
String _provinceCompany = '--';
|
String _cityCompany = '--'; // 市区域
|
||||||
|
String _authProvinceCompany = '--'; // 省团队
|
||||||
|
String _provinceCompany = '--'; // 省区域
|
||||||
String _province = '--';
|
String _province = '--';
|
||||||
|
|
||||||
// 团队数据(从 referral-service 获取)
|
// 团队数据(从 referral-service 获取)
|
||||||
|
|
@ -292,8 +294,10 @@ class _ProfilePageState extends ConsumerState<ProfilePage> {
|
||||||
|
|
||||||
debugPrint('[ProfilePage] 授权数据加载成功:');
|
debugPrint('[ProfilePage] 授权数据加载成功:');
|
||||||
debugPrint('[ProfilePage] 社区授权: ${summary.community != null}');
|
debugPrint('[ProfilePage] 社区授权: ${summary.community != null}');
|
||||||
debugPrint('[ProfilePage] 市公司授权: ${summary.cityCompany != null}');
|
debugPrint('[ProfilePage] 市团队授权: ${summary.authCityCompany != null}');
|
||||||
debugPrint('[ProfilePage] 省公司授权: ${summary.provinceCompany != null}');
|
debugPrint('[ProfilePage] 市区域授权: ${summary.cityCompany != null}');
|
||||||
|
debugPrint('[ProfilePage] 省团队授权: ${summary.authProvinceCompany != null}');
|
||||||
|
debugPrint('[ProfilePage] 省区域授权: ${summary.provinceCompany != null}');
|
||||||
|
|
||||||
// 获取社区层级数据
|
// 获取社区层级数据
|
||||||
try {
|
try {
|
||||||
|
|
@ -315,7 +319,9 @@ class _ProfilePageState extends ConsumerState<ProfilePage> {
|
||||||
if (mounted) {
|
if (mounted) {
|
||||||
setState(() {
|
setState(() {
|
||||||
_community = summary.communityName ?? '--';
|
_community = summary.communityName ?? '--';
|
||||||
|
_authCityCompany = summary.authCityCompanyName ?? '--';
|
||||||
_cityCompany = summary.cityCompanyName ?? '--';
|
_cityCompany = summary.cityCompanyName ?? '--';
|
||||||
|
_authProvinceCompany = summary.authProvinceCompanyName ?? '--';
|
||||||
_provinceCompany = summary.provinceCompanyName ?? '--';
|
_provinceCompany = summary.provinceCompanyName ?? '--';
|
||||||
|
|
||||||
// 更新社区考核数据
|
// 更新社区考核数据
|
||||||
|
|
@ -882,26 +888,38 @@ class _ProfilePageState extends ConsumerState<ProfilePage> {
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
const SizedBox(height: 12),
|
const SizedBox(height: 12),
|
||||||
// 第二行:所属社区 | 授权市公司
|
// 第二行:所属社区 | 市团队
|
||||||
Row(
|
Row(
|
||||||
children: [
|
children: [
|
||||||
Expanded(
|
Expanded(
|
||||||
child: _buildInfoItem('所属社区', _community),
|
child: _buildInfoItem('所属社区', _community),
|
||||||
),
|
),
|
||||||
Expanded(
|
Expanded(
|
||||||
child: _buildInfoItem('授权市公司', _cityCompany),
|
child: _buildInfoItem('市团队', _authCityCompany),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
const SizedBox(height: 12),
|
const SizedBox(height: 12),
|
||||||
// 第三行:上级社区 | 授权省公司
|
// 第三行:上级社区 | 市区域
|
||||||
Row(
|
Row(
|
||||||
children: [
|
children: [
|
||||||
Expanded(
|
Expanded(
|
||||||
child: _buildInfoItem('上级社区', _parentCommunity),
|
child: _buildInfoItem('上级社区', _parentCommunity),
|
||||||
),
|
),
|
||||||
Expanded(
|
Expanded(
|
||||||
child: _buildInfoItem('授权省公司', _provinceCompany),
|
child: _buildInfoItem('市区域', _cityCompany),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
const SizedBox(height: 12),
|
||||||
|
// 第四行:省团队 | 省区域
|
||||||
|
Row(
|
||||||
|
children: [
|
||||||
|
Expanded(
|
||||||
|
child: _buildInfoItem('省团队', _authProvinceCompany),
|
||||||
|
),
|
||||||
|
Expanded(
|
||||||
|
child: _buildInfoItem('省区域', _provinceCompany),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue