Commit c318bcc72c72d325868f1d396031703433ef8557

Authored by wdn127929
1 parent 659be1c4

我的客户列表筛选

///title 和select
class FilterBtnModel {
String id;
String title;
bool select = false;
FilterBtnModel();
factory FilterBtnModel.fromJson(Map<String, dynamic> json) => FilterBtnModel()
..id = json["id"]
..title = json["title"]
..select = json["select"];
Map<String, dynamic> toJson() =>
<String, dynamic>{"id": id, "title": title, "select": select};
}
... ...
... ... @@ -114,15 +114,17 @@ class _MyContactListPageState extends State<MyContactListPage> {
children: [
InkWell(
onTap: () {
List<CustomerListSunModel> data =
widget.provider.returnNowList();
data[index].select = !data[index].select;
if (data[index].select) {
widget.provider.addData(index);
} else {
widget.provider.cancelData(index);
if (widget.fromPage != FromPage.FromPageShowCutomerList) {
List<CustomerListSunModel> data =
widget.provider.userHistorys;
data[index].select = !data[index].select;
if (data[index].select) {
widget.provider.addData(index);
} else {
widget.provider.cancelData(index);
}
widget.provider.getCheckValue();
}
widget.provider.getCheckValue();
},
child: Stack(
alignment: Alignment.bottomCenter,
... ... @@ -144,13 +146,15 @@ class _MyContactListPageState extends State<MyContactListPage> {
fontSize: ScreenUtil().setSp(42)),
),
),
Positioned(
left: ScreenUtil().setWidth(-18),
child: Image.asset(
Utils.getImgPath(
model.select ? 'select' : 'unselect'),
width: ScreenUtil().setWidth(36),
))
widget.fromPage == FromPage.FromPageShowCutomerList
? SizedBox()
: Positioned(
left: ScreenUtil().setWidth(-18),
child: Image.asset(
Utils.getImgPath(
model.select ? 'select' : 'unselect'),
width: ScreenUtil().setWidth(36),
))
]),
Positioned(
bottom: ScreenUtil().setWidth(-20),
... ... @@ -318,27 +322,6 @@ class _MyContactListPageState extends State<MyContactListPage> {
)
],
),
widget.fromPage == FromPage.FromPageStoreCustomer
? Container(
padding: EdgeInsets.only(
left: ScreenUtil().setWidth(12),
right: ScreenUtil().setWidth(12),
top: ScreenUtil().setWidth(10),
),
decoration: BoxDecoration(
border: Border.all(
color: MyColours.color_199095,
width: ScreenUtil().setWidth(2)),
borderRadius: BorderRadius.circular(
ScreenUtil().setWidth(10))),
child: Text(
'xx经理',
style: TextStyle(
fontSize: ScreenUtil().setSp(24),
color: MyColours.color_333333),
),
)
: SizedBox()
],
))
],
... ... @@ -373,7 +356,10 @@ class _MyContactListPageState extends State<MyContactListPage> {
CustomerListSunModel model = widget.contacts[index];
return InkWell(
onTap: () {
NavigatorUtil.goMyCustomerDetailPage(context, model, widget.fromPage);
if (widget.fromPage != FromPage.FromPageShowCutomerList) {
NavigatorUtil.goMyCustomerDetailPage(
context, model, widget.fromPage);
}
},
child: _buildListItem(model, index),
);
... ...
... ... @@ -22,7 +22,8 @@ class MyCustomerDetailEditPage extends StatefulWidget {
: super(key: key);
@override
_MyCustomerDetailEditPageState createState() => _MyCustomerDetailEditPageState();
_MyCustomerDetailEditPageState createState() =>
_MyCustomerDetailEditPageState();
}
class _MyCustomerDetailEditPageState extends State<MyCustomerDetailEditPage> {
... ... @@ -90,11 +91,8 @@ class _MyCustomerDetailEditPageState extends State<MyCustomerDetailEditPage> {
///获取商家标签
_getLabelBySellerid() async {
Map<String, String> params = {
"sellerid": Provider.of<UserModel>(context, listen: false).user.sellerid,
};
List<CustomerLabelSunModel> modelLabel =
await customerProvider.getLabelBySellerid(context, params);
await customerProvider.getLabelBySellerid(context);
if (modelLabel.length > 0) {
for (int i = 0; i < customerProvider.labelList.length; i++) {
... ... @@ -570,7 +568,7 @@ class _MyCustomerDetailEditPageState extends State<MyCustomerDetailEditPage> {
],
),
)),
VEmptyView(60),
_textMulLine('忌口', '输入忌口的东西', jkController),
VEmptyView(30),
... ...
... ... @@ -2,6 +2,8 @@ import 'package:flutter/material.dart';
import 'package:flutter_screenutil/screenutil.dart';
import 'package:one_key/constant/state.dart';
import 'package:one_key/models/customer_label_model.dart';
import 'package:one_key/models/filter_btn_model.dart';
import 'package:one_key/pages/my/customer_type/my_customer/my_contant_list_page.dart';
import 'package:one_key/provider/customer_making_provider.dart';
... ... @@ -25,6 +27,8 @@ import 'package:one_key/widgets/v_empty_view.dart';
import 'package:provider/provider.dart';
typedef ClickCallback = void Function(dynamic value);
typedef ClickCall = void Function(FilterBtnModel value);
typedef ClickCallState = void Function(StateSetter state);
class MyCustomerListPage extends StatefulWidget {
final FromPage fromPage;
... ... @@ -45,7 +49,7 @@ class _MyCustomerListPageState extends State<MyCustomerListPage>
ScrollController _scrollCrl = ScrollController();
int dropValue = 0;
bool showDrop = true;
List<String> timeTilte = ['大于', '等于', '小于'];
List<String> timeTilte = ['等于', '小于', '大于'];
@override
void initState() {
... ... @@ -55,13 +59,27 @@ class _MyCustomerListPageState extends State<MyCustomerListPage>
tabController = TabController(length: 4, vsync: this);
tabController.addListener(() {
if (tabController.index == tabController.animation.value) {
if (customerProvider.index == tabController.index) {
return;
}
print(tabController.index);
customerProvider.index = tabController.index;
customerProvider.searchData(customerProvider.controller.text);
if (customerProvider.index != 0 && customerProvider.index != null) {
//1 活跃 2 沉睡 3 流失
for (FilterBtnModel item in customerProvider.filterHydList) {
item.select = false;
if (item.id == '${customerProvider.index}') {
item.select = true;
}
}
}
_getContantData();
}
});
WidgetsBinding.instance.addPostFrameCallback((_) async {
customerProvider.initData();
_getContantData();
_filterLabelList();
});
bus.on("refresh_guest_list", (arg) {
_getContantData();
... ... @@ -74,10 +92,80 @@ class _MyCustomerListPageState extends State<MyCustomerListPage>
super.dispose();
}
_getContantData() async {
_filterLabelList() async {
await customerProvider.getLabelBySellerid(context);
if (customerProvider.labelList != null &&
customerProvider.labelList.length > 0) {
customerProvider.filterLabelList = [];
for (CustomerLabelSunModel item in customerProvider.labelList) {
FilterBtnModel model = FilterBtnModel();
model.title = item.label;
model.id = item.id;
model.select = false;
customerProvider.filterLabelList.add(model);
}
}
}
_getContantData({bool showLoading = true}) async {
if (showLoading) {
customerProvider.pageState = PageState.Loading;
}
customerProvider.notifyListeners();
Map<String, String> params = {
"uid": Provider.of<UserModel>(context, listen: false).user.openid,
};
if (customerProvider.index != 0 && customerProvider.index != null) {
//1 活跃 2 沉睡 3 流失
for (FilterBtnModel item in customerProvider.filterHydList) {
if (item.id == '${customerProvider.index}') {
item.select = true;
}
}
}
String active = '';
for (FilterBtnModel item in customerProvider.filterHydList) {
if (item.select) {
active += '${item.id},';
}
}
if (active.length > 0) {
if (active.endsWith(',')) {
active = active.substring(0, active.length - 1);
}
params['active'] = active;
}
if (customerProvider.controller.text.trim().length > 0) {
params['keyword'] = customerProvider.controller.text; //搜索手机号/姓名
}
String labels = '';
for (FilterBtnModel item in customerProvider.filterLabelList) {
if (item.select) {
labels += '${item.id},';
}
}
if (labels.length > 0) {
if (labels.endsWith(',')) {
labels = labels.substring(0, labels.length - 1);
}
params['labelid'] = labels;
}
if (customerProvider.controllerstime.text.trim().length > 0) {
params['stime'] = customerProvider.controllerstime.text;
}
if (customerProvider.controlleretime.text.trim().length > 0) {
params['etime'] = customerProvider.controlleretime.text;
}
if (customerProvider.controllernum.text.trim().length > 0) {
params['reserve_num'] = customerProvider.controlleretime.text;
params['reserve_sort'] = '${dropValue + 1}';
}
// params['reserve_date'] XX天内,例:30
// params['reserve_num'] 时间内预定次数
// params['reserve_sort'] 1 等于 2 小于 3 大于
await customerProvider.getCustomerList(context, params);
// await customerProvider.searchData(customerProvider.controller.text);
}
... ... @@ -244,7 +332,7 @@ class _MyCustomerListPageState extends State<MyCustomerListPage>
onChanged: (value) {
// setState(() {});
// _searchSellerLocation();
customerProvider.searchData(value);
// customerProvider.searchData(value);
},
onEditingComplete: () {
FocusScope.of(context)
... ... @@ -275,7 +363,7 @@ class _MyCustomerListPageState extends State<MyCustomerListPage>
onTap: () {
WidgetsBinding.instance.addPostFrameCallback(((_) {
customerProvider.controller.clear();
customerProvider.searchData('');
// customerProvider.searchData('');
}));
},
)),
... ... @@ -354,16 +442,33 @@ class _MyCustomerListPageState extends State<MyCustomerListPage>
showFilter = !showFilter;
});
if (showFilter) {
_showFilterDialogFromTop(context, onPressedReset: () {
Navigator.of(context).pop();
setState(() {
showFilter = false;
_showFilterDialogFromTop(context, onPressedReset: (state) {
// Navigator.of(context).pop();
// setState(() {
// showFilter = false;
// });
state(() {
customerProvider.hydSelAll = false;
for (FilterBtnModel item
in customerProvider.filterHydList) {
item.select = false;
}
customerProvider.labelSelAll = false;
for (FilterBtnModel item
in customerProvider.filterLabelList) {
item.select = false;
}
customerProvider.controllerstime.text = '';
customerProvider.controlleretime.text = '';
customerProvider.controllernum.text = '';
dropValue = 0;
});
}, onPressedComplete: () {
Navigator.of(context).pop();
setState(() {
showFilter = false;
});
_getContantData();
}, tapWhiteBack: () {
// Navigator.of(context).pop();
// setState(() {
... ... @@ -401,7 +506,7 @@ class _MyCustomerListPageState extends State<MyCustomerListPage>
///筛选弹框
_showFilterDialogFromTop(BuildContext context,
{VoidCallback onPressedReset,
{ClickCallState onPressedReset,
VoidCallback onPressedComplete,
GestureTapCallback tapWhiteBack}) {
showGeneralDialog(
... ... @@ -439,44 +544,44 @@ class _MyCustomerListPageState extends State<MyCustomerListPage>
fontSize: ScreenUtil().setSp(size)));
}
///客户经理
Widget _managerWidget() {
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
_textWidget('客户经理', MyColours.color_333333, FontWeight.bold, 28),
GestureDetector(
onTap: () {},
child: _textWidget(
'全选', MyColours.color_199095, FontWeight.normal, 24),
)
],
),
VEmptyView(30),
Wrap(
spacing: ScreenUtil().setWidth(20),
runSpacing: ScreenUtil().setWidth(20),
children: _buildFilterItem([
{'title': 'kkkk', 'select': false},
{'title': 'kkkk', 'select': true},
{'title': 'kkkk', 'select': true},
{'title': 'kkkk', 'select': true},
{'title': 'k', 'select': true},
{'title': 'kkkk', 'select': true},
{'title': 'kkkk', 'select': true},
{'title': 'k', 'select': true},
{'title': 'kdsfjsfsdfhjsdfh', 'select': true},
{'title': 'kkkk', 'select': true},
], false)),
],
);
}
// ///客户经理
// Widget _managerWidget() {
// return Column(
// crossAxisAlignment: CrossAxisAlignment.start,
// children: [
// Row(
// mainAxisAlignment: MainAxisAlignment.spaceBetween,
// children: [
// _textWidget('客户经理', MyColours.color_333333, FontWeight.bold, 28),
// GestureDetector(
// onTap: () {},
// child: _textWidget(
// '全选', MyColours.color_199095, FontWeight.normal, 24),
// )
// ],
// ),
// VEmptyView(30),
// Wrap(
// spacing: ScreenUtil().setWidth(20),
// runSpacing: ScreenUtil().setWidth(20),
// children: _buildFilterItem([
// {'title': 'kkkk', 'select': false},
// {'title': 'kkkk', 'select': true},
// {'title': 'kkkk', 'select': true},
// {'title': 'kkkk', 'select': true},
// {'title': 'k', 'select': true},
// {'title': 'kkkk', 'select': true},
// {'title': 'kkkk', 'select': true},
// {'title': 'k', 'select': true},
// {'title': 'kdsfjsfsdfhjsdfh', 'select': true},
// {'title': 'kkkk', 'select': true},
// ], false)),
// ],
// );
// }
///活跃度
Widget _activityWidget() {
Widget _activityWidget(StateSetter state) {
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
... ... @@ -485,9 +590,29 @@ class _MyCustomerListPageState extends State<MyCustomerListPage>
children: [
_textWidget('活跃度', MyColours.color_333333, FontWeight.bold, 28),
GestureDetector(
onTap: () {},
child: _textWidget(
'全选', MyColours.color_199095, FontWeight.normal, 24),
onTap: () {
state(() {
customerProvider.hydSelAll = !customerProvider.hydSelAll;
if (customerProvider.hydSelAll) {
for (FilterBtnModel item
in customerProvider.filterHydList) {
item.select = true;
}
} else {
for (FilterBtnModel item
in customerProvider.filterHydList) {
item.select = false;
}
}
});
},
child: Container(
color: Colors.white,
height: ScreenUtil().setWidth(40),
alignment: Alignment.center,
padding: EdgeInsets.only(left: ScreenUtil().setWidth(130)),
child: _textWidget(customerProvider.hydSelAll ? '全不选' : '全选',
MyColours.color_199095, FontWeight.normal, 24)),
)
],
),
... ... @@ -495,24 +620,18 @@ class _MyCustomerListPageState extends State<MyCustomerListPage>
Wrap(
spacing: ScreenUtil().setWidth(20),
runSpacing: ScreenUtil().setWidth(20),
children: _buildFilterItem([
{'title': 'kkkk', 'select': false},
{'title': 'kkkk', 'select': true},
{'title': 'kkkk', 'select': true},
{'title': 'kkkk', 'select': true},
{'title': 'k', 'select': true},
{'title': 'kkkk', 'select': true},
{'title': 'kkkk', 'select': true},
{'title': 'k', 'select': true},
{'title': 'kdsfjsfsdfhjsdfh', 'select': true},
{'title': 'kkkk', 'select': true},
], false)),
children: _buildFilterItem(customerProvider.filterHydList, false,
(FilterBtnModel item) {
state(() {
item.select = !item.select;
});
})),
],
);
}
///自定义标签
Widget _labelWidget() {
Widget _labelWidget(StateSetter state) {
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
... ... @@ -521,28 +640,45 @@ class _MyCustomerListPageState extends State<MyCustomerListPage>
children: [
_textWidget('自定义标签', MyColours.color_333333, FontWeight.bold, 28),
GestureDetector(
onTap: () {},
child: _textWidget(
'全选', MyColours.color_199095, FontWeight.normal, 24),
)
onTap: () {
state(() {
customerProvider.labelSelAll =
!customerProvider.labelSelAll;
if (customerProvider.labelSelAll) {
for (FilterBtnModel item
in customerProvider.filterLabelList) {
item.select = true;
}
} else {
for (FilterBtnModel item
in customerProvider.filterLabelList) {
item.select = false;
}
}
});
},
child: Container(
color: Colors.white,
height: ScreenUtil().setWidth(40),
alignment: Alignment.center,
padding: EdgeInsets.only(left: ScreenUtil().setWidth(130)),
child: _textWidget(
customerProvider.labelSelAll ? '全不选' : '全选',
MyColours.color_199095,
FontWeight.normal,
24))),
],
),
VEmptyView(30),
Wrap(
spacing: ScreenUtil().setWidth(20),
runSpacing: ScreenUtil().setWidth(20),
children: _buildFilterItem([
{'title': 'kkkk', 'select': false},
{'title': 'kkkk', 'select': true},
{'title': 'kkkk', 'select': true},
{'title': 'kkkk', 'select': true},
{'title': 'k', 'select': true},
{'title': 'kkkk', 'select': true},
{'title': 'kkkk', 'select': true},
{'title': 'k', 'select': true},
{'title': 'kdsfjsfsdfhjsdfh', 'select': false},
{'title': 'kkkk', 'select': true},
], true)),
children: _buildFilterItem(customerProvider.filterLabelList, true,
(FilterBtnModel item) {
state(() {
item.select = !item.select;
});
})),
],
);
}
... ... @@ -601,7 +737,7 @@ class _MyCustomerListPageState extends State<MyCustomerListPage>
}
///高级筛选
Widget _advancedFilterWidget(state) {
Widget _advancedFilterWidget(StateSetter state) {
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
... ... @@ -610,32 +746,54 @@ class _MyCustomerListPageState extends State<MyCustomerListPage>
children: [
_textWidget('高级筛选', MyColours.color_333333, FontWeight.bold, 28),
GestureDetector(
onTap: () {},
child: _textWidget(
'清空', MyColours.color_199095, FontWeight.normal, 24),
)
onTap: () {
customerProvider.controllerstime.text = '';
customerProvider.controlleretime.text = '';
customerProvider.controllernum.text = '';
state(() {
dropValue = 0;
});
},
child: Container(
color: Colors.white,
height: ScreenUtil().setWidth(40),
alignment: Alignment.center,
padding: EdgeInsets.only(left: ScreenUtil().setWidth(130)),
child: _textWidget(
'清空', MyColours.color_199095, FontWeight.normal, 24),
))
],
),
VEmptyView(30),
Row(
children: [
Expanded(child: _textFeildWidget()),
Expanded(
child: _textFeildWidget(customerProvider.controllerstime,
customerProvider.stimeFocus)),
HEmptyView(10),
_textWidget('至', MyColours.color_199095, FontWeight.normal, 24),
HEmptyView(10),
Expanded(child: _textFeildWidget()),
Expanded(
child: _textFeildWidget(customerProvider.controlleretime,
customerProvider.etimeFocus)),
],
),
VEmptyView(30),
Wrap(
spacing: ScreenUtil().setWidth(20),
runSpacing: ScreenUtil().setWidth(20),
children: _buildFilterItem([
{'title': '7天', 'select': true},
{'title': '30天', 'select': true},
{'title': '60天', 'select': true},
{'title': '120天', 'select': true},
], true, grayBack: true)),
children: _buildFilterItem(customerProvider.filterDayList, true,
(FilterBtnModel item) {
if (customerProvider.stimeFocus.hasFocus) {
customerProvider.controllerstime.text = item.id;
}
if (customerProvider.etimeFocus.hasFocus) {
customerProvider.controlleretime.text = item.id;
}
// state(() {
// item.select = !item.select;
// });
}, grayBack: true)),
VEmptyView(30),
_textWidget('时间内预订次数', MyColours.color_333333, FontWeight.normal, 24),
VEmptyView(30),
... ... @@ -706,6 +864,8 @@ class _MyCustomerListPageState extends State<MyCustomerListPage>
),
onChanged: (value) {
print(value);
FocusScope.of(context)
.requestFocus(FocusNode()); //点击空白处隐藏键盘
state(() => dropValue = value);
}))),
HEmptyView(20),
... ... @@ -726,7 +886,7 @@ class _MyCustomerListPageState extends State<MyCustomerListPage>
color: MyColours.color_ffffff,
child: TextField(
maxLines: 1,
controller: customerProvider.controller,
controller: customerProvider.controllernum,
// focusNode: _focusNode,
// autofocus: true,
... ... @@ -745,13 +905,13 @@ class _MyCustomerListPageState extends State<MyCustomerListPage>
border: OutlineInputBorder(borderSide: BorderSide.none),
contentPadding: EdgeInsets.zero,
),
keyboardType: TextInputType.text,
keyboardType: TextInputType.number,
textInputAction: TextInputAction.done,
onChanged: (value) {
// setState(() {});
// _searchSellerLocation();
customerProvider.searchData(value);
// customerProvider.searchData(value);
},
onEditingComplete: () {
FocusScope.of(context)
... ... @@ -766,7 +926,7 @@ class _MyCustomerListPageState extends State<MyCustomerListPage>
HEmptyView(20),
_textWidget('次预订', MyColours.color_333333, FontWeight.normal, 24),
]),
VEmptyView(30),
VEmptyView(50),
],
);
}
... ... @@ -807,7 +967,8 @@ class _MyCustomerListPageState extends State<MyCustomerListPage>
}
/// 高级筛选输入框
Widget _textFeildWidget() {
Widget _textFeildWidget(
TextEditingController controller, FocusNode focusNode) {
return Container(
padding: EdgeInsets.symmetric(
horizontal: ScreenUtil().setWidth(20),
... ... @@ -823,8 +984,8 @@ class _MyCustomerListPageState extends State<MyCustomerListPage>
Expanded(
child: TextField(
maxLines: 1,
controller: customerProvider.controller,
// focusNode: _focusNode,
controller: controller,
focusNode: focusNode,
// autofocus: true,
style: TextStyle(
... ... @@ -832,7 +993,7 @@ class _MyCustomerListPageState extends State<MyCustomerListPage>
fontSize: ScreenUtil().setSp(26)),
// textAlignVertical: TextAlignVertical.center,
decoration: InputDecoration(
hintText: "xxx",
hintText: "",
hintStyle: TextStyle(
color: MyColours.color_999999,
fontSize: ScreenUtil().setSp(26),
... ... @@ -842,13 +1003,13 @@ class _MyCustomerListPageState extends State<MyCustomerListPage>
border: OutlineInputBorder(borderSide: BorderSide.none),
contentPadding: EdgeInsets.zero,
),
keyboardType: TextInputType.text,
keyboardType: TextInputType.number,
textInputAction: TextInputAction.done,
onChanged: (value) {
// setState(() {});
// _searchSellerLocation();
customerProvider.searchData(value);
// customerProvider.searchData(value);
},
onEditingComplete: () {
FocusScope.of(context)
... ... @@ -867,7 +1028,7 @@ class _MyCustomerListPageState extends State<MyCustomerListPage>
///筛选布局
Widget _filterWidget(
StateSetter state,
VoidCallback onPressedReset,
ClickCallState onPressedReset,
VoidCallback onPressedComplete,
) {
return Container(
... ... @@ -896,33 +1057,34 @@ class _MyCustomerListPageState extends State<MyCustomerListPage>
child: Column(
children: [
Expanded(
child: Scrollbar(
isAlwaysShown: true, //设置滚动条常亮
controller: _scrollCrl, //必须设置一个controller
// child: Scrollbar(
// isAlwaysShown: true, //设置滚动条常亮
// controller: _scrollCrl, //必须设置一个controller
///添加进度条
child: SingleChildScrollView(
controller: _scrollCrl,
// primary: true,
// reverse: true,
// physics: BouncingScrollPhysics(),
// padding: EdgeInsets.only(
// bottom:
// MediaQuery.of(context).viewInsets.bottom),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
VEmptyView(20),
_managerWidget(),
VEmptyView(30),
_activityWidget(),
VEmptyView(30),
_labelWidget(),
VEmptyView(30),
_advancedFilterWidget(state)
],
),
))),
// ///添加进度条
child: SingleChildScrollView(
controller: _scrollCrl,
// primary: true,
// reverse: true,
// physics: BouncingScrollPhysics(),
// padding: EdgeInsets.only(
// bottom:
// MediaQuery.of(context).viewInsets.bottom),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
VEmptyView(20),
// _managerWidget(),
// VEmptyView(30),
_activityWidget(state),
VEmptyView(30),
_labelWidget(state),
VEmptyView(30),
_advancedFilterWidget(state)
],
),
)),
// ),
Row(
children: [
Container(
... ... @@ -949,7 +1111,9 @@ class _MyCustomerListPageState extends State<MyCustomerListPage>
flex: 1,
child: Material(
child: InkWell(
onTap: onPressedReset,
onTap: () {
onPressedReset(state);
},
child: Container(
decoration: BoxDecoration(
color: MyColours.color_ffffff,
... ... @@ -1005,47 +1169,81 @@ class _MyCustomerListPageState extends State<MyCustomerListPage>
}
//构建筛选按钮
List<Widget> _buildFilterItem(List<Map> data, bool round,
List<Widget> _buildFilterItem(
List<FilterBtnModel> data, bool round, ClickCall onTap,
{bool grayBack = false}) {
List<Widget> items = [];
for (Map item in data) {
items.add(Container(
padding: EdgeInsets.symmetric(
horizontal: ScreenUtil().setWidth(20),
vertical: ScreenUtil().setWidth(6)),
decoration: BoxDecoration(
color: grayBack
? Color.fromRGBO(239, 239, 239, 1)
: item['select']
? MyColours.color_199095
: MyColours.color_ffffff,
border: Border.all(
color: grayBack
? Color.fromRGBO(239, 239, 239, 1)
: item['select']
? MyColours.color_199095
: round
? Color.fromRGBO(155, 155, 155, 1)
: MyColours.color_199095,
width: ScreenUtil().setWidth(2)),
borderRadius: BorderRadius.circular(
ScreenUtil().setWidth(round ? 30 : 10))),
child: _textWidget(
item['title'],
grayBack
? MyColours.color_333333
: item['select']
? MyColours.color_ffffff
: round
? MyColours.color_333333
: MyColours.color_199095,
FontWeight.normal,
24)));
if (data != null && data.length > 0) {
for (FilterBtnModel item in data) {
items.add(InkWell(
onTap: () {
onTap(item);
},
child: Container(
padding: EdgeInsets.symmetric(
horizontal: ScreenUtil().setWidth(20),
vertical: ScreenUtil().setWidth(6)),
decoration: BoxDecoration(
color: grayBack
? Color.fromRGBO(239, 239, 239, 1)
: item.select
? MyColours.color_199095
: MyColours.color_ffffff,
border: Border.all(
color: grayBack
? Color.fromRGBO(239, 239, 239, 1)
: item.select
? MyColours.color_199095
: round
? Color.fromRGBO(155, 155, 155, 1)
: MyColours.color_199095,
width: ScreenUtil().setWidth(2)),
borderRadius: BorderRadius.circular(
ScreenUtil().setWidth(round ? 30 : 10))),
child: _textWidget(
item.title,
grayBack
? MyColours.color_333333
: item.select
? MyColours.color_ffffff
: round
? MyColours.color_333333
: MyColours.color_199095,
FontWeight.normal,
24))));
}
}
return items;
}
List<Widget> _returnListWidget() {
List<Widget> list = [];
for (int i = 0; i < 4; i++) {
list.add(Consumer<CustomerProvider>(builder: (context, model, _) {
if (model.pageState != PageState.Success) {
return ExceptionPage(
pageState: model.pageState,
callback: () {
model.pageState = PageState.Loading;
model.notifyListeners();
_getContantData();
},
emptyMsg: "暂时没有客户哦",
emptyImg: "empty_search",
showMsg: "加载中,请稍后...",
);
} else {
return MyContactListPage(
contacts: model.userHistorys,
provider: customerProvider,
fromPage: widget.fromPage);
}
}));
}
return list;
}
@override
Widget build(BuildContext context) {
customerProvider = Provider.of<CustomerProvider>(context, listen: true);
... ... @@ -1069,110 +1267,14 @@ class _MyCustomerListPageState extends State<MyCustomerListPage>
body: SafeArea(
child: Column(children: [
_searchWidget(), _menuWidget(),
Expanded(child:
Consumer<CustomerProvider>(builder: (context, model, _) {
if (model.pageState != PageState.Success) {
return ExceptionPage(
pageState: model.pageState,
callback: () {
model.pageState = PageState.Loading;
model.notifyListeners();
_getContantData();
},
emptyMsg: "暂时没有客户哦",
emptyImg: "empty_search",
showMsg: "加载中,请稍后...",
);
} else {
return Column(children: [
Expanded(
child: TabBarView(
controller: tabController,
physics: NeverScrollableScrollPhysics(),
children: <Widget>[
MyContactListPage(
contacts: model.userHistorysShow,
provider: customerProvider,
fromPage: widget.fromPage),
Consumer<CustomerProvider>(
builder: (context, model, _) {
if (model.pageStateHuoyue != PageState.Success) {
return ExceptionPage(
pageState: model.pageStateHuoyue,
callback: () {
model.pageStateHuoyue = PageState.Loading;
model.notifyListeners();
_getContantData();
},
emptyMsg: "暂时没有客户哦",
emptyImg: "empty_search",
showMsg: "加载中,请稍后...",
);
} else {
return MyContactListPage(
contacts: model.userHistorysShowHuoyue,
provider: customerProvider,
fromPage: widget.fromPage);
}
}),
Consumer<CustomerProvider>(
builder: (context, model, _) {
if (model.pageStateChenshui !=
PageState.Success) {
return ExceptionPage(
pageState: model.pageStateChenshui,
callback: () {
model.pageStateChenshui = PageState.Loading;
model.notifyListeners();
_getContantData();
},
emptyMsg: "暂时没有客户哦",
emptyImg: "empty_search",
showMsg: "加载中,请稍后...",
);
} else {
return MyContactListPage(
contacts: model.userHistorysShowChenshui,
provider: customerProvider,
fromPage: widget.fromPage);
}
}),
Consumer<CustomerProvider>(
builder: (context, model, _) {
if (model.pageStateLiushi != PageState.Success) {
return ExceptionPage(
pageState: model.pageStateLiushi,
callback: () {
model.pageStateLiushi = PageState.Loading;
model.notifyListeners();
_getContantData();
},
emptyMsg: "暂时没有客户哦",
emptyImg: "empty_search",
showMsg: "加载中,请稍后...",
);
} else {
return MyContactListPage(
contacts: model.userHistorysShowLiushi,
provider: customerProvider,
fromPage: widget.fromPage);
}
}),
// ContactListPage(
// contacts: model.userHistorysShowChenshui,
// provider: customerProvider,
// fromPage: widget.fromPage),
// ContactListPage(
// contacts: model.userHistorysShowLiushi,
// provider: customerProvider,
// fromPage: widget.fromPage),
])),
customerProvider.pageState == PageState.Success
? _selectContantWidget()
: SizedBox(),
]);
}
})),
Expanded(
child: TabBarView(
controller: tabController,
physics: NeverScrollableScrollPhysics(),
children: _returnListWidget())),
customerProvider.pageState == PageState.Success
? _selectContantWidget()
: SizedBox(),
// _searchWidget(),
// Positioned(
// top: 0,
... ...
... ... @@ -210,40 +210,40 @@ class _SellerMyMarketingRecordsDetailPageState
color: MyColours.color_999999,
fontSize: ScreenUtil().setSp(30)),
)),
Padding(
padding: EdgeInsets.symmetric(
vertical: ScreenUtil().setWidth(25),
),
child: Row(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Text(
'总客户人数',
style: TextStyle(
color: MyColours.color_333333,
fontSize: ScreenUtil().setSp(30)),
),
Spacer(),
Text('${widget.sellerList.guestCount}人',
style: TextStyle(
color: MyColours.color_333333,
fontSize: ScreenUtil().setSp(30))),
HEmptyView(10),
InkWell(
onTap: () {
NavigatorUtil.goShowCustomerListPage(
context,
FromPage.FromPageStoreCustomer,
widget.sellerList.gid);
// NavigatorUtil.goSellerMyMarketingRecordsDetailPage(context);
},
child: Text('查看',
InkWell(
onTap: () {
NavigatorUtil.goShowCustomerListPage(
context,
FromPage.FromPageStoreCustomer,
widget.sellerList.gid);
// NavigatorUtil.goSellerMyMarketingRecordsDetailPage(context);
},
child: Padding(
padding: EdgeInsets.symmetric(
vertical: ScreenUtil().setWidth(25),
),
child: Row(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Text(
'总客户人数',
style: TextStyle(
color: MyColours.color_333333,
fontSize: ScreenUtil().setSp(30)),
),
Spacer(),
Text('${widget.sellerList.guestCount}人',
style: TextStyle(
color: MyColours.color_333333,
fontSize: ScreenUtil().setSp(30))),
HEmptyView(10),
Text('查看',
style: TextStyle(
decoration:
TextDecoration.underline,
color: MyColours.color_199095,
fontSize: ScreenUtil().setSp(30)))),
])),
fontSize: ScreenUtil().setSp(30))),
]))),
]))),
Column(
children: [
... ...
... ... @@ -60,7 +60,7 @@ class _ShowCustomerListPageState extends State<ShowCustomerListPage>
if (tabController.index == tabController.animation.value) {
print(tabController.index);
customerProvider.index = tabController.index;
customerProvider.searchData(customerProvider.controller.text);
// customerProvider.searchData(customerProvider.controller.text);
}
});
WidgetsBinding.instance.addPostFrameCallback((_) async {
... ... @@ -239,7 +239,7 @@ class _ShowCustomerListPageState extends State<ShowCustomerListPage>
onChanged: (value) {
// setState(() {});
// _searchSellerLocation();
customerProvider.searchData(value);
// customerProvider.searchData(value);
},
onEditingComplete: () {
FocusScope.of(context)
... ... @@ -270,7 +270,7 @@ class _ShowCustomerListPageState extends State<ShowCustomerListPage>
onTap: () {
WidgetsBinding.instance.addPostFrameCallback(((_) {
customerProvider.controller.clear();
customerProvider.searchData('');
// customerProvider.searchData('');
}));
},
)),
... ... @@ -746,7 +746,7 @@ class _ShowCustomerListPageState extends State<ShowCustomerListPage>
onChanged: (value) {
// setState(() {});
// _searchSellerLocation();
customerProvider.searchData(value);
// customerProvider.searchData(value);
},
onEditingComplete: () {
FocusScope.of(context)
... ... @@ -843,7 +843,7 @@ class _ShowCustomerListPageState extends State<ShowCustomerListPage>
onChanged: (value) {
// setState(() {});
// _searchSellerLocation();
customerProvider.searchData(value);
// customerProvider.searchData(value);
},
onEditingComplete: () {
FocusScope.of(context)
... ... @@ -1049,134 +1049,39 @@ class _ShowCustomerListPageState extends State<ShowCustomerListPage>
return Material(
child: InkWell(
onTap: () {
// FocusScope.of(context).requestFocus(FocusNode()); //点击空白处隐藏键盘
},
child: Scaffold(
resizeToAvoidBottomInset: false,
backgroundColor: MyColours.color_ffffff,
appBar: SystemAppBar(
'全店客户',
onTap: () {
Navigator.of(context).pop();
},
),
body: SafeArea(
child: Column(children: [
_searchWidget(), _menuWidget(),
Expanded(child:
Consumer<CustomerProvider>(builder: (context, model, _) {
if (model.pageStateListShow != PageState.Success) {
return ExceptionPage(
pageState: model.pageStateListShow,
callback: () {
model.pageStateListShow = PageState.Loading;
model.notifyListeners();
_getGuestByGid();
},
emptyMsg: "暂时没有客户哦",
emptyImg: "empty_search",
showMsg: "加载中,请稍后...",
);
} else {
return Column(children: [
Expanded(
child: TabBarView(
controller: tabController,
physics: NeverScrollableScrollPhysics(),
children: <Widget>[
MyContactListPage(
contacts: model.selectCustomer,
provider: customerProvider,
fromPage: FromPage.FromPageShowCutomerList),
Consumer<CustomerProvider>(
builder: (context, model, _) {
if (model.pageStateListShow !=
PageState.Success) {
return ExceptionPage(
pageState: model.pageStateListShow,
callback: () {
model.pageStateListShow = PageState.Loading;
model.notifyListeners();
_getGuestByGid();
},
emptyMsg: "暂时没有客户哦",
emptyImg: "empty_search",
showMsg: "加载中,请稍后...",
);
} else {
return MyContactListPage(
contacts: model.userHistorysShowHuoyue,
provider: customerProvider,
fromPage: FromPage.FromPageShowCutomerList);
}
}),
Consumer<CustomerProvider>(
builder: (context, model, _) {
if (model.pageStateChenshui !=
PageState.Success) {
return ExceptionPage(
pageState: model.pageStateChenshui,
callback: () {
model.pageStateChenshui = PageState.Loading;
model.notifyListeners();
_getGuestByGid();
},
emptyMsg: "暂时没有客户哦",
emptyImg: "empty_search",
showMsg: "加载中,请稍后...",
);
} else {
return MyContactListPage(
contacts: model.userHistorysShowChenshui,
provider: customerProvider,
fromPage: FromPage.FromPageShowCutomerList);
}
}),
Consumer<CustomerProvider>(
builder: (context, model, _) {
if (model.pageStateLiushi != PageState.Success) {
return ExceptionPage(
pageState: model.pageStateLiushi,
callback: () {
model.pageStateLiushi = PageState.Loading;
model.notifyListeners();
_getGuestByGid();
},
emptyMsg: "暂时没有客户哦",
emptyImg: "empty_search",
showMsg: "加载中,请稍后...",
);
} else {
return MyContactListPage(
contacts: model.userHistorysShowLiushi,
provider: customerProvider,
fromPage: FromPage.FromPageShowCutomerList);
}
}),
// ContactListPage(
// contacts: model.userHistorysShowChenshui,
// provider: customerProvider,
// fromPage: widget.fromPage),
// ContactListPage(
// contacts: model.userHistorysShowLiushi,
// provider: customerProvider,
// fromPage: widget.fromPage),
])),
// customerProvider.pageState == PageState.Success
// ? _selectContantWidget()
// : SizedBox(),
]);
}
})),
// _searchWidget(),
// Positioned(
// top: 0,
// left: ScreenUtil().setWidth(40),
// right: ScreenUtil().setWidth(40),
// child: _filterWidget())
// ],
])),
)));
onTap: () {
// FocusScope.of(context).requestFocus(FocusNode()); //点击空白处隐藏键盘
},
child: Scaffold(
resizeToAvoidBottomInset: false,
backgroundColor: MyColours.color_ffffff,
appBar: SystemAppBar(
'客户',
onTap: () {
Navigator.of(context).pop();
},
),
body: Consumer<CustomerProvider>(builder: (context, model, _) {
if (model.pageStateListShow != PageState.Success) {
return ExceptionPage(
pageState: model.pageStateListShow,
callback: () {
model.pageStateListShow = PageState.Loading;
model.notifyListeners();
_getGuestByGid();
},
emptyMsg: "暂时没有客户哦",
emptyImg: "empty_search",
showMsg: "加载中,请稍后...",
);
} else {
return MyContactListPage(
contacts: customerProvider.selectCustomer,
provider: customerProvider,
fromPage: FromPage.FromPageShowCutomerList);
}
}),
),
));
}
}
... ...
... ... @@ -90,11 +90,9 @@ class _CustomerDetailEditPageState extends State<CustomerDetailEditPage> {
///获取商家标签
_getLabelBySellerid() async {
Map<String, String> params = {
"sellerid": Provider.of<UserModel>(context, listen: false).user.sellerid,
};
List<CustomerLabelSunModel> modelLabel =
await customerProvider.getLabelBySellerid(context, params);
await customerProvider.getLabelBySellerid(context);
if (modelLabel.length > 0) {
for (int i = 0; i < customerProvider.labelList.length; i++) {
... ...
... ... @@ -267,7 +267,7 @@ class _CustomerListPageState extends State<CustomerListPage>
onChanged: (value) {
// setState(() {});
// _searchSellerLocation();
customerProvider.searchData(value);
// customerProvider.searchData(value);
},
onEditingComplete: () {
FocusScope.of(context)
... ... @@ -298,7 +298,7 @@ class _CustomerListPageState extends State<CustomerListPage>
onTap: () {
WidgetsBinding.instance.addPostFrameCallback(((_) {
customerProvider.controller.clear();
customerProvider.searchData('');
// customerProvider.searchData('');
}));
},
)),
... ... @@ -774,7 +774,7 @@ class _CustomerListPageState extends State<CustomerListPage>
onChanged: (value) {
// setState(() {});
// _searchSellerLocation();
customerProvider.searchData(value);
// customerProvider.searchData(value);
},
onEditingComplete: () {
FocusScope.of(context)
... ... @@ -871,7 +871,7 @@ class _CustomerListPageState extends State<CustomerListPage>
onChanged: (value) {
// setState(() {});
// _searchSellerLocation();
customerProvider.searchData(value);
// customerProvider.searchData(value);
},
onEditingComplete: () {
FocusScope.of(context)
... ...
... ... @@ -57,10 +57,7 @@ class _CustomerSettingPageState extends State<CustomerSettingPage> {
///获取商家标签
_getLabelBySellerid() async {
Map<String, String> params = {
"sellerid": Provider.of<UserModel>(context, listen: false).user.sellerid,
};
await customerProvider.getLabelBySellerid(context, params);
await customerProvider.getLabelBySellerid(context);
}
///商家创建商家标签
... ...
... ... @@ -250,41 +250,43 @@ class _MarketingRecordsDetailPageState
color: MyColours.color_999999,
fontSize: ScreenUtil().setSp(30)),
)),
Padding(
padding: EdgeInsets.symmetric(
vertical: ScreenUtil().setWidth(25),
),
child: Row(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Text(
'总客户人数',
style: TextStyle(
color: MyColours.color_333333,
fontSize: ScreenUtil().setSp(30)),
),
Spacer(),
Text(
'${model.marketingByIdSunModel.guestCount}人',
style: TextStyle(
color: MyColours.color_333333,
fontSize: ScreenUtil().setSp(30))),
HEmptyView(10),
InkWell(
onTap: () {
NavigatorUtil.goShowCustomerListPage(
context,
FromPage.FromPageStoreCustomer,
model.marketingByIdSunModel.gid);
},
child: Text('查看',
InkWell(
onTap: () {
NavigatorUtil.goShowCustomerListPage(
context,
FromPage.FromPageStoreCustomer,
model.marketingByIdSunModel.gid);
},
child: Padding(
padding: EdgeInsets.symmetric(
vertical: ScreenUtil().setWidth(25),
),
child: Row(
crossAxisAlignment:
CrossAxisAlignment.center,
children: [
Text(
'总客户人数',
style: TextStyle(
color: MyColours.color_333333,
fontSize: ScreenUtil().setSp(30)),
),
Spacer(),
Text(
'${model.marketingByIdSunModel.guestCount}人',
style: TextStyle(
color: MyColours.color_333333,
fontSize:
ScreenUtil().setSp(30))),
HEmptyView(10),
Text('查看',
style: TextStyle(
decoration:
TextDecoration.underline,
color: MyColours.color_199095,
fontSize:
ScreenUtil().setSp(30)))),
])),
ScreenUtil().setSp(30))),
]))),
RowMultiText(
'参与经理',
'${model.marketingByIdSunModel.sellerUserCount}人',
... ...
... ... @@ -8,6 +8,7 @@ import 'package:one_key/models/coupon_model.dart';
import 'package:one_key/models/customer_by_seller_model.dart';
import 'package:one_key/models/customer_label_model.dart';
import 'package:one_key/models/customer_list_model.dart';
import 'package:one_key/models/filter_btn_model.dart';
import 'package:one_key/models/guest_info_model.dart';
import 'package:one_key/models/guest_manage_model.dart';
import 'package:one_key/models/guest_reserve_model.dart';
... ... @@ -27,18 +28,18 @@ import 'package:provider/provider.dart';
class CustomerProvider extends ChangeNotifier {
PageState pageState = PageState.Loading;
List<CustomerListSunModel> userHistorys = []; //客户列表(总)
List<CustomerListSunModel> userHistorysShow = []; //全部展示
List<CustomerListSunModel> userHistorysShowHuoyue = []; //活跃展示
List<CustomerListSunModel> userHistorysShowChenshui = []; //沉睡展示
List<CustomerListSunModel> userHistorysShowLiushi = []; //流失展示
TextEditingController controller = TextEditingController(); //搜索框
TextEditingController controllerstime = TextEditingController(); //高级筛选开始时间
TextEditingController controlleretime = TextEditingController(); //高级筛选结束时间
TextEditingController controllernum = TextEditingController(); //预订次数
FocusNode stimeFocus = FocusNode(); //高级筛选开始时间
FocusNode etimeFocus = FocusNode(); //高级筛选结束时间
PageState pageStateMyHome = PageState.Loading;
PageState pageStateStoreHome = PageState.Loading;
PageState pageStateHuoyue = PageState.Loading;
PageState pageStateChenshui = PageState.Loading;
PageState pageStateLiushi = PageState.Loading;
GuestManageSunModel guestSunmodel; //我的客情首页数据
StoreCustomerHomeSunModel storeSunmodel; //全店客情首页数据
PageState pageStateGuestInfo = PageState.Loading; //客户详情
... ... @@ -70,6 +71,57 @@ class CustomerProvider extends ChangeNotifier {
PageState pageStateListShow = PageState.Loading;
List<CustomerBySellerSunModel> customerBySellerList; //全店客情列表
List<FilterBtnModel> filterHydList = []; //活跃度
List<FilterBtnModel> filterLabelList = []; //自定义标签
List<FilterBtnModel> filterDayList = []; //高级筛选---天数 7、30、60、120
bool hydSelAll = false;
bool labelSelAll = false;
initData() {
filterDayList = [];
FilterBtnModel model = FilterBtnModel();
model.id = '7';
model.title = '7天';
model.select = false;
filterDayList.add(model);
FilterBtnModel model1 = FilterBtnModel();
model1.id = '30';
model1.title = '30天';
model1.select = false;
filterDayList.add(model1);
FilterBtnModel model2 = FilterBtnModel();
model2.id = '60';
model2.title = '60天';
model2.select = false;
filterDayList.add(model2);
FilterBtnModel model3 = FilterBtnModel();
model3.id = '120';
model3.title = '120天';
model3.select = false;
filterDayList.add(model3);
filterHydList = [];
// FilterBtnModel modelhyd1 = FilterBtnModel();
// modelhyd1.id = '0';
// modelhyd1.title = '新客';
// modelhyd1.select = false;
// filterHydList.add(modelhyd1);
FilterBtnModel modelhyd2 = FilterBtnModel();
modelhyd2.id = '1';
modelhyd2.title = '活跃';
modelhyd2.select = false;
filterHydList.add(modelhyd2);
FilterBtnModel modelhyd3 = FilterBtnModel();
modelhyd3.id = '2';
modelhyd3.title = '沉睡';
modelhyd3.select = false;
filterHydList.add(modelhyd3);
FilterBtnModel modelhyd4 = FilterBtnModel();
modelhyd4.id = '3';
modelhyd4.title = '流失';
modelhyd4.select = false;
filterHydList.add(modelhyd4);
}
///客户经理获取所创建活动列表(选择优惠券)
Future<List<CouponSunModel>> getCustomerSelectActivityNew(
... ... @@ -96,7 +148,122 @@ class CustomerProvider extends ChangeNotifier {
return couponListSelect;
}
//用来获取客户列表
// //我的客情列表------获取筛选里面的活跃度,自定义标签
// getCustomerListWithFilter(BuildContext context) async {
// Map<String, String> params = {
// "uid": Provider.of<UserModel>(context, listen: false).user.openid,
// };
// BaseResp<List> baseResp = await DioUtil()
// .request<List>(context, Method.get, HttpUrl.get_customer_list,
// data: params, showLoading: false)
// .catchError((error) {
// print(error.toString());
// });
// if (baseResp != null && baseResp.code == Constant.status_success) {
// List<CustomerListSunModel> temp =
// CustomerListModel.fromJson(baseResp.responseData).data;
// if (temp.length == 0) {
// filterHydList = [];
// filterLabelList = [];
// } else {
// filterHydList = [];
// filterLabelList = [];
// List<String> temphyd = [];
// List<String> tempLabel = [];
// for (int i = 0; i < temp.length; i++) {
// CustomerListSunModel item = temp[i];
// if (item.attr != null) {
// temphyd.add(item.attr);
// }
// if (item.label != null) {
// tempLabel.add(item.label);
// }
// }
// temphyd = temphyd.toSet().toList();
// for (String item in temphyd) {
// FilterBtnModel model = FilterBtnModel();
// model.title = item;
// filterHydList.add(model);
// }
// tempLabel = tempLabel.toSet().toList();
// for (String item in tempLabel) {
// FilterBtnModel model = FilterBtnModel();
// model.title = item;
// filterLabelList.add(model);
// }
// }
// notifyListeners();
// }
// // if (baseResp != null && baseResp.code == Constant.status_success) {
// // userHistorys = baseResp.data.map<CustomerListSunModel>((value) {
// // return CustomerListSunModel.fromJson(value);
// // }).toList();
// // if (userHistorys.length == 0) {
// // pageState = PageState.Empty;
// // } else {
// // for (int i = 0; i < userHistorys.length; i++) {
// // CustomerListSunModel item = userHistorys[i];
// // item.pinyinFirst = '';
// // item.pinyinList = [];
// // item.pinyinList = [];
// // if (item.rname != null) {
// // item.pinyin =
// // PinyinHelper.getPinyin(item.rname).replaceAll(' ', '');
// // List<String> pinyinList =
// // PinyinHelper.getPinyin(item.rname).split(' ');
// // String pinyinAll = ''; //组装全拼组合
// // for (int j = 0; j < pinyinList.length; j++) {
// // String letter = pinyinList[j];
// // pinyinAll += pinyinList[j];
// // item.pinyinList.add(pinyinAll);
// // if (letter.length > 0) {
// // item.pinyinFirst += pinyinList[j].substring(0, 1);
// // } else {
// // item.pinyinFirst += '';
// // }
// // }
// // }
// // userHistorys[i] = item;
// // }
// // userHistorysShow = userHistorys; //全部客户列表信息
// // userHistorysShowHuoyue = [];
// // userHistorysShowChenshui = [];
// // userHistorysShowLiushi = [];
// // for (CustomerListSunModel item in userHistorysShow) {
// // if (item.attr == '活跃') {
// // userHistorysShowHuoyue.add(item);
// // } else if (item.attr == '沉睡') {
// // userHistorysShowChenshui.add(item);
// // } else if (item.attr == '流失') {
// // userHistorysShowLiushi.add(item);
// // }
// // }
// // if (userHistorysShowHuoyue.length > 0) {
// // pageStateHuoyue = PageState.Success;
// // } else {
// // pageStateHuoyue = PageState.Empty;
// // }
// // if (userHistorysShowChenshui.length > 0) {
// // pageStateChenshui = PageState.Success;
// // } else {
// // pageStateChenshui = PageState.Empty;
// // }
// // if (userHistorysShowLiushi.length > 0) {
// // pageStateLiushi = PageState.Success;
// // } else {
// // pageStateLiushi = PageState.Empty;
// // }
// // addAll();
// // pageState = PageState.Success;
// // }
// // notifyListeners();
// // }
// }
//我的客情 --- 用来获取客户列表
getCustomerList(BuildContext context, Map<String, String> params) async {
BaseResp<List> baseResp = await DioUtil()
.request<List>(context, Method.get, HttpUrl.get_customer_list,
... ... @@ -119,71 +286,93 @@ class CustomerProvider extends ChangeNotifier {
notifyListeners();
});
if (baseResp != null && baseResp.code == Constant.status_success) {
userHistorys = baseResp.data.map<CustomerListSunModel>((value) {
return CustomerListSunModel.fromJson(value);
}).toList();
userHistorys = CustomerListModel.fromJson(baseResp.responseData).data;
if (userHistorys.length == 0) {
pageState = PageState.Empty;
} else {
pageState = PageState.Success;
for (int i = 0; i < userHistorys.length; i++) {
CustomerListSunModel item = userHistorys[i];
item.pinyinFirst = '';
item.pinyinList = [];
item.pinyinList = [];
if (item.rname != null) {
item.pinyin =
PinyinHelper.getPinyin(item.rname).replaceAll(' ', '');
List<String> pinyinList =
PinyinHelper.getPinyin(item.rname).split(' ');
String pinyinAll = ''; //组装全拼组合
for (int j = 0; j < pinyinList.length; j++) {
String letter = pinyinList[j];
pinyinAll += pinyinList[j];
item.pinyinList.add(pinyinAll);
if (letter.length > 0) {
item.pinyinFirst += pinyinList[j].substring(0, 1);
} else {
item.pinyinFirst += '';
}
}
}
userHistorys[i] = item;
}
userHistorysShow = userHistorys; //全部客户列表信息
userHistorysShowHuoyue = [];
userHistorysShowChenshui = [];
userHistorysShowLiushi = [];
for (CustomerListSunModel item in userHistorysShow) {
if (item.attr == '活跃') {
userHistorysShowHuoyue.add(item);
} else if (item.attr == '沉睡') {
userHistorysShowChenshui.add(item);
} else if (item.attr == '流失') {
userHistorysShowLiushi.add(item);
}
}
if (userHistorysShowHuoyue.length > 0) {
pageStateHuoyue = PageState.Success;
} else {
pageStateHuoyue = PageState.Empty;
}
if (userHistorysShowChenshui.length > 0) {
pageStateChenshui = PageState.Success;
} else {
pageStateChenshui = PageState.Empty;
}
if (userHistorysShowLiushi.length > 0) {
pageStateLiushi = PageState.Success;
} else {
pageStateLiushi = PageState.Empty;
}
addAll();
pageState = PageState.Success;
myHandleList(userHistorys, needRefresh: true);
}
notifyListeners();
}
// if (baseResp != null && baseResp.code == Constant.status_success) {
// userHistorys = baseResp.data.map<CustomerListSunModel>((value) {
// return CustomerListSunModel.fromJson(value);
// }).toList();
// if (userHistorys.length == 0) {
// pageState = PageState.Empty;
// } else {
// for (int i = 0; i < userHistorys.length; i++) {
// CustomerListSunModel item = userHistorys[i];
// item.pinyinFirst = '';
// item.pinyinList = [];
// item.pinyinList = [];
// if (item.rname != null) {
// item.pinyin =
// PinyinHelper.getPinyin(item.rname).replaceAll(' ', '');
// List<String> pinyinList =
// PinyinHelper.getPinyin(item.rname).split(' ');
// String pinyinAll = ''; //组装全拼组合
// for (int j = 0; j < pinyinList.length; j++) {
// String letter = pinyinList[j];
// pinyinAll += pinyinList[j];
// item.pinyinList.add(pinyinAll);
// if (letter.length > 0) {
// item.pinyinFirst += pinyinList[j].substring(0, 1);
// } else {
// item.pinyinFirst += '';
// }
// }
// }
// userHistorys[i] = item;
// }
// userHistorysShow = userHistorys; //全部客户列表信息
// userHistorysShowHuoyue = [];
// userHistorysShowChenshui = [];
// userHistorysShowLiushi = [];
// for (CustomerListSunModel item in userHistorysShow) {
// if (item.attr == '活跃') {
// userHistorysShowHuoyue.add(item);
// } else if (item.attr == '沉睡') {
// userHistorysShowChenshui.add(item);
// } else if (item.attr == '流失') {
// userHistorysShowLiushi.add(item);
// }
// }
// if (userHistorysShowHuoyue.length > 0) {
// pageStateHuoyue = PageState.Success;
// } else {
// pageStateHuoyue = PageState.Empty;
// }
// if (userHistorysShowChenshui.length > 0) {
// pageStateChenshui = PageState.Success;
// } else {
// pageStateChenshui = PageState.Empty;
// }
// if (userHistorysShowLiushi.length > 0) {
// pageStateLiushi = PageState.Success;
// } else {
// pageStateLiushi = PageState.Empty;
// }
// addAll();
// pageState = PageState.Success;
// }
// notifyListeners();
// }
}
//客户经理营销中的用户列表
... ... @@ -521,41 +710,41 @@ class CustomerProvider extends ChangeNotifier {
//全选按钮执行“全选”
addAll() async {
List<CustomerListSunModel> temp = returnNowList();
//把数据状态全部改成true,即选中状态
selectCustomer = [];
for (var i = 0; i < temp.length; i++) {
temp[i].select = true;
selectCustomer.add(temp[i]);
}
_giveValue(temp);
checkValue = true;
labelsValue();
notifyListeners();
// List<CustomerListSunModel> temp = returnNowList();
// //把数据状态全部改成true,即选中状态
// selectCustomer = [];
// for (var i = 0; i < temp.length; i++) {
// temp[i].select = true;
// selectCustomer.add(temp[i]);
// }
// _giveValue(temp);
// checkValue = true;
// labelsValue();
// notifyListeners();
}
labelsValue() {
List<CustomerListSunModel> temp = returnNowList();
List<String> tempLabel = [];
for (CustomerListSunModel item in temp) {
if (item.select && item.attr != null) {
tempLabel.add(item.attr);
}
}
tempLabel = tempLabel.toSet().toList();
labels = Utils.listToStringEnglish(tempLabel);
// List<CustomerListSunModel> temp = returnNowList();
// List<String> tempLabel = [];
// for (CustomerListSunModel item in temp) {
// if (item.select && item.attr != null) {
// tempLabel.add(item.attr);
// }
// }
// tempLabel = tempLabel.toSet().toList();
// labels = Utils.listToStringEnglish(tempLabel);
}
_giveValue(List<CustomerListSunModel> temp) {
if (index == 0) {
userHistorysShow = temp; //全部
} else if (index == 1) {
userHistorysShowHuoyue = temp; //活跃
} else if (index == 2) {
userHistorysShowChenshui = temp; //沉睡
} else if (index == 3) {
userHistorysShowLiushi = temp; //流失
}
// if (index == 0) {
// userHistorysShow = temp; //全部
// } else if (index == 1) {
// userHistorysShowHuoyue = temp; //活跃
// } else if (index == 2) {
// userHistorysShowChenshui = temp; //沉睡
// } else if (index == 3) {
// userHistorysShowLiushi = temp; //流失
// }
}
///清除选择
... ... @@ -567,147 +756,147 @@ class CustomerProvider extends ChangeNotifier {
//全选按钮执行“全不选”
cancelAll() async {
List<CustomerListSunModel> temp = returnNowList();
selectCustomer = [];
//把数据状态全部改成false,即不选中状态
for (var i = 0; i < temp.length; i++) {
temp[i].select = false;
}
_giveValue(temp);
checkValue = false;
labelsValue();
notifyListeners();
// List<CustomerListSunModel> temp = returnNowList();
// selectCustomer = [];
// //把数据状态全部改成false,即不选中状态
// for (var i = 0; i < temp.length; i++) {
// temp[i].select = false;
// }
// _giveValue(temp);
// checkValue = false;
// labelsValue();
// notifyListeners();
}
//选中
addData(int index) {
List<CustomerListSunModel> temp = returnNowList();
temp[index].select = true;
_giveValue(temp);
selectCustomer.add(temp[index]);
labelsValue();
notifyListeners();
// List<CustomerListSunModel> temp = returnNowList();
// temp[index].select = true;
// _giveValue(temp);
// selectCustomer.add(temp[index]);
// labelsValue();
// notifyListeners();
}
///返回目前选中的list
List<CustomerListSunModel> returnNowList() {
List<CustomerListSunModel> temp = [];
if (index == 0) {
temp = userHistorysShow; //全部
} else if (index == 1) {
temp = userHistorysShowHuoyue; //活跃
} else if (index == 2) {
temp = userHistorysShowChenshui; //沉睡
} else if (index == 3) {
temp = userHistorysShowLiushi; //流失
}
return temp;
}
// ///返回目前选中的list
// List<CustomerListSunModel> returnNowList() {
// List<CustomerListSunModel> temp = [];
// if (index == 0) {
// temp = userHistorysShow; //全部
// } else if (index == 1) {
// temp = userHistorysShowHuoyue; //活跃
// } else if (index == 2) {
// temp = userHistorysShowChenshui; //沉睡
// } else if (index == 3) {
// temp = userHistorysShowLiushi; //流失
// }
// return temp;
// }
//未选中
cancelData(int index) {
List<CustomerListSunModel> temp = returnNowList();
temp[index].select = false;
_giveValue(temp);
selectCustomer.removeWhere((element) => element == temp[index].id);
labelsValue();
notifyListeners();
// List<CustomerListSunModel> temp = returnNowList();
// temp[index].select = false;
// _giveValue(temp);
// selectCustomer.removeWhere((element) => element == temp[index].id);
// labelsValue();
// notifyListeners();
}
//获取全选按钮的状态 true or false
getCheckValue() {
List<CustomerListSunModel> listData = returnNowList();
bool temp = listData.any((value) {
return value.select == false;
});
if (temp == true) {
checkValue = false;
} else {
checkValue = true;
}
notifyListeners();
// List<CustomerListSunModel> listData = returnNowList();
// bool temp = listData.any((value) {
// return value.select == false;
// });
// if (temp == true) {
// checkValue = false;
// } else {
// checkValue = true;
// }
// notifyListeners();
}
searchData(String key) {
// userHistorys 接口请求结果
// userHistorysShow 侧边栏功能结果
// 全部,活跃,沉睡,流失的数据是在userHistorysShow 中筛选出来的
if (userHistorys.length > 0) {
if (key == '') {
userHistorysShow = userHistorys;
pageState = PageState.Success;
} else {
userHistorysShow = [];
// searchData(String key) {
// // userHistorys 接口请求结果
// // userHistorysShow 侧边栏功能结果
// // 全部,活跃,沉睡,流失的数据是在userHistorysShow 中筛选出来的
// if (userHistorys.length > 0) {
// if (key == '') {
// userHistorysShow = userHistorys;
// pageState = PageState.Success;
// } else {
// userHistorysShow = [];
for (int i = 0; i < userHistorys.length; i++) {
String name = userHistorys[i].rname;
String pinyinFirst = userHistorys[i].pinyinFirst;
// String pinyin = userHistorys[i].pinyin;
String phone = userHistorys[i].phone;
List<String> pinyinList = userHistorys[i].pinyinList;
if ((name != null && name.contains(key)) ||
(pinyinFirst != null && pinyinFirst.contains(key)) ||
(phone != null && phone.contains(key)) ||
(pinyinList != null && pinyinList.contains(key))) {
userHistorysShow.add(userHistorys[i]);
}
}
// for (int i = 0; i < contacts.length; i++) {
// String name = contacts[i].rname;
// String pinyinFirst = contacts[i].pinyinFirst;
// List<String> pinyinList = contacts[i].pinyinList;
// // String pinyin = contacts[i].pinyin;
// String phone = contacts[i].phone;
// if ((name != null && name.contains(key)) ||
// (pinyinFirst != null && pinyinFirst.contains(key)) ||
// (phone != null && phone.contains(key)) ||
// (pinyinList != null && pinyinList.contains(key))) {
// contactsShow.add(contacts[i]);
// }
// }
if (userHistorysShow.length == 0) {
pageState = PageState.Empty;
notifyListeners();
} else {
userHistorysShowHuoyue = [];
userHistorysShowChenshui = [];
userHistorysShowLiushi = [];
for (CustomerListSunModel item in userHistorysShow) {
if (item.attr == '活跃') {
userHistorysShowHuoyue.add(item);
} else if (item.attr == '沉睡') {
userHistorysShowChenshui.add(item);
} else if (item.attr == '流失') {
userHistorysShowLiushi.add(item);
}
}
if (userHistorysShowHuoyue.length > 0) {
pageStateHuoyue = PageState.Success;
} else {
pageStateHuoyue = PageState.Empty;
}
if (userHistorysShowChenshui.length > 0) {
pageStateChenshui = PageState.Success;
} else {
pageStateChenshui = PageState.Empty;
}
if (userHistorysShowLiushi.length > 0) {
pageStateLiushi = PageState.Success;
} else {
pageStateLiushi = PageState.Empty;
}
pageState = PageState.Success;
}
// if (contactsShow.length == 0) {
// pageStateRight = PageState.Empty;
// } else {
// pageStateRight = PageState.Success;
// }
}
// for (int i = 0; i < userHistorys.length; i++) {
// String name = userHistorys[i].rname;
// String pinyinFirst = userHistorys[i].pinyinFirst;
// // String pinyin = userHistorys[i].pinyin;
// String phone = userHistorys[i].phone;
// List<String> pinyinList = userHistorys[i].pinyinList;
// if ((name != null && name.contains(key)) ||
// (pinyinFirst != null && pinyinFirst.contains(key)) ||
// (phone != null && phone.contains(key)) ||
// (pinyinList != null && pinyinList.contains(key))) {
// userHistorysShow.add(userHistorys[i]);
// }
// }
// // for (int i = 0; i < contacts.length; i++) {
// // String name = contacts[i].rname;
// // String pinyinFirst = contacts[i].pinyinFirst;
// // List<String> pinyinList = contacts[i].pinyinList;
// // // String pinyin = contacts[i].pinyin;
// // String phone = contacts[i].phone;
// // if ((name != null && name.contains(key)) ||
// // (pinyinFirst != null && pinyinFirst.contains(key)) ||
// // (phone != null && phone.contains(key)) ||
// // (pinyinList != null && pinyinList.contains(key))) {
// // contactsShow.add(contacts[i]);
// // }
// // }
// if (userHistorysShow.length == 0) {
// pageState = PageState.Empty;
// notifyListeners();
// } else {
// userHistorysShowHuoyue = [];
// userHistorysShowChenshui = [];
// userHistorysShowLiushi = [];
// for (CustomerListSunModel item in userHistorysShow) {
// if (item.attr == '活跃') {
// userHistorysShowHuoyue.add(item);
// } else if (item.attr == '沉睡') {
// userHistorysShowChenshui.add(item);
// } else if (item.attr == '流失') {
// userHistorysShowLiushi.add(item);
// }
// }
// if (userHistorysShowHuoyue.length > 0) {
// pageStateHuoyue = PageState.Success;
// } else {
// pageStateHuoyue = PageState.Empty;
// }
// if (userHistorysShowChenshui.length > 0) {
// pageStateChenshui = PageState.Success;
// } else {
// pageStateChenshui = PageState.Empty;
// }
// if (userHistorysShowLiushi.length > 0) {
// pageStateLiushi = PageState.Success;
// } else {
// pageStateLiushi = PageState.Empty;
// }
// pageState = PageState.Success;
// }
// // if (contactsShow.length == 0) {
// // pageStateRight = PageState.Empty;
// // } else {
// // pageStateRight = PageState.Success;
// // }
// }
myHandleList(userHistorysShow, needRefresh: true);
}
}
// myHandleList(userHistorysShow, needRefresh: true);
// }
// }
//实时更新右边数据 ABCDEFGHIGK....
... ... @@ -1129,9 +1318,11 @@ class CustomerProvider extends ChangeNotifier {
}
// 商家获取商家标签
Future<List<CustomerLabelSunModel>> getLabelBySellerid(
BuildContext context, Map<String, String> params,
Future<List<CustomerLabelSunModel>> getLabelBySellerid(BuildContext context,
{bool showLoading = false}) async {
Map<String, String> params = {
"sellerid": Provider.of<UserModel>(context, listen: false).user.sellerid,
};
BaseResp<dynamic> baseResp = await DioUtil()
.request<dynamic>(context, Method.get, HttpUrl.get_label_by_sellerid,
data: params, showLoading: showLoading)
... ...