From d634866a2f7b338cc6dfe00c36de8ba47c58d70d Mon Sep 17 00:00:00 2001 From: huixiang_app <953969641@qq.com> Date: Mon, 18 Sep 2023 23:05:20 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B5=81=E6=B0=B4=E8=AF=A6=E6=83=85=E6=9B=B4?= =?UTF-8?q?=E6=94=B9=EF=BC=9B=20=E9=A6=96=E9=A1=B5=E7=94=9F=E6=84=8F?= =?UTF-8?q?=E6=80=BB=E8=A7=88=E6=9B=B4=E6=94=B9=EF=BC=9B=20setState?= =?UTF-8?q?=E7=9A=84=E8=B0=83=E7=94=A8=E6=9B=B4=E6=94=B9=EF=BC=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../home/business_home_page.dart | 83 ++++++++++--------- lib/business_system/home/flow_page.dart | 27 ++---- lib/retrofit/data/day_flow_list.dart | 8 +- 3 files changed, 56 insertions(+), 62 deletions(-) diff --git a/lib/business_system/home/business_home_page.dart b/lib/business_system/home/business_home_page.dart index 0b1ac543..518abe51 100644 --- a/lib/business_system/home/business_home_page.dart +++ b/lib/business_system/home/business_home_page.dart @@ -51,7 +51,6 @@ class _BusinessHomePage extends State List orderTrend = []; VipCountsInfo vipCountsInfo; int daySelectIndex = 0; - String offsetDay; List dayFlowList = []; List lineChartSample2Data = [ LineChartSample2Data(0, 0, "2023-03-09"), @@ -88,7 +87,7 @@ class _BusinessHomePage extends State ? "0" : widget.businessLoginInfo.storeList[widget.selectStoreIndex].id); queryDayAmount(); - queryPopularList(offsetDay); + queryPopularList(isSing: false); queryOrderTrend(); queryVipCounts(); queryDayFlow(); @@ -123,16 +122,25 @@ class _BusinessHomePage extends State } ///热销榜单 - queryPopularList(offsetDay) async { + queryPopularList({isSing = true}) async { try { - BaseData baseData = - await businessService.popularList(offsetDay).catchError((error) {}); + if (isSing) + EasyLoading.show( + status: S.current.zhengzaijiazai, + maskType: EasyLoadingMaskType.black); + BaseData baseData = await businessService + .popularList(daySelectIndex.toString()) + .catchError((error) {}); if (baseData != null && baseData.isSuccess) { popularSalesList = baseData.data; - setState(() {}); } } finally { - addLoadCount(); + if (isSing) { + setState(() {}); + EasyLoading.dismiss(); + } else { + addLoadCount(); + } } } @@ -144,7 +152,7 @@ class _BusinessHomePage extends State if (baseData != null && baseData.isSuccess) { double index = 0; if (baseData.data.isNotEmpty) { - orderTrend.clear(); + lineChartSample2Data.clear(); } orderTrend = baseData.data; orderTrend.forEach((element) { @@ -176,14 +184,10 @@ class _BusinessHomePage extends State queryDayFlow() async { try { BaseData> baseData = await businessService - .dayFlow( - // "${DateFormat("yyyy-MM-dd").format(DateTime.now())}", - "2023-09-04", - "1") + .dayFlow(DateFormat("yyyy-MM-dd").format(DateTime.now()), "1") .catchError((error) {}); if (baseData != null && baseData.isSuccess) { dayFlowList = baseData.data; - setState(() {}); } } finally { addLoadCount(); @@ -559,16 +563,17 @@ class _BusinessHomePage extends State SizedBox( height: 18.h, ), - // if (lineChartSample2Data.isNotEmpty) - (lineChartSample2Data.isNotEmpty) - ? NoDataView( - src: "assets/image/xiao_fei.webp", - isShowBtn: false, - text: "暂无数据", - fontSize: 16.sp, - margin: EdgeInsets.all(20.h), - ) - : LineChartSample2(lineChartSample2Data, "销售量"), + if (lineChartSample2Data.isNotEmpty) + // (lineChartSample2Data.isNotEmpty) + // ? NoDataView( + // src: "assets/image/xiao_fei.webp", + // isShowBtn: false, + // text: "暂无数据", + // fontSize: 16.sp, + // margin: EdgeInsets.all(20.h), + // ) + // : + LineChartSample2(lineChartSample2Data, "销售量"), ], ), ); @@ -868,10 +873,8 @@ class _BusinessHomePage extends State GestureDetector( behavior: HitTestBehavior.opaque, onTap: () { - setState(() { - daySelectIndex = 0; - queryPopularList("0"); - }); + daySelectIndex = 0; + queryPopularList(); }, child: Container( padding: @@ -905,7 +908,7 @@ class _BusinessHomePage extends State onTap: () { setState(() { daySelectIndex = 1; - queryPopularList("1"); + queryPopularList(); }); }, child: Container( @@ -939,7 +942,7 @@ class _BusinessHomePage extends State onTap: () { setState(() { daySelectIndex = 2; - queryPopularList("7"); + queryPopularList(); }); }, child: Container( @@ -973,7 +976,7 @@ class _BusinessHomePage extends State onTap: () { setState(() { daySelectIndex = 3; - queryPopularList("30"); + queryPopularList(); }); }, child: Container( @@ -1130,18 +1133,18 @@ class _BusinessHomePage extends State GestureDetector( behavior: HitTestBehavior.opaque, onTap: () { - Navigator.of(context).pushNamed('/router/flow_page', - arguments: { - "storeName": widget?.businessLoginInfo - ?.storeList[widget.selectStoreIndex].name ?? - "", - "storeId": widget.businessLoginInfo - .storeList[widget.selectStoreIndex].name == + Navigator.of(context) + .pushNamed('/router/flow_page', arguments: { + "storeName": widget?.businessLoginInfo + ?.storeList[widget.selectStoreIndex].name ?? + "", + "storeId": widget.businessLoginInfo + .storeList[widget.selectStoreIndex].name == "所有门店" - ? "0" - : widget.businessLoginInfo + ? "0" + : widget.businessLoginInfo .storeList[widget.selectStoreIndex].id, - }); + }); }, child: Row( children: [ diff --git a/lib/business_system/home/flow_page.dart b/lib/business_system/home/flow_page.dart index cd9667e1..7839c674 100644 --- a/lib/business_system/home/flow_page.dart +++ b/lib/business_system/home/flow_page.dart @@ -4,6 +4,7 @@ import 'package:flutter_datetime_picker/flutter_datetime_picker.dart'; import 'package:flutter_easyloading/flutter_easyloading.dart'; import 'package:huixiang/utils/font_weight.dart'; import 'package:huixiang/view_widget/my_appbar.dart'; +import 'package:intl/intl.dart'; import 'package:pull_to_refresh/pull_to_refresh.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:shared_preferences/shared_preferences.dart'; @@ -43,7 +44,7 @@ class _FlowPage extends State { token: BusinessInstance.instance.businessToken, tenant: BusinessInstance.instance.businessTenant, storeId: storeId); - queryDayFlow("2023-09-04", "0"); + queryDayFlow(DateFormat("yyyy-MM-dd").format(DateTime.now()), "0"); }); } @@ -62,9 +63,9 @@ class _FlowPage extends State { if (isMonth == "0") { dayFlowList = baseData.data; } else { - dayFlowList - .firstWhere((element) => element.localDate == yearMonth) - .detailList = baseData.data.first.detailList; + dayFlowList.firstWhere((element) => element.localDate == yearMonth) + .detailList = baseData.data; + } setState(() {}); } @@ -170,7 +171,7 @@ class _FlowPage extends State { dayFlowList.detailList = null; }); }else{ - queryDayFlow("2023-09-04", "1"); + queryDayFlow(dayFlowList?.localDate ?? "", "1"); } }, child: Row( @@ -227,20 +228,6 @@ class _FlowPage extends State { return billIDetailsItem(e); }).toList(), ) - // if (isShowMore) - // ListView.builder( - // padding: EdgeInsets.zero, - // itemCount: 5, - // scrollDirection: Axis.vertical, - // shrinkWrap: true, - // physics: BouncingScrollPhysics(), - // itemBuilder: (context, position) { - // return GestureDetector( - // onTap: () {}, - // child: billIDetailsItem(), - // ); - // }, - // ) ], ), ); @@ -268,7 +255,7 @@ class _FlowPage extends State { ), ), Text( - detailList?.phone ?? "", + detailList?.phone ?? detailList?.nickname ?? detailList?.storeName ??"", style: TextStyle( fontSize: 14.sp, fontWeight: MyFontWeight.regular, diff --git a/lib/retrofit/data/day_flow_list.dart b/lib/retrofit/data/day_flow_list.dart index ef959b3b..4730a7bc 100644 --- a/lib/retrofit/data/day_flow_list.dart +++ b/lib/retrofit/data/day_flow_list.dart @@ -61,7 +61,6 @@ DayFlowList copyWith({ dynamic localDate, storeName: storeName ?? _storeName, nickname: nickname ?? _nickname, phone: phone ?? _phone, - ); dynamic get localDate => _localDate; String get localDateTime => _localDateTime; @@ -71,9 +70,14 @@ DayFlowList copyWith({ dynamic localDate, String get storeName => _storeName; dynamic get nickname => _nickname; dynamic get phone => _phone; - List detailList; + List _detailList; + + List get detailList => _detailList; + set detailList(List value) { + _detailList = value; + } Map toJson() { final map = {};