Browse Source

流水详情更改;

首页生意总览更改;
setState的调用更改;
wr_2023_business
huixiang_app 1 year ago
parent
commit
d634866a2f
  1. 83
      lib/business_system/home/business_home_page.dart
  2. 27
      lib/business_system/home/flow_page.dart
  3. 8
      lib/retrofit/data/day_flow_list.dart

83
lib/business_system/home/business_home_page.dart

@ -51,7 +51,6 @@ class _BusinessHomePage extends State<BusinessHomePage>
List<OrderTrend> orderTrend = []; List<OrderTrend> orderTrend = [];
VipCountsInfo vipCountsInfo; VipCountsInfo vipCountsInfo;
int daySelectIndex = 0; int daySelectIndex = 0;
String offsetDay;
List<DayFlowList> dayFlowList = []; List<DayFlowList> dayFlowList = [];
List<LineChartSample2Data> lineChartSample2Data = [ List<LineChartSample2Data> lineChartSample2Data = [
LineChartSample2Data(0, 0, "2023-03-09"), LineChartSample2Data(0, 0, "2023-03-09"),
@ -88,7 +87,7 @@ class _BusinessHomePage extends State<BusinessHomePage>
? "0" ? "0"
: widget.businessLoginInfo.storeList[widget.selectStoreIndex].id); : widget.businessLoginInfo.storeList[widget.selectStoreIndex].id);
queryDayAmount(); queryDayAmount();
queryPopularList(offsetDay); queryPopularList(isSing: false);
queryOrderTrend(); queryOrderTrend();
queryVipCounts(); queryVipCounts();
queryDayFlow(); queryDayFlow();
@ -123,16 +122,25 @@ class _BusinessHomePage extends State<BusinessHomePage>
} }
/// ///
queryPopularList(offsetDay) async { queryPopularList({isSing = true}) async {
try { try {
BaseData<PopularSalesList> baseData = if (isSing)
await businessService.popularList(offsetDay).catchError((error) {}); EasyLoading.show(
status: S.current.zhengzaijiazai,
maskType: EasyLoadingMaskType.black);
BaseData<PopularSalesList> baseData = await businessService
.popularList(daySelectIndex.toString())
.catchError((error) {});
if (baseData != null && baseData.isSuccess) { if (baseData != null && baseData.isSuccess) {
popularSalesList = baseData.data; popularSalesList = baseData.data;
setState(() {});
} }
} finally { } finally {
addLoadCount(); if (isSing) {
setState(() {});
EasyLoading.dismiss();
} else {
addLoadCount();
}
} }
} }
@ -144,7 +152,7 @@ class _BusinessHomePage extends State<BusinessHomePage>
if (baseData != null && baseData.isSuccess) { if (baseData != null && baseData.isSuccess) {
double index = 0; double index = 0;
if (baseData.data.isNotEmpty) { if (baseData.data.isNotEmpty) {
orderTrend.clear(); lineChartSample2Data.clear();
} }
orderTrend = baseData.data; orderTrend = baseData.data;
orderTrend.forEach((element) { orderTrend.forEach((element) {
@ -176,14 +184,10 @@ class _BusinessHomePage extends State<BusinessHomePage>
queryDayFlow() async { queryDayFlow() async {
try { try {
BaseData<List<DayFlowList>> baseData = await businessService BaseData<List<DayFlowList>> baseData = await businessService
.dayFlow( .dayFlow(DateFormat("yyyy-MM-dd").format(DateTime.now()), "1")
// "${DateFormat("yyyy-MM-dd").format(DateTime.now())}",
"2023-09-04",
"1")
.catchError((error) {}); .catchError((error) {});
if (baseData != null && baseData.isSuccess) { if (baseData != null && baseData.isSuccess) {
dayFlowList = baseData.data; dayFlowList = baseData.data;
setState(() {});
} }
} finally { } finally {
addLoadCount(); addLoadCount();
@ -559,16 +563,17 @@ class _BusinessHomePage extends State<BusinessHomePage>
SizedBox( SizedBox(
height: 18.h, height: 18.h,
), ),
// if (lineChartSample2Data.isNotEmpty) if (lineChartSample2Data.isNotEmpty)
(lineChartSample2Data.isNotEmpty) // (lineChartSample2Data.isNotEmpty)
? NoDataView( // ? NoDataView(
src: "assets/image/xiao_fei.webp", // src: "assets/image/xiao_fei.webp",
isShowBtn: false, // isShowBtn: false,
text: "暂无数据", // text: "暂无数据",
fontSize: 16.sp, // fontSize: 16.sp,
margin: EdgeInsets.all(20.h), // margin: EdgeInsets.all(20.h),
) // )
: LineChartSample2(lineChartSample2Data, "销售量"), // :
LineChartSample2(lineChartSample2Data, "销售量"),
], ],
), ),
); );
@ -868,10 +873,8 @@ class _BusinessHomePage extends State<BusinessHomePage>
GestureDetector( GestureDetector(
behavior: HitTestBehavior.opaque, behavior: HitTestBehavior.opaque,
onTap: () { onTap: () {
setState(() { daySelectIndex = 0;
daySelectIndex = 0; queryPopularList();
queryPopularList("0");
});
}, },
child: Container( child: Container(
padding: padding:
@ -905,7 +908,7 @@ class _BusinessHomePage extends State<BusinessHomePage>
onTap: () { onTap: () {
setState(() { setState(() {
daySelectIndex = 1; daySelectIndex = 1;
queryPopularList("1"); queryPopularList();
}); });
}, },
child: Container( child: Container(
@ -939,7 +942,7 @@ class _BusinessHomePage extends State<BusinessHomePage>
onTap: () { onTap: () {
setState(() { setState(() {
daySelectIndex = 2; daySelectIndex = 2;
queryPopularList("7"); queryPopularList();
}); });
}, },
child: Container( child: Container(
@ -973,7 +976,7 @@ class _BusinessHomePage extends State<BusinessHomePage>
onTap: () { onTap: () {
setState(() { setState(() {
daySelectIndex = 3; daySelectIndex = 3;
queryPopularList("30"); queryPopularList();
}); });
}, },
child: Container( child: Container(
@ -1130,18 +1133,18 @@ class _BusinessHomePage extends State<BusinessHomePage>
GestureDetector( GestureDetector(
behavior: HitTestBehavior.opaque, behavior: HitTestBehavior.opaque,
onTap: () { onTap: () {
Navigator.of(context).pushNamed('/router/flow_page', Navigator.of(context)
arguments: { .pushNamed('/router/flow_page', arguments: {
"storeName": widget?.businessLoginInfo "storeName": widget?.businessLoginInfo
?.storeList[widget.selectStoreIndex].name ?? ?.storeList[widget.selectStoreIndex].name ??
"", "",
"storeId": widget.businessLoginInfo "storeId": widget.businessLoginInfo
.storeList[widget.selectStoreIndex].name == .storeList[widget.selectStoreIndex].name ==
"所有门店" "所有门店"
? "0" ? "0"
: widget.businessLoginInfo : widget.businessLoginInfo
.storeList[widget.selectStoreIndex].id, .storeList[widget.selectStoreIndex].id,
}); });
}, },
child: Row( child: Row(
children: [ children: [

27
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:flutter_easyloading/flutter_easyloading.dart';
import 'package:huixiang/utils/font_weight.dart'; import 'package:huixiang/utils/font_weight.dart';
import 'package:huixiang/view_widget/my_appbar.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:pull_to_refresh/pull_to_refresh.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:shared_preferences/shared_preferences.dart'; import 'package:shared_preferences/shared_preferences.dart';
@ -43,7 +44,7 @@ class _FlowPage extends State<FlowPage> {
token: BusinessInstance.instance.businessToken, token: BusinessInstance.instance.businessToken,
tenant: BusinessInstance.instance.businessTenant, tenant: BusinessInstance.instance.businessTenant,
storeId: storeId); storeId: storeId);
queryDayFlow("2023-09-04", "0"); queryDayFlow(DateFormat("yyyy-MM-dd").format(DateTime.now()), "0");
}); });
} }
@ -62,9 +63,9 @@ class _FlowPage extends State<FlowPage> {
if (isMonth == "0") { if (isMonth == "0") {
dayFlowList = baseData.data; dayFlowList = baseData.data;
} else { } else {
dayFlowList dayFlowList.firstWhere((element) => element.localDate == yearMonth)
.firstWhere((element) => element.localDate == yearMonth) .detailList = baseData.data;
.detailList = baseData.data.first.detailList;
} }
setState(() {}); setState(() {});
} }
@ -170,7 +171,7 @@ class _FlowPage extends State<FlowPage> {
dayFlowList.detailList = null; dayFlowList.detailList = null;
}); });
}else{ }else{
queryDayFlow("2023-09-04", "1"); queryDayFlow(dayFlowList?.localDate ?? "", "1");
} }
}, },
child: Row( child: Row(
@ -227,20 +228,6 @@ class _FlowPage extends State<FlowPage> {
return billIDetailsItem(e); return billIDetailsItem(e);
}).toList(), }).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<FlowPage> {
), ),
), ),
Text( Text(
detailList?.phone ?? "", detailList?.phone ?? detailList?.nickname ?? detailList?.storeName ??"",
style: TextStyle( style: TextStyle(
fontSize: 14.sp, fontSize: 14.sp,
fontWeight: MyFontWeight.regular, fontWeight: MyFontWeight.regular,

8
lib/retrofit/data/day_flow_list.dart

@ -61,7 +61,6 @@ DayFlowList copyWith({ dynamic localDate,
storeName: storeName ?? _storeName, storeName: storeName ?? _storeName,
nickname: nickname ?? _nickname, nickname: nickname ?? _nickname,
phone: phone ?? _phone, phone: phone ?? _phone,
); );
dynamic get localDate => _localDate; dynamic get localDate => _localDate;
String get localDateTime => _localDateTime; String get localDateTime => _localDateTime;
@ -71,9 +70,14 @@ DayFlowList copyWith({ dynamic localDate,
String get storeName => _storeName; String get storeName => _storeName;
dynamic get nickname => _nickname; dynamic get nickname => _nickname;
dynamic get phone => _phone; dynamic get phone => _phone;
List<DayFlowList> detailList; List<DayFlowList> _detailList;
List<DayFlowList> get detailList => _detailList;
set detailList(List<DayFlowList> value) {
_detailList = value;
}
Map<String, dynamic> toJson() { Map<String, dynamic> toJson() {
final map = <String, dynamic>{}; final map = <String, dynamic>{};

Loading…
Cancel
Save