|
|
|
@ -6,7 +6,8 @@ import '../global.dart'; |
|
|
|
|
|
|
|
class AuthController extends GetxController { |
|
|
|
final isLoading = false.obs; |
|
|
|
final List<AuthCard> dataList = []; |
|
|
|
// var List<AuthCard> dataList = []; |
|
|
|
var dataList = <AuthCard>[].obs; |
|
|
|
// 是否正在登录中 |
|
|
|
final isLoggingIn = false.obs; |
|
|
|
final name = ''.obs; |
|
|
|
@ -19,31 +20,28 @@ class AuthController extends GetxController { |
|
|
|
super.onInit(); |
|
|
|
// 从全局依赖中获取UserApi |
|
|
|
_userApi = Get.find<UserApi>(); |
|
|
|
_loadInitialData(); |
|
|
|
loadInitialData(); |
|
|
|
} |
|
|
|
|
|
|
|
// 登录方法 |
|
|
|
Future<void> _loadInitialData() async { |
|
|
|
Future<void> loadInitialData() async { |
|
|
|
try { |
|
|
|
isLoading.value = true; |
|
|
|
late bool realAuth = false; |
|
|
|
late bool realAuth = false, checkPhoto = false; |
|
|
|
if (GlobalData().userData != null) { |
|
|
|
final information = GlobalData().userData!; |
|
|
|
if(information.identityCard != null){ |
|
|
|
realAuth = true; |
|
|
|
} |
|
|
|
if(information.profilePhoto != null){ |
|
|
|
checkPhoto = true; |
|
|
|
} |
|
|
|
} |
|
|
|
dataList.assignAll([ |
|
|
|
AuthCard( title: '手机绑定', desc: '防止账号丢失', index: 1, authed: true), |
|
|
|
AuthCard( title: '真实头像', desc: '提高交友成功率', index: 2, authed: false), |
|
|
|
AuthCard( title: '真实头像', desc: '提高交友成功率', index: 2, authed: checkPhoto), |
|
|
|
AuthCard( title: '实名认证', desc: '提高交友成功率', index: 3, authed: realAuth), |
|
|
|
]); |
|
|
|
// 调用登录接口 |
|
|
|
// final response = await _userApi.login({}); |
|
|
|
// 处理响应 |
|
|
|
// if (response.data.isSuccess) { |
|
|
|
// |
|
|
|
// } |
|
|
|
} catch (e) { |
|
|
|
SmartDialog.showToast('网络请求失败,请检查网络连接'); |
|
|
|
} finally { |
|
|
|
@ -78,8 +76,9 @@ class AuthController extends GetxController { |
|
|
|
} |
|
|
|
|
|
|
|
void changeAuth(int index){ |
|
|
|
AuthCard card = dataList.firstWhere((item) => item.index == index); |
|
|
|
card.authed = true; |
|
|
|
final updatedMessages = List<AuthCard>.from(dataList); |
|
|
|
updatedMessages[index].authed = true; |
|
|
|
dataList.assignAll(updatedMessages); |
|
|
|
} |
|
|
|
|
|
|
|
Future<void> startAuthing() async { |
|
|
|
|