|
|
@ -1,9 +1,11 @@
|
|
|
|
// import 'package:aku_community/base/base_style.dart';
|
|
|
|
// 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/cupertino.dart';
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
|
|
|
|
|
|
|
|
import 'package:bot_toast/bot_toast.dart';
|
|
|
|
import 'package:bot_toast/bot_toast.dart';
|
|
|
|
|
|
|
|
import 'package:flutter_easyrefresh/easy_refresh.dart';
|
|
|
|
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
|
|
|
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
|
|
|
import 'package:get/get.dart';
|
|
|
|
import 'package:get/get.dart';
|
|
|
|
import 'package:waterfall_flow/waterfall_flow.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/order/my_order_page.dart';
|
|
|
|
import 'package:aku_community/ui/market/search/search_goods_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/headers.dart';
|
|
|
|
import 'package:aku_community/utils/network/base_model.dart';
|
|
|
|
|
|
|
|
import 'package:aku_community/utils/network/net_util.dart';
|
|
|
|
import 'package:aku_community/utils/network/net_util.dart';
|
|
|
|
import 'package:aku_community/widget/bee_scaffold.dart';
|
|
|
|
import 'package:aku_community/widget/bee_scaffold.dart';
|
|
|
|
|
|
|
|
|
|
|
@ -37,24 +38,55 @@ class _MarketPageState extends State<MarketPage>
|
|
|
|
with AutomaticKeepAliveClientMixin {
|
|
|
|
with AutomaticKeepAliveClientMixin {
|
|
|
|
List<MarketCategoryModel> _marketModels = [];
|
|
|
|
List<MarketCategoryModel> _marketModels = [];
|
|
|
|
List<GoodsItem> _hotItems = [];
|
|
|
|
List<GoodsItem> _hotItems = [];
|
|
|
|
|
|
|
|
late EasyRefreshController _refreshController;
|
|
|
|
|
|
|
|
int _pageNum = 1;
|
|
|
|
|
|
|
|
int _size = 4;
|
|
|
|
|
|
|
|
|
|
|
|
Future updateMarketInfo() async {
|
|
|
|
Future updateMarketInfo() async {
|
|
|
|
_marketModels = await DisplayCategoryModel.top8;
|
|
|
|
BaseListModel baseListModel =
|
|
|
|
BaseModel baseModel = await NetUtil().get(API.market.hotTop);
|
|
|
|
await NetUtil().getList(API.market.hotTop, params: {
|
|
|
|
if (baseModel.status == true && baseModel.data != null) {
|
|
|
|
"pageNum": _pageNum,
|
|
|
|
_hotItems =
|
|
|
|
"size": _size,
|
|
|
|
(baseModel.data as List).map((e) => GoodsItem.fromJson(e)).toList();
|
|
|
|
});
|
|
|
|
|
|
|
|
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
|
|
|
|
@override
|
|
|
|
void initState() {
|
|
|
|
void initState() {
|
|
|
|
super.initState();
|
|
|
|
super.initState();
|
|
|
|
updateMarketInfo().then((_) {
|
|
|
|
_refreshController = EasyRefreshController();
|
|
|
|
setState(() {});
|
|
|
|
DisplayCategoryModel.top8.then((value) {
|
|
|
|
|
|
|
|
setState(() {
|
|
|
|
|
|
|
|
_marketModels = value;
|
|
|
|
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
|
|
|
void dispose() {
|
|
|
|
|
|
|
|
_refreshController.dispose();
|
|
|
|
|
|
|
|
super.dispose();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
super.build(context);
|
|
|
|
super.build(context);
|
|
|
@ -224,18 +256,38 @@ class _MarketPageState extends State<MarketPage>
|
|
|
|
),
|
|
|
|
),
|
|
|
|
];
|
|
|
|
];
|
|
|
|
},
|
|
|
|
},
|
|
|
|
body: WaterfallFlow.builder(
|
|
|
|
body: EasyRefresh(
|
|
|
|
gridDelegate: SliverWaterfallFlowDelegateWithFixedCrossAxisCount(
|
|
|
|
firstRefresh: true,
|
|
|
|
crossAxisCount: 2,
|
|
|
|
enableControlFinishLoad: true,
|
|
|
|
mainAxisSpacing: 20.w,
|
|
|
|
header: MaterialHeader(),
|
|
|
|
crossAxisSpacing: 20.w,
|
|
|
|
footer: MaterialFooter(),
|
|
|
|
),
|
|
|
|
controller: _refreshController,
|
|
|
|
padding: EdgeInsets.all(32.w),
|
|
|
|
onRefresh: () async {
|
|
|
|
itemBuilder: (context, index) {
|
|
|
|
_pageNum = 1;
|
|
|
|
final item = _hotItems[index];
|
|
|
|
updateMarketInfo();
|
|
|
|
return GoodsCard(item: item);
|
|
|
|
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,
|
|
|
|
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
);
|
|
|
|