diff --git a/lib/constants/api.dart b/lib/constants/api.dart index 5e78c0be..a0fb3338 100644 --- a/lib/constants/api.dart +++ b/lib/constants/api.dart @@ -196,7 +196,7 @@ class _Manager { String get articleReturnGoods => '/user/articleBorrow/articleReturn'; ///借还管理:根据用户主键id查询需要归还物品信息(归还界面) - String get articleReturnList => '/user/articleBorrow/articleReturn'; + String get articleReturnList => '/user/articleBorrow/findBorrowByUserId'; ///生活缴费:查询生活缴费信息list String get dailyPaymentList => '/user/dailyPayment/list'; @@ -330,6 +330,9 @@ class _Market { ///app商场中心:查询订阅量最高的4件商品(首页显示) String get hotTop => '/user/shop/findTopGoods'; + ///app商城中心:根据供应商主键id 查询预约量最高的4个商品信息(其他【4个】) + String get suppliyerHotTop => '/user/shop/findTopGoodsBySupplierId'; + ///app商城中心:商品搜索 String get search => '/user/shop/goodsSearch'; diff --git a/lib/pages/goods_manage_page/borrow/borrow_finsh_page.dart b/lib/pages/goods_manage_page/borrow/borrow_finsh_page.dart index 71e9a0aa..13c9cc04 100644 --- a/lib/pages/goods_manage_page/borrow/borrow_finsh_page.dart +++ b/lib/pages/goods_manage_page/borrow/borrow_finsh_page.dart @@ -61,7 +61,7 @@ class _BorrowFinshPageState extends State { minWidth: double.infinity, onPressed: widget.isSuccess! ? () { - Get.offAll(TabNavigator()); + Get.offAll(()=>TabNavigator()); } : () { Get.back(); diff --git a/lib/pages/things_page/widget/add_fixed_submit_page.dart b/lib/pages/things_page/widget/add_fixed_submit_page.dart index 27f4528c..bf34cd64 100644 --- a/lib/pages/things_page/widget/add_fixed_submit_page.dart +++ b/lib/pages/things_page/widget/add_fixed_submit_page.dart @@ -198,7 +198,7 @@ class _AddFixedSubmitPageState extends State { _textEditingController!.text, urls); if (baseModel.status!) { - Get.off(FinishFixedSubmitPage()); + Get.off(()=>FinishFixedSubmitPage()); } else BotToast.showText(text: baseModel.message!); cancel(); diff --git a/lib/ui/market/goods/goods_detail_page.dart b/lib/ui/market/goods/goods_detail_page.dart index 4726d23b..7f0dbdf5 100644 --- a/lib/ui/market/goods/goods_detail_page.dart +++ b/lib/ui/market/goods/goods_detail_page.dart @@ -93,7 +93,7 @@ class _GoodsDetailPageState extends State { _goodsModel = GoodsDetailModel.fail(); BotToast.showText(text: baseModel.message ?? '未知错误'); } - baseModel = await NetUtil().get(API.market.hotTop); + baseModel = await NetUtil().get(API.market.suppliyerHotTop); if (baseModel.status == true && baseModel.data != null) { _topGoods = (baseModel.data as List) .map((e) => GoodsItem.fromJson(e)) @@ -178,7 +178,7 @@ class _GoodsDetailPageState extends State { onPressed: () { if (!UserTool.userProvider.isLogin) { BotToast.showText(text: '请先登录!'); - Get.offAll(SignInPage()); + Get.offAll(()=>SignInPage()); return; } Get.bottomSheet(Material( diff --git a/lib/ui/market/goods/goods_tab_list_view.dart b/lib/ui/market/goods/goods_tab_list_view.dart index 6f0085d7..0c60f9e0 100644 --- a/lib/ui/market/goods/goods_tab_list_view.dart +++ b/lib/ui/market/goods/goods_tab_list_view.dart @@ -35,6 +35,8 @@ class _GoodsTabListViewState extends State padding: EdgeInsets.all(32.w), gridDelegate: SliverWaterfallFlowDelegateWithFixedCrossAxisCount( crossAxisCount: 2, + crossAxisSpacing: 24.w, + mainAxisSpacing: 24.w ), itemBuilder: (context, index) { final GoodsItem item = items[index]; diff --git a/lib/ui/market/market_page.dart b/lib/ui/market/market_page.dart index c3411046..d29bf4f4 100644 --- a/lib/ui/market/market_page.dart +++ b/lib/ui/market/market_page.dart @@ -1,9 +1,11 @@ // import 'package:aku_community/base/base_style.dart'; +import 'package:aku_community/utils/network/base_list_model.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:bot_toast/bot_toast.dart'; +import 'package:flutter_easyrefresh/easy_refresh.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:get/get.dart'; import 'package:waterfall_flow/waterfall_flow.dart'; @@ -18,7 +20,6 @@ import 'package:aku_community/ui/market/goods/goods_card.dart'; import 'package:aku_community/ui/market/order/my_order_page.dart'; import 'package:aku_community/ui/market/search/search_goods_page.dart'; import 'package:aku_community/utils/headers.dart'; -import 'package:aku_community/utils/network/base_model.dart'; import 'package:aku_community/utils/network/net_util.dart'; import 'package:aku_community/widget/bee_scaffold.dart'; @@ -37,24 +38,55 @@ class _MarketPageState extends State with AutomaticKeepAliveClientMixin { List _marketModels = []; List _hotItems = []; + late EasyRefreshController _refreshController; + int _pageNum = 1; + int _size = 4; Future updateMarketInfo() async { - _marketModels = await DisplayCategoryModel.top8; - BaseModel baseModel = await NetUtil().get(API.market.hotTop); - if (baseModel.status == true && baseModel.data != null) { - _hotItems = - (baseModel.data as List).map((e) => GoodsItem.fromJson(e)).toList(); + BaseListModel baseListModel = + await NetUtil().getList(API.market.hotTop, params: { + "pageNum": _pageNum, + "size": _size, + }); + if (baseListModel.tableList!.isNotEmpty) { + _hotItems = (baseListModel.tableList as List) + .map((e) => GoodsItem.fromJson(e)) + .toList(); + } + return baseListModel.pageCount; + } + + Future loadMarketInfo() async { + BaseListModel baseListModel = + await NetUtil().getList(API.market.hotTop, params: { + "pageNum": _pageNum, + "size": _size, + }); + if (baseListModel.tableList!.isNotEmpty) { + _hotItems.addAll((baseListModel.tableList as List) + .map((e) => GoodsItem.fromJson(e)) + .toList()); } + return baseListModel.pageCount; } @override void initState() { super.initState(); - updateMarketInfo().then((_) { - setState(() {}); + _refreshController = EasyRefreshController(); + DisplayCategoryModel.top8.then((value) { + setState(() { + _marketModels = value; + }); }); } + @override + void dispose() { + _refreshController.dispose(); + super.dispose(); + } + @override Widget build(BuildContext context) { super.build(context); @@ -224,18 +256,38 @@ class _MarketPageState extends State ), ]; }, - body: WaterfallFlow.builder( - gridDelegate: SliverWaterfallFlowDelegateWithFixedCrossAxisCount( - crossAxisCount: 2, - mainAxisSpacing: 20.w, - crossAxisSpacing: 20.w, - ), - padding: EdgeInsets.all(32.w), - itemBuilder: (context, index) { - final item = _hotItems[index]; - return GoodsCard(item: item); + body: EasyRefresh( + firstRefresh: true, + enableControlFinishLoad: true, + header: MaterialHeader(), + footer: MaterialFooter(), + controller: _refreshController, + onRefresh: () async { + _pageNum = 1; + updateMarketInfo(); + setState(() {}); }, - itemCount: _hotItems.length, + onLoad: () async { + _pageNum++; + int _pageCount = await loadMarketInfo(); + if (_pageCount !=_pageNum) { + _refreshController.finishLoad(); + } + setState(() {}); + }, + child: WaterfallFlow.builder( + gridDelegate: SliverWaterfallFlowDelegateWithFixedCrossAxisCount( + crossAxisCount: 2, + mainAxisSpacing: 20.w, + crossAxisSpacing: 20.w, + ), + padding: EdgeInsets.all(32.w), + itemBuilder: (context, index) { + final item = _hotItems[index]; + return GoodsCard(item: item); + }, + itemCount: _hotItems.length, + ), ), ), ); diff --git a/lib/ui/market/order/my_order_func.dart b/lib/ui/market/order/my_order_func.dart index e53f5903..deb69ba9 100644 --- a/lib/ui/market/order/my_order_func.dart +++ b/lib/ui/market/order/my_order_func.dart @@ -38,9 +38,9 @@ class MyOrderFunc { return baseModel; } - /// 获取热度最高的商品 + /// 获取此供应商热度最高的商品 static Future> getHotTops() async { - BaseModel baseModel = await NetUtil().get(API.market.hotTop); + BaseModel baseModel = await NetUtil().get(API.market.suppliyerHotTop); if (baseModel.status == true && baseModel.data != null) { return (baseModel.data as List) .map((e) => GoodsItem.fromJson(e)) diff --git a/lib/utils/network/net_util.dart b/lib/utils/network/net_util.dart index 8ee29a75..86832d5b 100644 --- a/lib/utils/network/net_util.dart +++ b/lib/utils/network/net_util.dart @@ -167,7 +167,7 @@ class NetUtil { final userProvider = Provider.of(Get.context!, listen: false); if (!model.status! && model.message == '登录失效,请登录' && userProvider.isLogin) { userProvider.logout(); - Get.offAll(SignInPage()); + Get.offAll(()=>SignInPage()); } if (!model.status! || showMessage) { BotToast.showText(text: model.message!);