From 195d99033ab1f63d815d3ff3ae055f8f5947ab28 Mon Sep 17 00:00:00 2001 From: fff Date: Fri, 24 Jan 2025 11:58:06 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=BB=E9=A1=B5=E9=9D=A2=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=EF=BC=8C=E5=A4=9A=E9=A1=B5=E9=9D=A2=E9=A2=84=E5=8A=A0=E8=BD=BD?= =?UTF-8?q?=E3=80=82=E6=B6=88=E6=81=AF=E5=B7=B2=E8=AF=BB=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E3=80=82UI=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/constant.dart | 4 + lib/data/find_mini_group.dart | 4 + lib/im/chat_details_page.dart | 7 +- lib/im/im_view/im_page.dart | 7 +- lib/main_page.dart | 26 +- lib/message/system_details.dart | 294 ++++----- lib/message/system_notice.dart | 2 +- lib/mine/mine_shop_page.dart | 4 +- lib/order/exchange_history_page.dart | 1 + .../invoices_manage/invoices_detail_page.dart | 23 +- .../invoices_manage/invoices_history.dart | 2 +- .../invoices_manage/invoices_manage_page.dart | 1 + .../invoices_manage/invoices_title_info.dart | 3 +- lib/order/order_detail_page.dart | 1 + lib/order/order_history_page.dart | 1 + lib/order/order_view/order_address.dart | 42 +- lib/order/order_view/order_commodity.dart | 6 +- lib/retrofit/min_api.dart | 59 +- lib/retrofit/retrofit_api.dart | 85 +-- lib/settlement/settlement.dart | 1 + lib/store/shop_details_page.dart | 203 ++----- lib/store/store_order.dart | 74 +-- lib/store/store_view/people_num.dart | 1 - lib/store/store_view/product_sku.dart | 4 - lib/store/store_view/shop_car.dart | 3 + lib/store/store_view/shop_goods.dart | 560 ++++++++---------- lib/store/store_view/shop_goods_car.dart | 132 ++--- lib/store/store_view/store_order_list.dart | 236 ++++---- lib/union/union_list.dart | 23 +- lib/union/union_page.dart | 9 +- lib/utils/flutter_utils.dart | 39 +- pubspec.lock | 16 + pubspec.yaml | 2 + 33 files changed, 801 insertions(+), 1074 deletions(-) diff --git a/lib/constant.dart b/lib/constant.dart index be399c31..4e46c5fc 100644 --- a/lib/constant.dart +++ b/lib/constant.dart @@ -99,14 +99,18 @@ extension StrExtension on String { SmartNonAnimationType.continueKeepSingle, ], ); + void get loading => SmartDialog.showLoading( msg: this, displayTime: 25000.milliseconds, + animationType: SmartAnimationType.fade, nonAnimationTypes: [ SmartNonAnimationType.continueLoading_nonAnimation, SmartNonAnimationType.continueKeepSingle, ], ); + void get loadingDismiss => SmartDialog.dismiss(status: SmartStatus.loading, force: true); + void get print => debugPrint(this); } diff --git a/lib/data/find_mini_group.dart b/lib/data/find_mini_group.dart index 7bfbcde0..1f881888 100644 --- a/lib/data/find_mini_group.dart +++ b/lib/data/find_mini_group.dart @@ -1,3 +1,4 @@ +import 'package:flutter/material.dart'; import 'package:huixiang/data/subscribe_param.dart'; import 'package:json_annotation/json_annotation.dart'; @@ -15,6 +16,9 @@ class FindMiniGroup { List? productList = []; dynamic productPageVO; + @JsonKey(includeFromJson: false, includeToJson: false) + GlobalKey scrollControllerKey = GlobalKey(); + FindMiniGroup(); factory FindMiniGroup.fromJson(Map json) => _$FindMiniGroupFromJson(json); diff --git a/lib/im/chat_details_page.dart b/lib/im/chat_details_page.dart index 5a112421..d0d4c744 100644 --- a/lib/im/chat_details_page.dart +++ b/lib/im/chat_details_page.dart @@ -7,7 +7,6 @@ import 'package:emoji_picker_flutter/emoji_picker_flutter.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; -import 'package:flutter/widgets.dart'; import 'package:flutter_keyboard_visibility/flutter_keyboard_visibility.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:flutter_smart_dialog/flutter_smart_dialog.dart'; @@ -15,7 +14,9 @@ import 'package:get/get.dart'; import 'package:huixiang/constant.dart'; import 'package:huixiang/data/base_data.dart'; import 'package:huixiang/data/im_user.dart'; +import 'package:huixiang/data/page.dart'; import 'package:huixiang/data/user_info.dart'; +import 'package:huixiang/data/message.dart' as msg; import 'package:huixiang/im/database/message.dart'; import 'package:huixiang/im/out/message.pb.dart'; import 'package:huixiang/main.dart'; @@ -822,8 +823,8 @@ class _ChatDetailsPage extends State textAlign: TextAlign.left, style: TextStyle( color: Colors.white, - fontSize: 17.sp, - fontWeight: MyFontWeight.regular, + fontSize: 10.sp, + fontWeight: MyFontWeight.black, ), ), ), diff --git a/lib/im/im_view/im_page.dart b/lib/im/im_view/im_page.dart index e3ffe5b1..52969b7c 100644 --- a/lib/im/im_view/im_page.dart +++ b/lib/im/im_view/im_page.dart @@ -332,7 +332,9 @@ class _IMPage extends State implements OnChatMessage { behavior: HitTestBehavior.opaque, onTap: () { Navigator.of(context) - .pushNamed('/router/system_notice') + .pushNamed( + '/router/system_notice', + ) .then((value) { setState(() { msgNumber["2"] = 0; @@ -380,7 +382,8 @@ class _IMPage extends State implements OnChatMessage { onTap: () { Navigator.of(context).pushNamed( '/router/system_details', - arguments: {"msgType": 5}).then((value) { + arguments: {"msgType": 5}, + ).then((value) { setState(() { msgNumber["5"] = 0; }); diff --git a/lib/main_page.dart b/lib/main_page.dart index 2b9cbbe8..e0258daa 100644 --- a/lib/main_page.dart +++ b/lib/main_page.dart @@ -26,6 +26,7 @@ import 'package:huixiang/utils/shared_preference.dart'; import 'package:huixiang/view_widget/update_dialog.dart'; import 'package:package_info_plus/package_info_plus.dart'; import 'package:permission_handler/permission_handler.dart'; +import 'package:preload_page_view/preload_page_view.dart'; import 'package:sharesdk_plugin/sharesdk_interface.dart'; import 'package:sharesdk_plugin/sharesdk_register.dart'; import 'package:tpns_flutter_plugin/android/xg_android_api.dart'; @@ -107,7 +108,7 @@ class _MainPage extends State with WidgetsBindingObserver { initDatabase(userId); connectSocket(); - pageController = PageController( + pageController = PreloadPageController( initialPage: widget.arguments != null && widget.arguments?["index"] != null ? widget.arguments!["index"] @@ -468,22 +469,23 @@ class _MainPage extends State with WidgetsBindingObserver { } } - late PageController pageController; + late PreloadPageController pageController; @override Widget build(BuildContext context) { return Scaffold( resizeToAvoidBottomInset: false, - body: Container( - child: PageView( - controller: pageController, - children: _widgetOptions, - physics: NeverScrollableScrollPhysics(), - onPageChanged: (index) { - clickIndex = index; - setState(() {}); - }, - ), + body: PreloadPageView.builder( + controller: pageController, + itemBuilder: (context, index) { + return _widgetOptions[index]; + }, + itemCount: _widgetOptions.length, + physics: NeverScrollableScrollPhysics(), + onPageChanged: (index) { + clickIndex = index; + setState(() {}); + }, ), extendBody: true, bottomNavigationBar: Container( diff --git a/lib/message/system_details.dart b/lib/message/system_details.dart index 99526866..5fa73710 100644 --- a/lib/message/system_details.dart +++ b/lib/message/system_details.dart @@ -70,7 +70,7 @@ class _SystemDetails extends State { "pageSize": 10, "searchKey": "", "state": "", - "typed": msgType + "typed": "$msgType" }).catchError((onError) { _refreshController.loadFailed(); _refreshController.refreshFailed(); @@ -947,161 +947,163 @@ class _SystemDetails extends State { } Widget followMessageItem(Message message) { - var messageRelational = jsonDecode(message.relational ?? ""); - if (message.relational?.startsWith("{") ?? false) { - return Container( - child: Row( - mainAxisAlignment: MainAxisAlignment.start, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - MImage( - messageRelational["avatar"], - width: 44, - height: 44, - isCircle: true, - fit: BoxFit.cover, - errorSrc: "assets/image/default_1.webp", - fadeSrc: "assets/image/default_1.webp", - ), - SizedBox( - width: 8, - ), - Expanded( - child: Column( - mainAxisAlignment: MainAxisAlignment.start, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Row( - mainAxisAlignment: MainAxisAlignment.start, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Expanded( - child: Column( - mainAxisAlignment: MainAxisAlignment.start, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Row( - children: [ - Text( - messageRelational["nickname"], - style: TextStyle( - fontWeight: MyFontWeight.semi_bold, - fontSize: 14.sp, - color: Color(0xFF1A1A1A), + if (message.relational?.isNotEmpty ?? false) { + var messageRelational = jsonDecode(message.relational ?? ""); + if (message.relational?.startsWith("{") ?? false) { + return Container( + child: Row( + mainAxisAlignment: MainAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + MImage( + messageRelational["avatar"], + width: 44, + height: 44, + isCircle: true, + fit: BoxFit.cover, + errorSrc: "assets/image/default_1.webp", + fadeSrc: "assets/image/default_1.webp", + ), + SizedBox( + width: 8, + ), + Expanded( + child: Column( + mainAxisAlignment: MainAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Row( + mainAxisAlignment: MainAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Expanded( + child: Column( + mainAxisAlignment: MainAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Row( + children: [ + Text( + messageRelational["nickname"], + style: TextStyle( + fontWeight: MyFontWeight.semi_bold, + fontSize: 14.sp, + color: Color(0xFF1A1A1A), + ), ), - ), - SizedBox( - width: 8.w, - ), - Text( - "关注了你", - style: TextStyle( - fontWeight: MyFontWeight.medium, - fontSize: 14.sp, - color: Color(0xFF32A060), + SizedBox( + width: 8.w, + ), + Text( + "关注了你", + style: TextStyle( + fontWeight: MyFontWeight.medium, + fontSize: 14.sp, + color: Color(0xFF32A060), + ), ), + ], + ), + SizedBox( + height: 8, + ), + Text( + message.updateTime ?? "", + style: TextStyle( + fontSize: 12.sp, + color: Color(0xFFA29E9E), ), - ], - ), - SizedBox( - height: 8, - ), - Text( - message.updateTime ?? "", - style: TextStyle( - fontSize: 12.sp, - color: Color(0xFFA29E9E), ), - ), - ], + ], + ), ), - ), - GestureDetector( - onTap: () { - setState(() { - _vipFollow(messageRelational["mid"].toString(), - message.followed ?? false); - }); - }, - child: RoundButton( - height: 21.h, - width: 56.w, - padding: EdgeInsets.all(2), - backgroup: (message.followed ?? false) - ? Color(0xFFE6E6E6) - : Color(0xFF32A060), - textColor: (message.followed ?? false) - ? Color(0xFF808080) - : Colors.white, - text: (message.followed ?? false) ? "已关注" : "回关", - radius: 20, - icons: Icon( - (message.followed ?? false) - ? Icons.check - : Icons.add, - color: (message.followed ?? false) + GestureDetector( + onTap: () { + setState(() { + _vipFollow(messageRelational["mid"].toString(), + message.followed ?? false); + }); + }, + child: RoundButton( + height: 21.h, + width: 56.w, + padding: EdgeInsets.all(2), + backgroup: (message.followed ?? false) + ? Color(0xFFE6E6E6) + : Color(0xFF32A060), + textColor: (message.followed ?? false) ? Color(0xFF808080) : Colors.white, - size: 12, + text: (message.followed ?? false) ? "已关注" : "回关", + radius: 20, + icons: Icon( + (message.followed ?? false) + ? Icons.check + : Icons.add, + color: (message.followed ?? false) + ? Color(0xFF808080) + : Colors.white, + size: 12, + ), ), + // Container( + // height: 21.h, + // width:56.w, + // padding:EdgeInsets.only(left:5,right:5), + // alignment: Alignment.center, + // decoration: BoxDecoration( + // borderRadius: BorderRadius.circular(11), + // border: Border.all( + // width: 1, + // color: Color(0xFF00A359), + // style: BorderStyle.solid, + // ), + // color: (message?.followed ?? false) + // ? Color(0xFFE6E6E6) + // : Color(0xFF32A060), + // ), + // child: Row( + // children: [ + // Icon((message?.followed ?? false) + // ? Icons.check + // : Icons.add, + // color:(message?.followed?? false) + // ? Color(0xFF808080) + // : Colors.white, + // size: 16, + // ), + // Text( + // (message?.followed ?? false) ? "已关注" : "回关", + // style: TextStyle( + // fontSize: 12.sp, + // fontWeight: MyFontWeight.medium, + // color:(message?.followed ?? false) + // ? Color(0xFF808080) + // : Colors.white, + // ), + // ), + // ], + // ), + // ) ), - // Container( - // height: 21.h, - // width:56.w, - // padding:EdgeInsets.only(left:5,right:5), - // alignment: Alignment.center, - // decoration: BoxDecoration( - // borderRadius: BorderRadius.circular(11), - // border: Border.all( - // width: 1, - // color: Color(0xFF00A359), - // style: BorderStyle.solid, - // ), - // color: (message?.followed ?? false) - // ? Color(0xFFE6E6E6) - // : Color(0xFF32A060), - // ), - // child: Row( - // children: [ - // Icon((message?.followed ?? false) - // ? Icons.check - // : Icons.add, - // color:(message?.followed?? false) - // ? Color(0xFF808080) - // : Colors.white, - // size: 16, - // ), - // Text( - // (message?.followed ?? false) ? "已关注" : "回关", - // style: TextStyle( - // fontSize: 12.sp, - // fontWeight: MyFontWeight.medium, - // color:(message?.followed ?? false) - // ? Color(0xFF808080) - // : Colors.white, - // ), - // ), - // ], - // ), - // ) - ), - ], - ), - SizedBox( - height: 8.h, - ), - Container( - margin: EdgeInsets.only(top: 16.h, bottom: 16.h), - height: 1.h, - width: double.infinity, - color: Color(0xFFF7F7F7), - ), - ], + ], + ), + SizedBox( + height: 8.h, + ), + Container( + margin: EdgeInsets.only(top: 16.h, bottom: 16.h), + height: 1.h, + width: double.infinity, + color: Color(0xFFF7F7F7), + ), + ], + ), ), - ), - ], - ), - ); + ], + ), + ); + } } return Container(); } diff --git a/lib/message/system_notice.dart b/lib/message/system_notice.dart index d8ae2191..ea52dd11 100644 --- a/lib/message/system_notice.dart +++ b/lib/message/system_notice.dart @@ -55,7 +55,7 @@ class _SystemNotice extends State { "pageSize": 10, "searchKey": "", "state": "", - "typed": "" + "typed": "2,3" }).catchError((onError) { _refreshController.loadFailed(); _refreshController.refreshFailed(); diff --git a/lib/mine/mine_shop_page.dart b/lib/mine/mine_shop_page.dart index f58b715b..d574bc8c 100644 --- a/lib/mine/mine_shop_page.dart +++ b/lib/mine/mine_shop_page.dart @@ -3,6 +3,7 @@ import 'dart:async'; import 'package:dio/dio.dart'; import 'package:flutter/material.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; +import 'package:flutter_smart_dialog/flutter_smart_dialog.dart'; import 'package:huixiang/constant.dart'; import 'package:huixiang/data/base_list_data.dart'; import 'package:huixiang/data/vip_card.dart'; @@ -85,7 +86,6 @@ class _MineShopPage extends State with WidgetsBindingObserver { queryVipCard({bool showLoading = true}) async { try { if (showLoading) { - AppUtils.addLoadingPath("loadShopColors"); S.current.zhengzaijiazai.loading; } BaseListData? baseData = await apiService?.vipList({ @@ -105,7 +105,7 @@ class _MineShopPage extends State with WidgetsBindingObserver { refreshController.refreshFailed(); } } finally { - AppUtils.cleanLoadingPath(); + SmartDialog.dismiss(status: SmartStatus.loading, force: true); setState(() {}); } } diff --git a/lib/order/exchange_history_page.dart b/lib/order/exchange_history_page.dart index 631c296a..57674886 100644 --- a/lib/order/exchange_history_page.dart +++ b/lib/order/exchange_history_page.dart @@ -182,6 +182,7 @@ class _ExchangeHistoryList extends State _refreshController.loadFailed(); } } finally { + SmartDialog.dismiss(status: SmartStatus.loading, force: true); setState(() {}); } } diff --git a/lib/order/invoices_manage/invoices_detail_page.dart b/lib/order/invoices_manage/invoices_detail_page.dart index 1b9f6663..7d060986 100644 --- a/lib/order/invoices_manage/invoices_detail_page.dart +++ b/lib/order/invoices_manage/invoices_detail_page.dart @@ -7,24 +7,22 @@ import 'package:flutter/material.dart'; import 'package:flutter/rendering.dart'; import 'package:flutter/services.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; -import 'package:flutter_smart_dialog/flutter_smart_dialog.dart'; +import 'package:huixiang/community/photo_view_gallery_screen.dart'; +import 'package:huixiang/data/base_data.dart'; +import 'package:huixiang/data/invoices_detail_info.dart'; import 'package:huixiang/order/invoices_manage/pdf_screen.dart'; +import 'package:huixiang/retrofit/retrofit_api.dart'; +import 'package:huixiang/utils/flutter_utils.dart'; +import 'package:huixiang/utils/font_weight.dart'; import 'package:huixiang/utils/shared_preference.dart'; +import 'package:huixiang/view_widget/classic_header.dart'; +import 'package:huixiang/view_widget/my_appbar.dart'; +import 'package:huixiang/view_widget/my_footer.dart'; import 'package:path_provider/path_provider.dart'; import 'package:pull_to_refresh/pull_to_refresh.dart'; -import 'package:shared_preferences/shared_preferences.dart'; import 'package:shimmer/shimmer.dart'; import 'package:url_launcher/url_launcher.dart'; -import '../../community/photo_view_gallery_screen.dart'; -import '../../data/base_data.dart'; -import '../../data/invoices_detail_info.dart'; -import '../../retrofit/retrofit_api.dart'; -import '../../utils/flutter_utils.dart'; -import '../../utils/font_weight.dart'; -import '../../view_widget/classic_header.dart'; -import '../../view_widget/my_appbar.dart'; -import '../../view_widget/my_footer.dart'; class InvoicesDetailPage extends StatefulWidget { final Map? arguments; @@ -776,7 +774,8 @@ class _InvoicesDetailPage extends State { style: TextStyle( fontSize: 14.sp, color: Color(0xFF0D0D0D), - fontWeight: MyFontWeight.bold), + fontWeight: MyFontWeight.bold, + ), ), Padding( padding: EdgeInsets.symmetric(vertical: 10.h), diff --git a/lib/order/invoices_manage/invoices_history.dart b/lib/order/invoices_manage/invoices_history.dart index e84a1f08..47110a7b 100644 --- a/lib/order/invoices_manage/invoices_history.dart +++ b/lib/order/invoices_manage/invoices_history.dart @@ -15,7 +15,6 @@ import 'package:huixiang/view_widget/my_appbar.dart'; import 'package:huixiang/view_widget/my_footer.dart'; import 'package:huixiang/view_widget/no_data_view.dart'; import 'package:pull_to_refresh/pull_to_refresh.dart'; -import 'package:shared_preferences/shared_preferences.dart'; import 'package:shimmer/shimmer.dart'; @@ -67,6 +66,7 @@ class _InvoicesHistory extends State { refreshController.loadFailed(); return BaseData()..isSuccess = false; }); + SmartDialog.dismiss(status: SmartStatus.loading, force: true); if (!mounted) return; if (baseData?.isSuccess ?? false) { records.addAll(baseData?.data?.records ?? []); diff --git a/lib/order/invoices_manage/invoices_manage_page.dart b/lib/order/invoices_manage/invoices_manage_page.dart index 52fb0244..b3ea10e8 100644 --- a/lib/order/invoices_manage/invoices_manage_page.dart +++ b/lib/order/invoices_manage/invoices_manage_page.dart @@ -67,6 +67,7 @@ class _InvoicesManagePage extends State { refreshController.loadFailed(); return BaseData()..isSuccess = false; }); + SmartDialog.dismiss(status: SmartStatus.loading, force: true); if (!mounted) return; if (baseData?.isSuccess ?? false) { records.addAll(baseData?.data?.records ?? []); diff --git a/lib/order/invoices_manage/invoices_title_info.dart b/lib/order/invoices_manage/invoices_title_info.dart index d3bb5b63..e4b4895e 100644 --- a/lib/order/invoices_manage/invoices_title_info.dart +++ b/lib/order/invoices_manage/invoices_title_info.dart @@ -5,7 +5,7 @@ import 'package:flutter_smart_dialog/flutter_smart_dialog.dart'; import 'package:huixiang/constant.dart'; import 'package:huixiang/utils/shared_preference.dart'; import 'package:pull_to_refresh/pull_to_refresh.dart'; -import 'package:shared_preferences/shared_preferences.dart'; + import 'package:shimmer/shimmer.dart'; import '../../data/base_data.dart'; @@ -84,6 +84,7 @@ class _InvoicesTitleInfo extends State { refreshController.loadFailed(); return BaseData()..isSuccess = false; }); + SmartDialog.dismiss(status: SmartStatus.loading, force: true); if (!mounted) return; if (baseData?.isSuccess ?? false) { records.addAll(baseData?.data?.records ?? []); diff --git a/lib/order/order_detail_page.dart b/lib/order/order_detail_page.dart index e5415ee4..1d1cf9c3 100644 --- a/lib/order/order_detail_page.dart +++ b/lib/order/order_detail_page.dart @@ -133,6 +133,7 @@ class _OrderDetailPage extends State { refreshController.refreshFailed(); refreshController.loadFailed(); } + SmartDialog.dismiss(status: SmartStatus.loading, force: true); } @override diff --git a/lib/order/order_history_page.dart b/lib/order/order_history_page.dart index 30ae8b41..df9373c1 100644 --- a/lib/order/order_history_page.dart +++ b/lib/order/order_history_page.dart @@ -198,6 +198,7 @@ class _OrderHistoryList extends State refreshController.refreshFailed(); refreshController.loadFailed(); } + SmartDialog.dismiss(status: SmartStatus.loading, force: true); } minLogin(OrderInfo orderInfo) { diff --git a/lib/order/order_view/order_address.dart b/lib/order/order_view/order_address.dart index 28f468c7..1a0fde7e 100644 --- a/lib/order/order_view/order_address.dart +++ b/lib/order/order_view/order_address.dart @@ -50,7 +50,9 @@ class _OrderAddress extends State { @override Widget build(BuildContext context) { return Container( - margin: EdgeInsets.only(left: 16.w, right: 16.w, top: 18, bottom: 2.h), + margin: EdgeInsets.only( + left: 16.w, right: 16.w, top: 18, bottom: 2.h, + ), padding: EdgeInsets.all(20), decoration: BoxDecoration( color: Colors.white, @@ -76,34 +78,27 @@ class _OrderAddress extends State { width: 24.w, height: 24.h, ), - Text( - (widget.orderInfo?.addressExt != null) - ? ((widget.isTakeOut == 0 || - widget.isTakeOut == 3 || - widget.isTakeOut == 4 - ? widget.orderInfo?.storeName - : widget.orderInfo?.addressExt?.recName) ?? - "") - : "", - overflow: TextOverflow.ellipsis, - style: TextStyle( + Expanded( + child: Text( + (widget.orderInfo?.addressExt != null) ? ((widget.isTakeOut == 0 || widget.isTakeOut == 3 || widget.isTakeOut == 4 ? widget.orderInfo?.storeName : widget.orderInfo?.addressExt?.recName) ?? "") : "", + overflow: TextOverflow.ellipsis, + style: TextStyle( fontSize: 15.sp, color: Color(0xFF4C4C4C), fontWeight: MyFontWeight.medium, - ), + ), + ) ), SizedBox( width: 7.w, ), - Expanded( - child: Text( - widget.orderInfo?.addressExt?.recMobile ?? "", - overflow: TextOverflow.ellipsis, - style: TextStyle( - fontSize: 15.sp, - color: Color(0xFF4C4C4C), - fontWeight: MyFontWeight.medium, - ), + Text( + widget.orderInfo?.addressExt?.recMobile ?? "", + overflow: TextOverflow.ellipsis, + style: TextStyle( + fontSize: 15.sp, + color: Color(0xFF4C4C4C), + fontWeight: MyFontWeight.medium, ), ), ], @@ -153,8 +148,7 @@ class _OrderAddress extends State { S.of(context).zhidianmendian, (open) { if (open) { - String? mobile = - widget.orderInfo?.storeVO?.mobile; + String? mobile = widget.orderInfo?.storeVO?.mobile; if (mobile?.isNotEmpty ?? false) { callMobile(mobile); } diff --git a/lib/order/order_view/order_commodity.dart b/lib/order/order_view/order_commodity.dart index 04ffaf26..bdbd7bc4 100644 --- a/lib/order/order_view/order_commodity.dart +++ b/lib/order/order_view/order_commodity.dart @@ -107,13 +107,13 @@ class _OrderCommodity extends State { } // 优惠券 - if ((widget.orderInfo?.orderDetail?.couponDTO?.money ??"0") != "0") { + if ((widget.orderInfo?.orderDetail?.couponDTO?["money"] ?? "0") != "0") { widgets.add( discountItem( Color(0xFFFF7A1A), S.of(context).youhuiquan, - widget.orderInfo?.orderDetail?.couponDTO?.name ??"", - widget.orderInfo?.orderDetail?.couponDTO?.money ??"0", + widget.orderInfo?.orderDetail?.couponDTO?["name"] ??"", + widget.orderInfo?.orderDetail?.couponDTO?["money"] ??"0", ), ); } diff --git a/lib/retrofit/min_api.dart b/lib/retrofit/min_api.dart index 547383ac..6596d053 100644 --- a/lib/retrofit/min_api.dart +++ b/lib/retrofit/min_api.dart @@ -63,40 +63,27 @@ abstract class MinApiService { headers: headers, responseType: ResponseType.json, ); + + if (!dio.interceptors.any((e) => e is LogInterceptor)) { + dio.interceptors.add(LogInterceptor( + responseBody: true, + requestBody: true, + requestHeader: true, + responseHeader: true, + request: false, + error: true, + )); + } + dio.interceptors.add( InterceptorsWrapper(onRequest: (RequestOptions options, RequestInterceptorHandler handler) { - debugPrint("\n======================= Min_请求数据 ======================="); - debugPrint("method = ${options.method.toString()}"); - debugPrint("url = ${options.uri.toString()}"); - debugPrint("headers = ${options.headers}"); - AppUtils.addLoadingPath(options.path); - if (!SmartDialog.checkExist(dialogTypes: {SmartAllDialogType.loading})) { - //是否显示loading - S.current.zhengzaijiazai.loading; - } - if (options.data is f.FormData) { - debugPrint("params data = FormData"); - } else { - debugPrint("params data = ${jsonEncode(options.data)}"); - } - debugPrint("params queryParameters = ${options.queryParameters}"); + S.current.zhengzaijiazai.loading; handler.next(options); }, onResponse: (r.Response response, ResponseInterceptorHandler handler) { - debugPrint("\n======================= Min_响应数据开始 ======================="); - if (SmartDialog.checkExist(dialogTypes: {SmartAllDialogType.loading})) { - AppUtils.removeLoadingPath(response.requestOptions.path); - } else { - AppUtils.cleanLoadingPath(); - } - - debugPrint("code = ${response.statusCode}"); - p(jsonEncode(response.data)); - Map map = response.data; if (map["code"] == 40005 || map["code"] == 40001) { LoginTipsDialog.instance.show(context); } - debugPrint("======================= Min_响应数据结束 =======================\n"); if (map["code"] == 0) { handler.next(response); } else { @@ -108,20 +95,16 @@ abstract class MinApiService { ); } }, onError: (DioException e, ErrorInterceptorHandler handler) { + debugPrint("errorLogger:${e.toString()}"); if (SmartDialog.checkExist(dialogTypes: {SmartAllDialogType.loading})) { - AppUtils.removeLoadingPath(e.requestOptions.path); - } else { - AppUtils.cleanLoadingPath(); + SmartDialog.dismiss(status: SmartStatus.loading, force: true); } + if (e.type == DioExceptionType.unknown) { if (e.message?.isNotEmpty ?? false) { e.message!.toast; } } - debugPrint("\n======================= Min_错误响应数据 ======================="); - debugPrint("type = ${e.type}"); - debugPrint("message = ${e.message}"); - debugPrint("\n"); handler.next(e); }), ); @@ -132,16 +115,6 @@ abstract class MinApiService { return _MinApiService(dio, baseUrl: baseUrl, errorLogger: errorLogger); } - - static void p(String msg) { - int maxStrLength = 900; - while (msg.length > maxStrLength) { - debugPrint(msg.substring(0, maxStrLength), wrapWidth: maxStrLength); - msg = msg.substring(maxStrLength); - } - debugPrint(msg, wrapWidth: maxStrLength); - } - /// 会员信息 @GET("/member/info") Future memberInfo(); diff --git a/lib/retrofit/retrofit_api.dart b/lib/retrofit/retrofit_api.dart index 4bf4ab6b..20a9c328 100644 --- a/lib/retrofit/retrofit_api.dart +++ b/lib/retrofit/retrofit_api.dart @@ -1,4 +1,3 @@ -import 'dart:convert'; import 'dart:io'; import 'package:dio/dio.dart'; @@ -67,7 +66,6 @@ import 'package:huixiang/data/vip_card_home.dart'; import 'package:huixiang/data/vip_rule_details.dart'; import 'package:huixiang/data/wx_pay.dart'; import 'package:huixiang/generated/l10n.dart'; -import 'package:huixiang/utils/flutter_utils.dart'; import 'package:huixiang/view_widget/login_tips_dialog.dart'; import 'package:retrofit/retrofit.dart'; @@ -97,36 +95,24 @@ abstract class ApiService { responseType: ResponseType.json, ); + if (!dio.interceptors.any((e) => e is LogInterceptor)) { + dio.interceptors.add(LogInterceptor( + responseBody: true, + requestBody: true, + requestHeader: true, + responseHeader: true, + request: false, + error: true, + )); + } + if (dio.interceptors.length <= 1) { dio.interceptors.add( InterceptorsWrapper(onRequest: (RequestOptions options, RequestInterceptorHandler handler) { - try { - debugPrint("\n======================= 请求数据 ======================="); - debugPrint("method = ${options.method.toString()}"); - debugPrint("url = ${options.uri.toString()}"); - debugPrint("headers = ${options.headers}"); - AppUtils.addLoadingPath(options.path); - if (showLoading && !SmartDialog.checkExist(dialogTypes: {SmartAllDialogType.loading})) { - //是否显示loading - S.current.zhengzaijiazai.loading; - } - if (options.data is FormData) { - debugPrint("params data = FormData"); - } else { - debugPrint("params data = ${jsonEncode(options.data)}"); - } - debugPrint("params queryParameters = ${options.queryParameters}"); - } catch (e1) {} + S.current.zhengzaijiazai.loading; handler.next(options); }, onResponse: (Response response, ResponseInterceptorHandler handler) { - debugPrint("\n======================= 响应数据开始 ======================="); - if (SmartDialog.checkExist(dialogTypes: {SmartAllDialogType.loading})) { - AppUtils.removeLoadingPath(response.requestOptions.path); - } else { - AppUtils.cleanLoadingPath(); - } - debugPrint("code = ${response.statusCode}"); - p(jsonEncode(response.data)); + if (response.data is Map) { Map map = response.data; if (map["code"] == 40005 || map["code"] == 40001) { @@ -134,7 +120,7 @@ abstract class ApiService { LoginTipsDialog.instance.show(context); } } - debugPrint("======================= 响应数据结束 =======================\n"); + if (map["code"] == 0 || map["code"] == 200 || map["repCode"] == "0000" || map["infocode"] == "10000") { handler.next(response); } else { @@ -149,20 +135,17 @@ abstract class ApiService { handler.next(response); } }, onError: (DioException e, ErrorInterceptorHandler handler) { + debugPrint("errorLogger:${e.toString()}"); + if (SmartDialog.checkExist(dialogTypes: {SmartAllDialogType.loading})) { - AppUtils.removeLoadingPath(e.requestOptions.path); - } else { - AppUtils.cleanLoadingPath(); + SmartDialog.dismiss(status: SmartStatus.loading, force: true); } + if (e.type == DioExceptionType.unknown) { if (e.message?.isNotEmpty ?? false) { e.message!.toast; } } - debugPrint("\n======================= 错误响应数据 ======================="); - debugPrint("type = ${e.type}"); - debugPrint("message = ${e.message}"); - debugPrint("\n"); handler.next(e); }), ); @@ -171,35 +154,18 @@ abstract class ApiService { return _ApiService(dio, baseUrl: baseUrl, errorLogger: errorLogger); } - static void p(String msg) { - //因为String的length是字符数量不是字节数量所以为了防止中文字符过多, - // 把4*1024的MAX字节打印长度改为1000字符数 - if (msg.length > 10000) return; - int maxStrLength = 900; - //大于1000时 - while (msg.length > maxStrLength) { - debugPrint(msg.substring(0, maxStrLength), wrapWidth: maxStrLength); - msg = msg.substring(maxStrLength); - } - //剩余部分 - debugPrint(msg, wrapWidth: maxStrLength); - } - ///文件上传 @POST("/file/upload") @MultiPart() - Future> upload(@Part(name: "file") File data, - @Part(name: "folderId") int folderId, bool isVideo); + Future> upload(@Part(name: "file") File data, @Part(name: "folderId") int folderId, bool isVideo); /// 周边搜索 @GET("https://restapi.amap.com/v3/place/around?key=542b46afa8e4b88fe1eb3c4d0ba0872f&location={lng},{lat}&keywords={keywords}&offset={size}&page={page}&extensions=all") - Future searchPoi(@Path("lat") String lat, @Path("lng") String lng, - @Path("keywords") String keywords, int size, int page); + Future searchPoi(@Path("lat") String lat, @Path("lng") String lng, @Path("keywords") String keywords, int size, int page); /// 逆地理编码 @GET("https://restapi.amap.com/v3/geocode/regeo?key=542b46afa8e4b88fe1eb3c4d0ba0872f&location={lng},{lat}&extensions=base&output=json") - Future geocodeRegeo( - @Path("lat") String lat, @Path("lng") String lng); + Future geocodeRegeo(@Path("lat") String lat, @Path("lng") String lng); /// 用户登录 @POST("/auth/platform/memberLogin") @@ -215,13 +181,11 @@ abstract class ApiService { ///积分商城商品列表 @POST("/creditGoods/list") - Future>> creditGoods( - @Body() Map param); + Future>> creditGoods(@Body() Map param); ///积分商城商品分類列表 @POST("/creditGoodsCategory/page") - Future>> goodsCategory( - @Body() Map param); + Future>> goodsCategory(@Body() Map param); ///积分商城商品详情 @GET("/creditGoods/{id}") @@ -249,8 +213,7 @@ abstract class ApiService { ///充值活动列表 @GET("/wallet/rechargeActList?tenantCode={tenantCode}") - Future> rechargeActList( - @Path("tenantCode") String tenantCode); + Future> rechargeActList(@Path("tenantCode") String tenantCode); ///领取优惠券 @GET("/coupon/receive?couponId={couponId}") diff --git a/lib/settlement/settlement.dart b/lib/settlement/settlement.dart index f8d2dbac..9893ea80 100644 --- a/lib/settlement/settlement.dart +++ b/lib/settlement/settlement.dart @@ -298,6 +298,7 @@ class _Settlement extends State { } } } finally { + SmartDialog.dismiss(status: SmartStatus.loading, force: true); setState(() {}); } } diff --git a/lib/store/shop_details_page.dart b/lib/store/shop_details_page.dart index 68454838..0d752af7 100644 --- a/lib/store/shop_details_page.dart +++ b/lib/store/shop_details_page.dart @@ -18,18 +18,19 @@ import 'package:huixiang/retrofit/retrofit_api.dart'; import 'package:huixiang/store/store_view/people_num.dart'; import 'package:huixiang/store/store_view/shop_car.dart'; import 'package:huixiang/utils/app_util.dart'; +import 'package:huixiang/utils/constant.dart'; +import 'package:huixiang/utils/flutter_utils.dart'; import 'package:huixiang/utils/font_weight.dart'; import 'package:huixiang/utils/shared_preference.dart'; +import 'package:huixiang/view_widget/border_text.dart'; import 'package:huixiang/view_widget/classic_header.dart'; import 'package:huixiang/view_widget/custom_image.dart'; import 'package:huixiang/view_widget/my_footer.dart'; +import 'package:huixiang/view_widget/request_permission.dart'; import 'package:huixiang/view_widget/round_button.dart'; import 'package:permission_handler/permission_handler.dart'; import 'package:pull_to_refresh/pull_to_refresh.dart'; -import 'package:shared_preferences/shared_preferences.dart'; -import '../view_widget/border_text.dart'; -import '../view_widget/request_permission.dart'; class ShopDetailsPage extends StatefulWidget { final Map? arguments; @@ -76,22 +77,7 @@ class _ShopDetailsPage extends State { id = widget.arguments?["id"] ?? ""; storeId = widget.arguments?["storeId"] ?? ""; isSetMeal = widget.arguments?["isSetMeal"] ?? false; - // SharedPreferences.getInstance().then((value) { - // String minToken = value.getString("minToken"); - // String tenant = value.getString("tenant"); - // String storeId = value.getString("storeId"); - // minService = MinApiService(Dio(), - // context: context, - // token: minToken, - // tenant: tenant, - // storeId: storeId, - // showLoading: true); - // queryMiNiDetail(id); - // queryShopCar().then((value) { - // this.shopCarGoods = value; - // setState(() {}); - // }); - // }); + queryStoreInfo(); buildCount(); } @@ -118,7 +104,6 @@ class _ShopDetailsPage extends State { } minLogin(); } - // SmartDialog.dismiss(); } /// 小程序登录 @@ -147,7 +132,6 @@ class _ShopDetailsPage extends State { this.shopCarGoods = value; setState(() {}); }); - // SmartDialog.dismiss(); } }); } @@ -171,6 +155,7 @@ class _ShopDetailsPage extends State { } else { refreshController.refreshFailed(); } + SmartDialog.dismiss(status: SmartStatus.loading, force: true); } _onRefresh() { @@ -178,7 +163,7 @@ class _ShopDetailsPage extends State { } ///获取父订单(火锅订单加菜前调用) - getParentInfo() async { + Future getParentInfo() async { BaseData? baseData = await minService?.getParentInfo("$tableId").catchError((error) { debugPrint("${error}"); return BaseData()..isSuccess = false; @@ -188,14 +173,13 @@ class _ShopDetailsPage extends State { parentId = baseData.data["id"]; parentCode = baseData.data["parentCode"]; } else { - ///TODO: 没有父订单, - queryStoreInfo1(); + await queryStoreInfo1(); } } } ///显示选择人数的弹窗 - showPeopleNum(String? tableName) async { + Future showPeopleNum(String? tableName) async { var people = await showDialog( context: context, barrierDismissible: false, @@ -214,7 +198,7 @@ class _ShopDetailsPage extends State { } ///获取桌子信息 - queryStoreInfo1() async { + Future queryStoreInfo1() async { BaseData? baseData = await minService?.queryStoreInfo1({ "getCoupon": true, "storeId": storeId, @@ -225,7 +209,7 @@ class _ShopDetailsPage extends State { }); if ((baseData?.isSuccess ?? false) && baseData!.data != null) { StoreInfo storeInfo = baseData.data!; - showPeopleNum(storeInfo.storeTable?.tableName); + await showPeopleNum(storeInfo.storeTable?.tableName); } } @@ -240,7 +224,7 @@ class _ShopDetailsPage extends State { } ///去下单结算页面 - toDownOrder() async { + Future toDownOrder() async { int num = count(); if (parentId == "") { @@ -269,48 +253,44 @@ class _ShopDetailsPage extends State { ); if ((miNiDetail?.subscribeParam?.isEnableSubscribe ?? false)) { - clearShopCar(); + await clearShopCar(); this.shopCarGoods = await queryShopCar(); } if (tableId > 0) { - getParentInfo(); + await getParentInfo(); } - queryShopCar().then((value) { - this.shopCarGoods = value; - setState(() {}); - }); + this.shopCarGoods = await queryShopCar(); + setState(() {}); } /// 购物车的key,用于刷新UI GlobalKey shopCartKey = GlobalKey(); ///购物车弹窗 - showShoppingCart() { - queryShopCar().then((value) { - this.shopCarGoods = value; - dialogShowing = true; - SmartDialog.show( - builder: (ctx) { - return ShopCar( - shopCartKey, - this.shopCarGoods, - clearShopCar, - toDownOrder, - shopCartAdd, - shopCartReduce, - ); - }, - onDismiss: () { - dialogShowing = false; - }, - alignment: Alignment.bottomCenter, - ); - }); + Future showShoppingCart() async { + this.shopCarGoods = await queryShopCar(); + dialogShowing = true; + SmartDialog.show( + builder: (ctx) { + return ShopCar( + shopCartKey, + this.shopCarGoods, + clearShopCar, + toDownOrder, + shopCartAdd, + shopCartReduce, + ); + }, + onDismiss: () { + dialogShowing = false; + }, + alignment: Alignment.bottomCenter, + ); } ///清空购物车 - clearShopCar() async { + Future clearShopCar() async { BaseData? baseData = await minService?.clearShoppingCart(num.parse(storeId)); if (baseData?.isSuccess ?? false) { shopCarGoods = null; @@ -319,7 +299,7 @@ class _ShopDetailsPage extends State { } ///选规格 - _queryMiNiDetail(String id, int count) async { + Future _queryMiNiDetail(String id, int count) async { S.current.zhengzaijiazai.loading; if (count < 0) { shopCarGoods?.shoppingCartSkuItemList?.forEach((element) { @@ -332,19 +312,20 @@ class _ShopDetailsPage extends State { } BaseData? baseData = await minService?.miNiDetail(id); if (baseData?.isSuccess ?? false) { - showStoreSelector(baseData!.data, id, count); + await showStoreSelector(baseData!.data, id, count); } } ///选规格弹窗 - showStoreSelector(MiniDetail? miNiDetail, String id, int count) async { + Future showStoreSelector(MiniDetail? miNiDetail, String id, int count) async { if (miNiDetail?.attrList?.length == 1 && (miNiDetail?.attrList![0].attrValueList?.isNotEmpty ?? false)) { - _addShopCar(miNiDetail, [], counts); + await _addShopCar(miNiDetail, [], counts); } else { // showSpanDialog(); selectSpecsShowBottomSheet(); } + SmartDialog.dismiss(status: SmartStatus.loading, force: true); } ///添加购物车 @@ -372,7 +353,7 @@ class _ShopDetailsPage extends State { .replaceAll(",", ""); if (miNiDetail?.subscribeParam?.isEnableSubscribe ?? false) { - clearShopCar(); + await clearShopCar(); } BaseListData? baseDate = await minService?.addShoppingCart({ @@ -398,14 +379,11 @@ class _ShopDetailsPage extends State { }).catchError((error) { return BaseListData()..isSuccess = false; }); - SmartDialog.dismiss(); if (baseDate?.isSuccess ?? false) { - queryShopCar().then((value) { - this.shopCarGoods = value; - if (miNiDetail?.subscribeParam?.isEnableSubscribe ?? false) - toDownOrder(); - setState(() {}); - }); + this.shopCarGoods = await queryShopCar(); + if (miNiDetail?.subscribeParam?.isEnableSubscribe ?? false) + toDownOrder(); + setState(() {}); } } @@ -415,7 +393,7 @@ class _ShopDetailsPage extends State { pid = ""; //活动 cName = ""; //优惠券 cid = ""; //优惠券 - BaseListData? baseDate = await minService?.getShoppingCart(tableId); + 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) { @@ -433,109 +411,52 @@ class _ShopDetailsPage extends State { }); } return baseDate.data![0]; - } else { - return null; } + return null; } ///购物车➕1 Future shopCartAdd(SkuItemList cartSkuItem) async { + S.current.zhengzaijiazai.loading; Map shopCarTemp = shopCarGoods?.toJson() ?? {}; int buyNum = cartSkuItem.buyNum ?? 0; - cartSkuItem.buyNum = buyNum + 1; - shopCarTemp["shoppingCartSkuItemList"] = [cartSkuItem.toJson()]; - BaseListData? baseDate = - await minService?.shoppingCartSingle(shopCarTemp); + Map shoppingCartSkuItemList = cartSkuItem.toJson(); + shoppingCartSkuItemList["buyNum"] = buyNum + 1; + shopCarTemp["shoppingCartSkuItemList"] = [shoppingCartSkuItemList]; + shopCarTemp["couponList"] = []; + BaseListData? baseDate = await minService?.shoppingCartSingle(shopCarTemp).catchLEr(); if (baseDate?.isSuccess ?? false) { this.shopCarGoods = await queryShopCar(); + cartSkuItem.buyNum = buyNum + 1; shopCartKey.currentState?.setState(() {}); setState(() {}); } + SmartDialog.dismiss(status: SmartStatus.loading, force: true); return this.shopCarGoods; } ///购物车➖1 Future shopCartReduce(SkuItemList cartSkuItem) async { + S.current.zhengzaijiazai.loading; Map shopCarTemp = shopCarGoods?.toJson() ?? {}; int buyNum = cartSkuItem.buyNum ?? 0; - cartSkuItem.buyNum = buyNum - 1; - shopCarTemp["shoppingCartSkuItemList"] = [cartSkuItem.toJson()]; + Map shoppingCartSkuItemList = cartSkuItem.toJson(); + shoppingCartSkuItemList["buyNum"] = buyNum - 1; + shopCarTemp["shoppingCartSkuItemList"] = [shoppingCartSkuItemList]; shopCarTemp["couponList"] = []; BaseListData? baseDate = await minService?.shoppingCartSingle(shopCarTemp); if (baseDate?.isSuccess ?? false) { this.shopCarGoods = await queryShopCar(); + cartSkuItem.buyNum = buyNum - 1; if (shopCartKey.currentState != null) { shopCartKey.currentState!.setState(() {}); } setState(() {}); } + SmartDialog.dismiss(status: SmartStatus.loading, force: true); return this.shopCarGoods; } - ///商品➕1 - add(MiniDetail miNiDetail, selectSkus) async { - ProductSkuVOList? productSku = miNiDetail.productSkuVOList?.firstWhere((element) { - return skuY(element, selectSkus); - }); - String? skuId = productSku?.id; - int shopSkuIndex = shopCarGoods?.shoppingCartSkuItemList - ?.indexWhere((element) => skuId == element.id) ?? - -1; - Map shopCarTemp = shopCarGoods?.toJson() ?? {}; - shopCarGoods?.tableId = "$tableId"; - - if (shopSkuIndex >= 0) { - int buyNum = shopCarGoods?.shoppingCartSkuItemList?[shopSkuIndex].buyNum ?? 0; - shopCarGoods?.shoppingCartSkuItemList?[shopSkuIndex].buyNum = buyNum + 1; - SkuItemList? cartSkuItem = shopCarGoods?.shoppingCartSkuItemList - ?.firstWhere((element) => skuId == element.id); - shopCarTemp["shoppingCartSkuItemList"] = [cartSkuItem?.toJson()]; - shopCarTemp["couponList"] = []; - } else { - await _addShopCar(miNiDetail, selectSkus, 2); - return; - } - - BaseListData? baseDate = await minService?.shoppingCartSingle(shopCarTemp); - if (baseDate?.isSuccess ?? false) { - queryShopCar().then((value) { - this.shopCarGoods = value; - setState(() {}); - }); - } - } - - ///商品➖1 - reduce(MiniDetail miNiDetail, selectSkus) async { - ProductSkuVOList? productSku = miNiDetail.productSkuVOList?.firstWhere((element) { - return skuY(element, selectSkus); - }); - String? skuId = productSku?.id; - SkuItemList? shopSkuItem = shopCarGoods?.shoppingCartSkuItemList - ?.firstWhere((element) => skuId == element.id); - int shopSkuIndex = shopCarGoods?.shoppingCartSkuItemList - ?.indexWhere((element) => skuId == element.id) ?? -1; - - if ((shopSkuItem?.buyNum ?? 0) > 1) { - int buyNum = shopCarGoods?.shoppingCartSkuItemList?[shopSkuIndex].buyNum ?? 0; - shopCarGoods?.shoppingCartSkuItemList?[shopSkuIndex].buyNum = buyNum - 1; - } - shopCarGoods?.tableId = "$tableId"; - - Map shopCarTemp = shopCarGoods?.toJson() ?? {}; - SkuItemList? cartSkuItem = shopCarGoods?.shoppingCartSkuItemList - ?.firstWhere((element) => skuId == element.id); - shopCarTemp["shoppingCartSkuItemList"] = [cartSkuItem?.toJson()]; - - BaseListData? baseDate = await minService?.shoppingCartSingle(shopCarTemp); - if (baseDate?.isSuccess ?? false) { - queryShopCar().then((value) { - this.shopCarGoods = value; - setState(() {}); - }); - } - } - bool skuY(ProductSkuVOList productSku, selectSkus) { bool gg = true; selectSkus.forEach((element1) { diff --git a/lib/store/store_order.dart b/lib/store/store_order.dart index 75763b14..0a88e529 100644 --- a/lib/store/store_order.dart +++ b/lib/store/store_order.dart @@ -113,19 +113,18 @@ class _StoreOrderPage extends State storeId: storeId, ); - queryMemberInfo(); + await queryMemberInfo(); - queryShopCar().then((value) { - this.shopCarGoods = value; - setState(() {}); - }); + ShoppingCart? value = await queryShopCar(); if (tableId > 0) { getParentInfo(); } + this.shopCarGoods = value; + setState(() {}); } ///会员信息 - queryMemberInfo() async { + Future queryMemberInfo() async { BaseData? baseData = await minService?.memberInfo().catchError((error) { debugPrint("${error}"); return BaseData()..isSuccess = false; @@ -137,7 +136,7 @@ class _StoreOrderPage extends State } ///获取父订单(火锅订单加菜前调用) - getParentInfo() async { + Future getParentInfo() async { BaseData? baseData = await minService?.getParentInfo("$tableId").catchError((error) { debugPrint("${error}"); @@ -154,7 +153,7 @@ class _StoreOrderPage extends State } ///获取桌子信息 - queryStoreInfo1() async { + Future queryStoreInfo1() async { BaseData? baseData = await minService?.queryStoreInfo1({ "getCoupon": true, "storeId": storeId, @@ -170,7 +169,7 @@ class _StoreOrderPage extends State } /// 查询店铺信息 - queryStoreInfo() async { + Future queryStoreInfo() async { BaseData? baseData = await apiService?.queryStoreInfo(storeId).catchError((error) { debugPrint("${error}"); @@ -370,6 +369,7 @@ class _StoreOrderPage extends State () { queryShopCar().then((value) { this.shopCarGoods = value; + SmartDialog.dismiss(status: SmartStatus.loading, force: true); setState(() {}); }); }, @@ -377,30 +377,6 @@ class _StoreOrderPage extends State ), ), ], - // pinnedHeaderSliverHeightBuilder: () { - // final double statusBarHeight = MediaQuery.of(context).padding.top; - // return statusBarHeight + kToolbarHeight + 38; - // }, - // body: StoreOrderListPage( - // widget.arguments, - // activitys, - // storeInfo, - // shopCarGoods, - // controller1, - // controller2, - // nestedScrollViewKey, - // minToken, - // tenant, - // tableId, - // _queryMiNiDetail, - // () { - // queryShopCar().then((value) { - // this.shopCarGoods = value; - // setState(() {}); - // }); - // }, - // scrollPhysics, - // ), ), ), ), @@ -682,9 +658,8 @@ class _StoreOrderPage extends State } ///清空购物车 - clearShopCar() async { - BaseData? baseData = - await minService?.clearShoppingCart(num.parse(storeId)); + Future clearShopCar() async { + BaseData? baseData = await minService?.clearShoppingCart(num.parse(storeId)); if (baseData?.isSuccess ?? false) { shopCarGoods = null; setState(() {}); @@ -700,23 +675,24 @@ class _StoreOrderPage extends State await shopCartReduce(skuItems!.first); setState(() {}); } + SmartDialog.dismiss(status: SmartStatus.loading, force: true); return; } BaseData? baseData = await minService?.miNiDetail(id); if (baseData?.isSuccess ?? false) { miniDetail = baseData!.data; if (baseData.data != null) { - showStoreSelector(baseData.data!, id, count); + await showStoreSelector(baseData.data!, id, count); } } + SmartDialog.dismiss(status: SmartStatus.loading, force: true); } ///选规格弹窗 - showStoreSelector(MiniDetail miniDetail, String? id, int count) async { + Future showStoreSelector(MiniDetail miniDetail, String? id, int count) async { if (miniDetail.attrStyle == 0) { - _addShopCar(miniDetail, [], count); + await _addShopCar(miniDetail, [], count); } else { - SmartDialog.dismiss(); dialogShowing = true; showModalBottomSheet( backgroundColor: Colors.transparent, @@ -761,7 +737,7 @@ class _StoreOrderPage extends State .replaceAll(",", ""); if (miniDetail?.subscribeParam?.isEnableSubscribe ?? false) { - clearShopCar(); + await clearShopCar(); } BaseListData? baseDate = await minService?.addShoppingCart({ @@ -785,7 +761,6 @@ class _StoreOrderPage extends State }, ], }).catchLEr(); - // SmartDialog.dismiss(); if (baseDate?.isSuccess ?? false) { this.shopCarGoods = await queryShopCar(); if (miniDetail?.subscribeParam?.isEnableSubscribe ?? false) toDownOrder(); @@ -802,33 +777,29 @@ class _StoreOrderPage extends State if (storeInfo?.posType?.code == "NORMALSTORE" && tableId == 0) { return null; } - BaseListData? baseDate = - await minService?.getShoppingCart(tableId).catchLEr(); - if ((baseDate?.isSuccess ?? false) && - (baseDate!.data?.isNotEmpty ?? false)) { + 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) { if (element.isMaxCoupon ?? false) { - // cName = element.promotionName; cid = element.id; } }); } else if (baseDate.data![0].selectDiscount == 2) { baseDate.data![0].promotionInfoList?.forEach((element) { if (element.isMaxPromotion ?? false) { - // pName = element.name; pid = element.id; } }); } return baseDate.data![0]; - } else { - return null; } + return null; } ///购物车➕1 Future shopCartAdd(SkuItemList cartSkuItem) async { + S.current.zhengzaijiazai.loading; Map shopCarTemp = shopCarGoods?.toJson() ?? {}; cartSkuItem.buyNum = (cartSkuItem.buyNum ?? 0) + 1; shopCarTemp["shoppingCartSkuItemList"] = [cartSkuItem.toJson()]; @@ -841,12 +812,14 @@ class _StoreOrderPage extends State this.shopCarGoods = await queryShopCar(); shopCartKey.currentState?.setState(() {}); } + SmartDialog.dismiss(status: SmartStatus.loading, force: true); setState(() {}); return this.shopCarGoods; } ///购物车➖1 Future shopCartReduce(SkuItemList cartSkuItem) async { + S.current.zhengzaijiazai.loading; Map shopCarTemp = shopCarGoods?.toJson() ?? {}; cartSkuItem.buyNum = (cartSkuItem.buyNum ?? 0) - 1; shopCarTemp["shoppingCartSkuItemList"] = [cartSkuItem.toJson()]; @@ -859,6 +832,7 @@ class _StoreOrderPage extends State } setState(() {}); } + SmartDialog.dismiss(status: SmartStatus.loading, force: true); return this.shopCarGoods; } diff --git a/lib/store/store_view/people_num.dart b/lib/store/store_view/people_num.dart index ddbf7310..0a58bf3e 100644 --- a/lib/store/store_view/people_num.dart +++ b/lib/store/store_view/people_num.dart @@ -125,7 +125,6 @@ class _PeopleNumView extends State { radius: 4.w, callback: () { // widget.callback(peopleNum); - // SmartDialog.dismiss(); Navigator.of(context).pop(peopleNum); }, ), diff --git a/lib/store/store_view/product_sku.dart b/lib/store/store_view/product_sku.dart index c1454b5b..7ee189f4 100644 --- a/lib/store/store_view/product_sku.dart +++ b/lib/store/store_view/product_sku.dart @@ -183,7 +183,6 @@ class _ProductSku extends State { InkWell( onTap: () { Navigator.of(context).pop(); - // SmartDialog.dismiss(); }, child: Image.asset( "assets/image/cancel.webp", @@ -288,7 +287,6 @@ class _ProductSku extends State { count += 1; } setState(() {}); - SmartDialog.dismiss(); }, child: Image.asset( "assets/image/add.webp", @@ -315,7 +313,6 @@ class _ProductSku extends State { fontSize: 16.sp, callback: () { Navigator.of(context1).pop(); - // SmartDialog.dismiss(); int number = count - realCount; if (number == 0 && realCount == 1) { number = 1; @@ -339,7 +336,6 @@ class _ProductSku extends State { fontSize: 16.sp, callback: () { Navigator.of(context).pop(); - // SmartDialog.dismiss(); widget.addShopCar(widget.miNiDetail, selectSkus, count); }, ), diff --git a/lib/store/store_view/shop_car.dart b/lib/store/store_view/shop_car.dart index 1f7c0e79..c7d5ca36 100644 --- a/lib/store/store_view/shop_car.dart +++ b/lib/store/store_view/shop_car.dart @@ -3,6 +3,7 @@ import 'package:flutter_smart_dialog/flutter_smart_dialog.dart'; import 'package:huixiang/data/shopping_cart.dart'; import 'package:huixiang/generated/l10n.dart'; import 'package:huixiang/store/store_view/shop_goods_car.dart'; +import 'package:huixiang/utils/constant.dart'; import 'package:huixiang/utils/font_weight.dart'; import 'package:huixiang/view_widget/round_button.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; @@ -97,6 +98,7 @@ class _ShopCar extends State { ], ), ), + 16.d, Expanded( child: Stack( children: [ @@ -112,6 +114,7 @@ class _ShopCar extends State { ), child: ListView.builder( itemCount: itemCount(), + padding: EdgeInsets.zero, physics: BouncingScrollPhysics(), itemBuilder: (context, position) { return ShopGoodsCar( diff --git a/lib/store/store_view/shop_goods.dart b/lib/store/store_view/shop_goods.dart index fd923dd1..56c61c6d 100644 --- a/lib/store/store_view/shop_goods.dart +++ b/lib/store/store_view/shop_goods.dart @@ -6,6 +6,7 @@ import 'package:huixiang/data/find_mini_group.dart'; import 'package:huixiang/data/mini_detail.dart'; import 'package:huixiang/data/shopping_cart.dart'; import 'package:huixiang/generated/l10n.dart'; +import 'package:huixiang/utils/flutter_utils.dart'; import 'package:huixiang/utils/font_weight.dart'; import 'package:huixiang/utils/shared_preference.dart'; import 'package:huixiang/utils/str_utils.dart'; @@ -55,6 +56,34 @@ class _ShopGoods extends State { int _jumpType = -1; MiniDetail? miNiDetail; + late ProductListBean? productListBean; + late SkuItemList? shoppingCartSkuItemListBean; + late int count; + late int tableId; + late bool isShopCart; + late StoreInfo? storeInfo; + + @override + void initState() { + productListBean = widget.productListBean; + shoppingCartSkuItemListBean = widget.shoppingCartSkuItemListBean; + count = widget.count; + tableId = widget.tableId; + isShopCart = widget.isShopCart; + storeInfo = widget.storeInfo; + super.initState(); + } + + didUpdateWidget(oldWidget) { + productListBean = widget.productListBean; + shoppingCartSkuItemListBean = widget.shoppingCartSkuItemListBean; + count = widget.count; + tableId = widget.tableId; + isShopCart = widget.isShopCart; + storeInfo = widget.storeInfo; + super.didUpdateWidget(oldWidget); + } + ///商品详情 queryMiNiDetail(id) async { MinApiService? minService; @@ -75,35 +104,30 @@ class _ShopGoods extends State { miNiDetail = baseData.data; if (baseData.data?.productSkuVOList?[0].productSetMeals?.isEmpty ?? true) { _jumpType = 0; - if (widget.shoppingCartSkuItemListBean != null) { - widget.add.call(widget.shoppingCartSkuItemListBean!); - } + widget.add.call(widget.shoppingCartSkuItemListBean); } else { _jumpType = 1; - await Navigator.of(context) - .pushNamed('/router/product_meals_sku', arguments: { - "id": widget.productListBean?.id, - "storeId": widget.productListBean?.storeId, - "tableId": widget.tableId - }); + await Navigator.of(context).pushNamed( + '/router/product_meals_sku', + arguments: { + "id": widget.productListBean?.id, + "storeId": widget.productListBean?.storeId, + "tableId": widget.tableId + }, + ); widget.queryShoppingCart(); } - } else { - // refreshController.refreshFailed(); } } @override Widget build(BuildContext context) { - String price = doubleStr2Int( - "${widget.isShopCart ? widget.shoppingCartSkuItemListBean?.skuPrice : widget.productListBean?.price}"); + String price = doubleStr2Int("${widget.isShopCart ? widget.shoppingCartSkuItemListBean?.skuPrice : widget.productListBean?.price}"); return Container( color: Colors.white, - // padding: EdgeInsets.only( - // right: 16.w, - // // bottom: 20.h, - // ), - height: 123.h, + padding: EdgeInsets.symmetric( + vertical: 8.h, + ), child: Row( crossAxisAlignment: CrossAxisAlignment.start, mainAxisAlignment: MainAxisAlignment.start, @@ -125,130 +149,71 @@ class _ShopGoods extends State { width: 10.w, ), Expanded( - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Padding( - padding: EdgeInsets.only(right: 16.w), - child: Row( - children: [ - Expanded( - child: Text( - widget.productListBean!.productName ?? - widget.shoppingCartSkuItemListBean!.productName ?? - "", - overflow: TextOverflow.ellipsis, - maxLines: 1, - style: TextStyle( - color: Colors.black, - fontSize: 13.sp, - fontWeight: MyFontWeight.medium, - ), - ), + child: IntrinsicHeight( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Padding( + padding: EdgeInsets.only(right: 16.w), + child: Text( + widget.productListBean!.productName ?? widget.shoppingCartSkuItemListBean!.productName ?? "", + overflow: TextOverflow.ellipsis, + maxLines: 1, + style: TextStyle( + color: Colors.black, + fontSize: 13.sp, + fontWeight: MyFontWeight.medium, ), - // Image.asset( - // "assets/image/green_leaf.webp", - // fit: BoxFit.cover, - // width: 12, - // height: 12, - // ), - // Text( - // "X300", - // style: TextStyle( - // color: Color(0xFF55BC51), - // fontSize: 10.sp, - // fontWeight: MyFontWeight.semi_bold, - // ), - // ), - ], + ), ), - ), - SizedBox( - height: 2.h, - ), - Padding( - padding: EdgeInsets.only(right: 16.w), - child: Row( - children: [ - Expanded( - child: Text( - widget.productListBean!.shortName ?? - widget.shoppingCartSkuItemListBean!.skuName ?? - "", - overflow: TextOverflow.ellipsis, - maxLines: 2, - style: TextStyle( - color: Color(0xFF4C4C4C), - fontSize: 10.sp, - fontWeight: MyFontWeight.regular, - ), - ), - ), - SizedBox( - width: 10.w, + SizedBox( + height: 2.h, + ), + Padding( + padding: EdgeInsets.only(right: 25.w), + child: Text( + widget.productListBean!.shortName ?? widget.shoppingCartSkuItemListBean!.skuName ?? "", + overflow: TextOverflow.ellipsis, + maxLines: 2, + style: TextStyle( + color: Color(0xFF4C4C4C), + fontSize: 10.sp, + fontWeight: MyFontWeight.regular, ), - ], + ), ), - ), - SizedBox( - height: 7.h, - ), - Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Row( - children: [ - Text( - "¥${price}", - style: TextStyle( - color: Color(0xFFFF4500), - fontSize: 16.sp, - fontFamily: 'JDZhengHT', - fontWeight: MyFontWeight.medium, + SizedBox( + height: 7.h, + ), + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Row( + children: [ + Text( + "¥${price}", + style: TextStyle( + color: Color(0xFFFF4500), + fontSize: 16.sp, + fontFamily: 'JDZhengHT', + fontWeight: MyFontWeight.medium, + ), ), - ), - SizedBox( - width: 2.w, - ), - // Container( - // width: 44.w, - // height: 18.h, - // decoration: BoxDecoration( - // color: Color(0xFFFF4500), - // borderRadius: BorderRadius.circular(2), - // ), - // alignment: Alignment.center, - // child: Text( - // "APP专享", - // style: TextStyle( - // color: Color(0xFFFFFFFF), - // fontSize: 10.sp, - // fontWeight: MyFontWeight.medium, - // ), - // ), - // ), - ], - ), - if (!widget.isShopCart && - (widget.productListBean?.attrStyle ?? 0) == 1 && - !(widget.productListBean?.subscribeParam - ?.isEnableSubscribe ?? - false) && - !(widget.productListBean?.isSetMeal ?? false)) - GestureDetector( + SizedBox( + width: 2.w, + ), + ], + ), + if (!widget.isShopCart && (widget.productListBean?.attrStyle ?? 0) == 1 && + !(widget.productListBean?.subscribeParam?.isEnableSubscribe ?? false) && + !(widget.productListBean?.isSetMeal ?? false)) + GestureDetector( behavior: HitTestBehavior.opaque, onTap: () async { - if (widget.storeInfo?.posType?.code == - "NORMALSTORE" && - widget.tableId == 0) { + if (widget.storeInfo?.posType?.code == "NORMALSTORE" && widget.tableId == 0) { showDeleteDialog(); } else { - widget.queryMiNiDetail( - widget.productListBean!.id ?? - widget.shoppingCartSkuItemListBean! - .productId ?? - "", - 0); + widget.queryMiNiDetail(widget.productListBean!.id ?? widget.shoppingCartSkuItemListBean!.productId ?? "", 0); } }, child: Stack( @@ -293,160 +258,128 @@ class _ShopGoods extends State { ), ), ], - )), - if (widget.isShopCart || - (widget.productListBean?.attrStyle ?? 0) == 0 && - !(widget.productListBean?.subscribeParam - ?.isEnableSubscribe ?? - false) && - !(widget.productListBean?.isSetMeal ?? false)) ...[ - Spacer(), - GestureDetector( - behavior: HitTestBehavior.opaque, - onTap: () async { - if (widget.storeInfo?.posType?.code == - "NORMALSTORE" && - widget.tableId == 0) { - showDeleteDialog(); - } else { - widget.reduce(widget.shoppingCartSkuItemListBean); - } - }, - child: Container( - padding: EdgeInsets.only(left: 15.w, right: 6.w), - child: Image.asset( - "assets/image/reduce.webp", - width: 22, - height: 22.h, ), ), - ), - Container( - alignment: Alignment.center, - child: Text( - "${widget.count}", - style: TextStyle( - color: Colors.black, - fontSize: 14.sp, - fontWeight: MyFontWeight.medium, + if (widget.isShopCart || (widget.productListBean?.attrStyle ?? 0) == 0 && + !(widget.productListBean?.subscribeParam?.isEnableSubscribe ?? false) && + !(widget.productListBean?.isSetMeal ?? false)) ...[ + Spacer(), + GestureDetector( + behavior: HitTestBehavior.opaque, + onTap: () async { + if (widget.storeInfo?.posType?.code == "NORMALSTORE" && widget.tableId == 0) { + showDeleteDialog(); + } else { + widget.reduce(widget.shoppingCartSkuItemListBean); + } + }, + child: Container( + padding: EdgeInsets.only(left: 15.w, right: 6.w), + child: Image.asset( + "assets/image/reduce.webp", + width: 22, + height: 22.h, + ), ), ), - ), - GestureDetector( - behavior: HitTestBehavior.opaque, - onTap: () async { - if (widget.storeInfo?.posType?.code == - "NORMALSTORE" && - widget.tableId == 0) { - showDeleteDialog(); - } else { - // if ((widget?.productListBean?.oversold ?? 0) == 0 && - // widget.count >= - // (widget?.shoppingCartSkuItemListBean - // ?.skuStock ?? - // 0)) { - // SmartDialog.showToast("库存不足", - // alignment: Alignment.center); - // } else - if (_jumpType == -1) - queryMiNiDetail(widget.productListBean?.id); - else if (_jumpType == 0) - widget.add(widget.shoppingCartSkuItemListBean); - else if (_jumpType == 1) - await Navigator.of(context).pushNamed( + Container( + alignment: Alignment.center, + child: Text( + "${widget.count}", + style: TextStyle( + color: Colors.black, + fontSize: 14.sp, + fontWeight: MyFontWeight.medium, + ), + ), + ), + GestureDetector( + behavior: HitTestBehavior.opaque, + onTap: () async { + if (widget.storeInfo?.posType?.code == "NORMALSTORE" && widget.tableId == 0) { + showDeleteDialog(); + } else { + if (_jumpType == -1) { + queryMiNiDetail(widget.productListBean?.id); + } else if (_jumpType == 0) { + widget.add(widget.shoppingCartSkuItemListBean); + } else if (_jumpType == 1) { + await Navigator.of(context).pushNamed( '/router/product_meals_sku', arguments: { "id": widget.productListBean?.id, "storeId": widget.productListBean?.storeId, "tableId": widget.tableId - }); - widget.queryShoppingCart(); - } - }, - child: Container( - padding: EdgeInsets.only(left: 6.w, right: 9.w), - child: Image.asset( - "assets/image/add.webp", - width: 22, - height: 22.h, - ), - ), - ), - ], - if (widget.productListBean?.subscribeParam - ?.isEnableSubscribe ?? - false) - GestureDetector( - behavior: HitTestBehavior.opaque, - onTap: () async { - if (widget.storeInfo?.posType?.code == - "NORMALSTORE" && - widget.tableId == 0) { - showDeleteDialog(); - } else if (widget.isShopCart || - (widget.productListBean?.attrStyle ?? 0) == 0) { - queryMiNiDetail(widget.productListBean?.id); - } else { - String? productId = widget.productListBean != null - ? widget.productListBean!.id - : widget.shoppingCartSkuItemListBean?.productId; - if (productId != null) { - widget.queryMiNiDetail(productId, 0); + }, + ); + widget.queryShoppingCart(); + } } - } - }, - child: Container( - padding: EdgeInsets.only( - left: 35.w, - top: 4.h, - bottom: 4.h, - ), - margin: EdgeInsets.only(right: 8.w, top: 4), - child: RoundButton( - text: S.of(context).lijiyuyue, - textColor: Colors.white, - fontWeight: MyFontWeight.medium, - radius: 3, - backgroup: Color(0xFF32A060), - fontSize: 11.sp, - padding: EdgeInsets.symmetric( - vertical: 5.h, - horizontal: 3.w, + }, + child: Container( + padding: EdgeInsets.only(left: 6.w, right: 9.w), + child: Image.asset( + "assets/image/add.webp", + width: 22, + height: 22.h, ), ), ), - ), - if ((widget.productListBean?.isSetMeal ?? false) == true) - GestureDetector( + ], + if (widget.productListBean?.subscribeParam?.isEnableSubscribe ?? false) + GestureDetector( behavior: HitTestBehavior.opaque, onTap: () async { - if (widget.storeInfo?.posType?.code == - "NORMALSTORE" && - widget.tableId == 0) { + if (widget.storeInfo?.posType?.code == "NORMALSTORE" && widget.tableId == 0) { showDeleteDialog(); + } else if (widget.isShopCart || (widget.productListBean?.attrStyle ?? 0) == 0) { + queryMiNiDetail(widget.productListBean?.id); + } else { + String? productId = widget.productListBean != null ? widget.productListBean!.id : widget.shoppingCartSkuItemListBean?.productId; + if (productId != null) { + widget.queryMiNiDetail(productId, 0); + } } - // else if ((widget?.productListBean?.oversold ?? - // 0) == - // 0 && - // widget.count >= - // (widget?.shoppingCartSkuItemListBean - // ?.skuStock ?? - // 0)) { - // SmartDialog.showToast("库存不足", - // alignment: Alignment.center); - // } - else { - await Navigator.of(context).pushNamed( + }, + child: Container( + padding: EdgeInsets.only( + left: 35.w, + top: 4.h, + bottom: 4.h, + ), + margin: EdgeInsets.only(right: 8.w, top: 4), + child: RoundButton( + text: S.of(context).lijiyuyue, + textColor: Colors.white, + fontWeight: MyFontWeight.medium, + radius: 3, + backgroup: Color(0xFF32A060), + fontSize: 11.sp, + padding: EdgeInsets.symmetric( + vertical: 5.h, + horizontal: 3.w, + ), + ), + ), + ), + if ((widget.productListBean?.isSetMeal ?? false) == true) + GestureDetector( + behavior: HitTestBehavior.opaque, + onTap: () async { + if (widget.storeInfo?.posType?.code == "NORMALSTORE" && widget.tableId == 0) { + showDeleteDialog(); + } else { + await Navigator.of(context).pushNamed( '/router/product_meals_sku', arguments: { "id": widget.productListBean?.id, "storeId": widget.productListBean?.storeId, "tableId": widget.tableId }, - ); - widget.queryShoppingCart(); - } - }, + ); + widget.queryShoppingCart(); + } + }, child: Stack( children: [ Container( @@ -464,7 +397,8 @@ class _ShopGoods extends State { backgroup: Color(0xFF32A060), fontSize: 11.sp, padding: EdgeInsets.symmetric( - vertical: 5.h, horizontal: 3.w), + vertical: 5.h, horizontal: 3.w, + ), ), ), Positioned( @@ -484,54 +418,56 @@ class _ShopGoods extends State { ), ), ], - )) - ], - ), - SizedBox( - height: 4.h, - ), + ), + ), + ], + ), + SizedBox( + height: 4.h, + ), - ///VIP价格(暂时弃用) - // if (widget.productListBean.vipPrice != null) - // Row( - // children: [ - // Container( - // alignment: Alignment.center, - // padding: EdgeInsets.symmetric(horizontal: 2.w), - // margin: EdgeInsets.only(right: 4.w), - // decoration: new BoxDecoration( - // color: Color(0xff32A060), - // borderRadius: BorderRadius.circular(4)), - // child: Text( - // "VIP", - // style: TextStyle( - // fontSize: 12.sp, - // fontWeight: MyFontWeight.medium, - // color: Color(0xFFFFFFFF), - // ), - // ), - // ), - // Text( - // "¥${AppUtils.calculateDouble(double.tryParse(widget.productListBean.vipPrice ?? "0") ?? 0)}", - // style: TextStyle( - // fontSize: 14.sp, - // fontWeight: MyFontWeight.medium, - // fontFamily: 'JDZhengHT', - // color: Color(0xff32A060), - // ), - // ), - // ], - // ), - // Text( - // "¥${AppUtils.calculateDouble(double.tryParse(widget.isShopCart ? widget.shoppingCartSkuItemListBean.skuPrice : widget.productListBean.applyPrice) ?? 0)}", - // style: TextStyle( - // color: Color(0xFFA29E9E), - // fontSize: 12.sp, - // decoration: TextDecoration.lineThrough, - // fontWeight: MyFontWeight.regular, - // ), - // ), - ], + ///VIP价格(暂时弃用) + // if (widget.productListBean.vipPrice != null) + // Row( + // children: [ + // Container( + // alignment: Alignment.center, + // padding: EdgeInsets.symmetric(horizontal: 2.w), + // margin: EdgeInsets.only(right: 4.w), + // decoration: new BoxDecoration( + // color: Color(0xff32A060), + // borderRadius: BorderRadius.circular(4)), + // child: Text( + // "VIP", + // style: TextStyle( + // fontSize: 12.sp, + // fontWeight: MyFontWeight.medium, + // color: Color(0xFFFFFFFF), + // ), + // ), + // ), + // Text( + // "¥${AppUtils.calculateDouble(double.tryParse(widget.productListBean.vipPrice ?? "0") ?? 0)}", + // style: TextStyle( + // fontSize: 14.sp, + // fontWeight: MyFontWeight.medium, + // fontFamily: 'JDZhengHT', + // color: Color(0xff32A060), + // ), + // ), + // ], + // ), + // Text( + // "¥${AppUtils.calculateDouble(double.tryParse(widget.isShopCart ? widget.shoppingCartSkuItemListBean.skuPrice : widget.productListBean.applyPrice) ?? 0)}", + // style: TextStyle( + // color: Color(0xFFA29E9E), + // fontSize: 12.sp, + // decoration: TextDecoration.lineThrough, + // fontWeight: MyFontWeight.regular, + // ), + // ), + ], + ), ), ), SizedBox(width: 6.w), diff --git a/lib/store/store_view/shop_goods_car.dart b/lib/store/store_view/shop_goods_car.dart index 80122301..44aa8070 100644 --- a/lib/store/store_view/shop_goods_car.dart +++ b/lib/store/store_view/shop_goods_car.dart @@ -43,8 +43,7 @@ class _ShopGoodsCar extends State { return Container( color: Colors.white, padding: EdgeInsets.only( - right: 16.w, - // bottom: 20.h, + right: 16.w, top: 12, bottom: 12, ), child: Column( children: [ @@ -68,100 +67,42 @@ class _ShopGoodsCar extends State { ), Expanded( child: Column( + mainAxisAlignment: MainAxisAlignment.spaceBetween, crossAxisAlignment: CrossAxisAlignment.start, children: [ - Row( - children: [ - Expanded( - child: Text( - widget.productListBean?.productName ?? widget.shoppingCartSkuItemListBean!.productName ?? "", - overflow: TextOverflow.ellipsis, - maxLines: 2, - style: TextStyle( - color: Colors.black, - fontSize: 13.sp, - fontWeight: MyFontWeight.medium, - ), - ), - ), - // Image.asset( - // "assets/image/green_leaf.webp", - // fit: BoxFit.cover, - // width: 12, - // height: 12, - // ), - // Text( - // "X300", - // style: TextStyle( - // color: Color(0xFF55BC51), - // fontSize: 10.sp, - // fontWeight: MyFontWeight.semi_bold, - // ), - // ), - ], + Text( + widget.productListBean?.productName ?? widget.shoppingCartSkuItemListBean!.productName ?? "", + overflow: TextOverflow.ellipsis, + maxLines: 2, + style: TextStyle( + color: Colors.black, + fontSize: 13.sp, + fontWeight: MyFontWeight.medium, + ), ), - SizedBox( - height: 2.h, + Text( + widget.productListBean?.shortName + ?? ((widget.shoppingCartSkuItemListBean?.skuName == "0") + ? "" : widget.shoppingCartSkuItemListBean?.skuName) ?? "", + overflow: TextOverflow.ellipsis, + maxLines: 2, + style: TextStyle( + color: Color(0xFF4C4C4C), + fontSize: 10.sp, + fontWeight: MyFontWeight.regular, + ), ), Row( children: [ - Expanded( - child: Text( - widget.productListBean?.shortName - ?? ((widget.shoppingCartSkuItemListBean?.skuName == "0") - ? "" : widget.shoppingCartSkuItemListBean?.skuName) ?? "", - overflow: TextOverflow.ellipsis, - maxLines: 2, - style: TextStyle( - color: Color(0xFF4C4C4C), - fontSize: 10.sp, - fontWeight: MyFontWeight.regular, - ), + Text( + "¥${price}", + style: TextStyle( + color: Color(0xFFFF7A1A), + fontSize: 16.sp, + fontFamily: 'JDZhengHT', + fontWeight: MyFontWeight.medium, ), ), - SizedBox( - width: 10, - ), - ], - ), - SizedBox( - height: 7.h, - ), - Row( - children: [ - Row( - children: [ - Text( - "¥${price}", - style: TextStyle( - color: Color(0xFFFF7A1A), - fontSize: 16.sp, - fontFamily: 'JDZhengHT', - fontWeight: MyFontWeight.medium, - ), - ), - SizedBox( - width: 2.w, - ), - // Container( - // width: 44.w, - // height: 18.h, - // decoration: BoxDecoration( - // color: Color(0xFFFF4500), - // borderRadius: BorderRadius.circular(2), - // ), - // alignment: Alignment.center, - // child: Text( - // "APP专享", - // style: TextStyle( - // color: Color(0xFFFFFFFF), - // fontSize: 10.sp, - // fontWeight: MyFontWeight.medium, - // ), - // ), - // ), - ], - ), Spacer(), if (!widget.isShopCart && (widget.productListBean?.attrStyle ?? 0) == 1) @@ -177,8 +118,7 @@ class _ShopGoodsCar extends State { radius: 3, backgroup: Color(0xFF32A060), fontSize: 11.sp, - padding: - EdgeInsets.symmetric(vertical: 5.h), + padding: EdgeInsets.symmetric(vertical: 5.h), callback: () { widget.queryMiNiDetail?.call(widget.productListBean?.id ?? widget.shoppingCartSkuItemListBean?.productId ?? "", 0); }, @@ -206,8 +146,7 @@ class _ShopGoodsCar extends State { (widget.productListBean?.attrStyle ?? 0) == 0) InkWell( onTap: () { - widget - .reduce(widget.shoppingCartSkuItemListBean); + widget.reduce(widget.shoppingCartSkuItemListBean); }, child: Image.asset( "assets/image/reduce.webp", @@ -243,9 +182,6 @@ class _ShopGoodsCar extends State { ), ], ), - SizedBox( - height: 4.h, - ), Text( "¥${applyPrice}", style: TextStyle( @@ -272,11 +208,9 @@ class _ShopGoodsCar extends State { return shopCarMealsItem(widget.shoppingCartSkuItemListBean!.setMealDataList![index]); }, ), - SizedBox( - height: 15.h, - ) ], - )); + ), + ); } Widget shopCarMealsItem(SetMealData setMealDataList) { diff --git a/lib/store/store_view/store_order_list.dart b/lib/store/store_view/store_order_list.dart index 3c985aaf..ef5e4879 100644 --- a/lib/store/store_view/store_order_list.dart +++ b/lib/store/store_view/store_order_list.dart @@ -1,11 +1,8 @@ import 'package:dio/dio.dart'; -import 'package:extended_nested_scroll_view/extended_nested_scroll_view.dart'; -import 'package:flutter/gestures.dart'; import 'package:flutter/material.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:flutter_smart_dialog/flutter_smart_dialog.dart'; import 'package:get/get.dart'; -import 'package:huixiang/constant.dart'; import 'package:huixiang/data/activity.dart'; import 'package:huixiang/data/base_list_data.dart'; import 'package:huixiang/data/find_mini_group.dart'; @@ -13,13 +10,12 @@ import 'package:huixiang/data/shopping_cart.dart'; import 'package:huixiang/data/store_info.dart'; import 'package:huixiang/retrofit/min_api.dart'; import 'package:huixiang/retrofit/retrofit_api.dart'; -import 'package:huixiang/store/shop/shop_scroll_controller.dart'; import 'package:huixiang/store/shop/shop_scroll_coordinator.dart'; import 'package:huixiang/store/store_view/shop_goods.dart'; -import 'package:huixiang/utils/flutter_utils.dart'; +import 'package:huixiang/utils/constant.dart'; import 'package:huixiang/utils/font_weight.dart'; import 'package:huixiang/view_widget/round_button.dart'; -import 'package:shared_preferences/shared_preferences.dart'; +import 'package:scrollview_observer/scrollview_observer.dart'; class StoreOrderListPage extends StatefulWidget { final Map? arguments; @@ -60,34 +56,73 @@ class _StoreOrderListPage extends State { late ApiService apiService; late MinApiService minService; List? appletProducts; - List productListBeans = []; int currentIndex = 0; late ShopScrollCoordinator _shopCoordinator; - late ShopScrollController _listScrollController1; - late ShopScrollController _listScrollController2; + late ListObserverController _listScrollController1; + late ListObserverController _listScrollController2; + + late Map? arguments; + late List? activitys; + late StoreInfo? storeInfo; + late ShopScrollCoordinator shopCoordinator; + late String? minToken; + late String tenant; + late int tableId; + late ScrollPhysics scrollPhysics; + late ShoppingCart? shopCarGoods; @override void initState() { + this.arguments = widget.arguments; + this.activitys = widget.activitys; + this.storeInfo = widget.storeInfo; + this.shopCoordinator = widget.shopCoordinator; + this.minToken = widget.minToken; + this.tenant = widget.tenant; + this.tableId = widget.tableId; + this.scrollPhysics = widget.scrollPhysics; super.initState(); _shopCoordinator = widget.shopCoordinator; - _listScrollController1 = _shopCoordinator.newChildScrollController(); - _listScrollController2 = _shopCoordinator.newChildScrollController(); - _listScrollController2.addListener(() { - for (int i = 0; i < (appletProducts?.length ?? 0); i++) { - if (currentIndex != i && _listScrollController2.offset >= (appletProducts?[i].goodsIndex ?? 0) && - (i == (appletProducts?.length ?? 0) - 1 || _listScrollController2.offset < (appletProducts?[i + 1].goodsIndex ?? 0))) { - setState(() { - currentIndex = i; - }); - break; - } - } - }); + _listScrollController1 = ListObserverController(controller: _shopCoordinator.newChildScrollController()); + _listScrollController2 = ListObserverController(controller: _shopCoordinator.newChildScrollController()); + appletGoods(); } + @override + void didUpdateWidget(oldWidget) { + super.didUpdateWidget(oldWidget); + if (oldWidget.arguments != widget.arguments) { + this.arguments = widget.arguments; + } + if (oldWidget.activitys != widget.activitys) { + this.activitys = widget.activitys; + } + if (oldWidget.storeInfo != widget.storeInfo) { + this.storeInfo = widget.storeInfo; + } + if (oldWidget.shopCoordinator != widget.shopCoordinator) { + this.shopCoordinator = widget.shopCoordinator; + } + if (oldWidget.minToken != widget.minToken) { + this.minToken = widget.minToken; + } + if (oldWidget.tenant != widget.tenant) { + this.tenant = widget.tenant; + } + if (oldWidget.tableId != widget.tableId) { + this.tableId = widget.tableId; + } + if (oldWidget.scrollPhysics != widget.scrollPhysics) { + this.scrollPhysics = widget.scrollPhysics; + } + if (oldWidget.shopCarGoods != widget.shopCarGoods) { + this.shopCarGoods = widget.shopCarGoods; + } + } + ///小程序查询分组及商品列表 appletGoods() async { minService = MinApiService( @@ -104,20 +139,10 @@ class _StoreOrderListPage extends State { }).catchError((error) { return BaseListData()..isSuccess = false; }); + SmartDialog.dismiss(status: SmartStatus.loading, force: true); if (baseData.isSuccess ?? false) { - // refreshController.refreshCompleted(); setState(() { appletProducts = baseData.data ?? []; - // productListBeans.clear(); - // if (appletProducts.length > 0) - // productListBeans.addAll(appletProducts[isSelected].productList); - int goodsIndex = 0; - appletProducts?.forEach((element) { - element.goodsIndex = goodsIndex; - element.height = - ((element.productList?.length ?? 0) * 120.h + 50.h).toInt(); - goodsIndex += (element.height ?? 0); - }); }); } } @@ -133,25 +158,38 @@ class _StoreOrderListPage extends State { children: [ Container( width: 100, - child: ListView.builder( - itemCount: appletProducts?.length ?? 0, - physics: ClampingScrollPhysics(), + child: ListViewObserver( controller: _listScrollController1, - padding: EdgeInsets.only(top: 0, bottom: 12.h), - itemBuilder: (context, position) { - return orderItem(position); - }, + child: ListView.builder( + itemCount: appletProducts?.length ?? 0, + physics: ClampingScrollPhysics(), + controller: _listScrollController1.controller, + padding: EdgeInsets.only(top: 0, bottom: 12.h), + itemBuilder: (context, position) { + return orderItem(position); + }, + ), ), ), Expanded( - child: ListView.builder( - itemCount: appletProducts?.length ?? 0, - padding: EdgeInsets.only(top: 0), + child: ListViewObserver( controller: _listScrollController2, - physics: ClampingScrollPhysics(), - itemBuilder: (context, position) { - return rightOrderItem(position); + onObserve: (result) { + if (result.firstChild?.index != null) { + setState(() { + currentIndex = result.firstChild!.index; + }); + } }, + child: ListView.builder( + itemCount: appletProducts?.length ?? 0, + padding: EdgeInsets.only(top: 0), + controller: _listScrollController2.controller, + physics: ClampingScrollPhysics(), + itemBuilder: (context, position) { + return rightOrderItem(position); + }, + ), ), ), ], @@ -159,7 +197,7 @@ class _StoreOrderListPage extends State { ); } - goShopDetailsPage(ProductListBean e) async { + Future goShopDetailsPage(ProductListBean e) async { await Navigator.of(context).pushNamed( '/router/shop_details_page', arguments: { @@ -174,15 +212,12 @@ class _StoreOrderListPage extends State { Widget orderItem(int index) { int count = calculateItemCount(appletProducts![index]); return Container( - width: 100.w, + width: 100, child: GestureDetector( onTap: () { + _listScrollController2.jumpTo(index: index); setState(() { - // isSelected = index; - // productListBeans.clear(); - // productListBeans.addAll(appletProducts[index].productList); - int aindex = appletProducts![index].goodsIndex ?? 0; - _listScrollController2.jumpTo(aindex.toDouble()); + currentIndex = index; }); }, child: Stack( @@ -191,8 +226,7 @@ class _StoreOrderListPage extends State { Container( color: currentIndex != index ? Color(0xFFFAFAFA) : Colors.white, alignment: Alignment.center, - padding: EdgeInsets.all(15), - // margin: EdgeInsets.only(bottom: (index==appletProducts.length - 1)?35.h:0), + padding: EdgeInsets.all(10), child: Row( mainAxisAlignment: MainAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.center, @@ -202,22 +236,23 @@ class _StoreOrderListPage extends State { width: 2, height: 17.h, color: Color(0xFF32A060), - margin: EdgeInsets.only(right: 10.w), + margin: EdgeInsets.only(right: 10), ), Expanded( - child: Text( - appletProducts![index].groupName ?? "", - textAlign: TextAlign.center, - style: TextStyle( - color: currentIndex != index - ? Color(0xFF4D4D4D) - : Color(0xFF000000), - fontSize: 12.sp, - fontWeight: currentIndex != index - ? MyFontWeight.medium - : MyFontWeight.semi_bold, + child: Text( + appletProducts![index].groupName ?? "", + textAlign: TextAlign.center, + style: TextStyle( + color: currentIndex != index + ? Color(0xFF4D4D4D) + : Color(0xFF000000), + fontSize: 12.sp, + fontWeight: currentIndex != index + ? MyFontWeight.medium + : MyFontWeight.semi_bold, + ), ), - )), + ), ], ), ), @@ -246,45 +281,37 @@ class _StoreOrderListPage extends State { Widget rightOrderItem(int rightIndex) { return Container( color: Colors.white, - // margin: EdgeInsets.only( - // bottom: (rightIndex == appletProducts!.length - 1) - // ? (_viewportDimension > (appletProducts![rightIndex].height ?? 0) - // ? _viewportDimension - - // (appletProducts![rightIndex].height ?? 0) - // : 30.h) - // : 0), + key: appletProducts![rightIndex].scrollControllerKey, child: Column( mainAxisAlignment: MainAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start, children: [ - SizedBox( - height: 50.h, - child: Padding( - padding: EdgeInsets.only(left: 16.w, top: 10.h, right: 12.w), - child: Text( - appletProducts![rightIndex].groupName ?? "", - textAlign: TextAlign.center, - style: TextStyle( - color: Color(0xFF000000), - fontSize: 12.sp, - fontWeight: MyFontWeight.semi_bold, - ), + Container( + alignment: Alignment.bottomLeft, + padding: EdgeInsets.all(10), + child: Text( + appletProducts![rightIndex].groupName ?? "", + textAlign: TextAlign.center, + style: TextStyle( + color: Color(0xFF000000), + fontSize: 12.sp, + fontWeight: MyFontWeight.semi_bold, ), ), ), Column( - children: appletProducts![rightIndex].productList?.map((e) { - return GestureDetector( - onTap: () { - if (widget.storeInfo?.posType?.code == "NORMALSTORE") - return; - else - goShopDetailsPage(e); - }, - child: goodsItem(e), - ); - }).toList() ?? - [], + children: (appletProducts![rightIndex].productList?.map((e) { + return GestureDetector( + onTap: () { + if (widget.storeInfo?.posType?.code == "NORMALSTORE") { + return; + } + goShopDetailsPage(e); + }, + child: goodsItem(e), + ); + }).toList() ?? + [])..add(12.d), ), ], ), @@ -308,7 +335,12 @@ class _StoreOrderListPage extends State { int count = 0; widget.shopCarGoods?.shoppingCartSkuItemList?.forEach((element) { if (e.id == element.productId) { - count += (element.buyNum ?? 0); + if (shoppingCartSkuItemListBean == null) { + shoppingCartSkuItemListBean = element; + count = (shoppingCartSkuItemListBean?.buyNum ?? 0); + } else { + count += (element.buyNum ?? 0); + } } }); return ShopGoods( @@ -331,8 +363,8 @@ class _StoreOrderListPage extends State { @override void dispose() { - _listScrollController1.dispose(); - _listScrollController2.dispose(); + _listScrollController1.controller?.dispose(); + _listScrollController2.controller?.dispose(); super.dispose(); } diff --git a/lib/union/union_list.dart b/lib/union/union_list.dart index 91d94743..7251dd5b 100644 --- a/lib/union/union_list.dart +++ b/lib/union/union_list.dart @@ -1,5 +1,4 @@ import 'package:dio/dio.dart'; -import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:flutter_smart_dialog/flutter_smart_dialog.dart'; @@ -18,7 +17,6 @@ import 'package:huixiang/view_widget/custom_image.dart'; import 'package:permission_handler/permission_handler.dart'; import 'package:pull_to_refresh/pull_to_refresh.dart'; import 'package:shimmer/shimmer.dart'; -import 'package:visibility_detector/visibility_detector.dart'; import '../data/product_show.dart'; import '../retrofit/retrofit_api.dart'; @@ -42,8 +40,7 @@ class UnionList extends StatefulWidget { } } -class UnionListState extends State - with AutomaticKeepAliveClientMixin { +class UnionListState extends State with AutomaticKeepAliveClientMixin { ApiService? apiService; List? storeList; Position? latLng; @@ -65,7 +62,8 @@ class UnionListState extends State getLocation(); } - getLocation() async { + Future getLocation() async { + S.current.zhengzaijiazai.toast; try { powerFlag = await LocationInstance.instance.startLocation(context, (Position? result) async { @@ -90,14 +88,14 @@ class UnionListState extends State } else { await getLatLng(); } - queryStore(); + await queryStore(); }); } finally { if (!powerFlag) { if (await Permission.locationWhenInUse.status.isGranted) { - getLocation(); + await getLocation(); } else { - queryStore(); + await queryStore(); } } } @@ -131,12 +129,12 @@ class UnionListState extends State } } - void refreshData(String areaName) { + Future refreshData(String areaName) async { this.cityName = areaName; - getLocation(); + await getLocation(); } - queryStore() async { + Future queryStore() async { apiService ??= ApiService( Dio(), context: context, @@ -154,6 +152,7 @@ class UnionListState extends State _refreshController.refreshFailed(); return BaseListData()..isSuccess = false; }); + SmartDialog.dismiss(status: SmartStatus.loading, force: true); if (baseData?.isSuccess ?? false) { storeList = baseData!.data; _refreshController.refreshCompleted(); @@ -642,7 +641,7 @@ class UnionListState extends State ), ), TextSpan( - text: "${(productShow?.price ?? "").split(".")[0]}", + text: "${(productShow.price ?? "").split(".")[0]}", style: TextStyle( fontWeight: FontWeight.bold, fontSize: 16.sp, diff --git a/lib/union/union_page.dart b/lib/union/union_page.dart index 7a08085e..f2118bd0 100644 --- a/lib/union/union_page.dart +++ b/lib/union/union_page.dart @@ -96,7 +96,8 @@ class UnionPageState extends State with AutomaticKeepAliveClientMixin } queryIpInfo() async { - ApiService apiIpService = ApiService(Dio(), context: context, showLoading: false); + S.current.zhengzaijiazai.toast; + ApiService apiIpService = ApiService(Dio(), context: context); String ipResult = await apiIpService.getIpInfo1().catchError((onError) { return ""; }); @@ -109,10 +110,10 @@ class UnionPageState extends State with AutomaticKeepAliveClientMixin } } - refreshChild() { + refreshChild() async { if (areaName?.isNotEmpty ?? false) { - _allKey.forEach((key1) { - key1.currentState?.refreshData(areaName!); + await Future.forEach(_allKey, (key1) async { + await key1.currentState?.refreshData(areaName!); }); } } diff --git a/lib/utils/flutter_utils.dart b/lib/utils/flutter_utils.dart index 063f63e6..61cd06ff 100644 --- a/lib/utils/flutter_utils.dart +++ b/lib/utils/flutter_utils.dart @@ -4,21 +4,11 @@ import 'dart:io'; import 'package:dio/dio.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter_smart_dialog/flutter_smart_dialog.dart'; -import 'package:huixiang/constant.dart'; import 'package:intl/intl.dart'; import 'package:path_provider/path_provider.dart'; + class AppUtils { - // ///计算距离(当前位置到店位置直线距离) - // static Future calculateDistance( - // BMFCoordinate bmfCoordinate, BMFCoordinate myLatLng, {bool isMi = false}) async { - // double? mi = await BMFCalculateUtils.getLocationDistance(bmfCoordinate, myLatLng); - // if (mi == null) { - // return "0"; - // } - // NumberFormat numberFormat = NumberFormat("#.#"); - // return "${numberFormat.format(mi! / (isMi ? 1 :1000))}"; - // } ///保留两位小数 static double stringAsFixedDouble2(double value) { @@ -82,14 +72,6 @@ class AppUtils { return resString; } - // ///坐标系转换(高德转百度) - // static Future coordConvert(BMFCoordinate latLng) async { - // // return BMFCalculateUtils.coordConvert( - // // coordinate: latLng, - // // fromType: BMF_COORD_TYPE.COMMON, - // // toType: BMF_COORD_TYPE.BD09LL); - // } - static bool isPhone(mobile) { RegExp exp = RegExp( r'^((13[0-9])|(14[0-9])|(15[0-9])|(16[0-9])|(17[0-9])|(18[0-9])|(19[0-9]))\d{8}$'); @@ -352,23 +334,4 @@ class AppUtils { } } - - static List loadingPaths = []; - - static void addLoadingPath(String path) { - loadingPaths.add(path); - } - - static void removeLoadingPath(String path) { - loadingPaths.remove(path); - if (loadingPaths.isEmpty) { - SmartDialog.dismiss(status: SmartStatus.loading, force: true); - } - } - - static void cleanLoadingPath() { - loadingPaths.clear(); - SmartDialog.dismiss(status: SmartStatus.loading, force: true); - } - } diff --git a/pubspec.lock b/pubspec.lock index a4cef059..a38722f1 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -1141,6 +1141,14 @@ packages: url: "https://pub.dev" source: hosted version: "1.5.1" + preload_page_view: + dependency: "direct main" + description: + name: preload_page_view + sha256: "488a10c158c5c2e9ba9d77e5dbc09b1e49e37a20df2301e5ba02992eac802b7a" + url: "https://pub.dev" + source: hosted + version: "0.2.0" protobuf: dependency: "direct main" description: @@ -1269,6 +1277,14 @@ packages: url: "https://pub.dev" source: hosted version: "1.6.0" + scrollview_observer: + dependency: "direct main" + description: + name: scrollview_observer + sha256: d607bc97165113b4ce6aa860a3865cfa6b849445a48c216461d74bc96be6cb94 + url: "https://pub.dev" + source: hosted + version: "1.24.0" shared_preferences: dependency: "direct main" description: diff --git a/pubspec.yaml b/pubspec.yaml index 6326a43e..521dfe97 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -147,6 +147,8 @@ dependencies: protobuf: ^3.1.0 color_thief_dart: ^0.1.0 + scrollview_observer: ^1.24.0 + preload_page_view: ^0.2.0 dev_dependencies: flutter_test: