From 17aa407ef7dd4bd8074ac5b44fe2032a9ad55d63 Mon Sep 17 00:00:00 2001 From: fmk Date: Sat, 23 Oct 2021 18:49:40 +0800 Subject: [PATCH] safety --- lib/retrofit/data/shoppingCart.dart | 2 +- lib/settlement/settlement.dart | 18 ++--------- lib/store/store_order.dart | 50 +++++++++++++++++++++-------- lib/store/store_view/shop_car.dart | 8 +++-- 4 files changed, 46 insertions(+), 32 deletions(-) diff --git a/lib/retrofit/data/shoppingCart.dart b/lib/retrofit/data/shoppingCart.dart index 9f5b9bc7..01b6ec19 100644 --- a/lib/retrofit/data/shoppingCart.dart +++ b/lib/retrofit/data/shoppingCart.dart @@ -34,7 +34,7 @@ class ShoppingCart { "cartSum": cartSum, "numberOfPeople": numberOfPeople, "selected": selected, - "shoppingCartSkuItemList": shoppingCartSkuItemList, + "shoppingCartSkuItemList": shoppingCartSkuItemList == null ? null : shoppingCartSkuItemList.map((e) => e.toJson()).toList(), "storeId": storeId, "storeName": storeName, "tableId": tableId, diff --git a/lib/settlement/settlement.dart b/lib/settlement/settlement.dart index 6141d9b5..30f52ecf 100644 --- a/lib/settlement/settlement.dart +++ b/lib/settlement/settlement.dart @@ -109,6 +109,9 @@ class _Settlement extends State { if (baseData != null && baseData.isSuccess) { setState(() { settleOrderInfo = baseData.data; + if (settleOrderInfo.orderProductList == null || settleOrderInfo.orderProductList.length == 0) { + queryOrderDetails(parentId); + } }); } } @@ -248,21 +251,6 @@ class _Settlement extends State { } } -//Undefined symbols for architecture armv7: -// "_OBJC_CLASS_$_HmsBitMap", referenced from: -// objc-class-ref in libflutter_scankit.a(FLScanKitView.o) -// objc-class-ref in libflutter_scankit.a(FlutterScankitPlugin.o) -// "_OBJC_CLASS_$_HmsDefaultScanViewController", referenced from: -// objc-class-ref in libflutter_scankit.a(FlutterScankitPlugin.o) -// "_OBJC_CLASS_$_HmsCustomScanViewController", referenced from: -// objc-class-ref in libflutter_scankit.a(FLScanKitView.o) -// "_OBJC_CLASS_$_HmsScanOptions", referenced from: -// objc-class-ref in libflutter_scankit.a(FLScanKitView.o) -// objc-class-ref in libflutter_scankit.a(FlutterScankitPlugin.o) -// ld: symbol(s) not found for architecture armv7 -// clang: error: linker command failed with exit code 1 (use -v to see invocation) - - ///结算 querySettlement() async { placeOrderFirst.id = parentId != "" ? parentId : downOrder.id; diff --git a/lib/store/store_order.dart b/lib/store/store_order.dart index b32bfe60..b821c434 100644 --- a/lib/store/store_order.dart +++ b/lib/store/store_order.dart @@ -3,6 +3,7 @@ import 'package:dio/dio.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/gestures.dart'; import 'package:flutter/material.dart'; +import 'package:flutter_easyloading/flutter_easyloading.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:flutter_smart_dialog/flutter_smart_dialog.dart'; import 'package:flutter_swiper/flutter_swiper.dart'; @@ -54,6 +55,8 @@ class _StoreOrderPage extends State ScrollController controller = ScrollController(); ShoppingCart shopCarGoods; int tableId = 0; + String parentId = ""; + String parentCode = ""; String tenant = ""; String storeId = ""; int numberOfPeople = 0; @@ -62,7 +65,7 @@ class _StoreOrderPage extends State void initState() { super.initState(); - tableId = widget.arguments["tableId"]; + tableId = widget.arguments["tableId"] ?? 0; tenant = widget.arguments["tenant"]; storeId = widget.arguments["id"]; @@ -82,10 +85,12 @@ class _StoreOrderPage extends State /// 小程序登录 minLogin(SharedPreferences shared) async { + EasyLoading.show(status: S.of(context).zhengzaijiazai); apiService = ApiService( Dio(), context: context, token: shared.getString('token'), + showLoading: false, ); queryStoreInfo(); apiService.minLogin(storeId).catchError((onError) { @@ -107,25 +112,33 @@ class _StoreOrderPage extends State token: minToken, tenant: tenant, storeId: storeId, + showLoading: false, ); queryShopCar().then((value) { this.shopCarGoods = value; setState(() {}); }); if (tableId > 0) { - queryStoreInfo1(); + getParentInfo(); } + EasyLoading.dismiss(); } }); } ///获取父订单(火锅订单加菜前调用) getParentInfo() async { - BaseData baseData = - await minService.getParentInfo("$tableId").catchError((error) { - debugPrint(error); - }); - if (baseData != null && baseData.isSuccess) {} + BaseData baseData = await minService.getParentInfo("$tableId") + .catchError((error) {debugPrint(error);}); + if (baseData != null && baseData.isSuccess) { + if(baseData.data != null) { + parentId = baseData.data["id"]; + parentCode = baseData.data["parentCode"]; + } else { + ///TODO: 没有父订单, + queryStoreInfo1(); + } + } } ///获取桌子信息 @@ -147,10 +160,8 @@ class _StoreOrderPage extends State /// 查询店铺信息 queryStoreInfo() async { - BaseData baseData = - await apiService.queryStoreInfo(storeId).catchError((error) { - debugPrint(error); - }); + BaseData baseData = await apiService.queryStoreInfo(storeId) + .catchError((error) {debugPrint(error);}); if (baseData != null && baseData.isSuccess) { storeInfo = StoreInfo.fromJson(baseData.data); activitys = storeInfo.informationVOPageVO.list @@ -160,6 +171,7 @@ class _StoreOrderPage extends State setState(() {}); } } + EasyLoading.dismiss(); } RefreshController refreshController; @@ -489,18 +501,24 @@ class _StoreOrderPage extends State toDownOrder() async { int num = count(); - if (tableId > 0 && num == 0) { - SmartDialog.showToast("请先选择您要购买的商品!~"); - return; + if (parentId == null || parentId == "") { + if (num == 0) { + SmartDialog.showToast("请先选择您要购买的商品!~"); + return; + } } await Navigator.of(context).pushNamed( '/router/settlement', arguments: { "storeInfo": storeInfo, + "tableId": tableId, + "parentCode": parentCode, + "parentId": parentId, "shoppingCart": shopCarGoods, }, ); + getParentInfo(); queryShopCar().then((value) { this.shopCarGoods = value; setState(() {}); @@ -629,6 +647,8 @@ class _StoreOrderPage extends State "storeName": storeInfo.storeName ?? "", "numberOfPeople": numberOfPeople, "tableId": tableId, + "parentId": parentId, + "parentCode": parentCode, "shoppingCartSkuItemList": [ { "buyNum": count, @@ -676,6 +696,7 @@ class _StoreOrderPage extends State if (baseDate.isSuccess) { queryShopCar().then((value) { this.shopCarGoods = value; + print("shopingCar111111: ${this.shopCarGoods.toJson()}"); if (shopCartKey != null) { shopCartKey.currentState.setState(() {}); } @@ -694,6 +715,7 @@ class _StoreOrderPage extends State if (baseDate.isSuccess) { queryShopCar().then((value) { this.shopCarGoods = value; + print("shopingCar111111: ${this.shopCarGoods.toJson()}"); if (shopCartKey != null) { shopCartKey.currentState.setState(() {}); } diff --git a/lib/store/store_view/shop_car.dart b/lib/store/store_view/shop_car.dart index 90e7a1da..3dbd5624 100644 --- a/lib/store/store_view/shop_car.dart +++ b/lib/store/store_view/shop_car.dart @@ -105,8 +105,12 @@ class _ShopCar extends State { physics: BouncingScrollPhysics(), itemBuilder: (context, position) { return ShopGoods( - widget.shopCartAdd, - widget.shopCartReduce, + (ShoppingCartSkuItemListBean cart) { + widget.shopCartAdd(cart); + }, + (ShoppingCartSkuItemListBean cart) { + widget.shopCartReduce(cart); + }, count: widget.shopingCar .shoppingCartSkuItemList[position].buyNum, shoppingCartSkuItemListBean: