From ff8431c70aa80329585b7fcdfac6acb7a7efbb3e Mon Sep 17 00:00:00 2001 From: Jolie <> Date: Fri, 7 Nov 2025 01:17:14 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E5=A4=B4=E5=83=8F=E5=AE=A1?= =?UTF-8?q?=E6=A0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/controller/mine/user_info_controller.dart | 71 ++++++++++++++----- lib/network/api_urls.dart | 1 + lib/network/user_api.dart | 5 ++ lib/network/user_api.g.dart | 34 +++++++++ lib/pages/home/home_page.dart | 67 ++++++++--------- 5 files changed, 126 insertions(+), 52 deletions(-) diff --git a/lib/controller/mine/user_info_controller.dart b/lib/controller/mine/user_info_controller.dart index 1b5b651..0586d41 100644 --- a/lib/controller/mine/user_info_controller.dart +++ b/lib/controller/mine/user_info_controller.dart @@ -75,7 +75,7 @@ class UserInfoController extends GetxController { if (photo != null) { avatarLocalPath.value = photo.path; - SmartDialog.showToast('已选择照片'); + await processSelectedImage(File(photo.path)); } } catch (e) { print('拍照失败: $e'); @@ -94,13 +94,13 @@ class UserInfoController extends GetxController { Future handleGallerySelection() async { try { // 请求相册/照片权限 - // final ok = await _ensurePermission( - // Permission.photos, - // // Android 上 photos 等价于 storage/mediaLibrary,permission_handler 会映射 - // denyToast: '相册权限被拒绝,请在设置中允许访问相册', + final ok = await _ensurePermission( + Permission.photos, + // Android 上 photos 等价于 storage/mediaLibrary,permission_handler 会映射 + denyToast: '相册权限被拒绝,请在设置中允许访问相册', - // ); - // if (!ok) return; + ); + if (!ok) return; // 从相册选择图片 final ImagePicker picker = ImagePicker(); @@ -108,7 +108,7 @@ class UserInfoController extends GetxController { if (image != null) { avatarLocalPath.value = image.path; - // SmartDialog.showToast('已选择图片'); + await processSelectedImage(File(image.path)); } } catch (e) { print('选择图片失败: $e'); @@ -153,17 +153,17 @@ class UserInfoController extends GetxController { Future processSelectedImage(File imageFile) async { try { // 显示加载提示 - SmartDialog.showLoading(msg: '提交信息中...'); + SmartDialog.showLoading(msg: '设置头像中...'); String objectName = '${DateUtil.getNowDateMs()}.${imageFile.path.split('.').last}'; String imageUrl = await OSSManager.instance.uploadFile(imageFile.readAsBytesSync(), objectName); print('上传成功,图片URL: $imageUrl'); avatarUrl.value = imageUrl; SmartDialog.dismiss(); - // SmartDialog.showToast('头像设置成功'); + SmartDialog.showToast('头像设置成功'); } catch (e) { SmartDialog.dismiss(); print('处理图片失败: $e'); - SmartDialog.showToast('提交失败,请重试'); + SmartDialog.showToast('设置头像失败,请重试'); } } @@ -200,7 +200,7 @@ class UserInfoController extends GetxController { } // 验证头像(必须选择) - if (avatarUrl.value.isEmpty && avatarLocalPath.value.isEmpty) { + if (avatarUrl.value.isEmpty) { SmartDialog.showToast('请先选择头像'); return false; } @@ -247,10 +247,7 @@ class UserInfoController extends GetxController { isSubmitting.value = true; try { - // 若还未上传远程头像,但已选择本地头像,则先上传 - if (avatarUrl.value.isEmpty && avatarLocalPath.value.isNotEmpty) { - await processSelectedImage(File(avatarLocalPath.value)); - } + // 构建请求参数 final params = _buildSubmitParams(); @@ -266,6 +263,48 @@ class UserInfoController extends GetxController { // 处理响应 if (response.data.isSuccess) { + // 获取 miId(资料id) + String miId = ''; + final regData = response.data.data; + if (regData != null) { + miId = regData; + await storage.write('miId', miId); + } else { + // 尝试从本地存储获取 + final stored = storage.read('miId'); + if (stored is String && stored.isNotEmpty) { + miId = stored; + } else { + SmartDialog.showToast('获取资料ID失败,请重试'); + return; + } + } + + // 先调用认证审核保存接口(保存头像,authenticationCode=8) + try { + final payload = { + 'miId': miId, + 'authenticationCode': '8', + 'value': '0', + 'imgUrl': avatarUrl.value.isNotEmpty ? [avatarUrl.value] : ['0'], + }; + + final auditResp = await _userApi.saveCertificationAudit(payload); + if (auditResp.data.isSuccess) { + + } + else{ + + SmartDialog.showToast(auditResp.data.message); + + return; + } + } catch (e) { + print('保存认证审核失败: $e'); + SmartDialog.showToast('提交失败,请重试'); + return; + } + // 更新本地存储的用户信息 final currentUserInfo = storage.read('userInfo') ?? {}; if (currentUserInfo is Map) { diff --git a/lib/network/api_urls.dart b/lib/network/api_urls.dart index ccf0d1b..cffc6de 100644 --- a/lib/network/api_urls.dart +++ b/lib/network/api_urls.dart @@ -11,6 +11,7 @@ class ApiUrls { static const String registerMarriageInformation = 'dating-agency-service/user/register/marriage-information'; static const String getHxUserToken = 'dating-agency-chat-audio/user/get/hx/user/token'; static const String getApplyTempAuth = 'dating-agency-uec/get/apply-temp-auth'; + static const String saveCertificationAudit = 'dating-agency-service/user/save/certification/audit'; // 后续可以在此添加更多API端点 } \ No newline at end of file diff --git a/lib/network/user_api.dart b/lib/network/user_api.dart index 414cf9c..5cd5f5d 100644 --- a/lib/network/user_api.dart +++ b/lib/network/user_api.dart @@ -36,6 +36,11 @@ abstract class UserApi { @Body() Map data, ); + @POST(ApiUrls.saveCertificationAudit) + Future>> saveCertificationAudit( + @Body() Map data, + ); + @GET(ApiUrls.getHxUserToken) Future>> getHxUserToken(); diff --git a/lib/network/user_api.g.dart b/lib/network/user_api.g.dart index 495cef1..18b97e6 100644 --- a/lib/network/user_api.g.dart +++ b/lib/network/user_api.g.dart @@ -186,6 +186,40 @@ class _UserApi implements UserApi { return httpResponse; } + @override + Future>> saveCertificationAudit( + Map data, + ) async { + final _extra = {}; + final queryParameters = {}; + final _headers = {}; + final _data = {}; + _data.addAll(data); + final _options = _setStreamType>>( + Options(method: 'POST', headers: _headers, extra: _extra) + .compose( + _dio.options, + 'dating-agency-service/user/save/certification/audit', + queryParameters: queryParameters, + data: _data, + ) + .copyWith(baseUrl: _combineBaseUrls(_dio.options.baseUrl, baseUrl)), + ); + final _result = await _dio.fetch>(_options); + late BaseResponse _value; + try { + _value = BaseResponse.fromJson( + _result.data!, + (json) => json as dynamic, + ); + } on Object catch (e, s) { + errorLogger?.logError(e, s, _options); + rethrow; + } + final httpResponse = HttpResponse(_value, _result); + return httpResponse; + } + @override Future>> getHxUserToken() async { final _extra = {}; diff --git a/lib/pages/home/home_page.dart b/lib/pages/home/home_page.dart index 271f166..8779c16 100644 --- a/lib/pages/home/home_page.dart +++ b/lib/pages/home/home_page.dart @@ -59,25 +59,21 @@ class _HomePageState extends State with AutomaticKeepAliveClientMixin return AppBar( backgroundColor: Colors.white, elevation: 0, - centerTitle: false, + centerTitle: true, toolbarHeight: 56, - titleSpacing: 16, + titleSpacing: 0, title: Row( + mainAxisAlignment: MainAxisAlignment.center, + mainAxisSize: MainAxisSize.min, children: [ _buildTabButton(title: '推荐', index: 0), - const SizedBox(width: 16), + const SizedBox(width: 28), _buildTabButton(title: '同城', index: 1), - const Spacer(), - Image.asset( - Assets.imagesOnlineIcon, - width: 20, - height: 20, - ), ], ), - bottom: PreferredSize( - preferredSize: const Size.fromHeight(8), - child: const SizedBox(height: 8), + bottom: const PreferredSize( + preferredSize: Size.fromHeight(4), + child: SizedBox(height: 4), ), ); } @@ -93,26 +89,25 @@ class _HomePageState extends State with AutomaticKeepAliveClientMixin } }, child: Column( - crossAxisAlignment: CrossAxisAlignment.start, + mainAxisSize: MainAxisSize.min, + crossAxisAlignment: CrossAxisAlignment.center, children: [ Text( title, style: TextStyle( - fontSize: 22, - fontWeight: FontWeight.w700, - color: selected ? Colors.black : const Color(0xFF999999), - ), - ), - const SizedBox(height: 4), - AnimatedContainer( - duration: const Duration(milliseconds: 200), - height: 4, - width: selected ? 28 : 0, - decoration: BoxDecoration( - color: const Color(0xFF6C63FF), - borderRadius: BorderRadius.circular(2), + fontSize: selected ? 19 : 17, + fontWeight: selected ? FontWeight.w700 : FontWeight.w400, + color: selected ? const Color(0xFF333333) : const Color(0xFF999999), ), ), + const SizedBox(height: 6), + selected + ? Image.asset( + Assets.imagesTabChangeIcon, + width: 32, + height: 8, + ) + : const SizedBox(height: 8), ], ), ); @@ -211,9 +206,9 @@ class _CardHeader extends StatelessWidget { const Text( '林园园', style: TextStyle( - fontSize: 20, - fontWeight: FontWeight.w700, - color: Color(0xFF333333), + fontSize: 15, + fontWeight: FontWeight.w500, + color: Color.fromRGBO(51, 51, 51, 1), ), ), const SizedBox(width: 6), @@ -221,16 +216,16 @@ class _CardHeader extends StatelessWidget { Container( padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 2), decoration: BoxDecoration( - color: const Color(0xFFEFFBF3), + color: Color.fromRGBO(234, 255, 219, 1), borderRadius: BorderRadius.circular(12), ), child: const Text( '在线', - style: TextStyle(fontSize: 12, color: Color(0xFF2ED573)), + style: TextStyle(fontSize: 12, color: Color.fromRGBO(38, 199, 124, 1)), ), ), const SizedBox(width: 6), - // 实名徽标 + // 实名徽, Container( padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 2), decoration: BoxDecoration( @@ -239,11 +234,11 @@ class _CardHeader extends StatelessWidget { ), child: Row( children: [ - Image.asset(Assets.imagesVerifiedIcon, width: 12, height: 12), + Image.asset(Assets.imagesVerifiedIcon, width: 14, height: 12), const SizedBox(width: 4), const Text( '实名', - style: TextStyle(fontSize: 12, color: Color(0xFF6C63FF)), + style: TextStyle(fontSize: 9, color: Color.fromRGBO(160, 92, 255, 1)), ), ], ), @@ -253,13 +248,13 @@ class _CardHeader extends StatelessWidget { const SizedBox(height: 4), const Text( '23岁 · 白云区', - style: TextStyle(fontSize: 16, color: Color(0xFF666666)), + style: TextStyle(fontSize: 12, color: Color.fromRGBO(51, 51, 51, 1)), ), ], ), ), if (showHi) - Image.asset(Assets.imagesHiIcon, width: 64, height: 32), + Image.asset(Assets.imagesHiIcon, width: 40, height: 20), ], ); }