After Width: | Height: | Size: 1003 B |
After Width: | Height: | Size: 808 B |
After Width: | Height: | Size: 583 B |
After Width: | Height: | Size: 1.7 KiB |
After Width: | Height: | Size: 1.6 KiB |
After Width: | Height: | Size: 988 B |
After Width: | Height: | Size: 432 B |
After Width: | Height: | Size: 429 B |
After Width: | Height: | Size: 317 B |
@ -0,0 +1,361 @@
|
||||
|
||||
|
||||
import 'package:flutter/material.dart'; |
||||
import 'package:flutter_screenutil/flutter_screenutil.dart'; |
||||
import 'package:huixiang/generated/l10n.dart'; |
||||
import 'package:huixiang/retrofit/data/order_info.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 SettleOrderInfo orderInfo; |
||||
|
||||
SettlementOrderCommodity(this.orderInfo,this.isTakeOut); |
||||
|
||||
@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.orderInfo == null) return []; |
||||
List<Widget> widgets = []; |
||||
if (widget.orderInfo.orderProductList != null) { |
||||
widgets |
||||
.addAll(widget.orderInfo.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.orderInfo.postAge}")); |
||||
} |
||||
|
||||
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(OrderProductListBean productList) { |
||||
return Container( |
||||
margin: EdgeInsets.only(top: 8.h, bottom: 8.h), |
||||
child: Row( |
||||
children: [ |
||||
MImage( |
||||
productList.skuImg, |
||||
width: 44.w, |
||||
height: 44, |
||||
fit: BoxFit.cover, |
||||
errorSrc: "assets/image/default_1.png", |
||||
fadeSrc: "assets/image/default_1.png", |
||||
), |
||||
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.weight != null |
||||
? "${productList.weight}kg" |
||||
: "", |
||||
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.orderInfo != null && widget.orderInfo.orderProductList != null) |
||||
? widget.orderInfo.orderProductList.length |
||||
: "0"), |
||||
style: TextStyle( |
||||
fontSize: 10.sp, |
||||
color: Color(0xFFA29E9E), |
||||
fontWeight: MyFontWeight.semi_bold |
||||
), |
||||
), |
||||
flex: 1, |
||||
), |
||||
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 totalPrice() { |
||||
if (widget.orderInfo == null) return ""; |
||||
double totalPrice = (double.tryParse(widget.orderInfo.orderSum) + |
||||
double.tryParse(widget.orderInfo.postAge)); |
||||
return "$totalPrice"; |
||||
} |
||||
|
||||
} |