From 4768dc0d6746ac30e4f01aa574c5ec3016eb47c3 Mon Sep 17 00:00:00 2001 From: laiiihz Date: Sat, 8 May 2021 16:34:38 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=86=E7=B1=BB=E9=A1=B5=E9=9D=A2=E6=9B=B4?= =?UTF-8?q?=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/constants/api.dart | 3 ++ lib/ui/market/category/category_card.dart | 18 +++++--- lib/ui/market/goods/goods_list_view.dart | 4 +- lib/ui/market/goods/goods_tab_list_view.dart | 46 ++++++++++++++++++++ 4 files changed, 63 insertions(+), 8 deletions(-) create mode 100644 lib/ui/market/goods/goods_tab_list_view.dart diff --git a/lib/constants/api.dart b/lib/constants/api.dart index 695e092b..1ce73d18 100644 --- a/lib/constants/api.dart +++ b/lib/constants/api.dart @@ -258,6 +258,9 @@ class _Community { class _Market { String get category => '/user/shop/findAllCategory'; + + ///app商城中心:根据分类主键id查询商品信息列表 + String get list => '/user/shop/findGoodsByCategoryId'; } class _Upload { diff --git a/lib/ui/market/category/category_card.dart b/lib/ui/market/category/category_card.dart index d8e02cf9..3a9c6d9e 100644 --- a/lib/ui/market/category/category_card.dart +++ b/lib/ui/market/category/category_card.dart @@ -1,7 +1,9 @@ import 'package:aku_community/constants/api.dart'; import 'package:aku_community/model/common/img_model.dart'; +import 'package:aku_community/models/market/display_category_model.dart'; import 'package:aku_community/models/market/market_category_model.dart'; import 'package:aku_community/ui/market/goods/goods_list_view.dart'; +import 'package:bot_toast/bot_toast.dart'; import 'package:flutter/material.dart'; import 'package:get/get.dart'; import 'package:aku_community/utils/headers.dart'; @@ -33,13 +35,15 @@ class CategoryCard extends StatelessWidget { Spacer(), ], ), - onPressed: () { - Get.to( - () => GoodsListView( - model: model, - subModels: [], - ), - ); + onPressed: () async { + final cancel = BotToast.showLoading(); + List models = + await DisplayCategoryModel.fetchCategory(model.id); + cancel(); + Get.to(() => GoodsListView( + model: model, + subModels: models, + )); }, ); } diff --git a/lib/ui/market/goods/goods_list_view.dart b/lib/ui/market/goods/goods_list_view.dart index 57b83713..4044a39b 100644 --- a/lib/ui/market/goods/goods_list_view.dart +++ b/lib/ui/market/goods/goods_list_view.dart @@ -2,6 +2,7 @@ import 'package:aku_community/base/base_style.dart'; import 'package:aku_community/constants/api.dart'; import 'package:aku_community/model/common/img_model.dart'; import 'package:aku_community/models/market/market_category_model.dart'; +import 'package:aku_community/ui/market/goods/goods_tab_list_view.dart'; import 'package:aku_community/ui/market/search/search_goods_page.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; @@ -91,8 +92,9 @@ class _GoodsListViewState extends State preferredSize: Size.fromHeight(220.w), ), body: TabBarView( - children: widget.subModels.map((e) => Text(e.name)).toList(), + children: widget.subModels.map((e) => GoodsTabListView(model: e)).toList(), controller: _tabController, + physics: NeverScrollableScrollPhysics(), ), ); } diff --git a/lib/ui/market/goods/goods_tab_list_view.dart b/lib/ui/market/goods/goods_tab_list_view.dart new file mode 100644 index 00000000..860cf57c --- /dev/null +++ b/lib/ui/market/goods/goods_tab_list_view.dart @@ -0,0 +1,46 @@ +import 'package:aku_community/constants/api.dart'; +import 'package:aku_community/models/market/goods_item.dart'; +import 'package:aku_community/models/market/market_category_model.dart'; +import 'package:aku_community/pages/things_page/widget/bee_list_view.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter_easyrefresh/easy_refresh.dart'; +import 'package:waterfall_flow/waterfall_flow.dart'; + +class GoodsTabListView extends StatefulWidget { + final MarketCategoryModel model; + GoodsTabListView({Key? key, required this.model}) : super(key: key); + + @override + _GoodsTabListViewState createState() => _GoodsTabListViewState(); +} + +class _GoodsTabListViewState extends State + with AutomaticKeepAliveClientMixin { + EasyRefreshController _refreshController = EasyRefreshController(); + @override + Widget build(BuildContext context) { + super.build(context); + return BeeListView( + path: API.market.list, + controller: _refreshController, + extraParams: {'categoryId': widget.model.id}, + convert: (model) => + model.tableList?.map((e) => GoodsItem.fromJson(e)).toList() ?? [], + builder: (items) { + return WaterfallFlow.builder( + gridDelegate: SliverWaterfallFlowDelegateWithFixedCrossAxisCount( + crossAxisCount: 2, + ), + itemBuilder: (context, index) { + final GoodsItem item = items[index]; + return Text(item.title); + }, + itemCount: items.length, + ); + }, + ); + } + + @override + bool get wantKeepAlive => true; +}