初始化
This commit is contained in:
@@ -0,0 +1,177 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:hgdj/assets_tool/app_colors.dart';
|
||||
import 'package:hgdj/config/address.dart';
|
||||
import 'package:hgdj/hj_utils/api_service/mine_service.dart';
|
||||
import 'package:hgdj/hj_utils/screen.dart';
|
||||
import 'package:hgdj/tools_base/debug_log.dart';
|
||||
import 'package:hgdj/tools_base/loading/loading_helper.dart';
|
||||
import 'package:hgdj/tools_base/net/http_manager.dart';
|
||||
import 'package:hgdj/tools_base/toast.dart';
|
||||
import 'package:hgdj/tools_base/widget/common_dialog.dart';
|
||||
|
||||
import '../../make_money/alipay_ccdcapi_model.dart';
|
||||
|
||||
class AddBankDialog extends StatefulWidget {
|
||||
const AddBankDialog({super.key});
|
||||
|
||||
@override
|
||||
State<AddBankDialog> createState() => _AddBankDialogState();
|
||||
}
|
||||
|
||||
class _AddBankDialogState extends State<AddBankDialog> {
|
||||
late final bankNameCtr = TextEditingController();
|
||||
late final bankNoCtr = TextEditingController();
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return CommonDialog(
|
||||
canTapClose: false,
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Text(
|
||||
'添加银行卡',
|
||||
style: TextStyle(
|
||||
color: Colors.white, fontSize: 20, fontWeight: FontWeight.w500),
|
||||
),
|
||||
12.sizeBoxH,
|
||||
Divider(height: .5, color: Colors.white.withValues(alpha: .1)),
|
||||
12.sizeBoxH,
|
||||
Container(
|
||||
height: 44,
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white.withValues(alpha: .1),
|
||||
borderRadius: BorderRadius.circular(6),
|
||||
),
|
||||
alignment: Alignment.centerLeft,
|
||||
padding: EdgeInsets.symmetric(horizontal: 16),
|
||||
child: TextField(
|
||||
maxLength: 20,
|
||||
controller: bankNameCtr,
|
||||
style: TextStyle(color: Colors.white),
|
||||
inputFormatters: [
|
||||
FilteringTextInputFormatter.allow(
|
||||
RegExp(r'[a-zA-Z\u4E00-\u9F5a]'))
|
||||
],
|
||||
decoration: InputDecoration(
|
||||
border: InputBorder.none,
|
||||
counterText: '',
|
||||
contentPadding: EdgeInsets.zero,
|
||||
isDense: true,
|
||||
hintText: '请输入姓名',
|
||||
hintStyle: TextStyle(
|
||||
fontSize: 14,
|
||||
color: Colors.white.withValues(alpha: .45),
|
||||
fontWeight: FontWeight.w400,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
12.sizeBoxH,
|
||||
Container(
|
||||
height: 44,
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white.withValues(alpha: .1),
|
||||
borderRadius: BorderRadius.circular(6),
|
||||
),
|
||||
alignment: Alignment.centerLeft,
|
||||
padding: EdgeInsets.symmetric(horizontal: 16),
|
||||
child: TextField(
|
||||
maxLength: 20,
|
||||
controller: bankNoCtr,
|
||||
style:
|
||||
TextStyle(color: Colors.white, fontWeight: FontWeight.w400),
|
||||
inputFormatters: [
|
||||
FilteringTextInputFormatter.allow(RegExp(r'[0-9]'))
|
||||
],
|
||||
keyboardType: TextInputType.number,
|
||||
decoration: InputDecoration(
|
||||
border: InputBorder.none,
|
||||
hintText: '请输入银行卡号',
|
||||
counterText: '',
|
||||
contentPadding: EdgeInsets.zero,
|
||||
isDense: true,
|
||||
hintStyle: TextStyle(
|
||||
fontSize: 14,
|
||||
color: Colors.white.withValues(alpha: .45),
|
||||
fontWeight: FontWeight.w400,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
24.sizeBoxH,
|
||||
InkWell(
|
||||
enableFeedback: false,
|
||||
onTap: () {
|
||||
if (bankNoCtr.text.isEmpty) {
|
||||
showToast('请输入银行卡号');
|
||||
return;
|
||||
}
|
||||
if (bankNameCtr.text.isEmpty) {
|
||||
showToast('请输入持卡人姓名');
|
||||
return;
|
||||
}
|
||||
_bankNumberVerifyReq();
|
||||
},
|
||||
child: Container(
|
||||
height: 44,
|
||||
alignment: Alignment.center,
|
||||
decoration: BoxDecoration(
|
||||
color: AppColors.actionRed,
|
||||
borderRadius: BorderRadius.circular(3),
|
||||
),
|
||||
child: Text(
|
||||
"立即提交",
|
||||
style: TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.w500),
|
||||
),
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
///校验银行卡信息
|
||||
void _bankNumberVerifyReq() async {
|
||||
String bankNum = bankNoCtr.text.trim();
|
||||
if (bankNum.isEmpty || bankNum.length < 13) {
|
||||
showToast("银行卡号错误");
|
||||
return;
|
||||
}
|
||||
LoadingHelper.showLoading();
|
||||
httpManager.fetchResponseByGET(Address.aliCcdApi + bankNum).then((ret) {
|
||||
LoadingHelper.dismissLoading();
|
||||
if (!ret.isSuccess) {
|
||||
showToast("银行卡验证失败.");
|
||||
return;
|
||||
}
|
||||
if (ret.isSuccess) {
|
||||
final model = ApcApiModel.fromMap(Map<String, dynamic>.from(ret.data));
|
||||
if (model?.validated ?? false) {
|
||||
// model.bank, model.cardType
|
||||
debugLog("model.bank-->", "${model?.bank}");
|
||||
debugLog("model.cardType-->", "${model?.cardType}");
|
||||
// _commonWithdrawReq(true, bank: model?.bank);
|
||||
_addBankCard(model!);
|
||||
} else {
|
||||
showToast("银行卡验证失败");
|
||||
}
|
||||
} else {
|
||||
showToast("银行卡验证失败");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
_addBankCard(ApcApiModel model) async {
|
||||
final res = await MineService.addBankCard(
|
||||
model.key, bankNameCtr.text, model.bank, model.cardType);
|
||||
if (res) {
|
||||
Get.back(result: true);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user