You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
67 lines
1.8 KiB
67 lines
1.8 KiB
import 'package:dating_touchme_app/controller/global.dart';
|
|
import 'package:dating_touchme_app/model/home/user_info_data.dart';
|
|
import 'package:dating_touchme_app/network/user_api.dart';
|
|
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
|
import 'package:get/get.dart';
|
|
|
|
class UserInformationController extends GetxController {
|
|
|
|
final String miId;
|
|
final String userId;
|
|
UserInformationController({required this.miId, required this.userId});
|
|
|
|
final nowSelect = 0.obs;
|
|
|
|
final userData = UserInfoData().obs;
|
|
|
|
List<String> tagList = [
|
|
"北京", "160cm", "想要甜甜的恋爱", "本科", "朋友圈摄影师", "英雄联盟", "流放之路",
|
|
"CF", "DNA", "堡垒之夜", "SCP"
|
|
];
|
|
|
|
late UserApi _userApi;
|
|
|
|
|
|
@override
|
|
void onInit() {
|
|
super.onInit();
|
|
_userApi = Get.find<UserApi>();
|
|
|
|
getUserData();
|
|
}
|
|
|
|
int calculateAge(String birthdayStr) {
|
|
final birthday = DateTime.parse(birthdayStr); // 自动识别 1996-1-20
|
|
final today = DateTime.now();
|
|
|
|
int age = today.year - birthday.year;
|
|
|
|
// 如果今年生日还没过,年龄要减 1
|
|
if (today.month < birthday.month ||
|
|
(today.month == birthday.month && today.day < birthday.day)) {
|
|
age--;
|
|
}
|
|
|
|
return age;
|
|
}
|
|
|
|
final myUserData = GlobalData().userData.obs;
|
|
|
|
getUserData() async {
|
|
try {
|
|
final response = await _userApi.getDongwoMarriageInformationDetail(miId: miId);
|
|
if (response.data.isSuccess && response.data.data != null) {
|
|
userData.value = response.data.data ?? UserInfoData();
|
|
} else {
|
|
|
|
// 响应失败,抛出异常
|
|
throw Exception(response.data.message ?? '获取数据失败');
|
|
}
|
|
} catch(e){
|
|
print('钱包数据获取失败: $e');
|
|
SmartDialog.showToast('钱包数据获取失败');
|
|
rethrow;
|
|
|
|
}
|
|
}
|
|
}
|