Browse Source

主页面修改,多页面预加载。消息已读修改。UI调整

dart3_last
fff 2 weeks ago
parent
commit
195d99033a
  1. 4
      lib/constant.dart
  2. 4
      lib/data/find_mini_group.dart
  3. 7
      lib/im/chat_details_page.dart
  4. 7
      lib/im/im_view/im_page.dart
  5. 14
      lib/main_page.dart
  6. 4
      lib/message/system_details.dart
  7. 2
      lib/message/system_notice.dart
  8. 4
      lib/mine/mine_shop_page.dart
  9. 1
      lib/order/exchange_history_page.dart
  10. 23
      lib/order/invoices_manage/invoices_detail_page.dart
  11. 2
      lib/order/invoices_manage/invoices_history.dart
  12. 1
      lib/order/invoices_manage/invoices_manage_page.dart
  13. 3
      lib/order/invoices_manage/invoices_title_info.dart
  14. 1
      lib/order/order_detail_page.dart
  15. 1
      lib/order/order_history_page.dart
  16. 24
      lib/order/order_view/order_address.dart
  17. 6
      lib/order/order_view/order_commodity.dart
  18. 57
      lib/retrofit/min_api.dart
  19. 83
      lib/retrofit/retrofit_api.dart
  20. 1
      lib/settlement/settlement.dart
  21. 161
      lib/store/shop_details_page.dart
  22. 74
      lib/store/store_order.dart
  23. 1
      lib/store/store_view/people_num.dart
  24. 4
      lib/store/store_view/product_sku.dart
  25. 3
      lib/store/store_view/shop_car.dart
  26. 204
      lib/store/store_view/shop_goods.dart
  27. 82
      lib/store/store_view/shop_goods_car.dart
  28. 158
      lib/store/store_view/store_order_list.dart
  29. 23
      lib/union/union_list.dart
  30. 9
      lib/union/union_page.dart
  31. 39
      lib/utils/flutter_utils.dart
  32. 16
      pubspec.lock
  33. 2
      pubspec.yaml

4
lib/constant.dart

@ -99,14 +99,18 @@ extension StrExtension<S, T> on String {
SmartNonAnimationType.continueKeepSingle, SmartNonAnimationType.continueKeepSingle,
], ],
); );
void get loading => SmartDialog.showLoading( void get loading => SmartDialog.showLoading(
msg: this, msg: this,
displayTime: 25000.milliseconds, displayTime: 25000.milliseconds,
animationType: SmartAnimationType.fade,
nonAnimationTypes: [ nonAnimationTypes: [
SmartNonAnimationType.continueLoading_nonAnimation, SmartNonAnimationType.continueLoading_nonAnimation,
SmartNonAnimationType.continueKeepSingle, SmartNonAnimationType.continueKeepSingle,
], ],
); );
void get loadingDismiss => SmartDialog.dismiss(status: SmartStatus.loading, force: true);
void get print => debugPrint(this); void get print => debugPrint(this);
} }

4
lib/data/find_mini_group.dart

@ -1,3 +1,4 @@
import 'package:flutter/material.dart';
import 'package:huixiang/data/subscribe_param.dart'; import 'package:huixiang/data/subscribe_param.dart';
import 'package:json_annotation/json_annotation.dart'; import 'package:json_annotation/json_annotation.dart';
@ -15,6 +16,9 @@ class FindMiniGroup {
List<ProductListBean>? productList = []; List<ProductListBean>? productList = [];
dynamic productPageVO; dynamic productPageVO;
@JsonKey(includeFromJson: false, includeToJson: false)
GlobalKey scrollControllerKey = GlobalKey();
FindMiniGroup(); FindMiniGroup();
factory FindMiniGroup.fromJson(Map<String, dynamic> json) => _$FindMiniGroupFromJson(json); factory FindMiniGroup.fromJson(Map<String, dynamic> json) => _$FindMiniGroupFromJson(json);

7
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/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/widgets.dart';
import 'package:flutter_keyboard_visibility/flutter_keyboard_visibility.dart'; import 'package:flutter_keyboard_visibility/flutter_keyboard_visibility.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:flutter_smart_dialog/flutter_smart_dialog.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/constant.dart';
import 'package:huixiang/data/base_data.dart'; import 'package:huixiang/data/base_data.dart';
import 'package:huixiang/data/im_user.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/user_info.dart';
import 'package:huixiang/data/message.dart' as msg;
import 'package:huixiang/im/database/message.dart'; import 'package:huixiang/im/database/message.dart';
import 'package:huixiang/im/out/message.pb.dart'; import 'package:huixiang/im/out/message.pb.dart';
import 'package:huixiang/main.dart'; import 'package:huixiang/main.dart';
@ -822,8 +823,8 @@ class _ChatDetailsPage extends State<ChatDetailsPage>
textAlign: TextAlign.left, textAlign: TextAlign.left,
style: TextStyle( style: TextStyle(
color: Colors.white, color: Colors.white,
fontSize: 17.sp, fontSize: 10.sp,
fontWeight: MyFontWeight.regular, fontWeight: MyFontWeight.black,
), ),
), ),
), ),

7
lib/im/im_view/im_page.dart

@ -332,7 +332,9 @@ class _IMPage extends State<IMPage> implements OnChatMessage {
behavior: HitTestBehavior.opaque, behavior: HitTestBehavior.opaque,
onTap: () { onTap: () {
Navigator.of(context) Navigator.of(context)
.pushNamed('/router/system_notice') .pushNamed(
'/router/system_notice',
)
.then((value) { .then((value) {
setState(() { setState(() {
msgNumber["2"] = 0; msgNumber["2"] = 0;
@ -380,7 +382,8 @@ class _IMPage extends State<IMPage> implements OnChatMessage {
onTap: () { onTap: () {
Navigator.of(context).pushNamed( Navigator.of(context).pushNamed(
'/router/system_details', '/router/system_details',
arguments: {"msgType": 5}).then((value) { arguments: {"msgType": 5},
).then((value) {
setState(() { setState(() {
msgNumber["5"] = 0; msgNumber["5"] = 0;
}); });

14
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:huixiang/view_widget/update_dialog.dart';
import 'package:package_info_plus/package_info_plus.dart'; import 'package:package_info_plus/package_info_plus.dart';
import 'package:permission_handler/permission_handler.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_interface.dart';
import 'package:sharesdk_plugin/sharesdk_register.dart'; import 'package:sharesdk_plugin/sharesdk_register.dart';
import 'package:tpns_flutter_plugin/android/xg_android_api.dart'; import 'package:tpns_flutter_plugin/android/xg_android_api.dart';
@ -107,7 +108,7 @@ class _MainPage extends State<MainPage> with WidgetsBindingObserver {
initDatabase(userId); initDatabase(userId);
connectSocket(); connectSocket();
pageController = PageController( pageController = PreloadPageController(
initialPage: initialPage:
widget.arguments != null && widget.arguments?["index"] != null widget.arguments != null && widget.arguments?["index"] != null
? widget.arguments!["index"] ? widget.arguments!["index"]
@ -468,23 +469,24 @@ class _MainPage extends State<MainPage> with WidgetsBindingObserver {
} }
} }
late PageController pageController; late PreloadPageController pageController;
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Scaffold( return Scaffold(
resizeToAvoidBottomInset: false, resizeToAvoidBottomInset: false,
body: Container( body: PreloadPageView.builder(
child: PageView(
controller: pageController, controller: pageController,
children: _widgetOptions, itemBuilder: (context, index) {
return _widgetOptions[index];
},
itemCount: _widgetOptions.length,
physics: NeverScrollableScrollPhysics(), physics: NeverScrollableScrollPhysics(),
onPageChanged: (index) { onPageChanged: (index) {
clickIndex = index; clickIndex = index;
setState(() {}); setState(() {});
}, },
), ),
),
extendBody: true, extendBody: true,
bottomNavigationBar: Container( bottomNavigationBar: Container(
alignment: Platform.isAndroid ? Alignment.center : Alignment.topCenter, alignment: Platform.isAndroid ? Alignment.center : Alignment.topCenter,

4
lib/message/system_details.dart

@ -70,7 +70,7 @@ class _SystemDetails extends State<SystemDetails> {
"pageSize": 10, "pageSize": 10,
"searchKey": "", "searchKey": "",
"state": "", "state": "",
"typed": msgType "typed": "$msgType"
}).catchError((onError) { }).catchError((onError) {
_refreshController.loadFailed(); _refreshController.loadFailed();
_refreshController.refreshFailed(); _refreshController.refreshFailed();
@ -947,6 +947,7 @@ class _SystemDetails extends State<SystemDetails> {
} }
Widget followMessageItem(Message message) { Widget followMessageItem(Message message) {
if (message.relational?.isNotEmpty ?? false) {
var messageRelational = jsonDecode(message.relational ?? ""); var messageRelational = jsonDecode(message.relational ?? "");
if (message.relational?.startsWith("{") ?? false) { if (message.relational?.startsWith("{") ?? false) {
return Container( return Container(
@ -1103,6 +1104,7 @@ class _SystemDetails extends State<SystemDetails> {
), ),
); );
} }
}
return Container(); return Container();
} }

2
lib/message/system_notice.dart

@ -55,7 +55,7 @@ class _SystemNotice extends State<SystemNotice> {
"pageSize": 10, "pageSize": 10,
"searchKey": "", "searchKey": "",
"state": "", "state": "",
"typed": "" "typed": "2,3"
}).catchError((onError) { }).catchError((onError) {
_refreshController.loadFailed(); _refreshController.loadFailed();
_refreshController.refreshFailed(); _refreshController.refreshFailed();

4
lib/mine/mine_shop_page.dart

@ -3,6 +3,7 @@ import 'dart:async';
import 'package:dio/dio.dart'; import 'package:dio/dio.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.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/constant.dart';
import 'package:huixiang/data/base_list_data.dart'; import 'package:huixiang/data/base_list_data.dart';
import 'package:huixiang/data/vip_card.dart'; import 'package:huixiang/data/vip_card.dart';
@ -85,7 +86,6 @@ class _MineShopPage extends State<MineShopPage> with WidgetsBindingObserver {
queryVipCard({bool showLoading = true}) async { queryVipCard({bool showLoading = true}) async {
try { try {
if (showLoading) { if (showLoading) {
AppUtils.addLoadingPath("loadShopColors");
S.current.zhengzaijiazai.loading; S.current.zhengzaijiazai.loading;
} }
BaseListData<VipCard>? baseData = await apiService?.vipList({ BaseListData<VipCard>? baseData = await apiService?.vipList({
@ -105,7 +105,7 @@ class _MineShopPage extends State<MineShopPage> with WidgetsBindingObserver {
refreshController.refreshFailed(); refreshController.refreshFailed();
} }
} finally { } finally {
AppUtils.cleanLoadingPath(); SmartDialog.dismiss(status: SmartStatus.loading, force: true);
setState(() {}); setState(() {});
} }
} }

1
lib/order/exchange_history_page.dart

@ -182,6 +182,7 @@ class _ExchangeHistoryList extends State<ExchangeHistoryList>
_refreshController.loadFailed(); _refreshController.loadFailed();
} }
} finally { } finally {
SmartDialog.dismiss(status: SmartStatus.loading, force: true);
setState(() {}); setState(() {});
} }
} }

23
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/rendering.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';
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/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/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:path_provider/path_provider.dart';
import 'package:pull_to_refresh/pull_to_refresh.dart'; import 'package:pull_to_refresh/pull_to_refresh.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'package:shimmer/shimmer.dart'; import 'package:shimmer/shimmer.dart';
import 'package:url_launcher/url_launcher.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 { class InvoicesDetailPage extends StatefulWidget {
final Map<String, dynamic>? arguments; final Map<String, dynamic>? arguments;
@ -776,7 +774,8 @@ class _InvoicesDetailPage extends State<InvoicesDetailPage> {
style: TextStyle( style: TextStyle(
fontSize: 14.sp, fontSize: 14.sp,
color: Color(0xFF0D0D0D), color: Color(0xFF0D0D0D),
fontWeight: MyFontWeight.bold), fontWeight: MyFontWeight.bold,
),
), ),
Padding( Padding(
padding: EdgeInsets.symmetric(vertical: 10.h), padding: EdgeInsets.symmetric(vertical: 10.h),

2
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/my_footer.dart';
import 'package:huixiang/view_widget/no_data_view.dart'; import 'package:huixiang/view_widget/no_data_view.dart';
import 'package:pull_to_refresh/pull_to_refresh.dart'; import 'package:pull_to_refresh/pull_to_refresh.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'package:shimmer/shimmer.dart'; import 'package:shimmer/shimmer.dart';
@ -67,6 +66,7 @@ class _InvoicesHistory extends State<InvoicesHistory> {
refreshController.loadFailed(); refreshController.loadFailed();
return BaseData<InvoicesHistoryList>()..isSuccess = false; return BaseData<InvoicesHistoryList>()..isSuccess = false;
}); });
SmartDialog.dismiss(status: SmartStatus.loading, force: true);
if (!mounted) return; if (!mounted) return;
if (baseData?.isSuccess ?? false) { if (baseData?.isSuccess ?? false) {
records.addAll(baseData?.data?.records ?? []); records.addAll(baseData?.data?.records ?? []);

1
lib/order/invoices_manage/invoices_manage_page.dart

@ -67,6 +67,7 @@ class _InvoicesManagePage extends State<InvoicesManagePage> {
refreshController.loadFailed(); refreshController.loadFailed();
return BaseData<InvoiceList>()..isSuccess = false; return BaseData<InvoiceList>()..isSuccess = false;
}); });
SmartDialog.dismiss(status: SmartStatus.loading, force: true);
if (!mounted) return; if (!mounted) return;
if (baseData?.isSuccess ?? false) { if (baseData?.isSuccess ?? false) {
records.addAll(baseData?.data?.records ?? []); records.addAll(baseData?.data?.records ?? []);

3
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/constant.dart';
import 'package:huixiang/utils/shared_preference.dart'; import 'package:huixiang/utils/shared_preference.dart';
import 'package:pull_to_refresh/pull_to_refresh.dart'; import 'package:pull_to_refresh/pull_to_refresh.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'package:shimmer/shimmer.dart'; import 'package:shimmer/shimmer.dart';
import '../../data/base_data.dart'; import '../../data/base_data.dart';
@ -84,6 +84,7 @@ class _InvoicesTitleInfo extends State<InvoicesTitleInfo> {
refreshController.loadFailed(); refreshController.loadFailed();
return BaseData<TitleInfoList>()..isSuccess = false; return BaseData<TitleInfoList>()..isSuccess = false;
}); });
SmartDialog.dismiss(status: SmartStatus.loading, force: true);
if (!mounted) return; if (!mounted) return;
if (baseData?.isSuccess ?? false) { if (baseData?.isSuccess ?? false) {
records.addAll(baseData?.data?.records ?? []); records.addAll(baseData?.data?.records ?? []);

1
lib/order/order_detail_page.dart

@ -133,6 +133,7 @@ class _OrderDetailPage extends State<OrderDetailPage> {
refreshController.refreshFailed(); refreshController.refreshFailed();
refreshController.loadFailed(); refreshController.loadFailed();
} }
SmartDialog.dismiss(status: SmartStatus.loading, force: true);
} }
@override @override

1
lib/order/order_history_page.dart

@ -198,6 +198,7 @@ class _OrderHistoryList extends State<OrderHistoryList>
refreshController.refreshFailed(); refreshController.refreshFailed();
refreshController.loadFailed(); refreshController.loadFailed();
} }
SmartDialog.dismiss(status: SmartStatus.loading, force: true);
} }
minLogin(OrderInfo orderInfo) { minLogin(OrderInfo orderInfo) {

24
lib/order/order_view/order_address.dart

@ -50,7 +50,9 @@ class _OrderAddress extends State<OrderAddress> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Container( 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), padding: EdgeInsets.all(20),
decoration: BoxDecoration( decoration: BoxDecoration(
color: Colors.white, color: Colors.white,
@ -76,27 +78,21 @@ class _OrderAddress extends State<OrderAddress> {
width: 24.w, width: 24.w,
height: 24.h, height: 24.h,
), ),
Text( Expanded(
(widget.orderInfo?.addressExt != null) child: Text(
? ((widget.isTakeOut == 0 || (widget.orderInfo?.addressExt != null) ? ((widget.isTakeOut == 0 || widget.isTakeOut == 3 || widget.isTakeOut == 4 ? widget.orderInfo?.storeName : widget.orderInfo?.addressExt?.recName) ?? "") : "",
widget.isTakeOut == 3 ||
widget.isTakeOut == 4
? widget.orderInfo?.storeName
: widget.orderInfo?.addressExt?.recName) ??
"")
: "",
overflow: TextOverflow.ellipsis, overflow: TextOverflow.ellipsis,
style: TextStyle( style: TextStyle(
fontSize: 15.sp, fontSize: 15.sp,
color: Color(0xFF4C4C4C), color: Color(0xFF4C4C4C),
fontWeight: MyFontWeight.medium, fontWeight: MyFontWeight.medium,
), ),
)
), ),
SizedBox( SizedBox(
width: 7.w, width: 7.w,
), ),
Expanded( Text(
child: Text(
widget.orderInfo?.addressExt?.recMobile ?? "", widget.orderInfo?.addressExt?.recMobile ?? "",
overflow: TextOverflow.ellipsis, overflow: TextOverflow.ellipsis,
style: TextStyle( style: TextStyle(
@ -105,7 +101,6 @@ class _OrderAddress extends State<OrderAddress> {
fontWeight: MyFontWeight.medium, fontWeight: MyFontWeight.medium,
), ),
), ),
),
], ],
), ),
Container( Container(
@ -153,8 +148,7 @@ class _OrderAddress extends State<OrderAddress> {
S.of(context).zhidianmendian, S.of(context).zhidianmendian,
(open) { (open) {
if (open) { if (open) {
String? mobile = String? mobile = widget.orderInfo?.storeVO?.mobile;
widget.orderInfo?.storeVO?.mobile;
if (mobile?.isNotEmpty ?? false) { if (mobile?.isNotEmpty ?? false) {
callMobile(mobile); callMobile(mobile);
} }

6
lib/order/order_view/order_commodity.dart

@ -107,13 +107,13 @@ class _OrderCommodity extends State<OrderCommodity> {
} }
// //
if ((widget.orderInfo?.orderDetail?.couponDTO?.money ??"0") != "0") { if ((widget.orderInfo?.orderDetail?.couponDTO?["money"] ?? "0") != "0") {
widgets.add( widgets.add(
discountItem( discountItem(
Color(0xFFFF7A1A), Color(0xFFFF7A1A),
S.of(context).youhuiquan, S.of(context).youhuiquan,
widget.orderInfo?.orderDetail?.couponDTO?.name ??"", widget.orderInfo?.orderDetail?.couponDTO?["name"] ??"",
widget.orderInfo?.orderDetail?.couponDTO?.money ??"0", widget.orderInfo?.orderDetail?.couponDTO?["money"] ??"0",
), ),
); );
} }

57
lib/retrofit/min_api.dart

@ -63,40 +63,27 @@ abstract class MinApiService {
headers: headers, headers: headers,
responseType: ResponseType.json, 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( dio.interceptors.add(
InterceptorsWrapper(onRequest: (RequestOptions options, RequestInterceptorHandler handler) { 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; 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}");
handler.next(options); handler.next(options);
}, onResponse: (r.Response response, ResponseInterceptorHandler handler) { }, 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; Map map = response.data;
if (map["code"] == 40005 || map["code"] == 40001) { if (map["code"] == 40005 || map["code"] == 40001) {
LoginTipsDialog.instance.show(context); LoginTipsDialog.instance.show(context);
} }
debugPrint("======================= Min_响应数据结束 =======================\n");
if (map["code"] == 0) { if (map["code"] == 0) {
handler.next(response); handler.next(response);
} else { } else {
@ -108,20 +95,16 @@ abstract class MinApiService {
); );
} }
}, onError: (DioException e, ErrorInterceptorHandler handler) { }, onError: (DioException e, ErrorInterceptorHandler handler) {
debugPrint("errorLogger:${e.toString()}");
if (SmartDialog.checkExist(dialogTypes: {SmartAllDialogType.loading})) { if (SmartDialog.checkExist(dialogTypes: {SmartAllDialogType.loading})) {
AppUtils.removeLoadingPath(e.requestOptions.path); SmartDialog.dismiss(status: SmartStatus.loading, force: true);
} else {
AppUtils.cleanLoadingPath();
} }
if (e.type == DioExceptionType.unknown) { if (e.type == DioExceptionType.unknown) {
if (e.message?.isNotEmpty ?? false) { if (e.message?.isNotEmpty ?? false) {
e.message!.toast; e.message!.toast;
} }
} }
debugPrint("\n======================= Min_错误响应数据 =======================");
debugPrint("type = ${e.type}");
debugPrint("message = ${e.message}");
debugPrint("\n");
handler.next(e); handler.next(e);
}), }),
); );
@ -132,16 +115,6 @@ abstract class MinApiService {
return _MinApiService(dio, baseUrl: baseUrl, errorLogger: errorLogger); 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") @GET("/member/info")
Future<BaseData> memberInfo(); Future<BaseData> memberInfo();

83
lib/retrofit/retrofit_api.dart

@ -1,4 +1,3 @@
import 'dart:convert';
import 'dart:io'; import 'dart:io';
import 'package:dio/dio.dart'; 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/vip_rule_details.dart';
import 'package:huixiang/data/wx_pay.dart'; import 'package:huixiang/data/wx_pay.dart';
import 'package:huixiang/generated/l10n.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:huixiang/view_widget/login_tips_dialog.dart';
import 'package:retrofit/retrofit.dart'; import 'package:retrofit/retrofit.dart';
@ -97,36 +95,24 @@ abstract class ApiService {
responseType: ResponseType.json, 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) { if (dio.interceptors.length <= 1) {
dio.interceptors.add( dio.interceptors.add(
InterceptorsWrapper(onRequest: (RequestOptions options, RequestInterceptorHandler handler) { 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; 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) {}
handler.next(options); handler.next(options);
}, onResponse: (Response response, ResponseInterceptorHandler handler) { }, 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) { if (response.data is Map) {
Map map = response.data; Map map = response.data;
if (map["code"] == 40005 || map["code"] == 40001) { if (map["code"] == 40005 || map["code"] == 40001) {
@ -134,7 +120,7 @@ abstract class ApiService {
LoginTipsDialog.instance.show(context); LoginTipsDialog.instance.show(context);
} }
} }
debugPrint("======================= 响应数据结束 =======================\n");
if (map["code"] == 0 || map["code"] == 200 || map["repCode"] == "0000" || map["infocode"] == "10000") { if (map["code"] == 0 || map["code"] == 200 || map["repCode"] == "0000" || map["infocode"] == "10000") {
handler.next(response); handler.next(response);
} else { } else {
@ -149,20 +135,17 @@ abstract class ApiService {
handler.next(response); handler.next(response);
} }
}, onError: (DioException e, ErrorInterceptorHandler handler) { }, onError: (DioException e, ErrorInterceptorHandler handler) {
debugPrint("errorLogger:${e.toString()}");
if (SmartDialog.checkExist(dialogTypes: {SmartAllDialogType.loading})) { if (SmartDialog.checkExist(dialogTypes: {SmartAllDialogType.loading})) {
AppUtils.removeLoadingPath(e.requestOptions.path); SmartDialog.dismiss(status: SmartStatus.loading, force: true);
} else {
AppUtils.cleanLoadingPath();
} }
if (e.type == DioExceptionType.unknown) { if (e.type == DioExceptionType.unknown) {
if (e.message?.isNotEmpty ?? false) { if (e.message?.isNotEmpty ?? false) {
e.message!.toast; e.message!.toast;
} }
} }
debugPrint("\n======================= 错误响应数据 =======================");
debugPrint("type = ${e.type}");
debugPrint("message = ${e.message}");
debugPrint("\n");
handler.next(e); handler.next(e);
}), }),
); );
@ -171,35 +154,18 @@ abstract class ApiService {
return _ApiService(dio, baseUrl: baseUrl, errorLogger: errorLogger); return _ApiService(dio, baseUrl: baseUrl, errorLogger: errorLogger);
} }
static void p(String msg) {
//String的length是字符数量不是字节数量所以为了防止中文字符过多
// 4*1024MAX字节打印长度改为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") @POST("/file/upload")
@MultiPart() @MultiPart()
Future<BaseData<UploadResult>> upload(@Part(name: "file") File data, Future<BaseData<UploadResult>> upload(@Part(name: "file") File data, @Part(name: "folderId") int folderId, bool isVideo);
@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") @GET("https://restapi.amap.com/v3/place/around?key=542b46afa8e4b88fe1eb3c4d0ba0872f&location={lng},{lat}&keywords={keywords}&offset={size}&page={page}&extensions=all")
Future<dynamic> searchPoi(@Path("lat") String lat, @Path("lng") String lng, Future<dynamic> searchPoi(@Path("lat") String lat, @Path("lng") String lng, @Path("keywords") String keywords, int size, int page);
@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") @GET("https://restapi.amap.com/v3/geocode/regeo?key=542b46afa8e4b88fe1eb3c4d0ba0872f&location={lng},{lat}&extensions=base&output=json")
Future<dynamic> geocodeRegeo( Future<dynamic> geocodeRegeo(@Path("lat") String lat, @Path("lng") String lng);
@Path("lat") String lat, @Path("lng") String lng);
/// ///
@POST("/auth/platform/memberLogin") @POST("/auth/platform/memberLogin")
@ -215,13 +181,11 @@ abstract class ApiService {
/// ///
@POST("/creditGoods/list") @POST("/creditGoods/list")
Future<BaseData<PageInfo<Goods>>> creditGoods( Future<BaseData<PageInfo<Goods>>> creditGoods(@Body() Map<String, dynamic> param);
@Body() Map<String, dynamic> param);
/// ///
@POST("/creditGoodsCategory/page") @POST("/creditGoodsCategory/page")
Future<BaseData<PageInfo<GoodsCategory>>> goodsCategory( Future<BaseData<PageInfo<GoodsCategory>>> goodsCategory(@Body() Map<String, dynamic> param);
@Body() Map<String, dynamic> param);
/// ///
@GET("/creditGoods/{id}") @GET("/creditGoods/{id}")
@ -249,8 +213,7 @@ abstract class ApiService {
/// ///
@GET("/wallet/rechargeActList?tenantCode={tenantCode}") @GET("/wallet/rechargeActList?tenantCode={tenantCode}")
Future<BaseData<RechargeAct>> rechargeActList( Future<BaseData<RechargeAct>> rechargeActList(@Path("tenantCode") String tenantCode);
@Path("tenantCode") String tenantCode);
/// ///
@GET("/coupon/receive?couponId={couponId}") @GET("/coupon/receive?couponId={couponId}")

1
lib/settlement/settlement.dart

@ -298,6 +298,7 @@ class _Settlement extends State<Settlement> {
} }
} }
} finally { } finally {
SmartDialog.dismiss(status: SmartStatus.loading, force: true);
setState(() {}); setState(() {});
} }
} }

161
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/people_num.dart';
import 'package:huixiang/store/store_view/shop_car.dart'; import 'package:huixiang/store/store_view/shop_car.dart';
import 'package:huixiang/utils/app_util.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/font_weight.dart';
import 'package:huixiang/utils/shared_preference.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/classic_header.dart';
import 'package:huixiang/view_widget/custom_image.dart'; import 'package:huixiang/view_widget/custom_image.dart';
import 'package:huixiang/view_widget/my_footer.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:huixiang/view_widget/round_button.dart';
import 'package:permission_handler/permission_handler.dart'; import 'package:permission_handler/permission_handler.dart';
import 'package:pull_to_refresh/pull_to_refresh.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 { class ShopDetailsPage extends StatefulWidget {
final Map<String, dynamic>? arguments; final Map<String, dynamic>? arguments;
@ -76,22 +77,7 @@ class _ShopDetailsPage extends State<ShopDetailsPage> {
id = widget.arguments?["id"] ?? ""; id = widget.arguments?["id"] ?? "";
storeId = widget.arguments?["storeId"] ?? ""; storeId = widget.arguments?["storeId"] ?? "";
isSetMeal = widget.arguments?["isSetMeal"] ?? false; 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(); queryStoreInfo();
buildCount(); buildCount();
} }
@ -118,7 +104,6 @@ class _ShopDetailsPage extends State<ShopDetailsPage> {
} }
minLogin(); minLogin();
} }
// SmartDialog.dismiss();
} }
/// ///
@ -147,7 +132,6 @@ class _ShopDetailsPage extends State<ShopDetailsPage> {
this.shopCarGoods = value; this.shopCarGoods = value;
setState(() {}); setState(() {});
}); });
// SmartDialog.dismiss();
} }
}); });
} }
@ -171,6 +155,7 @@ class _ShopDetailsPage extends State<ShopDetailsPage> {
} else { } else {
refreshController.refreshFailed(); refreshController.refreshFailed();
} }
SmartDialog.dismiss(status: SmartStatus.loading, force: true);
} }
_onRefresh() { _onRefresh() {
@ -178,7 +163,7 @@ class _ShopDetailsPage extends State<ShopDetailsPage> {
} }
/// ///
getParentInfo() async { Future getParentInfo() async {
BaseData? baseData = await minService?.getParentInfo("$tableId").catchError((error) { BaseData? baseData = await minService?.getParentInfo("$tableId").catchError((error) {
debugPrint("${error}"); debugPrint("${error}");
return BaseData()..isSuccess = false; return BaseData()..isSuccess = false;
@ -188,14 +173,13 @@ class _ShopDetailsPage extends State<ShopDetailsPage> {
parentId = baseData.data["id"]; parentId = baseData.data["id"];
parentCode = baseData.data["parentCode"]; parentCode = baseData.data["parentCode"];
} else { } else {
///TODO: await queryStoreInfo1();
queryStoreInfo1();
} }
} }
} }
/// ///
showPeopleNum(String? tableName) async { Future showPeopleNum(String? tableName) async {
var people = await showDialog( var people = await showDialog(
context: context, context: context,
barrierDismissible: false, barrierDismissible: false,
@ -214,7 +198,7 @@ class _ShopDetailsPage extends State<ShopDetailsPage> {
} }
/// ///
queryStoreInfo1() async { Future queryStoreInfo1() async {
BaseData<StoreInfo>? baseData = await minService?.queryStoreInfo1({ BaseData<StoreInfo>? baseData = await minService?.queryStoreInfo1({
"getCoupon": true, "getCoupon": true,
"storeId": storeId, "storeId": storeId,
@ -225,7 +209,7 @@ class _ShopDetailsPage extends State<ShopDetailsPage> {
}); });
if ((baseData?.isSuccess ?? false) && baseData!.data != null) { if ((baseData?.isSuccess ?? false) && baseData!.data != null) {
StoreInfo storeInfo = baseData.data!; StoreInfo storeInfo = baseData.data!;
showPeopleNum(storeInfo.storeTable?.tableName); await showPeopleNum(storeInfo.storeTable?.tableName);
} }
} }
@ -240,7 +224,7 @@ class _ShopDetailsPage extends State<ShopDetailsPage> {
} }
/// ///
toDownOrder() async { Future toDownOrder() async {
int num = count(); int num = count();
if (parentId == "") { if (parentId == "") {
@ -269,26 +253,23 @@ class _ShopDetailsPage extends State<ShopDetailsPage> {
); );
if ((miNiDetail?.subscribeParam?.isEnableSubscribe ?? false)) { if ((miNiDetail?.subscribeParam?.isEnableSubscribe ?? false)) {
clearShopCar(); await clearShopCar();
this.shopCarGoods = await queryShopCar(); this.shopCarGoods = await queryShopCar();
} }
if (tableId > 0) { if (tableId > 0) {
getParentInfo(); await getParentInfo();
} }
queryShopCar().then((value) { this.shopCarGoods = await queryShopCar();
this.shopCarGoods = value;
setState(() {}); setState(() {});
});
} }
/// key,UI /// key,UI
GlobalKey shopCartKey = GlobalKey(); GlobalKey shopCartKey = GlobalKey();
/// ///
showShoppingCart() { Future showShoppingCart() async {
queryShopCar().then((value) { this.shopCarGoods = await queryShopCar();
this.shopCarGoods = value;
dialogShowing = true; dialogShowing = true;
SmartDialog.show( SmartDialog.show(
builder: (ctx) { builder: (ctx) {
@ -306,11 +287,10 @@ class _ShopDetailsPage extends State<ShopDetailsPage> {
}, },
alignment: Alignment.bottomCenter, alignment: Alignment.bottomCenter,
); );
});
} }
/// ///
clearShopCar() async { Future clearShopCar() async {
BaseData<bool>? baseData = await minService?.clearShoppingCart(num.parse(storeId)); BaseData<bool>? baseData = await minService?.clearShoppingCart(num.parse(storeId));
if (baseData?.isSuccess ?? false) { if (baseData?.isSuccess ?? false) {
shopCarGoods = null; shopCarGoods = null;
@ -319,7 +299,7 @@ class _ShopDetailsPage extends State<ShopDetailsPage> {
} }
/// ///
_queryMiNiDetail(String id, int count) async { Future _queryMiNiDetail(String id, int count) async {
S.current.zhengzaijiazai.loading; S.current.zhengzaijiazai.loading;
if (count < 0) { if (count < 0) {
shopCarGoods?.shoppingCartSkuItemList?.forEach((element) { shopCarGoods?.shoppingCartSkuItemList?.forEach((element) {
@ -332,19 +312,20 @@ class _ShopDetailsPage extends State<ShopDetailsPage> {
} }
BaseData<MiniDetail>? baseData = await minService?.miNiDetail(id); BaseData<MiniDetail>? baseData = await minService?.miNiDetail(id);
if (baseData?.isSuccess ?? false) { 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 && if (miNiDetail?.attrList?.length == 1 &&
(miNiDetail?.attrList![0].attrValueList?.isNotEmpty ?? false)) { (miNiDetail?.attrList![0].attrValueList?.isNotEmpty ?? false)) {
_addShopCar(miNiDetail, [], counts); await _addShopCar(miNiDetail, [], counts);
} else { } else {
// showSpanDialog(); // showSpanDialog();
selectSpecsShowBottomSheet(); selectSpecsShowBottomSheet();
} }
SmartDialog.dismiss(status: SmartStatus.loading, force: true);
} }
/// ///
@ -372,7 +353,7 @@ class _ShopDetailsPage extends State<ShopDetailsPage> {
.replaceAll(",", ""); .replaceAll(",", "");
if (miNiDetail?.subscribeParam?.isEnableSubscribe ?? false) { if (miNiDetail?.subscribeParam?.isEnableSubscribe ?? false) {
clearShopCar(); await clearShopCar();
} }
BaseListData<ShoppingCart>? baseDate = await minService?.addShoppingCart({ BaseListData<ShoppingCart>? baseDate = await minService?.addShoppingCart({
@ -398,14 +379,11 @@ class _ShopDetailsPage extends State<ShopDetailsPage> {
}).catchError((error) { }).catchError((error) {
return BaseListData<ShoppingCart>()..isSuccess = false; return BaseListData<ShoppingCart>()..isSuccess = false;
}); });
SmartDialog.dismiss();
if (baseDate?.isSuccess ?? false) { if (baseDate?.isSuccess ?? false) {
queryShopCar().then((value) { this.shopCarGoods = await queryShopCar();
this.shopCarGoods = value;
if (miNiDetail?.subscribeParam?.isEnableSubscribe ?? false) if (miNiDetail?.subscribeParam?.isEnableSubscribe ?? false)
toDownOrder(); toDownOrder();
setState(() {}); setState(() {});
});
} }
} }
@ -415,7 +393,7 @@ class _ShopDetailsPage extends State<ShopDetailsPage> {
pid = ""; // pid = ""; //
cName = ""; // cName = ""; //
cid = ""; // cid = ""; //
BaseListData<ShoppingCart>? baseDate = await minService?.getShoppingCart(tableId); 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) {
@ -433,109 +411,52 @@ class _ShopDetailsPage extends State<ShopDetailsPage> {
}); });
} }
return baseDate.data![0]; return baseDate.data![0];
} else {
return null;
} }
return null;
} }
///1 ///1
Future<ShoppingCart?> shopCartAdd(SkuItemList cartSkuItem) async { Future<ShoppingCart?> shopCartAdd(SkuItemList cartSkuItem) async {
S.current.zhengzaijiazai.loading;
Map<String, dynamic> shopCarTemp = shopCarGoods?.toJson() ?? {}; Map<String, dynamic> shopCarTemp = shopCarGoods?.toJson() ?? {};
int buyNum = cartSkuItem.buyNum ?? 0; int buyNum = cartSkuItem.buyNum ?? 0;
cartSkuItem.buyNum = buyNum + 1; Map shoppingCartSkuItemList = cartSkuItem.toJson();
shopCarTemp["shoppingCartSkuItemList"] = [cartSkuItem.toJson()]; shoppingCartSkuItemList["buyNum"] = buyNum + 1;
BaseListData<ShoppingCart>? baseDate = shopCarTemp["shoppingCartSkuItemList"] = [shoppingCartSkuItemList];
await minService?.shoppingCartSingle(shopCarTemp); shopCarTemp["couponList"] = [];
BaseListData<ShoppingCart>? baseDate = await minService?.shoppingCartSingle(shopCarTemp).catchLEr<ShoppingCart>();
if (baseDate?.isSuccess ?? false) { if (baseDate?.isSuccess ?? false) {
this.shopCarGoods = await queryShopCar(); this.shopCarGoods = await queryShopCar();
cartSkuItem.buyNum = buyNum + 1;
shopCartKey.currentState?.setState(() {}); shopCartKey.currentState?.setState(() {});
setState(() {}); setState(() {});
} }
SmartDialog.dismiss(status: SmartStatus.loading, force: true);
return this.shopCarGoods; return this.shopCarGoods;
} }
///1 ///1
Future<ShoppingCart?> shopCartReduce(SkuItemList cartSkuItem) async { Future<ShoppingCart?> shopCartReduce(SkuItemList cartSkuItem) async {
S.current.zhengzaijiazai.loading;
Map<String, dynamic> shopCarTemp = shopCarGoods?.toJson() ?? {}; Map<String, dynamic> shopCarTemp = shopCarGoods?.toJson() ?? {};
int buyNum = cartSkuItem.buyNum ?? 0; int buyNum = cartSkuItem.buyNum ?? 0;
cartSkuItem.buyNum = buyNum - 1; Map shoppingCartSkuItemList = cartSkuItem.toJson();
shopCarTemp["shoppingCartSkuItemList"] = [cartSkuItem.toJson()]; shoppingCartSkuItemList["buyNum"] = buyNum - 1;
shopCarTemp["shoppingCartSkuItemList"] = [shoppingCartSkuItemList];
shopCarTemp["couponList"] = []; shopCarTemp["couponList"] = [];
BaseListData<ShoppingCart>? baseDate = await minService?.shoppingCartSingle(shopCarTemp); BaseListData<ShoppingCart>? baseDate = await minService?.shoppingCartSingle(shopCarTemp);
if (baseDate?.isSuccess ?? false) { if (baseDate?.isSuccess ?? false) {
this.shopCarGoods = await queryShopCar(); this.shopCarGoods = await queryShopCar();
cartSkuItem.buyNum = buyNum - 1;
if (shopCartKey.currentState != null) { if (shopCartKey.currentState != null) {
shopCartKey.currentState!.setState(() {}); shopCartKey.currentState!.setState(() {});
} }
setState(() {}); setState(() {});
} }
SmartDialog.dismiss(status: SmartStatus.loading, force: true);
return this.shopCarGoods; 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<String, dynamic> 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<ShoppingCart>? 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<String, dynamic> shopCarTemp = shopCarGoods?.toJson() ?? {};
SkuItemList? cartSkuItem = shopCarGoods?.shoppingCartSkuItemList
?.firstWhere((element) => skuId == element.id);
shopCarTemp["shoppingCartSkuItemList"] = [cartSkuItem?.toJson()];
BaseListData<ShoppingCart>? baseDate = await minService?.shoppingCartSingle(shopCarTemp);
if (baseDate?.isSuccess ?? false) {
queryShopCar().then((value) {
this.shopCarGoods = value;
setState(() {});
});
}
}
bool skuY(ProductSkuVOList productSku, selectSkus) { bool skuY(ProductSkuVOList productSku, selectSkus) {
bool gg = true; bool gg = true;
selectSkus.forEach((element1) { selectSkus.forEach((element1) {

74
lib/store/store_order.dart

@ -113,19 +113,18 @@ class _StoreOrderPage extends State<StoreOrderPage>
storeId: storeId, storeId: storeId,
); );
queryMemberInfo(); await queryMemberInfo();
queryShopCar().then((value) { ShoppingCart? value = await queryShopCar();
this.shopCarGoods = value;
setState(() {});
});
if (tableId > 0) { if (tableId > 0) {
getParentInfo(); getParentInfo();
} }
this.shopCarGoods = value;
setState(() {});
} }
/// ///
queryMemberInfo() async { Future queryMemberInfo() async {
BaseData? baseData = await minService?.memberInfo().catchError((error) { BaseData? baseData = await minService?.memberInfo().catchError((error) {
debugPrint("${error}"); debugPrint("${error}");
return BaseData()..isSuccess = false; return BaseData()..isSuccess = false;
@ -137,7 +136,7 @@ class _StoreOrderPage extends State<StoreOrderPage>
} }
/// ///
getParentInfo() async { Future getParentInfo() async {
BaseData? baseData = BaseData? baseData =
await minService?.getParentInfo("$tableId").catchError((error) { await minService?.getParentInfo("$tableId").catchError((error) {
debugPrint("${error}"); debugPrint("${error}");
@ -154,7 +153,7 @@ class _StoreOrderPage extends State<StoreOrderPage>
} }
/// ///
queryStoreInfo1() async { Future queryStoreInfo1() async {
BaseData<StoreInfo>? baseData = await minService?.queryStoreInfo1({ BaseData<StoreInfo>? baseData = await minService?.queryStoreInfo1({
"getCoupon": true, "getCoupon": true,
"storeId": storeId, "storeId": storeId,
@ -170,7 +169,7 @@ class _StoreOrderPage extends State<StoreOrderPage>
} }
/// ///
queryStoreInfo() async { Future queryStoreInfo() async {
BaseData<StoreInfo>? baseData = BaseData<StoreInfo>? baseData =
await apiService?.queryStoreInfo(storeId).catchError((error) { await apiService?.queryStoreInfo(storeId).catchError((error) {
debugPrint("${error}"); debugPrint("${error}");
@ -370,6 +369,7 @@ class _StoreOrderPage extends State<StoreOrderPage>
() { () {
queryShopCar().then((value) { queryShopCar().then((value) {
this.shopCarGoods = value; this.shopCarGoods = value;
SmartDialog.dismiss(status: SmartStatus.loading, force: true);
setState(() {}); setState(() {});
}); });
}, },
@ -377,30 +377,6 @@ class _StoreOrderPage extends State<StoreOrderPage>
), ),
), ),
], ],
// 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<StoreOrderPage>
} }
/// ///
clearShopCar() async { Future clearShopCar() async {
BaseData<bool>? baseData = BaseData<bool>? baseData = await minService?.clearShoppingCart(num.parse(storeId));
await minService?.clearShoppingCart(num.parse(storeId));
if (baseData?.isSuccess ?? false) { if (baseData?.isSuccess ?? false) {
shopCarGoods = null; shopCarGoods = null;
setState(() {}); setState(() {});
@ -700,23 +675,24 @@ class _StoreOrderPage extends State<StoreOrderPage>
await shopCartReduce(skuItems!.first); await shopCartReduce(skuItems!.first);
setState(() {}); setState(() {});
} }
SmartDialog.dismiss(status: SmartStatus.loading, force: true);
return; return;
} }
BaseData<MiniDetail>? baseData = await minService?.miNiDetail(id); BaseData<MiniDetail>? baseData = await minService?.miNiDetail(id);
if (baseData?.isSuccess ?? false) { if (baseData?.isSuccess ?? false) {
miniDetail = baseData!.data; miniDetail = baseData!.data;
if (baseData.data != null) { 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) { if (miniDetail.attrStyle == 0) {
_addShopCar(miniDetail, [], count); await _addShopCar(miniDetail, [], count);
} else { } else {
SmartDialog.dismiss();
dialogShowing = true; dialogShowing = true;
showModalBottomSheet( showModalBottomSheet(
backgroundColor: Colors.transparent, backgroundColor: Colors.transparent,
@ -761,7 +737,7 @@ class _StoreOrderPage extends State<StoreOrderPage>
.replaceAll(",", ""); .replaceAll(",", "");
if (miniDetail?.subscribeParam?.isEnableSubscribe ?? false) { if (miniDetail?.subscribeParam?.isEnableSubscribe ?? false) {
clearShopCar(); await clearShopCar();
} }
BaseListData<ShoppingCart>? baseDate = await minService?.addShoppingCart({ BaseListData<ShoppingCart>? baseDate = await minService?.addShoppingCart({
@ -785,7 +761,6 @@ class _StoreOrderPage extends State<StoreOrderPage>
}, },
], ],
}).catchLEr<ShoppingCart>(); }).catchLEr<ShoppingCart>();
// SmartDialog.dismiss();
if (baseDate?.isSuccess ?? false) { if (baseDate?.isSuccess ?? false) {
this.shopCarGoods = await queryShopCar(); this.shopCarGoods = await queryShopCar();
if (miniDetail?.subscribeParam?.isEnableSubscribe ?? false) toDownOrder(); if (miniDetail?.subscribeParam?.isEnableSubscribe ?? false) toDownOrder();
@ -802,33 +777,29 @@ 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 = BaseListData<ShoppingCart>? baseDate = await minService?.getShoppingCart(tableId).catchLEr<ShoppingCart>();
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) {
if (element.isMaxCoupon ?? false) { if (element.isMaxCoupon ?? false) {
// cName = element.promotionName;
cid = element.id; cid = element.id;
} }
}); });
} else if (baseDate.data![0].selectDiscount == 2) { } else if (baseDate.data![0].selectDiscount == 2) {
baseDate.data![0].promotionInfoList?.forEach((element) { baseDate.data![0].promotionInfoList?.forEach((element) {
if (element.isMaxPromotion ?? false) { if (element.isMaxPromotion ?? false) {
// pName = element.name;
pid = element.id; pid = element.id;
} }
}); });
} }
return baseDate.data![0]; return baseDate.data![0];
} else {
return null;
} }
return null;
} }
///1 ///1
Future<ShoppingCart?> shopCartAdd(SkuItemList cartSkuItem) async { Future<ShoppingCart?> shopCartAdd(SkuItemList cartSkuItem) async {
S.current.zhengzaijiazai.loading;
Map<String, dynamic> shopCarTemp = shopCarGoods?.toJson() ?? {}; Map<String, dynamic> shopCarTemp = shopCarGoods?.toJson() ?? {};
cartSkuItem.buyNum = (cartSkuItem.buyNum ?? 0) + 1; cartSkuItem.buyNum = (cartSkuItem.buyNum ?? 0) + 1;
shopCarTemp["shoppingCartSkuItemList"] = [cartSkuItem.toJson()]; shopCarTemp["shoppingCartSkuItemList"] = [cartSkuItem.toJson()];
@ -841,12 +812,14 @@ class _StoreOrderPage extends State<StoreOrderPage>
this.shopCarGoods = await queryShopCar(); this.shopCarGoods = await queryShopCar();
shopCartKey.currentState?.setState(() {}); shopCartKey.currentState?.setState(() {});
} }
SmartDialog.dismiss(status: SmartStatus.loading, force: true);
setState(() {}); setState(() {});
return this.shopCarGoods; return this.shopCarGoods;
} }
///1 ///1
Future<ShoppingCart?> shopCartReduce(SkuItemList cartSkuItem) async { Future<ShoppingCart?> shopCartReduce(SkuItemList cartSkuItem) async {
S.current.zhengzaijiazai.loading;
Map<String, dynamic> shopCarTemp = shopCarGoods?.toJson() ?? {}; Map<String, dynamic> shopCarTemp = shopCarGoods?.toJson() ?? {};
cartSkuItem.buyNum = (cartSkuItem.buyNum ?? 0) - 1; cartSkuItem.buyNum = (cartSkuItem.buyNum ?? 0) - 1;
shopCarTemp["shoppingCartSkuItemList"] = [cartSkuItem.toJson()]; shopCarTemp["shoppingCartSkuItemList"] = [cartSkuItem.toJson()];
@ -859,6 +832,7 @@ class _StoreOrderPage extends State<StoreOrderPage>
} }
setState(() {}); setState(() {});
} }
SmartDialog.dismiss(status: SmartStatus.loading, force: true);
return this.shopCarGoods; return this.shopCarGoods;
} }

1
lib/store/store_view/people_num.dart

@ -125,7 +125,6 @@ class _PeopleNumView extends State<PeopleNumView> {
radius: 4.w, radius: 4.w,
callback: () { callback: () {
// widget.callback(peopleNum); // widget.callback(peopleNum);
// SmartDialog.dismiss();
Navigator.of(context).pop(peopleNum); Navigator.of(context).pop(peopleNum);
}, },
), ),

4
lib/store/store_view/product_sku.dart

@ -183,7 +183,6 @@ class _ProductSku extends State<ProductSku> {
InkWell( InkWell(
onTap: () { onTap: () {
Navigator.of(context).pop(); Navigator.of(context).pop();
// SmartDialog.dismiss();
}, },
child: Image.asset( child: Image.asset(
"assets/image/cancel.webp", "assets/image/cancel.webp",
@ -288,7 +287,6 @@ class _ProductSku extends State<ProductSku> {
count += 1; count += 1;
} }
setState(() {}); setState(() {});
SmartDialog.dismiss();
}, },
child: Image.asset( child: Image.asset(
"assets/image/add.webp", "assets/image/add.webp",
@ -315,7 +313,6 @@ class _ProductSku extends State<ProductSku> {
fontSize: 16.sp, fontSize: 16.sp,
callback: () { callback: () {
Navigator.of(context1).pop(); Navigator.of(context1).pop();
// SmartDialog.dismiss();
int number = count - realCount; int number = count - realCount;
if (number == 0 && realCount == 1) { if (number == 0 && realCount == 1) {
number = 1; number = 1;
@ -339,7 +336,6 @@ class _ProductSku extends State<ProductSku> {
fontSize: 16.sp, fontSize: 16.sp,
callback: () { callback: () {
Navigator.of(context).pop(); Navigator.of(context).pop();
// SmartDialog.dismiss();
widget.addShopCar(widget.miNiDetail, selectSkus, count); widget.addShopCar(widget.miNiDetail, selectSkus, count);
}, },
), ),

3
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/data/shopping_cart.dart';
import 'package:huixiang/generated/l10n.dart'; import 'package:huixiang/generated/l10n.dart';
import 'package:huixiang/store/store_view/shop_goods_car.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/utils/font_weight.dart';
import 'package:huixiang/view_widget/round_button.dart'; import 'package:huixiang/view_widget/round_button.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart';
@ -97,6 +98,7 @@ class _ShopCar extends State<ShopCar> {
], ],
), ),
), ),
16.d,
Expanded( Expanded(
child: Stack( child: Stack(
children: [ children: [
@ -112,6 +114,7 @@ class _ShopCar extends State<ShopCar> {
), ),
child: ListView.builder( child: ListView.builder(
itemCount: itemCount(), itemCount: itemCount(),
padding: EdgeInsets.zero,
physics: BouncingScrollPhysics(), physics: BouncingScrollPhysics(),
itemBuilder: (context, position) { itemBuilder: (context, position) {
return ShopGoodsCar( return ShopGoodsCar(

204
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/mini_detail.dart';
import 'package:huixiang/data/shopping_cart.dart'; import 'package:huixiang/data/shopping_cart.dart';
import 'package:huixiang/generated/l10n.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/font_weight.dart';
import 'package:huixiang/utils/shared_preference.dart'; import 'package:huixiang/utils/shared_preference.dart';
import 'package:huixiang/utils/str_utils.dart'; import 'package:huixiang/utils/str_utils.dart';
@ -55,6 +56,34 @@ class _ShopGoods extends State<ShopGoods> {
int _jumpType = -1; int _jumpType = -1;
MiniDetail? miNiDetail; 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 { queryMiNiDetail(id) async {
MinApiService? minService; MinApiService? minService;
@ -75,35 +104,30 @@ class _ShopGoods extends State<ShopGoods> {
miNiDetail = baseData.data; miNiDetail = baseData.data;
if (baseData.data?.productSkuVOList?[0].productSetMeals?.isEmpty ?? true) { if (baseData.data?.productSkuVOList?[0].productSetMeals?.isEmpty ?? true) {
_jumpType = 0; _jumpType = 0;
if (widget.shoppingCartSkuItemListBean != null) { widget.add.call(widget.shoppingCartSkuItemListBean);
widget.add.call(widget.shoppingCartSkuItemListBean!);
}
} else { } else {
_jumpType = 1; _jumpType = 1;
await Navigator.of(context) await Navigator.of(context).pushNamed(
.pushNamed('/router/product_meals_sku', arguments: { '/router/product_meals_sku',
arguments: {
"id": widget.productListBean?.id, "id": widget.productListBean?.id,
"storeId": widget.productListBean?.storeId, "storeId": widget.productListBean?.storeId,
"tableId": widget.tableId "tableId": widget.tableId
}); },
);
widget.queryShoppingCart(); widget.queryShoppingCart();
} }
} else {
// refreshController.refreshFailed();
} }
} }
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
String price = doubleStr2Int( String price = doubleStr2Int("${widget.isShopCart ? widget.shoppingCartSkuItemListBean?.skuPrice : widget.productListBean?.price}");
"${widget.isShopCart ? widget.shoppingCartSkuItemListBean?.skuPrice : widget.productListBean?.price}");
return Container( return Container(
color: Colors.white, color: Colors.white,
// padding: EdgeInsets.only( padding: EdgeInsets.symmetric(
// right: 16.w, vertical: 8.h,
// // bottom: 20.h, ),
// ),
height: 123.h,
child: Row( child: Row(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.start, mainAxisAlignment: MainAxisAlignment.start,
@ -125,18 +149,14 @@ class _ShopGoods extends State<ShopGoods> {
width: 10.w, width: 10.w,
), ),
Expanded( Expanded(
child: IntrinsicHeight(
child: Column( child: Column(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
Padding( Padding(
padding: EdgeInsets.only(right: 16.w), padding: EdgeInsets.only(right: 16.w),
child: Row(
children: [
Expanded(
child: Text( child: Text(
widget.productListBean!.productName ?? widget.productListBean!.productName ?? widget.shoppingCartSkuItemListBean!.productName ?? "",
widget.shoppingCartSkuItemListBean!.productName ??
"",
overflow: TextOverflow.ellipsis, overflow: TextOverflow.ellipsis,
maxLines: 1, maxLines: 1,
style: TextStyle( style: TextStyle(
@ -146,35 +166,13 @@ class _ShopGoods extends State<ShopGoods> {
), ),
), ),
), ),
// 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( SizedBox(
height: 2.h, height: 2.h,
), ),
Padding( Padding(
padding: EdgeInsets.only(right: 16.w), padding: EdgeInsets.only(right: 25.w),
child: Row(
children: [
Expanded(
child: Text( child: Text(
widget.productListBean!.shortName ?? widget.productListBean!.shortName ?? widget.shoppingCartSkuItemListBean!.skuName ?? "",
widget.shoppingCartSkuItemListBean!.skuName ??
"",
overflow: TextOverflow.ellipsis, overflow: TextOverflow.ellipsis,
maxLines: 2, maxLines: 2,
style: TextStyle( style: TextStyle(
@ -184,12 +182,6 @@ class _ShopGoods extends State<ShopGoods> {
), ),
), ),
), ),
SizedBox(
width: 10.w,
),
],
),
),
SizedBox( SizedBox(
height: 7.h, height: 7.h,
), ),
@ -210,45 +202,18 @@ class _ShopGoods extends State<ShopGoods> {
SizedBox( SizedBox(
width: 2.w, 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 && if (!widget.isShopCart && (widget.productListBean?.attrStyle ?? 0) == 1 &&
(widget.productListBean?.attrStyle ?? 0) == 1 && !(widget.productListBean?.subscribeParam?.isEnableSubscribe ?? false) &&
!(widget.productListBean?.subscribeParam
?.isEnableSubscribe ??
false) &&
!(widget.productListBean?.isSetMeal ?? false)) !(widget.productListBean?.isSetMeal ?? false))
GestureDetector( GestureDetector(
behavior: HitTestBehavior.opaque, behavior: HitTestBehavior.opaque,
onTap: () async { onTap: () async {
if (widget.storeInfo?.posType?.code == if (widget.storeInfo?.posType?.code == "NORMALSTORE" && widget.tableId == 0) {
"NORMALSTORE" &&
widget.tableId == 0) {
showDeleteDialog(); showDeleteDialog();
} else { } else {
widget.queryMiNiDetail( widget.queryMiNiDetail(widget.productListBean!.id ?? widget.shoppingCartSkuItemListBean!.productId ?? "", 0);
widget.productListBean!.id ??
widget.shoppingCartSkuItemListBean!
.productId ??
"",
0);
} }
}, },
child: Stack( child: Stack(
@ -293,20 +258,16 @@ class _ShopGoods extends State<ShopGoods> {
), ),
), ),
], ],
)), ),
if (widget.isShopCart || ),
(widget.productListBean?.attrStyle ?? 0) == 0 && if (widget.isShopCart || (widget.productListBean?.attrStyle ?? 0) == 0 &&
!(widget.productListBean?.subscribeParam !(widget.productListBean?.subscribeParam?.isEnableSubscribe ?? false) &&
?.isEnableSubscribe ??
false) &&
!(widget.productListBean?.isSetMeal ?? false)) ...[ !(widget.productListBean?.isSetMeal ?? false)) ...[
Spacer(), Spacer(),
GestureDetector( GestureDetector(
behavior: HitTestBehavior.opaque, behavior: HitTestBehavior.opaque,
onTap: () async { onTap: () async {
if (widget.storeInfo?.posType?.code == if (widget.storeInfo?.posType?.code == "NORMALSTORE" && widget.tableId == 0) {
"NORMALSTORE" &&
widget.tableId == 0) {
showDeleteDialog(); showDeleteDialog();
} else { } else {
widget.reduce(widget.shoppingCartSkuItemListBean); widget.reduce(widget.shoppingCartSkuItemListBean);
@ -335,33 +296,25 @@ class _ShopGoods extends State<ShopGoods> {
GestureDetector( GestureDetector(
behavior: HitTestBehavior.opaque, behavior: HitTestBehavior.opaque,
onTap: () async { onTap: () async {
if (widget.storeInfo?.posType?.code == if (widget.storeInfo?.posType?.code == "NORMALSTORE" && widget.tableId == 0) {
"NORMALSTORE" &&
widget.tableId == 0) {
showDeleteDialog(); showDeleteDialog();
} else { } else {
// if ((widget?.productListBean?.oversold ?? 0) == 0 && if (_jumpType == -1) {
// widget.count >=
// (widget?.shoppingCartSkuItemListBean
// ?.skuStock ??
// 0)) {
// SmartDialog.showToast("库存不足",
// alignment: Alignment.center);
// } else
if (_jumpType == -1)
queryMiNiDetail(widget.productListBean?.id); queryMiNiDetail(widget.productListBean?.id);
else if (_jumpType == 0) } else if (_jumpType == 0) {
widget.add(widget.shoppingCartSkuItemListBean); widget.add(widget.shoppingCartSkuItemListBean);
else if (_jumpType == 1) } else if (_jumpType == 1) {
await Navigator.of(context).pushNamed( await Navigator.of(context).pushNamed(
'/router/product_meals_sku', '/router/product_meals_sku',
arguments: { arguments: {
"id": widget.productListBean?.id, "id": widget.productListBean?.id,
"storeId": widget.productListBean?.storeId, "storeId": widget.productListBean?.storeId,
"tableId": widget.tableId "tableId": widget.tableId
}); },
);
widget.queryShoppingCart(); widget.queryShoppingCart();
} }
}
}, },
child: Container( child: Container(
padding: EdgeInsets.only(left: 6.w, right: 9.w), padding: EdgeInsets.only(left: 6.w, right: 9.w),
@ -373,23 +326,16 @@ class _ShopGoods extends State<ShopGoods> {
), ),
), ),
], ],
if (widget.productListBean?.subscribeParam if (widget.productListBean?.subscribeParam?.isEnableSubscribe ?? false)
?.isEnableSubscribe ??
false)
GestureDetector( GestureDetector(
behavior: HitTestBehavior.opaque, behavior: HitTestBehavior.opaque,
onTap: () async { onTap: () async {
if (widget.storeInfo?.posType?.code == if (widget.storeInfo?.posType?.code == "NORMALSTORE" && widget.tableId == 0) {
"NORMALSTORE" &&
widget.tableId == 0) {
showDeleteDialog(); showDeleteDialog();
} else if (widget.isShopCart || } else if (widget.isShopCart || (widget.productListBean?.attrStyle ?? 0) == 0) {
(widget.productListBean?.attrStyle ?? 0) == 0) {
queryMiNiDetail(widget.productListBean?.id); queryMiNiDetail(widget.productListBean?.id);
} else { } else {
String? productId = widget.productListBean != null String? productId = widget.productListBean != null ? widget.productListBean!.id : widget.shoppingCartSkuItemListBean?.productId;
? widget.productListBean!.id
: widget.shoppingCartSkuItemListBean?.productId;
if (productId != null) { if (productId != null) {
widget.queryMiNiDetail(productId, 0); widget.queryMiNiDetail(productId, 0);
} }
@ -420,22 +366,9 @@ class _ShopGoods extends State<ShopGoods> {
GestureDetector( GestureDetector(
behavior: HitTestBehavior.opaque, behavior: HitTestBehavior.opaque,
onTap: () async { onTap: () async {
if (widget.storeInfo?.posType?.code == if (widget.storeInfo?.posType?.code == "NORMALSTORE" && widget.tableId == 0) {
"NORMALSTORE" &&
widget.tableId == 0) {
showDeleteDialog(); showDeleteDialog();
} } else {
// else if ((widget?.productListBean?.oversold ??
// 0) ==
// 0 &&
// widget.count >=
// (widget?.shoppingCartSkuItemListBean
// ?.skuStock ??
// 0)) {
// SmartDialog.showToast("库存不足",
// alignment: Alignment.center);
// }
else {
await Navigator.of(context).pushNamed( await Navigator.of(context).pushNamed(
'/router/product_meals_sku', '/router/product_meals_sku',
arguments: { arguments: {
@ -464,7 +397,8 @@ class _ShopGoods extends State<ShopGoods> {
backgroup: Color(0xFF32A060), backgroup: Color(0xFF32A060),
fontSize: 11.sp, fontSize: 11.sp,
padding: EdgeInsets.symmetric( padding: EdgeInsets.symmetric(
vertical: 5.h, horizontal: 3.w), vertical: 5.h, horizontal: 3.w,
),
), ),
), ),
Positioned( Positioned(
@ -484,7 +418,8 @@ class _ShopGoods extends State<ShopGoods> {
), ),
), ),
], ],
)) ),
),
], ],
), ),
SizedBox( SizedBox(
@ -534,6 +469,7 @@ class _ShopGoods extends State<ShopGoods> {
], ],
), ),
), ),
),
SizedBox(width: 6.w), SizedBox(width: 6.w),
], ],
), ),

82
lib/store/store_view/shop_goods_car.dart

@ -43,8 +43,7 @@ class _ShopGoodsCar extends State<ShopGoodsCar> {
return Container( return Container(
color: Colors.white, color: Colors.white,
padding: EdgeInsets.only( padding: EdgeInsets.only(
right: 16.w, right: 16.w, top: 12, bottom: 12,
// bottom: 20.h,
), ),
child: Column( child: Column(
children: [ children: [
@ -68,12 +67,10 @@ class _ShopGoodsCar extends State<ShopGoodsCar> {
), ),
Expanded( Expanded(
child: Column( child: Column(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
Row( Text(
children: [
Expanded(
child: Text(
widget.productListBean?.productName ?? widget.shoppingCartSkuItemListBean!.productName ?? "", widget.productListBean?.productName ?? widget.shoppingCartSkuItemListBean!.productName ?? "",
overflow: TextOverflow.ellipsis, overflow: TextOverflow.ellipsis,
maxLines: 2, maxLines: 2,
@ -83,30 +80,7 @@ class _ShopGoodsCar extends State<ShopGoodsCar> {
fontWeight: MyFontWeight.medium, fontWeight: MyFontWeight.medium,
), ),
), ),
), Text(
// 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,
),
Row(
children: [
Expanded(
child: Text(
widget.productListBean?.shortName widget.productListBean?.shortName
?? ((widget.shoppingCartSkuItemListBean?.skuName == "0") ?? ((widget.shoppingCartSkuItemListBean?.skuName == "0")
? "" : widget.shoppingCartSkuItemListBean?.skuName) ?? "", ? "" : widget.shoppingCartSkuItemListBean?.skuName) ?? "",
@ -118,17 +92,6 @@ class _ShopGoodsCar extends State<ShopGoodsCar> {
fontWeight: MyFontWeight.regular, fontWeight: MyFontWeight.regular,
), ),
), ),
),
SizedBox(
width: 10,
),
],
),
SizedBox(
height: 7.h,
),
Row(
children: [
Row( Row(
children: [ children: [
Text( Text(
@ -140,28 +103,6 @@ class _ShopGoodsCar extends State<ShopGoodsCar> {
fontWeight: MyFontWeight.medium, 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(), Spacer(),
if (!widget.isShopCart && if (!widget.isShopCart &&
(widget.productListBean?.attrStyle ?? 0) == 1) (widget.productListBean?.attrStyle ?? 0) == 1)
@ -177,8 +118,7 @@ class _ShopGoodsCar extends State<ShopGoodsCar> {
radius: 3, radius: 3,
backgroup: Color(0xFF32A060), backgroup: Color(0xFF32A060),
fontSize: 11.sp, fontSize: 11.sp,
padding: padding: EdgeInsets.symmetric(vertical: 5.h),
EdgeInsets.symmetric(vertical: 5.h),
callback: () { callback: () {
widget.queryMiNiDetail?.call(widget.productListBean?.id ?? widget.shoppingCartSkuItemListBean?.productId ?? "", 0); widget.queryMiNiDetail?.call(widget.productListBean?.id ?? widget.shoppingCartSkuItemListBean?.productId ?? "", 0);
}, },
@ -206,8 +146,7 @@ class _ShopGoodsCar extends State<ShopGoodsCar> {
(widget.productListBean?.attrStyle ?? 0) == 0) (widget.productListBean?.attrStyle ?? 0) == 0)
InkWell( InkWell(
onTap: () { onTap: () {
widget widget.reduce(widget.shoppingCartSkuItemListBean);
.reduce(widget.shoppingCartSkuItemListBean);
}, },
child: Image.asset( child: Image.asset(
"assets/image/reduce.webp", "assets/image/reduce.webp",
@ -243,9 +182,6 @@ class _ShopGoodsCar extends State<ShopGoodsCar> {
), ),
], ],
), ),
SizedBox(
height: 4.h,
),
Text( Text(
"${applyPrice}", "${applyPrice}",
style: TextStyle( style: TextStyle(
@ -272,11 +208,9 @@ class _ShopGoodsCar extends State<ShopGoodsCar> {
return shopCarMealsItem(widget.shoppingCartSkuItemListBean!.setMealDataList![index]); return shopCarMealsItem(widget.shoppingCartSkuItemListBean!.setMealDataList![index]);
}, },
), ),
SizedBox(
height: 15.h,
)
], ],
)); ),
);
} }
Widget shopCarMealsItem(SetMealData setMealDataList) { Widget shopCarMealsItem(SetMealData setMealDataList) {

158
lib/store/store_view/store_order_list.dart

@ -1,11 +1,8 @@
import 'package:dio/dio.dart'; 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/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart'; import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
import 'package:get/get.dart'; import 'package:get/get.dart';
import 'package:huixiang/constant.dart';
import 'package:huixiang/data/activity.dart'; import 'package:huixiang/data/activity.dart';
import 'package:huixiang/data/base_list_data.dart'; import 'package:huixiang/data/base_list_data.dart';
import 'package:huixiang/data/find_mini_group.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/data/store_info.dart';
import 'package:huixiang/retrofit/min_api.dart'; import 'package:huixiang/retrofit/min_api.dart';
import 'package:huixiang/retrofit/retrofit_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/shop/shop_scroll_coordinator.dart';
import 'package:huixiang/store/store_view/shop_goods.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/utils/font_weight.dart';
import 'package:huixiang/view_widget/round_button.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 { class StoreOrderListPage extends StatefulWidget {
final Map? arguments; final Map? arguments;
@ -60,32 +56,71 @@ class _StoreOrderListPage extends State<StoreOrderListPage> {
late ApiService apiService; late ApiService apiService;
late MinApiService minService; late MinApiService minService;
List<FindMiniGroup>? appletProducts; List<FindMiniGroup>? appletProducts;
List<ProductListBean> productListBeans = [];
int currentIndex = 0; int currentIndex = 0;
late ShopScrollCoordinator _shopCoordinator; late ShopScrollCoordinator _shopCoordinator;
late ShopScrollController _listScrollController1; late ListObserverController _listScrollController1;
late ShopScrollController _listScrollController2; late ListObserverController _listScrollController2;
late Map? arguments;
late List<Activity>? activitys;
late StoreInfo? storeInfo;
late ShopScrollCoordinator shopCoordinator;
late String? minToken;
late String tenant;
late int tableId;
late ScrollPhysics scrollPhysics;
late ShoppingCart? shopCarGoods;
@override @override
void initState() { 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(); super.initState();
_shopCoordinator = widget.shopCoordinator; _shopCoordinator = widget.shopCoordinator;
_listScrollController1 = _shopCoordinator.newChildScrollController(); _listScrollController1 = ListObserverController(controller: _shopCoordinator.newChildScrollController());
_listScrollController2 = _shopCoordinator.newChildScrollController(); _listScrollController2 = ListObserverController(controller: _shopCoordinator.newChildScrollController());
_listScrollController2.addListener(() {
for (int i = 0; i < (appletProducts?.length ?? 0); i++) { appletGoods();
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;
} }
@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();
} }
/// ///
@ -104,20 +139,10 @@ class _StoreOrderListPage extends State<StoreOrderListPage> {
}).catchError((error) { }).catchError((error) {
return BaseListData<FindMiniGroup>()..isSuccess = false; return BaseListData<FindMiniGroup>()..isSuccess = false;
}); });
SmartDialog.dismiss(status: SmartStatus.loading, force: true);
if (baseData.isSuccess ?? false) { if (baseData.isSuccess ?? false) {
// refreshController.refreshCompleted();
setState(() { setState(() {
appletProducts = baseData.data ?? []; 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,33 +158,46 @@ class _StoreOrderListPage extends State<StoreOrderListPage> {
children: [ children: [
Container( Container(
width: 100, width: 100,
child: ListViewObserver(
controller: _listScrollController1,
child: ListView.builder( child: ListView.builder(
itemCount: appletProducts?.length ?? 0, itemCount: appletProducts?.length ?? 0,
physics: ClampingScrollPhysics(), physics: ClampingScrollPhysics(),
controller: _listScrollController1, controller: _listScrollController1.controller,
padding: EdgeInsets.only(top: 0, bottom: 12.h), padding: EdgeInsets.only(top: 0, bottom: 12.h),
itemBuilder: (context, position) { itemBuilder: (context, position) {
return orderItem(position); return orderItem(position);
}, },
), ),
), ),
),
Expanded( Expanded(
child: ListViewObserver(
controller: _listScrollController2,
onObserve: (result) {
if (result.firstChild?.index != null) {
setState(() {
currentIndex = result.firstChild!.index;
});
}
},
child: ListView.builder( child: ListView.builder(
itemCount: appletProducts?.length ?? 0, itemCount: appletProducts?.length ?? 0,
padding: EdgeInsets.only(top: 0), padding: EdgeInsets.only(top: 0),
controller: _listScrollController2, controller: _listScrollController2.controller,
physics: ClampingScrollPhysics(), physics: ClampingScrollPhysics(),
itemBuilder: (context, position) { itemBuilder: (context, position) {
return rightOrderItem(position); return rightOrderItem(position);
}, },
), ),
), ),
),
], ],
), ),
); );
} }
goShopDetailsPage(ProductListBean e) async { Future goShopDetailsPage(ProductListBean e) async {
await Navigator.of(context).pushNamed( await Navigator.of(context).pushNamed(
'/router/shop_details_page', '/router/shop_details_page',
arguments: { arguments: {
@ -174,15 +212,12 @@ class _StoreOrderListPage extends State<StoreOrderListPage> {
Widget orderItem(int index) { Widget orderItem(int index) {
int count = calculateItemCount(appletProducts![index]); int count = calculateItemCount(appletProducts![index]);
return Container( return Container(
width: 100.w, width: 100,
child: GestureDetector( child: GestureDetector(
onTap: () { onTap: () {
_listScrollController2.jumpTo(index: index);
setState(() { setState(() {
// isSelected = index; currentIndex = index;
// productListBeans.clear();
// productListBeans.addAll(appletProducts[index].productList);
int aindex = appletProducts![index].goodsIndex ?? 0;
_listScrollController2.jumpTo(aindex.toDouble());
}); });
}, },
child: Stack( child: Stack(
@ -191,8 +226,7 @@ class _StoreOrderListPage extends State<StoreOrderListPage> {
Container( Container(
color: currentIndex != index ? Color(0xFFFAFAFA) : Colors.white, color: currentIndex != index ? Color(0xFFFAFAFA) : Colors.white,
alignment: Alignment.center, alignment: Alignment.center,
padding: EdgeInsets.all(15), padding: EdgeInsets.all(10),
// margin: EdgeInsets.only(bottom: (index==appletProducts.length - 1)?35.h:0),
child: Row( child: Row(
mainAxisAlignment: MainAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.center,
@ -202,7 +236,7 @@ class _StoreOrderListPage extends State<StoreOrderListPage> {
width: 2, width: 2,
height: 17.h, height: 17.h,
color: Color(0xFF32A060), color: Color(0xFF32A060),
margin: EdgeInsets.only(right: 10.w), margin: EdgeInsets.only(right: 10),
), ),
Expanded( Expanded(
child: Text( child: Text(
@ -217,7 +251,8 @@ class _StoreOrderListPage extends State<StoreOrderListPage> {
? MyFontWeight.medium ? MyFontWeight.medium
: MyFontWeight.semi_bold, : MyFontWeight.semi_bold,
), ),
)), ),
),
], ],
), ),
), ),
@ -246,21 +281,14 @@ class _StoreOrderListPage extends State<StoreOrderListPage> {
Widget rightOrderItem(int rightIndex) { Widget rightOrderItem(int rightIndex) {
return Container( return Container(
color: Colors.white, color: Colors.white,
// margin: EdgeInsets.only( key: appletProducts![rightIndex].scrollControllerKey,
// bottom: (rightIndex == appletProducts!.length - 1)
// ? (_viewportDimension > (appletProducts![rightIndex].height ?? 0)
// ? _viewportDimension -
// (appletProducts![rightIndex].height ?? 0)
// : 30.h)
// : 0),
child: Column( child: Column(
mainAxisAlignment: MainAxisAlignment.start, mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
SizedBox( Container(
height: 50.h, alignment: Alignment.bottomLeft,
child: Padding( padding: EdgeInsets.all(10),
padding: EdgeInsets.only(left: 16.w, top: 10.h, right: 12.w),
child: Text( child: Text(
appletProducts![rightIndex].groupName ?? "", appletProducts![rightIndex].groupName ?? "",
textAlign: TextAlign.center, textAlign: TextAlign.center,
@ -271,20 +299,19 @@ class _StoreOrderListPage extends State<StoreOrderListPage> {
), ),
), ),
), ),
),
Column( Column(
children: appletProducts![rightIndex].productList?.map((e) { children: (appletProducts![rightIndex].productList?.map<Widget>((e) {
return GestureDetector( return GestureDetector(
onTap: () { onTap: () {
if (widget.storeInfo?.posType?.code == "NORMALSTORE") if (widget.storeInfo?.posType?.code == "NORMALSTORE") {
return; return;
else }
goShopDetailsPage(e); goShopDetailsPage(e);
}, },
child: goodsItem(e), child: goodsItem(e),
); );
}).toList() ?? }).toList() ??
[], <Widget>[])..add(12.d),
), ),
], ],
), ),
@ -308,8 +335,13 @@ class _StoreOrderListPage extends State<StoreOrderListPage> {
int count = 0; int count = 0;
widget.shopCarGoods?.shoppingCartSkuItemList?.forEach((element) { widget.shopCarGoods?.shoppingCartSkuItemList?.forEach((element) {
if (e.id == element.productId) { if (e.id == element.productId) {
if (shoppingCartSkuItemListBean == null) {
shoppingCartSkuItemListBean = element;
count = (shoppingCartSkuItemListBean?.buyNum ?? 0);
} else {
count += (element.buyNum ?? 0); count += (element.buyNum ?? 0);
} }
}
}); });
return ShopGoods( return ShopGoods(
(SkuItemList? shoppingCartSkuItemListBean) { (SkuItemList? shoppingCartSkuItemListBean) {
@ -331,8 +363,8 @@ class _StoreOrderListPage extends State<StoreOrderListPage> {
@override @override
void dispose() { void dispose() {
_listScrollController1.dispose(); _listScrollController1.controller?.dispose();
_listScrollController2.dispose(); _listScrollController2.controller?.dispose();
super.dispose(); super.dispose();
} }

23
lib/union/union_list.dart

@ -1,5 +1,4 @@
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_screenutil/flutter_screenutil.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:flutter_smart_dialog/flutter_smart_dialog.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:permission_handler/permission_handler.dart';
import 'package:pull_to_refresh/pull_to_refresh.dart'; import 'package:pull_to_refresh/pull_to_refresh.dart';
import 'package:shimmer/shimmer.dart'; import 'package:shimmer/shimmer.dart';
import 'package:visibility_detector/visibility_detector.dart';
import '../data/product_show.dart'; import '../data/product_show.dart';
import '../retrofit/retrofit_api.dart'; import '../retrofit/retrofit_api.dart';
@ -42,8 +40,7 @@ class UnionList extends StatefulWidget {
} }
} }
class UnionListState extends State<UnionList> class UnionListState extends State<UnionList> with AutomaticKeepAliveClientMixin {
with AutomaticKeepAliveClientMixin {
ApiService? apiService; ApiService? apiService;
List<Store>? storeList; List<Store>? storeList;
Position? latLng; Position? latLng;
@ -65,7 +62,8 @@ class UnionListState extends State<UnionList>
getLocation(); getLocation();
} }
getLocation() async { Future<void> getLocation() async {
S.current.zhengzaijiazai.toast;
try { try {
powerFlag = await LocationInstance.instance.startLocation(context, powerFlag = await LocationInstance.instance.startLocation(context,
(Position? result) async { (Position? result) async {
@ -90,14 +88,14 @@ class UnionListState extends State<UnionList>
} else { } else {
await getLatLng(); await getLatLng();
} }
queryStore(); await queryStore();
}); });
} finally { } finally {
if (!powerFlag) { if (!powerFlag) {
if (await Permission.locationWhenInUse.status.isGranted) { if (await Permission.locationWhenInUse.status.isGranted) {
getLocation(); await getLocation();
} else { } else {
queryStore(); await queryStore();
} }
} }
} }
@ -131,12 +129,12 @@ class UnionListState extends State<UnionList>
} }
} }
void refreshData(String areaName) { Future refreshData(String areaName) async {
this.cityName = areaName; this.cityName = areaName;
getLocation(); await getLocation();
} }
queryStore() async { Future queryStore() async {
apiService ??= ApiService( apiService ??= ApiService(
Dio(), Dio(),
context: context, context: context,
@ -154,6 +152,7 @@ class UnionListState extends State<UnionList>
_refreshController.refreshFailed(); _refreshController.refreshFailed();
return BaseListData<Store>()..isSuccess = false; return BaseListData<Store>()..isSuccess = false;
}); });
SmartDialog.dismiss(status: SmartStatus.loading, force: true);
if (baseData?.isSuccess ?? false) { if (baseData?.isSuccess ?? false) {
storeList = baseData!.data; storeList = baseData!.data;
_refreshController.refreshCompleted(); _refreshController.refreshCompleted();
@ -642,7 +641,7 @@ class UnionListState extends State<UnionList>
), ),
), ),
TextSpan( TextSpan(
text: "${(productShow?.price ?? "").split(".")[0]}", text: "${(productShow.price ?? "").split(".")[0]}",
style: TextStyle( style: TextStyle(
fontWeight: FontWeight.bold, fontWeight: FontWeight.bold,
fontSize: 16.sp, fontSize: 16.sp,

9
lib/union/union_page.dart

@ -96,7 +96,8 @@ class UnionPageState extends State<UnionPage> with AutomaticKeepAliveClientMixin
} }
queryIpInfo() async { 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) { String ipResult = await apiIpService.getIpInfo1().catchError((onError) {
return ""; return "";
}); });
@ -109,10 +110,10 @@ class UnionPageState extends State<UnionPage> with AutomaticKeepAliveClientMixin
} }
} }
refreshChild() { refreshChild() async {
if (areaName?.isNotEmpty ?? false) { if (areaName?.isNotEmpty ?? false) {
_allKey.forEach((key1) { await Future.forEach(_allKey, (key1) async {
key1.currentState?.refreshData(areaName!); await key1.currentState?.refreshData(areaName!);
}); });
} }
} }

39
lib/utils/flutter_utils.dart

@ -4,21 +4,11 @@ import 'dart:io';
import 'package:dio/dio.dart'; import 'package:dio/dio.dart';
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart'; import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
import 'package:huixiang/constant.dart';
import 'package:intl/intl.dart'; import 'package:intl/intl.dart';
import 'package:path_provider/path_provider.dart'; import 'package:path_provider/path_provider.dart';
class AppUtils { class AppUtils {
// ///线
// static Future<String> 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) { static double stringAsFixedDouble2(double value) {
@ -82,14 +72,6 @@ class AppUtils {
return resString; return resString;
} }
// ///()
// static Future<BMFCoordinate?> coordConvert(BMFCoordinate latLng) async {
// // return BMFCalculateUtils.coordConvert(
// // coordinate: latLng,
// // fromType: BMF_COORD_TYPE.COMMON,
// // toType: BMF_COORD_TYPE.BD09LL);
// }
static bool isPhone(mobile) { static bool isPhone(mobile) {
RegExp exp = RegExp( 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}$'); 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<String> 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);
}
} }

16
pubspec.lock

@ -1141,6 +1141,14 @@ packages:
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "1.5.1" 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: protobuf:
dependency: "direct main" dependency: "direct main"
description: description:
@ -1269,6 +1277,14 @@ packages:
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "1.6.0" 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: shared_preferences:
dependency: "direct main" dependency: "direct main"
description: description:

2
pubspec.yaml

@ -147,6 +147,8 @@ dependencies:
protobuf: ^3.1.0 protobuf: ^3.1.0
color_thief_dart: ^0.1.0 color_thief_dart: ^0.1.0
scrollview_observer: ^1.24.0
preload_page_view: ^0.2.0
dev_dependencies: dev_dependencies:
flutter_test: flutter_test:

Loading…
Cancel
Save