account_auth.dart 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. /// 认证信息 - POST uc/approve/security/setting
  2. class AccountAuth {
  3. final String id;
  4. final String username;
  5. final String mobilePhone;
  6. final String email;
  7. final String realVerified;
  8. final String emailVerified;
  9. final String loginVerified;
  10. final String fundsVerified;
  11. final String googleStatus;
  12. const AccountAuth({
  13. this.id = '',
  14. this.username = '',
  15. this.mobilePhone = '',
  16. this.email = '',
  17. this.realVerified = '0',
  18. this.emailVerified = '0',
  19. this.loginVerified = '0',
  20. this.fundsVerified = '0',
  21. this.googleStatus = '0',
  22. });
  23. bool get isGoogleVerified => googleStatus == '1';
  24. bool get isFundsVerified => fundsVerified == '1';
  25. bool get isEmailVerified => emailVerified == '1';
  26. bool get isLoginVerified => loginVerified == '1';
  27. /// 邮箱脱敏:user@gmail.com → u**@gmail.com
  28. String get maskedEmail {
  29. if (email.isEmpty) return '';
  30. final parts = email.split('@');
  31. if (parts.length != 2) return email;
  32. final name = parts[0];
  33. if (name.length <= 1) return '$name**@${parts[1]}';
  34. return '${name[0]}**@${parts[1]}';
  35. }
  36. factory AccountAuth.fromJson(Map<String, dynamic> json) {
  37. return AccountAuth(
  38. id: json['id']?.toString() ?? '',
  39. username: json['username']?.toString() ?? '',
  40. mobilePhone: json['mobilePhone']?.toString() ?? '',
  41. email: json['email']?.toString() ?? '',
  42. realVerified: json['realVerified']?.toString() ?? '0',
  43. emailVerified: json['emailVerified']?.toString() ?? '0',
  44. loginVerified: json['loginVerified']?.toString() ?? '0',
  45. fundsVerified: json['fundsVerified']?.toString() ?? '0',
  46. googleStatus: json['googleStatus']?.toString() ?? '0',
  47. );
  48. }
  49. }