|
|
|
@ -2,11 +2,12 @@ import 'package:dio/dio.dart';
|
|
|
|
|
import 'package:flutter/cupertino.dart'; |
|
|
|
|
import 'package:flutter/material.dart'; |
|
|
|
|
import 'package:flutter/services.dart'; |
|
|
|
|
import 'package:flutter_baidu_mapapi_base/flutter_baidu_mapapi_base.dart'; |
|
|
|
|
import 'package:flutter_baidu_mapapi_utils/flutter_baidu_mapapi_utils.dart'; |
|
|
|
|
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart'; |
|
|
|
|
import 'package:flutter_svg/flutter_svg.dart'; |
|
|
|
|
import 'package:huixiang/generated/l10n.dart'; |
|
|
|
|
import 'package:huixiang/order/order_view/order_commodity.dart'; |
|
|
|
|
import 'package:huixiang/order/order_view/order_info.dart'; |
|
|
|
|
import 'package:huixiang/retrofit/data/address.dart'; |
|
|
|
|
import 'package:huixiang/retrofit/data/base_data.dart'; |
|
|
|
|
import 'package:huixiang/retrofit/data/findMiNiGroupList.dart'; |
|
|
|
|
import 'package:huixiang/retrofit/data/placeOrderFirst.dart'; |
|
|
|
@ -15,14 +16,13 @@ import 'package:huixiang/retrofit/data/settlement_bean.dart';
|
|
|
|
|
import 'package:huixiang/retrofit/data/shoppingCart.dart'; |
|
|
|
|
import 'package:huixiang/retrofit/data/store_info.dart'; |
|
|
|
|
import 'package:huixiang/retrofit/min_api.dart'; |
|
|
|
|
import 'package:huixiang/store/sku.dart'; |
|
|
|
|
import 'package:huixiang/store/store_view/settlement_order_commodity.dart'; |
|
|
|
|
import 'package:huixiang/settlement/settlement_view/settlement_order_commodity.dart'; |
|
|
|
|
import 'package:huixiang/utils/font_weight.dart'; |
|
|
|
|
import 'package:huixiang/utils/location.dart'; |
|
|
|
|
import 'package:huixiang/view_widget/my_appbar.dart'; |
|
|
|
|
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:huixiang/view_widget/separator.dart'; |
|
|
|
|
import 'package:intl/intl.dart'; |
|
|
|
|
import 'package:shared_preferences/shared_preferences.dart'; |
|
|
|
|
import 'package:flutter_screenutil/flutter_screenutil.dart'; |
|
|
|
|
|
|
|
|
@ -45,9 +45,6 @@ class _Settlement extends State<Settlement> {
|
|
|
|
|
SettleOrderInfo settleOrderInfo; |
|
|
|
|
int selectedCouponIndex = -1; |
|
|
|
|
|
|
|
|
|
List<ProductListBean> shopCar = []; |
|
|
|
|
List<Sku> shopCarGoods = []; |
|
|
|
|
|
|
|
|
|
TextEditingController _vc; |
|
|
|
|
List<String> addressBgs = [ |
|
|
|
|
"assets/svg/dingdan_ziqu.svg", |
|
|
|
@ -59,8 +56,6 @@ class _Settlement extends State<Settlement> {
|
|
|
|
|
void initState() { |
|
|
|
|
super.initState(); |
|
|
|
|
storeInfo = widget.arguments["storeInfo"]; |
|
|
|
|
shopCar = widget.arguments["shopProduct"]; |
|
|
|
|
shopCarGoods = widget.arguments["shopGoods"]; |
|
|
|
|
|
|
|
|
|
_vc = TextEditingController( |
|
|
|
|
text: storeInfo != null ? storeInfo.headMobile : ""); |
|
|
|
@ -68,24 +63,69 @@ class _Settlement extends State<Settlement> {
|
|
|
|
|
SharedPreferences.getInstance().then((value) { |
|
|
|
|
String minToken = value.getString("minToken"); |
|
|
|
|
String tenant = value.getString("tenant"); |
|
|
|
|
String storeId = value.getString("storeId"); |
|
|
|
|
minService = MinApiService( |
|
|
|
|
Dio(), |
|
|
|
|
context: context, |
|
|
|
|
token: minToken, |
|
|
|
|
tenant: tenant, |
|
|
|
|
storeId: storeId, |
|
|
|
|
); |
|
|
|
|
queryOrderInfo(); |
|
|
|
|
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(); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
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(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
///订单结算信息 |
|
|
|
|
queryOrderInfo() async { |
|
|
|
|
queryOrderInfo( |
|
|
|
|
addressId, isTake, memberCouponId, orderId, promotionId) async { |
|
|
|
|
BaseData<SettleOrderInfo> baseData = await minService.getOrderInfo({ |
|
|
|
|
"addressId": null, |
|
|
|
|
"isTake": 0, |
|
|
|
|
"memberCouponId": null, |
|
|
|
|
"orderId": 0, |
|
|
|
|
"promotionId": null |
|
|
|
|
"addressId": addressId, |
|
|
|
|
"isTake": isTake, |
|
|
|
|
"memberCouponId": memberCouponId, |
|
|
|
|
"orderId": orderId, |
|
|
|
|
"promotionId": promotionId |
|
|
|
|
}); |
|
|
|
|
if (baseData != null && baseData.isSuccess) { |
|
|
|
|
setState(() { |
|
|
|
@ -94,6 +134,55 @@ class _Settlement extends State<Settlement> {
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
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); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
///小程序下单 |
|
|
|
|
queryPlaceOrderFirst() async { |
|
|
|
|
PlaceOrderFirst placeOrderFirst = PlaceOrderFirst(); |
|
|
|
@ -109,34 +198,21 @@ class _Settlement extends State<Settlement> {
|
|
|
|
|
placeOrderFirst.parentId = 0; |
|
|
|
|
placeOrderFirst.payChannel = 1; |
|
|
|
|
placeOrderFirst.promotionInfoDTO = PlaceOrderFirstPromotionInfoDTO(); |
|
|
|
|
placeOrderFirst.promotionInfoDTO.couponId = selectedCouponIndex == -1?null : settleOrderInfo.couponList[selectedCouponIndex].couponId; |
|
|
|
|
placeOrderFirst.promotionInfoDTO.couponId = selectedCouponIndex == -1 |
|
|
|
|
? null |
|
|
|
|
: settleOrderInfo.couponList[selectedCouponIndex].couponId; |
|
|
|
|
placeOrderFirst.promotionInfoDTO.promotionId = "0"; |
|
|
|
|
placeOrderFirst.recMobile = storeInfo.headMobile; |
|
|
|
|
placeOrderFirst.shoppingCartSkuItemList = []; |
|
|
|
|
placeOrderFirst.skuItemDTOList = []; |
|
|
|
|
shopCarGoods.forEach((e0) { |
|
|
|
|
SkuItemDTOList skuItemDTOListBean = SkuItemDTOList(); |
|
|
|
|
skuItemDTOListBean.skuId = e0.skuId; |
|
|
|
|
skuItemDTOListBean.buyNum = e0.count; |
|
|
|
|
PlatterList platterListBean = PlatterList(); |
|
|
|
|
platterListBean.skuId = e0.skuId; |
|
|
|
|
platterListBean.productId = e0.id; |
|
|
|
|
skuItemDTOListBean.platterList = []; |
|
|
|
|
skuItemDTOListBean.platterList.add(platterListBean); |
|
|
|
|
placeOrderFirst.skuItemDTOList.add(skuItemDTOListBean); |
|
|
|
|
ShoppingCartSkuItemListBean shoppingCartSkuItemListBean = ShoppingCartSkuItemListBean(); |
|
|
|
|
shoppingCartSkuItemListBean.buyNum = e0.count; |
|
|
|
|
shoppingCartSkuItemListBean.productId = e0.id; |
|
|
|
|
shoppingCartSkuItemListBean.productName = e0.name; |
|
|
|
|
shoppingCartSkuItemListBean.skuId = e0.skuId; |
|
|
|
|
placeOrderFirst.shoppingCartSkuItemList.add(shoppingCartSkuItemListBean); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
placeOrderFirst.source = 1; |
|
|
|
|
placeOrderFirst.storeId = storeInfo.id; |
|
|
|
|
placeOrderFirst.subcribeTime = null; |
|
|
|
|
placeOrderFirst.tableId = 0; |
|
|
|
|
BaseData baseData = await minService.placeOrderFirst( |
|
|
|
|
placeOrderFirst.toJson()).catchError((error) {}); |
|
|
|
|
BaseData baseData = await minService |
|
|
|
|
.placeOrderFirst(placeOrderFirst.toJson()) |
|
|
|
|
.catchError((error) {}); |
|
|
|
|
if (baseData != null && baseData.isSuccess) { |
|
|
|
|
querySettlement(); |
|
|
|
|
} |
|
|
|
@ -150,97 +226,18 @@ class _Settlement extends State<Settlement> {
|
|
|
|
|
settlementBean.id = 0; |
|
|
|
|
settlementBean.isLogistics = true; |
|
|
|
|
settlementBean.orderProductVOList = []; |
|
|
|
|
shopCarGoods.forEach((e0) { |
|
|
|
|
OrderProductVOList orderProductVOListBean = OrderProductVOList(); |
|
|
|
|
orderProductVOListBean.skuId = e0.skuId; |
|
|
|
|
orderProductVOListBean.buyNum = e0.count; |
|
|
|
|
ActInfo actInfoBean = ActInfo(); |
|
|
|
|
actInfoBean.couponDiscountAmount = 0; |
|
|
|
|
actInfoBean.couponDiscountRate = 0; |
|
|
|
|
actInfoBean.couponId = 0; |
|
|
|
|
actInfoBean.couponType = 0; |
|
|
|
|
actInfoBean.discountAmount = 0; |
|
|
|
|
actInfoBean.discountRate = 0; |
|
|
|
|
actInfoBean.promotionId = 0; |
|
|
|
|
actInfoBean.promotionType = 0; |
|
|
|
|
AdditionalComment additionalCommentBean = AdditionalComment(); |
|
|
|
|
additionalCommentBean.bizType = 0; |
|
|
|
|
additionalCommentBean.commentImgs = ""; |
|
|
|
|
additionalCommentBean.commentImgsFlag = false; |
|
|
|
|
additionalCommentBean.commentStar = 0; |
|
|
|
|
additionalCommentBean.commentText = ""; |
|
|
|
|
additionalCommentBean.descStar = 0; |
|
|
|
|
additionalCommentBean.hideFlag = true; |
|
|
|
|
additionalCommentBean.id = 0; |
|
|
|
|
additionalCommentBean.isDelete = true; |
|
|
|
|
additionalCommentBean.likeNum = 0; |
|
|
|
|
additionalCommentBean.logisticsStar = 0; |
|
|
|
|
additionalCommentBean.mid = 0; |
|
|
|
|
additionalCommentBean.orderProductId = 0; |
|
|
|
|
additionalCommentBean.parentId = 0; |
|
|
|
|
additionalCommentBean.productId = 0; |
|
|
|
|
additionalCommentBean.sensitiveFlag = true; |
|
|
|
|
additionalCommentBean.serviceStar = 0; |
|
|
|
|
additionalCommentBean.storeId = 0; |
|
|
|
|
settlementBean.buyNum = 0; |
|
|
|
|
Comment commentBean = Comment(); |
|
|
|
|
commentBean.bizType = 0; |
|
|
|
|
commentBean.commentImgs = ""; |
|
|
|
|
commentBean.commentImgsFlag = true; |
|
|
|
|
commentBean.commentStar = 0; |
|
|
|
|
commentBean.commentText = ""; |
|
|
|
|
commentBean.descStar = 0; |
|
|
|
|
commentBean.hideFlag = true; |
|
|
|
|
commentBean.id = 0; |
|
|
|
|
commentBean.isDelete = true; |
|
|
|
|
commentBean.logisticsStar = 0; |
|
|
|
|
commentBean.mid = 0; |
|
|
|
|
commentBean.orderProductId = 0; |
|
|
|
|
commentBean.parentId = 0; |
|
|
|
|
commentBean.productId = 0; |
|
|
|
|
commentBean.sensitiveFlag = true; |
|
|
|
|
commentBean.serviceStar = 0; |
|
|
|
|
commentBean.storeId = 0; |
|
|
|
|
orderProductVOListBean.commentStatus = 0; |
|
|
|
|
orderProductVOListBean.discountAmount = 0; |
|
|
|
|
orderProductVOListBean.id = 0; |
|
|
|
|
orderProductVOListBean.productId = 0; |
|
|
|
|
orderProductVOListBean.productName = ""; |
|
|
|
|
orderProductVOListBean.returnCode = ""; |
|
|
|
|
orderProductVOListBean.returnStatus = 0; |
|
|
|
|
orderProductVOListBean.returnType = 0; |
|
|
|
|
orderProductVOListBean.sellPrice = 0; |
|
|
|
|
orderProductVOListBean.skuId = "0"; |
|
|
|
|
orderProductVOListBean.skuImg = ""; |
|
|
|
|
orderProductVOListBean.skuNameStr = ""; |
|
|
|
|
settlementBean.orderProductVOList.add(orderProductVOListBean); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
settlementBean.payChannel = 0; |
|
|
|
|
settlementBean.promotionInfoDTO = PromotionInfoDTO(); |
|
|
|
|
settlementBean.promotionInfoDTO.couponId = 0; |
|
|
|
|
settlementBean.promotionInfoDTO.promotionId = 0; |
|
|
|
|
BaseData baseData = await minService.settlementApi({ |
|
|
|
|
}).catchError((error) {}); |
|
|
|
|
if (baseData != null && baseData.isSuccess) { |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
BaseData baseData = |
|
|
|
|
await minService.settlementApi({}).catchError((error) {}); |
|
|
|
|
if (baseData != null && baseData.isSuccess) {} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
bool isEdit = false; |
|
|
|
|
|
|
|
|
|
String totalPrice(bool discountFlag) { |
|
|
|
|
if (shopCarGoods == null) return ""; |
|
|
|
|
double totalPrice = 0; |
|
|
|
|
shopCarGoods.forEach((element) { |
|
|
|
|
totalPrice += double.tryParse(element.price) * element.count; |
|
|
|
|
}); |
|
|
|
|
if(selectedCouponIndex != -1 && discountFlag){ |
|
|
|
|
double discountA = double.parse(settleOrderInfo.couponList[selectedCouponIndex].discountAmount); |
|
|
|
|
totalPrice -= discountA; |
|
|
|
|
} |
|
|
|
|
return totalPrice.toStringAsFixed(2); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@override |
|
|
|
|
Widget build(BuildContext context) { |
|
|
|
|
return Stack( |
|
|
|
@ -267,32 +264,86 @@ class _Settlement extends State<Settlement> {
|
|
|
|
|
titleSize: 18.sp, |
|
|
|
|
), |
|
|
|
|
body: Container( |
|
|
|
|
child: SingleChildScrollView( |
|
|
|
|
physics: BouncingScrollPhysics(), |
|
|
|
|
child: Container( |
|
|
|
|
child: Column( |
|
|
|
|
children: [ |
|
|
|
|
distributionMode(), |
|
|
|
|
SizedBox( |
|
|
|
|
height: 16, |
|
|
|
|
), |
|
|
|
|
child: Column( |
|
|
|
|
children: [ |
|
|
|
|
Expanded( |
|
|
|
|
child: Container( |
|
|
|
|
child: SingleChildScrollView( |
|
|
|
|
physics: BouncingScrollPhysics(), |
|
|
|
|
child: Container( |
|
|
|
|
child: Column( |
|
|
|
|
children: [ |
|
|
|
|
distributionMode(), |
|
|
|
|
SizedBox( |
|
|
|
|
height: 16, |
|
|
|
|
), |
|
|
|
|
|
|
|
|
|
/// 预留的手机号, 可修改 |
|
|
|
|
phoneWidget(), |
|
|
|
|
/// 预留的手机号, 可修改 |
|
|
|
|
phoneWidget(), |
|
|
|
|
|
|
|
|
|
///订单商品 |
|
|
|
|
SettlementOrderCommodity(shopCar, 0, shopCarGoods, settleOrderInfo), |
|
|
|
|
// if (payStatus == 0) couponRemarks(), |
|
|
|
|
/*(payStatus == 0) ? paySelector() : */ |
|
|
|
|
///订单商品 |
|
|
|
|
SettlementOrderCommodity( |
|
|
|
|
0, |
|
|
|
|
settleOrderInfo, |
|
|
|
|
), |
|
|
|
|
// if (payStatus == 0) couponRemarks(), |
|
|
|
|
/*(payStatus == 0) ? paySelector() : */ |
|
|
|
|
|
|
|
|
|
///优惠券/备注 |
|
|
|
|
activityRemarks(), |
|
|
|
|
///优惠券/备注 |
|
|
|
|
activityRemarks(), |
|
|
|
|
|
|
|
|
|
///支付方式 |
|
|
|
|
payMethod(), |
|
|
|
|
], |
|
|
|
|
///支付方式 |
|
|
|
|
payMethod(), |
|
|
|
|
], |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
flex: 1, |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
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: () {}, |
|
|
|
|
), |
|
|
|
|
], |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
], |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
@ -301,51 +352,6 @@ class _Settlement extends State<Settlement> {
|
|
|
|
|
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, |
|
|
|
|
), |
|
|
|
|
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: () {}, |
|
|
|
|
), |
|
|
|
|
], |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
) |
|
|
|
|
], |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
@ -504,9 +510,8 @@ class _Settlement extends State<Settlement> {
|
|
|
|
|
flex: 1, |
|
|
|
|
child: GestureDetector( |
|
|
|
|
onTap: () { |
|
|
|
|
setState(() { |
|
|
|
|
selectedBtn = 0; |
|
|
|
|
}); |
|
|
|
|
selectedBtn = 0; |
|
|
|
|
queryOrderInfo(null, selectedBtn, null, 0, null); |
|
|
|
|
}, |
|
|
|
|
child: Container( |
|
|
|
|
height: 50.h, |
|
|
|
@ -526,9 +531,8 @@ class _Settlement extends State<Settlement> {
|
|
|
|
|
flex: 1, |
|
|
|
|
child: GestureDetector( |
|
|
|
|
onTap: () { |
|
|
|
|
setState(() { |
|
|
|
|
selectedBtn = 1; |
|
|
|
|
}); |
|
|
|
|
selectedBtn = 1; |
|
|
|
|
queryAddress(); |
|
|
|
|
}, |
|
|
|
|
child: Container( |
|
|
|
|
height: 50.h, |
|
|
|
@ -579,8 +583,9 @@ class _Settlement extends State<Settlement> {
|
|
|
|
|
Expanded( |
|
|
|
|
child: Column( |
|
|
|
|
mainAxisAlignment: |
|
|
|
|
MainAxisAlignment.spaceBetween, |
|
|
|
|
MainAxisAlignment.spaceEvenly, |
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start, |
|
|
|
|
mainAxisSize: MainAxisSize.max, |
|
|
|
|
children: [ |
|
|
|
|
Text( |
|
|
|
|
storeInfo != null |
|
|
|
@ -594,7 +599,7 @@ class _Settlement extends State<Settlement> {
|
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
SizedBox( |
|
|
|
|
height: 4, |
|
|
|
|
height: 6, |
|
|
|
|
), |
|
|
|
|
Text( |
|
|
|
|
storeInfo != null |
|
|
|
@ -608,9 +613,6 @@ class _Settlement extends State<Settlement> {
|
|
|
|
|
color: Color(0xFF727272), |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
SizedBox( |
|
|
|
|
height: 12, |
|
|
|
|
), |
|
|
|
|
], |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
@ -634,7 +636,9 @@ class _Settlement extends State<Settlement> {
|
|
|
|
|
RoundButton( |
|
|
|
|
width: 41.w, |
|
|
|
|
height: 13, |
|
|
|
|
text: "距离您11m", |
|
|
|
|
text: distance.length > 3 |
|
|
|
|
? "${distance}km" |
|
|
|
|
: "距离您${distance}km", |
|
|
|
|
textColor: Color(0xFF34A262), |
|
|
|
|
fontWeight: MyFontWeight.semi_bold, |
|
|
|
|
radius: 7.5, |
|
|
|
@ -649,8 +653,11 @@ class _Settlement extends State<Settlement> {
|
|
|
|
|
], |
|
|
|
|
), |
|
|
|
|
], |
|
|
|
|
) |
|
|
|
|
), |
|
|
|
|
], |
|
|
|
|
mainAxisAlignment: MainAxisAlignment.center, |
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.center, |
|
|
|
|
mainAxisSize: MainAxisSize.max, |
|
|
|
|
), |
|
|
|
|
], |
|
|
|
|
), |
|
|
|
@ -692,13 +699,15 @@ class _Settlement extends State<Settlement> {
|
|
|
|
|
color: Color(0xFF4C4C4C), |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
), InkWell( |
|
|
|
|
), |
|
|
|
|
InkWell( |
|
|
|
|
onTap: () { |
|
|
|
|
setState(() { |
|
|
|
|
Navigator.of(context).popAndPushNamed('/router/manage_address_page'); |
|
|
|
|
Navigator.of(context).popAndPushNamed( |
|
|
|
|
'/router/manage_address_page'); |
|
|
|
|
}); |
|
|
|
|
}, |
|
|
|
|
child:Icon( |
|
|
|
|
child: Icon( |
|
|
|
|
Icons.keyboard_arrow_right, |
|
|
|
|
size: 24, |
|
|
|
|
), |
|
|
|
@ -772,10 +781,13 @@ class _Settlement extends State<Settlement> {
|
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
Text( |
|
|
|
|
(settleOrderInfo?.couponList == null || settleOrderInfo.couponList.length == 0) |
|
|
|
|
? "暂无可用优惠券" : (selectedCouponIndex == -1 |
|
|
|
|
? "拥有${settleOrderInfo.couponList.length}张优惠券": |
|
|
|
|
settleOrderInfo.couponList[selectedCouponIndex].promotionName), |
|
|
|
|
(settleOrderInfo?.couponList == null || |
|
|
|
|
settleOrderInfo.couponList.length == 0) |
|
|
|
|
? "暂无可用优惠券" |
|
|
|
|
: (selectedCouponIndex == -1 |
|
|
|
|
? "拥有${settleOrderInfo.couponList.length}张优惠券" |
|
|
|
|
: settleOrderInfo |
|
|
|
|
.couponList[selectedCouponIndex].promotionName), |
|
|
|
|
textAlign: TextAlign.end, |
|
|
|
|
style: TextStyle( |
|
|
|
|
fontSize: 14.sp, |
|
|
|
@ -956,117 +968,105 @@ class _Settlement extends State<Settlement> {
|
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
///手机号编辑 |
|
|
|
|
// showAlertDialog() { |
|
|
|
|
// //显示对话框 |
|
|
|
|
// showDialog( |
|
|
|
|
// barrierDismissible: false, |
|
|
|
|
// context: context, |
|
|
|
|
// builder: (context) { |
|
|
|
|
// return RenameDialog( |
|
|
|
|
// contentWidget: RenameDialogContent( |
|
|
|
|
// title: "请输入新的手机号码", |
|
|
|
|
// okBtnTap: () { |
|
|
|
|
// // print( |
|
|
|
|
// // "输入框中的文字为:${_vc.text}", |
|
|
|
|
// // ); |
|
|
|
|
// }, |
|
|
|
|
// vc: _vc, |
|
|
|
|
// cancelBtnTap: () {}, |
|
|
|
|
// ), |
|
|
|
|
// ); |
|
|
|
|
// }); |
|
|
|
|
// } |
|
|
|
|
|
|
|
|
|
///优惠券弹窗 |
|
|
|
|
couponCart() { |
|
|
|
|
showModalBottomSheet( |
|
|
|
|
context: context, |
|
|
|
|
backgroundColor: Colors.transparent, |
|
|
|
|
builder: (context) { |
|
|
|
|
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), |
|
|
|
|
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), |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
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, |
|
|
|
|
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, |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
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, |
|
|
|
|
), |
|
|
|
|
InkWell( |
|
|
|
|
onTap: () { |
|
|
|
|
Navigator.of(context).pop(); |
|
|
|
|
child: ListView.builder( |
|
|
|
|
itemCount: settleOrderInfo == null |
|
|
|
|
? 0 |
|
|
|
|
: settleOrderInfo.couponList.length, |
|
|
|
|
physics: BouncingScrollPhysics(), |
|
|
|
|
itemBuilder: (context, position) { |
|
|
|
|
return GestureDetector( |
|
|
|
|
onTap: () {}, |
|
|
|
|
child: couponItem( |
|
|
|
|
settleOrderInfo.couponList[position], |
|
|
|
|
position, |
|
|
|
|
), |
|
|
|
|
); |
|
|
|
|
}, |
|
|
|
|
child: Image.asset( |
|
|
|
|
"assets/image/cancel.png", |
|
|
|
|
width: 24, |
|
|
|
|
height: 24, |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
], |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
Expanded( |
|
|
|
|
child: Container( |
|
|
|
|
padding: EdgeInsets.only( |
|
|
|
|
top: 8, |
|
|
|
|
left: 16, |
|
|
|
|
right: 16, |
|
|
|
|
), |
|
|
|
|
child: ListView.builder( |
|
|
|
|
itemCount:settleOrderInfo == null ? 0 : settleOrderInfo.couponList.length, |
|
|
|
|
physics: BouncingScrollPhysics(), |
|
|
|
|
itemBuilder: (context, position) { |
|
|
|
|
// return shoppGoodsItem(); |
|
|
|
|
return GestureDetector( |
|
|
|
|
onTap: () {}, |
|
|
|
|
child: couponItem(settleOrderInfo.couponList[position],position), |
|
|
|
|
); |
|
|
|
|
}, |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
], |
|
|
|
|
), |
|
|
|
|
); |
|
|
|
|
}); |
|
|
|
|
], |
|
|
|
|
), |
|
|
|
|
); |
|
|
|
|
}, |
|
|
|
|
); |
|
|
|
|
}, |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
///优惠券列表 |
|
|
|
|
Widget couponItem(CouponListBean couponList,int index) { |
|
|
|
|
Widget couponItem(CouponListBean couponList, int index) { |
|
|
|
|
return StatefulBuilder(builder: (context1, state) { |
|
|
|
|
return Container( |
|
|
|
|
height: 170, |
|
|
|
@ -1212,16 +1212,20 @@ class _Settlement extends State<Settlement> {
|
|
|
|
|
// SmartDialog.showToast("当前优惠券不可用", alignment: Alignment.center); |
|
|
|
|
// return; |
|
|
|
|
// } |
|
|
|
|
double toPrice = double.parse(totalPrice(false)); |
|
|
|
|
double amount = double.parse(couponList.fullAmount); |
|
|
|
|
if(toPrice <= amount){ |
|
|
|
|
SmartDialog.showToast("当前金额不够使用优惠券", alignment: Alignment.center); |
|
|
|
|
double toPrice = double.parse("0"); |
|
|
|
|
double amount = |
|
|
|
|
double.parse(couponList.fullAmount); |
|
|
|
|
if (toPrice <= amount) { |
|
|
|
|
SmartDialog.showToast("当前金额不够使用优惠券", |
|
|
|
|
alignment: Alignment.center); |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
state(() { |
|
|
|
|
if(selectedCouponIndex == index) |
|
|
|
|
if (selectedCouponIndex == index) |
|
|
|
|
selectedCouponIndex = -1; |
|
|
|
|
else {selectedCouponIndex = index;} |
|
|
|
|
else { |
|
|
|
|
selectedCouponIndex = index; |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
Navigator.of(context).pop(); |
|
|
|
|
}); |
|
|
|
@ -1243,7 +1247,7 @@ class _Settlement extends State<Settlement> {
|
|
|
|
|
], |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
flex: (couponList?.isEx??false) ? 97 : 97, |
|
|
|
|
flex: (couponList?.isEx ?? false) ? 97 : 97, |
|
|
|
|
), |
|
|
|
|
Container( |
|
|
|
|
padding: EdgeInsets.symmetric(horizontal: 23.w), |
|
|
|
@ -1254,7 +1258,7 @@ class _Settlement extends State<Settlement> {
|
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
Expanded( |
|
|
|
|
flex: (couponList?.isEx??false) ? 56 : 42, |
|
|
|
|
flex: (couponList?.isEx ?? false) ? 56 : 42, |
|
|
|
|
child: Container( |
|
|
|
|
margin: EdgeInsets.symmetric(horizontal: 23.w, vertical: 8.h), |
|
|
|
|
child: Column( |
|
|
|
@ -1273,23 +1277,28 @@ class _Settlement extends State<Settlement> {
|
|
|
|
|
), |
|
|
|
|
GestureDetector( |
|
|
|
|
child: Icon( |
|
|
|
|
(!(couponList?.isEx??false)) |
|
|
|
|
(!(couponList?.isEx ?? false)) |
|
|
|
|
? Icons.keyboard_arrow_down |
|
|
|
|
: Icons.keyboard_arrow_up, |
|
|
|
|
color: Colors.black, |
|
|
|
|
size: 18, |
|
|
|
|
), //点击按钮布局 |
|
|
|
|
onTap: (){ |
|
|
|
|
onTap: () { |
|
|
|
|
setState(() { |
|
|
|
|
state((){ |
|
|
|
|
this.settleOrderInfo.couponList[index].isEx = !(this.settleOrderInfo.couponList[index].isEx??false); |
|
|
|
|
state(() { |
|
|
|
|
this.settleOrderInfo.couponList[index].isEx = |
|
|
|
|
!(this |
|
|
|
|
.settleOrderInfo |
|
|
|
|
.couponList[index] |
|
|
|
|
.isEx ?? |
|
|
|
|
false); |
|
|
|
|
}); |
|
|
|
|
}); |
|
|
|
|
}, |
|
|
|
|
), |
|
|
|
|
], |
|
|
|
|
), |
|
|
|
|
if (couponList?.isEx??false) |
|
|
|
|
if (couponList?.isEx ?? false) |
|
|
|
|
Row( |
|
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween, |
|
|
|
|
children: [ |
|
|
|
@ -1302,7 +1311,7 @@ class _Settlement extends State<Settlement> {
|
|
|
|
|
), |
|
|
|
|
Text( |
|
|
|
|
(couponList.useStartTime == null && |
|
|
|
|
couponList.useEndTime == null) |
|
|
|
|
couponList.useEndTime == null) |
|
|
|
|
? S.of(context).quantian |
|
|
|
|
: "${couponList.useStartTime.replaceAll("-", ".").split(" ")[0]} - ${couponList.useEndTime.replaceAll("-", ".").split(" ")[0]}", |
|
|
|
|
style: TextStyle( |