import 'package:dio/dio.dart'; import 'package:flutter/material.dart'; import 'package:flutter_easyloading/flutter_easyloading.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:flutter_smart_dialog/flutter_smart_dialog.dart'; import 'package:huixiang/view_widget/my_appbar.dart'; import 'package:pull_to_refresh/pull_to_refresh.dart'; import 'package:shimmer/shimmer.dart'; import '../../../generated/l10n.dart'; import '../../../retrofit/business_api.dart'; import '../../../retrofit/data/base_data.dart'; import '../../../retrofit/data/bus_recharge_list.dart'; import '../../../retrofit/data/phone_query_member_info.dart'; import '../../../utils/business_instance.dart'; import '../../../utils/flutter_utils.dart'; import '../../../utils/font_weight.dart'; import '../../../view_widget/border_text.dart'; import '../../../view_widget/classic_header.dart'; import '../../../view_widget/my_footer.dart'; import '../../../view_widget/no_data_view.dart'; import '../../../view_widget/round_button.dart'; import '../../../view_widget/settlement_tips_dialog.dart'; class VipRechargePage extends StatefulWidget { final Map arguments; VipRechargePage({this.arguments}); @override State createState() { return _VipRechargePage(); } } class _VipRechargePage extends State { BusinessApiService businessService; final TextEditingController vipPhoneController = TextEditingController(); final RefreshController _refreshController = RefreshController(); bool isKeyBoardShow = false; FocusNode _focusNode = FocusNode(); int selectIndex = 0; int payIndex = 1; String networkError = ""; int networkStatus = 0; List records = []; PhoneQueryMemberInfo phoneQueryMemberInfo; String rechargeId; List manualQueryInfo; @override void initState() { super.initState(); WidgetsBinding.instance.addPostFrameCallback((_) { setState(() { print("object: ${MediaQuery.of(context).viewInsets.bottom}"); if (MediaQuery.of(context).viewInsets.bottom == 0) { if (isKeyBoardShow) { isKeyBoardShow = false; //关闭键盘 软键盘关闭了, 清除输入控件的焦点, 否则重新进入页面会导致软键盘再弹出问题 FocusScope.of(context).requestFocus(FocusNode()); } } else { isKeyBoardShow = true; } }); }); _onRefresh(); } ///离开页面记着销毁和清除 @override void dispose() { _focusNode.unfocus(); super.dispose(); } _onRefresh({bool isShowLoad = true}) async { if (isShowLoad) EasyLoading.show( status: S.current.zhengzaijiazai, maskType: EasyLoadingMaskType.black); if (vipPhoneController?.text != "") await queryMemberPhoneInfo(vipPhoneController?.text ?? "", isShow: false); else await queryRechargeList("", isShow: false); EasyLoading.dismiss(); if (!mounted) return; if (_refreshController.isRefresh) _refreshController.refreshCompleted(); setState(() {}); } ///充值列表 queryRechargeList(mid, {isShow = true}) async { try { if (businessService == null) { businessService = BusinessApiService(Dio(), context: context, token: BusinessInstance.instance.businessToken, tenant: BusinessInstance.instance.businessTenant, storeId: widget.arguments["storeId"]); } BaseData baseData = await businessService.getRechargePreferential({ "current": 1, "size": 999, "model": { "rechargeType": "", "tenantCode": BusinessInstance.instance.businessTenant, "mid": mid } }).catchError((error) { networkError = AppUtils.dioErrorTypeToString(error.type); networkStatus = -1; setState(() {}); _refreshController.refreshFailed(); _refreshController.loadFailed(); }); if (!mounted) return; if (baseData != null && baseData.isSuccess) { records.clear(); records.addAll(baseData?.data?.records ?? []); networkStatus = 1; } else { SmartDialog.showToast(baseData.msg, alignment: Alignment.center); } } finally { if (isShow) setState(() {}); } } ///根据手机号搜索用户信息 queryMemberPhoneInfo(phoneNum, {isShow = true}) async { try { if (isShow) EasyLoading.show( status: S.current.zhengzaijiazai, maskType: EasyLoadingMaskType.black); if (businessService == null) { businessService = BusinessApiService(Dio(), context: context, token: BusinessInstance.instance.businessToken, tenant: BusinessInstance.instance.businessTenant, storeId: widget.arguments["storeId"]); } BaseData baseData = await businessService .queryMemberInfo( {"phoneNum": phoneNum, "isNewUser": false}).catchError((error) { networkError = AppUtils.dioErrorTypeToString(error.type); networkStatus = -1; setState(() {}); _refreshController.refreshFailed(); _refreshController.loadFailed(); }); if (!mounted) return; if (baseData != null && baseData.isSuccess) { phoneQueryMemberInfo = baseData.data; queryRechargeList(phoneQueryMemberInfo?.mid ?? ""); networkStatus = 1; } else { SmartDialog.showToast(baseData.msg, alignment: Alignment.center); } } finally { if (isShow) EasyLoading.dismiss(); } } ///充值方式支付 payMemberType( authCode, memberSourceId, rechargePreferentialId, source) async { try { EasyLoading.show( status: S.current.zhengzaijiazai, maskType: EasyLoadingMaskType.black); if (businessService == null) { businessService = BusinessApiService(Dio(), context: context, token: BusinessInstance.instance.businessToken, tenant: BusinessInstance.instance.businessTenant, storeId: widget.arguments["storeId"]); } BaseData baseData = await businessService.posMemberRecharge({ "authCode": authCode, "memberSourceId": memberSourceId, "rechargePreferentialId": rechargePreferentialId, "source": source }).catchError((error) { networkError = AppUtils.dioErrorTypeToString(error.type); networkStatus = -1; setState(() {}); _refreshController.refreshFailed(); _refreshController.loadFailed(); }); if (!mounted) return; if (baseData != null && baseData.isSuccess) { rechargeId = baseData.data; Navigator.of(context) .popAndPushNamed('/router/pay_success_page', arguments: { "rechargeId": baseData.data, "rechargeMoney": records[selectIndex].rechargeMoney, "payIndex": payIndex, }); networkStatus = 1; setState(() {}); } else { SmartDialog.show( widget: SettlementTips( () {}, text: baseData.msg, color: Color(0xFF30415B), )); } } finally { EasyLoading.dismiss(); } } ///手动查询充值订单状态 manualQueryRechargeOrder(memberRechargeId) async { try { EasyLoading.show( status: S.current.zhengzaijiazai, maskType: EasyLoadingMaskType.black); if (businessService == null) { businessService = BusinessApiService(Dio(), context: context, token: BusinessInstance.instance.businessToken, tenant: BusinessInstance.instance.businessTenant, storeId: widget.arguments["storeId"]); } BaseData baseData = await businessService.manualQuery({ "phone": phoneQueryMemberInfo?.phoneNum ?? "", "memberRechargeId": memberRechargeId, }).catchError((error) {}); if (baseData != null && baseData.isSuccess) { Navigator.of(context).pop(); Navigator.of(context) .popAndPushNamed('/router/pay_success_page', arguments: { "rechargeId": baseData.data, "rechargeMoney": records[selectIndex].rechargeMoney, "payIndex": payIndex, }); } else { if (baseData.msg != "需要用户输入支付密码") Navigator.of(context).pop(); SmartDialog.show( widget: SettlementTips( () {}, text: baseData.msg, color: Color(0xFF30415B), )); } } finally { EasyLoading.dismiss(); } } @override Widget build(BuildContext context) { return GestureDetector( behavior: HitTestBehavior.translucent, onTap: () { FocusScope.of(context).unfocus(); }, child: Scaffold( resizeToAvoidBottomInset: false, appBar: MyAppBar( title: S.of(context).chongzhi, titleColor: Colors.black, background: Colors.white, leadingColor: Colors.black, brightness: Brightness.dark, ), body: SmartRefresher( enablePullDown: true, enablePullUp: false, header: MyHeader( color: Color(0xFF30415B), ), footer: CustomFooter( builder: (context, mode) { return MyFooter(mode); }, ), controller: _refreshController, onRefresh: (){ _onRefresh(isShowLoad: false); }, physics: BouncingScrollPhysics(), child: networkStatus == -1? noNetwork() : SingleChildScrollView( physics: BouncingScrollPhysics(), child: Container( child:networkStatus == 0 ?vipRechargeSm():Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ ///会员搜索框 Container( decoration: BoxDecoration( color: Colors.white, boxShadow: [ BoxShadow( color: Color(0x0F06152E), offset: Offset(0, 2), blurRadius: 4, spreadRadius: 0, ) ], borderRadius: BorderRadius.circular(8), ), padding: EdgeInsets.symmetric(horizontal: 16.w), margin: EdgeInsets.only( bottom: 16.h, right: 16.w, left: 16.w, top: 8.h), child: Row( mainAxisAlignment: MainAxisAlignment.center, children: [ Expanded( child: Text( "会员", style: TextStyle( color: Color(0xFF1A1A1A), fontSize: 14.sp, fontWeight: FontWeight.w500, ), ), ), Expanded( child: TextField( controller: vipPhoneController, textInputAction: TextInputAction.search, onEditingComplete: () { FocusScope.of(context) .requestFocus(FocusNode()); queryMemberPhoneInfo( vipPhoneController.text ?? ""); }, decoration: InputDecoration( hintText: "请输入会员手机号", hintTextDirection: TextDirection.rtl, hintStyle: TextStyle( color: Color(0xFF808080), fontSize: 14.sp, fontWeight: MyFontWeight.regular), border: InputBorder.none, contentPadding: EdgeInsets.only(left: 16.w), ), textAlign: TextAlign.right, style: TextStyle( color: Color(0xFF808080), fontSize: 14.sp, fontWeight: MyFontWeight.regular), ), ), ], )), ///会员信息 if (phoneQueryMemberInfo != null) Container( width: double.infinity, decoration: BoxDecoration( color: Colors.white, boxShadow: [ BoxShadow( color: Color(0x0F06152E), offset: Offset(0, 2), blurRadius: 4, spreadRadius: 0, ) ], borderRadius: BorderRadius.circular(8), ), padding: EdgeInsets.only( top: 16.h, bottom: 16.h, left: 16.w), margin: EdgeInsets.only( bottom: 16.h, right: 16.w, left: 16.w), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Padding( padding: EdgeInsets.only(bottom: 16.h), child: Text( "用户名称: ${phoneQueryMemberInfo?.nickName ?? ""}", style: TextStyle( color: Color(0xFF1A1A1A), fontSize: 14.sp, fontWeight: MyFontWeight.regular, ), )), Padding( padding: EdgeInsets.only(bottom: 16.h), child: Text( "手机号: ${phoneQueryMemberInfo?.phoneNum ?? ""}", style: TextStyle( color: Color(0xFF1A1A1A), fontSize: 14.sp, fontWeight: MyFontWeight.regular, ), )), Text( "会员余额: ¥${phoneQueryMemberInfo?.balance ?? ""}", style: TextStyle( color: Color(0xFF1A1A1A), fontSize: 14.sp, fontWeight: MyFontWeight.regular, ), ), ], )), ///充值列表 rechargeList(), ///选择充值的套餐 if (networkStatus == 1) Container( decoration: BoxDecoration( color: Colors.white, boxShadow: [ BoxShadow( color: Color(0x0F06152E), offset: Offset(0, 2), blurRadius: 4, spreadRadius: 0, ) ], borderRadius: BorderRadius.circular(8), ), padding: EdgeInsets.all(16), margin: EdgeInsets.only( bottom: 24.h, right: 16.w, left: 16.w, ), child: Column( children: [ Row( children: [ Expanded( child: Text( "本次充值(元)", style: TextStyle( color: Color(0xFF1A1A1A), fontSize: 14.sp, fontWeight: FontWeight.w500, ), ), ), Text( AppUtils.calculateDouble((double.tryParse( records[selectIndex] ?.rechargeMoney) ?? 0)), style: TextStyle( color: Color(0xFF1A1A1A), fontSize: 14.sp, fontWeight: FontWeight.w500, ), ), ], ), Container( width: double.infinity, height: 1.h, color: Color(0xFFEBECEF), margin: EdgeInsets.symmetric(vertical: 16.h), ), Row( children: [ Expanded( child: Text( "充后余额(元)", style: TextStyle( color: Color(0xFF1A1A1A), fontSize: 14.sp, fontWeight: FontWeight.w500, ), ), ), Text( "${AppUtils.calculateDouble((double.tryParse(records[selectIndex]?.rechargeMoney) ?? 0) + (double.tryParse(records[selectIndex]?.giftdMoney) ?? 0))}", style: TextStyle( color: Color(0xFF1A1A1A), fontSize: 14.sp, fontWeight: FontWeight.w500, ), ), ], ), ], ), ), ///充值方式 Padding( padding: EdgeInsets.only(left: 16.w, bottom: 16.h), child: Text( "充值方式", style: TextStyle( color: Colors.black, fontSize: 15.sp, fontWeight: MyFontWeight.bold, ), )), Padding( padding: EdgeInsets.only(left: 16.w, right: 10.w), child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Expanded( child: GestureDetector( behavior: HitTestBehavior.opaque, onTap: () { setState(() { payIndex = 1; }); }, child: Container( decoration: BoxDecoration( borderRadius: BorderRadius.circular(8), border: Border.all( color: payIndex == 1 ? Color(0xFF30415B) : Color(0x29C5C5C5), width: 2, ), color: payIndex == 1 ? Color(0XFFEBF3FF) : Color(0xFFF9FAF8)), padding: EdgeInsets.only( top: 21.h, bottom: 15.h, ), margin: EdgeInsets.only(right: 6.w), child: Column( children: [ Image.asset( "assets/image/bus_vip_xj.webp", width: 45.w, height: 36.h, ), Padding( padding: EdgeInsets.only(top: 15.h), child: Text( "现金支付", style: TextStyle( color: Color(0xFF1A1A1A), fontSize: 14.sp, fontWeight: MyFontWeight.regular, ), )) ], ), ), )), Expanded( child: GestureDetector( behavior: HitTestBehavior.opaque, onTap: () { setState(() { payIndex = 3; }); }, child: Container( decoration: BoxDecoration( borderRadius: BorderRadius.circular(8), border: Border.all( color: payIndex == 3 ? Color(0xFF30415B) : Color(0x29C5C5C5), width: 2, ), color: payIndex == 3 ? Color(0XFFEBF3FF) : Color(0xFFF9FAF8)), padding: EdgeInsets.only( top: 21.h, bottom: 15.h, ), margin: EdgeInsets.only(right: 6.w, left: 6.w), child: Column( children: [ Image.asset( "assets/image/bus_vip_alipay.webp", width: 36.h, height: 36.h, ), Padding( padding: EdgeInsets.only(top: 15.h), child: Text( "支付宝支付", style: TextStyle( color: Color(0xFF1A1A1A), fontSize: 14.sp, fontWeight: MyFontWeight.regular, ), )) ], ), ), )), Expanded( child: GestureDetector( behavior: HitTestBehavior.opaque, onTap: () { setState(() { payIndex = 2; }); }, child: Container( decoration: BoxDecoration( borderRadius: BorderRadius.circular(8), border: Border.all( color: payIndex == 2 ? Color(0xFF30415B) : Color(0x29C5C5C5), width: 2, ), color: payIndex == 2 ? Color(0XFFEBF3FF) : Color(0xFFF9FAF8)), padding: EdgeInsets.only( top: 21.h, bottom: 15.h, ), margin: EdgeInsets.only(right: 6.w, left: 6.w), child: Column( children: [ Image.asset( "assets/image/bus_vip_wx.webp", width: 36.h, height: 36.h, ), Padding( padding: EdgeInsets.only(top: 15.h), child: Text( "微信支付", style: TextStyle( color: Color(0xFF1A1A1A), fontSize: 14.sp, fontWeight: MyFontWeight.regular, ), )) ], ), ), )), ], ), ), ///确认充值 Align( alignment: Alignment.bottomCenter, child: GestureDetector( behavior: HitTestBehavior.opaque, onTap: () { if (widget.arguments["storeId"] == "0") { SmartDialog.show( widget: SettlementTips( () {}, text: "请选择门店进行充值", color: Color(0xFF30415B), )); } else { if (vipPhoneController.text == "") { SmartDialog.show( widget: SettlementTips( () {}, text: "请输入会员手机号进行充值", color: Color(0xFF30415B), )); } else { showRechargePayDialog(); } } }, child: Container( color: Colors.white, width: double.infinity, margin: EdgeInsets.only(top: 132.h), padding: EdgeInsets.only( top: 10.h, left: 16.w, right: 16.w, bottom: 34.h), child: Container( alignment: Alignment.center, padding: EdgeInsets.symmetric(vertical: 16.h), decoration: BoxDecoration( color: Color(0xFF30415B), borderRadius: BorderRadius.circular(27), ), child: Text( "确认充值", style: TextStyle( color: Colors.white, fontSize: 16.sp, fontWeight: MyFontWeight.bold, ), ), ), ), )) ], ), )), ), ), ); } ///确认充值支付提示弹窗 showRechargePayDialog() { showDialog( context: context, builder: (context) { return AlertDialog( contentPadding: EdgeInsets.all(0), content: Container( width: MediaQuery.of(context).size.width - 80, padding: EdgeInsets.only( top: 24.h, ), child: Column( mainAxisAlignment: MainAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.center, mainAxisSize: MainAxisSize.min, children: [ Padding( padding: EdgeInsets.only(bottom: 20.h, left: 14.w, right: 14.w), child: Text.rich( TextSpan( children: [ TextSpan( text: "*", style: TextStyle( color: Color(0xFFFA5151), fontSize: 14.sp, fontWeight: FontWeight.w500, ), ), TextSpan( text: "请确认充账户及充值套餐后再点击确认", style: TextStyle( color: Color(0xFFFA5151), fontSize: 14.sp, fontWeight: MyFontWeight.regular, ), ), TextSpan( text: "*", style: TextStyle( color: Color(0xFFFA5151), fontSize: 14.sp, fontWeight: FontWeight.w500, ), ), ], ), ), ), Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Padding( padding: EdgeInsets.only( bottom: 18.h, left: 14.w, right: 14.w), child: Text( "充值账户: ${phoneQueryMemberInfo?.phoneNum ?? ""}", style: TextStyle( color: Color(0xFF1A1A1A), fontSize: 14.sp, fontWeight: MyFontWeight.bold, ), ), ), Padding( padding: EdgeInsets.only( bottom: 18.h, left: 14.w, right: 14.w), child: Text( "充值套餐: 充${records[selectIndex]?.rechargeMoney ?? ""}送${records[selectIndex]?.giftdMoney ?? ""}", style: TextStyle( color: Color(0xFF1A1A1A), fontSize: 14.sp, fontWeight: MyFontWeight.bold, ), ), ), ], ), Container( width: double.infinity, height: 1.h, color: Color(0xFFD8D8D8), ), Container( height: 55.h, child: Row( children: [ Expanded( child: InkWell( child: BorderText( text: S.of(context).quxiao, textColor: Colors.black, fontSize: 16.sp, fontWeight: FontWeight.bold, padding: EdgeInsets.all(14), ), onTap: () { Navigator.of(context).pop(); }, ), flex: 1, ), Container( width: 1.w, height: double.infinity, color: Color(0xFFD8D8D8), ), Expanded( child: InkWell( child: RoundButton( text: S.of(context).queren, textColor: Color(0xFF30415B), radius: 4, padding: EdgeInsets.all(14), fontSize: 16.sp, fontWeight: FontWeight.bold, ), onTap: () { Navigator.of(context).pop(); if (payIndex == 1) { payMemberType( null, phoneQueryMemberInfo?.sid ?? "", records[selectIndex]?.id ?? "", payIndex); } else { Navigator.of(context).pushNamed( '/router/scan_code_page', arguments: { "storeId": widget.arguments["storeId"], "scanCodeType": "支付", "rechargePreferentialId": records[selectIndex]?.id ?? "", "memberSourceId": phoneQueryMemberInfo?.sid ?? "", "source": payIndex.toString(), "rechargeMoney": records[selectIndex]?.rechargeMoney ?? "" }).then((value) { if (value == 1) { queryMemberPhoneInfo( vipPhoneController?.text ?? "", isShow: false); } else { manualQueryInfo = value; showPayQueryDialog( manualQueryInfo[0], manualQueryInfo[1]); } }); } }, ), flex: 1, ), ], ), ) ], ), ), ); }, ); } ///手动查询弹窗 showPayQueryDialog(String queryDialog, String rechargeOrderId) { showDialog( context: context, barrierDismissible: false, builder: (context) { return AlertDialog( contentPadding: EdgeInsets.all(0), content: Container( width: MediaQuery.of(context).size.width - 80, child: Column( mainAxisAlignment: MainAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.center, mainAxisSize: MainAxisSize.min, children: [ GestureDetector( behavior: HitTestBehavior.opaque, onTap: () { Navigator.of(context).pop(); }, child: Container( alignment: Alignment.topRight, padding: EdgeInsets.symmetric(horizontal: 5.w, vertical: 10.h), child: Image.asset( "assets/image/cancel.webp", width: 24.h, height: 24.h, )), ), Padding( padding: EdgeInsets.only(bottom: 20.h, left: 14.w, right: 14.w), child: Text( queryDialog, style: TextStyle( color: Colors.black, fontSize: 16.sp, fontWeight: MyFontWeight.bold, ), ), ), Padding( padding: EdgeInsets.only(bottom: 20.h, left: 14.w, right: 14.w), child: Text.rich( TextSpan( children: [ TextSpan( text: "*", style: TextStyle( color: Color(0xFFFA5151), fontSize: 14.sp, fontWeight: FontWeight.w500, ), ), TextSpan( text: "请确认用户支付成功后再点击手动查询", style: TextStyle( color: Color(0xFFFA5151), fontSize: 14.sp, fontWeight: MyFontWeight.regular, ), ), TextSpan( text: "*", style: TextStyle( color: Color(0xFFFA5151), fontSize: 14.sp, fontWeight: FontWeight.w500, ), ), TextSpan( text: "\n*", style: TextStyle( color: Colors.blue, fontSize: 14.sp, fontWeight: FontWeight.w500, ), ), TextSpan( text: "订单查询成功后可关闭当前弹窗", style: TextStyle( color: Colors.blue, fontSize: 14.sp, fontWeight: MyFontWeight.regular, ), ), TextSpan( text: "*", style: TextStyle( color: Colors.blue, fontSize: 14.sp, fontWeight: FontWeight.w500, ), ), ], ), ), ), GestureDetector( behavior: HitTestBehavior.opaque, onTap: () { manualQueryRechargeOrder(rechargeOrderId); }, child: Container( decoration: BoxDecoration( color: Color(0xFF30415B), borderRadius: BorderRadius.circular(4), ), padding: EdgeInsets.symmetric( horizontal: 26.w, vertical: 10.h), margin: EdgeInsets.only(right: 8.w, bottom: 20.h), child: Text( "手动查询", style: TextStyle( fontSize: 12.sp, fontWeight: MyFontWeight.regular, color: Colors.white, ), ), )), ], ), ), ); }, ); } Widget rechargeList() { return Container( margin: EdgeInsets.only(left: 16.w, right: 16.w, bottom: 16.h), child: (records != null && (records?.length ?? 0) > 0) ? ListView.builder( padding: EdgeInsets.zero, itemCount: records.length ?? 0, scrollDirection: Axis.vertical, shrinkWrap: true, physics: BouncingScrollPhysics(), itemBuilder: (context, position) { return GestureDetector( onTap: () { setState(() { selectIndex = position; }); }, child: rechargeItem(records[position], position)); }, ) : NoDataView( src: "assets/image/xiao_fei.webp", isShowBtn: false, text: "暂无充值套餐~", fontSize: 16.sp, margin: EdgeInsets.only(top: 90.h, left: 60.w, right: 60.w), )); } Widget rechargeItem(Records records, index) { return Stack( alignment: Alignment.topRight, children: [ Container( width: double.infinity, height: 69.h, decoration: BoxDecoration( borderRadius: BorderRadius.circular(8), border: Border.all( color: selectIndex == index ? Color(0xFF30415B) : Color(0x29C5C5C5), width: 2, ), color: selectIndex == index ? Color(0XFFEBF3FF) : Color(0xFFF9FAF8)), margin: EdgeInsets.only(bottom: 14.w), padding: EdgeInsets.only(left: 16), child: Flex( direction: Axis.horizontal, children: [ Expanded( flex: 2, child: Container( child: Text.rich( TextSpan(children: [ TextSpan( text: "储值 ", style: TextStyle( fontSize: 12.sp, color: selectIndex == index ? Color(0xFF4D4D4D) : Color(0xFF868686), fontWeight: MyFontWeight.regular), ), TextSpan( text: records?.rechargeMoney ?? "0", style: TextStyle( fontSize: 18.sp, fontFamily: 'JDZhengHT', color: selectIndex == index ? Color(0xFF353535) : Color(0xFF302F3A), fontWeight: MyFontWeight.medium), ), TextSpan( text: "元", style: TextStyle( fontSize: 18.sp, fontFamily: 'JDZhengHT', color: selectIndex == index ? Color(0xFF353535) : Color(0xFF302F3A), fontWeight: MyFontWeight.semi_bold), ), ]), ), )), Container( width: 1.w, height: 37.h, color: selectIndex == index ? Color(0xFF302F3A) : Color(0xFF979797), margin: EdgeInsets.only(right: 16.w, left: 12), ), Expanded( flex: 3, child: Text.rich( TextSpan(children: [ TextSpan( text: "赠送 ", style: TextStyle( fontSize: 12.sp, color: selectIndex == index ? Color(0xFF353535) : Color(0xFF868686), fontWeight: MyFontWeight.regular), ), TextSpan( text: records?.giftdMoney ?? "0", style: TextStyle( fontSize: 18.sp, fontFamily: 'JDZhengHT', color: selectIndex == index ? Color(0xFF353535) : Color(0xFF302F3A), fontWeight: MyFontWeight.medium), ), TextSpan( text: "元", style: TextStyle( fontSize: 18.sp, fontFamily: 'JDZhengHT', color: selectIndex == index ? Color(0xFF353535) : Color(0xFF302F3A), fontWeight: MyFontWeight.semi_bold), ), ]), ), ) ], ), ), if (selectIndex == index) Image.asset( "assets/image/bus_vip_j.webp", width: 32.h, height: 32.h, fit: BoxFit.fill, ), ], ); } Widget vipRechargeSm() { return Container( margin: EdgeInsets.symmetric(horizontal: 16.w), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ ///会员搜索框 Shimmer.fromColors( baseColor: Color(0XFFD8D8D8), highlightColor: Color(0XFFD8D8D8), child: Container( margin: EdgeInsets.only(top:8.h,bottom:16.h), decoration: BoxDecoration( color: Color(0XFFD8D8D8), borderRadius: BorderRadius.circular(2), ), width:double.infinity, height: 51.h, ), ), ///会员信息 Container( width: double.infinity, decoration: BoxDecoration( color: Colors.white, boxShadow: [ BoxShadow( color: Color(0x0F06152E), offset: Offset(0, 2), blurRadius: 4, spreadRadius: 0, ) ], borderRadius: BorderRadius.circular(8), ), padding: EdgeInsets.only(top: 16.h, bottom: 16.h, left: 16.w), margin: EdgeInsets.only(bottom: 16.h), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Row( children: [ Shimmer.fromColors( baseColor: Color(0XFFD8D8D8), highlightColor: Color(0XFFD8D8D8), child: Container( margin: EdgeInsets.only(right:10.w), decoration: BoxDecoration( color: Color(0XFFD8D8D8), borderRadius: BorderRadius.circular(2), ), width:70.w, height: 17.h, ), ), Shimmer.fromColors( baseColor: Color(0XFFD8D8D8), highlightColor: Color(0XFFD8D8D8), child: Container( margin: EdgeInsets.only(right:10.w), decoration: BoxDecoration( color: Color(0XFFD8D8D8), borderRadius: BorderRadius.circular(2), ), width:43.w, height: 17.h, ), ), ], ), SizedBox(height: 16.h,), Row( children: [ Shimmer.fromColors( baseColor: Color(0XFFD8D8D8), highlightColor: Color(0XFFD8D8D8), child: Container( margin: EdgeInsets.only(right:10.w), decoration: BoxDecoration( color: Color(0XFFD8D8D8), borderRadius: BorderRadius.circular(2), ), width:56.w, height: 17.h, ), ), Shimmer.fromColors( baseColor: Color(0XFFD8D8D8), highlightColor: Color(0XFFD8D8D8), child: Container( margin: EdgeInsets.only(right:10.w), decoration: BoxDecoration( color: Color(0XFFD8D8D8), borderRadius: BorderRadius.circular(2), ), width:85.w, height: 17.h, ), ), ], ), SizedBox(height: 16.h,), Row( children: [ Shimmer.fromColors( baseColor: Color(0XFFD8D8D8), highlightColor: Color(0XFFD8D8D8), child: Container( margin: EdgeInsets.only(right:10.w), decoration: BoxDecoration( color: Color(0XFFD8D8D8), borderRadius: BorderRadius.circular(2), ), width:70.w, height: 17.h, ), ), Shimmer.fromColors( baseColor: Color(0XFFD8D8D8), highlightColor: Color(0XFFD8D8D8), child: Container( margin: EdgeInsets.only(right:10.w), decoration: BoxDecoration( color: Color(0XFFD8D8D8), borderRadius: BorderRadius.circular(2), ), width:77.w, height: 17.h, ), ), ], ), ], )), ///充值列表 ListView.builder( padding: EdgeInsets.zero, itemCount: 3, scrollDirection: Axis.vertical, shrinkWrap: true, physics: BouncingScrollPhysics(), itemBuilder: (context, position) { return rechargeItemSm(); }, ), ///选择充值的套餐 Container( decoration: BoxDecoration( color: Colors.white, boxShadow: [ BoxShadow( color: Color(0x0F06152E), offset: Offset(0, 2), blurRadius: 4, spreadRadius: 0, ) ], borderRadius: BorderRadius.circular(8), ), padding: EdgeInsets.all(16), margin: EdgeInsets.only( bottom: 24.h, ), child: Column( children: [ Row( children: [ Shimmer.fromColors( baseColor: Color(0XFFD8D8D8), highlightColor: Color(0XFFD8D8D8), child: Container( decoration: BoxDecoration( color: Color(0XFFD8D8D8), borderRadius: BorderRadius.circular(2), ), width:89.w, height: 17.h, ), ), Spacer(), Shimmer.fromColors( baseColor: Color(0XFFD8D8D8), highlightColor: Color(0XFFD8D8D8), child: Container( decoration: BoxDecoration( color: Color(0XFFD8D8D8), borderRadius: BorderRadius.circular(2), ), width:26.w, height: 17.h, ), ), ], ), Container( width: double.infinity, height: 1.h, color: Color(0xFFEBECEF), margin: EdgeInsets.symmetric(vertical: 16.h), ), Row( children: [ Shimmer.fromColors( baseColor: Color(0XFFD8D8D8), highlightColor: Color(0XFFD8D8D8), child: Container( decoration: BoxDecoration( color: Color(0XFFD8D8D8), borderRadius: BorderRadius.circular(2), ), width:89.w, height: 17.h, ), ), Spacer(), Shimmer.fromColors( baseColor: Color(0XFFD8D8D8), highlightColor: Color(0XFFD8D8D8), child: Container( decoration: BoxDecoration( color: Color(0XFFD8D8D8), borderRadius: BorderRadius.circular(2), ), width:26.w, height: 17.h, ), ), ], ), ], ), ), ///充值方式 Shimmer.fromColors( baseColor: Color(0XFFD8D8D8), highlightColor: Color(0XFFD8D8D8), child: Container( margin: EdgeInsets.only(left: 16.w, bottom: 16.h), decoration: BoxDecoration( color: Color(0XFFD8D8D8), borderRadius: BorderRadius.circular(2), ), width:60.w, height: 21.h, ), ), Row( children: [ Expanded(child:Container( width: double.infinity, decoration: BoxDecoration( color: Colors.white, boxShadow: [ BoxShadow( color: Color(0x0F06152E), offset: Offset(0, 2), blurRadius: 4, spreadRadius: 0, ) ], borderRadius: BorderRadius.circular(8), ), padding: EdgeInsets.only(top: 16.h, bottom: 16.h, left: 16.w), margin: EdgeInsets.only(right: 16.w), child: Column( crossAxisAlignment: CrossAxisAlignment.center, children: [ Shimmer.fromColors( baseColor: Color(0XFFD8D8D8), highlightColor: Color(0XFFD8D8D8), child: Container( margin: EdgeInsets.only(bottom:15.h), decoration: BoxDecoration( color: Color(0XFFD8D8D8), borderRadius: BorderRadius.circular(2), ), width:45.w, height: 32.h, ), ), Shimmer.fromColors( baseColor: Color(0XFFD8D8D8), highlightColor: Color(0XFFD8D8D8), child: Container( decoration: BoxDecoration( color: Color(0XFFD8D8D8), borderRadius: BorderRadius.circular(2), ), width:56.w, height: 17.h, ), ), ], ))), Expanded(child:Container( width: double.infinity, decoration: BoxDecoration( color: Colors.white, boxShadow: [ BoxShadow( color: Color(0x0F06152E), offset: Offset(0, 2), blurRadius: 4, spreadRadius: 0, ) ], borderRadius: BorderRadius.circular(8), ), padding: EdgeInsets.only(top: 16.h, bottom: 16.h, left: 16.w), margin: EdgeInsets.only(right: 16.w), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Shimmer.fromColors( baseColor: Color(0XFFD8D8D8), highlightColor: Color(0XFFD8D8D8), child: Container( margin: EdgeInsets.only(bottom:15.h), decoration: BoxDecoration( color: Color(0XFFD8D8D8), borderRadius: BorderRadius.circular(2), ), width:45.w, height: 32.h, ), ), Shimmer.fromColors( baseColor: Color(0XFFD8D8D8), highlightColor: Color(0XFFD8D8D8), child: Container( decoration: BoxDecoration( color: Color(0XFFD8D8D8), borderRadius: BorderRadius.circular(2), ), width:56.w, height: 17.h, ), ), ], ))), Expanded(child:Container( width: double.infinity, decoration: BoxDecoration( color: Colors.white, boxShadow: [ BoxShadow( color: Color(0x0F06152E), offset: Offset(0, 2), blurRadius: 4, spreadRadius: 0, ) ], borderRadius: BorderRadius.circular(8), ), padding: EdgeInsets.only(top: 16.h, bottom: 16.h, left: 16.w), margin: EdgeInsets.only(right: 16.w), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Shimmer.fromColors( baseColor: Color(0XFFD8D8D8), highlightColor: Color(0XFFD8D8D8), child: Container( margin: EdgeInsets.only(bottom:15.h), decoration: BoxDecoration( color: Color(0XFFD8D8D8), borderRadius: BorderRadius.circular(2), ), width:45.w, height: 32.h, ), ), Shimmer.fromColors( baseColor: Color(0XFFD8D8D8), highlightColor: Color(0XFFD8D8D8), child: Container( decoration: BoxDecoration( color: Color(0XFFD8D8D8), borderRadius: BorderRadius.circular(2), ), width:56.w, height: 17.h, ), ), ], ))), ], ) , ///确认充值 Align( alignment: Alignment.bottomCenter, child: Shimmer.fromColors( baseColor: Color(0XFFD8D8D8), highlightColor: Color(0XFFD8D8D8), child: Container( margin: EdgeInsets.only(bottom: 16.h,top: 30.h), decoration: BoxDecoration( color: Color(0XFFD8D8D8), borderRadius: BorderRadius.circular(27), ), width:double.infinity, height: 54.h, ), ),) ], ), ); } Widget rechargeItemSm() { return Container( width: double.infinity, height: 69.h, color: Colors.white, margin: EdgeInsets.only(bottom: 14.w), padding: EdgeInsets.only(left: 16), child: Flex( direction: Axis.horizontal, children: [ Expanded( flex: 2, child: Row( children: [ Shimmer.fromColors( baseColor: Color(0XFFD8D8D8), highlightColor: Color(0XFFD8D8D8), child: Container( margin: EdgeInsets.only(right:10.w), decoration: BoxDecoration( color: Color(0XFFD8D8D8), borderRadius: BorderRadius.circular(2), ), width:25.w, height: 15.h, ), ), Row( children: [ Shimmer.fromColors( baseColor: Color(0XFFD8D8D8), highlightColor: Color(0XFFD8D8D8), child: Container( margin: EdgeInsets.only(right:10.w), decoration: BoxDecoration( color: Color(0XFFD8D8D8), borderRadius: BorderRadius.circular(2), ), width:50.w, height: 25.h, ), ), ], ) ], )), Container( width: 1.w, height: 37.h, color: Color(0xFF979797), margin: EdgeInsets.only(right: 16.w, left: 12), ), Expanded( flex: 3, child: Row( children: [ Shimmer.fromColors( baseColor: Color(0XFFD8D8D8), highlightColor: Color(0XFFD8D8D8), child: Container( margin: EdgeInsets.only(right:10.w), decoration: BoxDecoration( color: Color(0XFFD8D8D8), borderRadius: BorderRadius.circular(2), ), width:25.w, height: 15.h, ), ), Row( children: [ Shimmer.fromColors( baseColor: Color(0XFFD8D8D8), highlightColor: Color(0XFFD8D8D8), child: Container( margin: EdgeInsets.only(right:10.w), decoration: BoxDecoration( color: Color(0XFFD8D8D8), borderRadius: BorderRadius.circular(2), ), width:60.w, height: 25.h, ), ), ], ) ], ), ) ], ), ); } Widget noNetwork() { return Container( child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ Text( // "无法连接到网络", networkError.substring(0, networkError.indexOf(",")), style: TextStyle( fontSize: 14.sp, color: Color(0xFF0D0D0D), fontWeight: MyFontWeight.bold), ), Padding( padding: EdgeInsets.symmetric(vertical: 10.h), child: Text( "请检查网络设置或稍后重试", style: TextStyle( fontSize: 12.sp, color: Color(0xFF7A797F), fontWeight: MyFontWeight.regular), ), ), GestureDetector( behavior: HitTestBehavior.opaque, onTap: () { _onRefresh(); }, child: Container( decoration: BoxDecoration( color: Color(0xFF30415B), borderRadius: BorderRadius.circular(15), ), padding: EdgeInsets.symmetric(horizontal: 12.w, vertical: 3.h), child: Text( "重试", style: TextStyle( fontSize: 14.sp, color: Colors.white, fontWeight: MyFontWeight.regular), )), ) ], ), ); } }