123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550 |
- import 'package:sport/bean/carousel.dart';
- import 'package:sport/bean/jog/detail.dart';
- import 'package:sport/bean/sport_index.dart' as sport;
- import 'package:sport/bean/user.dart';
- import 'package:sport/services/Converter.dart';
- //import 'package:sport/bean/user.dart';
- import 'game.dart' as game;
- class ExerIndex {
- Today? today;
- Target? target;
- List<Records>? records;
- List<game.GameInfoData>? games;
- List<Achievement>? newAchievements;
- List<NewRank>? newRank;
- int? jogUserCount;
- int? jogLastId;
- Sum? sum;
- JogLast? jogLast;
- bool showGuide = false;
- bool showExerData = false;
- String? fitSlogan;
- String? buyShoesUrl;
- List<Carousel>? carousel;
- List<Records>? recentRecords;
- ExerIndex({this.today, this.target, this.records, this.games, this.newAchievements, this.newRank});
- ExerIndex.fromJson(Map<String, dynamic> json) {
- jogUserCount = json['jog_user_count'];
- jogLastId = json['jog_last_id'];
- today = json['today'] != null ? new Today.fromJson(json['today']) : null;
- sum = json['sum'] != null ? new Sum.fromJson(json['sum']) : null;
- target = json['target'] != null ? new Target.fromJson(json['target']) : null;
- if (json['records'] != null) {
- records = [];
- json['records'].forEach((v) {
- records!.add(new Records.fromJson(v));
- });
- }
- if (json['recent_records'] != null) {
- recentRecords = [];
- json['recent_records'].forEach((v) {
- recentRecords!.add(new Records.fromJson(v));
- });
- }
- if (json['games'] != null) {
- games = [];
- json['games'].forEach((v) {
- games!.add(new game.GameInfoData.fromJson(v));
- });
- // games?.sort((a, b) => (a.h5??0) > 0 ? -1 : 1);
- }
- if (json['new_achievements'] != null) {
- newAchievements = [];
- json['new_achievements'].forEach((v) {
- newAchievements!.add(new Achievement.fromJson(v));
- });
- }
- if (json['new_rank'] != null) {
- newRank = [];
- json['new_rank'].forEach((v) {
- newRank!.add(new NewRank.fromJson(v));
- });
- }
- jogLast = json['jog_last'] != null ? new JogLast.fromJson(json['jog_last']) : null;
- showGuide = json['show_guide'] ?? false;
- showExerData = json['show_exer_data'] ?? false;
- fitSlogan = json['fit_slogan'];
- buyShoesUrl = json['buy_shoes_url'];
- if (json['carousel'] != null) {
- carousel = [];
- json['carousel'].forEach((v) {
- carousel!.add(new Carousel.fromMap(v));
- });
- }
- }
- Map<String, dynamic> toJson() {
- final Map<String, dynamic> data = new Map<String, dynamic>();
- if (this.today != null) {
- data['today'] = this.today!.toJson();
- }
- if (this.sum != null) {
- data['sum'] = this.sum!.toJson();
- }
- if (this.target != null) {
- data['target'] = this.target!.toJson();
- }
- if (this.records != null) {
- data['records'] = this.records!.map((v) => v.toJson()).toList();
- }
- if (this.games != null) {
- data['games'] = this.games!.map((v) => v.toJson()).toList();
- }
- if (this.newAchievements != null) {
- data['new_achievements'] = this.newAchievements!.map((v) => v.toJson()).toList();
- }
- if (this.newRank != null) {
- data['new_rank'] = this.newRank!.map((v) => v.toJson()).toList();
- }
- return data;
- }
- }
- class Today {
- int? id;
- int? userId;
- int? consume;
- int? consumeGame;
- int? consumeJog;
- int? duration;
- int? durationGame;
- int? durationJog;
- int? step;
- int? stepGame;
- int? stepJog;
- int? stepDaily;
- int? distance;
- int? distanceGame;
- int? distanceJog;
- int? distanceDaily;
- int? times;
- int? timesGame;
- int? timesJog;
- int? crouch;
- int? jump;
- String? createdAt;
- int? jumpRate;
- int? crouchRate;
- double? stepRate;
- double? stepRateGame;
- double? stepRateJog;
- int? kmDuration;
- double? met;
- Today(
- {this.id,
- this.userId,
- this.consume,
- this.consumeGame,
- this.consumeJog,
- this.duration,
- this.durationGame,
- this.durationJog,
- this.step,
- this.stepGame,
- this.stepJog,
- this.stepDaily,
- this.distance,
- this.distanceGame,
- this.distanceJog,
- this.distanceDaily,
- this.times,
- this.timesGame,
- this.timesJog,
- this.crouch,
- this.jump,
- this.createdAt,
- this.jumpRate,
- this.crouchRate,
- this.stepRate,
- this.stepRateGame,
- this.stepRateJog,
- this.kmDuration});
- Today.fromJson(Map<String, dynamic> json) {
- id = json['id'];
- userId = json['user_id'];
- consume = json['consume'] ?? 0;
- consumeGame = json['consume_game'];
- consumeJog = json['consume_jog'];
- duration = json['duration'] ?? 0;
- durationGame = json['duration_game'];
- durationJog = json['duration_jog'];
- step = json['step'];
- stepGame = json['step_game'];
- stepJog = json['step_jog'];
- stepDaily = json['step_daily'];
- distance = json['distance'];
- distanceGame = json['distance_game'];
- distanceJog = json['distance_jog'];
- distanceDaily = json['distance_daily'];
- times = json['times'];
- timesGame = json['times_game'];
- timesJog = json['times_jog'];
- crouch = json['crouch'];
- jump = json['jump'];
- createdAt = json['created_at'];
- jumpRate = json['jump_rate'];
- crouchRate = json['crouch_rate'];
- stepRate = Converter.toDouble(json['step_rate']);
- stepRateGame = Converter.toDouble(json['step_rate_game']);
- stepRateJog = Converter.toDouble(json['step_rate_jog']);
- kmDuration = json['km_duration'];
- met = Converter.toDouble(json['met']);
- }
- Map<String, dynamic> toJson() {
- final Map<String, dynamic> data = new Map<String, dynamic>();
- data['id'] = this.id;
- data['user_id'] = this.userId;
- data['consume'] = this.consume;
- data['consume_game'] = this.consumeGame;
- data['consume_jog'] = this.consumeJog;
- data['duration'] = this.duration;
- data['duration_game'] = this.durationGame;
- data['duration_jog'] = this.durationJog;
- data['step'] = this.step;
- data['step_game'] = this.stepGame;
- data['step_jog'] = this.stepJog;
- data['step_daily'] = this.stepDaily;
- data['distance'] = this.distance;
- data['distance_game'] = this.distanceGame;
- data['distance_jog'] = this.distanceJog;
- data['distance_daily'] = this.distanceDaily;
- data['times'] = this.times;
- data['times_game'] = this.timesGame;
- data['times_jog'] = this.timesJog;
- data['crouch'] = this.crouch;
- data['jump'] = this.jump;
- data['created_at'] = this.createdAt;
- data['jump_rate'] = this.jumpRate;
- data['crouch_rate'] = this.crouchRate;
- data['step_rate'] = this.stepRate;
- data['step_rate_game'] = this.stepRateGame;
- data['step_rate_jog'] = this.stepRateJog;
- data['km_duration'] = this.kmDuration;
- return data;
- }
- double? get strength => sport.strengthToValue((consumeGame ?? 0) + (consumeJog ?? 0), duration);
- double? get metValue => met;
- String? strengthLabel() {
- return sport.strengthMetToLabel(met ?? 0);
- }
- int? value(String? type) => type == "consume" ? consume : ((duration ?? 0) / 60).round();
- int? get minute => (duration ?? 0) ~/ 60;
- String stepToStr() {
- int num = this.step ?? 0;
- return (num > 100000) ? "${(num / 10000.0).toStringAsFixed(1)}万" : "$num";
- }
- }
- class Target {
- int? id;
- int? userId;
- int? consume;
- int? duration;
- String? type;
- int? durationMinute;
- int? monthFinish;
- int? get valueTarget => type == "duration" ? (duration ?? 0) ~/ 60 : consume;
- String? get label => type == "duration" ? "分钟" : "大卡";
- double? progress(Today? today) {
- if (today == null) return 0;
- if (type == "consume") {
- return today.consume! / this.consume!;
- } else {
- return (today.duration ?? 0) / this.duration!;
- }
- }
- Target({this.id, this.userId, this.consume, this.duration, this.type, this.durationMinute, this.monthFinish});
- Target.fromJson(Map<String, dynamic> json) {
- id = json['id'];
- userId = json['user_id'];
- consume = json['consume'];
- duration = json['duration'];
- type = json['type'];
- durationMinute = json['duration_minute'];
- monthFinish = json['month_finish'];
- }
- Map<String, dynamic> toJson() {
- final Map<String, dynamic> data = new Map<String, dynamic>();
- data['id'] = this.id;
- data['user_id'] = this.userId;
- data['consume'] = this.consume;
- data['duration'] = this.duration;
- data['type'] = this.type;
- data['duration_minute'] = this.durationMinute;
- data['month_finish'] = this.monthFinish;
- return data;
- }
- }
- class Records {
- int? gameId;
- String? name;
- String? cover;
- int userCount = 0;
- int times = 0;
- int duration = 0;
- int? consume;
- Records({this.gameId, this.name, this.cover, this.userCount = 0, this.times = 0, this.duration = 0, this.consume});
- Records.fromJson(Map<String, dynamic> json) {
- gameId = json['game_id'];
- name = json['name'];
- cover = json['cover'];
- userCount = json['user_count'];
- times = json['times'];
- duration = json['duration'];
- consume = Converter.toInt(json['consume']);
- }
- Map<String, dynamic> toJson() {
- final Map<String, dynamic> data = new Map<String, dynamic>();
- data['game_id'] = this.gameId;
- data['name'] = this.name;
- data['cover'] = this.cover;
- data['user_count'] = this.userCount;
- data['times'] = this.times;
- data['duration'] = this.duration;
- data['consume'] = this.consume;
- return data;
- }
- }
- class NewRank {
- int? id;
- String? name;
- int? position;
- String? createdAt;
- NewRank({this.id, this.name, this.position, this.createdAt});
- NewRank.fromJson(Map<String, dynamic> json) {
- id = json['id'];
- name = json['name'];
- position = json['position'];
- createdAt = json['created_at'];
- }
- Map<String, dynamic> toJson() {
- final Map<String, dynamic> data = new Map<String, dynamic>();
- data['id'] = this.id;
- data['name'] = this.name;
- data['position'] = this.position;
- data['created_at'] = this.createdAt;
- return data;
- }
- }
- class Sum {
- int? id;
- int? userId;
- int? consume;
- int? consumeGame;
- int? consumeJog;
- int? consumeDaily;
- int? duration;
- int? durationGame;
- int? durationJog;
- int? step;
- int? stepGame;
- int? stepJog;
- int? stepDaily;
- int? distance;
- int? distanceGame;
- int? distanceJog;
- int? distanceDaily;
- int? times;
- int? timesGame;
- int? timesJog;
- int? crouch;
- int? jump;
- int? durationGameStep;
- int? durationJump;
- int? durationCrouch;
- int? durationStep;
- int? jumpRate;
- int? crouchRate;
- double? stepRate;
- double? stepRateGame;
- double? stepRateJog;
- Sum(
- {this.id,
- this.userId,
- this.consume,
- this.consumeGame,
- this.consumeJog,
- this.consumeDaily,
- this.duration,
- this.durationGame,
- this.durationJog,
- this.step,
- this.stepGame,
- this.stepJog,
- this.stepDaily,
- this.distance,
- this.distanceGame,
- this.distanceJog,
- this.distanceDaily,
- this.times,
- this.timesGame,
- this.timesJog,
- this.crouch,
- this.jump,
- this.durationGameStep,
- this.durationJump,
- this.durationCrouch,
- this.durationStep,
- this.jumpRate,
- this.crouchRate,
- this.stepRate,
- this.stepRateGame,
- this.stepRateJog});
- Sum.fromJson(Map<String, dynamic> json) {
- id = json['id'];
- userId = json['user_id'];
- consume = json['consume'];
- consumeGame = json['consume_game'];
- consumeJog = json['consume_jog'];
- consumeDaily = json['consume_daily'];
- duration = json['duration'];
- durationGame = json['duration_game'];
- durationJog = json['duration_jog'];
- step = json['step'];
- stepGame = json['step_game'];
- stepJog = json['step_jog'];
- stepDaily = json['step_daily'];
- distance = json['distance'];
- distanceGame = json['distance_game'];
- distanceJog = json['distance_jog'];
- distanceDaily = json['distance_daily'];
- times = json['times'];
- timesGame = json['times_game'];
- timesJog = json['times_jog'];
- crouch = json['crouch'];
- jump = json['jump'];
- durationGameStep = json['duration_game_step'];
- durationJump = json['duration_jump'];
- durationCrouch = json['duration_crouch'];
- durationStep = json['duration_step'];
- jumpRate = json['jump_rate'];
- crouchRate = json['crouch_rate'];
- stepRate = Converter.toDouble(json['step_rate']);
- stepRateGame = Converter.toDouble(json['step_rate_game']);
- stepRateJog = Converter.toDouble(json['step_rate_jog']);
- }
- Map<String, dynamic> toJson() {
- final Map<String, dynamic> data = new Map<String, dynamic>();
- data['id'] = this.id;
- data['user_id'] = this.userId;
- data['consume'] = this.consume;
- data['consume_game'] = this.consumeGame;
- data['consume_jog'] = this.consumeJog;
- data['consume_daily'] = this.consumeDaily;
- data['duration'] = this.duration;
- data['duration_game'] = this.durationGame;
- data['duration_jog'] = this.durationJog;
- data['step'] = this.step;
- data['step_game'] = this.stepGame;
- data['step_jog'] = this.stepJog;
- data['step_daily'] = this.stepDaily;
- data['distance'] = this.distance;
- data['distance_game'] = this.distanceGame;
- data['distance_jog'] = this.distanceJog;
- data['distance_daily'] = this.distanceDaily;
- data['times'] = this.times;
- data['times_game'] = this.timesGame;
- data['times_jog'] = this.timesJog;
- data['crouch'] = this.crouch;
- data['jump'] = this.jump;
- data['duration_game_step'] = this.durationGameStep;
- data['duration_jump'] = this.durationJump;
- data['duration_crouch'] = this.durationCrouch;
- data['duration_step'] = this.durationStep;
- data['jump_rate'] = this.jumpRate;
- data['crouch_rate'] = this.crouchRate;
- data['step_rate'] = this.stepRate;
- data['step_rate_game'] = this.stepRateGame;
- data['step_rate_jog'] = this.stepRateJog;
- return data;
- }
- }
- class JogLast {
- int? userId;
- String? type;
- int? recordId;
- String? createdAt;
- int? duration;
- double? distance;
- int? step;
- int? consume;
- double? stepRate;
- int? id;
- double? jumpRate;
- double? crouchRate;
- JogDetail? jogRecord;
- JogLast({this.userId, this.type, this.recordId, this.createdAt, this.duration, this.distance, this.step, this.consume, this.stepRate, this.id, this.jumpRate, this.crouchRate, this.jogRecord});
- JogLast.fromJson(Map<String, dynamic> json) {
- userId = json['user_id'];
- type = json['type'];
- recordId = json['record_id'];
- createdAt = json['created_at'];
- duration = json['duration'];
- distance = Converter.toDouble(json['distance']);
- step = Converter.toInt(json['step']);
- consume = Converter.toInt(json['consume']);
- stepRate = Converter.toDouble(json['step_rate']);
- id = json['id'];
- jumpRate = Converter.toDouble(json['jump_rate']);
- crouchRate = Converter.toDouble(json['crouch_rate']);
- jogRecord = json['jog_record'] != null ? new JogDetail.fromJson(json['jog_record']) : null;
- }
- Map<String, dynamic> toJson() {
- final Map<String, dynamic> data = new Map<String, dynamic>();
- data['user_id'] = this.userId;
- data['type'] = this.type;
- data['record_id'] = this.recordId;
- data['created_at'] = this.createdAt;
- data['duration'] = this.duration;
- data['distance'] = this.distance;
- data['step'] = this.step;
- data['consume'] = this.consume;
- data['step_rate'] = this.stepRate;
- data['id'] = this.id;
- data['jump_rate'] = this.jumpRate;
- data['crouch_rate'] = this.crouchRate;
- if (this.jogRecord != null) {
- data['jog_record'] = this.jogRecord!.toJson();
- }
- return data;
- }
- }
|