|
|
|
@ -1,6 +1,7 @@
|
|
|
|
|
import 'dart:convert'; |
|
|
|
|
|
|
|
|
|
import 'package:dio/dio.dart'; |
|
|
|
|
import 'package:flare_flutter/base/actor_ellipse.dart'; |
|
|
|
|
import 'package:flutter/material.dart'; |
|
|
|
|
import 'package:huixiang/generated/l10n.dart'; |
|
|
|
|
import 'package:huixiang/retrofit/data/base_data.dart'; |
|
|
|
@ -49,8 +50,8 @@ class _MineWalletPage extends State<MineWalletPage> {
|
|
|
|
|
UserInfo.fromJson(jsonDecode(sharedPreferences.getString('user'))); |
|
|
|
|
mBalance = double.tryParse(userInfo.money); |
|
|
|
|
mgreenMoney = double.tryParse(userInfo.greenMoney); |
|
|
|
|
tBalance = double.tryParse(userInfo.balance ?? "0"); |
|
|
|
|
activityMoney = double.tryParse(userInfo.activityMoney); |
|
|
|
|
tBalance = mBalance - (mgreenMoney ?? 0) - (activityMoney ?? 0); |
|
|
|
|
if (mounted) setState(() {}); |
|
|
|
|
String token = sharedPreferences.getString("token"); |
|
|
|
|
apiService = ApiService(Dio(), context: context, token: token); |
|
|
|
@ -67,10 +68,10 @@ class _MineWalletPage extends State<MineWalletPage> {
|
|
|
|
|
await apiService.queryInfo().catchError((onError) {}); |
|
|
|
|
if (baseData != null && baseData.isSuccess) { |
|
|
|
|
userInfo = baseData.data; |
|
|
|
|
mBalance = double.tryParse(userInfo.money); |
|
|
|
|
mgreenMoney = double.tryParse(userInfo.greenMoney); |
|
|
|
|
tBalance = double.tryParse(userInfo.balance ?? "0"); |
|
|
|
|
activityMoney = double.tryParse(userInfo.activityMoney); |
|
|
|
|
mBalance = double.tryParse(userInfo.money); |
|
|
|
|
tBalance = mBalance - (mgreenMoney ?? 0) - (activityMoney ?? 0); |
|
|
|
|
if (mounted) setState(() {}); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
@ -211,19 +212,46 @@ class _MineWalletPage extends State<MineWalletPage> {
|
|
|
|
|
Row( |
|
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween, |
|
|
|
|
children: [ |
|
|
|
|
Text( |
|
|
|
|
userBill.name, |
|
|
|
|
style: TextStyle( |
|
|
|
|
color: Colors.black, |
|
|
|
|
fontSize: 12.sp, |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
Text( |
|
|
|
|
calculateBalance(userBill, 0), |
|
|
|
|
style: TextStyle( |
|
|
|
|
color: Color(0xFF20662A), |
|
|
|
|
fontWeight: FontWeight.bold, |
|
|
|
|
fontSize: 12.sp, |
|
|
|
|
Expanded( |
|
|
|
|
flex: 7, |
|
|
|
|
child: Text( |
|
|
|
|
userBill.name, |
|
|
|
|
style: TextStyle( |
|
|
|
|
color: Colors.black, |
|
|
|
|
fontSize: 12.sp, |
|
|
|
|
), |
|
|
|
|
)), |
|
|
|
|
Expanded( |
|
|
|
|
flex: 4, |
|
|
|
|
child: Row( |
|
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween, |
|
|
|
|
children: calculateBalance(userBill, 0) |
|
|
|
|
.map( |
|
|
|
|
(e) => e == S.of(context).yue |
|
|
|
|
? Container( |
|
|
|
|
width: e == S.of(context).yue |
|
|
|
|
? (12.sp * 4) |
|
|
|
|
: double.infinity, |
|
|
|
|
alignment: Alignment.centerRight, |
|
|
|
|
child: Text( |
|
|
|
|
e, |
|
|
|
|
style: TextStyle( |
|
|
|
|
color: Color(0xFF20662A), |
|
|
|
|
fontWeight: FontWeight.bold, |
|
|
|
|
fontSize: 12.sp, |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
) |
|
|
|
|
: Text( |
|
|
|
|
e, |
|
|
|
|
style: TextStyle( |
|
|
|
|
color: Color(0xFF20662A), |
|
|
|
|
fontWeight: FontWeight.bold, |
|
|
|
|
fontSize: 12.sp, |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
) |
|
|
|
|
.toList(), |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
], |
|
|
|
@ -231,19 +259,48 @@ class _MineWalletPage extends State<MineWalletPage> {
|
|
|
|
|
Row( |
|
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween, |
|
|
|
|
children: [ |
|
|
|
|
Text( |
|
|
|
|
userBill.createTime, |
|
|
|
|
style: TextStyle( |
|
|
|
|
color: Color(0xFF727272), |
|
|
|
|
fontSize: 10.sp, |
|
|
|
|
Expanded( |
|
|
|
|
flex: 7, |
|
|
|
|
child: Text( |
|
|
|
|
userBill.createTime, |
|
|
|
|
style: TextStyle( |
|
|
|
|
color: Color(0xFF727272), |
|
|
|
|
fontSize: 10.sp, |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
Text( |
|
|
|
|
calculateBalance(userBill, 1), |
|
|
|
|
style: TextStyle( |
|
|
|
|
color: Color(0xFF20662A), |
|
|
|
|
fontWeight: FontWeight.bold, |
|
|
|
|
fontSize: 12.sp, |
|
|
|
|
if (calculateBalance(userBill, 1).isNotEmpty) |
|
|
|
|
Expanded( |
|
|
|
|
flex: 4, |
|
|
|
|
child: Row( |
|
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween, |
|
|
|
|
children: calculateBalance(userBill, 1) |
|
|
|
|
.map( |
|
|
|
|
(e) => e == S.of(context).yue |
|
|
|
|
? Container( |
|
|
|
|
width: e == S.of(context).yue |
|
|
|
|
? (12.sp * 4) |
|
|
|
|
: double.infinity, |
|
|
|
|
alignment: Alignment.centerRight, |
|
|
|
|
child: Text( |
|
|
|
|
e, |
|
|
|
|
style: TextStyle( |
|
|
|
|
color: Color(0xFF20662A), |
|
|
|
|
fontWeight: FontWeight.bold, |
|
|
|
|
fontSize: 12.sp, |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
) |
|
|
|
|
: Text( |
|
|
|
|
e, |
|
|
|
|
style: TextStyle( |
|
|
|
|
color: Color(0xFF20662A), |
|
|
|
|
fontWeight: FontWeight.bold, |
|
|
|
|
fontSize: 12.sp, |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
) |
|
|
|
|
.toList(), |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
], |
|
|
|
@ -253,22 +310,53 @@ class _MineWalletPage extends State<MineWalletPage> {
|
|
|
|
|
), |
|
|
|
|
Row( |
|
|
|
|
children: [ |
|
|
|
|
Expanded(flex: 1, child: Text( |
|
|
|
|
S.of(context).pingtaizongyue(userBill.balance, |
|
|
|
|
userBill.surplusActivityMoney, userBill.surplusGreenMoney), |
|
|
|
|
style: TextStyle( |
|
|
|
|
color: Color(0xFF727272), |
|
|
|
|
fontSize: 10.sp, |
|
|
|
|
), |
|
|
|
|
)), |
|
|
|
|
Text( |
|
|
|
|
calculateBalance(userBill, 2), |
|
|
|
|
style: TextStyle( |
|
|
|
|
color: Color(0xFF20662A), |
|
|
|
|
fontWeight: FontWeight.bold, |
|
|
|
|
fontSize: 12.sp, |
|
|
|
|
Expanded( |
|
|
|
|
flex: 7, |
|
|
|
|
child: Text( |
|
|
|
|
S.of(context).pingtaizongyue( |
|
|
|
|
userBill.balance, |
|
|
|
|
userBill.surplusActivityMoney, |
|
|
|
|
userBill.surplusGreenMoney), |
|
|
|
|
style: TextStyle( |
|
|
|
|
color: Color(0xFF727272), |
|
|
|
|
fontSize: 10.sp, |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
if (calculateBalance(userBill, 2).isNotEmpty) |
|
|
|
|
Expanded( |
|
|
|
|
flex: 4, |
|
|
|
|
child: Row( |
|
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween, |
|
|
|
|
children: calculateBalance(userBill, 2) |
|
|
|
|
.map( |
|
|
|
|
(e) => e == S.of(context).yue |
|
|
|
|
? Container( |
|
|
|
|
width: e == S.of(context).yue |
|
|
|
|
? (12.sp * 4) |
|
|
|
|
: double.infinity, |
|
|
|
|
alignment: Alignment.centerRight, |
|
|
|
|
child: Text( |
|
|
|
|
e, |
|
|
|
|
style: TextStyle( |
|
|
|
|
color: Color(0xFF20662A), |
|
|
|
|
fontWeight: FontWeight.bold, |
|
|
|
|
fontSize: 12.sp, |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
) |
|
|
|
|
: Text( |
|
|
|
|
e, |
|
|
|
|
style: TextStyle( |
|
|
|
|
color: Color(0xFF20662A), |
|
|
|
|
fontWeight: FontWeight.bold, |
|
|
|
|
fontSize: 12.sp, |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
) |
|
|
|
|
.toList(), |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
], |
|
|
|
|
), |
|
|
|
|
], |
|
|
|
@ -282,35 +370,57 @@ class _MineWalletPage extends State<MineWalletPage> {
|
|
|
|
|
return zero == 0; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
calculateBalance(UserBill userBill, int index) { |
|
|
|
|
List<String> calculateBalance(UserBill userBill, int index) { |
|
|
|
|
double tbalance = double.tryParse(userBill.number ?? "0"); |
|
|
|
|
|
|
|
|
|
/// 总余额 |
|
|
|
|
String surplusGreenMoney = userBill.surplusGreenMoney; |
|
|
|
|
String surplusActivityMoney = userBill.surplusActivityMoney; |
|
|
|
|
double surplusMoney = double.tryParse(surplusGreenMoney ?? "0"); |
|
|
|
|
double surplusActivity = double.tryParse(surplusActivityMoney ?? "0"); |
|
|
|
|
|
|
|
|
|
double balance = tbalance - (surplusMoney ?? 0) - (surplusActivity ?? 0); |
|
|
|
|
String greenMoney = userBill.greenMoney; |
|
|
|
|
String activityMoney = userBill.activityMoney; |
|
|
|
|
String number = userBill.number; |
|
|
|
|
double balance = double.tryParse(number ?? "0"); |
|
|
|
|
|
|
|
|
|
double money = double.tryParse(greenMoney ?? "0"); |
|
|
|
|
double activity = double.tryParse(activityMoney ?? "0"); |
|
|
|
|
if (index == 0) { |
|
|
|
|
if (money > 0) { |
|
|
|
|
return S.of(context).lvbiyue_("${userBill.pm == 0 ? '-' : '+'}$money"); |
|
|
|
|
return [S.of(context).lvbiyue, "${userBill.pm == 0 ? '-' : '+'}$money"]; |
|
|
|
|
} |
|
|
|
|
if (activity > 0) { |
|
|
|
|
return S.of(context).huodongyue_("${userBill.pm == 0 ? '-' : '+'}$activity"); |
|
|
|
|
return [ |
|
|
|
|
S.of(context).huodongyue, |
|
|
|
|
"${userBill.pm == 0 ? '-' : '+'}$activity" |
|
|
|
|
]; |
|
|
|
|
} |
|
|
|
|
if (balance > 0) { |
|
|
|
|
return [S.of(context).yue, "${userBill.pm == 0 ? '-' : '+'}$balance"]; |
|
|
|
|
} |
|
|
|
|
return S.of(context).yue__("${userBill.pm == 0 ? '-' : '+'}$balance"); |
|
|
|
|
} else if (index == 1) { |
|
|
|
|
if (activity > 0) { |
|
|
|
|
return S.of(context).huodongyue_("${userBill.pm == 0 ? '-' : '+'}$activity"); |
|
|
|
|
return [ |
|
|
|
|
S.of(context).huodongyue, |
|
|
|
|
"${userBill.pm == 0 ? '-' : '+'}$activity" |
|
|
|
|
]; |
|
|
|
|
} |
|
|
|
|
if (money > 0) { |
|
|
|
|
return S.of(context).yue__("${userBill.pm == 0 ? '-' : '+'}${(balance - money)}"); |
|
|
|
|
if (money > 0 && (balance - money) > 0) { |
|
|
|
|
return [ |
|
|
|
|
S.of(context).yue, |
|
|
|
|
"${userBill.pm == 0 ? '-' : '+'}${(balance - money)}" |
|
|
|
|
]; |
|
|
|
|
} else { |
|
|
|
|
return ""; |
|
|
|
|
return []; |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
if (activity > 0 && money > 0) { |
|
|
|
|
return S.of(context).yue__("${userBill.pm == 0 ? '-' : '+'}${(balance - money - activity)}"); |
|
|
|
|
return [ |
|
|
|
|
S.of(context).yue, |
|
|
|
|
"${userBill.pm == 0 ? '-' : '+'}${(balance - money - activity)}" |
|
|
|
|
]; |
|
|
|
|
} else { |
|
|
|
|
return ""; |
|
|
|
|
return []; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|