From d5db9c9740c40d07419e38c702ad90a903b34fde Mon Sep 17 00:00:00 2001 From: fff Date: Fri, 24 Jan 2025 18:38:52 +0800 Subject: [PATCH] =?UTF-8?q?=E5=95=86=E5=93=81=E6=9F=A5=E8=AF=A2loading?= =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/store/store_order.dart | 34 ++++++++++++++++------ lib/store/store_view/store_order_list.dart | 10 +++---- lib/union/union_list.dart | 12 ++++++-- lib/union/union_page.dart | 2 +- 4 files changed, 39 insertions(+), 19 deletions(-) diff --git a/lib/store/store_order.dart b/lib/store/store_order.dart index 0a88e529..92afe346 100644 --- a/lib/store/store_order.dart +++ b/lib/store/store_order.dart @@ -2,6 +2,7 @@ import 'dart:convert'; import 'dart:math' as mm; import 'package:dio/dio.dart'; +import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; @@ -68,6 +69,8 @@ class _StoreOrderPage extends State MemberVo? memberVo; MiniDetail? miniDetail; + final GlobalKey productListKey = GlobalKey(); + ///小程序token String? minToken; String? pName; @@ -120,6 +123,9 @@ class _StoreOrderPage extends State getParentInfo(); } this.shopCarGoods = value; + + productListKey.currentState?.appletGoods(); + setState(() {}); } @@ -137,8 +143,8 @@ class _StoreOrderPage extends State ///获取父订单(火锅订单加菜前调用) Future getParentInfo() async { - BaseData? baseData = - await minService?.getParentInfo("$tableId").catchError((error) { + BaseData? baseData = await minService?.getParentInfo("$tableId") + .catchError((error) { debugPrint("${error}"); return BaseData()..isSuccess = false; }); @@ -170,8 +176,8 @@ class _StoreOrderPage extends State /// 查询店铺信息 Future queryStoreInfo() async { - BaseData? baseData = - await apiService?.queryStoreInfo(storeId).catchError((error) { + BaseData? baseData = await apiService?.queryStoreInfo(storeId) + .catchError((error) { debugPrint("${error}"); return BaseData()..isSuccess = false; }); @@ -357,6 +363,7 @@ class _StoreOrderPage extends State ), SliverFillRemaining( child: StoreOrderListPage( + key: productListKey, widget.arguments, activitys, storeInfo, @@ -365,7 +372,9 @@ class _StoreOrderPage extends State minToken, tenant, tableId, - _queryMiNiDetail, + (String id, int count) { + _queryMiNiDetail(id, count); + }, () { queryShopCar().then((value) { this.shopCarGoods = value; @@ -703,9 +712,15 @@ class _StoreOrderPage extends State miniDetail, shopCarGoods, id, - _addShopCar, - add, - reduce, + (MiniDetail? miniDetail, selectSkus, int count) { + _addShopCar(miniDetail, selectSkus, count); + }, + (MiniDetail miniDetail, selectSkus) { + add(miniDetail, selectSkus); + }, + (MiniDetail miNiDetail, selectSkus) { + reduce(miNiDetail, selectSkus); + }, ); }, ); @@ -777,7 +792,8 @@ class _StoreOrderPage extends State if (storeInfo?.posType?.code == "NORMALSTORE" && tableId == 0) { return null; } - BaseListData? baseDate = await minService?.getShoppingCart(tableId).catchLEr(); + BaseListData? baseDate = await minService?.getShoppingCart(tableId) + .catchLEr(); if ((baseDate?.isSuccess ?? false) && (baseDate!.data?.isNotEmpty ?? false)) { if (baseDate.data![0].selectDiscount == 1) { baseDate.data![0].couponList?.forEach((element) { diff --git a/lib/store/store_view/store_order_list.dart b/lib/store/store_view/store_order_list.dart index ef5e4879..095a1aac 100644 --- a/lib/store/store_view/store_order_list.dart +++ b/lib/store/store_view/store_order_list.dart @@ -41,15 +41,15 @@ class StoreOrderListPage extends StatefulWidget { this.tableId, this.queryMiNiDetail, this.queryShoppingCart, - this.scrollPhysics); + this.scrollPhysics, {super.key}); @override State createState() { - return _StoreOrderListPage(); + return StoreOrderListPageState(); } } -class _StoreOrderListPage extends State { +class StoreOrderListPageState extends State { int isSelected = 0; // int tempClickIndex = 0; @@ -88,7 +88,6 @@ class _StoreOrderListPage extends State { _listScrollController1 = ListObserverController(controller: _shopCoordinator.newChildScrollController()); _listScrollController2 = ListObserverController(controller: _shopCoordinator.newChildScrollController()); - appletGoods(); } @override @@ -124,14 +123,13 @@ class _StoreOrderListPage extends State { } ///小程序查询分组及商品列表 - appletGoods() async { + Future appletGoods() async { minService = MinApiService( Dio(), context: context, token: widget.minToken ?? "", tenant: widget.tenant, storeId: widget.arguments?["id"], - showLoading: true, ); BaseListData baseData = await minService.findMiNiGroupList({ diff --git a/lib/union/union_list.dart b/lib/union/union_list.dart index 7251dd5b..3f87527e 100644 --- a/lib/union/union_list.dart +++ b/lib/union/union_list.dart @@ -63,7 +63,7 @@ class UnionListState extends State with AutomaticKeepAliveClientMixin } Future getLocation() async { - S.current.zhengzaijiazai.toast; + S.current.zhengzaijiazai.loading; try { powerFlag = await LocationInstance.instance.startLocation(context, (Position? result) async { @@ -81,8 +81,7 @@ class UnionListState extends State with AutomaticKeepAliveClientMixin ); Address? address = await LocationInstance.instance.getAddress(result.latitude, result.longitude); if (address != null) { - await saveLatLng( - latLng!, address.province, address.city, address.area); + await saveLatLng(latLng!, address.province, address.city, address.area); } LocationInstance.instance.stopLocation(); } else { @@ -164,6 +163,8 @@ class UnionListState extends State with AutomaticKeepAliveClientMixin setState(() {}); } + bool miniLogining = false; + @override Widget build(BuildContext context) { super.build(context); @@ -214,6 +215,10 @@ class UnionListState extends State with AutomaticKeepAliveClientMixin itemBuilder: (context, position) { return InkWell( onTap: () { + if (miniLogining) { + return; + } + miniLogining = true; String storeId = storeList![position].id ?? ""; String tenant = storeList![position].tenantCode ?? ""; miniLogin(apiService!, tenant, storeId, (token) { @@ -227,6 +232,7 @@ class UnionListState extends State with AutomaticKeepAliveClientMixin "miniToken": token, }, ); + miniLogining = false; }); }, child: buildStoreItem(storeList![position], position), diff --git a/lib/union/union_page.dart b/lib/union/union_page.dart index f2118bd0..b206a58e 100644 --- a/lib/union/union_page.dart +++ b/lib/union/union_page.dart @@ -96,7 +96,7 @@ class UnionPageState extends State with AutomaticKeepAliveClientMixin } queryIpInfo() async { - S.current.zhengzaijiazai.toast; + S.current.zhengzaijiazai.loading; ApiService apiIpService = ApiService(Dio(), context: context); String ipResult = await apiIpService.getIpInfo1().catchError((onError) { return "";