From 36b42e63405caa03d405ba2a60b93140e54e91a3 Mon Sep 17 00:00:00 2001 From: fmk Date: Thu, 14 Oct 2021 14:04:38 +0800 Subject: [PATCH] safety --- lib/store/store_order.dart | 3 +- lib/store/store_view/settlement.dart | 20 +-- lib/store/store_view/store_order_list.dart | 182 +++++++++++++-------- 3 files changed, 125 insertions(+), 80 deletions(-) diff --git a/lib/store/store_order.dart b/lib/store/store_order.dart index 49dfe413..6ab69206 100644 --- a/lib/store/store_order.dart +++ b/lib/store/store_order.dart @@ -407,7 +407,7 @@ class _StoreOrderPage extends State fontSize: 12.sp, radius: 100, ), - ) + ), ], ), ], @@ -557,7 +557,6 @@ class _StoreOrderPage extends State } calculatePrice() { - AiDecimalAccuracy allPriceDecimal = AiDecimalAccuracy.zero; int allCount = 0; shopCarGoods.forEach((element2) { diff --git a/lib/store/store_view/settlement.dart b/lib/store/store_view/settlement.dart index 81bc48af..b1c54034 100644 --- a/lib/store/store_view/settlement.dart +++ b/lib/store/store_view/settlement.dart @@ -82,16 +82,16 @@ class _Settlement extends State { ///订单结算信息 queryOrderInfo() async { - BaseData baseData = await minService.getOrderInfo({ - "addressId":0, - "isTake": 0, - "memberCouponId": 0, - "orderId": widget.arguments["orderId"], - "promotionId": 0 - }); - if (baseData != null && baseData.isSuccess) { - setState(() {}); - } + // BaseData baseData = await minService.getOrderInfo({ + // "addressId":0, + // "isTake": 0, + // "memberCouponId": 0, + // "orderId": widget.arguments["orderId"], + // "promotionId": 0 + // }); + // if (baseData != null && baseData.isSuccess) { + // setState(() {}); + // } } @override diff --git a/lib/store/store_view/store_order_list.dart b/lib/store/store_view/store_order_list.dart index ce5813c5..b4ed9754 100644 --- a/lib/store/store_view/store_order_list.dart +++ b/lib/store/store_view/store_order_list.dart @@ -10,6 +10,7 @@ import 'package:huixiang/retrofit/retrofit_api.dart'; import 'package:huixiang/store/store_view/shop_goods.dart'; import 'package:huixiang/utils/font_weight.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; +import 'package:huixiang/view_widget/round_button.dart'; import 'package:shared_preferences/shared_preferences.dart'; class StoreOrderListPage extends StatefulWidget { @@ -23,25 +24,22 @@ class StoreOrderListPage extends StatefulWidget { List> shopCarGoods; StoreOrderListPage( - this.arguments, - this.activitys, - this.storeInfo, - this.shopCarGoods, - this.controller, - this.queryMiNiDetail, - this.productListResult, - this.fc - ); + this.arguments, + this.activitys, + this.storeInfo, + this.shopCarGoods, + this.controller, + this.queryMiNiDetail, + this.productListResult, + this.fc); @override State createState() { return _StoreOrderListPage(); } - } class _StoreOrderListPage extends State { - int isSelected = 0; int tempClickIndex = 0; ApiService apiService; @@ -54,7 +52,6 @@ class _StoreOrderListPage extends State { super.initState(); appletGoods(); - } ///小程序查询分组及商品列表 @@ -89,40 +86,44 @@ class _StoreOrderListPage extends State { @override Widget build(BuildContext context) { return Container( - width: MediaQuery.of(context).size.width, - height: MediaQuery.of(context).size.height - (kToolbarHeight + 38 + 54.h), - margin: EdgeInsets.only( - top: (MediaQuery.of(context).padding.top + 38 + kToolbarHeight), - ), - child: Row( - mainAxisAlignment: MainAxisAlignment.start, - mainAxisSize: MainAxisSize.max, - children: [ - Container( - width: 100.w, - child: ListView.builder( - itemCount: appletProducts == null ? 0 : appletProducts.length, - controller: controller1, - physics: BouncingScrollPhysics(), - padding: EdgeInsets.only(top: 0, bottom: 25), - itemBuilder: (context, position) { - return orderItem(appletProducts[position], position); - }, + width: MediaQuery.of(context).size.width, + height: + MediaQuery.of(context).size.height - (kToolbarHeight + 38 + 54.h), + margin: EdgeInsets.only( + top: (MediaQuery.of(context).padding.top + 38 + kToolbarHeight), + ), + child: Row( + mainAxisAlignment: MainAxisAlignment.start, + mainAxisSize: MainAxisSize.max, + children: [ + Container( + width: 100.w, + child: ListView.builder( + itemCount: + appletProducts == null ? 0 : appletProducts.length, + controller: controller1, + physics: BouncingScrollPhysics(), + padding: EdgeInsets.only(top: 0, bottom: 25), + itemBuilder: (context, position) { + return orderItem(appletProducts[position], position); + }, + ), ), - ), - Container( - width: MediaQuery.of(context).size.width - 100.w, - child: ListView.builder( - itemCount: productListBeans == null ? 0 : productListBeans.length, - physics: BouncingScrollPhysics(), - padding: EdgeInsets.zero, - itemBuilder: (context, position) { - return goodsItem(position); - }, + Container( + width: MediaQuery.of(context).size.width - 100.w, + child: ListView.builder( + itemCount: productListBeans == null + ? 0 + : productListBeans.length, + physics: BouncingScrollPhysics(), + padding: EdgeInsets.zero, + itemBuilder: (context, position) { + return goodsItem(position); + }, + ), ), - ), - ], - ), + ], + ), ); } @@ -130,41 +131,86 @@ class _StoreOrderListPage extends State { ScrollController controller2 = ScrollController(); Widget orderItem(FindMiNiGroupList findMiNiGroupList, int index) { + int count = calculateItemCount(findMiNiGroupList); return Container( - child: Column( - mainAxisAlignment: MainAxisAlignment.spaceAround, - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - GestureDetector( - onTap: () { - setState(() { - isSelected = index; - productListBeans.clear(); - productListBeans.addAll(findMiNiGroupList.productList); - }); - }, - child: Container( + width: 100, + child: GestureDetector( + onTap: () { + setState(() { + isSelected = index; + productListBeans.clear(); + productListBeans.addAll(findMiNiGroupList.productList); + }); + }, + child: Stack( + alignment: Alignment.center, + children: [ + Container( color: isSelected != index ? Color(0xFFFAFAFA) : Colors.white, alignment: Alignment.center, padding: EdgeInsets.all(15), - child: Text( - findMiNiGroupList.groupName, - textAlign: TextAlign.center, - style: TextStyle( - color: isSelected != index - ? Color(0xFF202020) - : Color(0xFF000000), + child: Row( + mainAxisAlignment: MainAxisAlignment.center, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + if (isSelected == index) + Container( + width: 2, + height: 17, + color: Color(0xFF32A060), + margin: EdgeInsets.only(right: 10), + ), + Expanded( + child: Text( + findMiNiGroupList.groupName, + textAlign: TextAlign.center, + style: TextStyle( + color: isSelected != index + ? Color(0xFF202020) + : Color(0xFF000000), + fontSize: 12.sp, + fontWeight: MyFontWeight.medium, + ), + ), + flex: 1, + ), + ], + ), + ), + Positioned( + right: 0, + child: Visibility( + visible: count > 0, + child: RoundButton( + width: 17, + height: 17, + text: "$count", + textColor: Colors.white, + fontWeight: MyFontWeight.regular, + backgroup: Color(0xFF32A060), fontSize: 12.sp, - fontWeight: MyFontWeight.medium, + radius: 100, ), ), ), - ), - ], + ], + ), ), ); } + int calculateItemCount(FindMiNiGroupList findMiNiGroupList) { + int count = 0; + findMiNiGroupList.productList.forEach((element) { + widget.shopCarGoods.forEach((element1) { + if (element.id == element1["id"]) { + count += element1["count"]; + } + }); + }); + return count; + } + Widget goodsItem(position) { Map map; widget.shopCarGoods.forEach((element) { @@ -189,10 +235,10 @@ class _StoreOrderListPage extends State { } }); widget.fc(count, productId, allCount, allPrice.toDouble()); + setState(() {}); }, queryMiNiDetail: widget.queryMiNiDetail, shopCarGoods: map, ); } - }