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.

403 lines
12 KiB

3 years ago
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:huixiang/generated/l10n.dart';
3 years ago
import 'package:huixiang/retrofit/data/min_order_info.dart';
3 years ago
import 'package:huixiang/retrofit/data/order_product_vo.dart';
3 years ago
import 'package:huixiang/retrofit/data/settleOrderInfo.dart';
3 years ago
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;
3 years ago
final int tableId;
3 years ago
3 years ago
final SettleOrderInfo settleOrderInfo;
3 years ago
final MinOrderInfo minOrderInfo;
3 years ago
3 years ago
SettlementOrderCommodity(
3 years ago
this.isTakeOut, this.settleOrderInfo, this.minOrderInfo,this.tableId);
3 years ago
@override
State<StatefulWidget> createState() {
return _SettlementOrderCommodity();
}
3 years ago
3 years ago
}
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() {
3 years ago
if (widget.settleOrderInfo == null) return [];
3 years ago
List<Widget> widgets = [];
3 years ago
if (widget.minOrderInfo != null) {
widgets.addAll(widget.minOrderInfo.orderProductVOList
.map((e) => commodityItem(e))
.toList());
} else if (widget.settleOrderInfo != null) {
3 years ago
widgets.addAll(widget.settleOrderInfo.orderProductList
.map((e) => commodityItem(e))
.toList());
3 years ago
}
widgets.add(SizedBox(height: 20.h));
if (widget.isTakeOut != 0) {
// 配送费
3 years ago
widgets.add(
discountItem(
3 years ago
Color(0xFFFF7A1A),
widget.isTakeOut == 1
? S.of(context).peisongfei
: S.of(context).yunfei,
"",
3 years ago
(widget.minOrderInfo != null)
? "+ ${widget.minOrderInfo?.postFee ?? "0"}"
: "+ ${widget.settleOrderInfo?.postAge ?? "0"}",
3 years ago
),
);
3 years ago
}
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;
}
3 years ago
Widget commodityItem(OrderProductVOList productList) {
3 years ago
return Container(
margin: EdgeInsets.only(top: 8.h, bottom: 8.h),
child: Row(
children: [
MImage(
3 years ago
productList.skuImg,
width: 44,
3 years ago
height: 44,
fit: BoxFit.cover,
errorSrc: "assets/image/default_1.webp",
fadeSrc: "assets/image/default_1.webp",
3 years ago
),
Expanded(
flex: 1,
child: Container(
margin: EdgeInsets.only(
left: 16.w,
),
// height: 44.h,
3 years ago
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(
3 years ago
"x${productList.buyNum}",
3 years ago
style: TextStyle(
fontSize: 12.sp,
color: Color(0xFF727272),
),
),
],
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Expanded(
flex: 1,
child: Text(
3 years ago
productList.skuNameStr != null
? "${productList.skuNameStr ?? ""}"
3 years ago
: "",
overflow: TextOverflow.ellipsis,
style: TextStyle(
fontSize: 12.sp,
color: Color(0xFFA29E9E),
),
),
),
Text(
3 years ago
S.of(context).yuan_(productList.sellPrice),
3 years ago
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(
3 years ago
S.of(context).gongjijianshangpin((widget.minOrderInfo != null)
? ((widget.minOrderInfo != null)
? widget.minOrderInfo.orderProductVOList.length
: "0")
: (widget.settleOrderInfo != null)
? widget.settleOrderInfo.orderProductList.length
: "0"),
3 years ago
style: TextStyle(
3 years ago
fontSize: 10.sp,
color: Color(0xFFA29E9E),
fontWeight: MyFontWeight.semi_bold,
),
3 years ago
),
flex: 1,
),
3 years ago
Container(
child: Text(
"已优惠:¥${discountPrice()}",
3 years ago
style: TextStyle(
fontSize: 12.sp,
color: Color(0xFF7B7B7B),
fontWeight: MyFontWeight.medium,
),
),
),
SizedBox(
width: 15.w,
),
3 years ago
3 years ago
Container(
child: Text(
S.of(context).jiesuanjine,
style: TextStyle(
3 years ago
fontSize: 12.sp,
color: Color(0xFF353535),
fontWeight: MyFontWeight.semi_bold,
),
3 years ago
),
),
SizedBox(
width: 5.w,
),
Text(
totalPrice(),
textAlign: TextAlign.end,
style: TextStyle(
3 years ago
fontSize: 14.sp,
color: Color(0xFF32A060),
fontWeight: MyFontWeight.semi_bold,
),
),
3 years ago
],
),
);
}
String discountPrice(){
if(widget.minOrderInfo != null){
3 years ago
return (widget.minOrderInfo.discountAmount ?? "0") + (widget.settleOrderInfo.benefitDiscountAmount ?? "0");
}else if(widget.tableId < 0){
return "0";
}else {
return widget?.settleOrderInfo?.discountAmount ?? "0";
}
}
3 years ago
String totalPrice() {
3 years ago
if (widget.minOrderInfo != null &&
widget.minOrderInfo.orderProductVOList != null) {
return "${widget.minOrderInfo.orderSumPrice}";
}
3 years ago
if (widget.settleOrderInfo.orderProductList == null) return "";
return "${widget.settleOrderInfo.price}";
3 years ago
}
3 years ago
}