diff --git a/lib/constants/api.dart b/lib/constants/api.dart index 041c75b9..e356faba 100644 --- a/lib/constants/api.dart +++ b/lib/constants/api.dart @@ -264,6 +264,9 @@ class _Market { ///app商场中心:查询订阅量最高的4件商品(首页显示) String get hotTop => '/user/shop/findTopGoods'; + + ///app商城中心:商品搜索 + String get search => '/user/shop/goodsSearch'; } class _Upload { diff --git a/lib/ui/market/goods/goods_card.dart b/lib/ui/market/goods/goods_card.dart index 33ca2ddf..a8c39e61 100644 --- a/lib/ui/market/goods/goods_card.dart +++ b/lib/ui/market/goods/goods_card.dart @@ -1,3 +1,4 @@ +import 'package:aku_community/models/market/goods_item.dart'; import 'package:flutter/material.dart'; import 'package:get/get.dart'; @@ -7,7 +8,8 @@ import 'package:aku_community/ui/market/goods/goods_detail_page.dart'; import 'package:aku_community/utils/headers.dart'; class GoodsCard extends StatelessWidget { - const GoodsCard({Key? key}) : super(key: key); + final GoodsItem item; + const GoodsCard({Key? key, required this.item}) : super(key: key); @override Widget build(BuildContext context) { @@ -37,7 +39,7 @@ class GoodsCard extends StatelessWidget { alignment: Alignment.centerLeft, padding: EdgeInsets.symmetric(horizontal: 12.w), child: Text( - '分别是紫色烦恼则妇女色泽封闭周四鹅u部分紫色部分', + item.recommend, overflow: TextOverflow.ellipsis, style: TextStyle( color: Colors.white, @@ -55,7 +57,7 @@ class GoodsCard extends StatelessWidget { vertical: 20.w, ), child: Text( - '袁隆平水稻大米精选 56kg唇齿流香 无常有机稻花 无常有机稻花', + item.title, maxLines: 2, overflow: TextOverflow.ellipsis, style: TextStyle( @@ -71,17 +73,18 @@ class GoodsCard extends StatelessWidget { text: TextSpan( children: [ TextSpan( - text: '¥123.45 ', + text: '¥${item.sellingPrice} ', style: TextStyle( color: Colors.red, fontSize: 28.sp, ), ), TextSpan( - text: '123已付款', + text: '${item.markingPrice}', style: TextStyle( color: ktextSubColor, fontSize: 20.sp, + decoration: TextDecoration.lineThrough, ), ), ], diff --git a/lib/ui/market/goods/goods_tab_list_view.dart b/lib/ui/market/goods/goods_tab_list_view.dart index 970688ac..1cae0521 100644 --- a/lib/ui/market/goods/goods_tab_list_view.dart +++ b/lib/ui/market/goods/goods_tab_list_view.dart @@ -1,14 +1,14 @@ -import 'package:aku_community/ui/market/goods/goods_detail_page.dart'; +import 'package:aku_community/ui/market/goods/goods_card.dart'; import 'package:flutter/material.dart'; import 'package:flutter_easyrefresh/easy_refresh.dart'; -import 'package:get/get.dart'; import 'package:waterfall_flow/waterfall_flow.dart'; 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:aku_community/utils/headers.dart'; class GoodsTabListView extends StatefulWidget { final MarketCategoryModel model; @@ -32,17 +32,13 @@ class _GoodsTabListViewState extends State model.tableList?.map((e) => GoodsItem.fromJson(e)).toList() ?? [], builder: (items) { return WaterfallFlow.builder( + padding: EdgeInsets.all(32.w), gridDelegate: SliverWaterfallFlowDelegateWithFixedCrossAxisCount( crossAxisCount: 2, ), itemBuilder: (context, index) { final GoodsItem item = items[index]; - return MaterialButton( - onPressed: () { - Get.to(() => GoodsDetailPage(id: widget.model.id)); - }, - child: Text(item.title), - ); + return GoodsCard(item: item); }, itemCount: items.length, ); diff --git a/lib/ui/market/search/search_goods_page.dart b/lib/ui/market/search/search_goods_page.dart index 0d3b0e83..5315cc47 100644 --- a/lib/ui/market/search/search_goods_page.dart +++ b/lib/ui/market/search/search_goods_page.dart @@ -1,5 +1,9 @@ +import 'package:aku_community/constants/api.dart'; +import 'package:aku_community/models/market/goods_item.dart'; +import 'package:aku_community/pages/things_page/widget/bee_list_view.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; +import 'package:flutter_easyrefresh/easy_refresh.dart'; import 'package:waterfall_flow/waterfall_flow.dart'; @@ -26,6 +30,14 @@ class SearchGoodsPageState extends State { TextEditingController _editingController = TextEditingController(); OrderType _orderType = OrderType.NORMAL; IconData priceIcon = CupertinoIcons.chevron_up_chevron_down; + EasyRefreshController _refreshController = EasyRefreshController(); + + @override + void dispose() { + _refreshController.dispose(); + super.dispose(); + } + @override Widget build(BuildContext context) { final normalTypeButton = MaterialButton( @@ -108,6 +120,10 @@ class SearchGoodsPageState extends State { title: Padding( padding: EdgeInsets.symmetric(vertical: 12.w), child: TextField( + onEditingComplete: () { + setState(() {}); + _refreshController.callRefresh(); + }, controller: _editingController, decoration: InputDecoration( border: OutlineInputBorder( @@ -131,17 +147,27 @@ class SearchGoodsPageState extends State { // ), // preferredSize: Size.fromHeight(80.w), // ), - body: WaterfallFlow.builder( - padding: EdgeInsets.all(32.w), - gridDelegate: SliverWaterfallFlowDelegateWithFixedCrossAxisCount( - crossAxisCount: 2, - mainAxisSpacing: 20.w, - crossAxisSpacing: 20.w, - ), - itemBuilder: (context, index) { - return GoodsCard(); + body: BeeListView( + path: API.market.search, + controller: _refreshController, + extraParams: {'searchName': _editingController.text}, + convert: (model) => + model.tableList!.map((e) => GoodsItem.fromJson(e)).toList(), + builder: (items) { + return WaterfallFlow.builder( + padding: EdgeInsets.all(32.w), + gridDelegate: SliverWaterfallFlowDelegateWithFixedCrossAxisCount( + crossAxisCount: 2, + mainAxisSpacing: 20.w, + crossAxisSpacing: 20.w, + ), + itemBuilder: (context, index) { + final item = items[index]; + return GoodsCard(item: item); + }, + itemCount: items.length, + ); }, - itemCount: 10, ), ); }