You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
98 lines
2.7 KiB
98 lines
2.7 KiB
import 'package:dating_touchme_app/model/mine/bank_card_data.dart';
|
|
import 'package:dating_touchme_app/model/mine/withdraw_data.dart';
|
|
import 'package:dating_touchme_app/network/user_api.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
|
import 'package:get/get.dart';
|
|
import 'package:get/get_state_manager/src/simple/get_controllers.dart';
|
|
|
|
class WithdrawController extends GetxController {
|
|
|
|
late UserApi _userApi;
|
|
|
|
final money = 3880.obs;
|
|
|
|
final bankCardList = <BankCardData>[].obs;
|
|
|
|
final nowBankCard = BankCardData().obs;
|
|
|
|
final withdrawMoney = ''.obs;
|
|
final withdrawMoneyController = TextEditingController().obs;
|
|
|
|
final serviceFeeData = WithdrawData().obs;
|
|
|
|
@override
|
|
void onInit() {
|
|
super.onInit();
|
|
_userApi = Get.find<UserApi>();
|
|
|
|
getBankCard();
|
|
}
|
|
|
|
getBankCard() async {
|
|
try{
|
|
final response = await _userApi.listBankCardByIndividual({});
|
|
if (response.data.isSuccess && response.data.data != null) {
|
|
final data = response.data.data;
|
|
bankCardList.clear();
|
|
bankCardList.addAll(data?.toList() ?? []);
|
|
} else {
|
|
|
|
// 响应失败,抛出异常
|
|
throw Exception(response.data.message ?? '获取数据失败');
|
|
}
|
|
} catch (e) {
|
|
print('银行卡列表获取失败: $e');
|
|
SmartDialog.showToast('银行卡列表获取失败');
|
|
rethrow;
|
|
}
|
|
}
|
|
|
|
getServiceFee() async {
|
|
try {
|
|
final response = await _userApi.calculateWithdrawServiceFee({
|
|
"withdrawAmount": withdrawMoney.value,
|
|
"withdrawType": 1
|
|
});
|
|
if (response.data.isSuccess && response.data.data != null) {
|
|
serviceFeeData.value = response.data.data ?? WithdrawData();
|
|
} else {
|
|
|
|
// 响应失败,抛出异常
|
|
throw Exception(response.data.message ?? '获取数据失败');
|
|
}
|
|
} catch(e){
|
|
print('手续费获取失败: $e');
|
|
SmartDialog.showToast('手续费获取失败');
|
|
rethrow;
|
|
|
|
}
|
|
}
|
|
|
|
withdrawSubmit() async {
|
|
try {
|
|
final response = await _userApi.applyWalletAccountWithdraw({
|
|
"thirdPartyFields": [
|
|
{"key": 'bankCardId', "value": nowBankCard.value.id}
|
|
],
|
|
"withdrawAmount": withdrawMoney.value,
|
|
"withdrawType": 1
|
|
});
|
|
if (response.data.isSuccess) {
|
|
|
|
SmartDialog.showToast('提现审核提交成功');
|
|
Get.back();
|
|
Get.back();
|
|
} else {
|
|
|
|
// 响应失败,抛出异常
|
|
throw Exception(response.data.message ?? '获取数据失败');
|
|
}
|
|
} catch(e){
|
|
print('提现审核提交失败: $e');
|
|
SmartDialog.showToast('提现审核提交失败');
|
|
rethrow;
|
|
|
|
}
|
|
}
|
|
}
|