From dedd7b32433a9a6ab84be016f439f3a85eec55ce Mon Sep 17 00:00:00 2001 From: zhangmeng <494089941@qq.com> Date: Mon, 5 Jul 2021 19:42:47 +0800 Subject: [PATCH] no message --- .../user/functions/user_benefit_func.dart | 13 ++-- lib/pages/user/model/user_income_model1.dart | 59 ++++++++----------- lib/pages/user/user_benefit_currency_pag.dart | 8 +-- 3 files changed, 32 insertions(+), 48 deletions(-) diff --git a/lib/pages/user/functions/user_benefit_func.dart b/lib/pages/user/functions/user_benefit_func.dart index 51ab518..69d0e4d 100644 --- a/lib/pages/user/functions/user_benefit_func.dart +++ b/lib/pages/user/functions/user_benefit_func.dart @@ -23,25 +23,22 @@ enum BenefitDateType { class UserBenefitFunc { //已到账收益 static Future receicedIncome( - String date_str, int type) async { + String dateStr, int type) async { ResultData result = await HttpManager.post( - APIV2.userAPI.rceivedDetail, {'date_str': date_str, 'type': type}); - if (result.data != null) { + APIV2.userAPI.rceivedDetail, {'date_str': dateStr, 'type': type}); if (result.data['data'] != null) { return UserIncomeModel1.fromJson(result.data['data']); } - } } //未到账收益 static Future notReceicedIncome( - String date_str, int type) async { + String dateStr, int type) async { ResultData result = await HttpManager.post( - APIV2.userAPI.rceivedDetail, {'date_str': date_str, 'type': type}); - if (result.data != null) { + APIV2.userAPI.rceivedDetail, {'date_str': dateStr, 'type': type}); if (result.data['data'] != null) { return UserIncomeModel1.fromJson(result.data['data']); - } + } } diff --git a/lib/pages/user/model/user_income_model1.dart b/lib/pages/user/model/user_income_model1.dart index 676b6a3..da138f4 100644 --- a/lib/pages/user/model/user_income_model1.dart +++ b/lib/pages/user/model/user_income_model1.dart @@ -1,63 +1,52 @@ class UserIncomeModel1 { - Data data; + num amount; + num all; + List detial; - UserIncomeModel1({this.data}); + UserIncomeModel1({this.amount, this.all, this.detial}); UserIncomeModel1.fromJson(Map json) { - data = json['data'] != null ? new Data.fromJson(json['data']) : null; - } - - Map toJson() { - final Map data = new Map(); - if (this.data != null) { - data['data'] = this.data.toJson(); - } - return data; - } -} - -class Data { - double amount; - double all; - Detail detail; - - Data({this.amount, this.all, this.detail}); - - Data.fromJson(Map json) { amount = json['amount']; all = json['all']; - detail = - json['detail'] != null ? new Detail.fromJson(json['detail']) : null; + if (json['detial'] != null) { + detial = new List(); + json['detial'].forEach((v) { + detial.add(new Detial.fromJson(v)); + }); + } } Map toJson() { final Map data = new Map(); data['amount'] = this.amount; data['all'] = this.all; - if (this.detail != null) { - data['detail'] = this.detail.toJson(); + if (this.detial != null) { + data['detial'] = this.detial.map((v) => v.toJson()).toList(); } return data; } } -class Detail1 { +class Detial { int date; num sale; int count; num coin; - Detail1 detail; + List detail; - Detail1({this.date, this.sale, this.count, this.coin, this.detail}); + Detial({this.date, this.sale, this.count, this.coin, this.detail}); - Detail1.fromJson(Map json) { + Detial.fromJson(Map json) { date = json['date']; sale = json['sale']; count = json['count']; coin = json['coin']; - detail = json['detail'] != null - ? new Detail1.fromJson(json['detail']) - : Detail.init(); + if (json['detail'] != null) { + detail = new List(); + json['detail'].forEach((v) { + detail.add(new Detail.fromJson(v)); + }); + } } Map toJson() { @@ -67,7 +56,7 @@ class Detail1 { data['count'] = this.count; data['coin'] = this.coin; if (this.detail != null) { - data['detail'] = this.detail.toJson(); + data['detail'] = this.detail.map((v) => v.toJson()).toList(); } return data; } @@ -96,6 +85,4 @@ class Detail { data['coin'] = this.coin; return data; } - - factory Detail.init() => Detail(date: 0, sale: 0, count: 0, coin: 0); } diff --git a/lib/pages/user/user_benefit_currency_pag.dart b/lib/pages/user/user_benefit_currency_pag.dart index 0219bc9..bd1beba 100644 --- a/lib/pages/user/user_benefit_currency_pag.dart +++ b/lib/pages/user/user_benefit_currency_pag.dart @@ -464,10 +464,10 @@ class _UserBenefitCurrencyPageState extends State { } else { //团队补贴 } - _amount = _models.data?.amount?.toStringAsFixed(2); - _all = _models.data?.all?.toStringAsFixed(2); - print(_models?.data?.amount?.toStringAsFixed(2)); - print(_models?.data?.all?.toStringAsFixed(2)); + _amount = _models?.amount?.toStringAsFixed(2); + _all = _models?.all?.toStringAsFixed(2); + print(_models?.amount?.toStringAsFixed(2)); + print(_models?.all?.toStringAsFixed(2)); setState(() {}); _refreshController.refreshCompleted(); },