基础库
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.

user_info_model.dart 1.5 KiB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. import 'package:zhiying_comm/util/empty_util.dart';
  2. ///
  3. /// 用户信息类
  4. ///
  5. class UserInfoModel {
  6. String token;
  7. String mobile;
  8. String userId;
  9. String username;
  10. List<String> perms;
  11. String registerInviteCodeEnable;
  12. bool isTBAuth; // 是否淘宝授权
  13. // 获取模糊手机号码
  14. get blurMobile => !EmptyUtil.isEmpty(mobile) ? mobile.length == 11 ? '${mobile.substring(0, 3)}****${mobile.substring(7, mobile.length)}' : mobile : mobile;
  15. UserInfoModel({this.token, this.userId, this.username, this.perms, this.registerInviteCodeEnable, this.isTBAuth = false});
  16. UserInfoModel.fromJson(Map<String, dynamic> json) {
  17. token = json['token'];
  18. userId = json['user_id'];
  19. username = json['username'];
  20. mobile = json['mobile'];
  21. perms = json['perms']?.cast<String>();
  22. registerInviteCodeEnable = json['register_invite_code_enable'];
  23. isTBAuth = json['isTBAuth'] ?? false;
  24. }
  25. Map<String, dynamic> toJson() {
  26. final Map<String, dynamic> data = new Map<String, dynamic>();
  27. data['token'] = this.token;
  28. data['user_id'] = this.userId;
  29. data['username'] = this.username;
  30. data['perms'] = this.perms;
  31. data['mobile'] = this.mobile;
  32. data['register_invite_code_enable'] = this.registerInviteCodeEnable;
  33. data['isTBAuth'] = this.isTBAuth;
  34. return data;
  35. }
  36. @override
  37. String toString() {
  38. return 'LoginUser{token: $token, userId: $userId, username: $username, perms: $perms, registerInviteCodeEnable: $registerInviteCodeEnable}';
  39. }
  40. }