初始化

This commit is contained in:
谢宇宁
2026-09-15 15:44:13 +07:00
commit a23ba685e9
1065 changed files with 101122 additions and 0 deletions
@@ -0,0 +1,312 @@
import 'dart:convert' as convert;
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:hgdj/assets_tool/app_colors.dart';
import 'package:hgdj/hj_utils/api_service/mine_service.dart';
import 'package:hgdj/hj_utils/screen.dart';
import 'package:pull_to_refresh/pull_to_refresh.dart';
import 'package:hgdj/tools_base/toast.dart';
import 'package:hgdj/tools_base/widget/common_alert.dart';
import '../../../../hj_utils/light_model.dart';
import '../../../../hj_utils/store_keys.dart';
import '../../../../tools_base/refresh/pull_refresh.dart';
import '../../../hj_utils/widget_util.dart';
import '../../../tools_base/loading/loading_alert_widget.dart';
import '../../../tools_base/loading/loading_center_widget.dart';
import 'model/alipay_bank_list_model.dart';
import 'widget/add_bank_dialog.dart';
///银行卡管理
class BankCardHomePage extends StatefulWidget {
final AccountInfoModel? selectModel;
BankCardHomePage({super.key, this.selectModel});
@override
State<StatefulWidget> createState() {
return _BankCardHomePageState();
}
}
class _BankCardHomePageState extends State<BankCardHomePage> {
bool isEdit = false;
bool loading = true;
List<AccountInfoModel> aliList = [];
AccountInfoModel? selectItem;
List<AccountInfoModel> deleteList = [];
RefreshController? refreshCtr;
@override
void initState() {
super.initState();
_getAliListData();
}
void _onDeleteAccount() async {
if (deleteList.isEmpty) return;
var isDelete = await CommonAlert.show(content: "是否确认删除账号");
if (!isDelete) return;
LoadingAlertWidget.show();
bool result = false;
for (var model in deleteList) {
result = await MineService.bankCardDelete(id: model.id);
if (result) {
var result = await lightKV.getString(StoreKeys.LAST_A_ACCOUNT);
if (result != null) {
AccountInfoModel listBean =
AccountInfoModel.fromMap(convert.jsonDecode(result));
if (model.id == listBean.id) {
lightKV.setString(StoreKeys.LAST_A_ACCOUNT, "");
}
}
aliList.remove(model);
setState(() {});
}
}
if (result) {
showToast("删除成功");
isEdit = false;
if (mounted) setState(() {});
}
LoadingAlertWidget.cancel();
}
void _getAliListData() async {
final model = await MineService.getBankCards();
aliList.clear();
aliList.addAll(model?.list ?? []);
refreshCtr?.refreshCompleted();
if (aliList.isNotEmpty == true) {
if (widget.selectModel != null) {
selectItem = widget.selectModel;
} else {
// selectItem = aliList.firstOrNull;
}
}
loading = false;
setState(() {});
}
@override
Widget build(BuildContext context) {
return Scaffold(
resizeToAvoidBottomInset: false,
appBar: AppBar(
title: Text('选择银行卡',
style: textStyle(18, Color(0xE5FFFFFF), FontWeight.w600)),
leading: BackButton(
onPressed: () => Get.back(result: selectItem),
),
actions: [
InkWell(
enableFeedback: false,
onTap: () {
isEdit = !isEdit;
if (isEdit) {
deleteList.clear();
}
setState(() {});
},
child: Container(
alignment: Alignment.center,
padding: EdgeInsets.symmetric(horizontal: 10, vertical: 5),
child: Text(
isEdit ? "完成" : "编辑",
style: TextStyle(
color: isEdit ? AppColors.actionRed : Color(0x8CFFFFFF),
fontSize: 12,
),
),
),
),
18.sizeBoxW,
],
),
body: Stack(
fit: StackFit.expand,
children: [
Column(
children: [
Expanded(child: () {
if (loading) return LoadingCenterWidget();
if (aliList.isEmpty == true) return CErrorWidget();
return Container(
margin: EdgeInsets.fromLTRB(16, 12, 16, 0),
child: pullYsRefresh(
onInit: (ctr) => refreshCtr = ctr,
enablePullUp: false,
onRefresh: (ctr) => _getAliListData(),
child: ListView.builder(
padding: EdgeInsets.only(top: 10, bottom: 80),
shrinkWrap: true,
itemCount: aliList.length ?? 0,
itemBuilder: (BuildContext context, int index) {
return _buildCardView(index, aliList[index]);
},
),
),
);
}()),
_buildCardAddView(),
],
),
if (isEdit)
Positioned(
bottom: 0,
left: 0,
right: 0,
child: GestureDetector(
onTap: () => _onDeleteAccount(),
child: Container(
margin: EdgeInsets.symmetric(horizontal: 35, vertical: 20),
height: 44,
decoration: BoxDecoration(
color: Color(0xffF52C56),
borderRadius: const BorderRadius.all(Radius.circular(3)),
),
child: Center(
child: Text(
"删除",
style: TextStyle(
color: Colors.white,
fontWeight: FontWeight.w500,
fontSize: 16,
),
),
),
),
),
),
],
),
);
}
Widget _buildCardView(int index, AccountInfoModel? item) {
bool isSelected = false;
if (isEdit) {
if (deleteList.contains(item) == true) {
isSelected = true;
}
} else {
isSelected = selectItem?.id == item?.id;
}
return InkWell(
enableFeedback: false,
onTap: () {
if (isEdit) {
if (deleteList.contains(item) == true) {
deleteList.remove(item);
} else {
deleteList.add(item!);
}
} else {
Get.back(result: item);
}
setState(() {});
},
child: Container(
margin: EdgeInsets.only(bottom: 12),
padding: EdgeInsets.symmetric(horizontal: 12, vertical: 18),
decoration: BoxDecoration(
borderRadius: BorderRadius.all(Radius.circular(9)),
color: const Color(0x0DFFFFFF)),
child: Row(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.center,
children: [
Row(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Text(
item?.getBankName() ?? "",
style: const TextStyle(
color: const Color(0xE5ffffff),
fontWeight: FontWeight.w500,
fontSize: 16.0),
),
9.sizeBoxW,
Text(
item?.actName ?? "",
style: const TextStyle(
color: const Color(0xE5ffffff),
fontWeight: FontWeight.w400,
fontSize: 12.0),
)
],
),
6.sizeBoxH,
Text("卡号:${item?.act}",
style: const TextStyle(
color: const Color(0xffffffff),
fontWeight: FontWeight.w400,
fontSize: 12.0))
],
),
),
Stack(
alignment: Alignment.center,
children: [
Container(
width: 18,
height: 18,
decoration: BoxDecoration(
color: isSelected ? Colors.white : Colors.transparent,
shape: BoxShape.circle,
),
),
Icon(
isSelected
? CupertinoIcons.checkmark_circle_fill
: CupertinoIcons.circle,
color: isSelected ? Color(0xffE1351F) : Color(0xff999999),
),
],
),
],
),
),
);
}
//添加银行卡
_buildCardAddView() {
return InkWell(
enableFeedback: false,
onTap: () async {
final res = await Get.dialog(AddBankDialog(),
barrierColor: Colors.black.withValues(alpha: .7));
if (res != null) {
_getAliListData();
}
},
child: Container(
margin: EdgeInsets.symmetric(horizontal: 35, vertical: 20),
height: 44,
decoration: BoxDecoration(
color: AppColors.actionRed,
borderRadius: const BorderRadius.all(Radius.circular(3)),
),
child: Center(
child: Text(
"添加银行卡",
style: TextStyle(
color: Colors.white,
fontWeight: FontWeight.w500,
fontSize: 16,
),
),
),
),
);
}
}
@@ -0,0 +1,53 @@
import 'bankcard_info.dart';
class ApBankListModel {
List<AccountInfoModel>? list;
static ApBankListModel fromJson(Map<String, dynamic>? map) {
ApBankListModel apBankListModel = ApBankListModel();
if (map == null) return apBankListModel;
if (map['list'] is List) {
apBankListModel.list = (map['list'] as List).map((o) => AccountInfoModel.fromMap(o)).toList();
}
return apBankListModel;
}
}
class AccountInfoModel {
String? id;
String? actName;
String? act;
String? bankCode;
String? cardType;
static AccountInfoModel fromMap(Map<String, dynamic>? map) {
AccountInfoModel listBean = AccountInfoModel();
if (map == null) return AccountInfoModel();
listBean.id = map['id'];
listBean.actName = map['actName'];
listBean.act = map['act'];
listBean.bankCode = map['bankCode'];
listBean.cardType = map['cardType'];
return listBean;
}
///获取银行名称
String? getBankName() {
if (bankCode?.isEmpty == true) {
return "";
}
BankCardModel? model = BankcardInfo().getBankInfoMap(bankCode!);
if (model == null) {
return BankcardInfo().getBankName(bankCode!);
}
return model.bankName ?? "";
}
}
class BankCardModel {
String? bankLogoId;
String? bankName;
String? bankCardId;
BankCardModel(this.bankLogoId, this.bankName, this.bankCardId);
}
@@ -0,0 +1,201 @@
import 'alipay_bank_list_model.dart';
class BankcardInfo {
static final BankcardInfo _instance = BankcardInfo._internal();
factory BankcardInfo() => _instance;
BankcardInfo._internal();
var bankName = ['招商银行', '中国银行', '农业银行', '交通银行', '建设银行', '民生银行', '中信银行', '光大银行', '华夏银行', '工商银行', '兴业银行', '国家开发银行'];
var bankCardId = ['CMB', 'BOC', 'ABC', 'COMM', 'CCB', 'CMBC', 'CITIC', 'CEB', 'HXBANK', 'ICBC', 'CIB', 'CDB'];
BankCardModel? getBankInfoMap(String bankId) {
Map<String, dynamic> map = Map();
for (int i = 0; i < bankCardId.length; i++) {
BankCardModel model = new BankCardModel(null, bankName[i], bankCardId[i]);
map[bankCardId[i]] = model;
}
bool contains = map.containsKey(bankId);
if (contains) {
return map[bankId];
}
return null;
}
///支付宝支持银行
String? getBankName(String bankId) {
Map<String, String> map = Map();
map["SRCB"] = "深圳农村商业银行";
map["BGB"] = "广西北部湾银行";
map["SHRCB"] = "上海农村商业银行";
map["BJBANK"] = "北京银行";
map["WHCCB"] = "威海市商业银行";
map["BOZK"] = "周口银行";
map["KORLABANK"] = "库尔勒市商业银行";
map["SPABANK"] = "平安银行";
map["SDEB"] = "顺德农商银行";
map["HURCB"] = "湖北省农村信用社";
map["WRCB"] = "无锡农村商业银行";
map["BOCY"] = "朝阳银行";
map["CZBANK"] = "浙商银行";
map["HDBANK"] = "邯郸银行";
map["BOC"] = "中国银行";
map["BOD"] = "东莞银行";
map["CCB"] = "中国建设银行";
map["ZYCBANK"] = "遵义市商业银行";
map["SXCB"] = "绍兴银行";
map["GZRCU"] = "贵州省农村信用社";
map["ZJKCCB"] = "张家口市商业银行";
map["BOJZ"] = "锦州银行";
map["BOP"] = "平顶山银行";
map["HKB"] = "汉口银行";
map["SPDB"] = "上海浦东发展银行";
map["NXRCU"] = "宁夏黄河农村商业银行";
map["NYNB"] = "广东南粤银行";
map["GRCB"] = "广州农商银行";
map["BOSZ"] = "苏州银行";
map["HZCB"] = "杭州银行";
map["HSBK"] = "衡水银行";
map["HBC"] = "湖北银行";
map["JXBANK"] = "嘉兴银行";
map["HRXJB"] = "华融湘江银行";
map["BODD"] = "丹东银行";
map["AYCB"] = "安阳银行";
map["EGBANK"] = "恒丰银行";
map["CDB"] = "国家开发银行";
map["TCRCB"] = "江苏太仓农村商业银行";
map["NJCB"] = "南京银行";
map["ZZBANK"] = "郑州银行";
map["DYCB"] = "德阳商业银行";
map["YBCCB"] = "宜宾市商业银行";
map["SCRCU"] = "四川省农村信用";
map["KLB"] = "昆仑银行";
map["LSBANK"] = "莱商银行";
map["YDRCB"] = "尧都农商行";
map["CCQTGB"] = "重庆三峡银行";
map["FDB"] = "富滇银行";
map["JSRCU"] = "江苏省农村信用联合社";
map["JNBANK"] = "济宁银行";
map["CMB"] = "招商银行";
map["JINCHB"] = "晋城银行JCBANK";
map["FXCB"] = "阜新银行";
map["WHRCB"] = "武汉农村商业银行";
map["HBYCBANK"] = "湖北银行宜昌分行";
map["TZCB"] = "台州银行";
map["TACCB"] = "泰安市商业银行";
map["XCYH"] = "许昌银行";
map["CEB"] = "中国光大银行";
map["NXBANK"] = "宁夏银行";
map["HSBANK"] = "徽商银行";
map["JJBANK"] = "九江银行";
map["NHQS"] = "农信银清算中心";
map["MTBANK"] = "浙江民泰商业银行";
map["LANGFB"] = "廊坊银行";
map["ASCB"] = "鞍山银行";
map["KSRB"] = "昆山农村商业银行";
map["YXCCB"] = "玉溪市商业银行";
map["DLB"] = "大连银行";
map["DRCBCL"] = "东莞农村商业银行";
map["GCB"] = "广州银行";
map["NBBANK"] = "宁波银行";
map["BOYK"] = "营口银行";
map["SXRCCU"] = "陕西信合";
map["GLBANK"] = "桂林银行";
map["BOQH"] = "青海银行";
map["CDRCB"] = "成都农商银行";
map["QDCCB"] = "青岛银行";
map["HKBEA"] = "东亚银行";
map["HBHSBANK"] = "湖北银行黄石分行";
map["WZCB"] = "温州银行";
map["TRCB"] = "天津农商银行";
map["QLBANK"] = "齐鲁银行";
map["GDRCC"] = "广东省农村信用社联合社";
map["ZJTLCB"] = "浙江泰隆商业银行";
map["GZB"] = "赣州银行";
map["GYCB"] = "贵阳市商业银行";
map["CQBANK"] = "重庆银行";
map["DAQINGB"] = "龙江银行";
map["CGNB"] = "南充市商业银行";
map["SCCB"] = "三门峡银行";
map["CSRCB"] = "常熟农村商业银行";
map["SHBANK"] = "上海银行";
map["JLBANK"] = "吉林银行";
map["CZRCB"] = "常州农村信用联社";
map["BANKWF"] = "潍坊银行";
map["ZRCBANK"] = "张家港农村商业银行";
map["FJHXBC"] = "福建海峡银行";
map["ZJNX"] = "浙江省农村信用社联合社";
map["LZYH"] = "兰州银行";
map["JSB"] = "晋商银行";
map["BOHAIB"] = "渤海银行";
map["CZCB"] = "浙江稠州商业银行";
map["YQCCB"] = "阳泉银行";
map["SJBANK"] = "盛京银行";
map["XABANK"] = "西安银行";
map["BSB"] = "包商银行";
map["JSBANK"] = "江苏银行";
map["FSCB"] = "抚顺银行";
map["HNRCU"] = "河南省农村信用";
map["COMM"] = "交通银行";
map["CITIC"] = "中信银行";
map["XTB"] = "邢台银行";
map["HXBANK"] = "华夏银行";
map["HNRCC"] = "湖南省农村信用社";
map["DYCCB"] = "东营市商业银行";
map["ORBANK"] = "鄂尔多斯银行";
map["BJRCB"] = "北京农村商业银行";
map["XYBANK"] = "信阳银行";
map["ZGCCB"] = "自贡市商业银行";
map["CDCB"] = "成都银行";
map["HANABANK"] = "韩亚银行";
map["CMBC"] = "中国民生银行";
map["LYBANK"] = "洛阳银行";
map["GDB"] = "广东发展银行";
map["ZBCB"] = "齐商银行";
map["CBKF"] = "开封市商业银行";
map["H3CB"] = "内蒙古银行";
map["CIB"] = "兴业银行";
map["CRCBANK"] = "重庆农村商业银行";
map["SZSBK"] = "石嘴山银行";
map["DZBANK"] = "德州银行";
map["SRBANK"] = "上饶银行";
map["LSCCB"] = "乐山市商业银行";
map["JXRCU"] = "江西省农村信用";
map["ICBC"] = "中国工商银行";
map["JZBANK"] = "晋中市商业银行";
map["HZCCB"] = "湖州市商业银行";
map["NHB"] = "南海农村信用联社";
map["XXBANK"] = "新乡银行";
map["JRCB"] = "江苏江阴农村商业银行";
map["YNRCC"] = "云南省农村信用社";
map["ABC"] = "中国农业银行";
map["GXRCU"] = "广西省农村信用";
map["PSBC"] = "中国邮政储蓄银行";
map["BZMD"] = "驻马店银行";
map["ARCU"] = "安徽省农村信用社";
map["GSRCU"] = "甘肃省农村信用";
map["LYCB"] = "辽阳市商业银行";
map["JLRCU"] = "吉林农信";
map["URMQCCB"] = "乌鲁木齐市商业银行";
map["XLBANK"] = "中山小榄村镇银行";
map["CSCB"] = "长沙银行";
map["JHBANK"] = "金华银行";
map["BHB"] = "河北银行";
map["NBYZ"] = "鄞州银行";
map["LSBC"] = "临商银行";
map["BOCD"] = "承德银行";
map["SDRCU"] = "山东农信";
map["NCB"] = "南昌银行";
map["TCCB"] = "天津银行";
map["WJRCB"] = "吴江农商银行";
map["CBBQS"] = "城市商业银行资金清算中心";
map["HBRCU"] = "河北省农村信用社";
return map[bankId];
}
}
@@ -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);
}
}
}