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.

1350 lines
49 KiB

import 'package:dio/dio.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
3 years ago
import 'package:flutter/services.dart';
3 years ago
import 'package:flutter_baidu_mapapi_base/flutter_baidu_mapapi_base.dart';
import 'package:flutter_baidu_mapapi_utils/flutter_baidu_mapapi_utils.dart';
3 years ago
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
3 years ago
import 'package:flutter_svg/flutter_svg.dart';
import 'package:huixiang/generated/l10n.dart';
3 years ago
import 'package:huixiang/retrofit/data/address.dart';
import 'package:huixiang/retrofit/data/base_data.dart';
3 years ago
import 'package:huixiang/retrofit/data/findMiNiGroupList.dart';
3 years ago
import 'package:huixiang/retrofit/data/placeOrderFirst.dart';
3 years ago
import 'package:huixiang/retrofit/data/settleOrderInfo.dart';
3 years ago
import 'package:huixiang/retrofit/data/settlement_bean.dart';
import 'package:huixiang/retrofit/data/shoppingCart.dart';
3 years ago
import 'package:huixiang/retrofit/data/store_info.dart';
3 years ago
import 'package:huixiang/retrofit/min_api.dart';
3 years ago
import 'package:huixiang/settlement/settlement_view/settlement_order_commodity.dart';
import 'package:huixiang/utils/font_weight.dart';
3 years ago
import 'package:huixiang/utils/location.dart';
import 'package:huixiang/view_widget/my_appbar.dart';
import 'package:huixiang/view_widget/round_button.dart';
3 years ago
import 'package:huixiang/view_widget/separator.dart';
3 years ago
import 'package:intl/intl.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
class Settlement extends StatefulWidget {
final arguments;
3 years ago
Settlement({this.arguments});
@override
State<StatefulWidget> createState() {
return _Settlement();
}
}
class _Settlement extends State<Settlement> {
3 years ago
MinApiService minService;
int selectedBtn = 0;
3 years ago
Function(int type) callback;
3 years ago
StoreInfo storeInfo;
SettleOrderInfo settleOrderInfo;
3 years ago
int selectedCouponIndex = -1;
3 years ago
TextEditingController _vc;
List<String> addressBgs = [
"assets/svg/dingdan_ziqu.svg",
"assets/svg/dingdan_waimai.svg",
"assets/svg/dingdan_wuliu.svg",
];
@override
void initState() {
super.initState();
3 years ago
storeInfo = widget.arguments["storeInfo"];
3 years ago
_vc = TextEditingController(
text: storeInfo != null ? storeInfo.headMobile : "");
SharedPreferences.getInstance().then((value) {
3 years ago
String minToken = value.getString("minToken");
String tenant = value.getString("tenant");
3 years ago
String storeId = value.getString("storeId");
3 years ago
minService = MinApiService(
Dio(),
context: context,
3 years ago
token: minToken,
tenant: tenant,
3 years ago
storeId: storeId,
);
3 years ago
queryOrderInfo(null, selectedBtn, null, 0, null);
});
startLocation();
}
BMFCoordinate myLatLng;
String distance = "0";
///定位获取当前的位置
void startLocation() async {
Location.getInstance()
.aMapFlutterLocation
.onResultCallback()
.listen((event) {
if (event != null &&
event["latitude"] != null &&
event["longitude"] != null) {
print("location: $event");
if (event["latitude"] is String && event["longitude"] is String) {
myLatLng = BMFCoordinate(double.tryParse(event["latitude"]),
double.tryParse(event["longitude"]));
} else {
myLatLng = BMFCoordinate(event["latitude"], event["longitude"]);
}
calculateDistance();
}
});
3 years ago
Location.getInstance().prepareLoc();
Location.getInstance().startLocation(context);
}
///计算距离(当前位置到店位置直线距离)
calculateDistance() async {
BMFCoordinate bmfCoordinate = BMFCoordinate(
double.tryParse(storeInfo.latitude),
double.tryParse(storeInfo.longitude));
double mi =
await BMFCalculateUtils.getLocationDistance(bmfCoordinate, myLatLng);
NumberFormat numberFormat = NumberFormat("#.#");
distance = "${numberFormat.format(mi / 1000)}";
print("distance: $distance");
setState(() {});
Location.getInstance().stopLocation();
}
3 years ago
///订单结算信息
3 years ago
queryOrderInfo(
addressId, isTake, memberCouponId, orderId, promotionId) async {
3 years ago
BaseData<SettleOrderInfo> baseData = await minService.getOrderInfo({
3 years ago
"addressId": addressId,
"isTake": isTake,
"memberCouponId": memberCouponId,
"orderId": orderId,
"promotionId": promotionId
3 years ago
});
if (baseData != null && baseData.isSuccess) {
3 years ago
setState(() {
settleOrderInfo = baseData.data;
});
3 years ago
}
3 years ago
}
3 years ago
Address address;
queryAddress() async {
if (address != null) {
queryOrderInfo(address.id, selectedBtn, null, 0, null);
return;
}
BaseData<List<Address>> baseDate =
await minService.queryAddress().catchError((error) {});
BMFCoordinate bmfCoordinate = BMFCoordinate(
double.tryParse(storeInfo.latitude),
double.tryParse(storeInfo.longitude),
);
if (baseDate != null && baseDate.isSuccess) {
address = baseDate.data[0];
for (int i = 1; i < baseDate.data.length; i++) {
Address address1 = baseDate.data[i];
BMFCoordinate coordinate = await BMFCalculateUtils.coordConvert(
coordinate: BMFCoordinate(
double.tryParse(address.longitude),
double.tryParse(address.latitude),
),
fromType: BMF_COORD_TYPE.COMMON,
toType: BMF_COORD_TYPE.BD09LL);
BMFCoordinate coordinate1 = await BMFCalculateUtils.coordConvert(
coordinate: BMFCoordinate(
double.tryParse(address1.longitude),
double.tryParse(address1.latitude),
),
fromType: BMF_COORD_TYPE.COMMON,
toType: BMF_COORD_TYPE.BD09LL);
double mi = await BMFCalculateUtils.getLocationDistance(
bmfCoordinate, coordinate);
double mi1 = await BMFCalculateUtils.getLocationDistance(
bmfCoordinate, coordinate1);
print("address 1111: $mi");
print("address 11: $mi1");
if (mi1 < mi) {
address = address1;
}
}
queryOrderInfo(address.id, selectedBtn, null, 0, null);
}
}
3 years ago
///小程序下单
queryPlaceOrderFirst() async {
PlaceOrderFirst placeOrderFirst = PlaceOrderFirst();
placeOrderFirst.addressId = null;
placeOrderFirst.isSubscribe = false;
placeOrderFirst.isTakeOut = 0;
placeOrderFirst.notes = "";
placeOrderFirst.numberOfPeople = null;
placeOrderFirst.orderSource = 0;
placeOrderFirst.orderType = 0;
placeOrderFirst.orderTypeId = 0;
placeOrderFirst.parentCode = "";
placeOrderFirst.parentId = 0;
placeOrderFirst.payChannel = 1;
placeOrderFirst.promotionInfoDTO = PlaceOrderFirstPromotionInfoDTO();
3 years ago
placeOrderFirst.promotionInfoDTO.couponId = selectedCouponIndex == -1
? null
: settleOrderInfo.couponList[selectedCouponIndex].couponId;
3 years ago
placeOrderFirst.promotionInfoDTO.promotionId = "0";
placeOrderFirst.recMobile = storeInfo.headMobile;
placeOrderFirst.shoppingCartSkuItemList = [];
placeOrderFirst.skuItemDTOList = [];
3 years ago
3 years ago
placeOrderFirst.source = 1;
placeOrderFirst.storeId = storeInfo.id;
placeOrderFirst.subcribeTime = null;
placeOrderFirst.tableId = 0;
3 years ago
BaseData baseData = await minService
.placeOrderFirst(placeOrderFirst.toJson())
.catchError((error) {});
3 years ago
if (baseData != null && baseData.isSuccess) {
querySettlement();
}
}
///结算
querySettlement() async {
SettlementBean settlementBean = SettlementBean();
settlementBean.addressId = 0;
settlementBean.buyNum = 0;
settlementBean.id = 0;
settlementBean.isLogistics = true;
settlementBean.orderProductVOList = [];
3 years ago
3 years ago
settlementBean.payChannel = 0;
settlementBean.promotionInfoDTO = PromotionInfoDTO();
settlementBean.promotionInfoDTO.couponId = 0;
settlementBean.promotionInfoDTO.promotionId = 0;
3 years ago
BaseData baseData =
await minService.settlementApi({}).catchError((error) {});
if (baseData != null && baseData.isSuccess) {}
3 years ago
}
3 years ago
bool isEdit = false;
@override
Widget build(BuildContext context) {
return Stack(
children: [
Positioned(
top: 0,
left: 0,
right: 0,
child: Container(
3 years ago
height: 175.h,
color: Color(0xFF3A405A),
width: MediaQuery.of(context).size.width,
),
),
Positioned(
child: Scaffold(
backgroundColor: Colors.transparent,
appBar: MyAppBar(
background: Color(0xFF3A405A),
leadingColor: Colors.white,
3 years ago
title: S.of(context).dingdanjiesuan,
titleColor: Colors.white,
3 years ago
brightness: Brightness.dark,
titleSize: 18.sp,
),
body: Container(
3 years ago
child: Column(
children: [
Expanded(
child: Container(
child: SingleChildScrollView(
physics: BouncingScrollPhysics(),
child: Container(
child: Column(
children: [
distributionMode(),
SizedBox(
height: 16,
),
3 years ago
3 years ago
/// 预留的手机号, 可修改
phoneWidget(),
3 years ago
///订单商品
SettlementOrderCommodity(
0,
settleOrderInfo,
),
// if (payStatus == 0) couponRemarks(),
/*(payStatus == 0) ? paySelector() : */
3 years ago
///优惠券/备注
activityRemarks(),
3 years ago
///支付方式
payMethod(),
],
),
),
),
),
flex: 1,
),
3 years ago
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(
"${settleOrderInfo.orderSum}",
style: TextStyle(
fontSize: 20.sp,
fontWeight: MyFontWeight.semi_bold,
color: Color(0xFF32A060),
),
),
SizedBox(
width: 28,
),
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,
),
callback: () {},
),
],
),
),
],
),
),
),
left: 0,
right: 0,
top: 0,
bottom: 0,
),
],
);
}
3 years ago
/// 预留的手机号, 可修改
Widget phoneWidget() {
return Container(
margin: EdgeInsets.only(
left: 16,
right: 16,
),
decoration: BoxDecoration(
color: Colors.white,
boxShadow: [
BoxShadow(
color: Color(0x0D000000),
offset: Offset(0, 3),
blurRadius: 14,
spreadRadius: 0,
),
],
borderRadius: BorderRadius.circular(8),
),
padding: EdgeInsets.symmetric(
horizontal: 12.w,
vertical: 15.h,
),
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Text(
S.of(context).yuliudianhua,
overflow: TextOverflow.ellipsis,
style: TextStyle(
fontSize: 14.sp,
fontWeight: MyFontWeight.regular,
color: Color(0xFF4C4C4C),
),
),
SizedBox(
width: 50,
),
Expanded(
child: isEdit
? Container(
height: 25.h,
alignment: Alignment.centerRight,
child: TextField(
controller: _vc,
style: TextStyle(
fontSize: 14.sp,
fontWeight: MyFontWeight.medium,
color: Color(0xFF4C4C4C),
),
textAlign: TextAlign.right,
textAlignVertical: TextAlignVertical.center,
keyboardType: TextInputType.phone,
decoration: InputDecoration(
errorBorder: InputBorder.none,
focusedBorder: InputBorder.none,
enabledBorder: InputBorder.none,
hintText: "",
hintStyle: TextStyle(
fontSize: 10.sp,
color: Color(0xFFA29E9E),
),
),
textInputAction: TextInputAction.next,
inputFormatters: [LengthLimitingTextInputFormatter(11)],
cursorColor: Colors.grey,
),
)
: Container(
height: 25.h,
alignment: Alignment.centerRight,
child: Text(
storeInfo != null ? storeInfo.headMobile : "",
overflow: TextOverflow.ellipsis,
textAlign: TextAlign.end,
style: TextStyle(
fontSize: 14.sp,
fontWeight: MyFontWeight.regular,
color: Color(0xFF4C4C4C),
),
),
),
),
GestureDetector(
onTap: () {
setState(() {
this.isEdit = !this.isEdit;
});
},
child: Container(
padding: EdgeInsets.all(8),
child: isEdit
? Icon(
Icons.check,
size: 14.w,
color: Color(0xFF32A060),
)
: Image.asset(
"assets/image/pen.png",
height: 14.h,
width: 14.w,
),
),
),
],
),
);
}
///配送方式+地址
Widget distributionMode() {
return Container(
3 years ago
height: 143.h,
margin: EdgeInsets.only(
left: 16,
right: 16,
top: 10,
),
child: Stack(
children: [
3 years ago
Container(
decoration: BoxDecoration(
color: Color(0x80FFFFFF),
boxShadow: [
BoxShadow(
color: Color(0x0D000000),
offset: Offset(0, 3),
blurRadius: 14,
spreadRadius: 0,
),
],
borderRadius: BorderRadius.circular(8),
),
child: SvgPicture.asset(
addressBgs[selectedBtn],
width: double.infinity,
height: double.infinity,
fit: BoxFit.fill,
),
),
Column(
children: [
Container(
height: 50.h,
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.center,
3 years ago
mainAxisSize: MainAxisSize.max,
children: [
Expanded(
flex: 1,
3 years ago
child: GestureDetector(
onTap: () {
3 years ago
selectedBtn = 0;
queryOrderInfo(null, selectedBtn, null, 0, null);
3 years ago
},
child: Container(
height: 50.h,
alignment: Alignment.center,
3 years ago
child: Text(
S.of(context).daodianziqu,
style: TextStyle(
fontSize: 14.sp,
fontWeight: MyFontWeight.semi_bold,
color: Colors.black,
),
3 years ago
),
),
),
),
Expanded(
flex: 1,
3 years ago
child: GestureDetector(
onTap: () {
3 years ago
selectedBtn = 1;
queryAddress();
3 years ago
},
child: Container(
height: 50.h,
alignment: Alignment.center,
3 years ago
child: Text(
S.of(context).waimaipeisong,
style: TextStyle(
fontSize: 14.sp,
fontWeight: MyFontWeight.regular,
color: Colors.black,
),
3 years ago
),
),
),
),
Expanded(
flex: 1,
3 years ago
child: GestureDetector(
onTap: () {
SmartDialog.showToast("该功能暂未开放!",
alignment: Alignment.center);
},
child: Container(
height: 50.h,
alignment: Alignment.center,
3 years ago
child: Text(
S.of(context).kuaidiwuliu,
style: TextStyle(
fontSize: 14.sp,
fontWeight: MyFontWeight.regular,
color: Colors.black,
),
3 years ago
),
),
),
),
],
),
),
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:
3 years ago
MainAxisAlignment.spaceEvenly,
3 years ago
crossAxisAlignment: CrossAxisAlignment.start,
3 years ago
mainAxisSize: MainAxisSize.max,
3 years ago
children: [
Text(
storeInfo != null
? (storeInfo.storeName ?? "")
: "",
overflow: TextOverflow.ellipsis,
style: TextStyle(
fontSize: 14.sp,
fontWeight: MyFontWeight.semi_bold,
color: Color(0xFF4C4C4C),
),
),
SizedBox(
3 years ago
height: 6,
3 years ago
),
Text(
storeInfo != null
? storeInfo.address
: "",
overflow: TextOverflow.ellipsis,
maxLines: 2,
style: TextStyle(
fontSize: 12.sp,
fontWeight: MyFontWeight.regular,
color: Color(0xFF727272),
),
),
],
),
),
3 years ago
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,
3 years ago
text: distance.length > 3
? "${distance}km"
: "距离您${distance}km",
3 years ago
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,
),
],
),
],
3 years ago
),
3 years ago
],
3 years ago
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisSize: MainAxisSize.max,
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),
),
),
3 years ago
),
InkWell(
3 years ago
onTap: () {
setState(() {
3 years ago
Navigator.of(context).popAndPushNamed(
'/router/manage_address_page');
3 years ago
});
},
3 years ago
child: Icon(
3 years ago
Icons.keyboard_arrow_right,
size: 24,
),
3 years ago
),
],
),
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),
),
),
3 years ago
),
3 years ago
],
3 years ago
),
3 years ago
),
],
),
],
),
);
}
3 years ago
///活动备注
3 years ago
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,
3 years ago
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: [
3 years ago
Expanded(
flex: 1,
child: Text(
S.of(context).youhuiquan,
style: TextStyle(
fontWeight: MyFontWeight.regular,
fontSize: 14.sp,
color: Color(0xFF353535),
),
),
3 years ago
),
Text(
3 years ago
(settleOrderInfo?.couponList == null ||
settleOrderInfo.couponList.length == 0)
? "暂无可用优惠券"
: (selectedCouponIndex == -1
? "拥有${settleOrderInfo.couponList.length}张优惠券"
: settleOrderInfo
.couponList[selectedCouponIndex].promotionName),
textAlign: TextAlign.end,
style: TextStyle(
fontSize: 14.sp,
color: Color(0xFF32A060),
3 years ago
fontWeight: MyFontWeight.semi_bold,
),
),
3 years ago
InkWell(
onTap: () {
setState(() {
couponCart();
});
},
3 years ago
child: Icon(
3 years ago
Icons.keyboard_arrow_right,
size: 16,
),
),
],
),
3 years ago
SizedBox(
height: 13,
),
Row(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
3 years ago
Expanded(
flex: 1,
child: Text(
S.of(context).beizhu,
style: TextStyle(
fontWeight: MyFontWeight.regular,
fontSize: 14.sp,
color: Color(0xFF353535),
),
),
3 years ago
),
Text(
"口味、面包硬度等",
textAlign: TextAlign.end,
style: TextStyle(
3 years ago
fontSize: 14.sp,
color: Color(0xFF353535),
fontWeight: MyFontWeight.semi_bold,
),
),
Icon(
Icons.keyboard_arrow_right,
size: 16,
),
],
),
],
),
);
}
3 years ago
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,
3 years ago
fontWeight: MyFontWeight.regular,
),
),
),
GestureDetector(
onTap: () {
setState(() {
3 years ago
checkIndex = 1;
});
},
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
checkView(1),
Text(
S.of(context).pingtaiyue,
style: TextStyle(
3 years ago
fontSize: 14.sp,
color: Color(0xff353535),
fontWeight: MyFontWeight.semi_bold),
),
],
),
),
3 years ago
SizedBox(
height: 10,
),
GestureDetector(
onTap: () {
setState(() {
3 years ago
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),
3 years ago
fontWeight: MyFontWeight.semi_bold,
),
),
],
),
),
3 years ago
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),
3 years ago
fontWeight: MyFontWeight.semi_bold,
),
),
),
],
),
),
],
),
);
}
3 years ago
///优惠券弹窗
couponCart() {
showModalBottomSheet(
context: context,
backgroundColor: Colors.transparent,
builder: (context) {
3 years ago
return StatefulBuilder(
builder: (context1, state) {
return Container(
alignment: Alignment.topCenter,
width: double.infinity,
height: MediaQuery.of(context).size.height / 2,
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.only(
topLeft: Radius.circular(8),
topRight: Radius.circular(8),
),
3 years ago
),
3 years ago
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Container(
padding: EdgeInsets.only(
top: 16,
left: 16,
right: 16,
bottom: 8,
),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Expanded(
child: Text(
(settleOrderInfo?.couponList == null ||
settleOrderInfo.couponList.length == 0)
? "暂无可用优惠券"
: (selectedCouponIndex == -1
? "拥有${settleOrderInfo.couponList.length}张优惠券"
: settleOrderInfo
.couponList[selectedCouponIndex]
.promotionName),
style: TextStyle(
color: Color(0xFF000000),
fontSize: 14.sp,
fontWeight: MyFontWeight.medium,
),
3 years ago
),
3 years ago
),
3 years ago
InkWell(
onTap: () {
Navigator.of(context).pop();
},
child: Image.asset(
"assets/image/cancel.png",
width: 24,
height: 24,
),
),
],
),
),
Expanded(
child: Container(
padding: EdgeInsets.only(
top: 8,
left: 16,
right: 16,
3 years ago
),
3 years ago
child: ListView.builder(
itemCount: settleOrderInfo == null
? 0
: settleOrderInfo.couponList.length,
physics: BouncingScrollPhysics(),
itemBuilder: (context, position) {
return GestureDetector(
onTap: () {},
child: couponItem(
settleOrderInfo.couponList[position],
position,
),
);
3 years ago
},
),
),
),
3 years ago
],
),
);
},
);
3 years ago
},
);
}
///优惠券列表
3 years ago
Widget couponItem(CouponListBean couponList, int index) {
3 years ago
return StatefulBuilder(builder: (context1, state) {
3 years ago
return Container(
3 years ago
height: 170,
3 years ago
width: double.infinity,
margin: EdgeInsets.fromLTRB(14.w, 6.h, 14.w, 6.h),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(8),
boxShadow: [
BoxShadow(
color: Colors.black.withAlpha(12),
offset: Offset(0, 3),
blurRadius: 14,
spreadRadius: 0,
)
],
),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Expanded(
child: Container(
margin: EdgeInsets.only(top: 14.h, bottom: 8.h),
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Expanded(
3 years ago
child: Column(
3 years ago
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Expanded(
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.baseline,
textBaseline: TextBaseline.alphabetic,
children: [
Text(
"¥",
style: TextStyle(
fontSize: 22.sp,
fontWeight: MyFontWeight.medium,
color: Color(0xff32A060),
),
),
SizedBox(
height: 4.h,
),
Text(
3 years ago
couponList.discountAmount,
3 years ago
style: TextStyle(
fontSize: 40.sp,
fontWeight: MyFontWeight.semi_bold,
color: Color(0xff32A060),
),
),
],
),
),
Text(
3 years ago
S.of(context).manyuankeyong(couponList.fullAmount),
3 years ago
style: TextStyle(
fontSize: 12.sp,
fontWeight: MyFontWeight.semi_bold,
color: Color(0xff32A060),
),
),
],
),
flex: 1,
),
Expanded(
flex: 2,
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
children: [
Container(
padding: EdgeInsets.fromLTRB(4, 2, 4, 2),
decoration: BoxDecoration(
3 years ago
borderRadius: BorderRadius.circular(2),
3 years ago
border: Border.all(
width: 1,
color: Color(0xFFFF7A1A),
style: BorderStyle.solid,
),
),
child: Text(
S.of(context).shangjiaquan,
style: TextStyle(
fontSize: 10.sp,
fontWeight: MyFontWeight.medium,
color: Color(0xFFFF7A1A),
),
),
),
SizedBox(
width: 8.w,
),
Expanded(
child: Text(
3 years ago
storeInfo.storeName,
3 years ago
overflow: TextOverflow.ellipsis,
style: TextStyle(
fontSize: 16.sp,
fontWeight: MyFontWeight.semi_bold,
color: Color(0xff353535),
),
),
flex: 1,
)
],
),
Text(
3 years ago
couponList.promotionName,
3 years ago
overflow: TextOverflow.ellipsis,
style: TextStyle(
fontSize: 14.sp,
color: Color(0xff727272),
),
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.end,
children: [
Text(
S.of(context).quanchangtongyong,
style: TextStyle(
color: Color(0xFF353535),
fontSize: 12.sp,
),
),
Container(
margin: EdgeInsets.only(right: 23.w),
3 years ago
child: GestureDetector(
onTap: () {
3 years ago
setState(() {
// if (!couponList.usable){
// SmartDialog.showToast("当前优惠券不可用", alignment: Alignment.center);
// return;
// }
3 years ago
double toPrice = double.parse("0");
double amount =
double.parse(couponList.fullAmount);
if (toPrice <= amount) {
SmartDialog.showToast("当前金额不够使用优惠券",
alignment: Alignment.center);
3 years ago
return;
}
state(() {
3 years ago
if (selectedCouponIndex == index)
3 years ago
selectedCouponIndex = -1;
3 years ago
else {
selectedCouponIndex = index;
}
3 years ago
});
Navigator.of(context).pop();
3 years ago
});
},
3 years ago
child: Image.asset(
3 years ago
selectedCouponIndex != index
3 years ago
? "assets/image/icon_radio_unselected.png"
: "assets/image/icon_radio_selected.png",
width: 24,
height: 24,
),
),
),
],
),
],
),
),
],
),
),
3 years ago
flex: (couponList?.isEx ?? false) ? 97 : 97,
3 years ago
),
Container(
padding: EdgeInsets.symmetric(horizontal: 23.w),
child: MySeparator(
width: 5.w,
height: 1.h,
color: Color(0xFF353535),
),
),
Expanded(
3 years ago
flex: (couponList?.isEx ?? false) ? 56 : 42,
3 years ago
child: Container(
margin: EdgeInsets.symmetric(horizontal: 23.w, vertical: 8.h),
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Text(
S.of(context).xiangqing,
style: TextStyle(
color: Color(0xFF353535),
fontSize: 10.sp,
),
),
GestureDetector(
child: Icon(
3 years ago
(!(couponList?.isEx ?? false))
3 years ago
? Icons.keyboard_arrow_down
: Icons.keyboard_arrow_up,
color: Colors.black,
size: 18,
), //点击按钮布局
3 years ago
onTap: () {
3 years ago
setState(() {
3 years ago
state(() {
this.settleOrderInfo.couponList[index].isEx =
!(this
.settleOrderInfo
.couponList[index]
.isEx ??
false);
3 years ago
});
});
},
3 years ago
),
],
),
3 years ago
if (couponList?.isEx ?? false)
3 years ago
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
S.of(context).shiyongriqi,
style: TextStyle(
color: Color(0xFF353535),
fontSize: 10.sp,
),
),
Text(
3 years ago
(couponList.useStartTime == null &&
3 years ago
couponList.useEndTime == null)
3 years ago
? S.of(context).quantian
3 years ago
: "${couponList.useStartTime.replaceAll("-", ".").split(" ")[0]} - ${couponList.useEndTime.replaceAll("-", ".").split(" ")[0]}",
3 years ago
style: TextStyle(
color: Color(0xFF353535),
fontSize: 10.sp,
),
),
],
),
],
),
),
),
],
),
);
});
}
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,
),
);
}
}