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.
 
 
 
 
 
 

578 lines
23 KiB

import 'dart:io';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
import 'package:huixiang/generated/l10n.dart';
import 'package:huixiang/retrofit/data/min_order_info.dart';
import 'package:huixiang/retrofit/data/settleOrderInfo.dart';
import 'package:huixiang/utils/font_weight.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import '../../retrofit/data/miNiDetail.dart';
import '../../view_widget/settlement_tips_dialog.dart';
class ActivityCouponRemarks extends StatefulWidget {
final Function() couponCart;
final Function() activityCart;
final Function() editRemark;
final String coupons;
final String promotions;
final SettleOrderInfo settleOrderInfo;
final MinOrderInfo minOrderInfo;
final int couponCount;
final bool placeOrder;
final String remark;
final int tableId;
final Function(bool useVipPriceSelect) vipPriceSelect;
final Function showVipTips;
final Function(bool useBenefitSelect) vipBenefitSelect;
final int payChannell;
final String vipLevelName;
final SubscribeParam subscribeParam;
final Function() showDateSelector;
final String reservationTime;
final Function() showAlertDialog;
final String subscribeStoresName;
ActivityCouponRemarks(
this.couponCart,
this.activityCart,
this.settleOrderInfo,
this.minOrderInfo,
this.coupons,
this.promotions,
this.couponCount,
this.placeOrder,
this.remark,
this.editRemark,
this.tableId,
this.vipPriceSelect,
this.showVipTips,
this.vipBenefitSelect,
this.payChannell,
this.vipLevelName,
this.subscribeParam,
this.showDateSelector,
this.reservationTime,
this.showAlertDialog,
this.subscribeStoresName
);
@override
State<StatefulWidget> createState() {
return _ActivityCouponRemarks();
}
}
class _ActivityCouponRemarks extends State<ActivityCouponRemarks> {
bool vipSelect = true;
bool vipBenefit = true;
@override
Widget build(BuildContext context) {
return Container(
decoration: BoxDecoration(
color: Colors.white,
boxShadow: [
BoxShadow(
color: Color(0x0D000000),
offset: Offset(0, 1),
blurRadius: 8,
spreadRadius: 0,
),
],
borderRadius: BorderRadius.circular(8),
),
// height: 122.h / (!widget.placeOrder ? 2 : 1),
margin: EdgeInsets.only(left: 16.w, right: 16.w, top: 14.h, bottom: 14.h),
padding: EdgeInsets.only(
left: 16.w,
right: 16.w,
top: 14.h,
bottom: 14.h,
),
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
if ((widget.tableId > 0 ? !(widget?.minOrderInfo?.isRaise ?? false) : !(widget?.settleOrderInfo?.isRaise ?? false)) &&
(widget?.settleOrderInfo?.memberVO?.isVip ?? false) &&
widget.placeOrder)
Row(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Expanded(
flex: 1,
child: Text(
"VIP权益",
style: TextStyle(
fontWeight: MyFontWeight.regular,
fontSize: 14.sp,
color: Color(0xFF353535),
),
),
),
Platform.isAndroid
? Switch.adaptive(
value:
(widget.coupons != null && widget.coupons != "" ||
widget.promotions != null &&
widget.promotions != "" ||
widget.payChannell == 5 || widget.payChannell == 7 || ((widget?.settleOrderInfo?.discountType ?? "") == "MEMBER_RANK" || (widget?.settleOrderInfo?.discountType ?? "") == "SURPRISE") )
? false
: vipSelect,
materialTapTargetSize: MaterialTapTargetSize.shrinkWrap,
activeColor: Color(0xff32A060),
onChanged: (bool value) {
setState(() {
if(widget.settleOrderInfo.usePlateMoney == false || widget.payChannell == 5){
SmartDialog.show(
widget: SettlementTips(
() {
},
text: widget.payChannell == 5 ? "该支付余额为特殊活动充值, 不可参与任何活动" :"该用户平台余额为特殊活动充值, 不可参与任何活动",
));
return;
}
if ((widget?.settleOrderInfo?.memberVO?.isVip ??
false)) {
vipSelect = !vipSelect;
widget.vipPriceSelect(vipSelect);
} else {
widget.showVipTips();
return;
}
});
},
)
: GestureDetector(
onTap: () {
setState(() {
if(widget.settleOrderInfo.usePlateMoney == false || widget.payChannell == 5){
SmartDialog.show(
widget: SettlementTips(
() {
},
text: widget.payChannell == 5 ? "该支付余额为特殊活动充值, 不可参与任何活动" :"该用户平台余额为特殊活动充值, 不可参与任何活动",
));
return;
}
if ((widget?.settleOrderInfo?.memberVO?.isVip ??
false)) {
vipSelect = !vipSelect;
widget.vipPriceSelect(vipSelect);
} else {
widget.showVipTips();
return;
}
});
},
child: Container(
padding: EdgeInsets.only(bottom: 18.w),
alignment: Alignment.center,
child: Image.asset(
((widget.coupons != null && widget.coupons != "" ||
widget.promotions != null &&
widget.promotions != "" ||
widget.payChannell == 5 ||
widget.payChannell == 7 ||((widget?.settleOrderInfo?.discountType ?? "") == "MEMBER_RANK" || (widget?.settleOrderInfo?.discountType ?? "") == "SURPRISE")
|| (widget.payChannell == 4 && widget.settleOrderInfo.promotionInfoList.length <=0 && widget.settleOrderInfo.couponList.length <= 0))
? false
: vipSelect)
? "assets/image/vip_price.webp"
: "assets/image/vip_unprice.webp",
width: 38.w,
height: 20.h,
),
),
)
],
),
// if (widget.placeOrder && !(widget?.settleOrderInfo?.isRaise ?? false))
// Container(
// margin: EdgeInsets.only(
// bottom: 13,
// ),
// child: Row(
// mainAxisAlignment: MainAxisAlignment.center,
// crossAxisAlignment: CrossAxisAlignment.center,
// children: [
// Expanded(
// flex: 1,
// child: Text(
// "会员优惠金额",
// style: TextStyle(
// fontWeight: MyFontWeight.regular,
// fontSize: 14.sp,
// color: Color(0xFF353535),
// ),
// ),
// ),
// // Text(
// // "¥${widget.settleOrderInfo.benefitDiscountAmount}",
// // textAlign: TextAlign.end,
// // style: TextStyle(
// // fontSize: 14.sp,
// // color: Color(0xFF32A060),
// // fontFamily: 'JDZhengHT',
// // fontWeight: MyFontWeight.regular,
// // ),
// // ),
// Platform.isAndroid
// ? Switch.adaptive(
// value:
// (widget.coupons != null && widget.coupons != "" ||
// widget.promotions != null &&
// widget.promotions != "" ||
// widget.payChannell == 5 || widget.payChannell == 7 ||
// (widget.payChannell == 4 && widget.settleOrderInfo.usePlateMoney == false) )
// ? false
// : vipBenefit,
// materialTapTargetSize:
// MaterialTapTargetSize.shrinkWrap,
// activeColor: Color(0xff32A060),
// onChanged: (bool value) {
// setState(() {
// if(widget.settleOrderInfo.usePlateMoney == false || widget.payChannell == 5){
// SmartDialog.show(
// widget: SettlementTips(
// () {
// },
// text: widget.payChannell == 5 ? "该支付余额为特殊活动充值, 不可参与任何活动" :"该用户平台余额为特殊活动充值, 不可参与任何活动",
// ));
// return;
// }
// vipBenefit = !vipBenefit;
// widget.vipBenefitSelect(vipBenefit);
// });
// },
// )
// : GestureDetector(
// onTap: () {
// setState(() {
// vipBenefit = !vipBenefit;
// widget.vipBenefitSelect(vipBenefit);
// });
// },
// child: Container(
// padding: EdgeInsets.only(bottom: 18.w),
// alignment: Alignment.center,
// child: Image.asset(
// (((widget.coupons != null && widget.coupons != "") ||
// (widget.promotions != null && widget.promotions != "" )||
// widget.payChannell == 5 || widget.payChannell == 7||
// (widget.payChannell == 4 && widget.settleOrderInfo.promotionInfoList.length <=0 && widget.settleOrderInfo.couponList.length <= 0))
// ? false
// : vipSelect)
// ? "assets/image/vip_price.webp"
// : "assets/image/vip_unprice.webp",
// width: 38.w,
// height: 20.h,
// ),
// ),
// )
// ],
// ),
// ),
if (widget.placeOrder &&
((widget?.settleOrderInfo?.discountType == "MEMBER_RANK" || widget?.settleOrderInfo?.discountType == "SURPRISE") && widget?.settleOrderInfo?.benefitDiscountAmount != null &&
widget?.settleOrderInfo?.benefitDiscountAmount != "0"))
Container(
margin: EdgeInsets.only(bottom: 13),
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Expanded(
flex: 1,
child: Text(
"会员优惠金额",
style: TextStyle(
fontWeight: MyFontWeight.regular,
fontSize: 14.sp,
color: Color(0xFF353535),
),
),
),
Text(
widget.settleOrderInfo.benefitDiscountAmount,
textAlign: TextAlign.end,
style: TextStyle(
fontSize: 14.sp,
color: Color(0xFF32A060),
fontWeight: MyFontWeight.semi_bold,
),
),
],
),
),
if (widget.placeOrder && widget.tableId <= 0 && !(widget?.settleOrderInfo?.isRaise ?? false))
InkWell(
onTap: () {
if(widget.payChannell == 5){
SmartDialog.show(
widget: SettlementTips(
() {
},
text: "该支付余额为特殊活动充值, 不可参与任何活动",
));
return;
}
widget.activityCart();
},
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Expanded(
flex: 1,
child: Text(
S.of(context).huodong,
style: TextStyle(
fontWeight: MyFontWeight.regular,
fontSize: 14.sp,
color: Color(0xFF353535),
),
),
),
Text(
activityText(),
textAlign: TextAlign.end,
style: TextStyle(
fontSize: 14.sp,
color: Color(0xFF32A060),
fontWeight: MyFontWeight.semi_bold,
),
),
Icon(
Icons.keyboard_arrow_right,
size: 16,
),
],
),
),
if (widget.placeOrder && !(widget?.settleOrderInfo?.isRaise ?? false))
SizedBox(
height: 13,
),
if (widget.placeOrder && (widget.tableId > 0 ? !(widget?.minOrderInfo?.isRaise ?? false) : !(widget?.settleOrderInfo?.isRaise ?? false)))
InkWell(
onTap: () {
if(widget.payChannell == 5){
SmartDialog.show(
widget: SettlementTips(
() {
},
text: "该支付余额为特殊活动充值, 不可参与任何活动",
));
return;
}
widget.couponCart();
},
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Expanded(
flex: 1,
child: Text(
S.of(context).youhuiquan,
style: TextStyle(
fontWeight: MyFontWeight.regular,
fontSize: 14.sp,
color: Color(0xFF353535),
),
),
),
Text(
couponText(),
textAlign: TextAlign.end,
style: TextStyle(
fontSize: 14.sp,
color: Color(0xFF32A060),
fontWeight: MyFontWeight.semi_bold,
),
),
Icon(
Icons.keyboard_arrow_right,
size: 16,
),
],
),
),
if (widget.placeOrder && (widget.tableId > 0 ? !(widget?.minOrderInfo?.isRaise ?? false) : !(widget?.settleOrderInfo?.isRaise ?? false)))
SizedBox(
height: 13,
),
InkWell(
onTap: () {
widget.editRemark();
},
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Expanded(
flex: 1,
child: Text(
S.of(context).beizhu,
style: TextStyle(
fontWeight: MyFontWeight.regular,
fontSize: 14.sp,
color: Color(0xFF353535),
),
),
),
Expanded(
child: Text(
widget.remark != "" ? widget.remark : "点击添加备注",
textAlign: TextAlign.end,
style: TextStyle(
fontSize: 14.sp,
color: Color(0xFF858585),
fontWeight: MyFontWeight.medium,
),
),
),
Icon(
Icons.keyboard_arrow_right,
size: 16,
),
],
),
),
if ((widget.subscribeParam?.isEnableSubscribe ?? false) == true)
SizedBox(
height: 13,
),
if ((widget.subscribeParam?.isEnableSubscribe ?? false) == true)
InkWell(
onTap: () {
widget.showDateSelector();
},
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Expanded(
flex: 1,
child: Text(
"预约时间",
style: TextStyle(
fontWeight: MyFontWeight.regular,
fontSize: 14.sp,
color: Color(0xFF353535),
),
),
),
Expanded(
child: Text(
widget.reservationTime ?? "请选择时间",
textAlign: TextAlign.end,
style: TextStyle(
fontSize: 14.sp,
color: Color(0xFF858585),
fontWeight: MyFontWeight.medium,
),
),
),
Icon(
Icons.keyboard_arrow_right,
size: 16,
),
],
),
),
if ((widget.subscribeParam?.isEnableSubscribe ?? false) == true)
SizedBox(
height: 13,
),
if ((widget.subscribeParam?.isEnableSubscribe ?? false) == true)
InkWell(
onTap: () {
if (widget.subscribeParam.stores.length > 1)
widget.showAlertDialog();
},
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Expanded(
flex: 1,
child: Text(
"预约店铺",
style: TextStyle(
fontWeight: MyFontWeight.regular,
fontSize: 14.sp,
color: Color(0xFF353535),
),
),
),
Expanded(
child: Text(
((widget.subscribeParam.stores.length == 1)
? widget?.subscribeParam?.stores[0]
: widget.subscribeStoresName) ??
"请选择店铺",
textAlign: TextAlign.end,
style: TextStyle(
fontSize: 14.sp,
color: Color(0xFF858585),
fontWeight: MyFontWeight.medium,
),
),
),
Icon(
Icons.keyboard_arrow_right,
size: 16,
),
],
),
),
],
),
);
}
String activityText() {
String promotion = "";
if (widget.promotions == null || widget.promotions == "") {
promotion = "未选择任何活动";
if (widget.settleOrderInfo == null ||
widget.settleOrderInfo.promotionInfoList == null) {
promotion = "暂无可选活动";
} else if (widget.coupons != null && widget.coupons != "") {
promotion = "活动与优惠券不可同享";
}
} else {
promotion = widget.promotions;
}
return promotion;
}
String couponText() {
String coupon = "";
if (widget.coupons == null || widget.coupons == "") {
coupon = "未选择任何优惠券";
if (widget.placeOrder) if (widget.minOrderInfo == null ||
widget.minOrderInfo.orderInfoVo.couponList == null) {
coupon = "未选择任何优惠券";
} else if (widget.promotions != null && widget.promotions != "") {
coupon = "优惠券与活动不可同享";
}
if (widget.settleOrderInfo == null ||
widget.settleOrderInfo.couponList == null) {
coupon = "暂无可选优惠券";
} else if (widget.promotions != null && widget.promotions != "") {
coupon = "优惠券与活动不可同享";
}
} else {
coupon = widget.coupons;
}
return coupon;
}
}