diff --git a/lib/base_state.dart b/lib/base_state.dart index 916e047a..74dd3e55 100644 --- a/lib/base_state.dart +++ b/lib/base_state.dart @@ -6,6 +6,9 @@ import 'package:shared_preferences/shared_preferences.dart'; abstract class BaseState extends State with WidgetsBindingObserver { + + int lastTime = DateTime.now().millisecondsSinceEpoch; + @override void dispose() { super.dispose(); @@ -20,8 +23,11 @@ abstract class BaseState extends State break; case AppLifecycleState.resumed: //从后台切换前台,界面可见 pushRoute(); + if(DateTime.now().millisecondsSinceEpoch - lastTime > 300000) + Navigator.of(context).popAndPushNamed('/router/main_page'); break; case AppLifecycleState.paused: // 界面不可见,后台 + lastTime = DateTime.now().millisecondsSinceEpoch; break; case AppLifecycleState.detached: // APP结束时调用 break; @@ -49,41 +55,41 @@ abstract class BaseState extends State if (pushMap != null) { String routeName = ""; Map params = {}; - switch (pushMap["typed"]) { - case 1: - routeName = "/router/store_detail_page"; - params["articleId"] = pushMap["info"]; - break; - case 2: - routeName = "/router/store_detail_page"; - params["activityId"] = pushMap["info"]; - break; - case 3: - routeName = "/router/store_order"; - params["id"] = pushMap["info"]; - params["tenant"] = pushMap["tenant"]; - params["storeName"] = pushMap["storeName"]; - break; - case 4: - routeName = "/router/integral_store_page"; - params["goodsId"] = pushMap["info"]; - break; - case 5: - routeName = "/router/order_details"; - params["id"] = pushMap["info"]; - break; - case 6: - routeName = "/router/community_details"; - params["businessId"] = pushMap["info"]; - break; - case 8: - routeName = "/router/mine_wallet"; - params["id"] = pushMap["info"]; - break; - case 9: - routeName = "/router/welfare_page"; - params["id"] = pushMap["info"]; - break; + switch (pushMap["typed"].toString()) { + case "1":case "ARTICLE": + routeName = "/router/web_page"; + params["articleId"] = pushMap["info"]; + break; + case "2":case "ACTIVITY": + routeName = "/router/web_page"; + params["activityId"] = pushMap["info"]; + break; + case "3":case "SHOP": + routeName = "/router/store_order"; + params["id"] = pushMap["info"]; + params["tenant"] = pushMap["tenant"]; + params["storeName"] = pushMap["storeName"]; + break; + case "4":case "CREDIT_GOODS": + routeName = "/router/integral_store_page"; + params["goodsId"] = pushMap["info"]; + break; + case "5":case "ORDER": + routeName = "/router/order_details"; + params["id"] = pushMap["info"]; + break; + case "6":case "MEMBER": + routeName = "/router/community_details"; + params["businessId"] = pushMap["info"]; + break; + case "8":case "WALLET": + routeName = "/router/mine_wallet"; + params["id"] = pushMap["info"]; + break; + case "9":case "WELFARE": + routeName = "/router/welfare_page"; + params["id"] = pushMap["info"]; + break; } sharedPreferences.setString("pushData", ""); print("xgPushClickAction: routeName: $routeName"); diff --git a/lib/main_page.dart b/lib/main_page.dart index 85b3f8e2..18c3518f 100644 --- a/lib/main_page.dart +++ b/lib/main_page.dart @@ -57,7 +57,7 @@ class _MainPage extends State with WidgetsBindingObserver { final GlobalKey vipPageKey = GlobalKey(); // List iconn; ApiService apiService; - + int lastTime = DateTime.now().millisecondsSinceEpoch; @override void dispose() { @@ -73,8 +73,11 @@ class _MainPage extends State with WidgetsBindingObserver { break; case AppLifecycleState.resumed: //从后台切换前台,界面可见 pushRoute(); + if(DateTime.now().millisecondsSinceEpoch - lastTime > 300000) + Navigator.of(context).popAndPushNamed('/router/main_page'); break; case AppLifecycleState.paused: // 界面不可见,后台 + lastTime = DateTime.now().millisecondsSinceEpoch; break; case AppLifecycleState.detached: // APP结束时调用 break; @@ -224,7 +227,7 @@ class _MainPage extends State with WidgetsBindingObserver { ); } - /// @typed: 1文章 2活动 3店铺 4积分商品 5订单 6动态 7用户 8平台余额/钱包 9福利中心 + /// @typed: ARTICLE(1)文章 ACTIVITY(2)活动 SHOP(3)店铺 CREDIT_GOODS(4)积分商品 ORDER(5)订单 TREND(6)动态 MEMBER(7)用户 WALLET(8)平台余额/钱包 WELFARE(9)福利中心 xgFlutterPlugin.addEventHandler(xgPushClickAction: (event) async { print("xgPushClickAction1: $event"); if (event["actionType"] == 2) return event; @@ -288,38 +291,38 @@ class _MainPage extends State with WidgetsBindingObserver { if (pushMap != null) { String routeName = ""; Map params = {}; - switch (pushMap["typed"]) { - case 1: + switch (pushMap["typed"].toString()) { + case "1":case "ARTICLE": routeName = "/router/web_page"; params["articleId"] = pushMap["info"]; break; - case 2: + case "2":case "ACTIVITY": routeName = "/router/web_page"; params["activityId"] = pushMap["info"]; break; - case 3: + case "3":case "SHOP": routeName = "/router/store_order"; params["id"] = pushMap["info"]; params["tenant"] = pushMap["tenant"]; params["storeName"] = pushMap["storeName"]; break; - case 4: + case "4":case "CREDIT_GOODS": routeName = "/router/integral_store_page"; params["goodsId"] = pushMap["info"]; break; - case 5: + case "5":case "ORDER": routeName = "/router/order_details"; params["id"] = pushMap["info"]; break; - case 6: + case "6":case "MEMBER": routeName = "/router/community_details"; params["businessId"] = pushMap["info"]; break; - case 8: + case "8":case "WALLET": routeName = "/router/mine_wallet"; params["id"] = pushMap["info"]; break; - case 9: + case "9":case "WELFARE": routeName = "/router/welfare_page"; params["id"] = pushMap["info"]; break; diff --git a/lib/message/system_message.dart b/lib/message/system_message.dart index b7de1f57..7312b58b 100644 --- a/lib/message/system_message.dart +++ b/lib/message/system_message.dart @@ -645,7 +645,7 @@ class _SystemMessagePage extends State { ? "assets/image/icon_system_message.webp" : (message.typed == 2) ? "assets/image/icon_system_message.webp" - : "assets/image/icon.webp", + : "assets/image/icon_cz.webp", width: 40.w, height: 40.h, ), diff --git a/lib/order/order_detail_page.dart b/lib/order/order_detail_page.dart index 5d215b07..a9fac982 100644 --- a/lib/order/order_detail_page.dart +++ b/lib/order/order_detail_page.dart @@ -39,17 +39,14 @@ class _OrderDetailPage extends State { ApiService apiService; MinApiService minService; int jumpState; + final RefreshController refreshController = RefreshController(); @override void initState() { super.initState(); SharedPreferences.getInstance().then((value) { - apiService = ApiService( - Dio(), - context: context, - token: value.getString("token"), - showLoading: true - ); + apiService = ApiService(Dio(), + context: context, token: value.getString("token"), showLoading: true); queryDetails(); }); jumpState = widget.arguments["jumpState"]; @@ -66,7 +63,7 @@ class _OrderDetailPage extends State { String tenant = orderInfo.tenantCode; String storeId = orderInfo.storeId; SharedPreferences.getInstance().then( - (value) => { + (value) => { value.setString('minToken', minToken), value.setString('tenant', tenant), value.setString('storeId', storeId), @@ -94,16 +91,19 @@ class _OrderDetailPage extends State { queryDetails() async { if (apiService == null) { SharedPreferences value = await SharedPreferences.getInstance(); - apiService = ApiService( - Dio(), + apiService = ApiService(Dio(), context: context, token: value.getString("token"), - showLoading: false - ); + showLoading: false); } BaseData baseData = await apiService .orderDetail(widget.arguments["id"]) - .catchError((error) {}); + .catchError((error) { + SmartDialog.showToast(AppUtils.dioErrorTypeToString(error.type), + alignment: Alignment.center); + refreshController.refreshFailed(); + refreshController.loadFailed(); + }); if (baseData != null && baseData.isSuccess) { orderInfo = baseData.data; payStatus = orderInfo.payStatus; @@ -123,8 +123,12 @@ class _OrderDetailPage extends State { setState(() { statusTitle(); }); - }else{ - SmartDialog.showToast(baseData.msg,alignment: Alignment.center); + refreshController.refreshCompleted(); + refreshController.loadComplete(); + } else { + SmartDialog.showToast(baseData.msg, alignment: Alignment.center); + refreshController.refreshFailed(); + refreshController.loadFailed(); } } @@ -159,52 +163,70 @@ class _OrderDetailPage extends State { leadingColor: Colors.white, brightness: Brightness.dark, ), - body: Container( - child: SingleChildScrollView( - physics: BouncingScrollPhysics(), - child: Container( - child: Column( - children: [ - ///订单状态显示 - OrderStatus( - orderStatus, - isTakeOut, - sendStatus, - payStatus, - refundStatus, - title, - center, - orderInfo, - ), - - ///订单取货地址,或, 收货地址 - if(orderInfo != null && orderInfo.addressExt != null) - OrderAddress( - orderStatus, - isTakeOut, - sendStatus, - payStatus, - refundStatus, - title, - center, - paySelected, - _orderCancel, - orderInfo, - jumpState + body: SmartRefresher( + controller: refreshController, + enablePullDown: true, + enablePullUp: false, + header: MyHeader(), + footer: CustomFooter( + builder: (context, mode) { + return MyFooter(mode); + }, + ), + onRefresh:(){ + setState(() { + queryDetails(); + }); + }, + physics: BouncingScrollPhysics(), + scrollController: ScrollController(), + child: Container( + child: SingleChildScrollView( + physics: BouncingScrollPhysics(), + child: Container( + child: Column( + children: [ + ///订单状态显示 + OrderStatus( + orderStatus, + isTakeOut, + sendStatus, + payStatus, + refundStatus, + title, + center, + orderInfo, ), - ///订单商品 - if(orderInfo != null) - OrderCommodity(orderInfo), + ///订单取货地址,或, 收货地址 + if(orderInfo != null && orderInfo.addressExt != null) + OrderAddress( + orderStatus, + isTakeOut, + sendStatus, + payStatus, + refundStatus, + title, + center, + paySelected, + _orderCancel, + orderInfo, + jumpState + ), - ///显示订单信息 - if(orderInfo != null) - OrderInfoView(orderInfo, isTakeOut), + ///订单商品 + if(orderInfo != null) + OrderCommodity(orderInfo), - Container( - height: 42.h, - ), - ], + ///显示订单信息 + if(orderInfo != null) + OrderInfoView(orderInfo, isTakeOut), + + Container( + height: 42.h, + ), + ], + ), ), ), ), diff --git a/lib/view_widget/classic_header.dart b/lib/view_widget/classic_header.dart index 1bb7cccc..c744ceef 100644 --- a/lib/view_widget/classic_header.dart +++ b/lib/view_widget/classic_header.dart @@ -11,6 +11,9 @@ import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:rive/rive.dart'; class MyHeader extends StatelessWidget { + final Color color; + MyHeader({this.color}); + @override Widget build(BuildContext context) { return MyClassicHeader( @@ -22,11 +25,11 @@ class MyHeader extends StatelessWidget { idleText: S.of(context).xialashuaxin, iconPos: IconPosition.left, completeTextStyle: TextStyle( - color: Color(0xFF32A060), + color:color?? Color(0xFF32A060), ), completeIcon: Icon( Icons.done, - color: Color(0xFF32A060), + color: color??Color(0xFF32A060), ), refreshingIcon: SpinKitCircle( color: Colors.grey,