From 5ea6c2d46217d271d53b7b177b17b51e17475908 Mon Sep 17 00:00:00 2001 From: fmk Date: Thu, 21 Oct 2021 16:15:37 +0800 Subject: [PATCH] safety --- lib/settlement/settlement.dart | 1128 ++--------------- lib/settlement/settlement_view/activity.dart | 165 +++ .../activity_coupon_remarks.dart | 173 +++ lib/settlement/settlement_view/coupon.dart | 268 ++++ .../settlement_view/distribution.dart | 357 ++++++ .../settlement_view/edit_phone.dart | 150 +++ .../settlement_view/pay_method.dart | 156 +++ .../settlement_view/settlement_activity.dart | 174 +++ .../settlement_view/settlement_coupon.dart | 166 +++ .../settlement_order_commodity.dart | 51 +- lib/store/store_order.dart | 24 +- lib/utils/flutter_utils.dart | 14 + lib/utils/location.dart | 52 +- 13 files changed, 1781 insertions(+), 1097 deletions(-) create mode 100644 lib/settlement/settlement_view/activity.dart create mode 100644 lib/settlement/settlement_view/activity_coupon_remarks.dart create mode 100644 lib/settlement/settlement_view/coupon.dart create mode 100644 lib/settlement/settlement_view/distribution.dart create mode 100644 lib/settlement/settlement_view/edit_phone.dart create mode 100644 lib/settlement/settlement_view/pay_method.dart create mode 100644 lib/settlement/settlement_view/settlement_activity.dart create mode 100644 lib/settlement/settlement_view/settlement_coupon.dart diff --git a/lib/settlement/settlement.dart b/lib/settlement/settlement.dart index 89cb8947..b5f6df9b 100644 --- a/lib/settlement/settlement.dart +++ b/lib/settlement/settlement.dart @@ -16,12 +16,17 @@ 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/settlement/settlement_view/activity_coupon_remarks.dart'; +import 'package:huixiang/settlement/settlement_view/distribution.dart'; +import 'package:huixiang/settlement/settlement_view/edit_phone.dart'; +import 'package:huixiang/settlement/settlement_view/pay_method.dart'; +import 'package:huixiang/settlement/settlement_view/settlement_activity.dart'; +import 'package:huixiang/settlement/settlement_view/settlement_coupon.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/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'; @@ -39,27 +44,20 @@ class Settlement extends StatefulWidget { class _Settlement extends State { MinApiService minService; - int selectedBtn = 0; Function(int type) callback; StoreInfo storeInfo; SettleOrderInfo settleOrderInfo; - int selectedCouponIndex = -1; + int selectedBtn = 0; - TextEditingController _vc; - List addressBgs = [ - "assets/svg/dingdan_ziqu.svg", - "assets/svg/dingdan_waimai.svg", - "assets/svg/dingdan_wuliu.svg", - ]; + CouponListBean couponListBean; + PromotionInfoListBean promotion; + String mobile; @override void initState() { super.initState(); storeInfo = widget.arguments["storeInfo"]; - _vc = TextEditingController( - text: storeInfo != null ? storeInfo.headMobile : ""); - SharedPreferences.getInstance().then((value) { String minToken = value.getString("minToken"); String tenant = value.getString("tenant"); @@ -73,48 +71,6 @@ class _Settlement extends State { ); 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(); } ///订单结算信息 @@ -136,7 +92,8 @@ class _Settlement extends State { Address address; - queryAddress() async { + queryAddress(int selectedBtn) async { + this.selectedBtn = selectedBtn; if (address != null) { queryOrderInfo(address.id, selectedBtn, null, 0, null); return; @@ -172,8 +129,6 @@ class _Settlement extends State { bmfCoordinate, coordinate); double mi1 = await BMFCalculateUtils.getLocationDistance( bmfCoordinate, coordinate1); - print("address 1111: $mi"); - print("address 11: $mi1"); if (mi1 < mi) { address = address1; } @@ -198,9 +153,9 @@ class _Settlement extends State { 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 = []; @@ -236,8 +191,6 @@ class _Settlement extends State { if (baseData != null && baseData.isSuccess) {} } - bool isEdit = false; - @override Widget build(BuildContext context) { return Stack( @@ -273,27 +226,40 @@ class _Settlement extends State { child: Container( child: Column( children: [ - distributionMode(), + DistributionMode( + queryOrderInfo, + queryAddress, + storeInfo, + address, + ), + SizedBox( height: 16, ), /// 预留的手机号, 可修改 - phoneWidget(), + EditPhoneWidget( + storeInfo, + mobileChange, + ), ///订单商品 SettlementOrderCommodity( - 0, + selectedBtn, settleOrderInfo, ), - // if (payStatus == 0) couponRemarks(), - /*(payStatus == 0) ? paySelector() : */ ///优惠券/备注 - activityRemarks(), + ActivityCouponRemarks( + couponCart, + activityCart, + couponListBean, + promotion, + couponCount(), + ), ///支付方式 - payMethod(), + PayMethod(), ], ), ), @@ -317,7 +283,7 @@ class _Settlement extends State { ), ), Text( - "¥${settleOrderInfo.orderSum}", + "¥${settleOrderInfo == null ? "" : settleOrderInfo.price}", style: TextStyle( fontSize: 20.sp, fontWeight: MyFontWeight.semi_bold, @@ -356,994 +322,64 @@ class _Settlement extends State { ); } - /// 预留的手机号, 可修改 - 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( - height: 143.h, - margin: EdgeInsets.only( - left: 16, - right: 16, - top: 10, - ), - child: Stack( - children: [ - 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, - mainAxisSize: MainAxisSize.max, - children: [ - Expanded( - flex: 1, - child: GestureDetector( - onTap: () { - selectedBtn = 0; - queryOrderInfo(null, selectedBtn, null, 0, null); - }, - child: Container( - height: 50.h, - alignment: Alignment.center, - child: Text( - S.of(context).daodianziqu, - style: TextStyle( - fontSize: 14.sp, - fontWeight: MyFontWeight.semi_bold, - color: Colors.black, - ), - ), - ), - ), - ), - Expanded( - flex: 1, - child: GestureDetector( - onTap: () { - selectedBtn = 1; - queryAddress(); - }, - child: Container( - height: 50.h, - alignment: Alignment.center, - child: Text( - S.of(context).waimaipeisong, - style: TextStyle( - fontSize: 14.sp, - fontWeight: MyFontWeight.regular, - color: Colors.black, - ), - ), - ), - ), - ), - Expanded( - flex: 1, - child: GestureDetector( - onTap: () { - SmartDialog.showToast("该功能暂未开放!", - alignment: Alignment.center); - }, - child: Container( - height: 50.h, - alignment: Alignment.center, - child: Text( - S.of(context).kuaidiwuliu, - style: TextStyle( - fontSize: 14.sp, - fontWeight: MyFontWeight.regular, - color: Colors.black, - ), - ), - ), - ), - ), - ], - ), - ), - 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.spaceEvenly, - crossAxisAlignment: CrossAxisAlignment.start, - mainAxisSize: MainAxisSize.max, - children: [ - Text( - storeInfo != null - ? (storeInfo.storeName ?? "") - : "", - overflow: TextOverflow.ellipsis, - style: TextStyle( - fontSize: 14.sp, - fontWeight: MyFontWeight.semi_bold, - color: Color(0xFF4C4C4C), - ), - ), - SizedBox( - height: 6, - ), - Text( - storeInfo != null - ? storeInfo.address - : "", - overflow: TextOverflow.ellipsis, - maxLines: 2, - style: TextStyle( - fontSize: 12.sp, - fontWeight: MyFontWeight.regular, - color: Color(0xFF727272), - ), - ), - ], - ), - ), - 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: distance.length > 3 - ? "${distance}km" - : "距离您${distance}km", - 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, - ), - ], - ), - ], - ), - ], - mainAxisAlignment: MainAxisAlignment.center, - crossAxisAlignment: CrossAxisAlignment.center, - mainAxisSize: MainAxisSize.max, - ), - ], - ), - ) - : 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), - ), - ), - ), - InkWell( - onTap: () { - setState(() { - Navigator.of(context).popAndPushNamed( - '/router/manage_address_page'); - }); - }, - child: 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( - (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), - fontWeight: MyFontWeight.semi_bold, - ), - ), - InkWell( - onTap: () { - setState(() { - couponCart(); - }); - }, - child: 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, - ), - ], - ), - ], - ), - ); + mobileChange(String mobile) { + this.mobile = mobile; } - 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, - ), - ), - ), - ], - ), - ), - ], - ), - ); + int couponCount() { + if (settleOrderInfo == null || + settleOrderInfo.couponList == null || + settleOrderInfo.couponList.length == 0) return 0; + int count = 0; + settleOrderInfo.couponList.forEach((element) { + if (element.tenantCode == "") { + count++; + } + }); + return count; } ///优惠券弹窗 - couponCart() { - showModalBottomSheet( + couponCart() async { + CouponListBean couponBean = await 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), - ), - ), - 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, - ), - child: ListView.builder( - itemCount: settleOrderInfo == null - ? 0 - : settleOrderInfo.couponList.length, - physics: BouncingScrollPhysics(), - itemBuilder: (context, position) { - return GestureDetector( - onTap: () {}, - child: couponItem( - settleOrderInfo.couponList[position], - position, - ), - ); - }, - ), - ), - ), - ], - ), - ); - }, - ); + return SettlementCoupon(settleOrderInfo, storeInfo, + couponBean: couponListBean); }, ); + if (couponBean != null) { + this.couponListBean = couponBean; + this.promotion = null; + queryOrderInfo( + address != null ? address.id : null, + selectedBtn, + couponListBean != null ? couponListBean.id : null, + 0, + promotion != null ? promotion.id : null); + } } - ///优惠券列表 - Widget couponItem(CouponListBean couponList, int index) { - return StatefulBuilder(builder: (context1, state) { - return Container( - height: 170, - 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( - child: Column( - 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( - couponList.discountAmount, - style: TextStyle( - fontSize: 40.sp, - fontWeight: MyFontWeight.semi_bold, - color: Color(0xff32A060), - ), - ), - ], - ), - ), - Text( - S.of(context).manyuankeyong(couponList.fullAmount), - 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( - borderRadius: BorderRadius.circular(2), - 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( - storeInfo.storeName, - overflow: TextOverflow.ellipsis, - style: TextStyle( - fontSize: 16.sp, - fontWeight: MyFontWeight.semi_bold, - color: Color(0xff353535), - ), - ), - flex: 1, - ) - ], - ), - Text( - couponList.promotionName, - 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), - child: GestureDetector( - onTap: () { - setState(() { - // if (!couponList.usable){ - // SmartDialog.showToast("当前优惠券不可用", alignment: Alignment.center); - // return; - // } - double toPrice = double.parse("0"); - double amount = - double.parse(couponList.fullAmount); - if (toPrice <= amount) { - SmartDialog.showToast("当前金额不够使用优惠券", - alignment: Alignment.center); - return; - } - state(() { - if (selectedCouponIndex == index) - selectedCouponIndex = -1; - else { - selectedCouponIndex = index; - } - }); - Navigator.of(context).pop(); - }); - }, - child: Image.asset( - selectedCouponIndex != index - ? "assets/image/icon_radio_unselected.png" - : "assets/image/icon_radio_selected.png", - width: 24, - height: 24, - ), - ), - ), - ], - ), - ], - ), - ), - ], - ), - ), - flex: (couponList?.isEx ?? false) ? 97 : 97, - ), - Container( - padding: EdgeInsets.symmetric(horizontal: 23.w), - child: MySeparator( - width: 5.w, - height: 1.h, - color: Color(0xFF353535), - ), - ), - Expanded( - flex: (couponList?.isEx ?? false) ? 56 : 42, - 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( - (!(couponList?.isEx ?? false)) - ? Icons.keyboard_arrow_down - : Icons.keyboard_arrow_up, - color: Colors.black, - size: 18, - ), //点击按钮布局 - onTap: () { - setState(() { - state(() { - this.settleOrderInfo.couponList[index].isEx = - !(this - .settleOrderInfo - .couponList[index] - .isEx ?? - false); - }); - }); - }, - ), - ], - ), - if (couponList?.isEx ?? false) - Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Text( - S.of(context).shiyongriqi, - style: TextStyle( - color: Color(0xFF353535), - fontSize: 10.sp, - ), - ), - Text( - (couponList.useStartTime == null && - couponList.useEndTime == null) - ? S.of(context).quantian - : "${couponList.useStartTime.replaceAll("-", ".").split(" ")[0]} - ${couponList.useEndTime.replaceAll("-", ".").split(" ")[0]}", - 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, - ), + ///活动弹窗 + activityCart() async { + // if (couponListBean != null) return; + PromotionInfoListBean pro = await showModalBottomSheet( + context: context, + backgroundColor: Colors.transparent, + builder: (context) { + return SettlementActivity(settleOrderInfo, storeInfo); + }, ); + if (pro != null) { + this.promotion = pro; + this.couponListBean = null; + queryOrderInfo( + address != null ? address.id : null, + selectedBtn, + couponListBean != null ? couponListBean.id : null, + 0, + promotion != null ? promotion.id : null); + } } } diff --git a/lib/settlement/settlement_view/activity.dart b/lib/settlement/settlement_view/activity.dart new file mode 100644 index 00000000..199f2346 --- /dev/null +++ b/lib/settlement/settlement_view/activity.dart @@ -0,0 +1,165 @@ +import 'package:flutter/material.dart'; +import 'package:huixiang/retrofit/data/settleOrderInfo.dart'; +import 'package:huixiang/retrofit/data/store_info.dart'; +import 'package:flutter_screenutil/flutter_screenutil.dart'; +import 'package:huixiang/utils/font_weight.dart'; +import 'package:huixiang/view_widget/custom_image.dart'; +import 'package:huixiang/view_widget/icon_text.dart'; +import 'package:huixiang/view_widget/round_button.dart'; + +class ActivityWidget extends StatefulWidget { + final PromotionInfoListBean promotionInfoListBean; + final StoreInfo storeInfo; + final int index; + + final Function() callback; + + ActivityWidget(this.promotionInfoListBean, this.storeInfo, this.index, { this.callback, }); + + @override + State createState() { + return _ActivityWidget(); + } +} + +class _ActivityWidget extends State { + @override + Widget build(BuildContext context) { + return Container( + height: 177, + width: double.infinity, + padding: EdgeInsets.all(16), + 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( + children: [ + Expanded( + child: Row( + children: [ + MImage( + widget.promotionInfoListBean != null + ? widget.promotionInfoListBean.image + : "", + fit: BoxFit.cover, + aspectRatio: 1, + errorSrc: "assets/image/default_1.png", + fadeSrc: "assets/image/default_1.png", + ), + SizedBox( + width: 12.w, + ), + Expanded( + child: Column( + mainAxisAlignment: MainAxisAlignment.spaceEvenly, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + widget.promotionInfoListBean != null + ? (widget.promotionInfoListBean.name ?? "") + : "", + style: TextStyle( + fontWeight: MyFontWeight.medium, + fontSize: 14.sp, + color: Colors.black, + ), + ), + Text( + widget.promotionInfoListBean != null + ? (widget.promotionInfoListBean.description ?? "") + : "", + maxLines: 2, + overflow: TextOverflow.ellipsis, + style: TextStyle( + color: Color(0xFF727272), + fontSize: 12.sp, + fontWeight: MyFontWeight.medium, + ), + ), + SizedBox( + height: 8.w, + ), + IconText( + "全场通用", + leftIcon: Icons.circle, + iconColor: Color(0xFF32A060), + iconSize: 6, + textStyle: TextStyle( + fontSize: 12.sp, + fontWeight: MyFontWeight.regular, + color: Color(0xFF181818), + ), + ), + IconText( + widget.promotionInfoListBean != null + ? ("${widget.promotionInfoListBean.activityStartTime.split(" ")[0].replaceAll("-", ".")}-${widget.promotionInfoListBean.activityEndTime.split(" ")[0].replaceAll("-", ".")}") + : "", + leftIcon: Icons.circle, + iconColor: Color(0xFF32A060), + iconSize: 6, + textStyle: TextStyle( + fontSize: 12.sp, + fontWeight: MyFontWeight.regular, + color: Color(0xFF181818), + ), + ), + ], + ), + ), + ], + ), + flex: 1, + ), + SizedBox( + height: 12.w, + ), + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Text( + "*优惠券与活动不可同时选择", + style: TextStyle( + fontSize: 12.sp, + fontWeight: MyFontWeight.regular, + color: Color(0xFFACACAC), + ), + ), + if (widget.promotionInfoListBean != null && + widget.promotionInfoListBean.canPartake) + RoundButton( + text: "选择活动", + textColor: Colors.white, + padding: EdgeInsets.symmetric( + vertical: 4, + horizontal: 8, + ), + backgroup: Color(0xFF32A060), + radius: 12, + callback: widget.callback, + ) + else + Text( + "条件未达", + style: TextStyle( + color: Color(0xFF868686), + fontWeight: MyFontWeight.medium, + fontSize: 12.sp, + ), + ), + ], + ), + ], + ), + ); + } +} diff --git a/lib/settlement/settlement_view/activity_coupon_remarks.dart b/lib/settlement/settlement_view/activity_coupon_remarks.dart new file mode 100644 index 00000000..cf33dcfb --- /dev/null +++ b/lib/settlement/settlement_view/activity_coupon_remarks.dart @@ -0,0 +1,173 @@ +import 'package:flutter/material.dart'; +import 'package:huixiang/generated/l10n.dart'; +import 'package:huixiang/retrofit/data/settleOrderInfo.dart'; +import 'package:huixiang/utils/font_weight.dart'; +import 'package:flutter_screenutil/flutter_screenutil.dart'; + +class ActivityCouponRemarks extends StatefulWidget { + final Function() couponCart; + final Function() activityCart; + final CouponListBean couponListBean; + final PromotionInfoListBean promotion; + final int couponCount; + + ActivityCouponRemarks( + this.couponCart, + this.activityCart, + this.couponListBean, + this.promotion, + this.couponCount, + ); + + @override + State createState() { + return _ActivityCouponRemarks(); + } +} + +class _ActivityCouponRemarks extends State { + + @override + Widget build(BuildContext context) { + 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: 122.h, + margin: EdgeInsets.only( + left: 16, + right: 16, + top: 15, + ), + padding: EdgeInsets.only( + left: 16, + right: 16, + top: 14, + bottom: 14, + ), + child: Column( + mainAxisAlignment: MainAxisAlignment.spaceEvenly, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + InkWell( + onTap: () { + widget.activityCart(); + }, + child: Row( + mainAxisAlignment: MainAxisAlignment.center, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Expanded( + flex: 1, + child: Text( + S.of(context).huodong, + style: TextStyle( + fontWeight: MyFontWeight.regular, + fontSize: 14.sp, + color: Color(0xFF353535), + ), + ), + ), + Text( + widget.promotion == null ? "*优惠券与活动不可同时选择" : widget.promotion.name, + 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, + ), + InkWell( + onTap: () { + widget.couponCart(); + }, + child: 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( + (widget.couponListBean == null) + ? ("未使用优惠券") + : widget.couponListBean.promotionName, + 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, + ), + ], + ), + ], + ), + ); + } +} diff --git a/lib/settlement/settlement_view/coupon.dart b/lib/settlement/settlement_view/coupon.dart new file mode 100644 index 00000000..bae2b62b --- /dev/null +++ b/lib/settlement/settlement_view/coupon.dart @@ -0,0 +1,268 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_screenutil/flutter_screenutil.dart'; +import 'package:huixiang/generated/l10n.dart'; +import 'package:huixiang/retrofit/data/settleOrderInfo.dart'; +import 'package:huixiang/retrofit/data/store_info.dart'; +import 'package:huixiang/utils/font_weight.dart'; +import 'package:huixiang/view_widget/separator.dart'; + +class CouponWidget extends StatefulWidget { + final CouponListBean couponList; + final StoreInfo storeInfo; + final bool selected; + + CouponWidget( + this.couponList, + this.storeInfo, { + this.selected = false, + }); + + @override + State createState() { + return _CouponWidget(); + } +} + +class _CouponWidget extends State { + @override + Widget build(BuildContext context) { + return Container( + height: 170, + width: double.infinity, + 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( + child: Column( + 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( + "${double.tryParse(widget.couponList.discountAmount).toInt()}", + style: TextStyle( + fontSize: 40.sp, + fontWeight: MyFontWeight.semi_bold, + color: Color(0xff32A060), + ), + ), + ], + ), + ), + Text( + S + .of(context) + .manyuankeyong(widget.couponList.fullAmount), + 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( + borderRadius: BorderRadius.circular(2), + 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( + widget.storeInfo.storeName, + overflow: TextOverflow.ellipsis, + style: TextStyle( + fontSize: 16.sp, + fontWeight: MyFontWeight.semi_bold, + color: Color(0xff353535), + ), + ), + flex: 1, + ), + ], + ), + Text( + widget.couponList.promotionName, + 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, + ), + ), + if (widget.couponList.usable) + Container( + margin: EdgeInsets.only(right: 23.w), + child: GestureDetector( + onTap: () { + Navigator.of(context).pop(widget.couponList); + }, + child: Image.asset( + widget.selected + ? "assets/image/icon_radio_unselected.png" + : "assets/image/icon_radio_selected.png", + width: 24, + height: 24, + ), + ), + ), + ], + ), + ], + ), + ), + ], + ), + ), + flex: (widget.couponList?.isEx ?? false) ? 97 : 97, + ), + Container( + padding: EdgeInsets.symmetric(horizontal: 23.w), + child: MySeparator( + width: 5.w, + height: 1.h, + color: Color(0xFF353535), + ), + ), + Expanded( + flex: (widget.couponList?.isEx ?? false) ? 56 : 42, + 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( + (!(widget.couponList?.isEx ?? false)) + ? Icons.keyboard_arrow_down + : Icons.keyboard_arrow_up, + color: Colors.black, + size: 18, + ), //点击按钮布局 + onTap: () { + setState(() { + widget.couponList.isEx = + !(widget.couponList.isEx ?? false); + }); + }, + ), + ], + ), + if (widget.couponList?.isEx ?? false) + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Text( + S.of(context).shiyongriqi, + style: TextStyle( + color: Color(0xFF353535), + fontSize: 10.sp, + ), + ), + Text( + (widget.couponList.useStartTime == null && + widget.couponList.useEndTime == null) + ? S.of(context).quantian + : "${widget.couponList.useStartTime.replaceAll("-", ".").split(" ")[0]} - ${widget.couponList.useEndTime.replaceAll("-", ".").split(" ")[0]}", + style: TextStyle( + color: Color(0xFF353535), + fontSize: 10.sp, + ), + ), + ], + ), + ], + ), + ), + ), + ], + ), + ); + } +} diff --git a/lib/settlement/settlement_view/distribution.dart b/lib/settlement/settlement_view/distribution.dart new file mode 100644 index 00000000..474906e9 --- /dev/null +++ b/lib/settlement/settlement_view/distribution.dart @@ -0,0 +1,357 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_baidu_mapapi_base/flutter_baidu_mapapi_base.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/retrofit/data/address.dart'; +import 'package:huixiang/retrofit/data/store_info.dart'; +import 'package:huixiang/utils/flutter_utils.dart'; +import 'package:huixiang/utils/font_weight.dart'; +import 'package:huixiang/utils/location.dart'; +import 'package:huixiang/view_widget/round_button.dart'; +import 'package:flutter_screenutil/flutter_screenutil.dart'; + +class DistributionMode extends StatefulWidget { + final Function( + String addressId, + int isTake, + String memberCouponId, + int orderId, + String promotionId, + ) queryOrderInfo; + final Function(int selectedBtn) queryAddress; + final StoreInfo storeInfo; + final Address address; + + DistributionMode( + this.queryOrderInfo, this.queryAddress, this.storeInfo, this.address); + + @override + State createState() { + return _DistributionMode(); + } +} + +class _DistributionMode extends State { + List addressBgs = [ + "assets/svg/dingdan_ziqu.svg", + "assets/svg/dingdan_waimai.svg", + "assets/svg/dingdan_wuliu.svg", + ]; + + BMFCoordinate myLatLng; + String distance = "0"; + int selectedBtn = 0; + + @override + void initState() { + super.initState(); + + startLocation(); + } + + ///定位获取当前的位置 + 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"]); + } + calculate(); + Location.getInstance().stopLocation(); + } + }); + Location.getInstance().prepareLoc(); + Location.getInstance().startLocation(context); + } + + calculate() async { + BMFCoordinate bmfCoordinate = BMFCoordinate( + double.tryParse(widget.storeInfo.latitude), + double.tryParse(widget.storeInfo.longitude), + ); + distance = await AppUtils.calculateDistance(bmfCoordinate, myLatLng); + setState(() {}); + } + + @override + Widget build(BuildContext context) { + return Container( + height: 143.h, + margin: EdgeInsets.only( + left: 16, + right: 16, + top: 10, + ), + child: Stack( + children: [ + 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, + mainAxisSize: MainAxisSize.max, + children: [ + Expanded( + flex: 1, + child: GestureDetector( + onTap: () { + selectedBtn = 0; + widget.queryOrderInfo( + null, selectedBtn, null, 0, null); + }, + child: Container( + height: 50.h, + alignment: Alignment.center, + child: Text( + S.of(context).daodianziqu, + style: TextStyle( + fontSize: 14.sp, + fontWeight: MyFontWeight.semi_bold, + color: Colors.black, + ), + ), + ), + ), + ), + Expanded( + flex: 1, + child: GestureDetector( + onTap: () { + selectedBtn = 1; + widget.queryAddress(selectedBtn); + }, + child: Container( + height: 50.h, + alignment: Alignment.center, + child: Text( + S.of(context).waimaipeisong, + style: TextStyle( + fontSize: 14.sp, + fontWeight: MyFontWeight.regular, + color: Colors.black, + ), + ), + ), + ), + ), + Expanded( + flex: 1, + child: GestureDetector( + onTap: () { + SmartDialog.showToast("该功能暂未开放!", + alignment: Alignment.center); + }, + child: Container( + height: 50.h, + alignment: Alignment.center, + child: Text( + S.of(context).kuaidiwuliu, + style: TextStyle( + fontSize: 14.sp, + fontWeight: MyFontWeight.regular, + color: Colors.black, + ), + ), + ), + ), + ), + ], + ), + ), + 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.spaceEvenly, + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisSize: MainAxisSize.max, + children: [ + Text( + widget.storeInfo != null + ? (widget.storeInfo.storeName ?? "") + : "", + overflow: TextOverflow.ellipsis, + style: TextStyle( + fontSize: 14.sp, + fontWeight: MyFontWeight.semi_bold, + color: Color(0xFF4C4C4C), + ), + ), + SizedBox( + height: 6, + ), + Text( + widget.storeInfo != null + ? widget.storeInfo.address + : "", + overflow: TextOverflow.ellipsis, + maxLines: 2, + style: TextStyle( + fontSize: 12.sp, + fontWeight: MyFontWeight.regular, + color: Color(0xFF727272), + ), + ), + ], + ), + ), + 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: distance.length > 3 + ? "${distance}km" + : "距离您${distance}km", + 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, + ), + ], + ), + ], + ), + ], + mainAxisAlignment: MainAxisAlignment.center, + crossAxisAlignment: CrossAxisAlignment.center, + mainAxisSize: MainAxisSize.max, + ), + ], + ), + ) + : 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), + ), + ), + ), + InkWell( + onTap: () { + setState(() { + Navigator.of(context).popAndPushNamed( + '/router/manage_address_page'); + }); + }, + child: 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), + ), + ), + ), + ], + ), + ), + ], + ), + ], + ), + ); + } +} diff --git a/lib/settlement/settlement_view/edit_phone.dart b/lib/settlement/settlement_view/edit_phone.dart new file mode 100644 index 00000000..9d3ea619 --- /dev/null +++ b/lib/settlement/settlement_view/edit_phone.dart @@ -0,0 +1,150 @@ +import 'package:flutter/material.dart'; +import 'package:flutter/services.dart'; +import 'package:huixiang/generated/l10n.dart'; +import 'package:huixiang/retrofit/data/store_info.dart'; +import 'package:huixiang/utils/flutter_utils.dart'; +import 'package:huixiang/utils/font_weight.dart'; +import 'package:flutter_screenutil/flutter_screenutil.dart'; + +class EditPhoneWidget extends StatefulWidget { + + final StoreInfo storeInfo; + final Function(String headMobile) mobileChange; + + EditPhoneWidget(this.storeInfo, this.mobileChange); + + @override + State createState() { + return _EditPhoneWidget(); + } +} + +class _EditPhoneWidget extends State { + bool isEdit = false; + TextEditingController _vc; + + @override + void initState() { + // TODO: implement initState + super.initState(); + _vc = TextEditingController( + text: widget.storeInfo != null ? widget.storeInfo.headMobile : ""); + } + + @override + Widget build(BuildContext context) { + 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( + widget.storeInfo != null + ? widget.storeInfo.headMobile + : "", + overflow: TextOverflow.ellipsis, + textAlign: TextAlign.end, + style: TextStyle( + fontSize: 14.sp, + fontWeight: MyFontWeight.regular, + color: Color(0xFF4C4C4C), + ), + ), + ), + ), + GestureDetector( + onTap: () { + String mobile = _vc.text; + if (mobile != null && AppUtils.isPhone(mobile)) { + widget.mobileChange(mobile); + widget.storeInfo.headMobile = mobile; + } + 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, + ), + ), + ), + ], + ), + ); + } +} diff --git a/lib/settlement/settlement_view/pay_method.dart b/lib/settlement/settlement_view/pay_method.dart new file mode 100644 index 00000000..d1598eee --- /dev/null +++ b/lib/settlement/settlement_view/pay_method.dart @@ -0,0 +1,156 @@ + +import 'package:flutter/material.dart'; +import 'package:flutter_screenutil/flutter_screenutil.dart'; +import 'package:huixiang/generated/l10n.dart'; +import 'package:huixiang/utils/font_weight.dart'; + +class PayMethod extends StatefulWidget { + + @override + State createState() { + return _PayMethod(); + } + +} + +class _PayMethod extends State { + @override + Widget build(BuildContext context) { + 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, + ), + ), + ), + ], + ), + ), + ], + ), + ); + } + + 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, + ), + ); + } + +} \ No newline at end of file diff --git a/lib/settlement/settlement_view/settlement_activity.dart b/lib/settlement/settlement_view/settlement_activity.dart new file mode 100644 index 00000000..088a4844 --- /dev/null +++ b/lib/settlement/settlement_view/settlement_activity.dart @@ -0,0 +1,174 @@ +import 'package:flutter/material.dart'; +import 'package:huixiang/retrofit/data/settleOrderInfo.dart'; +import 'package:huixiang/retrofit/data/store_info.dart'; +import 'package:huixiang/settlement/settlement_view/activity.dart'; +import 'package:huixiang/settlement/settlement_view/coupon.dart'; +import 'package:huixiang/utils/font_weight.dart'; +import 'package:flutter_screenutil/flutter_screenutil.dart'; + +class SettlementActivity extends StatefulWidget { + + final StoreInfo storeInfo; + final SettleOrderInfo settleOrderInfo; + + SettlementActivity(this.settleOrderInfo, this.storeInfo); + + @override + State createState() { + return _SettlementActivity(); + } +} + +class _SettlementActivity extends State { + List promotionInfoCan = []; + List promotionInfoNo = []; + + @override + void initState() { + super.initState(); + + promotionInfoCan.clear(); + promotionInfoNo.clear(); + + if (widget.settleOrderInfo != null && + widget.settleOrderInfo.promotionInfoList != null && + widget.settleOrderInfo.promotionInfoList.length > 0) { + widget.settleOrderInfo.promotionInfoList.forEach((element) { + if (element.canPartake) { + promotionInfoCan.add(element); + } else { + promotionInfoNo.add(element); + } + }); + setState(() {}); + } + } + + @override + Widget build(BuildContext context) { + return StatefulBuilder( + builder: (context1, state) { + return Container( + alignment: Alignment.topCenter, + width: double.infinity, + height: MediaQuery.of(context).size.height / 3 * 2, + decoration: BoxDecoration( + color: Colors.white, + borderRadius: BorderRadius.only( + topLeft: Radius.circular(8), + topRight: Radius.circular(8), + ), + ), + child: SingleChildScrollView( + physics: BouncingScrollPhysics(), + 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( + "可参加的活动(${promotionInfoCan.length})", + 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, + ), + ), + ], + ), + ), + Container( + padding: EdgeInsets.only( + top: 8, + left: 16, + right: 16, + ), + child: ListView.builder( + itemCount: (promotionInfoCan == null || + promotionInfoCan.length == 0) + ? 0 + : promotionInfoCan.length, + shrinkWrap: true, + physics: NeverScrollableScrollPhysics(), + itemBuilder: (context, position) { + return ActivityWidget( + promotionInfoCan[position], + widget.storeInfo, + position, + callback: (){ + Navigator.of(context).pop(promotionInfoCan[position]); + }, + ); + }, + ), + ), + if (promotionInfoNo != null || promotionInfoNo.length > 0) + Container( + padding: EdgeInsets.only( + top: 16, + left: 16, + right: 16, + bottom: 8, + ), + child: Text( + "不可参加的活动", + style: TextStyle( + color: Color(0xFF000000), + fontSize: 14.sp, + fontWeight: MyFontWeight.medium, + ), + ), + ), + if (promotionInfoNo != null || promotionInfoNo.length > 0) + Container( + padding: EdgeInsets.only( + top: 8, + left: 16, + right: 16, + ), + child: ListView.builder( + itemCount: (promotionInfoNo == null || + promotionInfoNo.length == 0) + ? 0 + : promotionInfoNo.length, + shrinkWrap: true, + physics: NeverScrollableScrollPhysics(), + itemBuilder: (context, position) { + return ActivityWidget( + promotionInfoNo[position], + widget.storeInfo, + position, + ); + }, + ), + ), + ], + ), + ), + ); + }, + ); + } +} diff --git a/lib/settlement/settlement_view/settlement_coupon.dart b/lib/settlement/settlement_view/settlement_coupon.dart new file mode 100644 index 00000000..d9bf735f --- /dev/null +++ b/lib/settlement/settlement_view/settlement_coupon.dart @@ -0,0 +1,166 @@ +import 'package:flutter/material.dart'; +import 'package:huixiang/retrofit/data/settleOrderInfo.dart'; +import 'package:huixiang/retrofit/data/store_info.dart'; +import 'package:huixiang/settlement/settlement_view/coupon.dart'; +import 'package:huixiang/utils/font_weight.dart'; +import 'package:flutter_screenutil/flutter_screenutil.dart'; + +class SettlementCoupon extends StatefulWidget { + final StoreInfo storeInfo; + final SettleOrderInfo settleOrderInfo; + final CouponListBean couponBean; + + SettlementCoupon( + this.settleOrderInfo, + this.storeInfo, { + this.couponBean, + }); + + @override + State createState() { + return _SettlementCoupon(); + } +} + +class _SettlementCoupon extends State { + List couponCan = []; + List couponNo = []; + + @override + void initState() { + super.initState(); + + couponCan.clear(); + couponNo.clear(); + + if (widget.settleOrderInfo != null && + widget.settleOrderInfo.couponList != null && + widget.settleOrderInfo.couponList.length > 0) { + widget.settleOrderInfo.couponList.forEach((element) { + if (element.usable) { + couponCan.add(element); + } else { + couponNo.add(element); + } + }); + setState(() {}); + } + } + + @override + Widget build(BuildContext context) { + return StatefulBuilder( + builder: (context1, state) { + return Container( + alignment: Alignment.topCenter, + width: double.infinity, + height: MediaQuery.of(context).size.height / 3 * 2, + decoration: BoxDecoration( + color: Colors.white, + borderRadius: BorderRadius.only( + topLeft: Radius.circular(8), + topRight: Radius.circular(8), + ), + ), + child: SingleChildScrollView( + 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( + "可用优惠券(${couponCan.length})", + 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, + ), + ), + ], + ), + ), + Container( + padding: EdgeInsets.only( + top: 8, + left: 16, + right: 16, + ), + child: ListView.builder( + itemCount: couponCan == null ? 0 : couponCan.length, + physics: NeverScrollableScrollPhysics(), + shrinkWrap: true, + itemBuilder: (context, position) { + return CouponWidget( + couponCan[position], + widget.storeInfo, + selected: widget.couponBean == couponCan[position], + ); + }, + ), + ), + if (couponNo != null || couponNo.length > 0) + Container( + padding: EdgeInsets.only( + top: 16, + left: 16, + right: 16, + bottom: 8, + ), + child: Text( + "不可用优惠券", + style: TextStyle( + color: Color(0xFF000000), + fontSize: 14.sp, + fontWeight: MyFontWeight.medium, + ), + ), + ), + if (couponNo != null || couponNo.length > 0) + Container( + padding: EdgeInsets.only( + top: 8, + left: 16, + right: 16, + ), + child: ListView.builder( + itemCount: couponNo == null ? 0 : couponNo.length, + physics: NeverScrollableScrollPhysics(), + shrinkWrap: true, + itemBuilder: (context, position) { + return CouponWidget( + couponNo[position], + widget.storeInfo, + ); + }, + ), + ), + ], + ), + ), + ); + }, + ); + } +} diff --git a/lib/settlement/settlement_view/settlement_order_commodity.dart b/lib/settlement/settlement_view/settlement_order_commodity.dart index 51286a0b..f4c18d19 100644 --- a/lib/settlement/settlement_view/settlement_order_commodity.dart +++ b/lib/settlement/settlement_view/settlement_order_commodity.dart @@ -12,7 +12,7 @@ class SettlementOrderCommodity extends StatefulWidget { final SettleOrderInfo settleOrderInfo; - SettlementOrderCommodity(this.isTakeOut,this.settleOrderInfo); + SettlementOrderCommodity(this.isTakeOut, this.settleOrderInfo); @override State createState() { @@ -68,8 +68,9 @@ class _SettlementOrderCommodity extends State { if (widget.settleOrderInfo == null) return []; List widgets = []; if (widget.settleOrderInfo != null) { - widgets.addAll( - widget.settleOrderInfo.orderProductList.map((e) => commodityItem(e)).toList()); + widgets.addAll(widget.settleOrderInfo.orderProductList + .map((e) => commodityItem(e)) + .toList()); } widgets.add(SizedBox(height: 20.h)); @@ -81,8 +82,7 @@ class _SettlementOrderCommodity extends State { ? S.of(context).peisongfei : S.of(context).yunfei, "", - "+${widget.settleOrderInfo?.postAge??"0"}" - )); + "+${widget.settleOrderInfo?.postAge ?? "0"}")); } widgets.add(Container( @@ -101,7 +101,6 @@ class _SettlementOrderCommodity extends State { } Widget commodityItem(OrderProductListBean productList) { - return Container( margin: EdgeInsets.only(top: 8.h, bottom: 8.h), child: Row( @@ -153,8 +152,8 @@ class _SettlementOrderCommodity extends State { Expanded( flex: 1, child: Text( - productList.weight != null - ? "${productList.weight}kg" + productList.skuNameStr != null + ? "${productList.skuNameStr ?? ""}" : "", overflow: TextOverflow.ellipsis, style: TextStyle( @@ -315,19 +314,34 @@ class _SettlementOrderCommodity extends State { ? widget.settleOrderInfo.orderProductList.length : "0"), style: TextStyle( - fontSize: 10.sp, - color: Color(0xFFA29E9E), - fontWeight: MyFontWeight.semi_bold), + fontSize: 10.sp, + color: Color(0xFFA29E9E), + fontWeight: MyFontWeight.semi_bold, + ), ), flex: 1, ), + Container( + child: Text( + "已优惠:¥${widget.settleOrderInfo.discountAmount}", + style: TextStyle( + fontSize: 12.sp, + color: Color(0xFF7B7B7B), + fontWeight: MyFontWeight.medium, + ), + ), + ), + SizedBox( + width: 15.w, + ), Container( child: Text( S.of(context).jiesuanjine, style: TextStyle( - fontSize: 12.sp, - color: Color(0xFF353535), - fontWeight: MyFontWeight.semi_bold), + fontSize: 12.sp, + color: Color(0xFF353535), + fontWeight: MyFontWeight.semi_bold, + ), ), ), SizedBox( @@ -337,10 +351,11 @@ class _SettlementOrderCommodity extends State { totalPrice(), textAlign: TextAlign.end, style: TextStyle( - fontSize: 14.sp, - color: Color(0xFF32A060), - fontWeight: MyFontWeight.semi_bold), - ) + fontSize: 14.sp, + color: Color(0xFF32A060), + fontWeight: MyFontWeight.semi_bold, + ), + ), ], ), ); diff --git a/lib/store/store_order.dart b/lib/store/store_order.dart index 015a3936..bc340880 100644 --- a/lib/store/store_order.dart +++ b/lib/store/store_order.dart @@ -25,6 +25,7 @@ import 'package:huixiang/utils/font_weight.dart'; import 'package:huixiang/view_widget/classic_header.dart'; import 'package:huixiang/view_widget/custom_image.dart'; import 'package:huixiang/view_widget/my_tab.dart'; +import 'package:huixiang/view_widget/receive_success.dart'; import 'package:huixiang/view_widget/round_button.dart'; import 'package:pull_to_refresh/pull_to_refresh.dart'; import 'package:shared_preferences/shared_preferences.dart'; @@ -239,7 +240,7 @@ class _StoreOrderPage extends State storeInfo.couponVOList != null) UnionCoupon( storeInfo, - (a) {}, + _receiveCoupon, coupon: true, ), @@ -315,7 +316,6 @@ class _StoreOrderPage extends State shopCarGoods, controller, _queryMiNiDetail, - // _productListResult, _fc, ), @@ -416,6 +416,26 @@ class _StoreOrderPage extends State ); } + ///领取优惠券 + _receiveCoupon(couponId) async { + BaseData baseData = await apiService.receiveCoupon(couponId); + if (baseData != null && baseData.isSuccess) { + queryStoreInfo(); + showAlertDialog(); + } + } + + /// 领取成功弹窗 + showAlertDialog() { + //显示对话框 + showDialog( + context: context, + builder: (BuildContext context) { + return ReceiveSuccess(); + }, + ); + } + ///计算个数 int count() { if (shopCarGoods == null || diff --git a/lib/utils/flutter_utils.dart b/lib/utils/flutter_utils.dart index 494bd722..95a524be 100644 --- a/lib/utils/flutter_utils.dart +++ b/lib/utils/flutter_utils.dart @@ -8,6 +8,14 @@ import 'package:path_provider/path_provider.dart'; class AppUtils { + ///计算距离(当前位置到店位置直线距离) + static Future calculateDistance(BMFCoordinate bmfCoordinate, BMFCoordinate myLatLng) async { + double mi = await BMFCalculateUtils.getLocationDistance(bmfCoordinate, myLatLng); + NumberFormat numberFormat = NumberFormat("#.#"); + return "${numberFormat.format(mi / 1000)}"; + } + + static Future coordConvert(BMFCoordinate latLng) async { return BMFCalculateUtils.coordConvert( coordinate: latLng, @@ -15,6 +23,12 @@ class AppUtils { toType: BMF_COORD_TYPE.COMMON); } + static bool isPhone(mobile) { + RegExp exp = RegExp( + r'^((13[0-9])|(14[0-9])|(15[0-9])|(16[0-9])|(17[0-9])|(18[0-9])|(19[0-9]))\d{8}$'); + return exp.hasMatch(mobile); + } + static double textScale(context) { double textScaleFactor = MediaQuery.of(context).textScaleFactor; // print("textScaleFactor: $textScaleFactor"); diff --git a/lib/utils/location.dart b/lib/utils/location.dart index 404ed9fd..316e5775 100644 --- a/lib/utils/location.dart +++ b/lib/utils/location.dart @@ -1,6 +1,3 @@ - - - import 'dart:io'; import 'package:android_intent_plus/android_intent.dart'; @@ -11,7 +8,6 @@ import 'package:huixiang/view_widget/request_permission.dart'; import 'package:permission_handler/permission_handler.dart'; class Location { - static Location _instance; Location._internal() { @@ -74,8 +70,7 @@ class Location { } void stopLocation() { - if (aMapFlutterLocation != null) - aMapFlutterLocation.stopLocation(); + if (aMapFlutterLocation != null) aMapFlutterLocation.stopLocation(); } enableLocation(context) { @@ -87,8 +82,8 @@ class Location { S.of(context).nindingweigongnengweikaiqi, S.of(context).weilexiangnintuijianfujindemendianxinxi, S.of(context).dakaidingwei, - (result) async { - if(result) { + (result) async { + if (result) { final AndroidIntent intent = AndroidIntent( action: 'action_location_source_settings', package: "com.zsw.huixiang"); @@ -104,29 +99,24 @@ class Location { requestDialog(context) { showCupertinoDialog( - context: context, - builder: (context) { - return RequestPermission( - "assets/image/icon_permission_location_bg.png", - S.of(context).nindingweiquanxianweiyunxu, - S.of(context).weilexiangnintuijianfujindemendianxinxi, - S.of(context).kaiqiquanxian, - (result) async { - if (result) { - await openAppSettings(); - if (await Permission.location.isGranted) { - startLocation(context); - } + context: context, + builder: (context) { + return RequestPermission( + "assets/image/icon_permission_location_bg.png", + S.of(context).nindingweiquanxianweiyunxu, + S.of(context).weilexiangnintuijianfujindemendianxinxi, + S.of(context).kaiqiquanxian, + (result) async { + if (result) { + await openAppSettings(); + if (await Permission.location.isGranted) { + startLocation(context); } - }, - heightRatioWithWidth: 0.82, - ); - }); + } + }, + heightRatioWithWidth: 0.82, + ); + }, + ); } - } - - - - -