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.

869 lines
28 KiB

import 'package:dio/dio.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
3 years ago
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
import 'package:huixiang/generated/l10n.dart';
import 'package:huixiang/order/order_view/order_commodity.dart';
import 'package:huixiang/retrofit/data/base_data.dart';
import 'package:huixiang/retrofit/data/order_info.dart';
3 years ago
import 'package:huixiang/retrofit/data/settleOrderInfo.dart';
3 years ago
import 'package:huixiang/retrofit/data/store_info.dart';
3 years ago
import 'package:huixiang/retrofit/min_api.dart';
import 'package:huixiang/retrofit/retrofit_api.dart';
import 'package:huixiang/utils/font_weight.dart';
import 'package:huixiang/view_widget/my_appbar.dart';
3 years ago
import 'package:huixiang/view_widget/rename_dialog.dart';
import 'package:huixiang/view_widget/rename_dialog_content.dart';
import 'package:huixiang/view_widget/round_button.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
class Settlement extends StatefulWidget {
final arguments;
final OrderInfo orderInfo;
Settlement({this.arguments,this.orderInfo});
@override
State<StatefulWidget> createState() {
return _Settlement();
}
}
class _Settlement extends State<Settlement> {
ApiService apiService;
3 years ago
MinApiService minService;
int selectedBtn = 0;
@override
void initState() {
super.initState();
SharedPreferences.getInstance().then((value) {
3 years ago
minService = MinApiService(
Dio(),
context: context,
token: value.getString("token"),
);
3 years ago
queryOrderInfo();
});
}
OrderInfo orderInfo;
3 years ago
StoreInfo storeInfo;
int payStatus = 0;
int orderStatus = 0;
int sendStatus = 0;
int isTakeOut = 0;
int refundStatus = 0;
// String storeType = "NORMALSTORE"; //NORMALSTORE FASTSTORE RETAILSTORE
queryDetails() async {
3 years ago
BaseData<OrderInfo> baseData = await apiService.orderDetail(widget.arguments["id"]);
if (baseData != null && baseData.isSuccess) {
orderInfo = baseData.data;
payStatus = orderInfo.payStatus;
orderStatus = orderInfo.orderStatus;
sendStatus = orderInfo.sendStatus;
isTakeOut = orderInfo.isTakeOut;
refundStatus = orderInfo.refundStatus;
// storeType = orderInfo.storeVO.posType.code;
print("order refund_status: $refundStatus");
print("order payStatus: $payStatus");
print("order orderStatus: $orderStatus");
print("order sendStatus: $sendStatus");
print("order isTakeOut: $isTakeOut");
if (mounted)
setState(() {
statusTitle();
});
}
}
3 years ago
///订单结算信息
queryOrderInfo() async {
BaseData<SettleOrderInfo> baseData = await minService.getOrderInfo({
"addressId":0,
"isTake": 0,
"memberCouponId": 0,
"orderId": widget.arguments["orderId"],
"promotionId": 0
});
if (baseData != null && baseData.isSuccess) {
setState(() {});
}
}
@override
Widget build(BuildContext context) {
return Stack(
children: [
Positioned(
top: 0,
left: 0,
right: 0,
child: Container(
height: (orderStatus >= 4 ? 118.h : 118.h) +
MediaQuery.of(context).padding.top +
kToolbarHeight +
48.h,
color: Color(0xFF3A405A),
width: MediaQuery.of(context).size.width,
),
),
Positioned(
child: Scaffold(
backgroundColor: Colors.transparent,
appBar: MyAppBar(
background: Color(0xFF3A405A),
leadingColor: Colors.white,
title:S.of(context).dingdanjiesuan,
titleColor: Colors.white,
titleSize: 18.sp,
),
body: Container(
child: SingleChildScrollView(
physics: BouncingScrollPhysics(),
child: Container(
child: Column(
children: [
distributionMode(),
SizedBox(height: 14,),
///订单商品
OrderCommodity(orderInfo),
// if (payStatus == 0) couponRemarks(),
/*(payStatus == 0) ? paySelector() : */
3 years ago
///优惠券/备注
activityRemarks(),
3 years ago
///支付方式
payMethod(),
],
),
),
),
),
),
left: 0,
right: 0,
top: 0,
bottom: 0,
),
Positioned(
bottom: 0,
left: 0,
right: 0,
child:
Container(
height: 54.h,
color: Colors.white,
child: Row(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Spacer(),
Text(
S.of(context).heji,
style: TextStyle(
fontSize: 12.sp,
fontWeight: MyFontWeight.regular,
color: Colors.black,
),
),
Text(
"¥19.00",
style: TextStyle(
fontSize: 20.sp,
fontWeight: MyFontWeight.semi_bold,
color: Color(0xFF32A060),
),
),
SizedBox(width: 28,),
GestureDetector(
onTap: () {
},
child: RoundButton(
width: 103.w,
height: 54.h,
text: S.current.jiesuan,
textColor: Colors.white,
fontWeight: MyFontWeight.regular,
backgroup: Color(0xFF32A060),
fontSize: 16.sp,
padding: EdgeInsets.symmetric(vertical: 5.h),
),
),
],
),
),
)
],
);
}
String title = "";
String center = "";
3 years ago
TextEditingController _vc = TextEditingController();
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;
center = S.of(context).qudanhao(orderInfo.dayFlowCode);
break;
case 4:
title = S.of(context).dingdanyiwancheng;
center = S.of(context).dingdanyiwancheng;
break;
case 5:
title = S.of(context).yiquxiao;
center = S.of(context).yiquxiao;
break;
}
}
} else if (isTakeOut == 1) {
if (payStatus == 0) {
title = S.of(context).dingdandaizhifu;
} else {
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;
}
}
} else if (isTakeOut == 2) {
if (payStatus == 0) {
title = S.of(context).dingdandaizhifu;
} else {
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;
}
}
}
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;
}
}
Widget distributionMode() {
return Container(
decoration: BoxDecoration(
color: Color(0xFFFAFAFA),
boxShadow: [
BoxShadow(
color: Color(0x0D000000),
offset: Offset(0, 3),
blurRadius: 14,
spreadRadius: 0,
),
],
borderRadius: BorderRadius.circular(8),
),
height: 175.h,
margin: EdgeInsets.only(left: 16, right: 16, top: 15),
child: Stack(
children: [
Column(
children: [
Container(
decoration: BoxDecoration(
color: Color(0xFF9C9FAC),
borderRadius: BorderRadius.only(
topLeft: Radius.circular(8),
topRight: Radius.circular(8),
),
),
height: 50.h,
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Expanded(
flex: 1,
child: Container(
height: 50.h,
decoration: BoxDecoration(
image: selectedBtn == 0
? DecorationImage(
image: AssetImage(
"assets/image/order_btn1.png"),
fit: BoxFit.fill,
)
: null,
borderRadius: BorderRadius.only(
topLeft: Radius.circular(8))),
child: GestureDetector(
onTap: () {
setState(() {
selectedBtn = 0;
});
},
child: Stack(
alignment: Alignment.center,
children: [
Text(
S.of(context).daodianziqu,
style: TextStyle(
fontSize: 14.sp,
fontWeight: MyFontWeight.semi_bold,
color: Colors.black,
),
),
],
),
)),
),
Expanded(
flex: 1,
child: GestureDetector(
onTap: () {
setState(() {
selectedBtn = 1;
});
},
child: Stack(
alignment: Alignment.center,
children: [
if (selectedBtn == 1)
Image.asset(
"assets/image/order_btn2.png",
height: 50.h,
fit: BoxFit.fill,
),
Text(
S.of(context).waimaipeisong,
style: TextStyle(
fontSize: 14.sp,
fontWeight: MyFontWeight.regular,
color: Colors.black,
),
),
],
),
),
),
Expanded(
flex: 1,
child: Container(
height: 50.h,
decoration: BoxDecoration(
image: selectedBtn == 2
? DecorationImage(
image: AssetImage(
"assets/image/order_btn3.png"),
fit: BoxFit.fill,
)
: null,
borderRadius: BorderRadius.only(
topRight: Radius.circular(8))),
child: GestureDetector(
onTap: () {
setState(() {
3 years ago
// selectedBtn = 2;
SmartDialog.showToast("该功能暂未开放!", alignment: Alignment.center);
});
},
child: Stack(
alignment: Alignment.center,
children: [
Text(
S.of(context).kuaidiwuliu,
style: TextStyle(
fontSize: 14.sp,
fontWeight: MyFontWeight.regular,
color: Colors.black,
),
),
],
),
)),
),
],
),
),
3 years ago
selectedBtn == 0 ?
Container(
width: double.infinity,
padding: EdgeInsets.only(left: 16, right: 16, top: 15),
child: Column(
children: [
Row(
children: [
Expanded(child:Column(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
3 years ago
storeInfo != null ? (storeInfo.storeName ?? "") : "",
overflow: TextOverflow.ellipsis,
style: TextStyle(
fontSize: 14.sp,
fontWeight: MyFontWeight.semi_bold,
color: Color(0xFF4C4C4C),
),
),
SizedBox(
height: 4,
),
Text(
3 years ago
storeInfo != null ? storeInfo.address : "",
overflow: TextOverflow.ellipsis,
maxLines: 2,
style: TextStyle(
fontSize: 12.sp,
fontWeight: MyFontWeight.regular,
color: Color(0xFF727272),
),
),
SizedBox(
height: 12,
),
],
),),
SizedBox(
width: 18,
),
Stack(
alignment: Alignment.center,
children: [
Column(
children: [
Image.asset(
"assets/image/map.png",
height: 61.h,
width:61.w,
),
],
),
Column(children: [
RoundButton(
width: 41.w,
height: 13,
text: "距离您11m",
textColor:Color(0xFF34A262),
fontWeight: MyFontWeight.semi_bold,
radius:7.5,
backgroup:Colors.white,
fontSize:7.sp,
),
Image.asset(
"assets/image/landmark.png",
height: 24.h,
width:24.w,
),
],),
],
)
],
),
Row(
children: [
Expanded(child: Text(
S.of(context).yuliudianhua,
overflow: TextOverflow.ellipsis,
style: TextStyle(
fontSize: 14.sp,
fontWeight: MyFontWeight.regular,
color: Color(0xFF4C4C4C),
),
)),
Text(
3 years ago
storeInfo != null ? storeInfo.headMobile:"",
style: TextStyle(
fontSize: 14.sp,
fontWeight: MyFontWeight.medium,
color: Color(0xFF4C4C4C),
),
),
3 years ago
GestureDetector(
onTap: (){
showAlertDialog();
},
child:Image.asset(
"assets/image/pen.png",
height:14.h,
width:14.w,
),
),
],
)
],
),
3 years ago
)
: Container(
width: double.infinity,
padding: EdgeInsets.only(left: 16, right: 16, top: 15),
child: Column(
children: [
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Image.asset(
"assets/image/icon_permission_location.png",
height:24.h,
width:24.w,
), Text(
"张先生",
overflow: TextOverflow.ellipsis,
style: TextStyle(
fontSize: 15.sp,
fontWeight: MyFontWeight.medium,
color: Color(0xFF4C4C4C),
),
),
SizedBox(
width: 13,
),
Expanded(child: Text(
"12309090909",
overflow: TextOverflow.ellipsis,
maxLines: 2,
style: TextStyle(
fontSize: 15.sp,
fontWeight: MyFontWeight.medium,
color: Color(0xFF4C4C4C),
),
),),
Icon(
Icons.keyboard_arrow_right,
size:24,
),
],
),
Padding(padding:EdgeInsets.only(top: 4,left:25),
child: Text(
"武昌区中国铁建凯德1818蓝调步行街中北路109附33门牌号05",
overflow: TextOverflow.ellipsis,
maxLines: 2,
style: TextStyle(
fontSize: 12.sp,
fontWeight: MyFontWeight.regular,
color: Color(0xFF727272),
),
),),
],
),
),
],
),
],
),
);
}
Widget activityRemarks(){
return Container(
decoration: BoxDecoration(
color: Colors.white,
boxShadow: [
BoxShadow(
color: Color(0x0D000000),
offset: Offset(0, 3),
blurRadius: 14,
spreadRadius: 0,
),
],
borderRadius: BorderRadius.circular(8),
),
height: 86.h,
margin: EdgeInsets.only(left: 16, right: 16, top: 15),
padding: EdgeInsets.only(left: 16, right: 16, top: 16),
child: Column(
children: [
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(
"满30减10",
textAlign: TextAlign.end,
style: TextStyle(
fontSize: 14.sp,
color: Color(0xFF32A060),
fontWeight: MyFontWeight.semi_bold
),
),
Icon(
Icons.keyboard_arrow_right,
size: 16,
),
],
),
SizedBox(height: 13,
),
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),
),
)),
Text(
"口味、面包硬度等",
textAlign: TextAlign.end,
style: TextStyle(
fontSize: 14.sp,
color: Color(0xFF353535),
fontWeight: MyFontWeight.semi_bold
),
),
Icon(
Icons.keyboard_arrow_right,
size: 16,
),
],
),
],
),
);
}
Widget payMethod(){
return Container(
width: double.infinity,
margin: EdgeInsets.only(
left: 16.w,
right: 16.w,
top: 12.h,
bottom: 4.h,
),
padding: EdgeInsets.only(
left: 16.w,
right: 16.w,
top: 20.h,
bottom: 20.h,
),
decoration: BoxDecoration(
boxShadow: [
BoxShadow(
color: Color(0x000000).withAlpha(25),
offset: Offset(0, 1),
blurRadius: 12.0,
),
],
color: Colors.white,
borderRadius: BorderRadius.circular(8),
),
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceAround,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Padding(
padding: EdgeInsets.only(bottom: 16.h),
child: Text(
S.of(context).zhifufangshi,
style: TextStyle(
fontSize: 16.sp,
color: Colors.black,
fontWeight:MyFontWeight.regular,
),
),
),
GestureDetector(
onTap: () {
setState(() {
checkIndex =1;
});
},
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
checkView(1),
Text(
S.of(context).pingtaiyue,
style: TextStyle(
fontSize: 14.sp,
color: Color(0xff353535),
fontWeight: MyFontWeight.semi_bold
),
),
],
),
),
SizedBox(height: 10,),
GestureDetector(
onTap: () {
setState(() {
checkIndex =2;
});
},
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
checkView(2),
Text(
S.of(context).dianpuyue,
style: TextStyle(
fontSize: 14.sp,
color: Color(0xff353535),
fontWeight: MyFontWeight.semi_bold,
),
),
],
),
),
SizedBox(height: 10,),
GestureDetector(
onTap: () {
setState(() {
checkIndex = 3;
});
},
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
checkView(3),
Spacer(),
Image.asset("assets/image/icon_we_chat.png"),
Padding(
padding: EdgeInsets.only(left: 8.w),
child: Text(
S.of(context).weixinzhifu,
style: TextStyle(
fontSize: 14.sp,
color: Color(0xff353535),
fontWeight: MyFontWeight.semi_bold,
),
),
),
],
),
),
],
),
);
}
3 years ago
showAlertDialog() {
//显示对话框
showDialog(
barrierDismissible: false,
context: context,
builder: (context) {
return RenameDialog(
contentWidget: RenameDialogContent(
title: "请输入新的手机号码",
okBtnTap: () {
// print(
// "输入框中的文字为:${_vc.text}",
// );
},
vc: _vc,
cancelBtnTap: () {},
),
);
});
}
var checkIndex = 1;
Widget checkView(var index) {
return Container(
padding: EdgeInsets.only(right: 16.w),
alignment: Alignment.center,
child: Image.asset(
checkIndex != index
? "assets/image/icon_radio_unselected.png"
: "assets/image/icon_radio_selected.png",
width: 15.w,
height: 15.h,
),
);
}
String payChannel() {
switch (widget.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;
}
}