15 changed files with 772 additions and 296 deletions
Unified View
Diff Options
-
4lib/controller/mine/edit_info_controller.dart
-
108lib/controller/mine/my_wallet_controller.dart
-
13lib/controller/mine/rose_history_controller.dart
-
13lib/controller/mine/withdraw_history_controller.dart
-
6lib/model/mine/user_data.dart
-
40lib/model/mine/wallet_account_data.dart
-
72lib/model/mine/wallet_account_record_data.dart
-
4lib/network/api_urls.dart
-
31lib/network/user_api.dart
-
83lib/network/user_api.g.dart
-
5lib/pages/mine/edit_info_page.dart
-
586lib/pages/mine/my_wallet_page.dart
-
35lib/pages/mine/rose_history_page.dart
-
63lib/pages/mine/withdraw_history_page.dart
-
5lib/pages/mine/withdraw_page.dart
@ -0,0 +1,108 @@ |
|||||
|
import 'package:dating_touchme_app/model/mine/wallet_account_data.dart'; |
||||
|
import 'package:dating_touchme_app/network/user_api.dart'; |
||||
|
import 'package:easy_refresh/easy_refresh.dart'; |
||||
|
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart'; |
||||
|
import 'package:get/get.dart'; |
||||
|
|
||||
|
import '../../model/mine/wallet_account_record_data.dart'; |
||||
|
|
||||
|
class MyWalletController extends GetxController { |
||||
|
|
||||
|
final timeActive = 1.obs; |
||||
|
|
||||
|
final walletData = WalletAccountData().obs; |
||||
|
|
||||
|
final walletHistoryList = <Records>[].obs; |
||||
|
|
||||
|
final page = 1.obs; |
||||
|
|
||||
|
final size = 10.obs; |
||||
|
|
||||
|
late UserApi _userApi; |
||||
|
|
||||
|
late final EasyRefreshController listRefreshController; |
||||
|
|
||||
|
@override |
||||
|
void onInit() { |
||||
|
super.onInit(); |
||||
|
_userApi = Get.find<UserApi>(); |
||||
|
|
||||
|
listRefreshController = EasyRefreshController( |
||||
|
controlFinishRefresh: true, |
||||
|
controlFinishLoad: true, |
||||
|
); |
||||
|
getWalletData(); |
||||
|
getHistoryList(); |
||||
|
print(formatStartTimestamp(DateTime.now().millisecondsSinceEpoch - 86400000 * 30)); |
||||
|
print(formatStartTimestamp(DateTime.now().millisecondsSinceEpoch - 86400000 * 90)); |
||||
|
print(formatStartTimestamp(DateTime.now().millisecondsSinceEpoch - 86400000 * 180)); |
||||
|
} |
||||
|
|
||||
|
String formatStartTimestamp(int ms) { |
||||
|
final dt = DateTime.fromMillisecondsSinceEpoch(ms); |
||||
|
String two(int n) => n.toString().padLeft(2, '0'); |
||||
|
|
||||
|
return "${dt.year}-${two(dt.month)}-${two(dt.day)} " |
||||
|
"00:00:00"; |
||||
|
} |
||||
|
|
||||
|
String formatEndTimestamp(int ms) { |
||||
|
final dt = DateTime.fromMillisecondsSinceEpoch(ms); |
||||
|
String two(int n) => n.toString().padLeft(2, '0'); |
||||
|
|
||||
|
return "${dt.year}-${two(dt.month)}-${two(dt.day)} " |
||||
|
"23:59:59"; |
||||
|
} |
||||
|
|
||||
|
|
||||
|
getWalletData() async { |
||||
|
try { |
||||
|
final response = await _userApi.getWalletAccount({}); |
||||
|
if (response.data.isSuccess && response.data.data != null) { |
||||
|
walletData.value = response.data.data ?? WalletAccountData(); |
||||
|
} else { |
||||
|
|
||||
|
// 响应失败,抛出异常 |
||||
|
throw Exception(response.data.message ?? '获取数据失败'); |
||||
|
} |
||||
|
} catch(e){ |
||||
|
print('钱包数据获取失败: $e'); |
||||
|
SmartDialog.showToast('钱包数据获取失败'); |
||||
|
rethrow; |
||||
|
|
||||
|
} |
||||
|
} |
||||
|
|
||||
|
getHistoryList() async { |
||||
|
try { |
||||
|
final response = await _userApi.getWalletAccountRecord( |
||||
|
pageNum: page.value, |
||||
|
pageSize: size.value, |
||||
|
recordTimeFrom: timeActive.value == 1 ? |
||||
|
formatStartTimestamp(DateTime.now().millisecondsSinceEpoch - 86400000 * 30) : |
||||
|
timeActive.value == 2 ? formatStartTimestamp(DateTime.now().millisecondsSinceEpoch - 86400000 * 90) : |
||||
|
timeActive.value == 3 ? formatStartTimestamp(DateTime.now().millisecondsSinceEpoch - 86400000 * 180) : |
||||
|
"", |
||||
|
recordTimeTo: formatEndTimestamp(DateTime.now().millisecondsSinceEpoch), |
||||
|
); |
||||
|
if (response.data.isSuccess && response.data.data != null) { |
||||
|
walletHistoryList.addAll(response.data.data?.records ?? []); |
||||
|
if((response.data.data?.records?.length ?? 0) == size.value){ |
||||
|
|
||||
|
listRefreshController.finishLoad(IndicatorResult.success); |
||||
|
} else { |
||||
|
listRefreshController.finishLoad(IndicatorResult.noMore); |
||||
|
} |
||||
|
} else { |
||||
|
|
||||
|
// 响应失败,抛出异常 |
||||
|
throw Exception(response.data.message ?? '获取数据失败'); |
||||
|
} |
||||
|
} catch(e){ |
||||
|
print('钱包流水获取失败: $e'); |
||||
|
SmartDialog.showToast('钱包流水获取失败'); |
||||
|
rethrow; |
||||
|
|
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,40 @@ |
|||||
|
class WalletAccountData { |
||||
|
String? id; |
||||
|
num? totalBalance; |
||||
|
num? availableBalance; |
||||
|
num? frozenBalance; |
||||
|
num? availableWithdrawBalance; |
||||
|
num? settlementBalance; |
||||
|
num? totalWithdrawBalance; |
||||
|
|
||||
|
WalletAccountData( |
||||
|
{this.id, |
||||
|
this.totalBalance, |
||||
|
this.availableBalance, |
||||
|
this.frozenBalance, |
||||
|
this.availableWithdrawBalance, |
||||
|
this.settlementBalance, |
||||
|
this.totalWithdrawBalance}); |
||||
|
|
||||
|
WalletAccountData.fromJson(Map<String, dynamic> json) { |
||||
|
id = json['id']; |
||||
|
totalBalance = json['totalBalance']; |
||||
|
availableBalance = json['availableBalance']; |
||||
|
frozenBalance = json['frozenBalance']; |
||||
|
availableWithdrawBalance = json['availableWithdrawBalance']; |
||||
|
settlementBalance = json['settlementBalance']; |
||||
|
totalWithdrawBalance = json['totalWithdrawBalance']; |
||||
|
} |
||||
|
|
||||
|
Map<String, dynamic> toJson() { |
||||
|
final Map<String, dynamic> data = new Map<String, dynamic>(); |
||||
|
data['id'] = this.id; |
||||
|
data['totalBalance'] = this.totalBalance; |
||||
|
data['availableBalance'] = this.availableBalance; |
||||
|
data['frozenBalance'] = this.frozenBalance; |
||||
|
data['availableWithdrawBalance'] = this.availableWithdrawBalance; |
||||
|
data['settlementBalance'] = this.settlementBalance; |
||||
|
data['totalWithdrawBalance'] = this.totalWithdrawBalance; |
||||
|
return data; |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,72 @@ |
|||||
|
class WalletAccountRecordData { |
||||
|
List<Records>? records; |
||||
|
int? total; |
||||
|
int? size; |
||||
|
int? current; |
||||
|
int? pages; |
||||
|
|
||||
|
WalletAccountRecordData( |
||||
|
{this.records, this.total, this.size, this.current, this.pages}); |
||||
|
|
||||
|
WalletAccountRecordData.fromJson(Map<String, dynamic> json) { |
||||
|
if (json['records'] != null) { |
||||
|
records = <Records>[]; |
||||
|
json['records'].forEach((v) { |
||||
|
records!.add(new Records.fromJson(v)); |
||||
|
}); |
||||
|
} |
||||
|
total = json['total']; |
||||
|
size = json['size']; |
||||
|
current = json['current']; |
||||
|
pages = json['pages']; |
||||
|
} |
||||
|
|
||||
|
Map<String, dynamic> toJson() { |
||||
|
final Map<String, dynamic> data = new Map<String, dynamic>(); |
||||
|
if (this.records != null) { |
||||
|
data['records'] = this.records!.map((v) => v.toJson()).toList(); |
||||
|
} |
||||
|
data['total'] = this.total; |
||||
|
data['size'] = this.size; |
||||
|
data['current'] = this.current; |
||||
|
data['pages'] = this.pages; |
||||
|
return data; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
class Records { |
||||
|
String? id; |
||||
|
String? walletAccountId; |
||||
|
String? createTime; |
||||
|
int? tradeType; |
||||
|
double? tradeAmount; |
||||
|
bool? isIncome; |
||||
|
|
||||
|
Records( |
||||
|
{this.id, |
||||
|
this.walletAccountId, |
||||
|
this.createTime, |
||||
|
this.tradeType, |
||||
|
this.tradeAmount, |
||||
|
this.isIncome}); |
||||
|
|
||||
|
Records.fromJson(Map<String, dynamic> json) { |
||||
|
id = json['id']; |
||||
|
walletAccountId = json['walletAccountId']; |
||||
|
createTime = json['createTime']; |
||||
|
tradeType = json['tradeType']; |
||||
|
tradeAmount = json['tradeAmount']; |
||||
|
isIncome = json['isIncome']; |
||||
|
} |
||||
|
|
||||
|
Map<String, dynamic> toJson() { |
||||
|
final Map<String, dynamic> data = new Map<String, dynamic>(); |
||||
|
data['id'] = this.id; |
||||
|
data['walletAccountId'] = this.walletAccountId; |
||||
|
data['createTime'] = this.createTime; |
||||
|
data['tradeType'] = this.tradeType; |
||||
|
data['tradeAmount'] = this.tradeAmount; |
||||
|
data['isIncome'] = this.isIncome; |
||||
|
return data; |
||||
|
} |
||||
|
} |
||||
Write
Preview
Loading…
Cancel
Save