Browse Source

商品查询loading修改

dart3_last
fff 1 week ago
parent
commit
d5db9c9740
  1. 34
      lib/store/store_order.dart
  2. 10
      lib/store/store_view/store_order_list.dart
  3. 12
      lib/union/union_list.dart
  4. 2
      lib/union/union_page.dart

34
lib/store/store_order.dart

@ -2,6 +2,7 @@ import 'dart:convert';
import 'dart:math' as mm; import 'dart:math' as mm;
import 'package:dio/dio.dart'; import 'package:dio/dio.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/services.dart'; import 'package:flutter/services.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart';
@ -68,6 +69,8 @@ class _StoreOrderPage extends State<StoreOrderPage>
MemberVo? memberVo; MemberVo? memberVo;
MiniDetail? miniDetail; MiniDetail? miniDetail;
final GlobalKey<StoreOrderListPageState> productListKey = GlobalKey<StoreOrderListPageState>();
///token ///token
String? minToken; String? minToken;
String? pName; String? pName;
@ -120,6 +123,9 @@ class _StoreOrderPage extends State<StoreOrderPage>
getParentInfo(); getParentInfo();
} }
this.shopCarGoods = value; this.shopCarGoods = value;
productListKey.currentState?.appletGoods();
setState(() {}); setState(() {});
} }
@ -137,8 +143,8 @@ class _StoreOrderPage extends State<StoreOrderPage>
/// ///
Future getParentInfo() async { Future getParentInfo() async {
BaseData? baseData = BaseData? baseData = await minService?.getParentInfo("$tableId")
await minService?.getParentInfo("$tableId").catchError((error) { .catchError((error) {
debugPrint("${error}"); debugPrint("${error}");
return BaseData()..isSuccess = false; return BaseData()..isSuccess = false;
}); });
@ -170,8 +176,8 @@ class _StoreOrderPage extends State<StoreOrderPage>
/// ///
Future queryStoreInfo() async { Future queryStoreInfo() async {
BaseData<StoreInfo>? baseData = BaseData<StoreInfo>? baseData = await apiService?.queryStoreInfo(storeId)
await apiService?.queryStoreInfo(storeId).catchError((error) { .catchError((error) {
debugPrint("${error}"); debugPrint("${error}");
return BaseData<StoreInfo>()..isSuccess = false; return BaseData<StoreInfo>()..isSuccess = false;
}); });
@ -357,6 +363,7 @@ class _StoreOrderPage extends State<StoreOrderPage>
), ),
SliverFillRemaining( SliverFillRemaining(
child: StoreOrderListPage( child: StoreOrderListPage(
key: productListKey,
widget.arguments, widget.arguments,
activitys, activitys,
storeInfo, storeInfo,
@ -365,7 +372,9 @@ class _StoreOrderPage extends State<StoreOrderPage>
minToken, minToken,
tenant, tenant,
tableId, tableId,
_queryMiNiDetail, (String id, int count) {
_queryMiNiDetail(id, count);
},
() { () {
queryShopCar().then((value) { queryShopCar().then((value) {
this.shopCarGoods = value; this.shopCarGoods = value;
@ -703,9 +712,15 @@ class _StoreOrderPage extends State<StoreOrderPage>
miniDetail, miniDetail,
shopCarGoods, shopCarGoods,
id, id,
_addShopCar, (MiniDetail? miniDetail, selectSkus, int count) {
add, _addShopCar(miniDetail, selectSkus, count);
reduce, },
(MiniDetail miniDetail, selectSkus) {
add(miniDetail, selectSkus);
},
(MiniDetail miNiDetail, selectSkus) {
reduce(miNiDetail, selectSkus);
},
); );
}, },
); );
@ -777,7 +792,8 @@ class _StoreOrderPage extends State<StoreOrderPage>
if (storeInfo?.posType?.code == "NORMALSTORE" && tableId == 0) { if (storeInfo?.posType?.code == "NORMALSTORE" && tableId == 0) {
return null; return null;
} }
BaseListData<ShoppingCart>? baseDate = await minService?.getShoppingCart(tableId).catchLEr<ShoppingCart>(); BaseListData<ShoppingCart>? baseDate = await minService?.getShoppingCart(tableId)
.catchLEr<ShoppingCart>();
if ((baseDate?.isSuccess ?? false) && (baseDate!.data?.isNotEmpty ?? false)) { if ((baseDate?.isSuccess ?? false) && (baseDate!.data?.isNotEmpty ?? false)) {
if (baseDate.data![0].selectDiscount == 1) { if (baseDate.data![0].selectDiscount == 1) {
baseDate.data![0].couponList?.forEach((element) { baseDate.data![0].couponList?.forEach((element) {

10
lib/store/store_view/store_order_list.dart

@ -41,15 +41,15 @@ class StoreOrderListPage extends StatefulWidget {
this.tableId, this.tableId,
this.queryMiNiDetail, this.queryMiNiDetail,
this.queryShoppingCart, this.queryShoppingCart,
this.scrollPhysics); this.scrollPhysics, {super.key});
@override @override
State<StatefulWidget> createState() { State<StatefulWidget> createState() {
return _StoreOrderListPage(); return StoreOrderListPageState();
} }
} }
class _StoreOrderListPage extends State<StoreOrderListPage> { class StoreOrderListPageState extends State<StoreOrderListPage> {
int isSelected = 0; int isSelected = 0;
// int tempClickIndex = 0; // int tempClickIndex = 0;
@ -88,7 +88,6 @@ class _StoreOrderListPage extends State<StoreOrderListPage> {
_listScrollController1 = ListObserverController(controller: _shopCoordinator.newChildScrollController()); _listScrollController1 = ListObserverController(controller: _shopCoordinator.newChildScrollController());
_listScrollController2 = ListObserverController(controller: _shopCoordinator.newChildScrollController()); _listScrollController2 = ListObserverController(controller: _shopCoordinator.newChildScrollController());
appletGoods();
} }
@override @override
@ -124,14 +123,13 @@ class _StoreOrderListPage extends State<StoreOrderListPage> {
} }
/// ///
appletGoods() async { Future appletGoods() async {
minService = MinApiService( minService = MinApiService(
Dio(), Dio(),
context: context, context: context,
token: widget.minToken ?? "", token: widget.minToken ?? "",
tenant: widget.tenant, tenant: widget.tenant,
storeId: widget.arguments?["id"], storeId: widget.arguments?["id"],
showLoading: true,
); );
BaseListData<FindMiniGroup> baseData = await minService.findMiNiGroupList({ BaseListData<FindMiniGroup> baseData = await minService.findMiNiGroupList({

12
lib/union/union_list.dart

@ -63,7 +63,7 @@ class UnionListState extends State<UnionList> with AutomaticKeepAliveClientMixin
} }
Future<void> getLocation() async { Future<void> getLocation() async {
S.current.zhengzaijiazai.toast; S.current.zhengzaijiazai.loading;
try { try {
powerFlag = await LocationInstance.instance.startLocation(context, powerFlag = await LocationInstance.instance.startLocation(context,
(Position? result) async { (Position? result) async {
@ -81,8 +81,7 @@ class UnionListState extends State<UnionList> with AutomaticKeepAliveClientMixin
); );
Address? address = await LocationInstance.instance.getAddress(result.latitude, result.longitude); Address? address = await LocationInstance.instance.getAddress(result.latitude, result.longitude);
if (address != null) { if (address != null) {
await saveLatLng( await saveLatLng(latLng!, address.province, address.city, address.area);
latLng!, address.province, address.city, address.area);
} }
LocationInstance.instance.stopLocation(); LocationInstance.instance.stopLocation();
} else { } else {
@ -164,6 +163,8 @@ class UnionListState extends State<UnionList> with AutomaticKeepAliveClientMixin
setState(() {}); setState(() {});
} }
bool miniLogining = false;
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
super.build(context); super.build(context);
@ -214,6 +215,10 @@ class UnionListState extends State<UnionList> with AutomaticKeepAliveClientMixin
itemBuilder: (context, position) { itemBuilder: (context, position) {
return InkWell( return InkWell(
onTap: () { onTap: () {
if (miniLogining) {
return;
}
miniLogining = true;
String storeId = storeList![position].id ?? ""; String storeId = storeList![position].id ?? "";
String tenant = storeList![position].tenantCode ?? ""; String tenant = storeList![position].tenantCode ?? "";
miniLogin(apiService!, tenant, storeId, (token) { miniLogin(apiService!, tenant, storeId, (token) {
@ -227,6 +232,7 @@ class UnionListState extends State<UnionList> with AutomaticKeepAliveClientMixin
"miniToken": token, "miniToken": token,
}, },
); );
miniLogining = false;
}); });
}, },
child: buildStoreItem(storeList![position], position), child: buildStoreItem(storeList![position], position),

2
lib/union/union_page.dart

@ -96,7 +96,7 @@ class UnionPageState extends State<UnionPage> with AutomaticKeepAliveClientMixin
} }
queryIpInfo() async { queryIpInfo() async {
S.current.zhengzaijiazai.toast; S.current.zhengzaijiazai.loading;
ApiService apiIpService = ApiService(Dio(), context: context); ApiService apiIpService = ApiService(Dio(), context: context);
String ipResult = await apiIpService.getIpInfo1().catchError((onError) { String ipResult = await apiIpService.getIpInfo1().catchError((onError) {
return ""; return "";

Loading…
Cancel
Save