From f97a720d564aa860bcb19e30f62693ead8d1b1d9 Mon Sep 17 00:00:00 2001 From: wurong <953969641@qq.com> Date: Thu, 28 Sep 2023 18:30:58 +0800 Subject: [PATCH] =?UTF-8?q?=E5=95=86=E5=93=81=E5=88=97=E8=A1=A8=E5=9C=A8?= =?UTF-8?q?=E5=94=AE=E4=B8=AD=E6=9B=B4=E6=94=B9=EF=BC=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../goods/goods_search_page.dart | 1 + .../goods/on_sale/batch_shelf.dart | 61 +-- .../goods/on_sale/goods_sort.dart | 3 + .../goods/on_sale/on_sale_page.dart | 377 ++++++++++-------- lib/main.dart | 4 +- 5 files changed, 253 insertions(+), 193 deletions(-) diff --git a/lib/business_system/goods/goods_search_page.dart b/lib/business_system/goods/goods_search_page.dart index a0a1ce1f..632bbeb6 100644 --- a/lib/business_system/goods/goods_search_page.dart +++ b/lib/business_system/goods/goods_search_page.dart @@ -132,6 +132,7 @@ class _GoodsSearchPage extends State } } + ///商品下架 queryGoodsUpdate() async { if (businessService == null) { businessService = BusinessApiService(Dio(), diff --git a/lib/business_system/goods/on_sale/batch_shelf.dart b/lib/business_system/goods/on_sale/batch_shelf.dart index 638ab222..0752e923 100644 --- a/lib/business_system/goods/on_sale/batch_shelf.dart +++ b/lib/business_system/goods/on_sale/batch_shelf.dart @@ -9,6 +9,9 @@ import '../../../view_widget/classic_header.dart'; import '../../../view_widget/my_footer.dart'; class BatchShelf extends StatefulWidget { + final Map arguments; + + BatchShelf({this.arguments}); @override State createState() { return _BatchShelf(); @@ -96,7 +99,7 @@ class _BatchShelf extends State { physics: BouncingScrollPhysics(), shrinkWrap: true, itemBuilder: (context, position) { - return shelfRightItem(); + return shelfGoodsItem(); }, ), )), @@ -107,8 +110,6 @@ class _BatchShelf extends State { ); } - - ///左边list Widget shelfLeftItem(){ return Container( @@ -147,33 +148,33 @@ class _BatchShelf extends State { ); } - ///右边List - Widget shelfRightItem(){ - return Container( - margin: EdgeInsets.only(left:16.w,right:14.w), - width: double.infinity, - child:Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Padding(padding:EdgeInsets.symmetric(vertical: 16.h), - child: Text("人气必点榜",style: TextStyle( - color: Color(0xFF30415B), - fontSize: 12.sp, - fontWeight:MyFontWeight.regular, - ),)), - ListView.builder( - itemCount: 3, - controller: controller, - physics: scrollPhysics, - shrinkWrap: true, - itemBuilder: (context, position) { - return shelfGoodsItem(); - }, - ) - ], - ), - ); - } + // ///右边List + // Widget shelfRightItem(){ + // return Container( + // margin: EdgeInsets.only(left:16.w,right:14.w), + // width: double.infinity, + // child:Column( + // crossAxisAlignment: CrossAxisAlignment.start, + // children: [ + // Padding(padding:EdgeInsets.symmetric(vertical: 16.h), + // child: Text("人气必点榜",style: TextStyle( + // color: Color(0xFF30415B), + // fontSize: 12.sp, + // fontWeight:MyFontWeight.regular, + // ),)), + // ListView.builder( + // itemCount: 3, + // controller: controller, + // physics: scrollPhysics, + // shrinkWrap: true, + // itemBuilder: (context, position) { + // return shelfGoodsItem(); + // }, + // ) + // ], + // ), + // ); + // } Widget shelfGoodsItem(){ return Container( diff --git a/lib/business_system/goods/on_sale/goods_sort.dart b/lib/business_system/goods/on_sale/goods_sort.dart index a4da7052..b2803033 100644 --- a/lib/business_system/goods/on_sale/goods_sort.dart +++ b/lib/business_system/goods/on_sale/goods_sort.dart @@ -8,6 +8,9 @@ import '../../../view_widget/classic_header.dart'; import '../../../view_widget/my_footer.dart'; class GoodsSort extends StatefulWidget { + final Map arguments; + + GoodsSort({this.arguments}); @override State createState() { return _GoodsSort(); diff --git a/lib/business_system/goods/on_sale/on_sale_page.dart b/lib/business_system/goods/on_sale/on_sale_page.dart index 5a03d845..19c80df9 100644 --- a/lib/business_system/goods/on_sale/on_sale_page.dart +++ b/lib/business_system/goods/on_sale/on_sale_page.dart @@ -17,6 +17,8 @@ import '../../../retrofit/data/product_group_list.dart'; import '../../../utils/business_instance.dart'; import '../../../utils/flutter_utils.dart'; import '../../../utils/font_weight.dart'; +import '../../../view_widget/custom_image.dart'; +import '../../../view_widget/no_data_view.dart'; class OnSalePage extends StatefulWidget { final String storeId; @@ -39,6 +41,7 @@ class _OnSalePage extends State { List adminProductVoList = []; int _loadCount = 0; int _pageIndex = 1; + int groupIndex = -1; @override void dispose() { @@ -64,7 +67,7 @@ class _OnSalePage extends State { tenant: BusinessInstance.instance.businessTenant, storeId: widget.storeId); queryProductGroupList(); - queryGoodsList(isSing: false); + queryGoodsList("", isSing: false); }); } @@ -85,7 +88,7 @@ class _OnSalePage extends State { "current": 1, "map": {}, "model": {"groupImg": "", "groupName": "", "isDelete": ""}, - "size": 50, + "size": 100, "sort": "sort" }).catchError((error) { SmartDialog.showToast(AppUtils.dioErrorTypeToString(error.type), @@ -105,11 +108,15 @@ class _OnSalePage extends State { } ///商品列表 - queryGoodsList({isSing = true}) async { + queryGoodsList(groupId, {isSing = true}) async { + if(isSing) + EasyLoading.show( + status: S.current.zhengzaijiazai, + maskType: EasyLoadingMaskType.black); try { BaseData baseData = await businessService.findAdminProductLis({ - "groupId": "", + "groupId": groupId, "hasStock": "", "keyword": "", "pageIndex": _pageIndex, @@ -143,6 +150,27 @@ class _OnSalePage extends State { } } + ///商品下架 + queryGoodsUpdate() async { + if (businessService == null) { + businessService = BusinessApiService(Dio(), + context: context, + token: BusinessInstance.instance.businessToken, + tenant: BusinessInstance.instance.businessTenant, + storeId: widget.storeId); + } + BaseData baseData = await businessService.goodsUpdate({ + "productId": adminProductVoList[0]?.id ?? "", + "sell": false, + }).catchError((error) {}); + if (baseData != null && baseData.isSuccess) { + await queryGoodsList(groupIndex == -1?"":productGroupList?.records[groupIndex]?.id ?? ""); + SmartDialog.showToast("商品下架成功", alignment: Alignment.center); + } else { + SmartDialog.showToast(baseData.msg, alignment: Alignment.center); + } + } + @override Widget build(BuildContext context) { return Scaffold( @@ -165,78 +193,142 @@ class _OnSalePage extends State { ), Expanded( child: Container( - child: SmartRefresher( - controller: _refreshController, - enablePullDown: true, - enablePullUp: true, - header: MyHeader( - color: Color(0xFF30415B), - ), - physics: BouncingScrollPhysics(), - footer: CustomFooter( - builder: (context, mode) { - return MyFooter(mode); - }, + child: Row( + mainAxisAlignment: MainAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Container( + width: 100.w, + child: ListView.builder( + itemCount: productGroupList?.records?.length ?? 0, + physics: BouncingScrollPhysics(), + shrinkWrap: true, + itemBuilder: (context, position) { + return GestureDetector( + behavior: HitTestBehavior.opaque, + onTap: () { + setState(() { + groupIndex = position; + _pageIndex = 1; + adminProductVoList.clear(); + queryGoodsList( + productGroupList?.records[position].id, + isSing: false); + }); + }, + child: leftItem( + productGroupList.records[position], position), + ); + }, + ), ), - onRefresh: () { - _pageIndex = 1; - adminProductVoList.clear(); - _onRefresh(isShowLoad: false); - }, - onLoading: () { - _pageIndex++; - queryGoodsList(); - }, - child: SingleChildScrollView( - physics: NeverScrollableScrollPhysics(), - child: Container( - color: Colors.white, - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Row( - mainAxisAlignment: MainAxisAlignment.start, - crossAxisAlignment: CrossAxisAlignment.start, - mainAxisSize: MainAxisSize.max, - children: [ - Container( - width: 100.w, - child: ListView.builder( - itemCount: 5, - physics: BouncingScrollPhysics(), - shrinkWrap: true, - itemBuilder: (context, position) { - return GestureDetector( - behavior: HitTestBehavior.opaque, - onTap: () {}, - child: leftItem(), - ); - }, - ), - ), - Container( - width: - MediaQuery.of(context).size.width - 100.w, - child: ListView.builder( - itemCount: 6, - controller: controller, - physics: scrollPhysics, - shrinkWrap: true, - itemBuilder: (context, position) { - return rightItem(); - }, - ), - ), - ], - ), - SizedBox( - height: 70.h, - ) - ], + Container( + width: MediaQuery.of(context).size.width - 100.w, + child: SmartRefresher( + controller: _refreshController, + enablePullDown: false, + enablePullUp: adminProductVoList.length != 0 ?true:false, + header: MyHeader( + color: Color(0xFF30415B), + ), + physics: BouncingScrollPhysics(), + footer: CustomFooter( + builder: (context, mode) { + return MyFooter(mode); + }, ), + onLoading: () { + _pageIndex++; + queryGoodsList(groupIndex == -1 ? "":productGroupList?.records[groupIndex].id); + }, + child: Container( + color: Colors.white, + child: (adminProductVoList == null || adminProductVoList.length == 0) + ? NoDataView( + src: "assets/image/bs_no data_logo.webp", + isShowBtn: false, + text: "该分组暂无添加商品", + fontSize: 16.sp, + margin: EdgeInsets.all(20.h), + ) + : ListView.builder( + itemCount: adminProductVoList?.length ?? 0, + controller: controller, + physics: BouncingScrollPhysics(), + shrinkWrap: true, + itemBuilder: (context, position) { + return rightGoodsItem( + adminProductVoList[position]); + }, + ), + )), + ), + ], + ) + // SmartRefresher( + // controller: _refreshController, + // enablePullDown: true, + // enablePullUp: true, + // header: MyHeader( + // color: Color(0xFF30415B), + // ), + // physics: BouncingScrollPhysics(), + // footer: CustomFooter( + // builder: (context, mode) { + // return MyFooter(mode); + // }, + // ), + // onRefresh: () { + // _pageIndex = 1; + // adminProductVoList.clear(); + // _onRefresh(isShowLoad: false); + // }, + // onLoading: () { + // _pageIndex++; + // queryGoodsList(); + // }, + // child: Container( + // color: Colors.white, + // child: Row( + // mainAxisAlignment: MainAxisAlignment.start, + // crossAxisAlignment: CrossAxisAlignment.start, + // children: [ + // Container( + // width: 100.w, + // child: ListView.builder( + // itemCount: productGroupList?.records?.length ?? 0, + // physics: BouncingScrollPhysics(), + // shrinkWrap: true, + // itemBuilder: (context, position) { + // return GestureDetector( + // behavior: HitTestBehavior.opaque, + // onTap: () {}, + // child: leftItem(productGroupList.records[position]), + // ); + // }, + // ), + // ), + // Container( + // width: + // MediaQuery.of(context).size.width - 100.w, + // child: ListView.builder( + // itemCount: adminProductVoList?.length ?? 0, + // controller: controller, + // physics: BouncingScrollPhysics(), + // shrinkWrap: true, + // itemBuilder: (context, position) { + // return rightGoodsItem(adminProductVoList[position]); + // }, + // ), + // ), + // ], + // ), + // ), + // ), )), - ), - )) + SizedBox( + height: 70.h, + ) ], ), Row( @@ -245,7 +337,8 @@ class _OnSalePage extends State { child: GestureDetector( behavior: HitTestBehavior.opaque, onTap: () { - Navigator.of(context).pushNamed('/router/goods_assort',arguments: {"storeId":widget.storeId}); + Navigator.of(context).pushNamed('/router/goods_assort', + arguments: {"storeId": widget.storeId}); }, child: Container( color: Color(0xFFEDEDED), @@ -404,84 +497,41 @@ class _OnSalePage extends State { } ///左边list - Widget leftItem() { + Widget leftItem(Records records, index) { return Container( - width: 100.w, - child: GestureDetector( - behavior: HitTestBehavior.opaque, - onTap: () { - setState(() { - // controller.jumpTo(appletProducts[index].goodsIndex); - }); - }, - child: Container( - color: Color(0xFFFAFAFA), - alignment: Alignment.center, - padding: EdgeInsets.symmetric(vertical: 16.h, horizontal: 14.w), - // margin: EdgeInsets.only(bottom: (index==appletProducts.length - 1)?35.h:0), - child: Row( - mainAxisAlignment: MainAxisAlignment.center, - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - Expanded( - child: Text( - "人气必点榜", - textAlign: TextAlign.center, - style: TextStyle( - color: Color(0xFF000000), - fontSize: 12.sp, - fontWeight: MyFontWeight.semi_bold, - ), - )), - ], - ), - ), - ), - ); - } - - ///右边List - Widget rightItem() { - return Container( - margin: EdgeInsets.symmetric(horizontal: 16.w), - width: double.infinity, - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, + color: groupIndex == index ? Colors.transparent : Color(0xFFFAFAFA), + alignment: Alignment.center, + padding: EdgeInsets.symmetric(vertical: 16.h, horizontal: 14.w), + child: Row( + mainAxisAlignment: MainAxisAlignment.center, + crossAxisAlignment: CrossAxisAlignment.center, children: [ - Padding( - padding: EdgeInsets.symmetric(vertical: 16.h), + Expanded( child: Text( - "人气必点榜", - style: TextStyle( - color: Color(0xFF30415B), - fontSize: 12.sp, - fontWeight: MyFontWeight.regular, - ), - )), - ListView.builder( - itemCount: 8, - controller: controller, - physics: scrollPhysics, - shrinkWrap: true, - itemBuilder: (context, position) { - return rightGoodsItem(); - }, - ) + records?.groupName ?? "", + textAlign: TextAlign.center, + style: TextStyle( + color: groupIndex == index ? Color(0xFF30415B):Color(0xFF626264), + fontSize: 12.sp, + fontWeight: groupIndex == index ? MyFontWeight.semi_bold : MyFontWeight.regular, + ), + )), ], ), ); } - Widget rightGoodsItem() { + Widget rightGoodsItem(AdminProductVoList adminProductVoList) { return Container( - margin: EdgeInsets.only(bottom: 21.h), + margin: EdgeInsets.only(bottom: 21.h, left: 16.w, right: 16.w, top: 10.h), child: Row( children: [ - Image.asset( - "assets/image/hot_list.webp", - width: 70, - height: 70, - fit: BoxFit.fill, + MImage( + adminProductVoList?.productImg ?? "", + width: 70.h, + height: 70.h, + fit: BoxFit.cover, + radius: BorderRadius.circular(4), ), SizedBox( width: 12.w, @@ -493,7 +543,7 @@ class _OnSalePage extends State { Padding( padding: EdgeInsets.only(bottom: 11.h, top: 2.h), child: Text( - "台湾甄选手抓饺子三生", + adminProductVoList?.productName ?? "", maxLines: 1, overflow: TextOverflow.ellipsis, style: TextStyle( @@ -506,7 +556,7 @@ class _OnSalePage extends State { Row( children: [ Text( - "库存4321", + "库存${adminProductVoList?.stock ?? 0}", style: TextStyle( fontSize: 10.sp, fontWeight: MyFontWeight.regular, @@ -517,7 +567,7 @@ class _OnSalePage extends State { width: 8.w, ), Text( - "销量4321", + "销量${adminProductVoList?.sellCount ?? 0}", style: TextStyle( fontSize: 10.sp, fontWeight: MyFontWeight.regular, @@ -544,7 +594,7 @@ class _OnSalePage extends State { ), ), TextSpan( - text: "19", + text: adminProductVoList?.price ?? "", style: TextStyle( fontSize: 14.sp, fontWeight: MyFontWeight.medium, @@ -554,23 +604,28 @@ class _OnSalePage extends State { ], ), )), - Container( - decoration: BoxDecoration( - color: Colors.white, - borderRadius: BorderRadius.circular(33), - border: Border.all( - color: Color(0xFF30415B), - width: 1, + GestureDetector( + onTap: (){ + queryGoodsUpdate(); + }, + child: Container( + decoration: BoxDecoration( + color: Colors.white, + borderRadius: BorderRadius.circular(33), + border: Border.all( + color: Color(0xFF30415B), + width: 1, + ), ), - ), - padding: - EdgeInsets.symmetric(vertical: 2.h, horizontal: 12.w), - child: Text( - "下架", - style: TextStyle( - fontSize: 12.sp, - fontWeight: MyFontWeight.regular, - color: Color(0xFF30415B), + padding: + EdgeInsets.symmetric(vertical: 2.h, horizontal: 12.w), + child: Text( + "下架", + style: TextStyle( + fontSize: 12.sp, + fontWeight: MyFontWeight.regular, + color: Color(0xFF30415B), + ), ), ), ) diff --git a/lib/main.dart b/lib/main.dart index 37b5843e..d92cadac 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -483,9 +483,9 @@ Map routers = { '/router/add_assort': (context, {arguments}) => AddAssort(arguments: arguments), '/router/goods_sort': (context, {arguments}) => - GoodsSort(), + GoodsSort(arguments: arguments), '/router/batch_shelf': (context, {arguments}) => - BatchShelf(), + BatchShelf(arguments: arguments), '/router/business_order_detail': (context, {arguments}) => BusinessOrderDetail(arguments: arguments), '/router/order_write_off': (context, {arguments}) =>