You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
1267 lines
44 KiB
1267 lines
44 KiB
import 'package:dio/dio.dart'; |
|
import 'package:flutter/cupertino.dart'; |
|
import 'package:flutter/material.dart'; |
|
import 'package:flutter_easyloading/flutter_easyloading.dart'; |
|
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart'; |
|
import 'package:huixiang/business_system/home/home_view/home_sideslip_dialog.dart'; |
|
import 'package:huixiang/retrofit/data/day_flow_list.dart'; |
|
import 'package:huixiang/utils/business_instance.dart'; |
|
import 'package:huixiang/view_widget/classic_header.dart'; |
|
import 'package:huixiang/view_widget/my_footer.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'; |
|
|
|
import '../../generated/l10n.dart'; |
|
import '../../retrofit/business_api.dart'; |
|
import '../../retrofit/data/base_data.dart'; |
|
import '../../retrofit/data/business_login_info.dart'; |
|
import '../../retrofit/data/day_count.dart'; |
|
import '../../retrofit/data/order_trend.dart'; |
|
import '../../retrofit/data/popular_sales_list.dart'; |
|
import '../../retrofit/data/vip_counts_info.dart'; |
|
import '../../utils/flutter_utils.dart'; |
|
import '../../utils/font_weight.dart'; |
|
import '../../view_widget/no_data_view.dart'; |
|
import 'home_view/my_line_chart.dart'; |
|
|
|
class BusinessHomePage extends StatefulWidget { |
|
final BusinessLoginInfo businessLoginInfo; |
|
final int selectStoreIndex; |
|
final Function changeIndex; |
|
|
|
BusinessHomePage( |
|
this.businessLoginInfo, this.selectStoreIndex, this.changeIndex); |
|
|
|
@override |
|
State<StatefulWidget> createState() { |
|
return _BusinessHomePage(); |
|
} |
|
} |
|
|
|
class _BusinessHomePage extends State<BusinessHomePage> |
|
with AutomaticKeepAliveClientMixin { |
|
final RefreshController refreshController = RefreshController(); |
|
final ScrollController scrollController = ScrollController(); |
|
BusinessApiService businessService; |
|
DayCount dayCount; |
|
int _loadCount = 0; |
|
PopularSalesList popularSalesList; |
|
List<OrderTrend> orderTrend = []; |
|
VipCountsInfo vipCountsInfo; |
|
int daySelectIndex = 0; |
|
String offsetDay; |
|
List<DayFlowList> dayFlowList = []; |
|
List<LineChartSample2Data> lineChartSample2Data = [ |
|
LineChartSample2Data(0, 0, "2023-03-09"), |
|
LineChartSample2Data(1, 0, "2023-03-10"), |
|
LineChartSample2Data(2, 0, "2023-03-11"), |
|
LineChartSample2Data(3, 0, "2023-03-12"), |
|
LineChartSample2Data(4, 0, "2023-03-13"), |
|
LineChartSample2Data(5, 0, "2023-03-14"), |
|
LineChartSample2Data(6, 0, "2023-03-15") |
|
]; |
|
|
|
@override |
|
void initState() { |
|
super.initState(); |
|
_onRefresh(); |
|
} |
|
|
|
@override |
|
void dispose() { |
|
super.dispose(); |
|
} |
|
|
|
_onRefresh() async { |
|
EasyLoading.show( |
|
status: S.current.zhengzaijiazai, maskType: EasyLoadingMaskType.black); |
|
SharedPreferences.getInstance().then((value) { |
|
businessService = BusinessApiService(Dio(), |
|
context: context, |
|
token: BusinessInstance.instance.businessToken, |
|
tenant: BusinessInstance.instance.businessTenant, |
|
storeId: widget.businessLoginInfo.storeList[widget.selectStoreIndex] |
|
.name == |
|
"所有门店" |
|
? "0" |
|
: widget.businessLoginInfo.storeList[widget.selectStoreIndex].id); |
|
queryDayAmount(); |
|
queryPopularList(offsetDay); |
|
queryOrderTrend(); |
|
queryVipCounts(); |
|
queryDayFlow(); |
|
}); |
|
} |
|
|
|
addLoadCount() { |
|
_loadCount += 1; |
|
if (_loadCount == 5) { |
|
_loadCount = 0; |
|
EasyLoading.dismiss(); |
|
if (refreshController.isRefresh) refreshController.refreshCompleted(); |
|
if (mounted) setState(() {}); |
|
} |
|
} |
|
|
|
///每日营业额/交易笔数/退款金额/退款笔数 |
|
queryDayAmount() async { |
|
try { |
|
BaseData<DayCount> baseData = await businessService.getDayCounts({ |
|
"summaryDate": "${DateFormat("yyyy-MM-dd").format(DateTime.now())}" |
|
}).catchError((error) { |
|
SmartDialog.showToast(AppUtils.dioErrorTypeToString(error.type), |
|
alignment: Alignment.center); |
|
}); |
|
if (baseData != null && baseData.isSuccess) { |
|
dayCount = baseData.data; |
|
} |
|
} finally { |
|
addLoadCount(); |
|
} |
|
} |
|
|
|
///热销榜单 |
|
queryPopularList(offsetDay) async { |
|
try { |
|
BaseData<PopularSalesList> baseData = |
|
await businessService.popularList(offsetDay).catchError((error) {}); |
|
if (baseData != null && baseData.isSuccess) { |
|
popularSalesList = baseData.data; |
|
setState(() {}); |
|
} |
|
} finally { |
|
addLoadCount(); |
|
} |
|
} |
|
|
|
///生意总览 |
|
queryOrderTrend() async { |
|
try { |
|
BaseData<List<OrderTrend>> baseData = |
|
await businessService.orderTrend().catchError((error) {}); |
|
if (baseData != null && baseData.isSuccess) { |
|
double index = 0; |
|
if (baseData.data.isNotEmpty) { |
|
orderTrend.clear(); |
|
} |
|
orderTrend = baseData.data; |
|
orderTrend.forEach((element) { |
|
lineChartSample2Data.add(LineChartSample2Data( |
|
index, double.tryParse(element.number.toString()), element.date)); |
|
index += 1; |
|
}); |
|
} |
|
} finally { |
|
addLoadCount(); |
|
} |
|
} |
|
|
|
///用户总览/会员统计数据 |
|
queryVipCounts() async { |
|
try { |
|
BaseData<VipCountsInfo> baseData = await businessService |
|
.vipCounts("${DateFormat("yyyy-MM-dd").format(DateTime.now())}") |
|
.catchError((error) {}); |
|
if (baseData != null && baseData.isSuccess) { |
|
vipCountsInfo = baseData.data; |
|
} |
|
} finally { |
|
addLoadCount(); |
|
} |
|
} |
|
|
|
///今日流水/isMonth=0(当月数据),isMonth=1(当日数据) |
|
queryDayFlow() async { |
|
try { |
|
BaseData<List<DayFlowList>> baseData = await businessService |
|
.dayFlow( |
|
// "${DateFormat("yyyy-MM-dd").format(DateTime.now())}", |
|
"2023-09-04", |
|
"1") |
|
.catchError((error) {}); |
|
if (baseData != null && baseData.isSuccess) { |
|
dayFlowList = baseData.data; |
|
setState(() {}); |
|
} |
|
} finally { |
|
addLoadCount(); |
|
} |
|
} |
|
|
|
@override |
|
Widget build(BuildContext context) { |
|
super.build(context); |
|
return Column( |
|
children: [ |
|
Expanded( |
|
child: Container( |
|
child: SmartRefresher( |
|
controller: refreshController, |
|
enablePullDown: true, |
|
enablePullUp: false, |
|
header: MyHeader(), |
|
physics: BouncingScrollPhysics(), |
|
scrollController: scrollController, |
|
footer: CustomFooter( |
|
builder: (context, mode) { |
|
return MyFooter(mode); |
|
}, |
|
), |
|
onRefresh: _onRefresh, |
|
child: SingleChildScrollView( |
|
physics: NeverScrollableScrollPhysics(), |
|
child: Column( |
|
children: [ |
|
homeTop(), |
|
tradeOverview(), |
|
userOverview(), |
|
hotSellHotCharts(), |
|
todayFlow(), |
|
], |
|
)), |
|
), |
|
), |
|
), |
|
SizedBox( |
|
height: 76.h, |
|
), |
|
], |
|
); |
|
} |
|
|
|
///首页头部 |
|
Widget homeTop() { |
|
return Container( |
|
color: Color(0xFF30415B), |
|
width: double.infinity, |
|
padding: EdgeInsets.only( |
|
top: MediaQuery.of(context).padding.top + 23.h, |
|
bottom: 16.h, |
|
left: 16.w, |
|
right: 16.w), |
|
child: Column( |
|
children: [ |
|
Row( |
|
children: [ |
|
Expanded( |
|
child: GestureDetector( |
|
behavior: HitTestBehavior.opaque, |
|
onTap: () { |
|
showAlertDialog( |
|
widget.selectStoreIndex, |
|
widget.businessLoginInfo, |
|
); |
|
//改变导航栏状态栏颜色 |
|
// SystemChrome.setSystemUIOverlayStyle( SystemUiOverlayStyle(statusBarColor: Colors.white), ); |
|
// Navigator.of(context).pushNamed('/router/select_shop'); |
|
}, |
|
child: Row( |
|
children: [ |
|
Image.asset( |
|
"assets/image/bs_more.webp", |
|
width: 16.w, |
|
height: 13.h, |
|
), |
|
Padding( |
|
padding: EdgeInsets.only(left: 7.w), |
|
child: Text( |
|
widget?.businessLoginInfo |
|
?.storeList[widget.selectStoreIndex].name ?? |
|
"", |
|
style: TextStyle( |
|
fontSize: 16.sp, |
|
fontWeight: MyFontWeight.semi_bold, |
|
color: Colors.white, |
|
), |
|
), |
|
), |
|
], |
|
), |
|
)), |
|
GestureDetector( |
|
behavior: HitTestBehavior.opaque, |
|
onTap: () {}, |
|
child: Image.asset( |
|
"assets/image/icon_scan_qr_code.webp", |
|
width: 28.h, |
|
height: 28.h, |
|
), |
|
) |
|
], |
|
), |
|
SizedBox( |
|
height: 14.h, |
|
), |
|
Container( |
|
padding: EdgeInsets.symmetric(vertical: 12.h), |
|
decoration: BoxDecoration( |
|
color: Colors.white, |
|
borderRadius: BorderRadius.circular(4), |
|
), |
|
child: Column( |
|
crossAxisAlignment: CrossAxisAlignment.start, |
|
mainAxisAlignment: MainAxisAlignment.center, |
|
children: [ |
|
Padding( |
|
padding: EdgeInsets.symmetric(horizontal: 23.w), |
|
child: Row( |
|
children: [ |
|
Image.asset( |
|
"assets/image/bs_home_bill.webp", |
|
width: 14, |
|
height: 14, |
|
), |
|
Padding( |
|
padding: EdgeInsets.only(left: 3.w), |
|
child: Text( |
|
"营业额(元)", |
|
style: TextStyle( |
|
fontSize: 12.sp, |
|
fontWeight: MyFontWeight.semi_bold, |
|
color: Color(0xFF30415B), |
|
), |
|
), |
|
), |
|
], |
|
)), |
|
Padding( |
|
padding: EdgeInsets.only( |
|
top: 6.h, bottom: 17.h, left: 23.w, right: 23.w), |
|
child: Text( |
|
dayCount?.paySum ?? "0", |
|
style: TextStyle( |
|
fontSize: 24.sp, |
|
fontWeight: MyFontWeight.medium, |
|
color: Color(0xFF30415B), |
|
), |
|
), |
|
), |
|
Row( |
|
children: [ |
|
Expanded( |
|
child: Column( |
|
crossAxisAlignment: CrossAxisAlignment.center, |
|
children: [ |
|
Row( |
|
mainAxisAlignment: MainAxisAlignment.center, |
|
children: [ |
|
Image.asset( |
|
"assets/image/bs_trade_num.webp", |
|
width: 16, |
|
height: 16, |
|
), |
|
Padding( |
|
padding: EdgeInsets.only(left: 3.w), |
|
child: Text( |
|
"交易笔数", |
|
style: TextStyle( |
|
fontSize: 12.sp, |
|
fontWeight: MyFontWeight.medium, |
|
color: Color(0xFF30415B), |
|
), |
|
), |
|
), |
|
], |
|
), |
|
Padding( |
|
padding: EdgeInsets.only( |
|
top: 5.h, left: 20.w, right: 20.w), |
|
child: Text( |
|
(dayCount?.orderNum ?? 0).toString(), |
|
style: TextStyle( |
|
fontSize: 18.sp, |
|
fontWeight: MyFontWeight.medium, |
|
color: Color(0xFF30415B), |
|
), |
|
), |
|
), |
|
], |
|
)), |
|
Expanded( |
|
child: Column( |
|
crossAxisAlignment: CrossAxisAlignment.center, |
|
children: [ |
|
Row( |
|
mainAxisAlignment: MainAxisAlignment.center, |
|
children: [ |
|
Image.asset( |
|
"assets/image/bs_refund.webp", |
|
width: 14, |
|
height: 14, |
|
), |
|
Padding( |
|
padding: EdgeInsets.only(left: 3.w), |
|
child: Text( |
|
"退款金额(元)", |
|
style: TextStyle( |
|
fontSize: 12.sp, |
|
fontWeight: MyFontWeight.medium, |
|
color: Color(0xFF30415B), |
|
), |
|
), |
|
), |
|
], |
|
), |
|
Padding( |
|
padding: EdgeInsets.only( |
|
top: 5.h, left: 20.w, right: 20.w), |
|
child: Text( |
|
(dayCount?.refundMoney ?? "0.00") == "0" |
|
? "0.00" |
|
: (dayCount?.refundMoney ?? "0.00"), |
|
style: TextStyle( |
|
fontSize: 18.sp, |
|
fontWeight: MyFontWeight.medium, |
|
color: Color(0xFF30415B), |
|
), |
|
), |
|
), |
|
], |
|
)), |
|
Expanded( |
|
child: Column( |
|
crossAxisAlignment: CrossAxisAlignment.center, |
|
children: [ |
|
Row( |
|
mainAxisAlignment: MainAxisAlignment.center, |
|
children: [ |
|
Image.asset( |
|
"assets/image/bs_refund_num.webp", |
|
width: 14, |
|
height: 14, |
|
), |
|
Padding( |
|
padding: EdgeInsets.only(left: 3.w), |
|
child: Text( |
|
"退款笔数", |
|
style: TextStyle( |
|
fontSize: 12.sp, |
|
fontWeight: MyFontWeight.medium, |
|
color: Color(0xFF30415B), |
|
), |
|
), |
|
), |
|
], |
|
), |
|
Padding( |
|
padding: EdgeInsets.only( |
|
top: 5.h, left: 20.w, right: 20.w), |
|
child: Text( |
|
(dayCount?.refundOrderNum ?? 0).toString(), |
|
style: TextStyle( |
|
fontSize: 18.sp, |
|
fontWeight: MyFontWeight.medium, |
|
color: Color(0xFF30415B), |
|
), |
|
), |
|
), |
|
], |
|
)) |
|
], |
|
), |
|
], |
|
), |
|
) |
|
], |
|
), |
|
); |
|
} |
|
|
|
///侧面弹窗 |
|
showAlertDialog( |
|
selectStoreIndex, |
|
businessLoginInfo, |
|
) async { |
|
int index = await showCupertinoModalPopup( |
|
builder: (context) { |
|
return HomeSideslipDialog(selectStoreIndex, businessLoginInfo); |
|
}, |
|
context: context); |
|
if (index != null) { |
|
if (index == -1) { |
|
Navigator.of(context).pop(); |
|
return; |
|
} |
|
widget.changeIndex(index); |
|
_onRefresh(); |
|
} |
|
} |
|
|
|
///生意总览 |
|
Widget tradeOverview() { |
|
return Container( |
|
padding: |
|
EdgeInsets.only(left: 16.w, right: 21.w, top: 12.h, bottom: 16.h), |
|
color: Colors.white, |
|
child: Column( |
|
children: [ |
|
Row( |
|
children: [ |
|
Container(width: 4.w, height: 16.h, color: Color(0xFF30415B)), |
|
Padding( |
|
padding: EdgeInsets.only(left: 12.w, right: 8.w), |
|
child: Text( |
|
"生意总览", |
|
style: TextStyle( |
|
fontSize: 15.sp, |
|
fontWeight: MyFontWeight.semi_bold, |
|
color: Color(0xFF0D0D0D), |
|
), |
|
), |
|
), |
|
Expanded( |
|
child: Text( |
|
"近一周订单量趋势", |
|
style: TextStyle( |
|
fontSize: 12.sp, |
|
fontWeight: MyFontWeight.regular, |
|
color: Color(0x99000000), |
|
), |
|
)), |
|
GestureDetector( |
|
behavior: HitTestBehavior.opaque, |
|
onTap: () { |
|
Navigator.of(context) |
|
.pushNamed('/router/trade_overview_page', arguments: { |
|
"storeId": widget.businessLoginInfo |
|
.storeList[widget.selectStoreIndex].name == |
|
"所有门店" |
|
? "0" |
|
: widget.businessLoginInfo |
|
.storeList[widget.selectStoreIndex].id, |
|
}); |
|
}, |
|
child: Row( |
|
children: [ |
|
Text( |
|
"更多数据", |
|
style: TextStyle( |
|
fontSize: 14.sp, |
|
fontWeight: MyFontWeight.regular, |
|
color: Color(0xFF252626), |
|
), |
|
), |
|
SizedBox( |
|
width: 5.w, |
|
), |
|
Image.asset( |
|
"assets/image/bs_right.webp", |
|
width: 8.w, |
|
height: 12.h, |
|
), |
|
], |
|
), |
|
) |
|
], |
|
), |
|
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, "销售量"), |
|
], |
|
), |
|
); |
|
} |
|
|
|
///用户概览 |
|
Widget userOverview() { |
|
return Container( |
|
color: Colors.white, |
|
margin: EdgeInsets.only(top: 16.h), |
|
padding: |
|
EdgeInsets.only(left: 16.w, right: 15.w, top: 12.h, bottom: 12.h), |
|
child: Column( |
|
children: [ |
|
Row( |
|
children: [ |
|
Container(width: 4.w, height: 16.h, color: Color(0xFF30415B)), |
|
Padding( |
|
padding: EdgeInsets.only( |
|
left: 12.w, |
|
), |
|
child: Text( |
|
"用户概览", |
|
style: TextStyle( |
|
fontSize: 15.sp, |
|
fontWeight: MyFontWeight.semi_bold, |
|
color: Color(0xFF0D0D0D), |
|
), |
|
), |
|
), |
|
], |
|
), |
|
SizedBox( |
|
height: 12.h, |
|
), |
|
Row( |
|
children: [ |
|
Expanded( |
|
child: GestureDetector( |
|
behavior: HitTestBehavior.opaque, |
|
onTap: () { |
|
showVipTipDialog(1); |
|
}, |
|
child: Container( |
|
padding: EdgeInsets.symmetric(horizontal: 8.w, vertical: 6.h), |
|
decoration: BoxDecoration( |
|
gradient: LinearGradient( |
|
colors: [Color(0xFFFC5A58), Color(0xFFFF716F)], |
|
begin: Alignment.topCenter, |
|
end: Alignment.bottomCenter, |
|
), |
|
borderRadius: BorderRadius.circular(6.w), |
|
), |
|
child: Column( |
|
crossAxisAlignment: CrossAxisAlignment.start, |
|
children: [ |
|
Row( |
|
children: [ |
|
Padding( |
|
padding: EdgeInsets.only(right: 6.w), |
|
child: Text( |
|
"今日会员充值", |
|
style: TextStyle( |
|
fontSize: 12.sp, |
|
fontWeight: MyFontWeight.regular, |
|
color: Colors.white, |
|
), |
|
), |
|
), |
|
Image.asset( |
|
"assets/image/bs_query_logo.webp", |
|
width: 14, |
|
height: 14, |
|
), |
|
], |
|
), |
|
SizedBox( |
|
height: 7.h, |
|
), |
|
Text( |
|
vipCountsInfo?.rechargeMoney ?? "0", |
|
style: TextStyle( |
|
fontSize: 24.sp, |
|
fontWeight: MyFontWeight.medium, |
|
color: Colors.white, |
|
), |
|
), |
|
], |
|
), |
|
), |
|
)), |
|
SizedBox( |
|
width: 9.w, |
|
), |
|
Expanded( |
|
child: GestureDetector( |
|
behavior: HitTestBehavior.opaque, |
|
onTap: () { |
|
showVipTipDialog(2); |
|
}, |
|
child: Container( |
|
padding: EdgeInsets.symmetric( |
|
horizontal: 8.w, vertical: 6.h), |
|
decoration: BoxDecoration( |
|
gradient: LinearGradient( |
|
colors: [Color(0xFFFFA238), Color(0xFFFFBA6D)], |
|
begin: Alignment.topCenter, |
|
end: Alignment.bottomCenter, |
|
), |
|
borderRadius: BorderRadius.circular(6.w), |
|
), |
|
child: Column( |
|
crossAxisAlignment: CrossAxisAlignment.start, |
|
children: [ |
|
Row( |
|
children: [ |
|
Padding( |
|
padding: EdgeInsets.only(right: 6.w), |
|
child: Text( |
|
"今日新增会员", |
|
style: TextStyle( |
|
fontSize: 12.sp, |
|
fontWeight: MyFontWeight.regular, |
|
color: Colors.white, |
|
), |
|
), |
|
), |
|
Image.asset( |
|
"assets/image/bs_query_logo.webp", |
|
width: 14, |
|
height: 14, |
|
), |
|
], |
|
), |
|
SizedBox( |
|
height: 7.h, |
|
), |
|
Text( |
|
(vipCountsInfo?.newMemberNum ?? 0).toString(), |
|
style: TextStyle( |
|
fontSize: 24.sp, |
|
fontWeight: MyFontWeight.medium, |
|
color: Colors.white, |
|
), |
|
), |
|
], |
|
), |
|
))), |
|
SizedBox( |
|
width: 9.w, |
|
), |
|
Expanded( |
|
child: GestureDetector( |
|
behavior: HitTestBehavior.opaque, |
|
onTap: () { |
|
showVipTipDialog(3); |
|
}, |
|
child: Container( |
|
padding: EdgeInsets.symmetric( |
|
horizontal: 8.w, vertical: 6.h), |
|
decoration: BoxDecoration( |
|
gradient: LinearGradient( |
|
colors: [Color(0xFF4B77FC), Color(0xFF7091FF)], |
|
begin: Alignment.topCenter, |
|
end: Alignment.bottomCenter, |
|
), |
|
borderRadius: BorderRadius.circular(6.w), |
|
), |
|
child: Column( |
|
crossAxisAlignment: CrossAxisAlignment.start, |
|
children: [ |
|
Row( |
|
children: [ |
|
Padding( |
|
padding: EdgeInsets.only(right: 6.w), |
|
child: Text( |
|
"总会员数", |
|
style: TextStyle( |
|
fontSize: 12.sp, |
|
fontWeight: MyFontWeight.regular, |
|
color: Colors.white, |
|
), |
|
), |
|
), |
|
Image.asset( |
|
"assets/image/bs_query_logo.webp", |
|
width: 14, |
|
height: 14, |
|
), |
|
], |
|
), |
|
SizedBox( |
|
height: 7.h, |
|
), |
|
Text( |
|
(vipCountsInfo?.memberNum ?? 0).toString(), |
|
style: TextStyle( |
|
fontSize: 24.sp, |
|
fontWeight: MyFontWeight.medium, |
|
color: Colors.white, |
|
), |
|
), |
|
], |
|
), |
|
))), |
|
], |
|
) |
|
], |
|
), |
|
); |
|
} |
|
|
|
///用户概览弹窗提示 |
|
showVipTipDialog(index) { |
|
showDialog( |
|
context: context, |
|
builder: (context) { |
|
return AlertDialog( |
|
content: Column( |
|
mainAxisSize: MainAxisSize.min, |
|
mainAxisAlignment: MainAxisAlignment.center, |
|
crossAxisAlignment: CrossAxisAlignment.center, |
|
children: [ |
|
Image.asset( |
|
index == 1 |
|
? "assets/image/icon_vip_recharge.webp" |
|
: (index == 2 |
|
? "assets/image/icon_new_vip.webp" |
|
: "assets/image/icon_vip_total.webp"), |
|
width: 20.h, |
|
height: 20.h, |
|
), |
|
SizedBox( |
|
height: 6.h, |
|
), |
|
Text( |
|
index == 1 ? "今日会员充值" : (index == 2 ? "今日新增会员" : "总会员数"), |
|
style: TextStyle( |
|
color: Color(0xFF0D0D0D), |
|
fontSize: 15.sp, |
|
fontWeight: MyFontWeight.bold, |
|
), |
|
), |
|
SizedBox( |
|
height: 13.h, |
|
), |
|
Text( |
|
index == 1 |
|
? "今日会员充值指今天所选门店会员充值额度" |
|
: (index == 2 ? "今日新增会员指今天所选门店新增会员" : "总会员数指所选门店会员总会员人数"), |
|
textAlign: TextAlign.center, |
|
style: TextStyle( |
|
color: Color(0xFF666666), |
|
fontSize: 12.sp, |
|
fontWeight: MyFontWeight.regular, |
|
), |
|
), |
|
], |
|
), |
|
); |
|
}, |
|
); |
|
} |
|
|
|
///热销榜单 |
|
Widget hotSellHotCharts() { |
|
return Container( |
|
color: Colors.white, |
|
margin: EdgeInsets.only(top: 16.h), |
|
padding: |
|
EdgeInsets.only(left: 16.w, right: 15.w, top: 12.h, bottom: 16.h), |
|
child: Column( |
|
children: [ |
|
Row( |
|
children: [ |
|
Container(width: 4.w, height: 16.h, color: Color(0xFF30415B)), |
|
Padding( |
|
padding: EdgeInsets.only( |
|
left: 12.w, |
|
), |
|
child: Text( |
|
"热销榜单", |
|
style: TextStyle( |
|
fontSize: 15.sp, |
|
fontWeight: MyFontWeight.semi_bold, |
|
color: Color(0xFF0D0D0D), |
|
), |
|
), |
|
), |
|
], |
|
), |
|
SizedBox( |
|
height: 14.h, |
|
), |
|
Row( |
|
children: [ |
|
GestureDetector( |
|
behavior: HitTestBehavior.opaque, |
|
onTap: () { |
|
setState(() { |
|
daySelectIndex = 0; |
|
queryPopularList("0"); |
|
}); |
|
}, |
|
child: Container( |
|
padding: |
|
EdgeInsets.symmetric(horizontal: 19.w, vertical: 5.h), |
|
alignment: Alignment.center, |
|
margin: EdgeInsets.only(right: 16.w, bottom: 16.h), |
|
decoration: BoxDecoration( |
|
borderRadius: BorderRadius.circular(2.w), |
|
color: daySelectIndex == 0 |
|
? Color(0xFF30415B) |
|
: Colors.transparent, |
|
border: Border.all( |
|
color: Color(0xFF30415B), |
|
width: 1.w, |
|
), |
|
), |
|
child: Text( |
|
"今天", |
|
style: TextStyle( |
|
fontSize: 12.sp, |
|
fontWeight: MyFontWeight.regular, |
|
color: daySelectIndex == 0 |
|
? Colors.white |
|
: Color(0XFF30415B), |
|
), |
|
), |
|
), |
|
), |
|
GestureDetector( |
|
behavior: HitTestBehavior.opaque, |
|
onTap: () { |
|
setState(() { |
|
daySelectIndex = 1; |
|
queryPopularList("1"); |
|
}); |
|
}, |
|
child: Container( |
|
padding: |
|
EdgeInsets.symmetric(horizontal: 19.w, vertical: 5.h), |
|
alignment: Alignment.center, |
|
margin: EdgeInsets.only(right: 16.w, bottom: 16.h), |
|
decoration: BoxDecoration( |
|
borderRadius: BorderRadius.circular(2.w), |
|
color: daySelectIndex == 1 |
|
? Color(0xFF30415B) |
|
: Colors.transparent, |
|
border: Border.all( |
|
color: Color(0xFF30415B), |
|
width: 1.w, |
|
), |
|
), |
|
child: Text( |
|
"昨天", |
|
style: TextStyle( |
|
fontSize: 12.sp, |
|
fontWeight: MyFontWeight.regular, |
|
color: daySelectIndex == 1 |
|
? Colors.white |
|
: Color(0XFF30415B), |
|
), |
|
), |
|
)), |
|
GestureDetector( |
|
behavior: HitTestBehavior.opaque, |
|
onTap: () { |
|
setState(() { |
|
daySelectIndex = 2; |
|
queryPopularList("7"); |
|
}); |
|
}, |
|
child: Container( |
|
padding: |
|
EdgeInsets.symmetric(horizontal: 10.w, vertical: 5.h), |
|
alignment: Alignment.center, |
|
margin: EdgeInsets.only(right: 16.w, bottom: 16.h), |
|
decoration: BoxDecoration( |
|
borderRadius: BorderRadius.circular(2.w), |
|
color: daySelectIndex == 2 |
|
? Color(0xFF30415B) |
|
: Colors.transparent, |
|
border: Border.all( |
|
color: Color(0xFF30415B), |
|
width: 1.w, |
|
), |
|
), |
|
child: Text( |
|
"最近7天", |
|
style: TextStyle( |
|
fontSize: 12.sp, |
|
fontWeight: MyFontWeight.regular, |
|
color: daySelectIndex == 2 |
|
? Colors.white |
|
: Color(0XFF30415B), |
|
), |
|
), |
|
)), |
|
GestureDetector( |
|
behavior: HitTestBehavior.opaque, |
|
onTap: () { |
|
setState(() { |
|
daySelectIndex = 3; |
|
queryPopularList("30"); |
|
}); |
|
}, |
|
child: Container( |
|
padding: |
|
EdgeInsets.symmetric(horizontal: 10.w, vertical: 5.h), |
|
alignment: Alignment.center, |
|
margin: EdgeInsets.only(right: 16.w, bottom: 16.h), |
|
decoration: BoxDecoration( |
|
borderRadius: BorderRadius.circular(2.w), |
|
color: daySelectIndex == 3 |
|
? Color(0xFF30415B) |
|
: Colors.transparent, |
|
border: Border.all( |
|
color: Color(0xFF30415B), |
|
width: 1.w, |
|
), |
|
), |
|
child: Text( |
|
"最近30天", |
|
style: TextStyle( |
|
fontSize: 12.sp, |
|
fontWeight: MyFontWeight.regular, |
|
color: daySelectIndex == 3 |
|
? Colors.white |
|
: Color(0XFF30415B), |
|
), |
|
), |
|
)), |
|
], |
|
), |
|
Container( |
|
height: 310.h, |
|
child: (popularSalesList == null || |
|
popularSalesList.saleProductList.length == 0) |
|
? NoDataView( |
|
src: "assets/image/xiao_fei.webp", |
|
isShowBtn: false, |
|
text: "暂无数据", |
|
fontSize: 16.sp, |
|
margin: EdgeInsets.all(20.h), |
|
) |
|
: ListView.builder( |
|
padding: EdgeInsets.zero, |
|
itemCount: popularSalesList?.saleProductList?.length ?? 0, |
|
scrollDirection: Axis.vertical, |
|
shrinkWrap: true, |
|
physics: BouncingScrollPhysics(), |
|
itemBuilder: (context, position) { |
|
return GestureDetector( |
|
onTap: () {}, |
|
child: salesVolumeItem( |
|
popularSalesList.saleProductList[position], |
|
position), |
|
); |
|
}, |
|
), |
|
), |
|
], |
|
), |
|
); |
|
} |
|
|
|
///销量item |
|
Widget salesVolumeItem(SaleProductList saleProductList, index) { |
|
return Container( |
|
padding: EdgeInsets.only(bottom: 12.h), |
|
child: Row( |
|
children: [ |
|
if (index == 0 || index == 1 || index == 2) |
|
Image.asset( |
|
index == 0 |
|
? "assets/image/bs_trophy_one.webp" |
|
: (index == 1 |
|
? "assets/image/bs_trophy_two.webp" |
|
: "assets/image/bs_trophy_three.webp"), |
|
width: 26.h, |
|
height: 26.h, |
|
), |
|
if (index != 0 && index != 1 && index != 2) |
|
Padding( |
|
padding: EdgeInsets.symmetric(horizontal: 8.w), |
|
child: Text( |
|
(index + 1).toString(), |
|
style: TextStyle( |
|
fontSize: 12.sp, |
|
fontWeight: MyFontWeight.medium, |
|
color: Color(0xFF0D0D0D), |
|
), |
|
), |
|
), |
|
SizedBox( |
|
width: 8.w, |
|
), |
|
Expanded( |
|
child: Text( |
|
saleProductList?.productName ?? "", |
|
style: TextStyle( |
|
fontSize: 12.sp, |
|
fontWeight: MyFontWeight.regular, |
|
color: Color(0xFF0D0D0D), |
|
), |
|
), |
|
), |
|
Text( |
|
"已售", |
|
style: TextStyle( |
|
fontSize: 12.sp, |
|
fontWeight: MyFontWeight.regular, |
|
color: Color(0xFF0D0D0D), |
|
), |
|
), |
|
Padding( |
|
padding: EdgeInsets.only(left: 7.w), |
|
child: Text( |
|
"${(saleProductList?.saleNum ?? 0).toString()}件", |
|
style: TextStyle( |
|
fontSize: 12.sp, |
|
fontWeight: MyFontWeight.regular, |
|
color: Color(0xFF0D0D0D), |
|
), |
|
), |
|
) |
|
], |
|
), |
|
); |
|
} |
|
|
|
///今日流水 |
|
Widget todayFlow() { |
|
return Container( |
|
color: Colors.white, |
|
margin: EdgeInsets.only(top: 16.h, bottom: 26.h), |
|
padding: |
|
EdgeInsets.only(left: 16.w, right: 21.w, top: 12.h, bottom: 16.h), |
|
child: Column( |
|
children: [ |
|
Row( |
|
children: [ |
|
Container( |
|
width: 4.w, |
|
height: 16.h, |
|
color: Color(0xFF30415B), |
|
margin: EdgeInsets.only(right: 12.w), |
|
), |
|
Expanded( |
|
child: Text( |
|
"今日流水", |
|
style: TextStyle( |
|
fontSize: 15.sp, |
|
fontWeight: MyFontWeight.semi_bold, |
|
color: Color(0xFF0D0D0D), |
|
), |
|
)), |
|
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 == |
|
"所有门店" |
|
? "0" |
|
: widget.businessLoginInfo |
|
.storeList[widget.selectStoreIndex].id, |
|
}); |
|
}, |
|
child: Row( |
|
children: [ |
|
Text( |
|
"更多数据", |
|
style: TextStyle( |
|
fontSize: 14.sp, |
|
fontWeight: MyFontWeight.regular, |
|
color: Color(0xFF252626), |
|
), |
|
), |
|
SizedBox( |
|
width: 5.w, |
|
), |
|
Image.asset( |
|
"assets/image/bs_right.webp", |
|
width: 8.w, |
|
height: 12.h, |
|
), |
|
], |
|
), |
|
), |
|
], |
|
), |
|
SizedBox( |
|
height: 20.h, |
|
), |
|
Container( |
|
height: 360.h, |
|
child: (dayFlowList.length == null || dayFlowList?.length == 0) |
|
? NoDataView( |
|
src: "assets/image/xiao_fei.webp", |
|
isShowBtn: false, |
|
text: "暂无数据", |
|
fontSize: 16.sp, |
|
margin: EdgeInsets.all(20.h), |
|
) |
|
: ListView.builder( |
|
padding: EdgeInsets.zero, |
|
itemCount: dayFlowList?.length ?? 0, |
|
scrollDirection: Axis.vertical, |
|
shrinkWrap: true, |
|
physics: BouncingScrollPhysics(), |
|
itemBuilder: (context, position) { |
|
return GestureDetector( |
|
onTap: () {}, |
|
child: flowItem(dayFlowList[position]), |
|
); |
|
}, |
|
)) |
|
], |
|
), |
|
); |
|
} |
|
|
|
///流水item |
|
Widget flowItem(DayFlowList dayFlowList) { |
|
return Container( |
|
decoration: BoxDecoration( |
|
borderRadius: BorderRadius.circular(0.w), |
|
color: Color(0xFFF3F7FF), |
|
), |
|
margin: EdgeInsets.only(bottom: 12.h), |
|
padding: EdgeInsets.symmetric(horizontal: 17.w, vertical: 8.h), |
|
child: Row( |
|
children: [ |
|
Expanded( |
|
child: Column( |
|
crossAxisAlignment: CrossAxisAlignment.start, |
|
children: [ |
|
Text( |
|
dayFlowList?.localDateTime ?? "", |
|
style: TextStyle( |
|
fontSize: 12.sp, |
|
fontWeight: MyFontWeight.medium, |
|
color: Color(0xD9000000), |
|
), |
|
), |
|
SizedBox( |
|
height: 7.h, |
|
), |
|
Text( |
|
dayFlowList?.storeName ?? "", |
|
style: TextStyle( |
|
fontSize: 12.sp, |
|
fontWeight: MyFontWeight.regular, |
|
color: Color(0x99000000), |
|
), |
|
), |
|
], |
|
)), |
|
Text.rich( |
|
TextSpan( |
|
children: [ |
|
TextSpan( |
|
text: (dayFlowList?.amount != "0.00") ? "+" : "-", |
|
style: TextStyle( |
|
fontSize: 12.sp, |
|
fontWeight: MyFontWeight.medium, |
|
color: Color(0xD9000000), |
|
), |
|
), |
|
TextSpan( |
|
text: (dayFlowList?.amount != "0.00") |
|
? (dayFlowList?.amount ?? "") |
|
: (dayFlowList?.refundAmount ?? ""), |
|
style: TextStyle( |
|
fontSize: 14.sp, |
|
fontWeight: MyFontWeight.medium, |
|
color: Color(0xD9000000), |
|
), |
|
), |
|
], |
|
), |
|
), |
|
], |
|
), |
|
); |
|
} |
|
|
|
@override |
|
bool get wantKeepAlive => true; |
|
}
|
|
|