Commit 71a705f0dc209aeb071d81cfccfca79498938d85

Authored by wdn127929
1 parent 4744584f

封装柱形图widget

import 'package:flutter/material.dart';
import 'package:fl_chart/fl_chart.dart';
import '../../../../res/colors.dart';
import '../../../../utils/screen_util.dart';
/**
* 柱形图
*/
class BarData {
const BarData(this.color, this.value);
final Color color;
final double value;
}
class BarChartWidget extends StatefulWidget {
final List<BarData> dataList;
BarChartWidget({Key key, this.dataList}) : super(key: key);
@override
_BarChartWidgetState createState() => _BarChartWidgetState();
}
class _BarChartWidgetState extends State<BarChartWidget> {
BarChartGroupData generateBarGroup(
int x,
Color color,
double value,
) {
return BarChartGroupData(
x: x,
barRods: [
BarChartRodData(
toY: value,
// gradient: _barsGradient,
color: color,
borderRadius: BorderRadius.zero,
width: w(13),
)
],
showingTooltipIndicators: [0],
);
}
BarTouchData get barTouchData => BarTouchData(
enabled: false,
touchTooltipData: BarTouchTooltipData(
tooltipBgColor: Colors.transparent,
tooltipPadding: EdgeInsets.zero,
tooltipMargin: w(0),
getTooltipItem: (
BarChartGroupData group,
int groupIndex,
BarChartRodData rod,
int rodIndex,
) {
return BarTooltipItem(
// rod.toY.toString(),
rod.toY.round().toString(), //整数的话,可以这样显示
TextStyle(
fontSize: font(10),
color: MyColours.color_666666,
// fontWeight: FontWeight.bold,
),
);
},
),
);
Widget getTitles(double value, TitleMeta meta) {
final style = TextStyle(
color: MyColours.color_999999,
fontSize: font(10),
);
String text;
switch (value.toInt()) {
case 0:
text = '1月';
break;
case 1:
text = '2月';
break;
case 2:
text = '3月';
break;
case 3:
text = '4月';
break;
case 4:
text = '5月';
break;
case 5:
text = '6月';
break;
case 6:
text = '7月';
break;
case 7:
text = '8月';
break;
case 8:
text = '9月';
break;
case 9:
text = '10月';
break;
case 10:
text = '11月';
break;
case 11:
text = '12月';
break;
default:
text = '';
break;
}
return SideTitleWidget(
axisSide: meta.axisSide,
space: w(6),
child: Text(text, style: style),
);
}
Widget leftTitles(double value, TitleMeta meta) {
if (value == meta.max) {
return Container();
}
TextStyle style =
TextStyle(fontSize: font(10), color: MyColours.color_999999);
return SideTitleWidget(
axisSide: meta.axisSide,
space: w(6),
child: Text(
meta.formattedValue,
style: style,
textAlign: TextAlign.right,
));
}
FlTitlesData get titlesData => FlTitlesData(
show: true,
bottomTitles: AxisTitles(
sideTitles: SideTitles(
showTitles: true,
reservedSize: font(40),
getTitlesWidget: getTitles,
),
),
leftTitles: AxisTitles(
drawBehindEverything: true,
sideTitles: SideTitles(
showTitles: true,
reservedSize: w(30),
getTitlesWidget: leftTitles,
// interval: 5
),
),
topTitles: AxisTitles(
sideTitles: SideTitles(showTitles: false),
),
rightTitles: AxisTitles(
sideTitles: SideTitles(showTitles: false),
),
);
FlBorderData get borderData => FlBorderData(
show: false,
);
LinearGradient get _barsGradient => LinearGradient(
colors: [
MyColours.color_8EBBBE,
MyColours.color_8EBBBE,
],
begin: Alignment.bottomCenter,
end: Alignment.topCenter,
);
List<BarChartGroupData> getData(double barsWidth, double barsSpace) {
return [
BarChartGroupData(
x: 0,
barRods: [
BarChartRodData(
toY: 8,
// gradient: _barsGradient,
color: MyColours.color_8EBBBE,
borderRadius: BorderRadius.zero,
width: barsWidth,
)
],
showingTooltipIndicators: [0],
),
BarChartGroupData(
x: 1,
barRods: [
BarChartRodData(
toY: 10,
// gradient: _barsGradient,
borderRadius: BorderRadius.zero,
width: barsWidth,
color: MyColours.color_8EBBBE)
],
showingTooltipIndicators: [0],
),
BarChartGroupData(
x: 2,
barRods: [
BarChartRodData(
toY: 14,
borderRadius: BorderRadius.zero,
width: barsWidth,
// gradient: _barsGradient,
color: MyColours.color_8EBBBE)
],
showingTooltipIndicators: [0],
),
BarChartGroupData(
x: 3,
barRods: [
BarChartRodData(
toY: 15,
borderRadius: BorderRadius.zero,
width: barsWidth,
// gradient: _barsGradient,
color: MyColours.color_8EBBBE)
],
showingTooltipIndicators: [0],
),
BarChartGroupData(
x: 4,
barRods: [
BarChartRodData(
toY: 13,
borderRadius: BorderRadius.zero,
width: barsWidth,
// gradient: _barsGradient,
color: MyColours.color_8EBBBE)
],
showingTooltipIndicators: [0],
),
BarChartGroupData(
x: 5,
barRods: [
BarChartRodData(
toY: 10,
borderRadius: BorderRadius.zero,
width: barsWidth,
// gradient: _barsGradient,
color: MyColours.color_8EBBBE)
],
showingTooltipIndicators: [0],
),
BarChartGroupData(
x: 6,
barRods: [
BarChartRodData(
toY: 16,
borderRadius: BorderRadius.zero,
width: barsWidth,
// gradient: _barsGradient,
color: MyColours.color_8EBBBE)
],
showingTooltipIndicators: [0],
),
BarChartGroupData(
x: 7,
barRods: [
BarChartRodData(
toY: 16,
borderRadius: BorderRadius.zero,
width: barsWidth,
// gradient: _barsGradient,
color: MyColours.color_8EBBBE)
],
showingTooltipIndicators: [0],
),
BarChartGroupData(
x: 8,
barRods: [
BarChartRodData(
toY: 16,
borderRadius: BorderRadius.zero,
width: barsWidth,
// gradient: _barsGradient,
color: MyColours.color_8EBBBE)
],
showingTooltipIndicators: [0],
),
BarChartGroupData(
x: 9,
barRods: [
BarChartRodData(
toY: 16,
borderRadius: BorderRadius.zero,
width: barsWidth,
// gradient: _barsGradient,
color: MyColours.color_8EBBBE)
],
showingTooltipIndicators: [0],
),
BarChartGroupData(
x: 10,
barRods: [
BarChartRodData(
toY: 16,
borderRadius: BorderRadius.zero,
width: barsWidth,
// gradient: _barsGradient,
color: MyColours.color_8EBBBE)
],
showingTooltipIndicators: [0],
),
BarChartGroupData(
x: 11,
barRods: [
BarChartRodData(
toY: 16,
borderRadius: BorderRadius.zero,
width: barsWidth,
// gradient: _barsGradient,
color: MyColours.color_8EBBBE)
],
showingTooltipIndicators: [0],
),
];
}
@override
Widget build(BuildContext context) {
return BarChart(
BarChartData(
barTouchData: barTouchData,
titlesData: titlesData,
borderData: borderData,
barGroups: widget.dataList.asMap().entries.map((e) {
final index = e.key;
final data = e.value;
return generateBarGroup(
index,
data.color,
data.value,
);
}).toList(),
groupsSpace: w(10),
gridData: FlGridData(
show: true,
// checkToShowHorizontalLine: (value) => value % 10 == 0,
getDrawingHorizontalLine: (value) => FlLine(
color: MyColours.color_DBDBDB,
strokeWidth: w(1),
),
drawVerticalLine: false,
),
alignment: BarChartAlignment.spaceAround,
// maxY: 20,
// minY: 0,
// baselineY:
),
);
}
}
... ...
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:one_key/constant/state.dart';
import 'package:one_key/models/marketing_by_seller_model.dart';
import 'package:one_key/models/seller_info.dart';
import 'package:one_key/models/store_customer_home_model.dart';
import 'package:one_key/pages/my/customer_type/store_customer/bar_chart_page.dart';
import 'package:one_key/provider/customer_provider.dart';
import 'package:one_key/provider/user_model.dart';
import 'package:one_key/res/colors.dart';
import 'package:one_key/route/navigator_util.dart';
import 'package:one_key/utils/event_bus.dart';
import 'package:one_key/utils/utils.dart';
import 'package:one_key/widgets/h_empty_view.dart';
import 'package:one_key/widgets/page_exception.dart';
import 'package:one_key/widgets/round_button.dart';
import 'package:one_key/widgets/system_app_bar.dart';
import 'package:one_key/widgets/v_empty_view.dart';
import 'package:provider/provider.dart';
import '../../../../utils/screen_util.dart';
class StoreCustomerHomePage extends StatefulWidget {
StoreCustomerHomePage({Key key}) : super(key: key);
@override
_StoreCustomerHomePageState createState() => _StoreCustomerHomePageState();
}
class _StoreCustomerHomePageState extends State<StoreCustomerHomePage> {
ScrollController _controller = ScrollController();
CustomerProvider customerProvider;
bool showWarning = false;
List<BarData> dataList = [
BarData(MyColours.color_8EBBBE, 188),
BarData(MyColours.color_8EBBBE, 8),
BarData(MyColours.color_8EBBBE, 15),
BarData(MyColours.color_8EBBBE, 5),
BarData(MyColours.color_8EBBBE, 2),
BarData(MyColours.color_8EBBBE, 2),
BarData(MyColours.color_8EBBBE, 18),
BarData(MyColours.color_8EBBBE, 8),
BarData(MyColours.color_8EBBBE, 15),
BarData(MyColours.color_8EBBBE, 5),
BarData(MyColours.color_8EBBBE, 2),
BarData(MyColours.color_8EBBBE, 2),
];
@override
void initState() {
super.initState();
WidgetsBinding.instance.addPostFrameCallback((_) {
_getSellerGuestManage();
_getMarketingBySeller();
});
bus.on("refresh_store_customer_home", (arg) {
_getMarketingBySeller();
_getSellerGuestManage();
});
}
@override
void dispose() {
bus.off('refresh_store_customer_home');
// bus.off("refresh_coupon_list");
super.dispose();
}
///全店客情首页
_getSellerGuestManage() async {
StoreCustomerHomeSunModel model =
await customerProvider.getSellerGuestManage(context);
// setState(() {});
}
_getMarketingBySeller() async {
Map<String, String> params = {
"sellerid": Provider.of<UserModel>(context, listen: false).user.sellerid
};
List<MarketingBySellerSunModel> list =
await customerProvider.getMarketingBySeller(context, params);
if (list != null && list.length > 0) {
bool temp = list.any((value) {
return value.finishedStatus == '0';
});
setState(() {
showWarning = temp;
});
}
// await customerProvider.searchData(customerProvider.controller.text);
}
///活跃客户、沉睡客户、流失客户
Widget _percentWidget(String pnum, String btnTitle, String percent,
{String uid = ''}) {
return InkWell(
onTap: () async {
String index = '0';
if (btnTitle == '活跃客户') {
index = '1';
} else if (btnTitle == '沉睡客户') {
index = '2';
} else if (btnTitle == '流失客户') {
index = '3';
}
if (btnTitle == '未分配') {
NavigatorUtil.goCustomerListPage(
context, FromPage.FromPageHome, uid,
index: index, distribution: true);
} else {
NavigatorUtil.goCustomerListPage(
context, FromPage.FromPageHome, uid,
index: index);
}
},
child: Container(
color: MyColours.color_ffffff,
// height: ScreenUtil().setWidth(230),
width: (ScreenUtil().screenWidth - ScreenUtil().setWidth(20)) / 3,
height: (ScreenUtil().screenWidth - ScreenUtil().setWidth(20)) / 3,
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(pnum,
style: TextStyle(
color: MyColours.color_199095,
fontSize: ScreenUtil().setSp(40),
fontWeight: FontWeight.bold)),
Text('位',
style: TextStyle(
color: MyColours.color_199095,
fontSize: ScreenUtil().setSp(24),
))
],
),
btnTitle == '' ? SizedBox() : VEmptyView(20),
btnTitle == ''
? SizedBox()
: InkWell(
onTap: () async {
String index = '0';
if (btnTitle == '活跃客户') {
index = '1';
} else if (btnTitle == '沉睡客户') {
index = '2';
} else if (btnTitle == '流失客户') {
index = '3';
}
if (btnTitle == '未分配') {
NavigatorUtil.goCustomerListPage(
context, FromPage.FromPageHome, uid,
index: index, distribution: true);
} else {
NavigatorUtil.goCustomerListPage(
context, FromPage.FromPageHome, uid,
index: index);
}
},
child: Container(
height: ScreenUtil().setWidth(45),
width: ScreenUtil().setWidth(160),
alignment: Alignment.center,
padding: EdgeInsets.symmetric(horizontal: w(10)),
decoration: BoxDecoration(
color: MyColours.color_ffffff,
border: Border.all(
width: w(1),
color: Color.fromRGBO(118, 118, 118, 1),
),
borderRadius:
BorderRadius.circular(ScreenUtil().setWidth(30)),
),
child: Text(
btnTitle,
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: TextStyle(
color: MyColours.color_333333,
fontSize: font(12)),
),
))
// RoundButton(
// onPressed: () async {
// String index = '0';
// if (btnTitle == '活跃客户') {
// index = '1';
// } else if (btnTitle == '沉睡客户') {
// index = '2';
// } else if (btnTitle == '流失客户') {
// index = '3';
// }
// NavigatorUtil.goCustomerListPage(
// context, FromPage.FromPageHome, uid,
// index: index);
// },
// text: btnTitle,
// fontSize: 24,
// isBold: false,
// textColor: MyColours.color_333333,
// gradientStart: MyColours.color_ffffff,
// gradientEnd: MyColours.color_ffffff,
// borderColor: Color.fromRGBO(118, 118, 118, 1),
// height: ScreenUtil().setWidth(45),
// width: ScreenUtil().setWidth(160),
// radius: ScreenUtil().setWidth(30),
// ),
,
VEmptyView(16),
percent == null
? SizedBox()
: Text('${percent}%',
style: TextStyle(
color: MyColours.color_199095,
fontSize: ScreenUtil().setSp(24),
)),
],
),
));
}
Widget _chart() {
return AspectRatio(
aspectRatio: 1.4,
child: Padding(
padding: EdgeInsets.all(w(20)),
child: LayoutBuilder(builder: (context, constraints) {
return BarChartWidget(
dataList: dataList,
);
})));
// return Container(
// height: w(143),
// child: BarChart(
// BarChartData(
// barTouchData: barTouchData,
// titlesData: titlesData,
// borderData: borderData,
// barGroups: barGroups,
// gridData: FlGridData(show: false),
// alignment: BarChartAlignment.spaceAround,
// maxY: 20,
// ),
// ));
}
@override
Widget build(BuildContext context) {
customerProvider = Provider.of<CustomerProvider>(context, listen: false);
return Scaffold(
backgroundColor: Color.fromRGBO(246, 248, 250, 1),
appBar: SystemAppBar('全店客情', onTap: () {
EventBus().emit('changeStatusColor');
Navigator.pop(context);
}),
body: WillPopScope(onWillPop: () async {
EventBus().emit('changeStatusColor');
return true;
}, child: Consumer<CustomerProvider>(builder: (context, model, _) {
if (model.pageStateStoreHome != PageState.Success) {
return ExceptionPage(
pageState: model.pageStateStoreHome,
callback: () {
// getTableList();
_getSellerGuestManage();
},
emptyMsg: "暂时没有全店客情哦",
emptyImg: "empty_search",
showMsg: "加载中,请稍后...",
);
} else {
return Column(children: [
Expanded(
child: SingleChildScrollView(
controller: _controller,
child: Column(
children: [
VEmptyView(10),
Stack(
children: [
Container(
color: MyColours.color_ffffff,
padding: EdgeInsets.symmetric(
vertical: ScreenUtil().setWidth(30)),
child: Column(
children: [
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(
'${customerProvider.storeSunmodel.myCustomer}',
style: TextStyle(
color: MyColours.color_199095,
fontSize: ScreenUtil().setSp(60),
fontWeight: FontWeight.bold),
),
Text(
'位',
style: TextStyle(
color: MyColours.color_199095,
fontWeight: FontWeight.bold,
fontSize: ScreenUtil().setSp(30)),
)
],
),
VEmptyView(10),
RoundButton(
onPressed: () async {
NavigatorUtil.goCustomerListPage(
context, FromPage.FromPageHome, '');
},
text: '全店客户',
fontSize: 24,
isBold: false,
textColor: MyColours.color_333333,
gradientStart: MyColours.color_ffffff,
gradientEnd: MyColours.color_ffffff,
borderColor: Color.fromRGBO(118, 118, 118, 1),
height: ScreenUtil().setWidth(45),
width: ScreenUtil().setWidth(160),
radius: ScreenUtil().setWidth(30),
)
],
),
),
Positioned(
top: ScreenUtil().setWidth(30),
right: ScreenUtil().setWidth(40),
child: InkWell(
onTap: () {
NavigatorUtil.goCustomerSetPage(context);
},
child: Image.asset(Utils.getImgPath('c_set'),
width: ScreenUtil().setWidth(40))))
],
),
VEmptyView(10),
Row(
children: [
_percentWidget(
'${customerProvider.storeSunmodel.active.count}',
'活跃客户',
'${customerProvider.storeSunmodel.active.scale}'),
HEmptyView(10),
_percentWidget(
'${customerProvider.storeSunmodel.sleep.count}',
'沉睡客户',
'${customerProvider.storeSunmodel.sleep.scale}'),
HEmptyView(10),
_percentWidget(
'${customerProvider.storeSunmodel.drain.count}',
'流失客户',
'${customerProvider.storeSunmodel.drain.scale}'),
],
),
// GridView.builder(
// controller: _controller,
// shrinkWrap: true,
// cacheExtent: ScreenUtil().setWidth(0),
// itemCount: 3,
// gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
// crossAxisCount: 3,
// childAspectRatio: 1,
// mainAxisSpacing: ScreenUtil().setWidth(10),
// crossAxisSpacing: ScreenUtil().setWidth(10)),
// itemBuilder: (BuildContext context, int index) {
// // locationState = state;
// return _percentWidget('1999', '活跃客户', '39.20');
// }),
// Row(
// children: [
// _percentWidget('19992', '活跃客户', '90.90'),
// HEmptyView(10),
// _percentWidget('19992', '沉睡客户', '90.90'),
// HEmptyView(10),
// _percentWidget('19992', '流失客户', '5.90'),
// ],
// ),
Padding(
padding: EdgeInsets.symmetric(
vertical: ScreenUtil().setWidth(30)),
child: Text(
'客户经理',
style: TextStyle(
fontSize: ScreenUtil().setSp(28),
color: MyColours.color_333333),
),
),
GridView.builder(
controller: _controller,
shrinkWrap: true,
cacheExtent: ScreenUtil().setWidth(0),
itemCount:
customerProvider.storeSunmodel.sellerUser.length + 1,
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 3,
childAspectRatio: 1,
mainAxisSpacing: ScreenUtil().setWidth(10),
crossAxisSpacing: ScreenUtil().setWidth(10)),
itemBuilder: (BuildContext context, int index) {
// locationState = state;
if (index == 0) {
return _percentWidget(
'${customerProvider.storeSunmodel.distribution}',
'未分配',
null);
}
return _percentWidget(
'${customerProvider.storeSunmodel.sellerUser[index - 1].count}',
customerProvider.storeSunmodel.sellerUser[index - 1]
.account ==
null
? ''
: '${customerProvider.storeSunmodel.sellerUser[index - 1].nickName ?? customerProvider.storeSunmodel.sellerUser[index - 1].account}经理',
null,
uid: customerProvider
.storeSunmodel.sellerUser[index - 1].uid);
}),
VEmptyView(100),
_chart()
],
),
)),
Padding(
padding: EdgeInsets.only(bottom: ScreenUtil().setWidth(30)),
child: Stack(
children: [
RoundButton(
onPressed: () {
NavigatorUtil.goMarketingRecordsPage(
context, FromPage.FromPageStoreCustomer);
},
text: '营销记录',
fontSize: 24,
isBold: false,
textColor: MyColours.color_199095,
gradientStart: MyColours.color_ffffff,
gradientEnd: MyColours.color_ffffff,
borderColor: MyColours.color_199095,
height: ScreenUtil().setWidth(75),
width: ScreenUtil().setWidth(260),
radius: ScreenUtil().setWidth(10),
),
showWarning
? Positioned(
right: ScreenUtil().setWidth(30),
top: ScreenUtil().setWidth(40 / 2),
child: Image.asset(
Utils.getImgPath('warning'),
width: ScreenUtil().setWidth(35),
))
: SizedBox()
],
))
]);
}
})),
);
}
}
... ...
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:one_key/constant/state.dart';
import 'package:one_key/models/marketing_by_seller_model.dart';
import 'package:one_key/models/seller_info.dart';
import 'package:one_key/models/store_customer_home_model.dart';
import 'package:one_key/provider/customer_provider.dart';
import 'package:one_key/provider/user_model.dart';
import 'package:one_key/res/colors.dart';
import 'package:one_key/route/navigator_util.dart';
import 'package:one_key/utils/event_bus.dart';
import 'package:one_key/utils/utils.dart';
import 'package:one_key/widgets/h_empty_view.dart';
import 'package:one_key/widgets/page_exception.dart';
import 'package:one_key/widgets/round_button.dart';
import 'package:one_key/widgets/system_app_bar.dart';
import 'package:one_key/widgets/v_empty_view.dart';
import 'package:provider/provider.dart';
// import 'package:flutter/material.dart';
// import 'package:flutter_screenutil/flutter_screenutil.dart';
// import 'package:one_key/constant/state.dart';
// import 'package:one_key/models/marketing_by_seller_model.dart';
// import 'package:one_key/models/seller_info.dart';
// import 'package:one_key/models/store_customer_home_model.dart';
// import 'package:one_key/provider/customer_provider.dart';
// import 'package:one_key/provider/user_model.dart';
// import 'package:one_key/res/colors.dart';
// import 'package:one_key/route/navigator_util.dart';
// import 'package:one_key/utils/event_bus.dart';
// import 'package:one_key/utils/utils.dart';
// import 'package:one_key/widgets/h_empty_view.dart';
// import 'package:one_key/widgets/page_exception.dart';
// import 'package:one_key/widgets/round_button.dart';
// import 'package:one_key/widgets/system_app_bar.dart';
// import 'package:one_key/widgets/v_empty_view.dart';
// import 'package:provider/provider.dart';
import '../../../../utils/screen_util.dart';
// import '../../../../utils/screen_util.dart';
class StoreCustomerPage extends StatefulWidget {
StoreCustomerPage({Key key}) : super(key: key);
// class StoreCustomerPage extends StatefulWidget {
// StoreCustomerPage({Key key}) : super(key: key);
@override
_StoreCustomerPageState createState() => _StoreCustomerPageState();
}
// @override
// _StoreCustomerPageState createState() => _StoreCustomerPageState();
// }
class _StoreCustomerPageState extends State<StoreCustomerPage> {
ScrollController _controller = ScrollController();
CustomerProvider customerProvider;
bool showWarning = false;
// class _StoreCustomerPageState extends State<StoreCustomerPage> {
// ScrollController _controller = ScrollController();
// CustomerProvider customerProvider;
// bool showWarning = false;
@override
void initState() {
super.initState();
// @override
// void initState() {
// super.initState();
WidgetsBinding.instance.addPostFrameCallback((_) {
_getSellerGuestManage();
_getMarketingBySeller();
});
bus.on("refresh_store_customer_home", (arg) {
_getMarketingBySeller();
_getSellerGuestManage();
});
}
// WidgetsBinding.instance.addPostFrameCallback((_) {
// _getSellerGuestManage();
// _getMarketingBySeller();
// });
// bus.on("refresh_store_customer_home", (arg) {
// _getMarketingBySeller();
// _getSellerGuestManage();
// });
// }
@override
void dispose() {
bus.off('refresh_store_customer_home');
// bus.off("refresh_coupon_list");
super.dispose();
}
// @override
// void dispose() {
// bus.off('refresh_store_customer_home');
// // bus.off("refresh_coupon_list");
// super.dispose();
// }
///全店客情首页
_getSellerGuestManage() async {
StoreCustomerHomeSunModel model =
await customerProvider.getSellerGuestManage(context);
// setState(() {});
}
// ///全店客情首页
// _getSellerGuestManage() async {
// StoreCustomerHomeSunModel model =
// await customerProvider.getSellerGuestManage(context);
// // setState(() {});
// }
_getMarketingBySeller() async {
Map<String, String> params = {
"sellerid": Provider.of<UserModel>(context, listen: false).user.sellerid
};
List<MarketingBySellerSunModel> list =
await customerProvider.getMarketingBySeller(context, params);
if (list != null && list.length > 0) {
bool temp = list.any((value) {
return value.finishedStatus == '0';
});
setState(() {
showWarning = temp;
});
}
// await customerProvider.searchData(customerProvider.controller.text);
}
// _getMarketingBySeller() async {
// Map<String, String> params = {
// "sellerid": Provider.of<UserModel>(context, listen: false).user.sellerid
// };
// List<MarketingBySellerSunModel> list =
// await customerProvider.getMarketingBySeller(context, params);
// if (list != null && list.length > 0) {
// bool temp = list.any((value) {
// return value.finishedStatus == '0';
// });
// setState(() {
// showWarning = temp;
// });
// }
// // await customerProvider.searchData(customerProvider.controller.text);
// }
///活跃客户、沉睡客户、流失客户
Widget _percentWidget(String pnum, String btnTitle, String percent,
{String uid = ''}) {
return InkWell(
onTap: () async {
String index = '0';
// ///活跃客户、沉睡客户、流失客户
// Widget _percentWidget(String pnum, String btnTitle, String percent,
// {String uid = ''}) {
// return InkWell(
// onTap: () async {
// String index = '0';
if (btnTitle == '活跃客户') {
index = '1';
} else if (btnTitle == '沉睡客户') {
index = '2';
} else if (btnTitle == '流失客户') {
index = '3';
}
if (btnTitle == '未分配') {
NavigatorUtil.goCustomerListPage(
context, FromPage.FromPageHome, uid,
index: index, distribution: true);
} else {
NavigatorUtil.goCustomerListPage(
context, FromPage.FromPageHome, uid,
index: index);
}
},
child: Container(
color: MyColours.color_ffffff,
// height: ScreenUtil().setWidth(230),
width: (ScreenUtil().screenWidth - ScreenUtil().setWidth(20)) / 3,
height: (ScreenUtil().screenWidth - ScreenUtil().setWidth(20)) / 3,
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(pnum,
style: TextStyle(
color: MyColours.color_199095,
fontSize: ScreenUtil().setSp(40),
fontWeight: FontWeight.bold)),
Text('位',
style: TextStyle(
color: MyColours.color_199095,
fontSize: ScreenUtil().setSp(24),
))
],
),
btnTitle == '' ? SizedBox() : VEmptyView(20),
btnTitle == ''
? SizedBox()
: InkWell(
onTap: () async {
String index = '0';
// if (btnTitle == '活跃客户') {
// index = '1';
// } else if (btnTitle == '沉睡客户') {
// index = '2';
// } else if (btnTitle == '流失客户') {
// index = '3';
// }
// if (btnTitle == '未分配') {
// NavigatorUtil.goCustomerListPage(
// context, FromPage.FromPageHome, uid,
// index: index, distribution: true);
// } else {
// NavigatorUtil.goCustomerListPage(
// context, FromPage.FromPageHome, uid,
// index: index);
// }
// },
// child: Container(
// color: MyColours.color_ffffff,
// // height: ScreenUtil().setWidth(230),
// width: (ScreenUtil().screenWidth - ScreenUtil().setWidth(20)) / 3,
// height: (ScreenUtil().screenWidth - ScreenUtil().setWidth(20)) / 3,
// child: Column(
// mainAxisAlignment: MainAxisAlignment.center,
// children: [
// Row(
// mainAxisAlignment: MainAxisAlignment.center,
// children: [
// Text(pnum,
// style: TextStyle(
// color: MyColours.color_199095,
// fontSize: ScreenUtil().setSp(40),
// fontWeight: FontWeight.bold)),
// Text('位',
// style: TextStyle(
// color: MyColours.color_199095,
// fontSize: ScreenUtil().setSp(24),
// ))
// ],
// ),
// btnTitle == '' ? SizedBox() : VEmptyView(20),
// btnTitle == ''
// ? SizedBox()
// : InkWell(
// onTap: () async {
// String index = '0';
if (btnTitle == '活跃客户') {
index = '1';
} else if (btnTitle == '沉睡客户') {
index = '2';
} else if (btnTitle == '流失客户') {
index = '3';
}
if (btnTitle == '未分配') {
NavigatorUtil.goCustomerListPage(
context, FromPage.FromPageHome, uid,
index: index, distribution: true);
} else {
NavigatorUtil.goCustomerListPage(
context, FromPage.FromPageHome, uid,
index: index);
}
},
child: Container(
height: ScreenUtil().setWidth(45),
width: ScreenUtil().setWidth(160),
alignment: Alignment.center,
padding: EdgeInsets.symmetric(horizontal: w(10)),
decoration: BoxDecoration(
color: MyColours.color_ffffff,
border: Border.all(
width: w(1),
color: Color.fromRGBO(118, 118, 118, 1),
),
borderRadius:
BorderRadius.circular(ScreenUtil().setWidth(30)),
),
child: Text(
btnTitle,
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: TextStyle(
color: MyColours.color_333333,
fontSize: font(12)),
),
))
// RoundButton(
// onPressed: () async {
// String index = '0';
// if (btnTitle == '活跃客户') {
// index = '1';
// } else if (btnTitle == '沉睡客户') {
// index = '2';
// } else if (btnTitle == '流失客户') {
// index = '3';
// }
// if (btnTitle == '未分配') {
// NavigatorUtil.goCustomerListPage(
// context, FromPage.FromPageHome, uid,
// index: index, distribution: true);
// } else {
// NavigatorUtil.goCustomerListPage(
// context, FromPage.FromPageHome, uid,
// index: index);
// }
// },
// child: Container(
// height: ScreenUtil().setWidth(45),
// width: ScreenUtil().setWidth(160),
// alignment: Alignment.center,
// padding: EdgeInsets.symmetric(horizontal: w(10)),
// decoration: BoxDecoration(
// color: MyColours.color_ffffff,
// border: Border.all(
// width: w(1),
// color: Color.fromRGBO(118, 118, 118, 1),
// ),
// borderRadius:
// BorderRadius.circular(ScreenUtil().setWidth(30)),
// ),
// child: Text(
// btnTitle,
// maxLines: 1,
// overflow: TextOverflow.ellipsis,
// style: TextStyle(
// color: MyColours.color_333333,
// fontSize: font(12)),
// ),
// ))
// // RoundButton(
// // onPressed: () async {
// // String index = '0';
// if (btnTitle == '活跃客户') {
// index = '1';
// } else if (btnTitle == '沉睡客户') {
// index = '2';
// } else if (btnTitle == '流失客户') {
// index = '3';
// }
// NavigatorUtil.goCustomerListPage(
// context, FromPage.FromPageHome, uid,
// index: index);
// },
// text: btnTitle,
// fontSize: 24,
// isBold: false,
// textColor: MyColours.color_333333,
// gradientStart: MyColours.color_ffffff,
// gradientEnd: MyColours.color_ffffff,
// borderColor: Color.fromRGBO(118, 118, 118, 1),
// height: ScreenUtil().setWidth(45),
// width: ScreenUtil().setWidth(160),
// radius: ScreenUtil().setWidth(30),
// ),
,
VEmptyView(16),
percent == null
? SizedBox()
: Text('${percent}%',
style: TextStyle(
color: MyColours.color_199095,
fontSize: ScreenUtil().setSp(24),
)),
],
),
));
}
// // if (btnTitle == '活跃客户') {
// // index = '1';
// // } else if (btnTitle == '沉睡客户') {
// // index = '2';
// // } else if (btnTitle == '流失客户') {
// // index = '3';
// // }
// // NavigatorUtil.goCustomerListPage(
// // context, FromPage.FromPageHome, uid,
// // index: index);
// // },
// // text: btnTitle,
// // fontSize: 24,
// // isBold: false,
// // textColor: MyColours.color_333333,
// // gradientStart: MyColours.color_ffffff,
// // gradientEnd: MyColours.color_ffffff,
// // borderColor: Color.fromRGBO(118, 118, 118, 1),
// // height: ScreenUtil().setWidth(45),
// // width: ScreenUtil().setWidth(160),
// // radius: ScreenUtil().setWidth(30),
// // ),
// ,
// VEmptyView(16),
// percent == null
// ? SizedBox()
// : Text('${percent}%',
// style: TextStyle(
// color: MyColours.color_199095,
// fontSize: ScreenUtil().setSp(24),
// )),
// ],
// ),
// ));
// }
@override
Widget build(BuildContext context) {
customerProvider = Provider.of<CustomerProvider>(context, listen: false);
return Scaffold(
backgroundColor: Color.fromRGBO(246, 248, 250, 1),
appBar: SystemAppBar('全店客情', onTap: () {
EventBus().emit('changeStatusColor');
Navigator.pop(context);
}),
body: WillPopScope(onWillPop: () async {
EventBus().emit('changeStatusColor');
return true;
}, child: Consumer<CustomerProvider>(builder: (context, model, _) {
if (model.pageStateStoreHome != PageState.Success) {
return ExceptionPage(
pageState: model.pageStateStoreHome,
callback: () {
// getTableList();
_getSellerGuestManage();
},
emptyMsg: "暂时没有全店客情哦",
emptyImg: "empty_search",
showMsg: "加载中,请稍后...",
);
} else {
return Column(children: [
Expanded(
child: SingleChildScrollView(
controller: _controller,
child: Column(
children: [
VEmptyView(10),
Stack(
children: [
Container(
color: MyColours.color_ffffff,
padding: EdgeInsets.symmetric(
vertical: ScreenUtil().setWidth(30)),
child: Column(
children: [
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(
'${customerProvider.storeSunmodel.myCustomer}',
style: TextStyle(
color: MyColours.color_199095,
fontSize: ScreenUtil().setSp(60),
fontWeight: FontWeight.bold),
),
Text(
'位',
style: TextStyle(
color: MyColours.color_199095,
fontWeight: FontWeight.bold,
fontSize: ScreenUtil().setSp(30)),
)
],
),
VEmptyView(10),
RoundButton(
onPressed: () async {
NavigatorUtil.goCustomerListPage(
context, FromPage.FromPageHome, '');
},
text: '全店客户',
fontSize: 24,
isBold: false,
textColor: MyColours.color_333333,
gradientStart: MyColours.color_ffffff,
gradientEnd: MyColours.color_ffffff,
borderColor: Color.fromRGBO(118, 118, 118, 1),
height: ScreenUtil().setWidth(45),
width: ScreenUtil().setWidth(160),
radius: ScreenUtil().setWidth(30),
)
],
),
),
Positioned(
top: ScreenUtil().setWidth(30),
right: ScreenUtil().setWidth(40),
child: InkWell(
onTap: () {
NavigatorUtil.goCustomerSetPage(context);
},
child: Image.asset(Utils.getImgPath('c_set'),
width: ScreenUtil().setWidth(40))))
],
),
VEmptyView(10),
Row(
children: [
_percentWidget(
'${customerProvider.storeSunmodel.active.count}',
'活跃客户',
'${customerProvider.storeSunmodel.active.scale}'),
HEmptyView(10),
_percentWidget(
'${customerProvider.storeSunmodel.sleep.count}',
'沉睡客户',
'${customerProvider.storeSunmodel.sleep.scale}'),
HEmptyView(10),
_percentWidget(
'${customerProvider.storeSunmodel.drain.count}',
'流失客户',
'${customerProvider.storeSunmodel.drain.scale}'),
],
),
// GridView.builder(
// controller: _controller,
// shrinkWrap: true,
// cacheExtent: ScreenUtil().setWidth(0),
// itemCount: 3,
// gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
// crossAxisCount: 3,
// childAspectRatio: 1,
// mainAxisSpacing: ScreenUtil().setWidth(10),
// crossAxisSpacing: ScreenUtil().setWidth(10)),
// itemBuilder: (BuildContext context, int index) {
// // locationState = state;
// return _percentWidget('1999', '活跃客户', '39.20');
// }),
// Row(
// children: [
// _percentWidget('19992', '活跃客户', '90.90'),
// HEmptyView(10),
// _percentWidget('19992', '沉睡客户', '90.90'),
// HEmptyView(10),
// _percentWidget('19992', '流失客户', '5.90'),
// ],
// ),
Padding(
padding: EdgeInsets.symmetric(
vertical: ScreenUtil().setWidth(30)),
child: Text(
'客户经理',
style: TextStyle(
fontSize: ScreenUtil().setSp(28),
color: MyColours.color_333333),
),
),
GridView.builder(
controller: _controller,
shrinkWrap: true,
cacheExtent: ScreenUtil().setWidth(0),
itemCount:
customerProvider.storeSunmodel.sellerUser.length + 1,
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 3,
childAspectRatio: 1,
mainAxisSpacing: ScreenUtil().setWidth(10),
crossAxisSpacing: ScreenUtil().setWidth(10)),
itemBuilder: (BuildContext context, int index) {
// locationState = state;
if (index == 0) {
return _percentWidget(
'${customerProvider.storeSunmodel.distribution}',
'未分配',
null);
}
// @override
// Widget build(BuildContext context) {
// customerProvider = Provider.of<CustomerProvider>(context, listen: false);
// return Scaffold(
// backgroundColor: Color.fromRGBO(246, 248, 250, 1),
// appBar: SystemAppBar('全店客情', onTap: () {
// EventBus().emit('changeStatusColor');
// Navigator.pop(context);
// }),
// body: WillPopScope(onWillPop: () async {
// EventBus().emit('changeStatusColor');
// return true;
// }, child: Consumer<CustomerProvider>(builder: (context, model, _) {
// if (model.pageStateStoreHome != PageState.Success) {
// return ExceptionPage(
// pageState: model.pageStateStoreHome,
// callback: () {
// // getTableList();
// _getSellerGuestManage();
// },
// emptyMsg: "暂时没有全店客情哦",
// emptyImg: "empty_search",
// showMsg: "加载中,请稍后...",
// );
// } else {
// return Column(children: [
// Expanded(
// child: SingleChildScrollView(
// controller: _controller,
// child: Column(
// children: [
// VEmptyView(10),
// Stack(
// children: [
// Container(
// color: MyColours.color_ffffff,
// padding: EdgeInsets.symmetric(
// vertical: ScreenUtil().setWidth(30)),
// child: Column(
// children: [
// Row(
// mainAxisAlignment: MainAxisAlignment.center,
// children: [
// Text(
// '${customerProvider.storeSunmodel.myCustomer}',
// style: TextStyle(
// color: MyColours.color_199095,
// fontSize: ScreenUtil().setSp(60),
// fontWeight: FontWeight.bold),
// ),
// Text(
// '位',
// style: TextStyle(
// color: MyColours.color_199095,
// fontWeight: FontWeight.bold,
// fontSize: ScreenUtil().setSp(30)),
// )
// ],
// ),
// VEmptyView(10),
// RoundButton(
// onPressed: () async {
// NavigatorUtil.goCustomerListPage(
// context, FromPage.FromPageHome, '');
// },
// text: '全店客户',
// fontSize: 24,
// isBold: false,
// textColor: MyColours.color_333333,
// gradientStart: MyColours.color_ffffff,
// gradientEnd: MyColours.color_ffffff,
// borderColor: Color.fromRGBO(118, 118, 118, 1),
// height: ScreenUtil().setWidth(45),
// width: ScreenUtil().setWidth(160),
// radius: ScreenUtil().setWidth(30),
// )
// ],
// ),
// ),
// Positioned(
// top: ScreenUtil().setWidth(30),
// right: ScreenUtil().setWidth(40),
// child: InkWell(
// onTap: () {
// NavigatorUtil.goCustomerSetPage(context);
// },
// child: Image.asset(Utils.getImgPath('c_set'),
// width: ScreenUtil().setWidth(40))))
// ],
// ),
// VEmptyView(10),
// Row(
// children: [
// _percentWidget(
// '${customerProvider.storeSunmodel.active.count}',
// '活跃客户',
// '${customerProvider.storeSunmodel.active.scale}'),
// HEmptyView(10),
// _percentWidget(
// '${customerProvider.storeSunmodel.sleep.count}',
// '沉睡客户',
// '${customerProvider.storeSunmodel.sleep.scale}'),
// HEmptyView(10),
// _percentWidget(
// '${customerProvider.storeSunmodel.drain.count}',
// '流失客户',
// '${customerProvider.storeSunmodel.drain.scale}'),
// ],
// ),
// // GridView.builder(
// // controller: _controller,
// // shrinkWrap: true,
// // cacheExtent: ScreenUtil().setWidth(0),
// // itemCount: 3,
// // gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
// // crossAxisCount: 3,
// // childAspectRatio: 1,
// // mainAxisSpacing: ScreenUtil().setWidth(10),
// // crossAxisSpacing: ScreenUtil().setWidth(10)),
// // itemBuilder: (BuildContext context, int index) {
// // // locationState = state;
// // return _percentWidget('1999', '活跃客户', '39.20');
// // }),
// // Row(
// // children: [
// // _percentWidget('19992', '活跃客户', '90.90'),
// // HEmptyView(10),
// // _percentWidget('19992', '沉睡客户', '90.90'),
// // HEmptyView(10),
// // _percentWidget('19992', '流失客户', '5.90'),
// // ],
// // ),
// Padding(
// padding: EdgeInsets.symmetric(
// vertical: ScreenUtil().setWidth(30)),
// child: Text(
// '客户经理',
// style: TextStyle(
// fontSize: ScreenUtil().setSp(28),
// color: MyColours.color_333333),
// ),
// ),
// GridView.builder(
// controller: _controller,
// shrinkWrap: true,
// cacheExtent: ScreenUtil().setWidth(0),
// itemCount:
// customerProvider.storeSunmodel.sellerUser.length + 1,
// gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
// crossAxisCount: 3,
// childAspectRatio: 1,
// mainAxisSpacing: ScreenUtil().setWidth(10),
// crossAxisSpacing: ScreenUtil().setWidth(10)),
// itemBuilder: (BuildContext context, int index) {
// // locationState = state;
// if (index == 0) {
// return _percentWidget(
// '${customerProvider.storeSunmodel.distribution}',
// '未分配',
// null);
// }
return _percentWidget(
'${customerProvider.storeSunmodel.sellerUser[index - 1].count}',
customerProvider.storeSunmodel.sellerUser[index - 1]
.account ==
null
? ''
: '${customerProvider.storeSunmodel.sellerUser[index - 1].nickName ?? customerProvider.storeSunmodel.sellerUser[index - 1].account}经理',
null,
uid: customerProvider
.storeSunmodel.sellerUser[index - 1].uid);
})
],
),
)),
Padding(
padding: EdgeInsets.only(bottom: ScreenUtil().setWidth(30)),
child: Stack(
children: [
RoundButton(
onPressed: () {
NavigatorUtil.goMarketingRecordsPage(
context, FromPage.FromPageStoreCustomer);
},
text: '营销记录',
fontSize: 24,
isBold: false,
textColor: MyColours.color_199095,
gradientStart: MyColours.color_ffffff,
gradientEnd: MyColours.color_ffffff,
borderColor: MyColours.color_199095,
height: ScreenUtil().setWidth(75),
width: ScreenUtil().setWidth(260),
radius: ScreenUtil().setWidth(10),
),
showWarning
? Positioned(
right: ScreenUtil().setWidth(30),
top: ScreenUtil().setWidth(40 / 2),
child: Image.asset(
Utils.getImgPath('warning'),
width: ScreenUtil().setWidth(35),
))
: SizedBox()
],
))
]);
}
})),
);
}
}
// return _percentWidget(
// '${customerProvider.storeSunmodel.sellerUser[index - 1].count}',
// customerProvider.storeSunmodel.sellerUser[index - 1]
// .account ==
// null
// ? ''
// : '${customerProvider.storeSunmodel.sellerUser[index - 1].nickName ?? customerProvider.storeSunmodel.sellerUser[index - 1].account}经理',
// null,
// uid: customerProvider
// .storeSunmodel.sellerUser[index - 1].uid);
// })
// ],
// ),
// )),
// Padding(
// padding: EdgeInsets.only(bottom: ScreenUtil().setWidth(30)),
// child: Stack(
// children: [
// RoundButton(
// onPressed: () {
// NavigatorUtil.goMarketingRecordsPage(
// context, FromPage.FromPageStoreCustomer);
// },
// text: '营销记录',
// fontSize: 24,
// isBold: false,
// textColor: MyColours.color_199095,
// gradientStart: MyColours.color_ffffff,
// gradientEnd: MyColours.color_ffffff,
// borderColor: MyColours.color_199095,
// height: ScreenUtil().setWidth(75),
// width: ScreenUtil().setWidth(260),
// radius: ScreenUtil().setWidth(10),
// ),
// showWarning
// ? Positioned(
// right: ScreenUtil().setWidth(30),
// top: ScreenUtil().setWidth(40 / 2),
// child: Image.asset(
// Utils.getImgPath('warning'),
// width: ScreenUtil().setWidth(35),
// ))
// : SizedBox()
// ],
// ))
// ]);
// }
// })),
// );
// }
// }
... ...
... ... @@ -180,6 +180,7 @@ import '../pages/feast/feast_set_page.dart';
import '../pages/feast/feast_setmeal_page.dart';
import '../pages/feast/feast_wine_page.dart';
import '../pages/message/message_recharge_info_page.dart';
import '../pages/my/customer_type/store_customer/store_customer_home_page.dart';
import '../pages/my/feast_manage/feast_deposit_type_page.dart';
import '../pages/my/feast_manage/feast_dish_page.dart';
import '../pages/my/feast_manage/feast_dish_share_page.dart';
... ... @@ -1041,7 +1042,7 @@ var storeCustomerPageHandle = new Handler(
handlerFunc: (BuildContext context, Map<dynamic, List<Object>> params) {
// String idstr = params["idstr"].first;
return ChangeNotifierProvider<CustomerProvider>(
create: (_) => CustomerProvider(), child: StoreCustomerPage());
create: (_) => CustomerProvider(), child: StoreCustomerHomePage());
});
///我的客情
... ...
... ... @@ -351,6 +351,13 @@ packages:
url: "https://pub.flutter-io.cn"
source: hosted
version: "0.0.2"
equatable:
dependency: transitive
description:
name: equatable
url: "https://pub.flutter-io.cn"
source: hosted
version: "2.0.5"
extended_image:
dependency: transitive
description:
... ... @@ -407,6 +414,13 @@ packages:
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.0.0"
fl_chart:
dependency: "direct main"
description:
name: fl_chart
url: "https://pub.flutter-io.cn"
source: hosted
version: "0.62.0"
fluro:
dependency: "direct main"
description:
... ...
... ... @@ -190,6 +190,8 @@ dependencies:
pin_code_fields: ^7.4.0
# 二维码扫描
barcode_scan2: ^4.2.4
# 柱形图
fl_chart: ^0.62.0
# ai_barcode 3.2.4
# qr_code_scanner: ^1.0.1
# mobile_scanner: ^3.2.0
... ...