import 'package:dio/dio.dart'; import 'package:flutter/material.dart'; import 'package:flutter_easyloading/flutter_easyloading.dart'; import 'package:flutter_smart_dialog/flutter_smart_dialog.dart'; import 'package:huixiang/utils/font_weight.dart'; import 'package:huixiang/view_widget/my_appbar.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:pull_to_refresh/pull_to_refresh.dart'; import '../../../generated/l10n.dart'; import '../../../retrofit/business_api.dart'; import '../../../retrofit/data/base_data.dart'; import '../../../retrofit/data/phone_query_member_info.dart'; import '../../../utils/business_instance.dart'; import '../../../utils/flutter_utils.dart'; import '../../../view_widget/border_text.dart'; import '../../../view_widget/classic_header.dart'; import '../../../view_widget/custom_image.dart'; import '../../../view_widget/my_footer.dart'; import '../../../view_widget/round_button.dart'; import '../../../view_widget/settlement_tips_dialog.dart'; class CashierPage extends StatefulWidget { final Map arguments; CashierPage({this.arguments}); @override State createState() { return _CashierPage(); } } class _CashierPage extends State { final TextEditingController editingController = TextEditingController(); final RefreshController refreshController = RefreshController(); FocusNode _focusNode = FocusNode(); bool isKeyBoardShow = false; BusinessApiService businessService; String networkError = ""; int networkStatus = 0; PhoneQueryMemberInfo phoneQueryMemberInfo; String cashierOrderId; String _display = ""; double _displayTotal = 0; List manualQueryInfo; bool isDisplayVipInfo = false; ///离开页面记着销毁和清除 @override void dispose() { super.dispose(); refreshController.dispose(); _focusNode.unfocus(); } @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; } }); }); if((widget?.arguments["phone"] ?? "")!= "") queryMemberPhoneInfo(widget?.arguments["phone"] ?? ""); } ///根据手机号搜索用户信息 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; isDisplayVipInfo = true; refreshController.loadComplete(); refreshController.refreshCompleted(); networkStatus = 1; } else { SmartDialog.showToast(baseData.msg, alignment: Alignment.center); refreshController.refreshFailed(); refreshController.loadFailed(); } } finally { if (isShow) EasyLoading.dismiss(); setState(() {}); } } ///收银台创建直付订单 cashierCreateOrder(payChannel) 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.createOrder({ "createOrderType": "DIRECT", // 创建订单类型 DIRECT 直接下单 ASSIGN 指定商品下单 "orderAmount": _displayTotal.toStringAsFixed(2), "virtualProductId": -2, "mid": phoneQueryMemberInfo?.sid ?? "" }).catchError((error) { networkError = AppUtils.dioErrorTypeToString(error.type); networkStatus = -1; setState(() {}); refreshController.refreshFailed(); refreshController.loadFailed(); }); if (!mounted) return; if (baseData != null && baseData.isSuccess) { cashierOrderId = baseData.data; if (payChannel == 1 || payChannel == 2) { Navigator.of(context).pushNamed('/router/scan_code_page', arguments: { "storeId": widget.arguments["storeId"], "scanCodeType": "收银台支付", "mid": phoneQueryMemberInfo?.sid ?? "", "orderId": cashierOrderId, "payChannel": payChannel }).then((value) { if (value == 1) { _display = ""; _displayTotal = 0; } else { manualQueryInfo = value; showPayQueryDialog(manualQueryInfo[0], manualQueryInfo[1]); } }); } else { await cashierPayOrder( cashierOrderId, payChannel, phoneQueryMemberInfo?.sid ?? ""); } networkStatus = 1; setState(() {}); } } finally { EasyLoading.dismiss(); } } ///支付接口 cashierPayOrder(orderId, payChannel, mid) 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.prePayOrder({ "orderId": orderId, "payChannel": payChannel, "mid": mid, "authCode": (payChannel == 1 || payChannel == 2) ? "" : null, }).catchError((error) { networkError = AppUtils.dioErrorTypeToString(error.type); networkStatus = -1; setState(() {}); refreshController.refreshFailed(); refreshController.loadFailed(); }); if (!mounted) return; if (baseData != null && baseData.isSuccess) { _display = ""; _displayTotal = 0; if (phoneQueryMemberInfo != null) await queryMemberPhoneInfo(editingController?.text ?? "", isShow: false); SmartDialog.show( widget: SettlementTips( () {}, text: baseData.data ?? "", color: Color(0xFF30415B), )); networkStatus = 1; setState(() {}); } else { SmartDialog.show( widget: SettlementTips( () {}, text: baseData.msg, color: Color(0xFF30415B), )); } } finally {} } ///手动查询充值订单状态 manualQueryCashierOrder(orderId) 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 .queryCashierOrder(cashierOrderId, true) .catchError((error) {}); if (baseData != null && baseData.isSuccess) { _display = ""; _displayTotal = 0; Navigator.of(context).pop(); SmartDialog.show( widget: SettlementTips( () {}, text: baseData.data ?? "", color: Color(0xFF30415B), )); } 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.opaque, onTap: () { FocusScope.of(context).requestFocus(FocusNode()); }, child: Scaffold( appBar: MyAppBar( title: "收银", titleColor: Colors.black, background: Colors.white, leadingColor: Colors.black, brightness: Brightness.dark, ), body:networkStatus == -1 ? noNetwork() :SmartRefresher( enablePullDown: true, enablePullUp: false, header: MyHeader( color: Color(0xFF30415B), ), footer: CustomFooter( builder: (context, mode) { return MyFooter(mode); }, ), controller: refreshController, onRefresh: () { if (editingController.text != "") queryMemberPhoneInfo(editingController.text ?? "", isShow: false); else { refreshController.loadComplete(); refreshController.refreshCompleted(); } }, physics: BouncingScrollPhysics(), child: SingleChildScrollView( physics: BouncingScrollPhysics(), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ if (isDisplayVipInfo == false) Container( width: double.infinity, padding: EdgeInsets.only(top: 19.h, bottom: 13.h), decoration: BoxDecoration( color: Colors.white, ), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Padding( padding: EdgeInsets.only(left: 16.w), child: Text( "快速收银", style: TextStyle( fontSize: 15.sp, fontWeight: MyFontWeight.bold, color: Color(0xFF0D0D0D), ), ), ), Stack( children: [ Container( width: double.infinity, height: 2.h, margin: EdgeInsets.only(top: 5.h), color: Color(0xFFD8D8D8), ), Container( width: 44.w, height: 1.5.h, margin: EdgeInsets.only(top: 5.h, left: 24.w), color: Color(0xFF30415B), ), ], ), SizedBox( height: 13.h, ), vipUserSearch(), ], ), ), (phoneQueryMemberInfo != null && isDisplayVipInfo == true) ? GestureDetector( onTap:(){ Navigator.of(context).pushNamed( '/router/member_details_page', arguments: { "storeId": widget?.arguments["storeId"] ?? "", "phoneNum":editingController?.text ?? "" }); }, child: vipPlate(), ) : SizedBox(height: 103.h), calculator() ], ), ), ), ), ); } /// 搜索框 Widget vipUserSearch() { return Container( color: Colors.white, child: Container( height: 40.h, margin: EdgeInsets.only(left: 18.w, right: 18.w), decoration: BoxDecoration( color: Color(0xFFF7F8FA), borderRadius: BorderRadius.circular(2), ), child: TextField( focusNode: _focusNode, textInputAction: TextInputAction.search, onEditingComplete: () { FocusScope.of(context).requestFocus(FocusNode()); queryMemberPhoneInfo(editingController.text ?? ""); }, style: TextStyle( fontSize: 15.sp, fontWeight: MyFontWeight.regular, color: Color(0xFF808080), ), controller: editingController, decoration: InputDecoration( hintText: "请输入会员手机号", hintStyle: TextStyle( color: Color(0xFF808080), fontSize: 15.sp, fontWeight: MyFontWeight.regular), contentPadding: EdgeInsets.symmetric( vertical: 12.h, ), prefixIcon: Image.asset( "assets/image/bs_goods_search.webp", width: 20, height: 20, ), border: InputBorder.none, ), ), ), ); } ///会员信息板块 Widget vipPlate() { return Container( width: double.infinity, margin: EdgeInsets.only(top: 12.h, left: 19.w, right: 13.w), padding: EdgeInsets.only(bottom: 15.h), decoration: BoxDecoration( color: Colors.white, boxShadow: [ BoxShadow( color: Color(0x0F06152E), offset: Offset(0, 2), blurRadius: 4, spreadRadius: 0, ) ], borderRadius: BorderRadius.circular(8), ), child: Column( children: [ Container( width: double.infinity, padding: EdgeInsets.only(left: 16.w, bottom: 33.h), margin: EdgeInsets.only(bottom: 10.h), decoration: BoxDecoration( color: Colors.white, gradient: LinearGradient( begin: Alignment.centerLeft, end: Alignment.centerRight, colors: [Color(0xFF30415B), Color(0xFF5171A4)]), borderRadius: BorderRadius.vertical( top: Radius.circular(8), ), ), child: Row( crossAxisAlignment: CrossAxisAlignment.start, children: [ Container( width: 52.h, height: 52.h, margin: EdgeInsets.only(right: 15.w, top: 13.h), decoration: BoxDecoration( borderRadius: BorderRadius.circular(4), ), child:MImage( (phoneQueryMemberInfo?.headimg ?? ""), width: double.infinity, height: double.infinity, fit: BoxFit.cover, errorSrc: "assets/image/default_1.webp", fadeSrc: "assets/image/default_1.webp", ), ), Expanded( child: Container( padding: EdgeInsets.only(top: 13.h), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Padding( padding: EdgeInsets.only(bottom: 8.h), child: Text( "会员名称:${phoneQueryMemberInfo?.nickName ?? ""}", overflow: TextOverflow.ellipsis, maxLines: 2, style: TextStyle( fontSize: 12.sp, fontWeight: MyFontWeight.regular, color: Colors.white, ), )), Text( "手机号:${phoneQueryMemberInfo?.phoneNum ?? ""}", style: TextStyle( fontSize: 12.sp, fontWeight: MyFontWeight.regular, color: Colors.white, ), ) ], ), ), ), Expanded( child: GestureDetector( behavior: HitTestBehavior.opaque, onTap: () { setState(() { isDisplayVipInfo = false; editingController.text = ""; }); }, child: Container( padding: EdgeInsets.only(right: 19.w, top: 13.h, bottom: 13.h), child: Column( children: [ Image.asset( "assets/image/bus_cashier_switch.webp", width: 17.w, height: 15.h, color: Colors.white, fit: BoxFit.fill, ), Padding( padding: EdgeInsets.only(top: 5.h), child: Text( "切换会员", style: TextStyle( fontSize: 10.sp, fontWeight: MyFontWeight.regular, color: Colors.white, ), )) ], )), )) ], ), ), Row( mainAxisAlignment: MainAxisAlignment.center, children: [ Expanded( child: Column( crossAxisAlignment: CrossAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.center, children: [ Padding( padding: EdgeInsets.only(bottom: 7.h), child: Row( mainAxisAlignment: MainAxisAlignment.center, children: [ Image.asset( "assets/image/bus_vip_balance.webp", width: 24.h, height: 24.h, fit: BoxFit.fill, ), Padding( padding: EdgeInsets.only(left: 7.w), child: Text( "会员余额", style: TextStyle( fontSize: 14.sp, fontWeight: MyFontWeight.regular, color: Color(0xFF252626), ), )) ], )), Text( "${double.tryParse(phoneQueryMemberInfo?.balance ?? 0)}", style: TextStyle( fontSize: 14.sp, fontWeight: MyFontWeight.medium, color: Color(0xFF30415B), ), ) ], )), Expanded( child: Column( crossAxisAlignment: CrossAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.center, children: [ Padding( padding: EdgeInsets.only(bottom: 7.h), child: Row( mainAxisAlignment: MainAxisAlignment.center, children: [ Image.asset( "assets/image/bus_coupon.webp", width: 20.w, height: 18.h, fit: BoxFit.fill, ), Padding( padding: EdgeInsets.only(left: 7.w), child: Text( "优惠券", style: TextStyle( fontSize: 14.sp, fontWeight: MyFontWeight.regular, color: Color(0xFF252626), ), )) ], )), Text( (phoneQueryMemberInfo?.useableConponList?.length ?? 0) .toString(), style: TextStyle( fontSize: 14.sp, fontWeight: MyFontWeight.medium, color: Color(0xFF30415B), ), ) ], )), ], ) ], ), ); } ///计算器ui Widget calculator() { return Container( color: Colors.white, margin: EdgeInsets.only(top: isDisplayVipInfo == false ? 15.h : 45.h), alignment: Alignment.bottomCenter, child: Column( crossAxisAlignment: CrossAxisAlignment.end, children: [ Container( padding: EdgeInsets.symmetric( vertical: 6.h, ), margin: EdgeInsets.only(right: 32.w), child: Text( _display, textAlign: TextAlign.end, style: TextStyle( fontSize: 18.sp, fontWeight: MyFontWeight.bold, color: Color(0x4D000000), ), ), ), Container( margin: EdgeInsets.only(right: 30.w), child: Text( _displayTotal.toStringAsFixed(2), style: TextStyle( fontSize: 36.sp, fontWeight: MyFontWeight.bold, color: Colors.black, ), ), ), Container( color: Color(0xFFD8D8D8), width: double.infinity, height: 1.h, ), Row( mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: [ buildButton('7'), buildButton('8'), buildButton('9'), Expanded( flex: 2, child: GestureDetector( onTap: () { setState(() { _display = ""; _displayTotal = 0; }); }, child: Container( alignment: Alignment.center, padding: EdgeInsets.only(top: 23.h, bottom: 18.h), decoration: BoxDecoration( border: Border( right: BorderSide( color: Color(0xFFD8D8D8), width: 1.w, ), ), ), child: Text( "C", style: TextStyle( fontSize: 32.sp, fontWeight: MyFontWeight.bold, color: Color(0xFF30415B), ), ), ), )) ], ), Container( color: Color(0xFFD8D8D8), width: double.infinity, height: 1.h, ), Row( mainAxisAlignment: MainAxisAlignment.spaceEvenly, crossAxisAlignment: CrossAxisAlignment.center, children: [ buildButton('4'), buildButton('5'), buildButton('6'), Expanded( flex: 2, child: GestureDetector( onTap: () => _onPressed("back"), child: Container( alignment: Alignment.center, decoration: BoxDecoration( border: Border( right: BorderSide( color: Color(0xFFD8D8D8), width: 1.w, ), ), ), child: Image.asset( "assets/image/bus_calculator_enter.webp", width: 24.w, height: 16.h, fit: BoxFit.fill, ), ), )) ], ), Container( color: Color(0xFFD8D8D8), width: double.infinity, height: 1.h, ), Row( children: [ Expanded( child: Column( children: [ Row( children: [ buildButton('1'), buildButton('2'), buildButton('3'), ], ), Container( color: Color(0xFFD8D8D8), width: double.infinity, height: 1.h, ), Row( children: [ buildButton('0', flex: 2), buildButton('.'), ], ), ], ), flex: 3, ), Expanded( child: GestureDetector( behavior: HitTestBehavior.opaque, onTap: () => _onPressed("+"), child: Container( alignment: Alignment.center, padding: EdgeInsets.only(top: 23.h, bottom: 18.h), decoration: BoxDecoration(), child: Text( "+", style: TextStyle( fontSize: 32.sp, fontWeight: MyFontWeight.bold, color: Color(0xFF30415B), ), ), ), ), flex: 2, ), ], ), Container( height: 100.h, child: Row( children: [ Expanded( flex: 2, child: Container( alignment: Alignment.center, color: Color(0xFF5A7092), padding: EdgeInsets.only(top: 10.h, bottom: 10.h), child: Text( "¥${_displayTotal.toStringAsFixed(2)}", style: TextStyle( fontSize: 24.sp, fontWeight: MyFontWeight.bold, color: Colors.white, ), ), )), GestureDetector( behavior: HitTestBehavior.opaque, onTap: () { if (_displayTotal.toStringAsFixed(2) == "0.00") { SmartDialog.show( widget: SettlementTips( () {}, text: "订单支付金额小于或等于0,无法进行支付操作", color: Color(0xFF30415B), )); } else { showPaySelectDialog(); } }, child: Container( alignment: Alignment.center, color: Color(0xFF30415B), padding: EdgeInsets.only( top: 10.h, bottom: 10.h, left: 45.w, right: 33.w), child: Text( "结账", style: TextStyle( fontSize: 36.sp, fontWeight: MyFontWeight.bold, color: Colors.white, ), ), )), ], ), ) ], ), ); } ///计算器文本 Widget buildButton(String text, {int flex = 1}) { return Expanded( child: GestureDetector( behavior: HitTestBehavior.opaque, child: Container( alignment: Alignment.center, padding: EdgeInsets.only(top: 23.h, bottom: 18.h), decoration: BoxDecoration( border: Border( right: BorderSide( color: Color(0xFFD8D8D8), width: 1.w, ), ), ), child: Text( text, style: TextStyle( fontSize: 32.sp, fontWeight: MyFontWeight.bold, color: Color(0xD9000000), ), ), ), onTap: () => _onPressed(text), ), flex: flex, ); } ///计算器点击事件的处理 void _onPressed(String button) { setState(() { FocusScope.of(context).requestFocus(FocusNode()); int addIndex = _display.lastIndexOf("+") + 1; String rStr = _display.substring(addIndex); if (button == "+" || button == ".") { if (_display.isEmpty || _display.endsWith(".") || _display.endsWith("+")) { return; } if (button == ".") { if (rStr.contains(".")) return; } } else if (button == "0") { if (rStr == "0") return; } else { if (rStr == "0") { _display = _display.substring(0, _display.length - 1); } } if (button == "back") { // 回删一个数值 if (_display.length > 0) _display = _display.substring(0, _display.length - 1); } else { _display += button; } _displayTotal = 0; var tempNumArr = _display.split("+"); tempNumArr.forEach((element) { _displayTotal += double.parse(element); }); }); } ///支付选项 showPaySelectDialog() { showModalBottomSheet( context: context, backgroundColor: Colors.transparent, builder: (context) { return Container( width: double.infinity, height: phoneQueryMemberInfo != null ? 280.h : 220.h, decoration: BoxDecoration( color: Colors.white, borderRadius: BorderRadius.only( topLeft: Radius.circular(8), topRight: Radius.circular(8), ), ), child: Column( mainAxisAlignment: MainAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start, children: [ Row( mainAxisAlignment: MainAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.center, children: [ Expanded( child: Container( alignment: Alignment.center, margin: EdgeInsets.only(top: 12.h, bottom: 12.h, left: 41.w), child: Text( S.of(context).zhifufangshi, style: TextStyle( fontWeight: MyFontWeight.bold, fontSize: 17.sp, color: Color(0xFF1A1A1A), ), ), )), GestureDetector( onTap: () { setState(() { Navigator.of(context).pop(); }); }, child: Padding( padding: EdgeInsets.only(right: 16.w), child: Image.asset( "assets/image/cancel.webp", width: 25.h, height: 25.h, ), ), ), ], ), Padding( padding: EdgeInsets.only(left: 23.w, right: 9.w), child: Column( children: [ GestureDetector( behavior: HitTestBehavior.opaque, onTap: () { Navigator.of(context).pop(); showPayAmountDialog(0, "现金"); }, child: Padding( padding: EdgeInsets.only(left: 5.w), child: Row( children: [ Image.asset( "assets/image/bus_cashier_xj.webp", width: 31.w, height: 22.h, ), Padding( padding: EdgeInsets.only(left: 14.w), child: Text( "现金支付", textAlign: TextAlign.center, style: TextStyle( color: Color(0xFF1A1A1A), fontSize: 14.sp, fontWeight: MyFontWeight.regular, ), )) ], ), ), ), Container( width: double.infinity, height: 1.h, color: Color(0xFFEBEBEB), margin: EdgeInsets.symmetric(vertical: 13.h), ), GestureDetector( behavior: HitTestBehavior.opaque, onTap: () { Navigator.of(context).pop(); showPayAmountDialog(1, "微信"); }, child: Padding( padding: EdgeInsets.only(left: 5.w), child: Row( children: [ Image.asset( "assets/image/bus_vip_wx.webp", width: 29.w, height: 26.h, ), Padding( padding: EdgeInsets.only(left: 14.w), child: Text( "微信", textAlign: TextAlign.center, style: TextStyle( color: Color(0xFF1A1A1A), fontSize: 14.sp, fontWeight: MyFontWeight.regular, ), )) ], ), )), Container( width: double.infinity, height: 1.h, color: Color(0xFFEBEBEB), margin: EdgeInsets.symmetric(vertical: 13.h), ), GestureDetector( behavior: HitTestBehavior.opaque, onTap: () { Navigator.of(context).pop(); showPayAmountDialog(2, "支付宝"); }, child: Padding( padding: EdgeInsets.only(left: 5.w), child: Row( children: [ Image.asset( "assets/image/bus_vip_alipay.webp", width: 29.h, height: 29.h, ), Padding( padding: EdgeInsets.only(left: 14.w), child: Text( "支付宝", textAlign: TextAlign.center, style: TextStyle( color: Color(0xFF1A1A1A), fontSize: 14.sp, fontWeight: MyFontWeight.regular, ), )) ], ), )), if (phoneQueryMemberInfo != null) Container( width: double.infinity, height: 1.h, color: Color(0xFFEBEBEB), margin: EdgeInsets.symmetric(vertical: 13.h), ), if (phoneQueryMemberInfo != null) GestureDetector( behavior: HitTestBehavior.opaque, onTap: () { Navigator.of(context).pop(); showPayAmountDialog(3, "商户余额"); }, child: Padding( padding: EdgeInsets.only(left: 5.w), child: Row( children: [ Image.asset( "assets/image/bus_cashier_balance.webp", width: 27.h, height: 27.h, ), Padding( padding: EdgeInsets.only(left: 14.w), child: Text( "商户余额", textAlign: TextAlign.center, style: TextStyle( color: Color(0xFF1A1A1A), fontSize: 14.sp, fontWeight: MyFontWeight.regular, ), )) ], ), )), // Container( // width: double.infinity, // height: 1.h, // color: Color(0xFFEBEBEB), // margin: EdgeInsets.symmetric(vertical:13.h), // ), // GestureDetector( // behavior: HitTestBehavior.opaque, // onTap:(){ // Navigator.of(context).pop(); // showPayAmountDialog(4,"平台余额");}, // child: Padding(padding:EdgeInsets.only(left: 5.w), // child: Row( // children: [ // Image.asset( // "assets/image/bus_cashier_pt.webp", // width: 27.h, // height: 27.h, // ), // Padding( // padding: EdgeInsets.only(left: 14.w), // child: Text( // "平台余额", // textAlign: TextAlign.center, // style: TextStyle( // color: Color(0xFF1A1A1A), // fontSize: 14.sp, // fontWeight: MyFontWeight.regular, // ), // )) // ], // ),)), ], ), ) ], ), ); }); } ///确认支付金额提示 showPayAmountDialog(index, payText) { showDialog( context: context, builder: (context) { return AlertDialog( content: Container( width: MediaQuery.of(context).size.width - 84.w, child: Column( mainAxisSize: MainAxisSize.min, mainAxisAlignment: MainAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( "此操作将进行金额支付,请确认支付金额及支付方式是否正确?", style: TextStyle( color: Color(0xFFF4524D), fontSize: 16.sp, fontWeight: MyFontWeight.regular, ), ), SizedBox( height: 15.h, ), Text( "支付方式: ${payText}", style: TextStyle( color: Color(0xFF0D0D0D), fontSize: 16.sp, fontWeight: MyFontWeight.regular, ), ), SizedBox( height: 10.h, ), Text( "支付金额: ${_displayTotal.toStringAsFixed(2)}元", style: TextStyle( color: Color(0xFF0D0D0D), fontSize: 16.sp, fontWeight: MyFontWeight.regular, ), ), SizedBox( height: 35.h, ), Row( children: [ Expanded( child: InkWell( child: BorderText( text: S.of(context).quxiao, textColor: Color(0xFF30415B), fontSize: 16.sp, fontWeight: FontWeight.bold, borderColor: Color(0xFF30415B), radius: 4, padding: EdgeInsets.all(12), borderWidth: 1, ), onTap: () { Navigator.of(context).pop(); }, ), flex: 1, ), SizedBox( width: 16.w, ), Expanded( child: InkWell( child: RoundButton( text: S.of(context).queren, textColor: Colors.white, radius: 4, padding: EdgeInsets.all(12), backgroup: Color(0xFF30415B), fontSize: 16.sp, fontWeight: FontWeight.bold, ), onTap: () { setState(() { Navigator.of(context).pop(); cashierCreateOrder(index); }); }, ), flex: 1, ), ], ) ], ), ), ); }, ); } ///手动查询弹窗 showPayQueryDialog(String queryDialog, String orderId) { 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: () { manualQueryCashierOrder(orderId); }, 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 noNetwork() { return Container( color: Colors.white, width: double.infinity, 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: () { queryMemberPhoneInfo(widget?.arguments["phoneNum"] ?? ""); }, 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), )), ) ], ), ); } }