From e1491699ad4dd143d9cf5dd494a1899c02da3ea4 Mon Sep 17 00:00:00 2001 From: wurong <953969641@qq.com> Date: Mon, 15 Jul 2024 11:36:04 +0800 Subject: [PATCH] =?UTF-8?q?PayMethod=20=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../settlement_view/pay_method.dart | 473 ++++++++++-------- 1 file changed, 264 insertions(+), 209 deletions(-) diff --git a/lib/settlement/settlement_view/pay_method.dart b/lib/settlement/settlement_view/pay_method.dart index 20f7ff74..bda99c7e 100644 --- a/lib/settlement/settlement_view/pay_method.dart +++ b/lib/settlement/settlement_view/pay_method.dart @@ -1,15 +1,12 @@ import 'dart:convert'; import 'package:flutter/material.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; -import 'package:flutter_smart_dialog/flutter_smart_dialog.dart'; import 'package:huixiang/data/min_order_info.dart'; import 'package:huixiang/data/settle_order_info.dart'; import 'package:huixiang/generated/l10n.dart'; import 'package:huixiang/utils/font_weight.dart'; import 'package:shared_preferences/shared_preferences.dart'; -import '../../view_widget/settlement_tips_dialog.dart'; - class PayMethod extends StatefulWidget { final Function(int payChannel) payChannelCheck; final String coupons; @@ -92,232 +89,277 @@ class _PayMethod extends State { ), ), ), - if(widget.tableId > 0 ? !(widget.minOrderInfo?.isRaise ?? false) : !(widget.settleOrderInfo?.isRaise ?? false)) - GestureDetector( - behavior: HitTestBehavior.opaque, - onTap: () { - setState(() { - checkIndex = 1; - }); - widget.payChannelCheck(4); - }, - child: Row( - mainAxisAlignment: MainAxisAlignment.center, - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - checkView(1), - Expanded( - child: Container(), - flex: 1, - ), - Text( - "¥$money", - style: TextStyle( - fontSize: 14.sp, - fontFamily: 'JDZhengHT', - color: Color(0xff353535), - fontWeight: MyFontWeight.medium, + if(widget.tableId > 0 ? !(widget?.minOrderInfo?.isRaise ?? false) : !(widget?.settleOrderInfo?.isRaise ?? false)) + GestureDetector( + behavior: HitTestBehavior.opaque, + onTap: () { + double m = double.parse(money); + if (m == null) { + m = 0; + } + double orderSum = double.parse(widget.settleOrderInfo?.orderSum ?? '0'); + if (orderSum == null) { + orderSum = 0; + } + if (orderSum > m) { + return; + } + setState(() { + checkIndex = 1; + }); + widget.payChannelCheck(4); + }, + child: Row( + mainAxisAlignment: MainAxisAlignment.center, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + checkView(1, isHide: (double.parse(widget.settleOrderInfo?.orderSum ?? '0') ?? 0) > (double.parse(money) ?? 0)), + Expanded( + child: Container(), + flex: 1, ), - ), - SizedBox( - width: 10, - ), - Text( - S.of(context).huixiangqianbao, - style: TextStyle( - fontSize: 14.sp, - color: Color(0xff353535), - fontWeight: MyFontWeight.semi_bold, + Text( + "¥$money", + style: TextStyle( + fontSize: 14.sp, + fontFamily: 'JDZhengHT', + color: (double.parse(widget.settleOrderInfo?.orderSum ?? '0') ?? 0) > (double.parse(money) ?? 0) ? Color(0x66353535) : Color(0xff353535), + fontWeight: MyFontWeight.medium, + ), ), - ), - ], - ), - ), - if(widget.tableId > 0 ? !(widget.minOrderInfo?.isRaise ?? false) : !(widget.settleOrderInfo?.isRaise ?? false)) - SizedBox( - height: 10, - ), - if(widget.tableId > 0 ? !(widget.minOrderInfo?.isRaise ?? false) : !(widget.settleOrderInfo?.isRaise ?? false)) - GestureDetector( - behavior: HitTestBehavior.opaque, - onTap: () { - setState(() { - checkIndex = 2; - }); - widget.payChannelCheck(3); - }, - child: Row( - mainAxisAlignment: MainAxisAlignment.center, - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - checkView(2), - Expanded( - child: Container(), - flex: 1, - ), - Text( - "¥$balance", - style: TextStyle( - fontSize: 14.sp, - fontFamily: 'JDZhengHT', - color: Color(0xff353535), - fontWeight: MyFontWeight.medium, + SizedBox( + width: 10, ), - ), - SizedBox( - width: 10, - ), - Text( - S.of(context).mendianyue, - style: TextStyle( - fontSize: 14.sp, - color: Color(0xff353535), - fontWeight: MyFontWeight.semi_bold, + Text( + S.of(context).huixiangqianbao, + style: TextStyle( + fontSize: 14.sp, + color: (double.parse(widget.settleOrderInfo?.orderSum ?? '0') ?? 0) > (double.parse(money) ?? 0) ? Color(0x66353535) : Color(0xff353535), + fontWeight: MyFontWeight.semi_bold, + ), ), - ), - ], + ], + ), ), - ), - if(widget.tableId > 0 ? !(widget.minOrderInfo?.isRaise ?? false) : !(widget.settleOrderInfo?.isRaise ?? false)) - SizedBox( - height: 10, - ), - if(mGreenMoney!="0.00" && (widget.tableId > 0 ? !(widget.minOrderInfo?.isRaise ?? false) : !(widget.settleOrderInfo?.isRaise ?? false))) - GestureDetector( - behavior: HitTestBehavior.opaque, - onTap: () { - setState(() { - checkIndex = 3; - if(widget.promotions != "" || widget.coupons != "" || widget.useVipPriceSelect || widget.useBenefitSelect){ - SmartDialog.show( - widget: SettlementTips( - () { - }, - text: "绿币支付不参与任何活动优惠,请重新选择支付方式", - )); + if(widget.tableId > 0 ? !(widget?.minOrderInfo?.isRaise ?? false) : !(widget?.settleOrderInfo?.isRaise ?? false)) + SizedBox( + height: 10, + ), + if(widget.tableId > 0 ? !(widget?.minOrderInfo?.isRaise ?? false) : !(widget?.settleOrderInfo?.isRaise ?? false)) + GestureDetector( + behavior: HitTestBehavior.opaque, + onTap: () { + double balanceMoney = double.parse(balance); + if (balanceMoney == null) { + balanceMoney = 0; + } + double orderSum = double.parse(widget.settleOrderInfo?.orderSum ?? '0'); + if (orderSum == null) { + orderSum = 0; + } + if (orderSum > balanceMoney) { return; } - }); - widget.payChannelCheck(5); - }, - child: Row( - mainAxisAlignment: MainAxisAlignment.center, - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - checkView(3), - Expanded( - child: Container(), - flex: 1, - ), - Text( - "¥$mGreenMoney", - style: TextStyle( - fontSize: 14.sp, - fontFamily: 'JDZhengHT', - color: Color(0xff353535), - fontWeight: MyFontWeight.medium, + setState(() { + checkIndex = 2; + }); + widget.payChannelCheck(3); + }, + child: Row( + mainAxisAlignment: MainAxisAlignment.center, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + checkView(2, isHide: (double.parse(widget.settleOrderInfo?.orderSum ?? '0') ?? 0) > (double.parse(balance) ?? 0)), + Expanded( + child: Container(), + flex: 1, ), - ), - SizedBox( - width: 10, - ), - Text( - S.of(context).lvbizhifu, - style: TextStyle( - fontSize: 14.sp, - color: Color(0xff353535), - fontWeight: MyFontWeight.semi_bold, + Text( + "¥$balance", + style: TextStyle( + fontSize: 14.sp, + fontFamily: 'JDZhengHT', + color: (double.parse(widget.settleOrderInfo?.orderSum ?? '0') ?? 0) > (double.parse(balance) ?? 0) ? Color(0x66353535) : Color(0xff353535), + fontWeight: MyFontWeight.medium, + ), ), - ), - ], + SizedBox( + width: 10, + ), + Text( + S.of(context).mendianyue, + style: TextStyle( + fontSize: 14.sp, + color: (double.parse(widget.settleOrderInfo?.orderSum ?? '0') ?? 0) > (double.parse(balance) ?? 0) ? Color(0x66353535) : Color(0xff353535), + fontWeight: MyFontWeight.semi_bold, + ), + ), + ], + ), ), - ), - if(mGreenMoney!="0.00" && (widget.tableId > 0 ? !(widget.minOrderInfo?.isRaise ?? false) : !(widget.settleOrderInfo?.isRaise ?? false))) - SizedBox( - height: 10, - ), - if(mRaiseMoney!="0" && (widget.tableId > 0? (widget.minOrderInfo?.isRaise ?? false) : (widget.settleOrderInfo?.isRaise ?? false))) - GestureDetector( - behavior: HitTestBehavior.opaque, - onTap: () { - setState(() { - checkIndex = 4; - if(widget.promotions != "" || widget.coupons != "" || widget.useVipPriceSelect || widget.useBenefitSelect){ - SmartDialog.show( - widget: SettlementTips( - () { - }, - text: "助农积分不参与任何活动优惠,请重新选择支付方式", - )); + if(widget.tableId > 0 ? !(widget?.minOrderInfo?.isRaise ?? false) : !(widget?.settleOrderInfo?.isRaise ?? false)) + SizedBox( + height: 10, + ), + if(mGreenMoney!="0.00" && (widget.tableId > 0 ? !(widget?.minOrderInfo?.isRaise ?? false) : !(widget?.settleOrderInfo?.isRaise ?? false))) + GestureDetector( + behavior: HitTestBehavior.opaque, + onTap: () { + double greenMoney = double.parse(mGreenMoney); + if (greenMoney == null) { + greenMoney = 0; + } + double orderSum = double.parse(widget.settleOrderInfo?.orderSum ?? '0'); + if (orderSum == null) { + orderSum = 0; + } + if (orderSum > greenMoney) { return; } - }); - widget.payChannelCheck(7); - }, - child: Row( - mainAxisAlignment: MainAxisAlignment.center, - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - checkView(4), - Expanded( - child: Container(), - flex: 1, - ), - Text( - "¥$mRaiseMoney", - style: TextStyle( - fontSize: 14.sp, - fontFamily: 'JDZhengHT', - color: Color(0xff353535), - fontWeight: MyFontWeight.medium, + setState(() { + checkIndex = 3; + // if(widget.promotions != "" || widget.coupons != "" || widget.useVipPriceSelect || widget.useBenefitSelect){ + // print("discount-promotions: ${widget.promotions}"); + // print("discount-coupons: ${widget.coupons}"); + // print("discount-useVipPriceSelect: ${widget.useVipPriceSelect}"); + // print("discount-useBenefitSelect: ${widget.useBenefitSelect}"); + // SmartDialog.show( + // widget: SettlementTips( + // () { + // }, + // text: "绿币支付不参与任何活动优惠,请重新选择支付方式", + // )); + // return; + // } + }); + print("discount-payChannelCheck: 5"); + widget.payChannelCheck(5); + }, + child: Row( + mainAxisAlignment: MainAxisAlignment.center, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + checkView(3, isHide: (double.parse(widget.settleOrderInfo?.orderSum ?? '0') ?? 0) > (double.parse(mGreenMoney) ?? 0)), + Spacer(flex: 1,), + Text( + "¥$mGreenMoney", + style: TextStyle( + fontSize: 14.sp, + fontFamily: 'JDZhengHT', + color: (double.parse(widget.settleOrderInfo?.orderSum ?? '0') ?? 0) > (double.parse(mGreenMoney) ?? 0) ? Color(0x66353535) : Color(0xff353535), + fontWeight: MyFontWeight.medium, + ), ), - ), - SizedBox( - width: 10, - ), - Text( - S.of(context).zhunongjifen, - style: TextStyle( - fontSize: 14.sp, - color: Color(0xff353535), - fontWeight: MyFontWeight.semi_bold, + SizedBox( + width: 10, ), - ), - ], + Text( + S.of(context).lvbizhifu, + style: TextStyle( + fontSize: 14.sp, + color: (double.parse(widget.settleOrderInfo?.orderSum ?? '0') ?? 0) > (double.parse(mGreenMoney) ?? 0) ? Color(0x66353535) : Color(0xff353535), + fontWeight: MyFontWeight.semi_bold, + ), + ), + ], + ), ), - ), - if(mRaiseMoney !="0" && (widget.tableId > 0 ? !(widget.minOrderInfo?.isRaise ?? false) : !(widget.settleOrderInfo?.isRaise ?? false))) - - if(widget.tableId > 0 ? !(widget.minOrderInfo?.isRaise ?? false) : !(widget.settleOrderInfo?.isRaise ?? false)) - GestureDetector( - behavior: HitTestBehavior.opaque, - onTap: () { - setState(() { - checkIndex = 5; - widget.payChannelCheck(1); - }); - }, - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - checkView(5), - Spacer(), - Image.asset("assets/image/icon_we_chat.webp"), - Padding( - padding: EdgeInsets.only(left: 8.w), - child: Text( - S.of(context).weixinzhifu, + if(mGreenMoney != "0.00" && (widget.tableId > 0 ? !(widget?.minOrderInfo?.isRaise ?? false) : !(widget?.settleOrderInfo?.isRaise ?? false))) + SizedBox( + height: 10, + ), + if(mRaiseMoney != "0" && (widget.tableId > 0 ? (widget?.minOrderInfo?.isRaise ?? false) : (widget?.settleOrderInfo?.isRaise ?? false))) + GestureDetector( + behavior: HitTestBehavior.opaque, + onTap: () { + double raiseMoney = double.parse(mRaiseMoney); + if (raiseMoney == null) { + raiseMoney = 0; + } + double orderSum = double.parse(widget.settleOrderInfo?.orderSum ?? '0'); + if (orderSum == null) { + orderSum = 0; + } + if (orderSum > raiseMoney) { + return; + } + setState(() { + checkIndex = 4; + // if(widget.promotions != "" || widget.coupons != "" || widget.useVipPriceSelect || widget.useBenefitSelect){ + // SmartDialog.show( + // widget: SettlementTips( + // () {}, + // text: "助农积分不参与任何活动优惠,请重新选择支付方式", + // ), + // ); + // return; + // } + }); + widget.payChannelCheck(7); + }, + child: Row( + mainAxisAlignment: MainAxisAlignment.center, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + checkView(4, isHide: (double.parse(widget.settleOrderInfo?.orderSum ?? '0') ?? 0) > (double.parse(mRaiseMoney) ?? 0)), + Spacer( + flex: 1, + ), + Text( + "¥$mRaiseMoney", + style: TextStyle( + fontSize: 14.sp, + fontFamily: 'JDZhengHT', + color: (double.parse(widget.settleOrderInfo?.orderSum ?? '0') ?? 0) > (double.parse(mRaiseMoney) ?? 0) ? Color(0x66353535) : Color(0xff353535), + fontWeight: MyFontWeight.medium, + ), + ), + SizedBox( + width: 10, + ), + Text( + S.of(context).zhunongjifen, style: TextStyle( fontSize: 14.sp, - color: Color(0xff353535), + color: (double.parse(widget.settleOrderInfo?.orderSum ?? '0') ?? 0) > (double.parse(mRaiseMoney) ?? 0) ? Color(0x66353535) : Color(0xff353535), fontWeight: MyFontWeight.semi_bold, ), ), - ), - ], + ], + ), ), - ), + if(mRaiseMoney !="0" && (widget.tableId > 0 ? !(widget?.minOrderInfo?.isRaise ?? false) : !(widget?.settleOrderInfo?.isRaise ?? false))) + + if(widget.tableId > 0 ? !(widget?.minOrderInfo?.isRaise ?? false) : !(widget?.settleOrderInfo?.isRaise ?? false)) + GestureDetector( + behavior: HitTestBehavior.opaque, + onTap: () { + setState(() { + checkIndex = 5; + widget.payChannelCheck(1); + }); + }, + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + checkView(5), + Spacer(), + Image.asset("assets/image/icon_we_chat.webp"), + Padding( + padding: EdgeInsets.only(left: 8.w), + child: Text( + S.of(context).weixinzhifu, + style: TextStyle( + fontSize: 14.sp, + color: Color(0xff353535), + fontWeight: MyFontWeight.semi_bold, + ), + ), + ), + ], + ), + ), ], ), ); @@ -325,7 +367,20 @@ class _PayMethod extends State { var checkIndex = 5; - Widget checkView(var index) { + Widget checkView(var index, {bool isHide = false}) { + + if (isHide) { + return Container( + padding: EdgeInsets.only(right:36.w), + alignment: Alignment.center, + child: Image.asset( + "assets/image/disenable_seletor.png", + width: 15.w, + height: 15.h, + ), + ); + } + return Container( padding: EdgeInsets.only(right:36.w), alignment: Alignment.center,