You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
343 lines
11 KiB
343 lines
11 KiB
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/generated/l10n.dart'; |
|
import 'package:huixiang/utils/font_weight.dart'; |
|
import 'package:shared_preferences/shared_preferences.dart'; |
|
|
|
import '../../retrofit/data/min_order_info.dart'; |
|
import '../../retrofit/data/settleOrderInfo.dart'; |
|
import '../../view_widget/settlement_tips_dialog.dart'; |
|
import '../../view_widget/tips_dialog.dart'; |
|
|
|
class PayMethod extends StatefulWidget { |
|
final Function(int payChannel) payChannelCheck; |
|
final String coupons; |
|
final String promotions; |
|
final bool useVipPriceSelect; |
|
final SettleOrderInfo settleOrderInfo; |
|
final bool useBenefitSelect; |
|
final int tableId; |
|
final MinOrderInfo minOrderInfo; |
|
|
|
PayMethod(this.payChannelCheck,this.coupons,this.promotions,this.useVipPriceSelect,this.settleOrderInfo,this.useBenefitSelect,this.tableId,this.minOrderInfo); |
|
|
|
@override |
|
State<StatefulWidget> createState() { |
|
return _PayMethod(); |
|
} |
|
} |
|
|
|
class _PayMethod extends State<PayMethod> { |
|
String money = "0"; |
|
String balance = "0"; |
|
String mGreenMoney = "0"; |
|
String mRaiseMoney = "0"; |
|
|
|
@override |
|
void initState() { |
|
super.initState(); |
|
checkIndex = ((widget.minOrderInfo != null) ? (widget?.minOrderInfo?.isRaise??false) : (widget?.settleOrderInfo?.isRaise ?? false)) ? 4:5; |
|
SharedPreferences.getInstance().then((value) { |
|
Map<String, dynamic> memberInfo = |
|
jsonDecode(value.getString("minMember")); |
|
balance = memberInfo["balance"]; |
|
money = memberInfo["money"]; |
|
mGreenMoney = memberInfo["greenMoney"]; |
|
mRaiseMoney = memberInfo["raiseMoney"]; |
|
setState(() {}); |
|
}); |
|
} |
|
|
|
@override |
|
Widget build(BuildContext context) { |
|
return Container( |
|
width: double.infinity, |
|
margin: EdgeInsets.only( |
|
left: 16.w, |
|
right: 16.w, |
|
top: 8.h, |
|
bottom: 16.h, |
|
), |
|
padding: EdgeInsets.only( |
|
left: 16.w, |
|
right: 16.w, |
|
top: 20.h, |
|
bottom: 20.h, |
|
), |
|
decoration: BoxDecoration( |
|
boxShadow: [ |
|
BoxShadow( |
|
color: Color(0x000000).withAlpha(25), |
|
offset: Offset(0, 2), |
|
blurRadius: 3, |
|
), |
|
], |
|
color: Colors.white, |
|
borderRadius: BorderRadius.circular(8), |
|
), |
|
child: Column( |
|
mainAxisAlignment: MainAxisAlignment.spaceAround, |
|
crossAxisAlignment: CrossAxisAlignment.start, |
|
children: [ |
|
Padding( |
|
padding: EdgeInsets.only(bottom: 16.h), |
|
child: Text( |
|
S.of(context).zhifufangshi, |
|
style: TextStyle( |
|
fontSize: 16.sp, |
|
color: Colors.black, |
|
fontWeight: MyFontWeight.regular, |
|
), |
|
), |
|
), |
|
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, |
|
), |
|
), |
|
SizedBox( |
|
width: 10, |
|
), |
|
Text( |
|
S.of(context).huixiangqianbao, |
|
style: TextStyle( |
|
fontSize: 14.sp, |
|
color: Color(0xff353535), |
|
fontWeight: MyFontWeight.semi_bold, |
|
), |
|
), |
|
], |
|
), |
|
), |
|
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, |
|
), |
|
Text( |
|
S.of(context).mendianyue, |
|
style: TextStyle( |
|
fontSize: 14.sp, |
|
color: 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: "绿币支付不参与任何活动优惠,请重新选择支付方式", |
|
)); |
|
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, |
|
), |
|
), |
|
SizedBox( |
|
width: 10, |
|
), |
|
Text( |
|
S.of(context).lvbizhifu, |
|
style: TextStyle( |
|
fontSize: 14.sp, |
|
color: 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: "助农积分不参与任何活动优惠,请重新选择支付方式", |
|
)); |
|
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, |
|
), |
|
), |
|
SizedBox( |
|
width: 10, |
|
), |
|
Text( |
|
S.of(context).zhunongjifen, |
|
style: TextStyle( |
|
fontSize: 14.sp, |
|
color: Color(0xff353535), |
|
fontWeight: MyFontWeight.semi_bold, |
|
), |
|
), |
|
], |
|
), |
|
), |
|
if(mRaiseMoney !="0" && (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 = 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, |
|
), |
|
), |
|
), |
|
], |
|
), |
|
), |
|
], |
|
), |
|
); |
|
} |
|
|
|
var checkIndex = 5; |
|
|
|
Widget checkView(var index) { |
|
return Container( |
|
padding: EdgeInsets.only(right:36.w), |
|
alignment: Alignment.center, |
|
child: Image.asset( |
|
checkIndex != index |
|
? "assets/image/icon_radio_unselected.webp" |
|
: "assets/image/icon_radio_selected.webp", |
|
width: 15.w, |
|
height: 15.h, |
|
), |
|
); |
|
} |
|
}
|
|
|