商城首页添加分页 样式改为瀑布流

修复 分类目录下 瀑布流间距问题
更改商品详情 订单详情类目下热门商品为 此供应商热门商品
hmxc
张萌 4 years ago
parent 8312a0ad43
commit d49a8bcc0c

@ -196,7 +196,7 @@ class _Manager {
String get articleReturnGoods => '/user/articleBorrow/articleReturn'; String get articleReturnGoods => '/user/articleBorrow/articleReturn';
///id ///id
String get articleReturnList => '/user/articleBorrow/articleReturn'; String get articleReturnList => '/user/articleBorrow/findBorrowByUserId';
///list ///list
String get dailyPaymentList => '/user/dailyPayment/list'; String get dailyPaymentList => '/user/dailyPayment/list';
@ -330,6 +330,9 @@ class _Market {
///app4 ///app4
String get hotTop => '/user/shop/findTopGoods'; String get hotTop => '/user/shop/findTopGoods';
///appid 4(4)
String get suppliyerHotTop => '/user/shop/findTopGoodsBySupplierId';
///app ///app
String get search => '/user/shop/goodsSearch'; String get search => '/user/shop/goodsSearch';

@ -61,7 +61,7 @@ class _BorrowFinshPageState extends State<BorrowFinshPage> {
minWidth: double.infinity, minWidth: double.infinity,
onPressed: widget.isSuccess! onPressed: widget.isSuccess!
? () { ? () {
Get.offAll(TabNavigator()); Get.offAll(()=>TabNavigator());
} }
: () { : () {
Get.back(); Get.back();

@ -198,7 +198,7 @@ class _AddFixedSubmitPageState extends State<AddFixedSubmitPage> {
_textEditingController!.text, _textEditingController!.text,
urls); urls);
if (baseModel.status!) { if (baseModel.status!) {
Get.off(FinishFixedSubmitPage()); Get.off(()=>FinishFixedSubmitPage());
} else } else
BotToast.showText(text: baseModel.message!); BotToast.showText(text: baseModel.message!);
cancel(); cancel();

@ -93,7 +93,7 @@ class _GoodsDetailPageState extends State<GoodsDetailPage> {
_goodsModel = GoodsDetailModel.fail(); _goodsModel = GoodsDetailModel.fail();
BotToast.showText(text: baseModel.message ?? '未知错误'); 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) { if (baseModel.status == true && baseModel.data != null) {
_topGoods = (baseModel.data as List) _topGoods = (baseModel.data as List)
.map((e) => GoodsItem.fromJson(e)) .map((e) => GoodsItem.fromJson(e))
@ -178,7 +178,7 @@ class _GoodsDetailPageState extends State<GoodsDetailPage> {
onPressed: () { onPressed: () {
if (!UserTool.userProvider.isLogin) { if (!UserTool.userProvider.isLogin) {
BotToast.showText(text: '请先登录!'); BotToast.showText(text: '请先登录!');
Get.offAll(SignInPage()); Get.offAll(()=>SignInPage());
return; return;
} }
Get.bottomSheet(Material( Get.bottomSheet(Material(

@ -35,6 +35,8 @@ class _GoodsTabListViewState extends State<GoodsTabListView>
padding: EdgeInsets.all(32.w), padding: EdgeInsets.all(32.w),
gridDelegate: SliverWaterfallFlowDelegateWithFixedCrossAxisCount( gridDelegate: SliverWaterfallFlowDelegateWithFixedCrossAxisCount(
crossAxisCount: 2, crossAxisCount: 2,
crossAxisSpacing: 24.w,
mainAxisSpacing: 24.w
), ),
itemBuilder: (context, index) { itemBuilder: (context, index) {
final GoodsItem item = items[index]; final GoodsItem item = items[index];

@ -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,22 +38,53 @@ 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
@ -224,7 +256,26 @@ class _MarketPageState extends State<MarketPage>
), ),
]; ];
}, },
body: WaterfallFlow.builder( body: EasyRefresh(
firstRefresh: true,
enableControlFinishLoad: true,
header: MaterialHeader(),
footer: MaterialFooter(),
controller: _refreshController,
onRefresh: () async {
_pageNum = 1;
updateMarketInfo();
setState(() {});
},
onLoad: () async {
_pageNum++;
int _pageCount = await loadMarketInfo();
if (_pageCount !=_pageNum) {
_refreshController.finishLoad();
}
setState(() {});
},
child: WaterfallFlow.builder(
gridDelegate: SliverWaterfallFlowDelegateWithFixedCrossAxisCount( gridDelegate: SliverWaterfallFlowDelegateWithFixedCrossAxisCount(
crossAxisCount: 2, crossAxisCount: 2,
mainAxisSpacing: 20.w, mainAxisSpacing: 20.w,
@ -238,6 +289,7 @@ class _MarketPageState extends State<MarketPage>
itemCount: _hotItems.length, itemCount: _hotItems.length,
), ),
), ),
),
); );
} }

@ -38,9 +38,9 @@ class MyOrderFunc {
return baseModel; return baseModel;
} }
/// ///
static Future<List<GoodsItem>> getHotTops() async { static Future<List<GoodsItem>> 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) { if (baseModel.status == true && baseModel.data != null) {
return (baseModel.data as List) return (baseModel.data as List)
.map((e) => GoodsItem.fromJson(e)) .map((e) => GoodsItem.fromJson(e))

@ -167,7 +167,7 @@ class NetUtil {
final userProvider = Provider.of<UserProvider>(Get.context!, listen: false); final userProvider = Provider.of<UserProvider>(Get.context!, listen: false);
if (!model.status! && model.message == '登录失效,请登录' && userProvider.isLogin) { if (!model.status! && model.message == '登录失效,请登录' && userProvider.isLogin) {
userProvider.logout(); userProvider.logout();
Get.offAll(SignInPage()); Get.offAll(()=>SignInPage());
} }
if (!model.status! || showMessage) { if (!model.status! || showMessage) {
BotToast.showText(text: model.message!); BotToast.showText(text: model.message!);

Loading…
Cancel
Save