|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
|
|
|
import 'package:huixiang/generated/l10n.dart';
|
|
|
|
import 'package:huixiang/retrofit/data/activity_details.dart';
|
|
|
|
import 'package:huixiang/retrofit/data/min_order_info.dart';
|
|
|
|
import 'package:huixiang/retrofit/data/order_product_vo.dart';
|
|
|
|
import 'package:huixiang/retrofit/data/settleOrderInfo.dart';
|
|
|
|
import 'package:huixiang/utils/font_weight.dart';
|
|
|
|
import 'package:huixiang/view_widget/custom_image.dart';
|
|
|
|
import 'package:huixiang/view_widget/separator.dart';
|
|
|
|
|
|
|
|
class SettlementOrderCommodity extends StatefulWidget {
|
|
|
|
final int isTakeOut;
|
|
|
|
final int tableId;
|
|
|
|
|
|
|
|
final SettleOrderInfo settleOrderInfo;
|
|
|
|
final MinOrderInfo minOrderInfo;
|
|
|
|
final String pageType;
|
|
|
|
|
|
|
|
SettlementOrderCommodity(
|
|
|
|
this.isTakeOut, this.settleOrderInfo, this.minOrderInfo,this.tableId,this.pageType,);
|
|
|
|
|
|
|
|
@override
|
|
|
|
State<StatefulWidget> createState() {
|
|
|
|
return _SettlementOrderCommodity();
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
class _SettlementOrderCommodity extends State<SettlementOrderCommodity> {
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
return Stack(
|
|
|
|
alignment: Alignment.centerRight,
|
|
|
|
children: [
|
|
|
|
Container(
|
|
|
|
margin: EdgeInsets.only(
|
|
|
|
left: 16.w,
|
|
|
|
right: 16.w,
|
|
|
|
top: 16.h,
|
|
|
|
bottom: 8.h,
|
|
|
|
),
|
|
|
|
padding: EdgeInsets.only(
|
|
|
|
left: 20.w,
|
|
|
|
right: 20.w,
|
|
|
|
top: 12.h,
|
|
|
|
bottom: 12.h,
|
|
|
|
),
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
color: Colors.white,
|
|
|
|
boxShadow: [
|
|
|
|
BoxShadow(
|
|
|
|
color: Colors.black.withAlpha(12),
|
|
|
|
offset: Offset(0, 1),
|
|
|
|
blurRadius: 12,
|
|
|
|
spreadRadius: 0,
|
|
|
|
),
|
|
|
|
],
|
|
|
|
borderRadius: BorderRadius.circular(8),
|
|
|
|
),
|
|
|
|
child: Column(
|
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
|
|
|
children: commodityList(),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
Visibility(
|
|
|
|
child: buildQrCode(),
|
|
|
|
visible: false,
|
|
|
|
),
|
|
|
|
],
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
List<Widget> commodityList() {
|
|
|
|
if (widget.settleOrderInfo == null) return [];
|
|
|
|
List<Widget> widgets = [];
|
|
|
|
|
|
|
|
if (widget.minOrderInfo != null) {
|
|
|
|
widgets.addAll(widget.minOrderInfo.orderProductVOList
|
|
|
|
.map((e) => commodityItem(e))
|
|
|
|
.toList());
|
|
|
|
} else if (widget.settleOrderInfo != null) {
|
|
|
|
widgets.addAll(widget.settleOrderInfo.orderProductList
|
|
|
|
.map((e) => commodityItem(e))
|
|
|
|
.toList());
|
|
|
|
}
|
|
|
|
widgets.add(SizedBox(height: 20.h));
|
|
|
|
|
|
|
|
if (widget.isTakeOut != 0) {
|
|
|
|
// 配送费
|
|
|
|
widgets.add(
|
|
|
|
discountItem(
|
|
|
|
Color(0xFFFF7A1A),
|
|
|
|
widget.isTakeOut == 1
|
|
|
|
? S.of(context).peisongfei
|
|
|
|
: S.of(context).yunfei,
|
|
|
|
"",
|
|
|
|
(widget.minOrderInfo != null)
|
|
|
|
? "+ ${widget.minOrderInfo?.postFee ?? "0"}"
|
|
|
|
: "+ ${widget.settleOrderInfo?.postAge ?? "0"}",
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
widgets.add(Container(
|
|
|
|
margin: EdgeInsets.only(
|
|
|
|
top: 24.h,
|
|
|
|
bottom: 4.h,
|
|
|
|
),
|
|
|
|
child: MySeparator(
|
|
|
|
height: 1,
|
|
|
|
width: 5.w,
|
|
|
|
color: Colors.grey,
|
|
|
|
),
|
|
|
|
));
|
|
|
|
// widgets.add(buildTotalPrice());
|
|
|
|
return widgets;
|
|
|
|
}
|
|
|
|
|
|
|
|
Widget commodityItem(OrderProductVOList productList) {
|
|
|
|
return Container(
|
|
|
|
margin: EdgeInsets.only(top: 8.h, bottom: 8.h),
|
|
|
|
child: Row(
|
|
|
|
children: [
|
|
|
|
MImage(
|
|
|
|
productList.skuImg,
|
|
|
|
width: 44,
|
|
|
|
height: 44,
|
|
|
|
fit: BoxFit.cover,
|
|
|
|
errorSrc: "assets/image/default_1.webp",
|
|
|
|
fadeSrc: "assets/image/default_1.webp",
|
|
|
|
),
|
|
|
|
Expanded(
|
|
|
|
flex: 1,
|
|
|
|
child: Container(
|
|
|
|
margin: EdgeInsets.only(
|
|
|
|
left: 16.w,
|
|
|
|
),
|
|
|
|
// height: 44.h,
|
|
|
|
child: Column(
|
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
children: [
|
|
|
|
Row(
|
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.center,
|
|
|
|
children: [
|
|
|
|
Text(
|
|
|
|
productList.productName,
|
|
|
|
style: TextStyle(
|
|
|
|
fontWeight: FontWeight.bold,
|
|
|
|
fontSize: 14.sp,
|
|
|
|
color: Color(0xFF353535),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
Text(
|
|
|
|
"x${productList.buyNum}",
|
|
|
|
style: TextStyle(
|
|
|
|
fontSize: 12.sp,
|
|
|
|
color: Color(0xFF727272),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
Row(
|
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.center,
|
|
|
|
children: [
|
|
|
|
Expanded(
|
|
|
|
flex: 1,
|
|
|
|
child: Text(
|
|
|
|
productList.skuNameStr != null
|
|
|
|
? "${productList.skuNameStr ?? ""}"
|
|
|
|
: "",
|
|
|
|
overflow: TextOverflow.ellipsis,
|
|
|
|
style: TextStyle(
|
|
|
|
fontSize: 12.sp,
|
|
|
|
color: Color(0xFFA29E9E),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
Text(
|
|
|
|
S.of(context).yuan_(productList.sellPrice),
|
|
|
|
style: TextStyle(
|
|
|
|
fontWeight: FontWeight.bold,
|
|
|
|
fontSize: 12.sp,
|
|
|
|
color: Color(0xFF4C4C4C),
|
|
|
|
),
|
|
|
|
)
|
|
|
|
],
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
Widget discountItem(Color color, textName, condition, amount) {
|
|
|
|
return Container(
|
|
|
|
margin: EdgeInsets.only(top: 9.h, bottom: 9.h),
|
|
|
|
child: Row(
|
|
|
|
children: [
|
|
|
|
Container(
|
|
|
|
padding: EdgeInsets.fromLTRB(4.w, 2.h, 4.w, 2.h),
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
borderRadius: BorderRadius.all(Radius.circular(2)),
|
|
|
|
border: Border.all(
|
|
|
|
width: 1,
|
|
|
|
color: color,
|
|
|
|
style: BorderStyle.solid,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
child: Text(
|
|
|
|
textName,
|
|
|
|
style: TextStyle(
|
|
|
|
fontSize: 10.sp,
|
|
|
|
color: color,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
SizedBox(
|
|
|
|
width: 27.w,
|
|
|
|
),
|
|
|
|
Expanded(
|
|
|
|
child: Text(
|
|
|
|
condition ?? "",
|
|
|
|
style: TextStyle(
|
|
|
|
fontSize: 10.sp,
|
|
|
|
color: Color(0xFFA29E9E),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
flex: 1,
|
|
|
|
),
|
|
|
|
Text(
|
|
|
|
S.of(context).yuan_("$amount"),
|
|
|
|
style: TextStyle(
|
|
|
|
fontSize: 12.sp,
|
|
|
|
color: color,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
Widget buildQrCode() {
|
|
|
|
return Container(
|
|
|
|
margin: EdgeInsets.only(right: 16.w),
|
|
|
|
child: Stack(
|
|
|
|
children: [
|
|
|
|
Container(
|
|
|
|
width: 94.w,
|
|
|
|
height: 33.h,
|
|
|
|
margin: EdgeInsets.only(left: 12.w),
|
|
|
|
padding: EdgeInsets.only(left: 16.w),
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
color: Colors.white,
|
|
|
|
boxShadow: [
|
|
|
|
BoxShadow(
|
|
|
|
color: Colors.black.withAlpha(25),
|
|
|
|
offset: Offset(0, 1),
|
|
|
|
blurRadius: 12,
|
|
|
|
spreadRadius: 0,
|
|
|
|
)
|
|
|
|
],
|
|
|
|
borderRadius: BorderRadius.only(
|
|
|
|
topLeft: Radius.circular(2),
|
|
|
|
bottomLeft: Radius.circular(2),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
child: Row(
|
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.center,
|
|
|
|
children: [
|
|
|
|
Text(
|
|
|
|
S.of(context).qujianma,
|
|
|
|
style: TextStyle(
|
|
|
|
fontWeight: FontWeight.bold,
|
|
|
|
fontSize: 12.sp,
|
|
|
|
color: Colors.black,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
Icon(
|
|
|
|
Icons.keyboard_arrow_right,
|
|
|
|
color: Colors.black,
|
|
|
|
size: 16,
|
|
|
|
)
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
Container(
|
|
|
|
margin: EdgeInsets.only(top: 6.h, bottom: 6.h),
|
|
|
|
// padding: EdgeInsets.all(2),
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
color: Colors.white,
|
|
|
|
boxShadow: [
|
|
|
|
BoxShadow(
|
|
|
|
color: Colors.black.withAlpha(25),
|
|
|
|
offset: Offset(0, 1),
|
|
|
|
blurRadius: 12,
|
|
|
|
spreadRadius: 0,
|
|
|
|
)
|
|
|
|
],
|
|
|
|
borderRadius: BorderRadius.circular(2),
|
|
|
|
),
|
|
|
|
child: Icon(
|
|
|
|
Icons.qr_code,
|
|
|
|
size: 20,
|
|
|
|
color: Color(0xFF32A060),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Widget buildTotalPrice() {
|
|
|
|
// return Container(
|
|
|
|
// margin: EdgeInsets.only(top: 7.h, bottom: 11.h),
|
|
|
|
// child: Row(
|
|
|
|
// mainAxisAlignment: MainAxisAlignment.end,
|
|
|
|
// crossAxisAlignment: CrossAxisAlignment.baseline,
|
|
|
|
// textBaseline: TextBaseline.alphabetic,
|
|
|
|
// children: [
|
|
|
|
// Expanded(
|
|
|
|
// child: Text(
|
|
|
|
// S.of(context).gongjijianshangpin((widget.minOrderInfo != null)
|
|
|
|
// ? ((widget.minOrderInfo != null)
|
|
|
|
// ? widget.minOrderInfo.orderProductVOList.length
|
|
|
|
// : "0")
|
|
|
|
// : (widget.settleOrderInfo != null)
|
|
|
|
// ? widget.settleOrderInfo.orderProductList.length
|
|
|
|
// : "0"),
|
|
|
|
// style: TextStyle(
|
|
|
|
// fontSize: 10.sp,
|
|
|
|
// color: Color(0xFFA29E9E),
|
|
|
|
// fontWeight: MyFontWeight.semi_bold,
|
|
|
|
// ),
|
|
|
|
// ),
|
|
|
|
// flex: 1,
|
|
|
|
// ),
|
|
|
|
// Container(
|
|
|
|
// child: Text(
|
|
|
|
// "已优惠:¥${discountPrice()}",
|
|
|
|
// style: TextStyle(
|
|
|
|
// fontSize: 12.sp,
|
|
|
|
// color: Color(0xFF7B7B7B),
|
|
|
|
// fontWeight: MyFontWeight.medium,
|
|
|
|
// ),
|
|
|
|
// ),
|
|
|
|
// ),
|
|
|
|
// SizedBox(
|
|
|
|
// width: 15.w,
|
|
|
|
// ),
|
|
|
|
//
|
|
|
|
// Container(
|
|
|
|
// child: Text(
|
|
|
|
// S.of(context).jiesuanjine,
|
|
|
|
// style: TextStyle(
|
|
|
|
// fontSize: 12.sp,
|
|
|
|
// color: Color(0xFF353535),
|
|
|
|
// fontWeight: MyFontWeight.semi_bold,
|
|
|
|
// ),
|
|
|
|
// ),
|
|
|
|
// ),
|
|
|
|
// SizedBox(
|
|
|
|
// width: 5.w,
|
|
|
|
// ),
|
|
|
|
// Text(
|
|
|
|
// totalPrice(),
|
|
|
|
// textAlign: TextAlign.end,
|
|
|
|
// style: TextStyle(
|
|
|
|
// fontSize: 14.sp,
|
|
|
|
// color: Color(0xFF32A060),
|
|
|
|
// fontWeight: MyFontWeight.semi_bold,
|
|
|
|
// ),
|
|
|
|
// ),
|
|
|
|
// ],
|
|
|
|
// ),
|
|
|
|
// );
|
|
|
|
// }
|
|
|
|
|
|
|
|
String discountPrice(){
|
|
|
|
if(widget.minOrderInfo != null){
|
|
|
|
return (widget.minOrderInfo.discountAmount ?? "0") + (widget.settleOrderInfo.benefitDiscountAmount ?? "0");
|
|
|
|
}else if(widget.tableId < 0){
|
|
|
|
return "0";
|
|
|
|
}else {
|
|
|
|
return widget?.settleOrderInfo?.discountAmount ?? "0";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
String totalPrice() {
|
|
|
|
if (widget.minOrderInfo != null &&
|
|
|
|
widget.minOrderInfo.orderProductVOList != null) {
|
|
|
|
return "${widget.minOrderInfo.orderSumPrice}";
|
|
|
|
}
|
|
|
|
if (widget.settleOrderInfo.orderProductList == null) return "";
|
|
|
|
return "${widget.settleOrderInfo.price}";
|
|
|
|
}
|
|
|
|
}
|