Commit 60bfa78dccda8d01696bbe466c8408b5bb489641

Authored by wdn127929
1 parent 20fede7d

我的和全店客情首页列表数据 部分y月份null

class MessageMenuModel {
MessageMenuModel();
String uid;
String title;
bool select;
}
... ...
class SellerCountsListModel {
int ret;
List<SellerCountsListSunModel> data;
String msg;
SellerCountsListModel({this.ret, this.data, this.msg});
SellerCountsListModel.fromJson(Map<String, dynamic> json) {
ret = json['ret'];
if (json['data'] != null) {
data = new List<SellerCountsListSunModel>();
json['data'].forEach((v) {
data.add(new SellerCountsListSunModel.fromJson(v));
});
}
msg = json['msg'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['ret'] = this.ret;
if (this.data != null) {
data['data'] = this.data.map((v) => v.toJson()).toList();
}
data['msg'] = this.msg;
return data;
}
}
class SellerCountsListSunModel {
dynamic monthss;
dynamic totalRserve;
dynamic totalPnum;
dynamic totalDao;
dynamic totalCel;
dynamic totalPrice;
dynamic totalConsume;
dynamic avgPrice;
dynamic totalDaoKe;
dynamic totalTable;
dynamic daoTable;
dynamic storeWine;
dynamic order;
dynamic plancook;
dynamic agvTable;
SellerCountsListSunModel(
{this.monthss,
this.totalRserve,
this.totalPnum,
this.totalDao,
this.totalCel,
this.totalPrice,
this.totalConsume,
this.avgPrice,
this.totalDaoKe,
this.totalTable,
this.daoTable,
this.storeWine,
this.order,
this.plancook,
this.agvTable});
SellerCountsListSunModel.fromJson(Map<String, dynamic> json) {
monthss = json['monthss'];
totalRserve = json['totalRserve'];
totalPnum = json['totalPnum'];
totalDao = json['totalDao'];
totalCel = json['totalCel'];
totalPrice = json['totalPrice'];
totalConsume = json['totalConsume'];
avgPrice = json['avgPrice'];
totalDaoKe = json['totalDaoKe'];
totalTable = json['totalTable'];
daoTable = json['daoTable'];
storeWine = json['storeWine'];
order = json['Order'];
plancook = json['Plancook'];
agvTable = json['agvTable'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['monthss'] = this.monthss;
data['totalRserve'] = this.totalRserve;
data['totalPnum'] = this.totalPnum;
data['totalDao'] = this.totalDao;
data['totalCel'] = this.totalCel;
data['totalPrice'] = this.totalPrice;
data['totalConsume'] = this.totalConsume;
data['avgPrice'] = this.avgPrice;
data['totalDaoKe'] = this.totalDaoKe;
data['totalTable'] = this.totalTable;
data['daoTable'] = this.daoTable;
data['storeWine'] = this.storeWine;
data['Order'] = this.order;
data['Plancook'] = this.plancook;
data['agvTable'] = this.agvTable;
return data;
}
}
... ...
... ... @@ -390,7 +390,6 @@ class HttpUrl {
static const String set_confing =
"?service=App.Reserve.SetConfing"; // 设置订座商家配置信息
// static const String send_vc_code =
// "?service=App.SendSMS.SendVcCode"; // 向指定手机号码发送验证码
... ... @@ -437,13 +436,13 @@ class HttpUrl {
static const String get_is_examine_list =
"?service=App.Activity.GetIsExamineList"; // 商家券核销列表
static const String get_pay_message_by_id =
static const String get_pay_message_by_id =
"?service=App.Activity.GetPayMessageByID"; // 充值成功通知消息获取详情
static const String set_cook_book_order =
static const String set_cook_book_order =
"?service=App.Cookbook.SetCookbookOrder"; // App设置菜品移动
static const String get_seller_counts_list =
"?service=App.GuestManage.GetSellerCountsList"; // 获取全店全年订单统计数据
}
... ...
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:one_key/models/seller_counts_list.dart';
import '../../../res/colors.dart';
import '../../../utils/screen_util.dart';
... ... @@ -9,7 +10,8 @@ import '../../../widgets/h_empty_view.dart';
import '../../../widgets/v_empty_view.dart';
class MonthItem extends StatefulWidget {
MonthItem({Key key}) : super(key: key);
final SellerCountsListSunModel countsListSunModel;
MonthItem({Key key, this.countsListSunModel}) : super(key: key);
@override
_MonthItemState createState() => _MonthItemState();
... ... @@ -52,7 +54,7 @@ class _MonthItemState extends State<MonthItem> {
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
'4月',
'${widget.countsListSunModel.monthss}月',
style: TextStyle(
color: MyColours.color_515151, fontSize: font(18)),
),
... ... @@ -60,13 +62,13 @@ class _MonthItemState extends State<MonthItem> {
mainAxisAlignment: MainAxisAlignment.end,
children: [
Text(
'预订1089单',
'预订${widget.countsListSunModel.totalRserve}单',
style: TextStyle(
color: MyColours.color_515151, fontSize: font(14)),
),
_space(),
Text(
'1190桌',
'${widget.countsListSunModel.totalTable}桌',
style: TextStyle(
color: MyColours.color_515151, fontSize: font(14)),
),
... ... @@ -87,7 +89,7 @@ class _MonthItemState extends State<MonthItem> {
runSpacing: w(6),
children: [
Text(
'到店 1059单',
'到店 ${widget.countsListSunModel.totalDao}单',
style: TextStyle(
color: MyColours.color_515151,
fontSize: font(12)),
... ... @@ -100,7 +102,7 @@ class _MonthItemState extends State<MonthItem> {
),
HEmptyView(10),
Text(
'1160桌',
'${widget.countsListSunModel.daoTable}桌',
style: TextStyle(
color: MyColours.color_515151,
fontSize: font(12)),
... ... @@ -113,7 +115,7 @@ class _MonthItemState extends State<MonthItem> {
),
HEmptyView(10),
Text(
'8000人',
'${widget.countsListSunModel.totalPnum}人',
style: TextStyle(
color: MyColours.color_515151,
fontSize: font(12)),
... ... @@ -126,7 +128,7 @@ class _MonthItemState extends State<MonthItem> {
),
HEmptyView(10),
Text(
'30取消',
'${widget.countsListSunModel.totalCel}取消',
style: TextStyle(
color: MyColours.color_515151,
fontSize: font(12)),
... ... @@ -139,7 +141,7 @@ class _MonthItemState extends State<MonthItem> {
),
HEmptyView(10),
Text(
'到客97.2%',
'到客${widget.countsListSunModel.totalDaoKe}',
style: TextStyle(
color: MyColours.color_515151,
fontSize: font(12)),
... ... @@ -154,7 +156,7 @@ class _MonthItemState extends State<MonthItem> {
runSpacing: w(6),
children: [
Text(
'有金额订单数 6000',
'有金额订单数 ${widget.countsListSunModel.totalPrice}',
style: TextStyle(
color: MyColours.color_999999,
fontSize: font(
... ... @@ -169,7 +171,7 @@ class _MonthItemState extends State<MonthItem> {
),
HEmptyView(10),
Text(
'总消费 9585800.00元',
'总消费 ${widget.countsListSunModel.totalConsume ?? 0}元',
style: TextStyle(
color: MyColours.color_999999,
fontSize: font(
... ... @@ -186,7 +188,7 @@ class _MonthItemState extends State<MonthItem> {
runSpacing: w(6),
children: [
Text(
'人均 8885.58元',
'人均 ${widget.countsListSunModel.avgPrice ?? 0}元',
style: TextStyle(
color: MyColours.color_999999,
fontSize: font(
... ... @@ -201,7 +203,7 @@ class _MonthItemState extends State<MonthItem> {
),
HEmptyView(10),
Text(
'桌均 95888.58元',
'桌均 ${widget.countsListSunModel.agvTable ?? 0}元',
style: TextStyle(
color: MyColours.color_999999,
fontSize: font(
... ... @@ -218,7 +220,7 @@ class _MonthItemState extends State<MonthItem> {
runSpacing: w(6),
children: [
Text(
'存酒 8位',
'存酒 ${widget.countsListSunModel.storeWine}位',
style: TextStyle(
color: MyColours.color_999999,
fontSize: font(
... ... @@ -233,7 +235,7 @@ class _MonthItemState extends State<MonthItem> {
),
HEmptyView(10),
Text(
'提前点餐 9位',
'提前点餐 ${widget.countsListSunModel.order}位',
style: TextStyle(
color: MyColours.color_999999,
fontSize: font(
... ... @@ -248,7 +250,7 @@ class _MonthItemState extends State<MonthItem> {
),
HEmptyView(10),
Text(
'安排菜 9位',
'安排菜 ${widget.countsListSunModel.plancook}位',
style: TextStyle(
color: MyColours.color_999999,
fontSize: font(
... ...
... ... @@ -19,6 +19,7 @@ import 'package:one_key/widgets/system_app_bar.dart';
import 'package:one_key/widgets/v_empty_view.dart';
import 'package:provider/provider.dart';
import '../../../../models/seller_counts_list.dart';
import '../../../../utils/screen_util.dart';
import '../../../../widgets/MyDivider.dart';
import '../month_item.dart';
... ... @@ -41,20 +42,6 @@ class _MyCustomerHomePageState extends State<MyCustomerHomePage> {
int year;
List<BarData> dataList = [
BarData(MyColours.color_8EBBBE, 200),
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, 168),
BarData(MyColours.color_8EBBBE, 15),
BarData(MyColours.color_8EBBBE, 5),
BarData(MyColours.color_8EBBBE, null ?? 0),
BarData(MyColours.color_8EBBBE, 0),
];
@override
void initState() {
super.initState();
... ... @@ -63,10 +50,12 @@ class _MyCustomerHomePageState extends State<MyCustomerHomePage> {
_couponNetworkData();
_getMarketingByUid();
_getSellerCountsList();
});
bus.on("refresh_my_customer_home", (arg) {
_getGuestManageData(isShowLoading: false);
_getMarketingByUid();
_getSellerCountsList();
});
}
... ... @@ -84,6 +73,21 @@ class _MyCustomerHomePageState extends State<MyCustomerHomePage> {
// setState(() {});
}
_getSellerCountsList({isShowLoading = false, VoidCallback callback}) async {
Map<String, String> params = {
'sellerid': Provider.of<UserModel>(context, listen: false).user.sellerid,
'year': year.toString(),
'uid': Provider.of<UserModel>(context, listen: false).user.openid
};
await customerProvider.getSellerCountsList(context, params,
isShowLoading: isShowLoading);
if ((customerProvider.managerStatisticsList == null ||
customerProvider.managerStatisticsList.length == 0) &&
callback != null) {
callback();
}
}
///消费券
_couponNetworkData({bool isShowLoading = true}) async {
// customerMakingProvider.couponSelectIndex = 0;
... ... @@ -140,16 +144,27 @@ class _MyCustomerHomePageState extends State<MyCustomerHomePage> {
children: [
InkWell(
onTap: () {
if (year == 2018) {
return;
}
setState(() {
year--;
});
// _getGuestReserve(showLoading: true);
_getSellerCountsList(
isShowLoading: true,
callback: () {
setState(() {
year++;
});
});
},
child: Padding(
padding:
EdgeInsets.only(right: ScreenUtil().setWidth(20)),
child: Image.asset(
Utils.getImgPath('c_arrow_left'),
Utils.getImgPath(year == 2018
? 'c_arrow_left_gray'
: 'c_arrow_left'),
width: ScreenUtil().setWidth(24),
))),
Text(
... ... @@ -166,7 +181,13 @@ class _MyCustomerHomePageState extends State<MyCustomerHomePage> {
setState(() {
year++;
});
// _getGuestReserve(showLoading: true);
_getSellerCountsList(
isShowLoading: true,
callback: () {
setState(() {
year--;
});
});
},
child: Padding(
padding: EdgeInsets.only(
... ... @@ -186,7 +207,7 @@ class _MyCustomerHomePageState extends State<MyCustomerHomePage> {
height: w(177),
child: LayoutBuilder(builder: (context, constraints) {
return BarChartWidget(
dataList: dataList,
dataList: customerProvider.chartManagerDataList,
);
}))
],
... ... @@ -640,12 +661,15 @@ class _MyCustomerHomePageState extends State<MyCustomerHomePage> {
}),
_chart(),
ListView.builder(
itemCount: 10,
itemCount: customerProvider.managerStatisticsList.length,
shrinkWrap: true,
controller: _controller,
padding: EdgeInsets.symmetric(horizontal: w(10)),
itemBuilder: (context, index) {
return MonthItem();
SellerCountsListSunModel countsListSunModel =
customerProvider.managerStatisticsList[index];
return MonthItem(
countsListSunModel: countsListSunModel);
})
],
),
... ...
... ... @@ -84,9 +84,9 @@ class _BarChartWidgetState extends State<BarChartWidget> {
}
Widget leftTitles(double value, TitleMeta meta) {
// if (value == meta.max) {
// return Container();
// }
if (value == meta.max) {
return Container();
}
print(value);
print(meta);
print(meta.max);
... ... @@ -139,9 +139,12 @@ class _BarChartWidgetState extends State<BarChartWidget> {
borderData: FlBorderData(
show: true,
border: Border.symmetric(
horizontal: BorderSide(color: MyColours.color_DBDBDB, width: w(1)),
border: Border(
bottom: BorderSide(color: MyColours.color_DBDBDB, width: w(1)),
),
// border: Border.symmetric(
// horizontal: BorderSide(color: MyColours.color_DBDBDB, width: w(1)),
// ),
),
barGroups: widget.dataList.asMap().entries.map((e) {
final index = e.key;
... ... @@ -159,6 +162,7 @@ class _BarChartWidgetState extends State<BarChartWidget> {
// checkToShowHorizontalLine: (value) => value % 10 == 0,
getDrawingHorizontalLine: (value) => FlLine(
color: MyColours.color_DBDBDB,
// color: Colors.red,
strokeWidth: w(1),
),
drawVerticalLine: false,
... ... @@ -166,7 +170,7 @@ class _BarChartWidgetState extends State<BarChartWidget> {
alignment: BarChartAlignment.spaceAround,
// maxY: 20,
// minY: 0,
// baselineY:
// baselineY:20
),
);
}
... ...
... ... @@ -2,6 +2,7 @@ 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_counts_list.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';
... ... @@ -23,7 +24,8 @@ import '../../../../utils/screen_util.dart';
import '../month_item.dart';
class StoreCustomerHomeLeftPage extends StatefulWidget {
StoreCustomerHomeLeftPage({Key key}) : super(key: key);
final CustomerProvider customerProvider;
StoreCustomerHomeLeftPage({Key key, this.customerProvider}) : super(key: key);
@override
_StoreCustomerHomeLeftPageState createState() =>
... ... @@ -32,24 +34,10 @@ class StoreCustomerHomeLeftPage extends StatefulWidget {
class _StoreCustomerHomeLeftPageState extends State<StoreCustomerHomeLeftPage> {
ScrollController _controller = ScrollController();
CustomerProvider customerProvider;
// widget.customerProvider widget.customerProvider;
bool showWarning = false;
int year;
int month;
List<BarData> dataList = [
BarData(MyColours.color_8EBBBE, 200),
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, 168),
BarData(MyColours.color_8EBBBE, 15),
BarData(MyColours.color_8EBBBE, 5),
BarData(MyColours.color_8EBBBE, null ?? 0),
BarData(MyColours.color_8EBBBE, 0),
];
@override
void initState() {
... ... @@ -58,12 +46,14 @@ class _StoreCustomerHomeLeftPageState extends State<StoreCustomerHomeLeftPage> {
year = DateTime.now().year;
month = DateTime.now().month;
WidgetsBinding.instance.addPostFrameCallback((_) {
_getSellerGuestManage();
// _getSellerGuestManage();
_getMarketingBySeller();
_getSellerCountsList();
});
bus.on("refresh_store_customer_home", (arg) {
_getMarketingBySeller();
_getSellerGuestManage();
// _getSellerGuestManage();
_getSellerCountsList();
});
}
... ... @@ -77,7 +67,7 @@ class _StoreCustomerHomeLeftPageState extends State<StoreCustomerHomeLeftPage> {
///全店客情首页
_getSellerGuestManage() async {
StoreCustomerHomeSunModel model =
await customerProvider.getSellerGuestManage(context);
await widget.customerProvider.getSellerGuestManage(context);
// setState(() {});
}
... ... @@ -86,7 +76,7 @@ class _StoreCustomerHomeLeftPageState extends State<StoreCustomerHomeLeftPage> {
"sellerid": Provider.of<UserModel>(context, listen: false).user.sellerid
};
List<MarketingBySellerSunModel> list =
await customerProvider.getMarketingBySeller(context, params);
await widget.customerProvider.getMarketingBySeller(context, params);
if (list != null && list.length > 0) {
bool temp = list.any((value) {
return value.finishedStatus == '0';
... ... @@ -95,7 +85,21 @@ class _StoreCustomerHomeLeftPageState extends State<StoreCustomerHomeLeftPage> {
showWarning = temp;
});
}
// await customerProvider.searchData(customerProvider.controller.text);
// await widget.customerProvider.searchData(widget.customerProvider.controller.text);
}
_getSellerCountsList({isShowLoading = false, VoidCallback callback}) async {
Map<String, String> params = {
'sellerid': Provider.of<UserModel>(context, listen: false).user.sellerid,
'year': year.toString()
};
await widget.customerProvider
.getSellerCountsList(context, params, isShowLoading: isShowLoading);
if ((widget.customerProvider.homeStatisticsList == null ||
widget.customerProvider.homeStatisticsList.length == 0) &&
callback != null) {
callback();
}
}
///活跃客户、沉睡客户、流失客户
... ... @@ -332,16 +336,28 @@ class _StoreCustomerHomeLeftPageState extends State<StoreCustomerHomeLeftPage> {
children: [
InkWell(
onTap: () {
if (year == 2018) {
return;
}
setState(() {
year--;
});
_getSellerCountsList(
isShowLoading: true,
callback: () {
setState(() {
year++;
});
});
// _getGuestReserve(showLoading: true);
},
child: Padding(
padding:
EdgeInsets.only(right: ScreenUtil().setWidth(20)),
child: Image.asset(
Utils.getImgPath('c_arrow_left'),
Utils.getImgPath(year == 2018
? 'c_arrow_left_gray'
: 'c_arrow_left'),
width: ScreenUtil().setWidth(24),
))),
Text(
... ... @@ -358,6 +374,13 @@ class _StoreCustomerHomeLeftPageState extends State<StoreCustomerHomeLeftPage> {
setState(() {
year++;
});
_getSellerCountsList(
isShowLoading: true,
callback: () {
setState(() {
year--;
});
});
// _getGuestReserve(showLoading: true);
},
child: Padding(
... ... @@ -378,7 +401,7 @@ class _StoreCustomerHomeLeftPageState extends State<StoreCustomerHomeLeftPage> {
height: w(177),
child: LayoutBuilder(builder: (context, constraints) {
return BarChartWidget(
dataList: dataList,
dataList: widget.customerProvider.chartHomeDataList,
);
}))
],
... ... @@ -787,7 +810,7 @@ class _StoreCustomerHomeLeftPageState extends State<StoreCustomerHomeLeftPage> {
@override
Widget build(BuildContext context) {
customerProvider = Provider.of<CustomerProvider>(context, listen: false);
// widget.customerProvider = Provider.of<widget.customerProvider>(context, listen: true);
return Scaffold(
// backgroundColor: Color.fromRGBO(246, 248, 250, 1),
// appBar: SystemAppBar('全店客情', onTap: () {
... ... @@ -831,7 +854,7 @@ class _StoreCustomerHomeLeftPageState extends State<StoreCustomerHomeLeftPage> {
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(
'${customerProvider.storeSunmodel.myCustomer}',
'${widget.customerProvider.storeSunmodel.myCustomer}',
style: TextStyle(
color: MyColours.color_438E93,
fontSize: ScreenUtil().setSp(64),
... ... @@ -862,19 +885,19 @@ class _StoreCustomerHomeLeftPageState extends State<StoreCustomerHomeLeftPage> {
Row(
children: [
_percentWidget(
'${customerProvider.storeSunmodel.active.count}',
'${widget.customerProvider.storeSunmodel.active.count}',
'活跃',
'${customerProvider.storeSunmodel.active.scale}'),
'${widget.customerProvider.storeSunmodel.active.scale}'),
HEmptyView(10),
_percentWidget(
'${customerProvider.storeSunmodel.sleep.count}',
'${widget.customerProvider.storeSunmodel.sleep.count}',
'60天未到店',
'${customerProvider.storeSunmodel.sleep.scale}'),
'${widget.customerProvider.storeSunmodel.sleep.scale}'),
HEmptyView(10),
_percentWidget(
'${customerProvider.storeSunmodel.drain.count}',
'${widget.customerProvider.storeSunmodel.drain.count}',
'120天未到店',
'${customerProvider.storeSunmodel.drain.scale}'),
'${widget.customerProvider.storeSunmodel.drain.scale}'),
],
),
// GridView.builder(
... ... @@ -915,8 +938,9 @@ class _StoreCustomerHomeLeftPageState extends State<StoreCustomerHomeLeftPage> {
controller: _controller,
shrinkWrap: true,
cacheExtent: ScreenUtil().setWidth(0),
itemCount:
customerProvider.storeSunmodel.sellerUser.length + 1,
itemCount: widget.customerProvider.storeSunmodel
.sellerUser.length +
1,
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 3,
childAspectRatio: 1.05,
... ... @@ -926,21 +950,21 @@ class _StoreCustomerHomeLeftPageState extends State<StoreCustomerHomeLeftPage> {
// locationState = state;
if (index == 0) {
return _managerWidget(
'${customerProvider.storeSunmodel.distribution}',
'${widget.customerProvider.storeSunmodel.distribution}',
'未分配经理',
null);
}
return _managerWidget(
'${customerProvider.storeSunmodel.sellerUser[index - 1].count}',
customerProvider.storeSunmodel.sellerUser[index - 1]
.account ==
'${widget.customerProvider.storeSunmodel.sellerUser[index - 1].count}',
widget.customerProvider.storeSunmodel
.sellerUser[index - 1].account ==
null
? ''
: '${customerProvider.storeSunmodel.sellerUser[index - 1].nickName ?? customerProvider.storeSunmodel.sellerUser[index - 1].account}',
: '${widget.customerProvider.storeSunmodel.sellerUser[index - 1].nickName ?? widget.customerProvider.storeSunmodel.sellerUser[index - 1].account}',
null,
uid: customerProvider
.storeSunmodel.sellerUser[index - 1].uid);
uid: widget.customerProvider.storeSunmodel
.sellerUser[index - 1].uid);
}),
VEmptyView(10),
ListView.builder(
... ... @@ -987,16 +1011,20 @@ class _StoreCustomerHomeLeftPageState extends State<StoreCustomerHomeLeftPage> {
// _monthWidget(),
ListView.builder(
itemCount: 10,
itemCount:
widget.customerProvider.homeStatisticsList.length,
shrinkWrap: true,
controller: _controller,
padding: EdgeInsets.symmetric(horizontal: w(10)),
itemBuilder: (context, index) {
SellerCountsListSunModel countsListSunModel =
widget.customerProvider.homeStatisticsList[index];
return InkWell(
onTap: () {
NavigatorUtil.goMonthOrderPage(context);
},
child: MonthItem());
child: MonthItem(
countsListSunModel: countsListSunModel));
}),
/**
ListView.builder(
... ...
... ... @@ -4,7 +4,10 @@ import 'package:one_key/pages/my/customer_type/store_customer/store_customer_hom
import 'package:one_key/pages/my/customer_type/store_customer/store_customer_home_right_page.dart';
import 'package:one_key/widgets/h_empty_view.dart';
import 'package:one_key/widgets/system_app_bar.dart';
import 'package:provider/provider.dart';
import '../../../../models/store_customer_home_model.dart';
import '../../../../provider/customer_provider.dart';
import '../../../../res/colors.dart';
import '../../../../utils/screen_util.dart';
import '../../../../widgets/v_empty_view.dart';
... ... @@ -25,6 +28,7 @@ class _StoreCustomerHomePageState extends State<StoreCustomerHomePage>
TabController tabController;
Color selectedColor = MyColours.color_ffffff;
Color unSelectedColor = MyColours.color_BFC4D4;
CustomerProvider customerProvider;
@override
void initState() {
... ... @@ -40,10 +44,21 @@ class _StoreCustomerHomePageState extends State<StoreCustomerHomePage>
// setState(() {});
// }
});
WidgetsBinding.instance.addPostFrameCallback((_) {
_getSellerGuestManage();
});
}
///全店客情首页
_getSellerGuestManage() async {
StoreCustomerHomeSunModel model =
await customerProvider.getSellerGuestManage(context);
// setState(() {});
}
@override
Widget build(BuildContext context) {
customerProvider = Provider.of<CustomerProvider>(context, listen: false);
return Scaffold(
appBar: SystemAppBar('全店客情'),
body: Column(
... ... @@ -99,11 +114,12 @@ class _StoreCustomerHomePageState extends State<StoreCustomerHomePage>
// right: ScreenUtil().setWidth(32)),
// indicatorWeight: ScreenUtil().setWidth(6.0),
)),
Expanded(
child: TabBarView(controller: tabController, children: [
StoreCustomerHomeLeftPage(),
StoreCustomerHomeRightPage()
StoreCustomerHomeLeftPage(
customerProvider: customerProvider,
),
StoreCustomerHomeRightPage(customerProvider: customerProvider)
]),
),
],
... ...
... ... @@ -20,6 +20,7 @@ import 'package:one_key/widgets/v_empty_view.dart';
import 'package:provider/provider.dart';
import '../../../../models/message_menu_model.dart';
import '../../../../models/seller_counts_list.dart';
import '../../../../utils/screen_util.dart';
import '../../../../widgets/MyDivider.dart';
import '../month_item.dart';
... ... @@ -29,7 +30,9 @@ import '../store_customer/bar_chart_page.dart';
*
*/
class StoreCustomerHomeRightPage extends StatefulWidget {
StoreCustomerHomeRightPage({Key key}) : super(key: key);
final CustomerProvider customerProvider;
StoreCustomerHomeRightPage({Key key, this.customerProvider})
: super(key: key);
@override
_StoreCustomerHomeRightPageState createState() =>
... ... @@ -39,45 +42,42 @@ class StoreCustomerHomeRightPage extends StatefulWidget {
class _StoreCustomerHomeRightPageState
extends State<StoreCustomerHomeRightPage> {
ScrollController _controller = ScrollController();
CustomerProvider customerProvider;
// widget.customerProvider widget.customerProvider;
bool showWarning = false;
int year;
List<BarData> dataList = [
BarData(MyColours.color_8EBBBE, 200),
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, 168),
BarData(MyColours.color_8EBBBE, 15),
BarData(MyColours.color_8EBBBE, 5),
BarData(MyColours.color_8EBBBE, null ?? 0),
BarData(MyColours.color_8EBBBE, 0),
];
List<MessageMenuModel> menuTitle = [];
@override
void initState() {
super.initState();
year = DateTime.now().year;
for (int i = 0; i < 15; i++) {
widget.customerProvider.storeSunmodel.sellerUser.forEach((element) {
MessageMenuModel messageMenuModel = MessageMenuModel();
messageMenuModel.title = '${i}经理';
messageMenuModel.select = i == 0 ? true : false;
messageMenuModel.uid = element.uid;
messageMenuModel.title = element.nickName ?? element.account;
messageMenuModel.select = false;
menuTitle.add(messageMenuModel);
});
if (menuTitle.length > 0) {
menuTitle[0].select = true;
}
// for (int i = 0; i < 15; i++) {
// MessageMenuModel messageMenuModel = MessageMenuModel();
// messageMenuModel.title = '${i}经理';
// messageMenuModel.select = i == 0 ? true : false;
// menuTitle.add(messageMenuModel);
// }
WidgetsBinding.instance.addPostFrameCallback((_) {
_couponNetworkData();
_getMarketingByUid();
_getSellerCountsList();
});
bus.on("refresh_my_customer_home", (arg) {
_getGuestManageData(isShowLoading: false);
// _getGuestManageData(isShowLoading: false);
_getMarketingByUid();
_getSellerCountsList();
});
}
... ... @@ -88,9 +88,30 @@ class _StoreCustomerHomeRightPageState
super.dispose();
}
_getSellerCountsList({isShowLoading = false, VoidCallback callback}) async {
String uid = '';
menuTitle.forEach((element) {
if (element.select) {
uid = element.uid;
}
});
Map<String, String> params = {
'sellerid': Provider.of<UserModel>(context, listen: false).user.sellerid,
'year': year.toString(),
'uid': uid
};
await widget.customerProvider
.getSellerCountsList(context, params, isShowLoading: isShowLoading);
if ((widget.customerProvider.managerStatisticsList == null ||
widget.customerProvider.managerStatisticsList.length == 0) &&
callback != null) {
callback();
}
}
///我的客户首页
_getGuestManageData({bool isShowLoading = true}) async {
GuestManageSunModel model = await customerProvider
GuestManageSunModel model = await widget.customerProvider
.getGuestManageData(context, isShowLoading: isShowLoading);
// setState(() {});
}
... ... @@ -101,16 +122,16 @@ class _StoreCustomerHomeRightPageState
Map<String, String> params = {
"uid": Provider.of<UserModel>(context, listen: false).user.openid,
};
await customerProvider.getCustomerSelectActivityNew(context, params,
await widget.customerProvider.getCustomerSelectActivityNew(context, params,
isShowLoading: isShowLoading);
//此人已经新建好券
// if (customerProvider.couponListSelect.length > 0) {
// for (int i = 0; i < customerProvider.couponListSelect.length; i++) {
// if (widget.sellerList.aid == customerProvider.couponListSelect[i].id) {
// aidStr = customerProvider.couponListSelect[i].aname;
// if (widget.customerProvider.couponListSelect.length > 0) {
// for (int i = 0; i < widget.customerProvider.couponListSelect.length; i++) {
// if (widget.sellerList.aid == widget.customerProvider.couponListSelect[i].id) {
// aidStr = widget.customerProvider.couponListSelect[i].aname;
// }
// }
// customerProvider.notifyListeners();
// widget.customerProvider.notifyListeners();
// } else {
// //没有新建的优惠券
// }
... ... @@ -121,10 +142,10 @@ class _StoreCustomerHomeRightPageState
Map<String, String> params = {
"uid": Provider.of<UserModel>(context, listen: false).user.openid
};
// await customerProvider.getMarketingByUid(context, params);
// await widget.customerProvider.getMarketingByUid(context, params);
MarketingByUidsSunModel myRecordData =
await customerProvider.getMarketingByUid(context, params);
await widget.customerProvider.getMarketingByUid(context, params);
if (myRecordData != null && myRecordData.sellerList.length > 0) {
bool temp = myRecordData.sellerList.any((value) {
return value.finishedStatus == '0';
... ... @@ -133,7 +154,7 @@ class _StoreCustomerHomeRightPageState
showWarning = temp;
});
}
// await customerProvider.searchData(customerProvider.controller.text);
// await widget.customerProvider.searchData(widget.customerProvider.controller.text);
}
Widget _chart() {
... ... @@ -151,16 +172,27 @@ class _StoreCustomerHomeRightPageState
children: [
InkWell(
onTap: () {
if (year == 2018) {
return;
}
setState(() {
year--;
});
// _getGuestReserve(showLoading: true);
_getSellerCountsList(
isShowLoading: true,
callback: () {
setState(() {
year++;
});
});
},
child: Padding(
padding:
EdgeInsets.only(right: ScreenUtil().setWidth(20)),
child: Image.asset(
Utils.getImgPath('c_arrow_left'),
Utils.getImgPath(year == 2018
? 'c_arrow_left_gray'
: 'c_arrow_left'),
width: ScreenUtil().setWidth(24),
))),
Text(
... ... @@ -177,7 +209,13 @@ class _StoreCustomerHomeRightPageState
setState(() {
year++;
});
// _getGuestReserve(showLoading: true);
_getSellerCountsList(
isShowLoading: true,
callback: () {
setState(() {
year--;
});
});
},
child: Padding(
padding: EdgeInsets.only(
... ... @@ -197,8 +235,7 @@ class _StoreCustomerHomeRightPageState
height: w(177),
child: LayoutBuilder(builder: (context, constraints) {
return BarChartWidget(
dataList: dataList,
);
dataList: widget.customerProvider.chartManagerDataList);
}))
],
),
... ... @@ -292,7 +329,7 @@ class _StoreCustomerHomeRightPageState
@override
Widget build(BuildContext context) {
customerProvider = Provider.of<CustomerProvider>(context, listen: false);
// widget.customerProvider = Provider.of<widget.customerProvider>(context, listen: true);
return Scaffold(
// backgroundColor: MyColours.color_f3f3f3,
// appBar: SystemAppBar('我的客情', onTap: () {
... ... @@ -332,6 +369,9 @@ class _StoreCustomerHomeRightPageState
}
menuTitle[index].select = true;
setState(() {});
_getSellerCountsList(
isShowLoading: true,
callback: () {});
// offset = 0;
// 1提前点餐/2内部预订/10在线预订/15店内消息传/12在线买单
... ... @@ -437,7 +477,7 @@ class _StoreCustomerHomeRightPageState
// fontSize: ScreenUtil().setSp(32)),
// ),
Text(
'${customerProvider.guestSunmodel.myCustomer}',
'${widget.customerProvider.guestSunmodel.myCustomer}',
style: TextStyle(
color: MyColours.color_199095,
fontSize: ScreenUtil().setSp(64),
... ... @@ -467,44 +507,44 @@ class _StoreCustomerHomeRightPageState
// itemBuilder: (BuildContext context, int index) {
// // locationState = state;
// return _percentWidget(
// '${customerProvider.guestSunmodel.active.count}',
// '${widget.customerProvider.guestSunmodel.active.count}',
// '活跃客户',
// '${customerProvider.guestSunmodel.active.scale}');
// '${widget.customerProvider.guestSunmodel.active.scale}');
// }),
Row(
children: [
_percentWidget(
'${customerProvider.guestSunmodel.active.count}',
'${widget.customerProvider.guestSunmodel.active.count}',
'活跃',
'${customerProvider.guestSunmodel.active.scale}'),
'${widget.customerProvider.guestSunmodel.active.scale}'),
HEmptyView(10),
_percentWidget(
'${customerProvider.guestSunmodel.sleep.count}',
'${widget.customerProvider.guestSunmodel.sleep.count}',
'60天未到店',
'${customerProvider.guestSunmodel.sleep.scale}'),
'${widget.customerProvider.guestSunmodel.sleep.scale}'),
HEmptyView(10),
_percentWidget(
'${customerProvider.guestSunmodel.drain.count}',
'${widget.customerProvider.guestSunmodel.drain.count}',
'120天未到店',
'${customerProvider.guestSunmodel.drain.scale}'),
'${widget.customerProvider.guestSunmodel.drain.scale}'),
],
),
ListView.builder(
controller: _controller,
shrinkWrap: true,
cacheExtent: ScreenUtil().setWidth(0),
itemCount:
customerProvider.guestSunmodel.tips.task ==
null ||
customerProvider.guestSunmodel.tips
.task.length ==
0
? 0
: customerProvider
.guestSunmodel.tips.task.length,
itemCount: widget.customerProvider.guestSunmodel
.tips.task ==
null ||
widget.customerProvider.guestSunmodel
.tips.task.length ==
0
? 0
: widget.customerProvider.guestSunmodel.tips
.task.length,
itemBuilder: (BuildContext context, int index) {
// locationState = state;
Task data = customerProvider
Task data = widget.customerProvider
.guestSunmodel.tips.task[index];
return Column(
children: [
... ... @@ -638,11 +678,11 @@ class _StoreCustomerHomeRightPageState
controller: _controller,
shrinkWrap: true,
cacheExtent: ScreenUtil().setWidth(0),
itemCount: customerProvider
.guestSunmodel.tips.recover ==
itemCount: widget.customerProvider.guestSunmodel
.tips.recover ==
null ||
customerProvider.guestSunmodel.tips
.recover.length ==
widget.customerProvider.guestSunmodel
.tips.recover.length ==
0
? 0
: 1,
... ... @@ -668,7 +708,7 @@ class _StoreCustomerHomeRightPageState
HEmptyView(15),
Expanded(
child: Text(
'${customerProvider.guestSunmodel.tips.recover[0]}',
'${widget.customerProvider.guestSunmodel.tips.recover[0]}',
maxLines: 10,
overflow: TextOverflow.ellipsis,
style: TextStyle(
... ... @@ -699,7 +739,8 @@ class _StoreCustomerHomeRightPageState
.FromPageMyCustomer,
homeGid: Utils
.listToStringEnglish1(
customerProvider
widget
.customerProvider
.guestSunmodel
.tips
.recover[1]));
... ... @@ -715,11 +756,11 @@ class _StoreCustomerHomeRightPageState
controller: _controller,
shrinkWrap: true,
cacheExtent: ScreenUtil().setWidth(0),
itemCount: customerProvider
.guestSunmodel.tips.awaken ==
itemCount: widget.customerProvider.guestSunmodel
.tips.awaken ==
null ||
customerProvider.guestSunmodel.tips
.awaken.length ==
widget.customerProvider.guestSunmodel
.tips.awaken.length ==
0
? 0
: 1,
... ... @@ -745,7 +786,7 @@ class _StoreCustomerHomeRightPageState
HEmptyView(15),
Expanded(
child: Text(
'${customerProvider.guestSunmodel.tips.awaken[0]}',
'${widget.customerProvider.guestSunmodel.tips.awaken[0]}',
maxLines: 10,
overflow: TextOverflow.ellipsis,
style: TextStyle(
... ... @@ -776,7 +817,8 @@ class _StoreCustomerHomeRightPageState
.FromPageMyCustomer,
homeGid: Utils
.listToStringEnglish1(
customerProvider
widget
.customerProvider
.guestSunmodel
.tips
.awaken[1]));
... ... @@ -790,13 +832,18 @@ class _StoreCustomerHomeRightPageState
}),
_chart(),
ListView.builder(
itemCount: 10,
itemCount: widget.customerProvider
.managerStatisticsList.length,
shrinkWrap: true,
controller: _controller,
padding:
EdgeInsets.symmetric(horizontal: w(10)),
itemBuilder: (context, index) {
return MonthItem();
SellerCountsListSunModel countsListSunModel =
widget.customerProvider
.managerStatisticsList[index];
return MonthItem(
countsListSunModel: countsListSunModel);
})
],
),
... ...
... ... @@ -29,6 +29,10 @@ import 'package:one_key/utils/utils.dart';
import 'package:one_key/widgets/loading.dart';
import 'package:provider/provider.dart';
import '../models/seller_counts_list.dart';
import '../pages/my/customer_type/store_customer/bar_chart_page.dart';
import '../res/colors.dart';
class CustomerProvider extends ChangeNotifier {
PageState pageState = PageState.Loading;
List<CustomerListSunModel> userHistorys = []; //客户列表(总)
... ... @@ -91,6 +95,69 @@ class CustomerProvider extends ChangeNotifier {
List pageData = [];
List pageDataMy = [];
List<SellerCountsListSunModel> homeStatisticsList = []; //全店客情首页统计数据
List<BarData> chartHomeDataList = [];
List<SellerCountsListSunModel> managerStatisticsList = []; //经理客情首页统计数据
List<BarData> chartManagerDataList = [];
///获取全店全年订单统计数据
Future<List<SellerCountsListSunModel>> getSellerCountsList(
BuildContext context, Map<String, String> params,
{isShowLoading = true}) async {
BaseResp<dynamic> baseResp = await DioUtil()
.request<dynamic>(context, Method.get, HttpUrl.get_seller_counts_list,
data: params, showLoading: isShowLoading)
.catchError((error) {
print(error.toString());
if (error is MyError) {
switch (error.type) {
}
}
});
if (baseResp == null) return [];
if (baseResp.code == Constant.status_success) {
List<SellerCountsListSunModel> data = []; //经理客情首页统计数据
List<BarData> chartDataTemp = [];
data = SellerCountsListModel.fromJson(baseResp.responseData).data;
chartDataTemp = [];
Map<String, double> chartData = {};
List<String> monthss = [];
data.forEach((element) {
//
monthss.add(element.monthss.toString());
chartData[element.monthss.toString()] =
double.parse(element.totalRserve.toString());
});
print(monthss);
monthss.sort((a, b) => int.parse(a).compareTo(int.parse(b)));
// monthss.reversed.toList();
print(monthss);
for (int i = 0; i < monthss.length; i++) {
String key = monthss[i];
chartDataTemp.add(BarData(MyColours.color_8EBBBE, chartData[key]));
}
if (params.keys.contains('uid')) {
//经理请求数据
managerStatisticsList = data;
chartManagerDataList = chartDataTemp;
} else {
homeStatisticsList = data;
chartHomeDataList = chartDataTemp;
}
notifyListeners();
} else {
if (baseResp != null) {
Utils.showToast(baseResp.msg ?? "");
}
}
return homeStatisticsList;
}
//获取全选按钮的状态 true or false
getCheckhydSelAll() {
bool temp = filterHydList.any((value) {
... ...