Commit 463d88ef33fb9c049be50a3eef760f558773bd8f

Authored by wdn127929
1 parent 5313562d

客情列表

import 'package:azlistview/azlistview.dart';
import 'package:json_annotation/json_annotation.dart';
part 'user_history_entity.g.dart';
@JsonSerializable()
class UserHistoryEntity extends Object {
class UserHistoryEntity extends Object with ISuspensionBean {
@JsonKey(name: 'id')
String id;
... ... @@ -25,6 +26,7 @@ class UserHistoryEntity extends Object {
List<String> pinyinList; //全拼数组
String pinyin; //全拼字母
String pinyinFirst; //首字母
String tagIndex; //abcdefg
UserHistoryEntity(
this.id,
... ... @@ -39,4 +41,7 @@ class UserHistoryEntity extends Object {
_$UserHistoryEntityFromJson(srcJson);
Map<String, dynamic> toJson() => _$UserHistoryEntityToJson(this);
@override
String getSuspensionTag() => tagIndex;
}
... ...
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/screenutil.dart';
import 'package:one_key/models/user_history_entity.dart';
import 'package:one_key/provider/contant_show_model.dart';
import 'package:one_key/provider/customer_provider.dart';
import 'package:one_key/res/colors.dart';
import 'package:one_key/utils/utils.dart';
import 'package:one_key/widgets/MyDivider.dart';
... ... @@ -9,7 +9,7 @@ import 'package:one_key/widgets/v_empty_view.dart';
class ContantItemPage extends StatefulWidget {
final int index;
final ContantShowModel model;
final CustomerProvider model;
final GestureTapCallback onTap;
final List<UserHistoryEntity> data;
ContantItemPage({Key key, this.index, this.model, this.onTap, this.data})
... ... @@ -193,13 +193,13 @@ class _ContantItemPageState extends State<ContantItemPage> {
return InkWell(
onTap: widget.onTap,
child: Column(crossAxisAlignment: CrossAxisAlignment.start, children: [
widget.index == 0
? MyDivider(
double.infinity,
ScreenUtil().setWidth(20),
color: MyColours.color_f5f5f5,
)
: Container(),
// widget.index == 0
// ? MyDivider(
// double.infinity,
// ScreenUtil().setWidth(20),
// color: MyColours.color_f5f5f5,
// )
// : SizedBox(),
Container(
width: double.infinity,
padding: EdgeInsets.symmetric(
... ...
import 'package:flutter/material.dart';
import 'package:flutter_easyrefresh/easy_refresh.dart';
// import 'package:flutter/material.dart';
// import 'package:flutter_easyrefresh/easy_refresh.dart';
import 'package:one_key/constant/state.dart';
// import 'package:one_key/constant/state.dart';
import 'package:one_key/pages/my/contant_item_page.dart';
import 'package:one_key/provider/contant_show_model.dart';
import 'package:one_key/provider/user_model.dart';
import 'package:one_key/utils/dialog_util.dart';
// import 'package:one_key/pages/my/contant_item_page.dart';
// import 'package:one_key/provider/contant_show_model.dart';
// import 'package:one_key/provider/user_model.dart';
// import 'package:one_key/utils/dialog_util.dart';
import 'package:one_key/widgets/page_exception.dart';
// import 'package:one_key/widgets/page_exception.dart';
import 'package:provider/provider.dart';
// import 'package:provider/provider.dart';
class ContantLeftPage extends StatefulWidget {
ContantLeftPage({Key key}) : super(key: key);
// class ContantLeftPage extends StatefulWidget {
// ContantLeftPage({Key key}) : super(key: key);
@override
_ContantLeftPageState createState() => _ContantLeftPageState();
}
// @override
// _ContantLeftPageState createState() => _ContantLeftPageState();
// }
class _ContantLeftPageState extends State<ContantLeftPage> {
EasyRefreshController _controller;
ContantShowModel contantShowModel;
// class _ContantLeftPageState extends State<ContantLeftPage> {
// EasyRefreshController _controller;
// ContantShowModel contantShowModel;
@override
void initState() {
super.initState();
_controller = EasyRefreshController();
// @override
// void initState() {
// super.initState();
// _controller = EasyRefreshController();
WidgetsBinding.instance.addPostFrameCallback((_) {
_getContantData();
});
}
// WidgetsBinding.instance.addPostFrameCallback((_) {
// _getContantData();
// });
// }
_getContantData() async {
Map<String, String> params = {
"sid": Provider.of<UserModel>(context, listen: false).user.sellerid,
};
await contantShowModel.getUserHistorys(context, params);
await contantShowModel.searchData(contantShowModel.controller.text);
}
// _getContantData() async {
// Map<String, String> params = {
// "sid": Provider.of<UserModel>(context, listen: false).user.sellerid,
// };
// await contantShowModel.getUserHistorys(context, params);
// await contantShowModel.searchData(contantShowModel.controller.text);
// }
@override
Widget build(BuildContext context) {
contantShowModel = Provider.of<ContantShowModel>(context, listen: true);
return Consumer<ContantShowModel>(
builder: (context, model, _) {
if (model.pageStateLeft != PageState.Success) {
return ExceptionPage(
pageState: model.pageStateLeft,
callback: () {
model.pageStateLeft = PageState.Loading;
model.notifyListeners();
_getContantData();
},
emptyMsg: "暂时没有联系人哦",
emptyImg: "empty_search",
showMsg: "加载中,请稍后...",
);
} else {
return ListView.builder(
itemCount: model.userHistorysShow.length,
itemBuilder: (BuildContext context, int index) {
String phone = model.userHistorysShow[index].phone == null ||
model.userHistorysShow[index].phone == ''
? ''
: model.userHistorysShow[index].phone;
return ContantItemPage(
onTap: () {
if (model.userHistorysShow[index].phone != null &&
model.userHistorysShow[index].phone != '') {
DialogUtil.goPhone(model.userHistorysShow[index].phone);
}
},
index: index,
model: contantShowModel,
data: model.userHistorysShow,
);
});
}
},
);
}
}
// @override
// Widget build(BuildContext context) {
// contantShowModel = Provider.of<ContantShowModel>(context, listen: true);
// return Consumer<ContantShowModel>(
// builder: (context, model, _) {
// if (model.pageStateLeft != PageState.Success) {
// return ExceptionPage(
// pageState: model.pageStateLeft,
// callback: () {
// model.pageStateLeft = PageState.Loading;
// model.notifyListeners();
// _getContantData();
// },
// emptyMsg: "暂时没有联系人哦",
// emptyImg: "empty_search",
// showMsg: "加载中,请稍后...",
// );
// } else {
// return ListView.builder(
// itemCount: model.userHistorysShow.length,
// itemBuilder: (BuildContext context, int index) {
// String phone = model.userHistorysShow[index].phone == null ||
// model.userHistorysShow[index].phone == ''
// ? ''
// : model.userHistorysShow[index].phone;
// return ContantItemPage(
// onTap: () {
// if (model.userHistorysShow[index].phone != null &&
// model.userHistorysShow[index].phone != '') {
// DialogUtil.goPhone(model.userHistorysShow[index].phone);
// }
// },
// index: index,
// model: contantShowModel,
// data: model.userHistorysShow,
// );
// });
// }
// },
// );
// }
// }
... ...
import 'package:flutter/material.dart';
// import 'package:flutter/material.dart';
import 'package:contacts_service/contacts_service.dart';
import 'package:flutter_screenutil/screenutil.dart';
// import 'package:contacts_service/contacts_service.dart';
// import 'package:flutter_screenutil/screenutil.dart';
import 'package:one_key/pages/my/contant_left_page.dart';
import 'package:one_key/pages/my/contant_right_page.dart';
import 'package:one_key/provider/contant_show_model.dart';
import 'package:one_key/res/colors.dart';
import 'package:one_key/utils/event_bus.dart';
import 'package:one_key/utils/utils.dart';
// import 'package:one_key/pages/my/contant_left_page.dart';
// import 'package:one_key/pages/my/contant_right_page.dart';
// import 'package:one_key/provider/contant_show_model.dart';
// import 'package:one_key/res/colors.dart';
// import 'package:one_key/utils/event_bus.dart';
// import 'package:one_key/utils/utils.dart';
import 'package:one_key/widgets/custom_tab_indicator.dart';
import 'package:one_key/widgets/system_app_bar.dart';
// import 'package:one_key/widgets/custom_tab_indicator.dart';
// import 'package:one_key/widgets/system_app_bar.dart';
import 'package:provider/provider.dart';
// import 'package:provider/provider.dart';
class ContactListPage extends StatefulWidget {
@override
_ContactListPageState createState() => _ContactListPageState();
}
// class ContactListPage extends StatefulWidget {
// @override
// _ContactListPageState createState() => _ContactListPageState();
// }
class _ContactListPageState extends State<ContactListPage>
with TickerProviderStateMixin {
List<Contact> _contacts;
List _tabBarTitle;
TabController tabController;
// class _ContactListPageState extends State<ContactListPage>
// with TickerProviderStateMixin {
// List<Contact> _contacts;
// List _tabBarTitle;
// TabController tabController;
ContantShowModel contantShowModel;
@override
void initState() {
_tabBarTitle = ['预订联系人', '手机联系人'];
super.initState();
tabController = TabController(length: 2, vsync: this);
}
// ContantShowModel contantShowModel;
// @override
// void initState() {
// _tabBarTitle = ['预订联系人', '手机联系人'];
// super.initState();
// tabController = TabController(length: 2, vsync: this);
// }
@override
Widget build(BuildContext context) {
contantShowModel = Provider.of<ContantShowModel>(context, listen: true);
return Material(
child: InkWell(
onTap: () {
// FocusScope.of(context).requestFocus(FocusNode()); //点击空白处隐藏键盘
},
child: Scaffold(
resizeToAvoidBottomInset: false,
backgroundColor: MyColours.color_ffffff,
appBar: SystemAppBar(
'联系人',
onTap: () {
EventBus().emit('changeStatusColor');
Navigator.of(context).pop();
},
),
body: WillPopScope(
child: SafeArea(
child: Column(
children: <Widget>[
Container(
// color: Colors.red,
padding: EdgeInsets.symmetric(
horizontal: ScreenUtil().setWidth(40),
vertical: ScreenUtil().setWidth(10)),
height: ScreenUtil().setWidth(45 * 2),
// alignment: Alignment.center,
child: Stack(
children: [
Container(
alignment: Alignment.center,
padding: EdgeInsets.symmetric(
horizontal: ScreenUtil().setWidth(20 * 2),
vertical: ScreenUtil().setWidth(14)),
decoration: BoxDecoration(
color: MyColours.color_F0F0F0,
borderRadius: BorderRadius.circular(
ScreenUtil().setWidth(24 * 2))),
child: TextField(
maxLines: 1,
controller: contantShowModel.controller,
// focusNode: _focusNode,
// autofocus: true,
style: TextStyle(
color: MyColours.color_333333,
fontSize: ScreenUtil().setSp(30)),
// textAlignVertical: TextAlignVertical.center,
decoration: InputDecoration(
contentPadding: EdgeInsets.only(
right: ScreenUtil().setWidth(40 * 2)),
hintText: "搜索联系人",
hintStyle: TextStyle(
color: MyColours.color_999999,
fontSize: ScreenUtil().setSp(30),
),
isCollapsed:
true, //重点,相当于高度包裹的意思,必须设置为true,不然有默认奇妙的最小高度
border: OutlineInputBorder(
borderSide: BorderSide.none),
// 左边图标设置
icon: Image.asset(
Utils.getImgPath('search'),
width: ScreenUtil().setWidth(30),
),
//右边图标设置
// suffixIcon:
),
keyboardType: TextInputType.text,
textInputAction: TextInputAction.done,
// @override
// Widget build(BuildContext context) {
// contantShowModel = Provider.of<ContantShowModel>(context, listen: true);
// return Material(
// child: InkWell(
// onTap: () {
// // FocusScope.of(context).requestFocus(FocusNode()); //点击空白处隐藏键盘
// },
// child: Scaffold(
// resizeToAvoidBottomInset: false,
// backgroundColor: MyColours.color_ffffff,
// appBar: SystemAppBar(
// '联系人',
// onTap: () {
// EventBus().emit('changeStatusColor');
// Navigator.of(context).pop();
// },
// ),
// body: WillPopScope(
// child: SafeArea(
// child: Column(
// children: <Widget>[
// Container(
// // color: Colors.red,
// padding: EdgeInsets.symmetric(
// horizontal: ScreenUtil().setWidth(40),
// vertical: ScreenUtil().setWidth(10)),
// height: ScreenUtil().setWidth(45 * 2),
// // alignment: Alignment.center,
// child: Stack(
// children: [
// Container(
// alignment: Alignment.center,
// padding: EdgeInsets.symmetric(
// horizontal: ScreenUtil().setWidth(20 * 2),
// vertical: ScreenUtil().setWidth(14)),
// decoration: BoxDecoration(
// color: MyColours.color_F0F0F0,
// borderRadius: BorderRadius.circular(
// ScreenUtil().setWidth(24 * 2))),
// child: TextField(
// maxLines: 1,
// controller: contantShowModel.controller,
// // focusNode: _focusNode,
// // autofocus: true,
// style: TextStyle(
// color: MyColours.color_333333,
// fontSize: ScreenUtil().setSp(30)),
// // textAlignVertical: TextAlignVertical.center,
// decoration: InputDecoration(
// contentPadding: EdgeInsets.only(
// right: ScreenUtil().setWidth(40 * 2)),
// hintText: "搜索联系人",
// hintStyle: TextStyle(
// color: MyColours.color_999999,
// fontSize: ScreenUtil().setSp(30),
// ),
// isCollapsed:
// true, //重点,相当于高度包裹的意思,必须设置为true,不然有默认奇妙的最小高度
// border: OutlineInputBorder(
// borderSide: BorderSide.none),
// // 左边图标设置
// icon: Image.asset(
// Utils.getImgPath('search'),
// width: ScreenUtil().setWidth(30),
// ),
// //右边图标设置
// // suffixIcon:
// ),
// keyboardType: TextInputType.text,
// textInputAction: TextInputAction.done,
onChanged: (value) {
// setState(() {});
// _searchSellerLocation();
contantShowModel.searchData(value);
},
onEditingComplete: () {
FocusScope.of(context).requestFocus(
FocusNode()); //点击空白处隐藏键盘
// contantShowModel.searchData(
// contantShowModel.controller.text);
// _searchSellerLocation();
// _focusNode.unfocus();
},
),
),
Positioned(
right: 0,
top: 0,
bottom: 0,
child: Offstage(
offstage:
contantShowModel.controller.text ==
'',
child: GestureDetector(
child: Container(
padding: EdgeInsets.only(
right: ScreenUtil()
.setWidth(20 * 2)),
// color: Colors.orange,
height:
ScreenUtil().setWidth(45 * 2),
width:
ScreenUtil().setWidth(100 * 2),
alignment: Alignment.centerRight,
child: Image.asset(
Utils.getImgPath('clear'),
width: ScreenUtil().setWidth(30),
height: ScreenUtil().setWidth(30),
),
),
onTap: () {
WidgetsBinding.instance
.addPostFrameCallback(((_) {
contantShowModel.controller
.clear();
contantShowModel.searchData('');
}));
},
)))
],
)),
Container(
padding: EdgeInsets.only(
bottom: ScreenUtil().setWidth(10)),
margin: EdgeInsets.symmetric(
horizontal: ScreenUtil().setWidth(30)),
child: TabBar(
controller: tabController,
indicator: CustomTabIndicator(
radius: 0,
),
indicatorColor: MyColours.color_199095,
indicatorSize: TabBarIndicatorSize.tab,
// indicatorPadding: EdgeInsets.symmetric(
// horizontal: ScreenUtil().setWidth(12)),
labelColor: MyColours.color_199095,
labelStyle: TextStyle(
fontSize: ScreenUtil().setSp(32),
fontWeight: FontWeight.bold),
labelPadding: EdgeInsets.zero,
unselectedLabelStyle:
TextStyle(fontWeight: FontWeight.normal),
unselectedLabelColor: MyColours.color_999999,
tabs: _tabBarTitle.map((value) {
return Tab(
child: Text(value),
);
}).toList()),
),
Expanded(
child: TabBarView(
controller: tabController,
// physics: NeverScrollableScrollPhysics(),
children: <Widget>[
ContantLeftPage(),
ContantRightPage(),
],
)),
],
)),
onWillPop: () async {
EventBus().emit('changeStatusColor');
return true;
}))));
}
}
// onChanged: (value) {
// // setState(() {});
// // _searchSellerLocation();
// contantShowModel.searchData(value);
// },
// onEditingComplete: () {
// FocusScope.of(context).requestFocus(
// FocusNode()); //点击空白处隐藏键盘
// // contantShowModel.searchData(
// // contantShowModel.controller.text);
// // _searchSellerLocation();
// // _focusNode.unfocus();
// },
// ),
// ),
// Positioned(
// right: 0,
// top: 0,
// bottom: 0,
// child: Offstage(
// offstage:
// contantShowModel.controller.text ==
// '',
// child: GestureDetector(
// child: Container(
// padding: EdgeInsets.only(
// right: ScreenUtil()
// .setWidth(20 * 2)),
// // color: Colors.orange,
// height:
// ScreenUtil().setWidth(45 * 2),
// width:
// ScreenUtil().setWidth(100 * 2),
// alignment: Alignment.centerRight,
// child: Image.asset(
// Utils.getImgPath('clear'),
// width: ScreenUtil().setWidth(30),
// height: ScreenUtil().setWidth(30),
// ),
// ),
// onTap: () {
// WidgetsBinding.instance
// .addPostFrameCallback(((_) {
// contantShowModel.controller
// .clear();
// contantShowModel.searchData('');
// }));
// },
// )))
// ],
// )),
// Container(
// padding: EdgeInsets.only(
// bottom: ScreenUtil().setWidth(10)),
// margin: EdgeInsets.symmetric(
// horizontal: ScreenUtil().setWidth(30)),
// child: TabBar(
// controller: tabController,
// indicator: CustomTabIndicator(
// radius: 0,
// ),
// indicatorColor: MyColours.color_199095,
// indicatorSize: TabBarIndicatorSize.tab,
// // indicatorPadding: EdgeInsets.symmetric(
// // horizontal: ScreenUtil().setWidth(12)),
// labelColor: MyColours.color_199095,
// labelStyle: TextStyle(
// fontSize: ScreenUtil().setSp(32),
// fontWeight: FontWeight.bold),
// labelPadding: EdgeInsets.zero,
// unselectedLabelStyle:
// TextStyle(fontWeight: FontWeight.normal),
// unselectedLabelColor: MyColours.color_999999,
// tabs: _tabBarTitle.map((value) {
// return Tab(
// child: Text(value),
// );
// }).toList()),
// ),
// Expanded(
// child: TabBarView(
// controller: tabController,
// // physics: NeverScrollableScrollPhysics(),
// children: <Widget>[
// ContantLeftPage(),
// ContantRightPage(),
// ],
// )),
// ],
// )),
// onWillPop: () async {
// EventBus().emit('changeStatusColor');
// return true;
// }))));
// }
// }
... ...
import 'package:flutter/material.dart';
// import 'package:flutter/material.dart';
import 'package:lpinyin/lpinyin.dart';
import 'package:one_key/constant/state.dart';
import 'package:one_key/models/user_history_entity.dart';
import 'package:one_key/pages/my/contant_item_page.dart';
import 'package:one_key/provider/contant_show_model.dart';
// import 'package:lpinyin/lpinyin.dart';
// import 'package:one_key/constant/state.dart';
// import 'package:one_key/models/user_history_entity.dart';
// import 'package:one_key/pages/my/contant_item_page.dart';
// import 'package:one_key/provider/contant_show_model.dart';
import 'package:one_key/utils/dialog_util.dart';
import 'package:one_key/utils/misc.dart';
// import 'package:one_key/utils/dialog_util.dart';
// import 'package:one_key/utils/misc.dart';
import 'package:one_key/widgets/page_exception.dart';
// import 'package:one_key/widgets/page_exception.dart';
import 'package:contacts_service/contacts_service.dart';
import 'package:permission_handler/permission_handler.dart';
import 'package:provider/provider.dart';
// import 'package:contacts_service/contacts_service.dart';
// import 'package:permission_handler/permission_handler.dart';
// import 'package:provider/provider.dart';
class ContantRightPage extends StatefulWidget {
ContantRightPage({Key key}) : super(key: key);
// class ContantRightPage extends StatefulWidget {
// ContantRightPage({Key key}) : super(key: key);
@override
_ContantRightPageState createState() => _ContantRightPageState();
}
// @override
// _ContantRightPageState createState() => _ContantRightPageState();
// }
class _ContantRightPageState extends State<ContantRightPage> {
List<Contact> _contacts;
bool isNeed = false;
bool goSetting = false;
bool userNo = false;
ContantShowModel contantShowModel;
@override
void initState() {
super.initState();
WidgetsBinding.instance.addPostFrameCallback((_) {
_openAddressBook();
});
}
// class _ContantRightPageState extends State<ContantRightPage> {
// List<Contact> _contacts;
// bool isNeed = false;
// bool goSetting = false;
// bool userNo = false;
// ContantShowModel contantShowModel;
// @override
// void initState() {
// super.initState();
// WidgetsBinding.instance.addPostFrameCallback((_) {
// _openAddressBook();
// });
// }
_openAddressBook() async {
if (!(await checkContactPermission())) {
PermissionStatus permissionStatus = await contactPermissionStatus();
if (permissionStatus == PermissionStatus.permanentlyDenied) {
//用户选择不在弹出权限提示框
print('never');
userNo = true;
setState(() {
contantShowModel.pageStateRight = PageState.NoPermission;
});
// DialogUtil.openAlertDialog(
// context, '未获得通讯录权限', "请在手机的权限管理里,将通讯录权限开启", '去设置', 340.0,
// onTap: () {
// goSetting = true;
// openSetting();
// Navigator.pop(context, '');
// });
} else {
// 申请权限
bool canContacts = await requestContactPermission();
if (canContacts) {
refreshContacts();
} else {
setState(() {
contantShowModel.pageStateRight = PageState.NoPermission;
});
//拒绝通讯录权限 , 苹果拒绝权限后,不再提示权限框,进入此处
// DialogUtil.openAlertDialog(
// context, '未获得通讯录权限', "请在手机的权限管理里,将通讯录权限开启。", '去设置', 340.0,
// onTap: () {
// goSetting = true;
// openSetting();
// Navigator.pop(context, '');
// });
}
}
} else {
refreshContacts();
}
}
// _openAddressBook() async {
// if (!(await checkContactPermission())) {
// PermissionStatus permissionStatus = await contactPermissionStatus();
// if (permissionStatus == PermissionStatus.permanentlyDenied) {
// //用户选择不在弹出权限提示框
// print('never');
// userNo = true;
// setState(() {
// contantShowModel.pageStateRight = PageState.NoPermission;
// });
// // DialogUtil.openAlertDialog(
// // context, '未获得通讯录权限', "请在手机的权限管理里,将通讯录权限开启", '去设置', 340.0,
// // onTap: () {
// // goSetting = true;
// // openSetting();
// // Navigator.pop(context, '');
// // });
// } else {
// // 申请权限
// bool canContacts = await requestContactPermission();
// if (canContacts) {
// refreshContacts();
// } else {
// setState(() {
// contantShowModel.pageStateRight = PageState.NoPermission;
// });
// //拒绝通讯录权限 , 苹果拒绝权限后,不再提示权限框,进入此处
// // DialogUtil.openAlertDialog(
// // context, '未获得通讯录权限', "请在手机的权限管理里,将通讯录权限开启。", '去设置', 340.0,
// // onTap: () {
// // goSetting = true;
// // openSetting();
// // Navigator.pop(context, '');
// // });
// }
// }
// } else {
// refreshContacts();
// }
// }
Future<void> refreshContacts() async {
List<Contact> contacts = (await ContactsService.getContacts(
withThumbnails: false, iOSLocalizedLabels: false))
.toList();
// Future<void> refreshContacts() async {
// List<Contact> contacts = (await ContactsService.getContacts(
// withThumbnails: false, iOSLocalizedLabels: false))
// .toList();
setState(() {
_contacts = contacts;
if (_contacts.length > 0) {
contantShowModel.contacts = [];
for (int i = 0; i < _contacts.length; i++) {
UserHistoryEntity item = UserHistoryEntity(
'',
'',
_contacts[i].displayName == null ? '' : _contacts[i].displayName,
'',
_contacts[i].phones == null
? ''
: _contacts[i].phones.first.value.replaceAll(' ', ''),
'');
item.pinyin = _contacts[i].displayName == null
? ''
: PinyinHelper.getPinyin(_contacts[i].displayName)
.replaceAll(' ', '');
List<String> pinyinList = _contacts[i].displayName == null
? []
: PinyinHelper.getPinyin(_contacts[i].displayName).split(' ');
item.pinyinFirst = '';
item.pinyinList = [];
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 += '';
}
}
contantShowModel.contacts.add(item);
}
contantShowModel.contactsShow = contantShowModel.contacts;
contantShowModel.pageStateRight = PageState.Success;
} else {
contantShowModel.pageStateRight = PageState.Empty;
}
});
await contantShowModel.searchData(contantShowModel.controller.text);
}
// setState(() {
// _contacts = contacts;
// if (_contacts.length > 0) {
// contantShowModel.contacts = [];
// for (int i = 0; i < _contacts.length; i++) {
// UserHistoryEntity item = UserHistoryEntity(
// '',
// '',
// _contacts[i].displayName == null ? '' : _contacts[i].displayName,
// '',
// _contacts[i].phones == null
// ? ''
// : _contacts[i].phones.first.value.replaceAll(' ', ''),
// '');
// item.pinyin = _contacts[i].displayName == null
// ? ''
// : PinyinHelper.getPinyin(_contacts[i].displayName)
// .replaceAll(' ', '');
// List<String> pinyinList = _contacts[i].displayName == null
// ? []
// : PinyinHelper.getPinyin(_contacts[i].displayName).split(' ');
// item.pinyinFirst = '';
// item.pinyinList = [];
// 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 += '';
// }
// }
// contantShowModel.contacts.add(item);
// }
// contantShowModel.contactsShow = contantShowModel.contacts;
// contantShowModel.pageStateRight = PageState.Success;
// } else {
// contantShowModel.pageStateRight = PageState.Empty;
// }
// });
// await contantShowModel.searchData(contantShowModel.controller.text);
// }
@override
Widget build(BuildContext context) {
contantShowModel = Provider.of<ContantShowModel>(context, listen: true);
return Consumer<ContantShowModel>(builder: (context, model, _) {
if (model.pageStateRight != PageState.Success) {
return ExceptionPage(
pageState: model.pageStateRight,
callback: () async {
if (await checkContactPermission()) {
_openAddressBook();
} else {
goSetting = true;
openSetting();
}
},
emptyMsg: "暂时没有联系人哦",
emptyImg: "empty_search",
showMsg: "加载中,请稍后...",
);
} else {
return ListView.builder(
itemCount: contantShowModel.contactsShow?.length ?? 0,
itemBuilder: (BuildContext context, int index) {
UserHistoryEntity c = contantShowModel.contactsShow[index];
return ContantItemPage(
onTap: () {
if (c.phone != null && c.phone != '') {
DialogUtil.goPhone(c.phone);
}
},
index: index,
model: contantShowModel,
data: contantShowModel.contactsShow,
);
});
}
});
}
}
// @override
// Widget build(BuildContext context) {
// contantShowModel = Provider.of<ContantShowModel>(context, listen: true);
// return Consumer<ContantShowModel>(builder: (context, model, _) {
// if (model.pageStateRight != PageState.Success) {
// return ExceptionPage(
// pageState: model.pageStateRight,
// callback: () async {
// if (await checkContactPermission()) {
// _openAddressBook();
// } else {
// goSetting = true;
// openSetting();
// }
// },
// emptyMsg: "暂时没有联系人哦",
// emptyImg: "empty_search",
// showMsg: "加载中,请稍后...",
// );
// } else {
// return ListView.builder(
// itemCount: contantShowModel.contactsShow?.length ?? 0,
// itemBuilder: (BuildContext context, int index) {
// UserHistoryEntity c = contantShowModel.contactsShow[index];
// return ContantItemPage(
// onTap: () {
// if (c.phone != null && c.phone != '') {
// DialogUtil.goPhone(c.phone);
// }
// },
// index: index,
// model: contantShowModel,
// data: contantShowModel.contactsShow,
// );
// });
// }
// });
// }
// }
... ...
import 'package:azlistview/azlistview.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:lpinyin/lpinyin.dart';
import 'package:one_key/models/user_history_entity.dart';
import 'package:one_key/provider/contact_model.dart';
import 'package:one_key/res/colors.dart';
import 'package:one_key/utils/utils.dart';
class ContactListPage extends StatefulWidget {
final List<UserHistoryEntity> contacts;
const ContactListPage({Key key, this.contacts}) : super(key: key);
@override
State<StatefulWidget> createState() {
return new _ContactListPageState();
}
}
class _ContactListPageState extends State<ContactListPage> {
// List<contan> _contacts = [];
double susItemHeight = ScreenUtil().setWidth(10);
@override
void initState() {
super.initState();
// loadData();
_handleList(widget.contacts);
}
// void loadData() async {
// //加载联系人列表
// rootBundle.loadString('assets/data/contacts.json').then((value) {
// List list = json.decode(value);
// list.forEach((v) {
// _contacts.add(ContactInfo.fromJson(v));
// });
// _handleList(_contacts);
// });
// }
void _handleList(List<UserHistoryEntity> list) {
if (list == null || list.isEmpty) return;
for (int i = 0, length = list.length; i < length; i++) {
String pinyin = '';
String tag = '';
if (list[i].pinyin == null || list[i].pinyin == '') {
// list[i].pinyin = pinyin;
} else {
tag = list[i].pinyin.substring(0, 1).toUpperCase();
}
if (RegExp("[A-Z]").hasMatch(tag)) {
list[i].tagIndex = tag;
} else {
list[i].tagIndex = "#";
}
}
// A-Z sort.
SuspensionUtil.sortListBySuspensionTag(widget.contacts);
// show sus tag.
SuspensionUtil.setShowSuspensionStatus(widget.contacts);
// add header.
// _contacts.insert(0, UserHistoryEntity(name: 'header', tagIndex: '↑'));
setState(() {});
}
Widget _buildHeader() {
return Container(
padding: EdgeInsets.all(20),
alignment: Alignment.center,
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
ClipOval(
child: Image.asset(
"./assets/images/avatar.png",
width: 80.0,
)),
Padding(
padding: const EdgeInsets.all(8.0),
child: Text(
"远行",
textScaleFactor: 1.2,
),
),
Text("+86 182-286-44678"),
],
),
);
}
Widget _buildSusWidget(String susTag) {
return Container(
padding: EdgeInsets.symmetric(
horizontal: ScreenUtil().setWidth(20),
vertical: ScreenUtil().setWidth(10)),
// height: susItemHeight,
// margin: EdgeInsets.only(bottom: ScreenUtil().setWidth(20)),
width: double.infinity,
color: Color.fromRGBO(239, 239, 239, 1),
alignment: Alignment.centerLeft,
child: Text(
'$susTag',
style: TextStyle(fontSize: ScreenUtil().setWidth(28)),
),
);
}
Widget _buildListItem(UserHistoryEntity model) {
String susTag = model.getSuspensionTag();
return Column(
children: <Widget>[
Offstage(
offstage: model.isShowSuspension != true,
child: _buildSusWidget(susTag),
),
Container(
padding: EdgeInsets.only(
left: ScreenUtil().setWidth(30),
right: ScreenUtil().setWidth(30),
bottom: ScreenUtil().setWidth(30)),
decoration: BoxDecoration(
border: Border(
bottom: BorderSide(
color: Color.fromRGBO(244, 244, 244, 1),
width: ScreenUtil().setWidth(2)))),
child: Row(
children: [
Stack(
alignment: Alignment.bottomCenter,
clipBehavior: Clip.none,
children: [
Stack(
alignment: Alignment.centerLeft,
clipBehavior: Clip.none,
children: [
CircleAvatar(
radius: ScreenUtil().setWidth(60),
backgroundColor: Color.fromRGBO(239, 239, 239, 1),
child: Text(
model.rname != null && model.rname != ''
? model.rname.substring(0, 1)
: '',
style: TextStyle(
color: Color.fromRGBO(206, 206, 206, 1),
fontSize: ScreenUtil().setSp(42)),
),
),
Positioned(
left: ScreenUtil().setWidth(-18),
child: Image.asset(
Utils.getImgPath('select'),
width: ScreenUtil().setWidth(36),
))
]),
Positioned(
bottom: ScreenUtil().setWidth(-20),
child: Container(
padding: EdgeInsets.symmetric(
horizontal: ScreenUtil().setWidth(10),
vertical: ScreenUtil().setWidth(2),
),
decoration: BoxDecoration(
color: Color.fromRGBO(223, 33, 81, 1),
borderRadius: BorderRadius.circular(
ScreenUtil().setWidth(10),
),
),
child: Text('沉睡',
style: TextStyle(
color: MyColours.color_ffffff,
fontSize: ScreenUtil().setSp(28)))))
],
)
],
),
)
// ListTile(
// leading: ,
// title: Text(model.rname),
// onTap: () {
// print("OnItemClick: $model");
// Navigator.pop(context, model);
// },
// )
],
);
}
Decoration getIndexBarDecoration(Color color) {
return BoxDecoration(
color: color,
borderRadius: BorderRadius.circular(20.0),
border: Border.all(color: Colors.grey[300], width: .5));
}
@override
Widget build(BuildContext context) {
return AzListView(
data: widget.contacts,
itemCount: widget.contacts.length,
itemBuilder: (BuildContext context, int index) {
// if (index == 0) return _buildHeader();
UserHistoryEntity model = widget.contacts[index];
return Padding(
padding: EdgeInsets.symmetric(vertical: ScreenUtil().setWidth(40)),
child: _buildListItem(model));
},
physics: BouncingScrollPhysics(),
indexBarData: SuspensionUtil.getTagIndexList(widget.contacts),
indexHintBuilder: (context, hint) {
return Container(
alignment: Alignment.center,
width: ScreenUtil().setWidth(120),
height: ScreenUtil().setWidth(120),
decoration: BoxDecoration(
color: Color.fromRGBO(239, 239, 239, 1),
shape: BoxShape.circle,
),
child:
Text(hint, style: TextStyle(color: Colors.white, fontSize: 30.0)),
);
},
indexBarMargin: EdgeInsets.all(10),
indexBarOptions: IndexBarOptions(
needRebuild: true,
decoration: getIndexBarDecoration(Colors.grey[50]),
downDecoration: getIndexBarDecoration(Colors.grey[200]),
),
);
}
}
... ...
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/screenutil.dart';
import 'package:one_key/constant/state.dart';
import 'package:one_key/pages/my/contant_item_page.dart';
import 'package:one_key/pages/my/customer_type/contant_list_page.dart';
import 'package:one_key/provider/contant_show_model.dart';
import 'package:one_key/provider/customer_provider.dart';
import 'package:one_key/provider/user_model.dart';
import 'package:one_key/res/colors.dart';
import 'package:one_key/utils/dialog_util.dart';
import 'package:one_key/utils/event_bus.dart';
import 'package:one_key/utils/utils.dart';
import 'package:one_key/widgets/custom_tab_indicator.dart';
import 'package:one_key/widgets/h_empty_view.dart';
import 'package:one_key/widgets/page_exception.dart';
import 'package:one_key/widgets/system_app_bar.dart';
import 'package:one_key/widgets/v_empty_view.dart';
import 'package:azlistview/azlistview.dart';
import 'package:provider/provider.dart';
class CustomerListPage extends StatefulWidget {
@override
_CustomerListPageState createState() => _CustomerListPageState();
}
class _CustomerListPageState extends State<CustomerListPage>
with TickerProviderStateMixin {
List _tabBarTitle;
TabController tabController;
CustomerProvider customerProvider;
@override
void initState() {
_tabBarTitle = ['全部', '活跃', '沉睡', '流失'];
super.initState();
tabController = TabController(length: 4, vsync: this);
WidgetsBinding.instance.addPostFrameCallback((_) async {
_getContantData();
});
}
_getContantData() async {
Map<String, String> params = {
"sid": Provider.of<UserModel>(context, listen: false).user.sellerid,
};
await customerProvider.getUserHistorys(context, params);
await customerProvider.searchData(customerProvider.controller.text);
}
@override
Widget build(BuildContext context) {
customerProvider = Provider.of<CustomerProvider>(context, listen: true);
return Material(
child: InkWell(
onTap: () {
// FocusScope.of(context).requestFocus(FocusNode()); //点击空白处隐藏键盘
},
child: Scaffold(
resizeToAvoidBottomInset: false,
backgroundColor: MyColours.color_ffffff,
appBar: SystemAppBar(
'全店客户',
onTap: () {
EventBus().emit('changeStatusColor');
Navigator.of(context).pop();
},
),
body: WillPopScope(
child: SafeArea(
child: Column(
children: <Widget>[
Container(
color: MyColours.color_ffffff,
padding: EdgeInsets.symmetric(
horizontal: ScreenUtil().setWidth(40),
vertical: ScreenUtil().setWidth(10)),
height: ScreenUtil().setWidth(45 * 2),
// alignment: Alignment.center,
child: Stack(
children: [
Container(
alignment: Alignment.center,
padding: EdgeInsets.symmetric(
horizontal: ScreenUtil().setWidth(20 * 2),
vertical: ScreenUtil().setWidth(14)),
decoration: BoxDecoration(
color: MyColours.color_ffffff,
borderRadius: BorderRadius.circular(
ScreenUtil().setWidth(24 * 2)),
border: Border.all(
color:
Color.fromRGBO(228, 228, 228, 1)),
boxShadow: [
BoxShadow(
color: Color.fromRGBO(
220, 220, 220, 1), //投影颜色
offset: Offset(2, 3), //x,y轴
blurRadius:
ScreenUtil().setWidth(6) //投影距离
)
]),
child: TextField(
maxLines: 1,
controller: customerProvider.controller,
// focusNode: _focusNode,
// autofocus: true,
style: TextStyle(
color: MyColours.color_333333,
fontSize: ScreenUtil().setSp(26)),
// textAlignVertical: TextAlignVertical.center,
decoration: InputDecoration(
contentPadding: EdgeInsets.only(
right: ScreenUtil().setWidth(40 * 2)),
hintText: "输入手机号或姓名",
hintStyle: TextStyle(
color: MyColours.color_999999,
fontSize: ScreenUtil().setSp(26),
),
isCollapsed:
true, //重点,相当于高度包裹的意思,必须设置为true,不然有默认奇妙的最小高度
border: OutlineInputBorder(
borderSide: BorderSide.none),
// 左边图标设置
icon: Image.asset(
Utils.getImgPath('search'),
width: ScreenUtil().setWidth(30),
),
//右边图标设置
// suffixIcon:
),
keyboardType: TextInputType.text,
textInputAction: TextInputAction.done,
onChanged: (value) {
// setState(() {});
// _searchSellerLocation();
customerProvider.searchData(value);
},
onEditingComplete: () {
FocusScope.of(context).requestFocus(
FocusNode()); //点击空白处隐藏键盘
// contantShowModel.searchData(
// contantShowModel.controller.text);
// _searchSellerLocation();
// _focusNode.unfocus();
},
),
),
Positioned(
right: 0,
top: 0,
bottom: 0,
child: Offstage(
offstage:
customerProvider.controller.text ==
'',
child: GestureDetector(
child: Container(
padding: EdgeInsets.only(
right: ScreenUtil()
.setWidth(20 * 2)),
// color: Colors.orange,
height:
ScreenUtil().setWidth(45 * 2),
width:
ScreenUtil().setWidth(100 * 2),
alignment: Alignment.centerRight,
child: Image.asset(
Utils.getImgPath('clear'),
width: ScreenUtil().setWidth(30),
height: ScreenUtil().setWidth(30),
),
),
onTap: () {
WidgetsBinding.instance
.addPostFrameCallback(((_) {
customerProvider.controller
.clear();
customerProvider.searchData('');
}));
},
)))
],
)),
Container(
margin: EdgeInsets.symmetric(
horizontal: ScreenUtil().setWidth(40),
vertical: ScreenUtil().setWidth(20)),
decoration: BoxDecoration(
color: MyColours.color_ffffff,
boxShadow: [
BoxShadow(
// color: Colors.red,
color: Color.fromRGBO(
220, 220, 220, 1), //投影颜色
offset: Offset(2, 2), //x,y轴
blurRadius:
ScreenUtil().setWidth(6) //投影距离
)
]),
child: Row(
children: [
Expanded(
child: Container(
padding: EdgeInsets.only(
bottom: ScreenUtil().setWidth(10)),
margin: EdgeInsets.symmetric(
horizontal: ScreenUtil().setWidth(30)),
child: TabBar(
controller: tabController,
indicator: CustomTabIndicator(
radius: 0,
),
indicatorColor: MyColours.color_199095,
indicatorSize: TabBarIndicatorSize.tab,
// indicatorPadding: EdgeInsets.symmetric(
// horizontal: ScreenUtil().setWidth(12)),
labelColor: MyColours.color_199095,
labelStyle: TextStyle(
fontSize: ScreenUtil().setSp(32),
fontWeight: FontWeight.bold),
labelPadding: EdgeInsets.zero,
unselectedLabelStyle: TextStyle(
fontWeight: FontWeight.normal,
fontSize: ScreenUtil().setSp(28),
),
unselectedLabelColor:
MyColours.color_999999,
tabs: _tabBarTitle.map((value) {
return Tab(
child: Text(value),
);
}).toList()),
)),
InkWell(
onTap: () {},
child: Container(
padding: EdgeInsets.only(
bottom: ScreenUtil().setWidth(10)),
margin: EdgeInsets.only(
right: ScreenUtil().setWidth(30)),
width: ScreenUtil().setWidth(100),
// height: ScreenUtil().setWidth(50),
child: Row(
children: [
Text(
'筛选',
style: TextStyle(
fontSize:
ScreenUtil().setSp(28),
color: MyColours.color_999999),
),
HEmptyView(10),
Image.asset(
Utils.getImgPath(
'enter_order_arrow'),
width: ScreenUtil().setWidth(20),
height: ScreenUtil().setWidth(10),
)
],
)),
)
],
)),
VEmptyView(10),
Expanded(
child: TabBarView(
controller: tabController,
// physics: NeverScrollableScrollPhysics(),
children: <Widget>[
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 ContactListPage(
contacts: model.userHistorysShow);
// return ListView.builder(
// itemCount: model.userHistorysShow.length,
// itemBuilder:
// (BuildContext context, int index) {
// String phone = model
// .userHistorysShow[index]
// .phone ==
// null ||
// model.userHistorysShow[index]
// .phone ==
// ''
// ? ''
// : model
// .userHistorysShow[index].phone;
// return ContantItemPage(
// onTap: () {
// if (model.userHistorysShow[index]
// .phone !=
// null &&
// model.userHistorysShow[index]
// .phone !=
// '') {
// DialogUtil.goPhone(model
// .userHistorysShow[index]
// .phone);
// }
// },
// index: index,
// model: customerProvider,
// data: model.userHistorysShow,
// );
// });
}
},
),
Container(
height: 200,
width: 300,
color: Colors.red,
),
Container(
height: 200,
width: 300,
color: Colors.red,
),
Container(
height: 200,
width: 300,
color: Colors.red,
)
],
)),
],
)),
onWillPop: () async {
EventBus().emit('changeStatusColor');
return true;
}))));
}
}
... ...
import 'package:flutter/material.dart';
import 'package:one_key/widgets/system_app_bar.dart';
class MyCustomerPage extends StatefulWidget {
MyCustomerPage({Key key}) : super(key: key);
@override
_MyCustomerPageState createState() => _MyCustomerPageState();
}
class _MyCustomerPageState extends State<MyCustomerPage> {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: SystemAppBar('我的客情', onTap: () {
Navigator.pop(context);
}),
body: Container(),
);
}
}
... ...
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/screenutil.dart';
import 'package:one_key/res/colors.dart';
import 'package:one_key/route/navigator_util.dart';
import 'package:one_key/utils/event_bus.dart';
import 'package:one_key/utils/utils.dart';
import 'package:one_key/widgets/h_empty_view.dart';
import 'package:one_key/widgets/round_button.dart';
import 'package:one_key/widgets/system_app_bar.dart';
import 'package:one_key/widgets/v_empty_view.dart';
class StoreCustomerPage extends StatefulWidget {
StoreCustomerPage({Key key}) : super(key: key);
@override
_StoreCustomerPageState createState() => _StoreCustomerPageState();
}
class _StoreCustomerPageState extends State<StoreCustomerPage> {
ScrollController _controller = ScrollController();
///活跃客户、沉睡客户、流失客户
Widget _percentWidget(String pnum, String btnTitle, String percent) {
return Container(
color: MyColours.color_ffffff,
// height: ScreenUtil().setWidth(230),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(pnum,
style: TextStyle(
color: MyColours.color_199095,
fontSize: ScreenUtil().setSp(40),
fontWeight: FontWeight.bold)),
Text('位',
style: TextStyle(
color: MyColours.color_199095,
fontSize: ScreenUtil().setSp(24),
))
],
),
VEmptyView(20),
RoundButton(
onPressed: () async {},
text: btnTitle,
fontSize: 24,
isBold: false,
textColor: MyColours.color_333333,
gradientStart: MyColours.color_ffffff,
gradientEnd: MyColours.color_ffffff,
borderColor: Color.fromRGBO(118, 118, 118, 1),
height: ScreenUtil().setWidth(45),
width: ScreenUtil().setWidth(160),
radius: ScreenUtil().setWidth(30),
),
VEmptyView(16),
percent == null
? SizedBox()
: Text('${percent}%',
style: TextStyle(
color: MyColours.color_199095,
fontSize: ScreenUtil().setSp(24),
)),
],
),
);
}
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Color.fromRGBO(246, 248, 250, 1),
appBar: SystemAppBar('全店客情', onTap: () {
EventBus().emit('changeStatusColor');
Navigator.pop(context);
}),
body: WillPopScope(
onWillPop: () async {
EventBus().emit('changeStatusColor');
return true;
},
child: Column(children: [
Expanded(
child: SingleChildScrollView(
controller: _controller,
child: Column(
children: [
VEmptyView(10),
Stack(
children: [
Container(
color: MyColours.color_ffffff,
padding: EdgeInsets.symmetric(
vertical: ScreenUtil().setWidth(30)),
child: Column(
children: [
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(
'19906',
style: TextStyle(
color: MyColours.color_199095,
fontSize: ScreenUtil().setSp(60),
fontWeight: FontWeight.bold),
),
Text(
'位',
style: TextStyle(
color: MyColours.color_199095,
fontWeight: FontWeight.bold,
fontSize: ScreenUtil().setSp(30)),
)
],
),
VEmptyView(10),
RoundButton(
onPressed: () async {
NavigatorUtil.goCustomerListPage(context);
},
text: '全店客户',
fontSize: 24,
isBold: false,
textColor: MyColours.color_333333,
gradientStart: MyColours.color_ffffff,
gradientEnd: MyColours.color_ffffff,
borderColor: Color.fromRGBO(118, 118, 118, 1),
height: ScreenUtil().setWidth(45),
width: ScreenUtil().setWidth(160),
radius: ScreenUtil().setWidth(30),
)
],
),
),
Positioned(
top: ScreenUtil().setWidth(20),
right: ScreenUtil().setWidth(40),
child: Image.asset(Utils.getImgPath('add_area'),
width: ScreenUtil().setWidth(30)))
],
),
VEmptyView(10),
GridView.builder(
controller: _controller,
shrinkWrap: true,
cacheExtent: ScreenUtil().setWidth(0),
itemCount: 3,
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 3,
childAspectRatio: 1,
mainAxisSpacing: ScreenUtil().setWidth(10),
crossAxisSpacing: ScreenUtil().setWidth(10)),
itemBuilder: (BuildContext context, int index) {
// locationState = state;
return _percentWidget('1999', '活跃客户', '39.20');
}),
// Row(
// children: [
// _percentWidget('19992', '活跃客户', '90.90'),
// HEmptyView(10),
// _percentWidget('19992', '沉睡客户', '90.90'),
// HEmptyView(10),
// _percentWidget('19992', '流失客户', '5.90'),
// ],
// ),
Padding(
padding: EdgeInsets.symmetric(
vertical: ScreenUtil().setWidth(30)),
child: Text(
'客户经理',
style: TextStyle(
fontSize: ScreenUtil().setSp(28),
color: MyColours.color_333333),
),
),
GridView.builder(
controller: _controller,
shrinkWrap: true,
cacheExtent: ScreenUtil().setWidth(0),
itemCount: 20,
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 3,
childAspectRatio: 1,
mainAxisSpacing: ScreenUtil().setWidth(10),
crossAxisSpacing: ScreenUtil().setWidth(10)),
itemBuilder: (BuildContext context, int index) {
// locationState = state;
return _percentWidget('1999', 'xx经理', null);
})
],
),
)),
Padding(
padding: EdgeInsets.only(bottom: ScreenUtil().setWidth(30)),
child: RoundButton(
onPressed: () async {},
text: '营销记录',
fontSize: 24,
isBold: false,
textColor: MyColours.color_199095,
gradientStart: MyColours.color_ffffff,
gradientEnd: MyColours.color_ffffff,
borderColor: MyColours.color_199095,
height: ScreenUtil().setWidth(75),
width: ScreenUtil().setWidth(260),
radius: ScreenUtil().setWidth(10),
// image: Utils.getImgPath('add_area')
),
)
])),
);
}
}
... ...
... ... @@ -264,6 +264,7 @@ class MyPageState extends State<MyPage> with WidgetsBindingObserver {
];
}, body: Consumer<UserModel>(
builder: (BuildContext context, UserModel model, Widget child) {
UserModel userModel = Provider.of<UserModel>(context, listen: false);
return MediaQuery.removePadding(
context: context,
child: SingleChildScrollView(
... ... @@ -317,9 +318,19 @@ class MyPageState extends State<MyPage> with WidgetsBindingObserver {
ScreenUtil().setHeight(1),
color: MyColours.color_f3f3f3,
),
userModel.user.role_name == '管理员' ||
userModel.user.role_name == '店长'
? MyItem(
title: "全店客情",
content: "",
callback: () {
// Utils.goMiniProgramZm(context, "roomtype/roomtype");
NavigatorUtil.goStoreCustomerPage(context);
},
)
: SizedBox(),
MyItem(
title: "联系人",
title: "我的客情",
content: "",
callback: () {
// Utils.goMiniProgramZm(context, "roomtype/roomtype");
... ...
import 'package:flutter/material.dart';
import 'package:lpinyin/lpinyin.dart';
import 'package:one_key/constant/constant.dart';
import 'package:one_key/constant/error.dart';
import 'package:one_key/constant/state.dart';
import 'package:one_key/models/user_history_entity.dart';
import 'package:one_key/net/base_resp.dart';
import 'package:one_key/net/dio_util.dart';
import 'package:one_key/net/http_url.dart';
import 'package:one_key/widgets/loading.dart';
class CustomerProvider extends ChangeNotifier {
PageState pageState = PageState.Loading;
List<UserHistoryEntity> userHistorys = []; //历史录入(总)
List<UserHistoryEntity> userHistorysShow = []; //历史录入展示
TextEditingController controller = TextEditingController(); //搜索框
//获取历史录入
getUserHistorys(BuildContext context, Map<String, String> params) async {
BaseResp<List> baseResp = await DioUtil()
.request<List>(context, Method.get, HttpUrl.get_reserve_user,
data: params, showLoading: false)
.catchError((error) {
print(error.toString());
if (error is MyError) {
switch (error.type) {
case 1:
pageState = PageState.ConnectivityError;
break;
case 2:
pageState = PageState.ConnectivityTimeOut;
break;
default:
pageState = PageState.ConnectivityError;
break;
}
}
notifyListeners();
});
if (baseResp != null && baseResp.code == Constant.status_success) {
userHistorys = baseResp.data.map<UserHistoryEntity>((value) {
return UserHistoryEntity.fromJson(value);
}).toList();
if (userHistorys.length == 0) {
pageState = PageState.Empty;
} else {
for (int i = 0; i < userHistorys.length; i++) {
UserHistoryEntity 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;
pageState = PageState.Success;
}
notifyListeners();
}
}
searchData(String key) {
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;
} else {
pageState = PageState.Success;
}
// if (contactsShow.length == 0) {
// pageStateRight = PageState.Empty;
// } else {
// pageStateRight = PageState.Success;
// }
}
notifyListeners();
}
}
... ...
... ... @@ -506,10 +506,24 @@ class NavigatorUtil {
/// 填写预订联系人页面
static Future<dynamic> goEditReserverPage(
BuildContext context, String rid, String name,String sex,
BuildContext context, String rid, String name, String sex,
{replace = false, bool needBtn = false}) {
return _navigateTo(context,
"${Routes.edit_reserver_page}?rid=${rid}&needBtn=$needBtn&name=${Uri.encodeComponent(name)}&sex=$sex",
replace: replace);
}
/// 全店客情页面
static Future<dynamic> goStoreCustomerPage(BuildContext context,
{replace = false, bool needBtn = false}) {
return _navigateTo(context, "${Routes.store_customer_page}",
replace: replace);
}
/// 客情列表
static Future<dynamic> goCustomerListPage(BuildContext context,
{replace = false, bool needBtn = false}) {
return _navigateTo(context, "${Routes.customer_list_page}",
replace: replace);
}
}
... ...
... ... @@ -39,6 +39,8 @@ import 'package:one_key/pages/detail/handle_online_page.dart';
import 'package:one_key/pages/detail/notebook_detail_page.dart';
import 'package:one_key/pages/login/web_page.dart';
import 'package:one_key/pages/message/message_order_menu.dart';
import 'package:one_key/pages/my/customer_type/customer_list_page.dart';
import 'package:one_key/pages/my/customer_type/store_customer_page.dart';
import 'package:one_key/pages/my/personnel_type/personnel_detail_page.dart';
import 'package:one_key/pages/my/personnel_type/personnel_manage_page.dart';
import 'package:one_key/pages/my/personnel_type/personnel_password_edit_page.dart';
... ... @@ -75,6 +77,7 @@ import 'package:one_key/provider/choose_table_model.dart';
import 'package:one_key/provider/contant_show_model.dart';
import 'package:one_key/provider/coupon_provider.dart';
import 'package:one_key/provider/create_store_model.dart';
import 'package:one_key/provider/customer_provider.dart';
import 'package:one_key/provider/menu_provider.dart';
import 'package:one_key/provider/my_model.dart';
import 'package:one_key/provider/notebook_detail_change_model.dart';
... ... @@ -581,15 +584,15 @@ var myIntegralPageHandler = new Handler(
});
///我的联系人
var myContantPageHandler = new Handler(
handlerFunc: (BuildContext context, Map<String, List<Object>> params) {
// IntegralSunModel sunModel = IntegralSunModel.fromJson(json
// .decode(FluroConvertUtils.fluroCnParamsDecode(params["sunModel"].first)));
// String urlStr = FluroConvertUtils.fluroCnParamsDecode(params["urlStr"].first);
// var myContantPageHandler = new Handler(
// handlerFunc: (BuildContext context, Map<String, List<Object>> params) {
// // IntegralSunModel sunModel = IntegralSunModel.fromJson(json
// // .decode(FluroConvertUtils.fluroCnParamsDecode(params["sunModel"].first)));
// // String urlStr = FluroConvertUtils.fluroCnParamsDecode(params["urlStr"].first);
return ChangeNotifierProvider<ContantShowModel>(
create: (_) => ContantShowModel(), child: ContactListPage());
});
// return ChangeNotifierProvider<ContantShowModel>(
// create: (_) => ContantShowModel(), child: ContactListPage());
// });
///桌位照片管理
var tablePhotoManagerHandler = new Handler(
... ... @@ -814,3 +817,19 @@ var personnelPasswordEditPageHandle = new Handler(
create: (_) => PersonnelProvider(),
child: PersonnelPasswordEditPage(idstr: idstr));
});
///全店客情
var storeCustomerPageHandle = new Handler(
handlerFunc: (BuildContext context, Map<dynamic, List<Object>> params) {
// String idstr = params["idstr"].first;
return ChangeNotifierProvider<CustomerProvider>(
create: (_) => CustomerProvider(), child: StoreCustomerPage());
});
///客情列表
var customerListPageHandle = new Handler(
handlerFunc: (BuildContext context, Map<dynamic, List<Object>> params) {
// String idstr = params["idstr"].first;
return ChangeNotifierProvider<CustomerProvider>(
create: (_) => CustomerProvider(), child: CustomerListPage());
});
... ...
... ... @@ -66,8 +66,9 @@ class Routes {
"/personnel_password_edit_page"; //密码修改页
static String change_detail_f = "/change_detail_f"; //变更预订_方硕新修改页面
static String photo_manager_page = "/photo_manager_page"; //照片管理
static String edit_reserver_page = "/edit_reserver_page"; //填写预订联系人
static String edit_reserver_page = "/edit_reserver_page"; //填写预订联系人
static String store_customer_page = "/store_customer_page"; //全店客情
static String customer_list_page = "/customer_list_page"; //客情列表
static void configureRoutes(FluroRouter router) {
router.notFoundHandler = new Handler(
... ... @@ -118,7 +119,7 @@ class Routes {
router.define(complete_create_store,
handler: completeCreateStorePageHandler);
router.define(my_integral_page, handler: myIntegralPageHandler);
router.define(my_contant_page, handler: myContantPageHandler);
// router.define(my_contant_page, handler: myContantPageHandler);
router.define(table_photo_manager, handler: tablePhotoManagerHandler);
router.define(statistics_page, handler: statisticsPageHandler);
router.define(statistics_sms_page, handler: statisticsSmsPageHandler);
... ... @@ -142,7 +143,9 @@ class Routes {
handler: personnelPasswordEditPageHandle);
router.define(change_detail_f, handler: noteBookChangeFPageHandle);
router.define(photo_manager_page, handler: photoManagerPageHandle);
router.define(edit_reserver_page, handler: editReserverPageHandle);
router.define(edit_reserver_page, handler: editReserverPageHandle);
router.define(store_customer_page, handler: storeCustomerPageHandle);
router.define(customer_list_page, handler: customerListPageHandle);
}
... ...
... ... @@ -71,6 +71,13 @@ packages:
url: "https://pub.flutter-io.cn"
source: hosted
version: "0.14.2"
azlistview:
dependency: "direct main"
description:
name: azlistview
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.1.1"
boolean_selector:
dependency: transitive
description:
... ...
... ... @@ -143,6 +143,8 @@ dependencies:
path: library/webview_flutter-2.0.13-copy_inappwebview_select_file_20210930
sendsms:
path: library/sendsms-1.0.3
#联系人索引
azlistview: ^1.1.1
# sendsms: ^1.0.3
... ...