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.

1698 lines
58 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/business_vip_list.dart' as vip;
import '../../retrofit/data/day_count.dart';
import '../../retrofit/data/order_trend.dart';
import '../../retrofit/data/popular_sales_list.dart';
import '../../retrofit/data/recharge_flow_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<vip.Records> records = [];
List<Records> rechargeFlowList = [];
List<OrderTrend> orderTrend = [];
VipCountsInfo vipCountsInfo;
int daySelectIndex = 0;
int vipIndex = 0;
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({int index, isLoading = true}) async {
if (isLoading)
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[index ?? widget.selectStoreIndex].name ==
"所有门店"
? "0"
: widget.businessLoginInfo
.storeList[index ?? widget.selectStoreIndex].id);
if(vipIndex != 1 && vipIndex != 2){
queryDayAmount();
queryPopularList(isSing: false);
queryOrderTrend();
queryVipCounts();
queryDayFlow();
}
if(vipIndex == 1)
queryVipList();
if(vipIndex == 2)
queryRechargeFlow();
});
}
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);
refreshController.refreshFailed();
refreshController.loadFailed();
});
if (baseData != null && baseData.isSuccess) {
dayCount = baseData.data;
}
} finally {
addLoadCount();
}
}
///热销榜单
queryPopularList({isSing = true}) async {
try {
if (isSing)
EasyLoading.show(
status: S.current.zhengzaijiazai,
maskType: EasyLoadingMaskType.black);
BaseData<PopularSalesList> baseData = await businessService
.popularList(daySelectIndex.toString())
.catchError((error) {});
if (baseData != null && baseData.isSuccess) {
popularSalesList = baseData.data;
}
} finally {
if (isSing) {
setState(() {});
EasyLoading.dismiss();
} else {
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) {
lineChartSample2Data.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()), "1")
.catchError((error) {});
if (baseData != null && baseData.isSuccess) {
dayFlowList = baseData.data;
}
} finally {
addLoadCount();
}
}
///会员列表
queryVipList() async {
try {
BaseData<vip.BusinessVipList> baseData = await businessService.vipDataList({
"map": {"nickname": "", "phone": "", "source": "", "hasMoney": "2"},
"model": {"tenantCode": null},
"date": "",
"sort": "id",
"size": 12,
"current": 1
}).catchError((error) {});
if (baseData != null && baseData.isSuccess) {
records.clear();
records.addAll(baseData?.data?.records ?? []);
setState((){});
}
} finally {
EasyLoading.dismiss();
}
}
///会员充值流水
queryRechargeFlow() async {
try {
BaseData<RechargeFlowList> baseData = await businessService.rechargeFlow({
"size": 10,
"pageSize": 10,
"current": 1,
"currentPage": 1,
"sort": "id",
"order": "descending",
"model": {"id":""},
"timeRange": null
}).catchError((error) {});
if (baseData != null && baseData.isSuccess) {
rechargeFlowList.clear();
rechargeFlowList.addAll(baseData?.data?.records ?? []);
setState((){});
}
} finally {
EasyLoading.dismiss();
}
}
@override
Widget build(BuildContext context) {
super.build(context);
return Column(
children: [
Expanded(
child: Container(
child: SmartRefresher(
controller: refreshController,
enablePullDown: true,
enablePullUp: false,
header: MyHeader(
color: Color(0xFF30415B),
),
physics: BouncingScrollPhysics(),
scrollController: scrollController,
footer: CustomFooter(
builder: (context, mode) {
return MyFooter(mode);
},
),
onRefresh: () {
_onRefresh(isLoading: false);
},
child: SingleChildScrollView(
physics: NeverScrollableScrollPhysics(),
child: Column(
children: [
homeTop(),
tradeOverview(),
vipManage(),
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: () {
showIdentitySwitchDialog();
},
child: Container(
padding: EdgeInsets.symmetric(horizontal: 10.w),
child: Image.asset(
"assets/image/bs_user_switch.webp",
width: 25.h,
height: 25.h,
color: Colors.white,
),
)),
GestureDetector(
behavior: HitTestBehavior.opaque,
onTap: () {
Navigator.of(context)
.pushNamed('/router/scan_code_page', arguments: {
"storeId": widget.businessLoginInfo
.storeList[widget.selectStoreIndex].name ==
"所有门店"
? "0"
: widget.businessLoginInfo
.storeList[widget.selectStoreIndex].id
});
},
child: Image.asset(
"assets/image/icon_scan_qr_code.webp",
width: 28.h,
height: 28.h,
),
)
],
),
Container(
margin: EdgeInsets.only(top: 14.h),
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(index: index);
}
}
///用户身份切换
showIdentitySwitchDialog() async {
SharedPreferences sharedPreferences = await SharedPreferences.getInstance();
showDialog(
context: context,
builder: (context) {
return AlertDialog(
content: GestureDetector(
behavior: HitTestBehavior.opaque,
onTap: () {
sharedPreferences.setString('identitySwitch', "2");
Navigator.of(context).pushNamedAndRemoveUntil(
'/router/main_page',
(route) => false,
);
},
child: Column(
mainAxisSize: MainAxisSize.min,
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Image.asset(
"assets/image/bs_user_switch_bg.webp",
width: 144.h,
height: 97.h,
),
Padding(
padding: EdgeInsets.only(top: 10.h, bottom: 10.h),
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Image.asset(
"assets/image/bs_switch.webp",
width: 12.h,
height: 12.h,
),
SizedBox(
width: 10.w,
),
Text(
"切换成用户端",
style: TextStyle(
color: Color(0xFF30415B),
fontSize: 15.sp,
fontWeight: MyFontWeight.bold,
),
),
],
),
)
],
),
));
},
);
}
///生意总览
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,
),
LineChartSample2(lineChartSample2Data, "销售量"),
],
),
);
}
///会员概览
Widget userOverview() {
return Container(
color: Colors.white,
margin: EdgeInsets.only(bottom: 16.h),
child: Column(
children: [
Row(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Expanded(
child: GestureDetector(
behavior: HitTestBehavior.opaque,
onTap: () {
showVipTipDialog(1);
},
child: Container(
padding: EdgeInsets.symmetric(horizontal: 8.w, vertical: 6.h),
margin: EdgeInsets.symmetric(horizontal: 4.w),
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,
),
),
],
),
),
)),
Expanded(
child: GestureDetector(
behavior: HitTestBehavior.opaque,
onTap: () {
showVipTipDialog(2);
},
child: Container(
padding: EdgeInsets.symmetric(
horizontal: 8.w, vertical: 6.h),
margin: EdgeInsets.symmetric(horizontal: 4.w),
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,
),
),
],
),
))),
Expanded(
child: GestureDetector(
behavior: HitTestBehavior.opaque,
onTap: () {
showVipTipDialog(3);
},
child: Container(
padding: EdgeInsets.symmetric(
horizontal: 8.w, vertical: 6.h),
margin: EdgeInsets.symmetric(horizontal: 4.w),
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,
),
),
],
),
))),
],
)
],
),
);
}
///会员管理
Widget vipManage() {
return Container(
color: Colors.white,
margin: EdgeInsets.only(top: 16.h),
padding: EdgeInsets.only(bottom: 12.h),
child: Column(
children: [
Padding(
padding: EdgeInsets.only(left: 16.w),
child: Row(
children: [
Container(width: 4.w, height: 16.h, color: Color(0xFF30415B),margin: EdgeInsets.only(right: 12.w,top: 12.h),),
Expanded(
child: Padding(
padding: EdgeInsets.only(top: 12.h),
child: Text(
"会员管理",
style: TextStyle(
fontSize: 15.sp,
fontWeight: MyFontWeight.semi_bold,
color: Color(0xFF0D0D0D),
),
),
),
),
GestureDetector(
behavior: HitTestBehavior.opaque,
onTap: () {
Navigator.of(context).pushNamed(
'/router/business_vip_page',
arguments: {"storeId": widget.businessLoginInfo
.storeList[widget.selectStoreIndex].name ==
"所有门店"
? "0"
: widget.businessLoginInfo
.storeList[widget.selectStoreIndex].id,},
);
},
child: Container(
// color: Colors.red,
padding: EdgeInsets.only(left: 20.w,right: 20.w,top: 12.h),
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,
),
],
),
),
)
],
)),
Padding(
padding: EdgeInsets.only(left: 16.w),
child: Row(
children: [
GestureDetector(
behavior: HitTestBehavior.opaque,
onTap: () {
setState(() {
vipIndex = 0;
});
},
child: Container(
padding:
EdgeInsets.only(right: 20.w, top: 15.h, bottom: 18.h),
alignment: Alignment.center,
child: Text(
"会员概览",
style: TextStyle(
fontSize: 14.sp,
fontWeight: MyFontWeight.bold,
color: vipIndex == 0
? Color(0xFF30415B)
: Color(0XFF262626),
),
),
),
),
GestureDetector(
behavior: HitTestBehavior.opaque,
onTap: () {
setState(() {
vipIndex = 1;
_onRefresh();
});
},
child: Container(
padding:
EdgeInsets.only(right: 20.w, top: 15.h, bottom: 18.h),
alignment: Alignment.center,
child: Text(
"会员列表",
style: TextStyle(
fontSize: 14.sp,
fontWeight: MyFontWeight.bold,
color: vipIndex == 1
? Color(0xFF30415B)
: Color(0XFF262626),
),
),
),
),
GestureDetector(
behavior: HitTestBehavior.opaque,
onTap: () {
setState(() {
vipIndex = 2;
_onRefresh();
});
},
child: Container(
padding:
EdgeInsets.only(right: 20.w, top: 15.h, bottom: 18.h),
alignment: Alignment.center,
child: Text(
"会员充值流水",
style: TextStyle(
fontSize: 14.sp,
fontWeight: MyFontWeight.bold,
color: vipIndex == 2
? Color(0xFF30415B)
: Color(0XFF262626),
),
),
),
),
],
)),
if (vipIndex == 0) userOverview(),
if (vipIndex == 1 || vipIndex == 2)
Padding(
padding: EdgeInsets.only(left: 16.w),
child: Row(
children: [
Expanded(
child: Text(
"昵称",
style: TextStyle(
fontSize: 12.sp,
fontWeight: MyFontWeight.medium,
color: Color(0xFF30415B),
),
),
),
Expanded(
child: Text(
"手机号",
style: TextStyle(
fontSize: 12.sp,
fontWeight: MyFontWeight.medium,
color: Color(0xFF30415B),
),
),
),
Expanded(
child: Text(
"商户余额",
style: TextStyle(
fontSize: 12.sp,
fontWeight: MyFontWeight.medium,
color: Color(0xFF30415B),
),
),
),
],
)),
if (vipIndex == 1)
Container(
height: 310.h,
padding: EdgeInsets.only(left: 16.w),
child:
(records == null ||
records.length == 0)
? NoDataView(
src: "assets/image/bs_no data_logo.webp",
isShowBtn: false,
text: "暂无数据",
fontSize: 16.sp,
margin: EdgeInsets.all(20.h),
) :
ListView.builder(
padding: EdgeInsets.zero,
itemCount: records?.length ?? 0,
scrollDirection: Axis.vertical,
shrinkWrap: true,
physics: BouncingScrollPhysics(),
itemBuilder: (context, position) {
return GestureDetector(
onTap: () {},
child: busVipItem(records[position]),
);
},
),
),
if (vipIndex == 2)
Container(
height: 310.h,
padding: EdgeInsets.only(left: 16.w),
child:
(rechargeFlowList == null ||
rechargeFlowList.length == 0)
? NoDataView(
src: "assets/image/bs_no data_logo.webp",
isShowBtn: false,
text: "暂无数据",
fontSize: 16.sp,
margin: EdgeInsets.all(20.h),
) :
ListView.builder(
padding: EdgeInsets.zero,
itemCount: rechargeFlowList?.length ?? 0,
scrollDirection: Axis.vertical,
shrinkWrap: true,
physics: BouncingScrollPhysics(),
itemBuilder: (context, position) {
return GestureDetector(
onTap: () {},
child: busRechargeFlowItem(rechargeFlowList[position]),
);
},
),
),
],
),
);
}
///会员列表
Widget busVipItem(vip.Records records) {
return Container(
margin: EdgeInsets.only(top: 17.h, bottom: 20.h),
child: Row(
children: [
Expanded(
child: Text(
records?.nickname ?? "",
style: TextStyle(
fontSize: 12.sp,
fontWeight: MyFontWeight.medium,
color: Color(0xD9000000),
),
),
),
Expanded(
child: Text(
records?.phone ?? "",
style: TextStyle(
fontSize: 12.sp,
fontWeight: MyFontWeight.medium,
color: Color(0xD9000000),
),
),
),
Expanded(
child: Text(
records?.balance ?? "",
style: TextStyle(
fontSize: 12.sp,
fontWeight: MyFontWeight.medium,
color: Color(0xD9000000),
),
),
),
],
),
);
}
///会员充值流水
Widget busRechargeFlowItem(Records rechargeFlowList) {
return Container(
margin: EdgeInsets.only(top: 17.h, bottom: 20.h),
child: Row(
children: [
Expanded(
child: Text(
rechargeFlowList?.createPerson ?? "",
style: TextStyle(
fontSize: 12.sp,
fontWeight: MyFontWeight.medium,
color: Color(0xD9000000),
),
),
),
Expanded(
child: Text(
rechargeFlowList?.phone ?? "",
style: TextStyle(
fontSize: 12.sp,
fontWeight: MyFontWeight.medium,
color: Color(0xD9000000),
),
),
),
Expanded(
child: Text(
rechargeFlowList?.balance ?? "",
style: TextStyle(
fontSize: 12.sp,
fontWeight: MyFontWeight.medium,
color: Color(0xD9000000),
),
),
),
],
),
);
}
///用户概览弹窗提示
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: () {
daySelectIndex = 0;
queryPopularList();
},
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: () {
daySelectIndex = 1;
queryPopularList();
},
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: () {
daySelectIndex = 7;
queryPopularList();
},
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 == 7
? 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 == 7
? Colors.white
: Color(0XFF30415B),
),
),
)),
GestureDetector(
behavior: HitTestBehavior.opaque,
onTap: () {
daySelectIndex = 30;
queryPopularList();
},
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 == 30
? 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 == 30
? Colors.white
: Color(0XFF30415B),
),
),
)),
],
),
Container(
height: 310.h,
child: (popularSalesList == null ||
popularSalesList.saleProductList.length == 0)
? NoDataView(
src: "assets/image/bs_no data_logo.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/bs_no data_logo.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;
}