diff --git a/lib/retrofit/data/shoppingCart.dart b/lib/retrofit/data/shoppingCart.dart index c6a85668..06a62c30 100644 --- a/lib/retrofit/data/shoppingCart.dart +++ b/lib/retrofit/data/shoppingCart.dart @@ -15,14 +15,14 @@ class ShoppingCart { String storeName; int tableId; - static ShoppingCart fromJon(Map map) { + static ShoppingCart fromJson(Map map) { if (map == null) return null; ShoppingCart shoppingCartBean = ShoppingCart(); shoppingCartBean.cartSum = map['cartSum']; shoppingCartBean.numberOfPeople = map['numberOfPeople']; shoppingCartBean.selected = map['selected']; - shoppingCartBean.shoppingCartSkuItemList = List()..addAll( - (map['shoppingCartSkuItemList'] as List ?? []).map((o) => ShoppingCartSkuItemListBean.fromJon(o)) + shoppingCartBean.shoppingCartSkuItemList = []..addAll( + (map['shoppingCartSkuItemList'] as List ?? []).map((o) => ShoppingCartSkuItemListBean.fromJson(o)) ); shoppingCartBean.storeId = map['storeId']; shoppingCartBean.storeName = map['storeName']; @@ -72,7 +72,7 @@ class ShoppingCartSkuItemListBean { int storeId; int tableId; - static ShoppingCartSkuItemListBean fromJon(Map map) { + static ShoppingCartSkuItemListBean fromJson(Map map) { if (map == null) return null; ShoppingCartSkuItemListBean shoppingCartSkuItemListBean = ShoppingCartSkuItemListBean(); shoppingCartSkuItemListBean.buyNum = map['buyNum']; @@ -80,7 +80,7 @@ class ShoppingCartSkuItemListBean { shoppingCartSkuItemListBean.groupId = map['groupId']; shoppingCartSkuItemListBean.id = map['id']; shoppingCartSkuItemListBean.platterList = List()..addAll( - (map['platterList'] as List ?? []).map((o) => PlatterListBean.fromJon(o)) + (map['platterList'] as List ?? []).map((o) => PlatterListBean.fromJson(o)) ); shoppingCartSkuItemListBean.productId = map['productId']; shoppingCartSkuItemListBean.productName = map['productName']; @@ -125,7 +125,7 @@ class PlatterListBean { bool required; int skuId; - static PlatterListBean fromJon(Map map) { + static PlatterListBean fromJson(Map map) { if (map == null) return null; PlatterListBean platterListBean = PlatterListBean(); platterListBean.deleted = map['deleted']; diff --git a/lib/retrofit/min_api.g.dart b/lib/retrofit/min_api.g.dart index 2dcec64f..a7ede126 100644 --- a/lib/retrofit/min_api.g.dart +++ b/lib/retrofit/min_api.g.dart @@ -17,22 +17,18 @@ class _MinApiService implements MinApiService { String baseUrl; @override - Future>> findMiNiGroupList( - param, header) async { + Future>> findMiNiGroupList(param) async { ArgumentError.checkNotNull(param, 'param'); - ArgumentError.checkNotNull(header, 'header'); const _extra = {}; final queryParameters = {}; final _data = {}; _data.addAll(param ?? {}); - final _header= {}; - _header.addAll(header ?? {}); final _result = await _dio.request>( 'product/findMiNiGroupList', queryParameters: queryParameters, options: RequestOptions( method: 'POST', - headers: _header, + headers: {}, extra: _extra, baseUrl: baseUrl), data: _data); @@ -62,7 +58,30 @@ class _MinApiService implements MinApiService { data: _data); final value = BaseData.fromJson( _result.data, - (json) => MiNiDetail.fromMap(json), + (json) => MiNiDetail.fromJson(json), + ); + return value; + } + + @override + Future> shoppingCart(param, header) async { + ArgumentError.checkNotNull(param, 'param'); + ArgumentError.checkNotNull(header, 'header'); + const _extra = {}; + final queryParameters = {}; + final _data = {}; + _data.addAll(param ?? {}); + final _result = await _dio.request>('shoppingcart', + queryParameters: queryParameters, + options: RequestOptions( + method: 'POST', + headers: {}, + extra: _extra, + baseUrl: baseUrl), + data: _data); + final value = BaseData.fromJson( + _result.data, + (json) => ShoppingCart.fromJson(json), ); return value; } diff --git a/lib/store/store_order.dart b/lib/store/store_order.dart index c5b25cc7..94a8c305 100644 --- a/lib/store/store_order.dart +++ b/lib/store/store_order.dart @@ -80,7 +80,7 @@ class _StoreOrderPage extends State activitys, ), ]; - + minLogin(); queryStoreInfo(); } @@ -108,7 +108,7 @@ class _StoreOrderPage extends State String minToken = minStoreInfo["token"]; String tenant = widget.arguments["tenant"]; SharedPreferences.getInstance().then( - (value) => { + (value) => { value.setString('minToken', minToken), value.setString('tenant', tenant), }, @@ -123,7 +123,6 @@ class _StoreOrderPage extends State }); } - /// 查询店铺信息 queryStoreInfo() async { final SharedPreferences value = await SharedPreferences.getInstance(); @@ -452,12 +451,16 @@ class _StoreOrderPage extends State context: context, backgroundColor: Colors.transparent, builder: (context) { - return ShopCar(productLists, _queryMiNiDetail, (ac, ap) { - setState(() { - allCount = ac; - allPrice = ap; - }); - }); + return ShopCar( + productLists, + _queryMiNiDetail, + (allCount, allPrice) { + setState(() { + this.allCount = allCount; + this.allPrice = allPrice; + }); + }, + ); }, ); } diff --git a/lib/store/store_view/shop_car.dart b/lib/store/store_view/shop_car.dart index e8bb23e4..3f06d98d 100644 --- a/lib/store/store_view/shop_car.dart +++ b/lib/store/store_view/shop_car.dart @@ -8,21 +8,27 @@ import 'package:huixiang/view_widget/round_button.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; class ShopCar extends StatefulWidget { - final List productLists; final Function(String id) queryMiNiDetail; final Function(int allCount, double allPrice) fc; - ShopCar(this.productLists, this.queryMiNiDetail, this.fc); + ShopCar( + this.productLists, + this.queryMiNiDetail, + this.fc, + ); @override State createState() { return _ShopCar(); } - } class _ShopCar extends State { + + int allCount; + double allPrice; + @override Widget build(BuildContext context) { return StatefulBuilder(builder: (context1, state) { @@ -32,8 +38,9 @@ class _ShopCar extends State { height: MediaQuery.of(context).size.height / 2, decoration: BoxDecoration( color: Colors.white, - borderRadius: BorderRadius.vertical( - top: Radius.circular(8), + borderRadius: BorderRadius.only( + topLeft: Radius.circular(8), + topRight: Radius.circular(8), ), ), child: Column( @@ -78,12 +85,25 @@ class _ShopCar extends State { right: 16, ), child: ListView.builder( - itemCount: widget.productLists == null ? 0 : widget.productLists.length, + itemCount: widget.productLists == null + ? 0 + : widget.productLists.length, physics: BouncingScrollPhysics(), itemBuilder: (context, position) { return GestureDetector( onTap: () {}, - child: ShopGoods(widget.productLists, position, widget.queryMiNiDetail, widget.fc), + child: ShopGoods( + widget.productLists, + position, + widget.queryMiNiDetail, + (int allCount, double allPrice){ + widget.fc(allCount, allPrice); + setState(() { + this.allCount = allCount; + this.allPrice = allPrice; + }); + }, + ), ); }, ), @@ -117,7 +137,7 @@ class _ShopCar extends State { ), ), Text( - "¥19.00", + "¥" + allPrice.toString(), style: TextStyle( fontSize: 20.sp, fontWeight: MyFontWeight.medium, @@ -125,16 +145,24 @@ class _ShopCar extends State { ), ), Spacer(), - RoundButton( - width: 103.w, - height: 54.h, - text: S.current.jiesuan, - textColor: Colors.white, - fontWeight: MyFontWeight.regular, - backgroup: Color(0xFF32A060), - radius: 0, - fontSize: 16.sp, - padding: EdgeInsets.symmetric(vertical: 5.h), + GestureDetector( + onTap: () { + Navigator.of(context).pushNamed( + '/router/settlement', + arguments: {}, + ); + }, + child: RoundButton( + width: 103.w, + height: 54.h, + text: S.current.jiesuan, + textColor: Colors.white, + fontWeight: MyFontWeight.regular, + backgroup: Color(0xFF32A060), + radius: 0, + fontSize: 16.sp, + padding: EdgeInsets.symmetric(vertical: 5.h), + ), ), ], ), @@ -157,15 +185,14 @@ class _ShopCar extends State { child: RoundButton( width: 17, height: 17, - text: "1", + text: allCount.toString(), textColor: Colors.white, fontWeight: MyFontWeight.regular, backgroup: Color(0xFF32A060), fontSize: 12.sp, radius: 100, callback: () { - Navigator.of(context) - .pushNamed('/router/test_page'); + Navigator.of(context).pushNamed('/router/test_page'); }, ), ), @@ -178,5 +205,4 @@ class _ShopCar extends State { ); }); } - -} \ No newline at end of file +}