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.

1280 lines
39 KiB

4 years ago
import 'package:dio/dio.dart';
4 years ago
import 'package:flutter/material.dart';
3 years ago
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
4 years ago
import 'package:huixiang/generated/l10n.dart';
4 years ago
import 'package:huixiang/retrofit/data/base_data.dart';
import 'package:huixiang/retrofit/data/order_info.dart';
import 'package:huixiang/retrofit/retrofit_api.dart';
4 years ago
import 'package:huixiang/utils/flutter_utils.dart';
4 years ago
import 'package:huixiang/view_widget/border_text.dart';
4 years ago
import 'package:huixiang/view_widget/custom_image.dart';
import 'package:huixiang/view_widget/icon_text.dart';
3 years ago
import 'package:huixiang/view_widget/login_tips.dart';
4 years ago
import 'package:huixiang/view_widget/my_appbar.dart';
4 years ago
import 'package:huixiang/view_widget/pay_input_view.dart';
3 years ago
import 'package:huixiang/view_widget/request_permission.dart';
4 years ago
import 'package:huixiang/view_widget/round_button.dart';
import 'package:huixiang/view_widget/separator.dart';
3 years ago
import 'package:huixiang/view_widget/text_image_dialog.dart';
4 years ago
import 'package:shared_preferences/shared_preferences.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
3 years ago
import 'package:url_launcher/url_launcher.dart';
4 years ago
class OrderDetailPage extends StatefulWidget {
4 years ago
final arguments;
OrderDetailPage({this.arguments});
4 years ago
@override
State<StatefulWidget> createState() {
return _OrderDetailPage();
}
}
class _OrderDetailPage extends State<OrderDetailPage> {
4 years ago
ApiService apiService;
@override
void initState() {
super.initState();
SharedPreferences.getInstance().then((value) {
apiService =
ApiService(Dio(), context: context, token: value.getString("token"));
queryDetails();
});
}
OrderInfo orderInfo;
4 years ago
int payStatus = 0;
int orderStatus = 0;
int sendStatus = 0;
int isTakeOut = 0;
int refundStatus = 0;
4 years ago
// String storeType = "NORMALSTORE"; //NORMALSTORE FASTSTORE RETAILSTORE
4 years ago
queryDetails() async {
3 years ago
BaseData<OrderInfo> baseData = await apiService.orderDetail(widget.arguments["id"]);
4 years ago
if (baseData != null && baseData.isSuccess) {
3 years ago
orderInfo = baseData.data;
4 years ago
payStatus = orderInfo.payStatus;
orderStatus = orderInfo.orderStatus;
sendStatus = orderInfo.sendStatus;
isTakeOut = orderInfo.isTakeOut;
refundStatus = orderInfo.refundStatus;
4 years ago
// storeType = orderInfo.storeVO.posType.code;
print("refund_status: $refundStatus");
4 years ago
print("payStatus: $payStatus");
print("orderStatus: $orderStatus");
print("sendStatus: $sendStatus");
print("isTakeOut: $isTakeOut");
if (mounted)
setState(() {
statusTitle();
});
4 years ago
}
}
4 years ago
@override
Widget build(BuildContext context) {
return Scaffold(
4 years ago
appBar: MyAppBar(
3 years ago
title: title ?? S.of(context).jinxingzhongdedingdan,
4 years ago
titleColor: Colors.white,
background: Color(0xFF3A405A),
leadingColor: Colors.white,
3 years ago
toolbarHeight: (orderStatus >= 4 ? 118.h : 118.h) +
3 years ago
MediaQuery.of(context).padding.top +
kToolbarHeight,
3 years ago
brightness: Brightness.dark,
4 years ago
bottom: PreferredSize(
3 years ago
preferredSize: Size(double.infinity, orderStatus >= 4 ? 118.h : 118),
4 years ago
child: Container(
3 years ago
height: orderStatus >= 4 ? 118.h : 118.h,
padding: EdgeInsets.fromLTRB(16.w, 0, 16.w, 10.h),
child: Column(
children: [
Visibility(
visible: center != null && center != "",
child: Container(
child: IconText(
(center != null && center != "") ? center : "",
leftImage: "assets/image/icon_order_ok.png",
iconSize: 40.w,
textStyle: TextStyle(
fontSize: 24.sp,
fontWeight: FontWeight.bold,
color: Colors.white,
4 years ago
),
),
),
3 years ago
),
Expanded(
child: Row(
mainAxisAlignment: MainAxisAlignment.end,
crossAxisAlignment: CrossAxisAlignment.end,
children: [
Expanded(
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
RoundButton(
text: isTakeOut == 0
? S.of(context).ziqu
: isTakeOut == 1
? S.of(context).waimai
: S.of(context).kuaidi,
width: 42.w,
height: 20.h,
textColor: Colors.white,
fontSize: 12.sp,
padding: EdgeInsets.fromLTRB(8.w, 1.h, 8.w, 1.h),
backgroup: Color(0xFF32A060),
radius: 15.w,
),
Text(
title,
style: TextStyle(
color: Colors.white,
4 years ago
fontSize: 12.sp,
4 years ago
),
4 years ago
),
3 years ago
],
),
flex: 1,
),
Visibility(
child: Container(
height: 33.h,
child: Row(
mainAxisSize: MainAxisSize.min,
children: timeWidget(),
4 years ago
),
3 years ago
),
visible: (orderStatus >= 4 || isTakeOut == 2)
? false
: (isTakeOut == 0)
? !(payStatus == 1)
: (isTakeOut == 1)
? !(payStatus == 1 &&
(sendStatus != 2 && sendStatus != 3))
: !(payStatus == 1 && (sendStatus != 1)),
),
],
),
flex: 1,
),
],
),
),
4 years ago
),
),
body: Container(
child:
/*Column(
children: [
Expanded(
child:*/
Stack(
4 years ago
children: [
Positioned(
top: 0,
left: 0,
right: 0,
child: Container(
3 years ago
height: 36.h,
color: Color(0xFF3A405A),
),
4 years ago
),
SingleChildScrollView(
physics: BouncingScrollPhysics(),
child: Container(
child: Column(
children: [
buildAddress(),
buildCommodity(),
// if (payStatus == 0) couponRemarks(),
/*(payStatus == 0) ? paySelector() : */
buildOrderInfo(),
4 years ago
Container(
4 years ago
height: 42.h,
4 years ago
),
],
),
),
),
],
),
// flex: 1,
// ),
// if (payStatus == 0)
// bottomPay(),
// ],
// ),
),
);
}
4 years ago
List<Widget> timeWidget() {
4 years ago
if (orderInfo == null) return [];
4 years ago
String hour = "";
String minute = "";
if (payStatus == 0) {
String hourMinute = AppUtils.getHourMinuteAfter30mByString(
(orderInfo != null) ? orderInfo.createTime : "");
var hourMinutes = hourMinute.split(":");
hour = hourMinutes[0];
minute = hourMinutes[1];
} else {
if (isTakeOut == 0) {
} else if (isTakeOut == 1) {
if (sendStatus == 2 || sendStatus == 3) {
String hourMinute = AppUtils.getHourMinuteByString(
(orderInfo != null && orderInfo.orderDetail != null)
? orderInfo.orderDetail.predictTime
: "");
var hourMinutes = hourMinute.split(":");
hour = hourMinutes[0];
minute = hourMinutes[1];
}
} else if (isTakeOut == 2) {
4 years ago
// if (sendStatus == 1) {
// String hourMinute = AppUtils.getHourMinuteByString(
// (orderInfo != null && orderInfo.orderDetail != null)
// ? orderInfo.orderDetail.predictTime
// : "");
// var hourMinutes = hourMinute.split(":");
// hour = hourMinutes[0];
// minute = hourMinutes[1];
// }
4 years ago
}
}
return [
AspectRatio(
aspectRatio: 1,
child: BorderText(
text: hour,
textColor: Colors.white,
fontSize: 21.sp,
fontWeight: FontWeight.bold,
borderColor: Colors.white,
borderWidth: 1,
padding: EdgeInsets.all(2),
),
),
SizedBox(
width: 8.w,
),
Text(
":",
style: TextStyle(
color: Colors.white,
fontSize: 21.sp,
),
),
SizedBox(
width: 8.w,
),
AspectRatio(
aspectRatio: 1,
child: BorderText(
text: minute,
textColor: Colors.white,
fontSize: 21.sp,
fontWeight: FontWeight.bold,
borderColor: Colors.white,
borderWidth: 1,
padding: EdgeInsets.all(2),
),
),
];
}
String title = "";
String center = "";
statusTitle() {
if (isTakeOut == 0) {
if (payStatus == 0) {
title = S.of(context).dingdandaizhifu;
} else {
title = S.of(context).dingdanyizhifu;
switch (orderStatus) {
case 2:
title = S.of(context).shangjiazhengzaipeican;
break;
case 3:
title = S.of(context).dengdaiyonghuqucan;
4 years ago
center = S.of(context).qudanhao(orderInfo.dayFlowCode);
4 years ago
break;
case 4:
title = S.of(context).dingdanyiwancheng;
center = S.of(context).dingdanyiwancheng;
break;
4 years ago
case 5:
title = S.of(context).yiquxiao;
center = S.of(context).yiquxiao;
break;
4 years ago
}
}
} else if (isTakeOut == 1) {
if (payStatus == 0) {
title = S.of(context).dingdandaizhifu;
} else {
4 years ago
title = S.of(context).dengdaishangjiaqueren;
if (orderStatus < 4) {
switch (sendStatus) {
case 1:
title = S.of(context).zhengzaihujiaoqishou;
break;
case 2:
title = S.of(context).qishouyijiedanquhuozhong;
break;
case 3:
title = S.of(context).qishoupeisongzhongyujisongdashijian;
break;
case 4:
title = S.of(context).dingdanyisongda;
center = S.of(context).dingdanyisongda;
switch (orderStatus) {
case 4:
title = S.of(context).dingdanyiwancheng;
center = S.of(context).dingdanyiwancheng;
break;
}
break;
}
} else if (orderStatus == 4) {
title = S.of(context).dingdanyiwancheng;
center = S.of(context).dingdanyiwancheng;
4 years ago
}
}
} else if (isTakeOut == 2) {
if (payStatus == 0) {
title = S.of(context).dingdandaizhifu;
} else {
4 years ago
title = S.of(context).dingdandaifahuo;
if (orderStatus < 4) {
switch (sendStatus) {
case 1:
title = S.of(context).shangjiayifahuo;
break;
case 4:
title = S.of(context).huopinyisongda;
center = S.of(context).huopinyisongda;
break;
}
} else if (orderStatus == 4) {
title = S.of(context).dingdanyiwancheng;
center = S.of(context).dingdanyiwancheng;
4 years ago
}
}
}
4 years ago
if (orderStatus == 5) {
title = S.of(context).yiquxiao;
center = S.of(context).yiquxiao;
}
if (refundStatus == 1) {
title = S.of(context).dingdanyituikuan;
center = S.of(context).dingdanyituikuan;
}
4 years ago
}
Widget couponRemarks() {
return Container(
margin: EdgeInsets.only(left: 16.w, right: 16.w, top: 8.h, bottom: 2.h),
padding: EdgeInsets.all(20),
decoration: BoxDecoration(
color: Colors.white,
boxShadow: [
BoxShadow(
color: Colors.black.withAlpha(12),
offset: Offset(0, 3),
blurRadius: 14,
spreadRadius: 0,
),
],
3 years ago
borderRadius: BorderRadius.circular(8),
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
orderInfoItem(S.of(context).youhuiquan, "暂无可用优惠券"),
orderInfoItem(S.of(context).beizhu, "口味、面包硬度等"),
],
),
);
}
Widget bottomPay() {
return Container(
height: 54.h,
color: Colors.white,
child: Row(
children: [
Expanded(
child: Row(
mainAxisAlignment: MainAxisAlignment.end,
crossAxisAlignment: CrossAxisAlignment.baseline,
textBaseline: TextBaseline.alphabetic,
children: [
Text(
4 years ago
S.of(context).heji,
style: TextStyle(
fontSize: 12.sp,
color: Colors.black,
),
),
Text(
S
.of(context)
4 years ago
.yuan_(orderInfo != null ? orderInfo.finalPayPrice : "0"),
style: TextStyle(
fontSize: 20.sp,
color: Color(0xFF32A060),
fontWeight: FontWeight.bold,
),
),
],
),
flex: 1,
),
SizedBox(
width: 16.w,
),
InkWell(
onTap: () {},
child: Container(
alignment: Alignment.center,
color: Color(0xFF32A060),
padding: EdgeInsets.symmetric(horizontal: 36.w),
child: Text(
4 years ago
S.of(context).jiesuan,
style: TextStyle(
fontSize: 16.sp,
color: Colors.white,
),
),
),
),
],
4 years ago
),
);
}
carryOnPay() async {
showDialog(
context: context,
builder: (context) {
return AlertDialog(
content: Container(
width: MediaQuery.of(context).size.width - 84.w,
height: 120.h,
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Text(
"app暂不支持支付,\n请前往对应小程序处理",
textAlign: TextAlign.center,
style: TextStyle(
fontSize: 16.sp,
fontWeight: FontWeight.bold,
color: Colors.black,
),
),
SizedBox(
height: 30.h,
),
Row(
children: [
Expanded(
child: InkWell(
child: BorderText(
text: "取消",
textColor: Color(0xFF32A060),
fontSize: 16.sp,
fontWeight: FontWeight.bold,
borderColor: Color(0xFF32A060),
radius: 4,
padding: EdgeInsets.all(12),
borderWidth: 1,
),
onTap: () {
Navigator.of(context).pop();
},
),
flex: 1,
),
SizedBox(
width: 16.w,
),
Expanded(
child: InkWell(
child: RoundButton(
text: "好的",
textColor: Colors.white,
radius: 4,
padding: EdgeInsets.all(12),
backgroup: Color(0xFF32A060),
fontSize: 16.sp,
fontWeight: FontWeight.bold,
),
onTap: () {
Navigator.of(context).pop();
},
),
flex: 1,
),
],
)
],
),
),
);
});
}
4 years ago
Widget paySelector() {
return Container(
margin: EdgeInsets.only(left: 16.w, right: 16.w, top: 14.h, bottom: 2.h),
4 years ago
padding: EdgeInsets.all(20),
decoration: BoxDecoration(
color: Colors.white,
boxShadow: [
BoxShadow(
color: Colors.black.withAlpha(12),
offset: Offset(0, 3),
blurRadius: 14,
spreadRadius: 0,
),
],
3 years ago
borderRadius: BorderRadius.circular(8),
4 years ago
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
S.of(context).zhifufangshi,
4 years ago
style: TextStyle(
color: Color(0xFF727272),
fontSize: 12.sp,
fontWeight: FontWeight.bold,
),
),
SizedBox(
height: 20.h,
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
checkView(0),
// Image.asset("assets/image/icon_alipay.png"),
Text(
S.of(context).yue,
style: TextStyle(
fontSize: 12.sp,
color: Color(0xff353535),
),
),
],
),
SizedBox(
height: 20.h,
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
checkView(1),
IconText(
S.of(context).weixinzhifu,
4 years ago
leftImage: "assets/image/icon_we_chat.png",
iconSize: 14.w,
space: 8.w,
textStyle: TextStyle(
fontSize: 12.sp,
color: Color(0xFF353535),
),
),
],
)
],
),
);
}
var checkIndex = 0;
Widget checkView(var index) {
return GestureDetector(
onTap: () {
setState(() {
checkIndex = index;
});
},
child: Container(
padding: EdgeInsets.only(right: 16),
alignment: Alignment.center,
child: Image.asset(
checkIndex != index
? "assets/image/icon_radio_unselected.png"
: "assets/image/icon_radio_selected.png",
width: 15,
height: 15,
)),
);
}
4 years ago
Widget buildAddress() {
return Container(
3 years ago
margin: EdgeInsets.only(left: 16.w, right: 16.w, top: 20.h, bottom: 2.h),
4 years ago
padding: EdgeInsets.all(20),
decoration: BoxDecoration(
color: Colors.white,
boxShadow: [
BoxShadow(
color: Colors.black.withAlpha(12),
offset: Offset(0, 3),
blurRadius: 14,
spreadRadius: 0,
),
],
3 years ago
borderRadius: BorderRadius.circular(8),
4 years ago
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
children: [
Image.asset(
"assets/image/icon_location_address.png",
4 years ago
width: 28.w,
height: 28.h,
4 years ago
),
4 years ago
Text(
(orderInfo != null && orderInfo.addressExt != null)
? (orderInfo.addressExt.recName ?? "")
: "",
overflow: TextOverflow.ellipsis,
style: TextStyle(
fontSize: 14.sp,
color: Color(0xFF4C4C4C),
),
),
SizedBox(
width: 12.w,
),
4 years ago
Expanded(
child: Text(
4 years ago
(orderInfo != null && orderInfo.addressExt != null)
? (orderInfo.addressExt.recMobile ?? "")
: "",
4 years ago
overflow: TextOverflow.ellipsis,
4 years ago
style: TextStyle(
fontSize: 14.sp,
color: Color(0xFF4C4C4C),
),
4 years ago
),
),
Icon(
Icons.keyboard_arrow_right,
size: 16,
color: Colors.black,
4 years ago
),
4 years ago
],
),
Container(
4 years ago
margin: EdgeInsets.only(left: 28.w),
4 years ago
child: Text(
4 years ago
(orderInfo != null && orderInfo.addressExt != null)
? (orderInfo.addressExt.address ?? "")
: "",
4 years ago
overflow: TextOverflow.ellipsis,
4 years ago
style: TextStyle(
fontSize: 10.sp,
color: Color(0xFFA29E9E),
),
4 years ago
),
),
4 years ago
Visibility(
4 years ago
visible: orderStatus < 5 && refundStatus == 0,
4 years ago
child: Container(
margin: EdgeInsets.only(top: 20.h, bottom: 16.h),
child: MySeparator(
width: 5.w,
height: 1.h,
color: Color(0xFFA29E9E),
),
4 years ago
),
),
4 years ago
Visibility(
4 years ago
visible: orderStatus < 5 && refundStatus == 0,
4 years ago
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
InkWell(
onTap: () {
3 years ago
// showModalBottomSheet(
// context: context,
// builder: (context) {
// return PayInputWidget();
// },
// );
if (payStatus == 0) {
} else if (payStatus < 4) {
SmartDialog.show(
widget: TextImageWidget(
"assets/image/icon_empty.png",
S.of(context).ruxutuikuanqingyumendianlianxi,
"",
S.of(context).zhidianmendian,
(open) {
if (open) {
String mobile = (orderInfo != null &&
orderInfo.storeVO != null)
3 years ago
? (orderInfo.storeVO.mobile ?? "")
: "";
if (mobile != "") {
callMobile(mobile);
}
}
SmartDialog.dismiss();
},
leftText: S.of(context).quxiao,
width: MediaQuery.of(context).size.width - 30.w,
heightRatioWithWidth: 0.9,
),
);
}
4 years ago
},
child: Column(
children: [
Image.asset(
payStatus == 0
? "assets/image/icon_order_cancel.png"
: "assets/image/icon_request_refund.png",
width: 24.w,
height: 24.h,
fit: BoxFit.contain,
4 years ago
),
4 years ago
SizedBox(
height: 8.h,
),
Text(
payStatus == 0
? S.of(context).quxiaodingdan
: S.of(context).shenqingtuikuan,
style: TextStyle(
color: Color(0xFF353535),
fontSize: 12.sp,
),
),
],
),
4 years ago
),
4 years ago
GestureDetector(
onTap: () {
if (payStatus == 0) {
carryOnPay();
} else {}
},
child: Column(
children: [
Image.asset(
payStatus == 0
? "assets/image/icon_order_renminbi.png"
: "assets/image/icon_order_agin.png",
width: 24.w,
height: 24.h,
fit: BoxFit.contain,
4 years ago
),
4 years ago
SizedBox(
height: 8.h,
),
Text(
payStatus == 0
? S.of(context).jixuzhifu
: S.of(context).zailaiyidan,
style: TextStyle(
color: Color(0xFF32A060),
fontSize: 12.sp,
),
),
],
),
4 years ago
),
4 years ago
],
),
4 years ago
),
],
),
);
}
3 years ago
callMobile(mobile) async {
String url = "tel:$mobile";
if (await canLaunch(url)) {
await launch(url);
} else {
throw 'Could not launch $url';
}
}
4 years ago
Widget buildCommodity() {
return Stack(
alignment: Alignment.centerRight,
children: [
Container(
3 years ago
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,
),
4 years ago
decoration: BoxDecoration(
4 years ago
color: Colors.white,
boxShadow: [
BoxShadow(
4 years ago
color: Colors.black.withAlpha(12),
offset: Offset(0, 1),
blurRadius: 12,
spreadRadius: 0,
)
4 years ago
],
3 years ago
borderRadius: BorderRadius.circular(8),
4 years ago
),
4 years ago
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: commodityList(),
),
),
4 years ago
Visibility(
child: buildQrCode(),
visible: false,
),
4 years ago
],
);
}
List<Widget> commodityList() {
4 years ago
if (orderInfo == null) return [];
List<Widget> widgets = [];
if (orderInfo.productList != null) {
4 years ago
widgets
.addAll(orderInfo.productList.map((e) => commodityItem(e)).toList());
4 years ago
}
widgets.add(SizedBox(height: 20.h));
4 years ago
4 years ago
if (orderInfo.isTakeOut != 0) {
// 配送费
3 years ago
widgets.add(discountItem(
Color(0xFFFF7A1A),
orderInfo.isTakeOut == 1
? S.of(context).peisongfei
: S.of(context).yunfei,
"",
"+${orderInfo.postFee}"));
4 years ago
}
4 years ago
if (orderInfo.orderDetail != null &&
orderInfo.orderDetail.couponDTO != null) {
// 配送费
widgets.add(discountItem(
Color(0xFF32A060),
"优惠券",
orderInfo.orderDetail.couponDTO.name,
orderInfo.orderDetail.couponDTO.money));
4 years ago
}
4 years ago
if (orderInfo.storeVO != null && orderInfo.storeVO.couponVO != null) {
4 years ago
// widgets.add(discountItem(Color(0xFF32A060),
// orderInfo.storeVO.couponVO.storeName,
// S.of(context).huodongjianmianpeisongfei(orderInfo.storeVO.couponVO.discountAmount),
// orderInfo.storeVO.couponVO.f));
4 years ago
// Color(0xFFFF7A1A)
}
widgets.add(Container(
margin: EdgeInsets.only(
top: 24.h,
bottom: 4.h,
),
child: MySeparator(
height: 1,
width: 5.w,
color: Colors.grey,
4 years ago
),
4 years ago
));
widgets.add(buildTotalPrice());
return widgets;
4 years ago
}
Widget buildQrCode() {
return Container(
4 years ago
margin: EdgeInsets.only(right: 16.w),
4 years ago
child: Stack(
children: [
Container(
4 years ago
width: 94.w,
height: 33.h,
margin: EdgeInsets.only(left: 12.w),
padding: EdgeInsets.only(left: 16.w),
4 years ago
decoration: BoxDecoration(
4 years ago
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),
),
),
4 years ago
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Text(
S.of(context).qujianma,
style: TextStyle(
3 years ago
fontWeight: FontWeight.bold,
fontSize: 12.sp,
color: Colors.black,
),
4 years ago
),
Icon(
Icons.keyboard_arrow_right,
color: Colors.black,
size: 16,
)
],
),
),
Container(
3 years ago
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),
),
),
4 years ago
],
),
);
}
Widget buildOrderInfo() {
return Container(
margin: EdgeInsets.only(left: 16.w, right: 16.w, top: 8.h, bottom: 8.h),
4 years ago
padding:
EdgeInsets.only(left: 20.w, right: 20.w, top: 12.h, bottom: 12.h),
4 years ago
decoration: BoxDecoration(
4 years ago
color: Colors.white,
boxShadow: [
BoxShadow(
color: Colors.black.withAlpha(12),
offset: Offset(0, 1),
blurRadius: 12,
spreadRadius: 0,
)
],
3 years ago
borderRadius: BorderRadius.circular(8),
4 years ago
),
4 years ago
child: Column(
children: [
orderInfoItem(
S.of(context).dingdanhao, orderInfo != null ? orderInfo.id : ""),
orderInfoItem(S.of(context).xiadanshijian,
orderInfo != null ? orderInfo.createTime : ""),
// orderInfoItem(S.of(context).peisongfangshi, orderInfo != null ? orderInfo.createTime : ""),
orderInfoItem(
S.of(context).beizhu,
orderInfo != null
? orderInfo.notes ?? S.of(context).qingshurubeizhuyaoqiu
: S.of(context).qingshurubeizhuyaoqiu),
orderInfoItem(S.of(context).zhifufangshi,
orderInfo != null ? payChannel() : S.of(context).yue),
4 years ago
],
),
);
}
String payChannel() {
switch (orderInfo.payChannel) {
case 0:
return "现金支付";
case 1:
return "微信支付";
case 2:
return "支付宝支付";
case 3:
return "商户会员余额支付";
case 4:
return "平台会员余额支付";
case 5:
return "美团买单";
case 6:
return "饿了么支付";
case 7:
return "扫呗支付";
case 8:
return "微生活";
case 9:
return "银联支付";
}
return S.of(context).yue;
}
4 years ago
Widget orderInfoItem(leftText, rightText) {
return Container(
4 years ago
margin: EdgeInsets.only(top: 8.h, bottom: 8.h),
4 years ago
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Text(
leftText,
style: TextStyle(
4 years ago
fontWeight: FontWeight.bold,
fontSize: 12.sp,
color: Color(0xFF727272),
),
4 years ago
),
Expanded(
child: Text(
rightText,
textAlign: TextAlign.end,
style: TextStyle(
4 years ago
fontSize: 12.sp,
4 years ago
color: Color(0xFF353535),
),
),
flex: 1,
),
3 years ago
// SizedBox(
// width: 16.w,
// ),
// Icon(
// Icons.keyboard_arrow_right,
// size: 16,
// color: Colors.black,
// )
4 years ago
],
),
);
}
Widget commodityItem(ProductList productList) {
4 years ago
return Container(
4 years ago
margin: EdgeInsets.only(top: 8.h, bottom: 8.h),
4 years ago
child: Row(
children: [
4 years ago
MImage(
productList.skuImg,
4 years ago
width: 44.w,
height: 44.w,
fit: BoxFit.cover,
errorSrc: "assets/image/default_1.png",
fadeSrc: "assets/image/default_1.png",
4 years ago
),
Expanded(
flex: 1,
child: Container(
3 years ago
margin: EdgeInsets.only(
left: 16.w,
),
4 years ago
height: 44.h,
4 years ago
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceAround,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Text(
productList.productName,
4 years ago
style: TextStyle(
4 years ago
fontWeight: FontWeight.bold,
fontSize: 14.sp,
color: Color(0xFF353535),
),
4 years ago
),
Text(
"x${productList.buyNum}",
4 years ago
style: TextStyle(
fontSize: 12.sp,
color: Color(0xFF727272),
),
4 years ago
),
],
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Expanded(
4 years ago
flex: 1,
child: Text(
3 years ago
productList.weight != null
? "${productList.weight}kg"
: "",
4 years ago
overflow: TextOverflow.ellipsis,
style: TextStyle(
fontSize: 12.sp,
color: Color(0xFFA29E9E),
),
),
),
4 years ago
Text(
4 years ago
S.of(context).yuan_(productList.sellPrice),
4 years ago
style: TextStyle(
4 years ago
fontWeight: FontWeight.bold,
fontSize: 12.sp,
color: Color(0xFF4C4C4C),
),
4 years ago
)
],
),
],
),
),
),
],
),
);
}
4 years ago
Widget discountItem(Color color, textName, condition, amount) {
4 years ago
return Container(
4 years ago
margin: EdgeInsets.only(top: 9.h, bottom: 9.h),
4 years ago
child: Row(
children: [
Container(
4 years ago
padding: EdgeInsets.fromLTRB(4.w, 2.h, 4.w, 2.h),
4 years ago
decoration: BoxDecoration(
4 years ago
borderRadius: BorderRadius.all(Radius.circular(2)),
4 years ago
border: Border.all(
width: 1,
color: color,
style: BorderStyle.solid,
),
4 years ago
),
4 years ago
child: Text(
4 years ago
textName,
4 years ago
style: TextStyle(
4 years ago
fontSize: 10.sp,
4 years ago
color: color,
),
),
),
SizedBox(
4 years ago
width: 27.w,
4 years ago
),
Expanded(
child: Text(
4 years ago
condition,
4 years ago
style: TextStyle(
4 years ago
fontSize: 10.sp,
4 years ago
color: Color(0xFFA29E9E),
),
),
flex: 1,
),
Text(
4 years ago
S.of(context).yuan_("$amount"),
4 years ago
style: TextStyle(
4 years ago
fontSize: 12.sp,
4 years ago
color: color,
),
),
],
),
);
}
Widget buildTotalPrice() {
return Container(
4 years ago
margin: EdgeInsets.only(top: 7.h, bottom: 11.h),
4 years ago
child: Row(
mainAxisAlignment: MainAxisAlignment.end,
crossAxisAlignment: CrossAxisAlignment.baseline,
textBaseline: TextBaseline.alphabetic,
children: [
Expanded(
child: Text(
4 years ago
S.of(context).gongjijianshangpin(
(orderInfo != null && orderInfo.productList != null)
? orderInfo.productList.length
: "0"),
4 years ago
style: TextStyle(
4 years ago
fontSize: 10.sp,
4 years ago
color: Color(0xFFA29E9E),
),
),
flex: 1,
),
Container(
child: Text(
S.of(context).jiesuanjine,
style: TextStyle(
4 years ago
fontSize: 10.sp,
4 years ago
color: Color(0xFF353535),
),
),
),
3 years ago
SizedBox(
width: 5.w,
),
4 years ago
Text(
4 years ago
totalPrice(),
4 years ago
textAlign: TextAlign.end,
style: TextStyle(
4 years ago
fontSize: 30.sp,
4 years ago
color: Color(0xFF32A060),
),
)
],
),
);
}
4 years ago
String totalPrice() {
if (orderInfo == null) return "";
double totalPrice = (double.tryParse(orderInfo.orderSum) +
double.tryParse(orderInfo.postFee));
if (orderInfo.orderDetail != null &&
orderInfo.orderDetail.couponDTO != null) {
totalPrice -= double.tryParse(orderInfo.orderDetail.couponDTO.money);
}
return "$totalPrice";
}
4 years ago
}