From 2a226e156c8ea532d88dec095af7341b51e1ec49 Mon Sep 17 00:00:00 2001 From: wurong <953969641@qq.com> Date: Tue, 28 Mar 2023 14:30:47 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=94=B9=E8=AE=A2=E5=8D=95=E7=BB=93?= =?UTF-8?q?=E7=AE=97vip=E6=8C=89=E9=92=AE=E4=BA=8B=E4=BB=B6=EF=BC=9B=20?= =?UTF-8?q?=E6=9B=B4=E6=94=B9=E6=88=91=E7=9A=84=E9=A1=B5=E9=9D=A2=EF=BC=8C?= =?UTF-8?q?=E9=9A=90=E8=97=8F=E5=95=86=E5=AE=B6=E5=85=A5=E9=A9=BB=E6=9D=BF?= =?UTF-8?q?=E5=9D=97=EF=BC=9B=EF=BC=88=E5=B0=8F=E7=B1=B3=E5=AE=A1=E6=A0=B8?= =?UTF-8?q?=E8=A6=81=E6=B1=82=EF=BC=89=20=E6=9B=B4=E6=94=B9=E8=AE=A2?= =?UTF-8?q?=E5=8D=95=E8=AF=A6=E6=83=85ui=EF=BC=9B=20=E8=AE=A2=E5=8D=95?= =?UTF-8?q?=E7=BB=93=E7=AE=97=E9=A1=B5=E5=8E=BB=E6=8E=89=E2=80=9C=E8=AE=A2?= =?UTF-8?q?=E5=8D=95=E6=AD=A3=E5=9C=A8=E6=8F=90=E4=BA=A4=E4=B8=AD=E2=80=9D?= =?UTF-8?q?=E6=8F=90=E7=A4=BA=20=E6=9B=B4=E6=94=B9=E5=A5=97=E9=A4=90?= =?UTF-8?q?=EF=BC=8C=E9=80=82=E9=85=8D=E5=A5=B6=E8=8C=B6=E5=A5=97=E9=A4=90?= =?UTF-8?q?=20=E6=9B=B4=E6=94=B9=E5=A5=97=E9=A4=90=E8=A7=84=E6=A0=BC?= =?UTF-8?q?=E6=98=BE=E7=A4=BA=E6=A0=B7=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/mine/mine_view/mine_item.dart | 21 +- lib/order/order_detail_page.dart | 79 +++--- lib/retrofit/data/miNiDetail.dart | 7 + lib/settlement/settlement.dart | 25 +- .../activity_coupon_remarks.dart | 3 +- lib/store/store_view/product_meals_sku.dart | 225 ++++++++++++------ lib/store/store_view/shop_goods_car.dart | 23 +- 7 files changed, 240 insertions(+), 143 deletions(-) diff --git a/lib/mine/mine_view/mine_item.dart b/lib/mine/mine_view/mine_item.dart index 6a37dc05..c53bcb3b 100644 --- a/lib/mine/mine_view/mine_item.dart +++ b/lib/mine/mine_view/mine_item.dart @@ -252,16 +252,16 @@ class _MineItem extends State { // ), // ),), ///商户入驻 - Expanded(child: InkWell( - onTap: () { - SmartDialog.showToast("该功能暂未开放!", - alignment: Alignment.center); - }, - child: mineItem( - S.of(context).shanghuruzhu, - "assets/image/settled.webp", - ), - ),), + // Expanded(child: InkWell( + // onTap: () { + // SmartDialog.showToast("该功能暂未开放!", + // alignment: Alignment.center); + // }, + // child: mineItem( + // S.of(context).shanghuruzhu, + // "assets/image/settled.webp", + // ), + // ),), ///帮助反馈 Expanded(child: InkWell( onTap: () { @@ -283,6 +283,7 @@ class _MineItem extends State { ), ),), Expanded(child:Container(),), + Expanded(child:Container(),), // ///帮助反馈 // Expanded(child: InkWell( // onTap: () { diff --git a/lib/order/order_detail_page.dart b/lib/order/order_detail_page.dart index 37d61db5..73f52e6a 100644 --- a/lib/order/order_detail_page.dart +++ b/lib/order/order_detail_page.dart @@ -180,48 +180,51 @@ class _OrderDetailPage extends State { }, physics: BouncingScrollPhysics(), scrollController: ScrollController(), - child: Column( - children: [ - ///订单状态显示 - OrderStatus( - orderStatus, - isTakeOut, - sendStatus, - payStatus, - refundStatus, - title, - center, - orderInfo, - ), - - ///订单取货地址,或, 收货地址 - if(orderInfo != null && orderInfo.addressExt != null) - OrderAddress( - orderStatus, - isTakeOut, - sendStatus, - payStatus, - refundStatus, - title, - center, - paySelected, - _orderCancel, - orderInfo, - jumpState + child:SingleChildScrollView( + physics: BouncingScrollPhysics(), + child: Column( + children: [ + ///订单状态显示 + OrderStatus( + orderStatus, + isTakeOut, + sendStatus, + payStatus, + refundStatus, + title, + center, + orderInfo, ), - ///订单商品 - if(orderInfo != null) - OrderCommodity(orderInfo), + ///订单取货地址,或, 收货地址 + if(orderInfo != null && orderInfo.addressExt != null) + OrderAddress( + orderStatus, + isTakeOut, + sendStatus, + payStatus, + refundStatus, + title, + center, + paySelected, + _orderCancel, + orderInfo, + jumpState + ), - ///显示订单信息 - if(orderInfo != null) - OrderInfoView(orderInfo, isTakeOut), + ///订单商品 + if(orderInfo != null) + OrderCommodity(orderInfo), - Container( - height: 42.h, - ), - ], + ///显示订单信息 + if(orderInfo != null) + OrderInfoView(orderInfo, isTakeOut), + + Container( + height: 42.h, + ), + ], + ), ), ), ) diff --git a/lib/retrofit/data/miNiDetail.dart b/lib/retrofit/data/miNiDetail.dart index c2f2a725..6f5fb06e 100644 --- a/lib/retrofit/data/miNiDetail.dart +++ b/lib/retrofit/data/miNiDetail.dart @@ -649,6 +649,7 @@ class SkuInfoList { } String _id; String _skuName; + bool _isSelected = false; List _productSkuAttrList; SkuInfoList copyWith({ String id, String skuName, @@ -661,6 +662,12 @@ class SkuInfoList { String get skuName => _skuName; List get productSkuAttrList => _productSkuAttrList; + bool get isSelected => _isSelected; + + set isSelected(bool value) { + _isSelected = value; + } + Map toJson() { final map = {}; map['id'] = _id; diff --git a/lib/settlement/settlement.dart b/lib/settlement/settlement.dart index 23f86df5..023e78aa 100644 --- a/lib/settlement/settlement.dart +++ b/lib/settlement/settlement.dart @@ -518,7 +518,7 @@ class _Settlement extends State { placeOrderFirst.storeId = storeInfo.id; placeOrderFirst.subcribeTime = null; placeOrderFirst.tableId = "$tableId"; - for(int i = 0;i { this.downOrder = DownOrder.fromJson(baseData.data); querySettlement(); } else { - orderButton = false; + // orderButton = false; SmartDialog.showToast(baseData?.msg, alignment: Alignment.center); } } else { @@ -562,7 +562,7 @@ class _Settlement extends State { }); } } - orderButton = false; + // orderButton = false; if (baseData != null && baseData.isSuccess) { placeOrder = true; this.downOrder = DownOrder.fromJson(baseData.data); @@ -570,7 +570,7 @@ class _Settlement extends State { queryOrderDetails(parentId); setState(() {}); } else { - orderButton = false; + // orderButton = false; SmartDialog.showToast(baseData?.msg, alignment: Alignment.center); } } @@ -597,7 +597,7 @@ class _Settlement extends State { .catchError((error) { print(error); }); - orderButton = false; + // orderButton = false; if (baseData != null && baseData.isSuccess) { WxPay wxPay = baseData.data; await registerWxApi( @@ -621,12 +621,13 @@ class _Settlement extends State { .catchError((error) { print(error); }); - orderButton = false; + // orderButton = false; if (baseData != null && baseData.isSuccess) { SmartDialog.showToast(baseData.data, alignment: Alignment.center); toOrderDetails(placeOrderFirst.id); } else { SmartDialog.show( + clickBgDismissTemp: false, widget: SettlementTips( () { toOrderDetails(placeOrderFirst.id); @@ -895,12 +896,12 @@ class _Settlement extends State { vertical: 5.h, ), callback: () { - if (orderButton) { - SmartDialog.showToast("订单正在提交中...", - alignment: Alignment.center); - return; - } else - orderButton = true; + // if (orderButton) { + // SmartDialog.showToast("订单正在提交中...", + // alignment: Alignment.center); + // return; + // } else + // orderButton = true; pageType != null ? bargainOrderId != null ? activityPay() diff --git a/lib/settlement/settlement_view/activity_coupon_remarks.dart b/lib/settlement/settlement_view/activity_coupon_remarks.dart index 7538970f..4335d428 100644 --- a/lib/settlement/settlement_view/activity_coupon_remarks.dart +++ b/lib/settlement/settlement_view/activity_coupon_remarks.dart @@ -112,7 +112,6 @@ class _ActivityCouponRemarks extends State { GestureDetector( onTap: () { setState(() { - // (widget.coupons != null && widget.coupons != ""||widget.promotions != null && widget.promotions != "") ? false:vipSelect, if ((widget?.settleOrderInfo?.memberVO?.isVip ?? false)) { vipSelect = !vipSelect; widget.vipPriceSelect(vipSelect); @@ -126,7 +125,7 @@ class _ActivityCouponRemarks extends State { padding: EdgeInsets.only(bottom: 18.w), alignment: Alignment.center, child: Image.asset( - vipSelect + ((widget.coupons != null && widget.coupons != ""||widget.promotions != null && widget.promotions != "") ? false:vipSelect) ? "assets/image/vip_price.webp" : "assets/image/vip_unprice.webp", width: 38.w, diff --git a/lib/store/store_view/product_meals_sku.dart b/lib/store/store_view/product_meals_sku.dart index cfa3906d..408932a7 100644 --- a/lib/store/store_view/product_meals_sku.dart +++ b/lib/store/store_view/product_meals_sku.dart @@ -84,21 +84,22 @@ class _ProductMealsSku extends State { ///添加购物车 addShopCar() async { - List setMealDataList = []; productSetMeals.forEach((element) { List productInfoListBean = []; element.productInfoList.forEach((ele) { - if(ele.count > 0) - productInfoListBean.add({ - "productId":ele.productId, - "skuId":(ele.productAttrInfoList[0].attrName == "") ? (ele.skuInfoList[0].productSkuAttrList[0].skuId): - (ele.skuInfoList.firstWhere((e1) => e1.skuName == ele.productAttrInfoList[0].selectSku).id) - }); + if (ele.count > 0) { + productInfoListBean.add({ + "productId": ele.productId, + "skuId": ele.skuInfoList.length == 1 + ? ele.skuInfoList.first.id + : ele.skuInfoList.firstWhere((e2) => e2.isSelected).id + }); + } }); setMealDataList.add({ - "groupName":element.groupName, - "productInfoList":productInfoListBean + "groupName": element.groupName, + "productInfoList": productInfoListBean }); }); @@ -114,17 +115,18 @@ class _ProductMealsSku extends State { "skuPrice": miNiDetail.productSkuVOList[0].skuPrice, "skuStock": miNiDetail.productSkuVOList[0].skuStock, "skuImg": miNiDetail.productSkuVOList[0].skuImg, - "setMealDataList":setMealDataList + "setMealDataList": setMealDataList }, ], }; - BaseData> baseDate = await minService.addShoppingCart(requestData); - EasyLoading.dismiss(); - if (baseDate != null && baseDate.isSuccess) { - Navigator.of(context).pop(); - } else { - SmartDialog.showToast(baseDate?.msg, alignment: Alignment.center); + BaseData> baseDate = + await minService.addShoppingCart(requestData); + EasyLoading.dismiss(); + if (baseDate != null && baseDate.isSuccess) { + Navigator.of(context).pop(); + } else { + SmartDialog.showToast(baseDate?.msg, alignment: Alignment.center); } } @@ -210,8 +212,7 @@ class _ProductMealsSku extends State { shrinkWrap: true, padding: EdgeInsets.zero, itemBuilder: (context, position) { - return productMealsList( - position); + return productMealsList(position); }, ), ], @@ -304,14 +305,14 @@ class _ProductMealsSku extends State { shrinkWrap: true, padding: EdgeInsets.zero, itemBuilder: (context, index) { - return productMealsItem(position,index); + return productMealsItem(position, index); }, ), ], )); } - Widget productMealsItem(int position,int index) { + Widget productMealsItem(int position, int index) { return Container( margin: EdgeInsets.symmetric(vertical: 16.h), child: Row( @@ -335,7 +336,10 @@ class _ProductMealsSku extends State { children: [ Expanded( child: Text( - productSetMeals[position].productInfoList[index].productName ?? "", + productSetMeals[position] + .productInfoList[index] + .productName ?? + "", overflow: TextOverflow.ellipsis, maxLines: 1, style: TextStyle( @@ -345,7 +349,11 @@ class _ProductMealsSku extends State { ), ), ), - if (productSetMeals[position].productInfoList[index].productAttrInfoList[0].attrName != "") + if (productSetMeals[position] + .productInfoList[index] + .productAttrInfoList[0] + .attrName != + "") GestureDetector( child: Text( "选规格", @@ -356,29 +364,43 @@ class _ProductMealsSku extends State { ), ), onTap: () { - showSkuDialog(position,index); + showSkuDialog(position, index); }, ), - if (productSetMeals[position].productInfoList[index].productAttrInfoList[0].attrName != "") - GestureDetector( - onTap: (){ - showSkuDialog(position,index); - }, - child: Icon( - Icons.chevron_right, - color: Colors.black, - size: 18, - ), - ) + if (productSetMeals[position] + .productInfoList[index] + .productAttrInfoList[0] + .attrName != + "") + GestureDetector( + onTap: () { + showSkuDialog(position, index); + }, + child: Icon( + Icons.chevron_right, + color: Colors.black, + size: 18, + ), + ) ], ), SizedBox(height: 8.h), Row( children: [ - if (productSetMeals[position].productInfoList[index].productAttrInfoList[0].attrName != "" - && productSetMeals[position].productInfoList[index].count > 0) + if (productSetMeals[position] + .productInfoList[index] + .skuInfoList + .where((element) => element.isSelected) + .isNotEmpty && + productSetMeals[position].productInfoList[index].count > + 0) Text( - productSetMeals[position].productInfoList[index].productAttrInfoList[0].selectSku ?? "", + productSetMeals[position] + .productInfoList[index] + .skuInfoList + .firstWhere((element) => element.isSelected) + .skuName ?? + "", overflow: TextOverflow.ellipsis, maxLines: 1, style: TextStyle( @@ -391,8 +413,13 @@ class _ProductMealsSku extends State { InkWell( onTap: () { setState(() { - if (productSetMeals[position].productInfoList[index].count >= 1) - productSetMeals[position].productInfoList[index].count -= 1; + if (productSetMeals[position] + .productInfoList[index] + .count >= + 1) + productSetMeals[position] + .productInfoList[index] + .count -= 1; }); }, child: Image.asset( @@ -405,7 +432,10 @@ class _ProductMealsSku extends State { width: 30, alignment: Alignment.center, child: Text( - productSetMeals[position].productInfoList[index].count.toString(), + productSetMeals[position] + .productInfoList[index] + .count + .toString(), style: TextStyle( color: Colors.black, fontSize: 14.sp, @@ -416,21 +446,33 @@ class _ProductMealsSku extends State { GestureDetector( onTap: () { setState(() { - if(productSetMeals[position].productInfoList[index].productAttrInfoList[0].attrName != ""){ - showSkuDialog(position,index); + if (productSetMeals[position] + .productInfoList[index] + .productAttrInfoList[0] + .attrName != + "") { + showSkuDialog(position, index); return; } int total = 0; - productSetMeals[position].productInfoList.forEach((element) { + productSetMeals[position] + .productInfoList + .forEach((element) { total += element.count; }); - if (total >= productSetMeals[position].optionalNumber) { + if (total >= + productSetMeals[position].optionalNumber) { SmartDialog.showToast("抱歉,无法加购更多", alignment: Alignment.center); return; } - if (productSetMeals[position].productInfoList[index].count == 0) - productSetMeals[position].productInfoList[index].count += 1; + if (productSetMeals[position] + .productInfoList[index] + .count == + 0) + productSetMeals[position] + .productInfoList[index] + .count += 1; }); }, child: Image.asset( @@ -452,16 +494,28 @@ class _ProductMealsSku extends State { ); } - Widget porAttrItem(int position,int index,int pos,state) { - if (productSetMeals[position].productInfoList[index].productAttrInfoList[pos].attrValueList != null && - productSetMeals[position].productInfoList[index].productAttrInfoList[pos].attrValueList.length > 0) + Widget porAttrItem(int position, int index, int pos, state) { + if (productSetMeals[position] + .productInfoList[index] + .productAttrInfoList[pos] + .attrValueList != + null && + productSetMeals[position] + .productInfoList[index] + .productAttrInfoList[pos] + .attrValueList + .length > + 0) return Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Padding( padding: EdgeInsets.only(top: 16, bottom: 16), child: Text( - productSetMeals[position].productInfoList[index].productAttrInfoList[pos].attrName, + productSetMeals[position] + .productInfoList[index] + .productAttrInfoList[pos] + .attrName, style: TextStyle( color: Color(0xFFB3B3B3), fontSize: 14.sp, @@ -469,7 +523,7 @@ class _ProductMealsSku extends State { ), ), ), - sweetnessStore(position,index, pos,state), + sweetnessStore(position, index, pos, state), ], ); else { @@ -477,23 +531,36 @@ class _ProductMealsSku extends State { } } - Widget sweetnessStore(int position,int index,int pos,state) { + Widget sweetnessStore(int position, int index, int pos, state) { return Wrap( runSpacing: 10.0, spacing: 10.0, - children: productSetMeals[position].productInfoList[index].productAttrInfoList[pos].attrValueList - .take(productSetMeals[position].productInfoList[index].productAttrInfoList[pos].attrValueList.length) + children: productSetMeals[position] + .productInfoList[index] + .productAttrInfoList[pos] + .attrValueList + .take(productSetMeals[position] + .productInfoList[index] + .productAttrInfoList[pos] + .attrValueList + .length) .map((AttrValueList tag) { return GestureDetector( onTap: () { state(() { - productSetMeals[position].productInfoList[index].productAttrInfoList[pos].selectSku = - tag.attrName; + productSetMeals[position] + .productInfoList[index] + .productAttrInfoList[pos] + .selectSku = tag.attrName; }); }, child: sweetnessItem( tag.attrName, - (productSetMeals[position].productInfoList[index].productAttrInfoList[pos].selectSku == tag.attrName), + (productSetMeals[position] + .productInfoList[index] + .productAttrInfoList[pos] + .selectSku == + tag.attrName), )); }).toList()); } @@ -524,7 +591,7 @@ class _ProductMealsSku extends State { } ///选择規格弹窗 - showSkuDialog(int position,int index) async { + showSkuDialog(int position, int index) async { showDialog( context: context, builder: (context) { @@ -542,18 +609,15 @@ class _ProductMealsSku extends State { children: [ Expanded( child: ListView.builder( - itemCount: productSetMeals[position].productInfoList[index] + itemCount: productSetMeals[position] + .productInfoList[index] .productAttrInfoList .length, scrollDirection: Axis.vertical, physics: BouncingScrollPhysics(), padding: EdgeInsets.zero, itemBuilder: (context, pos) { - return porAttrItem( - position,index, - pos, - state - ); + return porAttrItem(position, index, pos, state); }, ), ), @@ -564,20 +628,45 @@ class _ProductMealsSku extends State { onTap: () { setState(() { int total = 0; - productSetMeals[position].productInfoList.forEach((element) { + productSetMeals[position] + .productInfoList + .forEach((element) { total += element.count; }); - if(productSetMeals[position].productInfoList[index].productAttrInfoList[0].selectSku == null){ + if (productSetMeals[position] + .productInfoList[index] + .productAttrInfoList + .where((element) => element.selectSku == null) + .isNotEmpty) { SmartDialog.showToast("请先选择规格", alignment: Alignment.center); return; } - if (total >= productSetMeals[position].optionalNumber && productSetMeals[position].productInfoList[index].count != 1) { + if (total >= productSetMeals[position].optionalNumber && + productSetMeals[position] + .productInfoList[index] + .count != + 1) { SmartDialog.showToast("抱歉,无法加购更多", alignment: Alignment.center); return; } - productSetMeals[position].productInfoList[index].count = 1; + productSetMeals[position].productInfoList[index].count = + 1; + productSetMeals[position] + .productInfoList[index] + .skuInfoList + .forEach((element) { + bool flag = true; + productSetMeals[position] + .productInfoList[index] + .productAttrInfoList + .forEach((e1) { + if (!element.skuName.contains(e1.selectSku)) + flag = false; + }); + element.isSelected = flag; + }); Navigator.of(context).pop(); }); }, diff --git a/lib/store/store_view/shop_goods_car.dart b/lib/store/store_view/shop_goods_car.dart index d727ecf2..084aa832 100644 --- a/lib/store/store_view/shop_goods_car.dart +++ b/lib/store/store_view/shop_goods_car.dart @@ -291,7 +291,7 @@ class _ShopGoodsCar extends State { child: Row( children: [ Expanded( - flex: 3, + flex:2, child: Text( setMealDataList.productInfoList[0].productName, overflow: TextOverflow.ellipsis, @@ -303,7 +303,7 @@ class _ShopGoodsCar extends State { ), ), ), - Expanded(flex: 2, + Expanded(flex:3, child: Text( "${(setMealDataList.productInfoList[0].skuName == "") ? "默认": setMealDataList.productInfoList[0].skuName}", overflow: TextOverflow.ellipsis, @@ -315,17 +315,14 @@ class _ShopGoodsCar extends State { ), ), ), - Expanded( - flex: 1, - child: Text( - setMealDataList.productInfoList[0].buyNumber.toString(), - overflow: TextOverflow.ellipsis, - maxLines: 1, - style: TextStyle( - color: Color(0xffFF7A1A), - fontSize: 13.sp, - fontWeight: MyFontWeight.regular, - ), + Text( + setMealDataList.productInfoList[0].buyNumber.toString(), + overflow: TextOverflow.ellipsis, + maxLines: 1, + style: TextStyle( + color: Color(0xffFF7A1A), + fontSize: 13.sp, + fontWeight: MyFontWeight.regular, ), ), ],