diff --git a/lib/home/home_page.dart b/lib/home/home_page.dart index ef10a954..6d0b0e76 100644 --- a/lib/home/home_page.dart +++ b/lib/home/home_page.dart @@ -94,7 +94,6 @@ class HomePageState extends State with AutomaticKeepAliveClientMixin { @override void initState() { super.initState(); - eventBus.on().listen((event) { if (event.type < 3) { setState(() {}); @@ -169,6 +168,9 @@ class HomePageState extends State with AutomaticKeepAliveClientMixin { if (baseData != null && baseData.isSuccess) { bannerData = baseData.data.records; // if (bannerData.length > 0) swiperController.move(0, animation: false); + SharedPreferences.getInstance().then((value) { + value.setString("bannerData", jsonEncode(bannerData)); + }); } } finally { addLoadCount(); @@ -260,7 +262,9 @@ class HomePageState extends State with AutomaticKeepAliveClientMixin { "state": 1 }; BaseData> pageGoods = - await apiService.creditGoods(param).catchError((onError) {}); + await apiService.creditGoods(param).catchError((onError) { + debugPrint("error${onError}"); + }); if (pageGoods != null && pageGoods.isSuccess) { goods = pageGoods.data.list; } @@ -358,6 +362,11 @@ class HomePageState extends State with AutomaticKeepAliveClientMixin { context: context, token: value.getString("token"), ); + if (value.getString("bannerData") != null) { + bannerData = jsonDecode(value.getString("bannerData")).map((i) => BannerData.fromJson(i as Map)) + .toList(); + setState(() {}); + } } dioErrorType = null; if (isFirstIn) queryActivity(); diff --git a/lib/mine/mine_shop_page.dart b/lib/mine/mine_shop_page.dart index 3a496fd4..67e1017c 100644 --- a/lib/mine/mine_shop_page.dart +++ b/lib/mine/mine_shop_page.dart @@ -177,7 +177,7 @@ class _MineShopPage extends State with WidgetsBindingObserver{ : NoDataView( src: "assets/image/icon_empty.webp", isShowBtn: false, - text: "还没有会员卡~", + text: "没有找到相应的门店,试试其他的搜索~", fontSize: 16.sp, margin: EdgeInsets.only(top: 120.h), )), diff --git a/lib/store/shop_details_page.dart b/lib/store/shop_details_page.dart index 8c1d3a57..af7c01d2 100644 --- a/lib/store/shop_details_page.dart +++ b/lib/store/shop_details_page.dart @@ -1,3 +1,5 @@ +import 'dart:convert'; + import 'package:dio/dio.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; @@ -115,13 +117,18 @@ class _ShopDetailsPage extends State { queryStoreInfo() async { EasyLoading.show( status: S.current.zhengzaijiazai, maskType: EasyLoadingMaskType.black); - SharedPreferences value = await SharedPreferences.getInstance(); - if (apiService == null) + if (apiService == null){ + SharedPreferences value = await SharedPreferences.getInstance(); apiService = ApiService( Dio(), context: context, token: value.getString("token"), ); + if (value.getString("miNiDetail${id}") != null) { + miNiDetail = MiNiDetail.fromJson(jsonDecode(value.getString('miNiDetail${id}'))); + setState(() {}); + } + } BaseData baseData = await apiService.queryStoreInfo(storeId).catchError((error) { debugPrint(error); @@ -186,6 +193,11 @@ class _ShopDetailsPage extends State { selectSkus.add(element.attrValueList[0].attrValue); }); }); + SharedPreferences.getInstance().then( + (value) => { + value.setString('miNiDetail${id}', jsonEncode(baseData.data)), + }, + ); EasyLoading.dismiss(); refreshController.refreshCompleted(); } else { @@ -686,10 +698,14 @@ class _ShopDetailsPage extends State { style: { 'body': Style( backgroundColor: Colors.white, - padding: EdgeInsets.all(0), + padding: EdgeInsets.symmetric(horizontal:12.w), + fontSize: FontSize(14.sp), + lineHeight: LineHeight.rem(1.5), margin: EdgeInsets.all(0)), 'p': Style( margin: EdgeInsets.all(0), + fontSize: FontSize(14.sp), + lineHeight: LineHeight.rem(1.5), padding: EdgeInsets.all(0), ), }, diff --git a/lib/store/store_order.dart b/lib/store/store_order.dart index 9b04c52e..79956e0b 100644 --- a/lib/store/store_order.dart +++ b/lib/store/store_order.dart @@ -76,7 +76,7 @@ class _StoreOrderPage extends State @override void initState() { super.initState(); - + _onRefresh(); tableId = widget.arguments["tableId"] ?? 0; tenant = widget.arguments["tenant"]; storeId = widget.arguments["id"]; @@ -90,9 +90,19 @@ class _StoreOrderPage extends State vsync: this, ); - SharedPreferences.getInstance().then((value) { - minLogin(value); - }); + // SharedPreferences.getInstance().then((value) { + // minLogin(value); + // }); + + } + + _onRefresh() async{ + SharedPreferences value = await SharedPreferences.getInstance(); + if (value.getString("storeInfo_${storeId}") != null) { + storeInfo = StoreInfo.fromJson(jsonDecode(value.getString('storeInfo_${storeId}'))); + setState(() {}); + } + minLogin(value); } /// 小程序登录 @@ -205,6 +215,11 @@ class _StoreOrderPage extends State if (mounted) { setState(() {}); } + SharedPreferences.getInstance().then( + (value) => { + value.setString('storeInfo_${storeId}', jsonEncode(baseData.data)), + }, + ); } } diff --git a/lib/store/store_view/store_order_list.dart b/lib/store/store_view/store_order_list.dart index 8a9190ce..85d2cb27 100644 --- a/lib/store/store_view/store_order_list.dart +++ b/lib/store/store_view/store_order_list.dart @@ -1,3 +1,5 @@ +import 'dart:convert'; + import 'package:dio/dio.dart'; import 'package:flutter/material.dart'; import 'package:flutter_smart_dialog/flutter_smart_dialog.dart'; @@ -65,6 +67,7 @@ class _StoreOrderListPage extends State { @override void initState() { super.initState(); + _onRefresh(); controller.addListener(() { _viewportDimension = controller.position.viewportDimension; for (int i = 0; i < appletProducts.length; i++) { @@ -79,19 +82,29 @@ class _StoreOrderListPage extends State { } } }); + + } + + _onRefresh() async { + if (minService == null) { + SharedPreferences value = await SharedPreferences.getInstance(); + minService = MinApiService(Dio(), + context: context, + token: widget.minToken, + tenant: widget.tenant, + storeId: widget.arguments["id"], + showLoading: true); + if (value.getString("appletProducts_${widget.arguments["id"]}") != null) { + appletProducts = jsonDecode(value.getString("appletProducts_${widget.arguments["id"]}")).map((i) => FindMiNiGroupList.fromJson(i as Map)) + .toList(); + setState(() {}); + } + } appletGoods(); } ///小程序查询分组及商品列表 appletGoods() async { - SharedPreferences value = await SharedPreferences.getInstance(); - minService = MinApiService(Dio(), - context: context, - token: widget.minToken, - tenant: widget.tenant, - storeId: widget.arguments["id"], - showLoading: true); - BaseData> baseData = await minService.findMiNiGroupList({ "id": widget.arguments["id"], @@ -105,6 +118,9 @@ class _StoreOrderListPage extends State { // refreshController.refreshCompleted(); setState(() { appletProducts = baseData.data ?? []; + SharedPreferences.getInstance().then((value) { + value.setString("appletProducts_${widget.arguments["id"]}", jsonEncode(appletProducts)); + }); // productListBeans.clear(); // if (appletProducts.length > 0) // productListBeans.addAll(appletProducts[isSelected].productList); @@ -115,6 +131,7 @@ class _StoreOrderListPage extends State { goodsIndex += element.height; }); }); + } else { // refreshController.refreshFailed(); }