Browse Source

提交头像审核

ios
Jolie 4 months ago
parent
commit
ff8431c70a
5 changed files with 126 additions and 52 deletions
  1. 71
      lib/controller/mine/user_info_controller.dart
  2. 1
      lib/network/api_urls.dart
  3. 5
      lib/network/user_api.dart
  4. 34
      lib/network/user_api.g.dart
  5. 67
      lib/pages/home/home_page.dart

71
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<void> handleGallerySelection() async {
try {
// /
// final ok = await _ensurePermission(
// Permission.photos,
// // Android photos storage/mediaLibrarypermission_handler
// denyToast: '相册权限被拒绝,请在设置中允许访问相册',
final ok = await _ensurePermission(
Permission.photos,
// Android photos storage/mediaLibrarypermission_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<void> 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) {
// miIdid
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<String, dynamic>) {

1
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端点
}

5
lib/network/user_api.dart

@ -36,6 +36,11 @@ abstract class UserApi {
@Body() Map<String, dynamic> data,
);
@POST(ApiUrls.saveCertificationAudit)
Future<HttpResponse<BaseResponse<dynamic>>> saveCertificationAudit(
@Body() Map<String, dynamic> data,
);
@GET(ApiUrls.getHxUserToken)
Future<HttpResponse<BaseResponse<String>>> getHxUserToken();

34
lib/network/user_api.g.dart

@ -186,6 +186,40 @@ class _UserApi implements UserApi {
return httpResponse;
}
@override
Future<HttpResponse<BaseResponse<dynamic>>> saveCertificationAudit(
Map<String, dynamic> data,
) async {
final _extra = <String, dynamic>{};
final queryParameters = <String, dynamic>{};
final _headers = <String, dynamic>{};
final _data = <String, dynamic>{};
_data.addAll(data);
final _options = _setStreamType<HttpResponse<BaseResponse<dynamic>>>(
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<Map<String, dynamic>>(_options);
late BaseResponse<dynamic> _value;
try {
_value = BaseResponse<dynamic>.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<HttpResponse<BaseResponse<String>>> getHxUserToken() async {
final _extra = <String, dynamic>{};

67
lib/pages/home/home_page.dart

@ -59,25 +59,21 @@ class _HomePageState extends State<HomePage> 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<HomePage> 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),
],
);
}

Loading…
Cancel
Save