import 'package:zhiying_base_widget/widgets/team/fans_list/model/team_fans_list_model.dart';
import 'package:meta/meta.dart';

@immutable
class TeamDetailsDataModel {
  List<TeamDetailsDataModelDashBoard> dash_board;
  TeamFansListItemModel info;
  TeamFansListItemModel referrer;

  TeamDetailsDataModel({this.dash_board, this.info, this.referrer});

  factory TeamDetailsDataModel.fromJson(Map<String, dynamic> json) {
    return TeamDetailsDataModel(
      dash_board: json['dash_board'] != null ? (json['dash_board'] as List).map((i) => TeamDetailsDataModelDashBoard.fromJson(i)).toList() : null,
      info: json['info'] != null ? TeamFansListItemModel.fromJson(json['info']) : null,
      referrer: json['referrer'] != null ? TeamFansListItemModel.fromJson(json['referrer']) : null,
    );
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = new Map<String, dynamic>();
    if (this.dash_board != null) {
      data['dash_board'] = this.dash_board.map((v) => v.toJson()).toList();
    }
    if (this.info != null) {
      data['info'] = this.info.toJson();
    }
    if (this.referrer != null) {
      data['referrer'] = this.referrer.toJson();
    }
    return data;
  }
}

// class TeamDetailsDataModelReferrer {
//   String referrer_avatar;
//   String referrer_invite_code;
//   String referrer_phone;
//   String referrer_username;
//   String referrer_wechat;
//   String uid;
//
//   TeamDetailsDataModelReferrer({this.referrer_avatar, this.referrer_invite_code, this.referrer_phone, this.referrer_username, this.referrer_wechat, this.uid});
//
//   // 获取模糊手机号码
//   get blurMobile => !EmptyUtil.isEmpty(referrer_phone)
//       ? referrer_phone.length == 11 ? '${referrer_phone.substring(0, 3)}****${referrer_phone.substring(7, referrer_phone.length)}' : referrer_phone
//       : referrer_phone;
//
//   // 获取模糊昵称
//   get blurUserName =>
//       !EmptyUtil.isEmpty(referrer_username) ? referrer_username.length > 6 ? '${referrer_username.substring(0, 3)}****${referrer_username.substring(referrer_username.length - 3, referrer_username.length)}' : referrer_username : referrer_username;
//
//   // 获取模糊微信
//   get blurWeChat => !EmptyUtil.isEmpty(referrer_wechat) ? referrer_wechat.length > 6 ? '${referrer_wechat.substring(0, 3)}****${referrer_wechat.substring(referrer_wechat.length - 3, referrer_wechat.length)}' : referrer_wechat : referrer_wechat;
//
//   factory TeamDetailsDataModelReferrer.fromJson(Map<String, dynamic> json) {
//     return TeamDetailsDataModelReferrer(
//       referrer_avatar: json['referrer_avatar'],
//       referrer_invite_code: json['referrer_invite_code'],
//       referrer_phone: json['referrer_phone'],
//       referrer_username: json['referrer_username'],
//       referrer_wechat: json['referrer_wechat'],
//       uid: json['uid'],
//     );
//   }
//
//   Map<String, dynamic> toJson() {
//     final Map<String, dynamic> data = new Map<String, dynamic>();
//     data['referrer_avatar'] = this.referrer_avatar;
//     data['referrer_invite_code'] = this.referrer_invite_code;
//     data['referrer_phone'] = this.referrer_phone;
//     data['referrer_username'] = this.referrer_username;
//     data['referrer_wechat'] = this.referrer_wechat;
//     data['uid'] = this.uid;
//     return data;
//   }
// }

class TeamDetailsDataModelDashBoard {
  List<TeamDetailsDashBoardItem> list;
  String type;

  TeamDetailsDataModelDashBoard({this.list, this.type});

  factory TeamDetailsDataModelDashBoard.fromJson(Map<String, dynamic> json) {
    return TeamDetailsDataModelDashBoard(
      list: json['list'] != null ? (json['list'] as List).map((i) => TeamDetailsDashBoardItem.fromJson(i)).toList() : null,
      type: json['type'],
    );
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = new Map<String, dynamic>();
    data['type'] = this.type;
    if (this.list != null) {
      data['list'] = this.list.map((v) => v.toJson()).toList();
    }
    return data;
  }
}

class TeamDetailsDashBoardItem {
  List<String> data_list;
  String type;

  TeamDetailsDashBoardItem({this.data_list, this.type});

  factory TeamDetailsDashBoardItem.fromJson(Map<String, dynamic> json) {
    return TeamDetailsDashBoardItem(
      data_list: json['data_list'] != null ? new List<String>.from(json['data_list']) : null,
      type: json['type'],
    );
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = new Map<String, dynamic>();
    data['type'] = this.type;
    if (this.data_list != null) {
      data['data_list'] = this.data_list;
    }
    return data;
  }
}