Commit 039263fdd981bc3c1be5cf9a379ed53038e265e7

Authored by wdn127929
1 parent b3ddaaa1

客户列表信息 差头像,选中状态,筛选业务

... ... @@ -8,6 +8,14 @@ enum PageState {
Empty, //空页面
NoPermission, //没有权限
First,
Statics,//统计页
Statics, //统计页
Success //成功
}
/**
* 来自那个页面
*/
enum FromPage {
FromPageMyCustomer, //我的客情
FromPageStoreCustomer, //全店客情
}
... ...
import 'package:azlistview/azlistview.dart';
import 'package:json_annotation/json_annotation.dart';
part 'customer_list_model.g.dart';
@JsonSerializable()
class CustomerListModel extends Object {
@JsonKey(name: 'ret')
int ret;
@JsonKey(name: 'data')
List<CustomerListSunModel> data;
@JsonKey(name: 'msg')
String msg;
CustomerListModel(
this.ret,
this.data,
this.msg,
);
factory CustomerListModel.fromJson(Map<String, dynamic> srcJson) =>
_$CustomerListModelFromJson(srcJson);
Map<String, dynamic> toJson() => _$CustomerListModelToJson(this);
}
@JsonSerializable()
class CustomerListSunModel extends Object with ISuspensionBean {
@JsonKey(name: 'id')
String id;
@JsonKey(name: 'sellerid')
String sellerid;
@JsonKey(name: 'uid')
String uid;
@JsonKey(name: 'rname')
String rname;
@JsonKey(name: 'sex')
String sex;
@JsonKey(name: 'phone')
String phone;
@JsonKey(name: 'cdate')
String cdate;
@JsonKey(name: 'leiji')
String leiji;
@JsonKey(name: 'attr')
String attr;
@JsonKey(name: 'ddate')
String ddate;
@JsonKey(name: 'ddate_solt')
String ddateSolt;
@JsonKey(name: 'company')
String company;
@JsonKey(name: 'section')
String section;
@JsonKey(name: 'position')
String position;
@JsonKey(name: 'taboos')
String taboos;
@JsonKey(name: 'like')
String like;
@JsonKey(name: 'serve')
String serve;
@JsonKey(name: 'c_day')
String cDay;
@JsonKey(name: 'udate')
String udate;
@JsonKey(name: 'month_count')
String monthCount;
@JsonKey(name: 'label')
String label;
List<String> pinyinList; //全拼数组
String pinyin; //全拼字母
String pinyinFirst; //首字母
String tagIndex; //abcdefg
String get rnameStr {
if (rname == null || rname == '') return "";
return rname;
}
String get sexStr {
if (sex == null || sex == '') return "";
switch (sex.toString()) {
case "1": //先生
case "男":
case "先生":
return "先生";
case "2": //女士
case "女":
case "女士":
return "女士";
case "3": //公司
case "公司":
return "公司";
}
}
CustomerListSunModel(
this.id,
this.sellerid,
this.uid,
this.rname,
this.sex,
this.phone,
this.cdate,
this.leiji,
this.attr,
this.ddate,
this.ddateSolt,
this.company,
this.section,
this.position,
this.taboos,
this.like,
this.serve,
this.cDay,
this.udate,
this.monthCount,
this.label);
factory CustomerListSunModel.fromJson(Map<String, dynamic> srcJson) =>
_$CustomerListSunModelFromJson(srcJson);
Map<String, dynamic> toJson() => _$CustomerListSunModelToJson(this);
@override
String getSuspensionTag() => tagIndex;
}
... ...
// GENERATED CODE - DO NOT MODIFY BY HAND
part of 'customer_list_model.dart';
// **************************************************************************
// JsonSerializableGenerator
// **************************************************************************
CustomerListModel _$CustomerListModelFromJson(Map<String, dynamic> json) {
return CustomerListModel(
json['ret'] as int,
(json['data'] as List)
?.map((e) => e == null
? null
: CustomerListSunModel.fromJson(e as Map<String, dynamic>))
?.toList(),
json['msg'] as String,
);
}
Map<String, dynamic> _$CustomerListModelToJson(CustomerListModel instance) =>
<String, dynamic>{
'ret': instance.ret,
'data': instance.data,
'msg': instance.msg,
};
CustomerListSunModel _$CustomerListSunModelFromJson(Map<String, dynamic> json) {
return CustomerListSunModel(
json['id'] as String,
json['sellerid'] as String,
json['uid'] as String,
json['rname'] as String,
json['sex'] as String,
json['phone'] as String,
json['cdate'] as String,
json['leiji'] as String,
json['attr'] as String,
json['ddate'] as String,
json['ddate_solt'] as String,
json['company'] as String,
json['section'] as String,
json['position'] as String,
json['taboos'] as String,
json['like'] as String,
json['serve'] as String,
json['c_day'] as String,
json['udate'] as String,
json['month_count'] as String,
json['label'] as String,
);
}
Map<String, dynamic> _$CustomerListSunModelToJson(
CustomerListSunModel instance) =>
<String, dynamic>{
'id': instance.id,
'sellerid': instance.sellerid,
'uid': instance.uid,
'rname': instance.rname,
'sex': instance.sex,
'phone': instance.phone,
'cdate': instance.cdate,
'leiji': instance.leiji,
'attr': instance.attr,
'ddate': instance.ddate,
'ddate_solt': instance.ddateSolt,
'company': instance.company,
'section': instance.section,
'position': instance.position,
'taboos': instance.taboos,
'like': instance.like,
'serve': instance.serve,
'c_day': instance.cDay,
'udate': instance.udate,
'month_count': instance.monthCount,
'label': instance.label
};
... ...
... ... @@ -172,4 +172,7 @@ class HttpUrl {
static const String guest_manage =
"?service=App.GuestManage.GuestManage"; //我的客户首页
static const String get_customer_list =
"?service=App.GuestManage.GetCustomerList"; //用来获取客户列表
}
... ...
import 'package:azlistview/azlistview.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:one_key/constant/state.dart';
import 'package:one_key/models/customer_list_model.dart';
import 'package:one_key/models/user_history_entity.dart';
import 'package:one_key/provider/customer_provider.dart';
... ... @@ -11,10 +13,11 @@ import 'package:one_key/widgets/h_empty_view.dart';
import 'package:one_key/widgets/v_empty_view.dart';
class ContactListPage extends StatefulWidget {
final List<UserHistoryEntity> contacts;
final List<CustomerListSunModel> contacts;
final CustomerProvider provider;
final FromPage fromPage;
const ContactListPage({Key key, this.contacts, this.provider})
const ContactListPage({Key key, this.contacts, this.provider, this.fromPage})
: super(key: key);
@override
State<StatefulWidget> createState() {
... ... @@ -86,8 +89,9 @@ class _ContactListPageState extends State<ContactListPage> {
);
}
Widget _buildListItem(UserHistoryEntity model) {
Widget _buildListItem(CustomerListSunModel model) {
String susTag = model.getSuspensionTag();
return Column(
children: <Widget>[
Offstage(
... ... @@ -143,12 +147,23 @@ class _ContactListPageState extends State<ContactListPage> {
vertical: ScreenUtil().setWidth(2),
),
decoration: BoxDecoration(
color: Color.fromRGBO(223, 33, 81, 1),
color: model.attr != null && model.attr != ''
? model.attr == '沉睡'
? Color.fromRGBO(223, 33, 81, 1)
: model.attr == '活跃'
? Color.fromRGBO(81, 170, 94, 1)
: model.attr == '流失'
? Color.fromRGBO(109, 101, 248, 1)
: Color.fromRGBO(239, 143, 49, 1)
: Colors.transparent,
borderRadius: BorderRadius.circular(
ScreenUtil().setWidth(10),
),
),
child: Text('沉睡',
child: Text(
model.attr == null || model.attr == ''
? ''
: model.attr,
style: TextStyle(
color: MyColours.color_ffffff,
fontSize: ScreenUtil().setSp(28)))))
... ... @@ -162,45 +177,88 @@ class _ContactListPageState extends State<ContactListPage> {
Row(
crossAxisAlignment: CrossAxisAlignment.end,
children: [
Container(
constraints: BoxConstraints(
maxWidth: ScreenUtil().setWidth(200)),
child: Text(
model.rnameStr,
overflow: TextOverflow.ellipsis,
style: TextStyle(
color: MyColours.color_333333,
fontSize: ScreenUtil().setSp(36),
fontWeight: FontWeight.bold),
)),
HEmptyView(10),
Text(
model.sexStr != '' ? '[${model.sexStr}]' : '',
style: TextStyle(
color: MyColours.color_333333,
fontSize: ScreenUtil().setSp(22),
),
),
HEmptyView(10),
Container(
constraints: BoxConstraints(
maxWidth: ScreenUtil().setWidth(150)),
child: Text(
'低频高消费',
overflow: TextOverflow.ellipsis,
style: TextStyle(
color: Color.fromRGBO(193, 194, 63, 1),
fontSize: ScreenUtil().setSp(22),
),
))
model.rnameStr != null && model.rnameStr != ''
? Row(
children: [
Container(
constraints: BoxConstraints(
maxWidth: ScreenUtil().setWidth(200)),
child: Text(
model.rnameStr,
overflow: TextOverflow.ellipsis,
style: TextStyle(
color: MyColours.color_333333,
fontSize: ScreenUtil().setSp(36),
fontWeight: FontWeight.bold),
)),
HEmptyView(10),
Text(
model.sexStr != '' ? '[${model.sexStr}]' : '',
style: TextStyle(
color: MyColours.color_333333,
fontSize: ScreenUtil().setSp(22),
),
),
HEmptyView(10),
],
)
: SizedBox(),
model.label != null
? Container(
constraints: BoxConstraints(
maxWidth: ScreenUtil().setWidth(150)),
child: Text(
model.label,
overflow: TextOverflow.ellipsis,
style: TextStyle(
color: Color.fromRGBO(193, 194, 63, 1),
fontSize: ScreenUtil().setSp(22),
),
))
: SizedBox()
],
),
VEmptyView(10),
widget.fromPage == FromPage.FromPageMyCustomer &&
((model.company != null && model.company != '') ||
(model.phone != null && model.phone != ''))
? Padding(
padding: EdgeInsets.only(
bottom: ScreenUtil().setWidth(10)),
child: Row(
crossAxisAlignment: CrossAxisAlignment.end,
children: [
model.company != null && model.company != ''
? Container(
padding: EdgeInsets.only(
right: ScreenUtil().setWidth(10)),
constraints: BoxConstraints(
maxWidth: ScreenUtil().setWidth(200)),
child: Text(
'[${model.company}]',
overflow: TextOverflow.ellipsis,
style: TextStyle(
color: MyColours.color_999999,
fontSize: ScreenUtil().setSp(30)),
))
: SizedBox(),
model.phone != null && model.phone != ''
? Text(
model.phone,
overflow: TextOverflow.ellipsis,
style: TextStyle(
color: MyColours.color_999999,
fontSize: ScreenUtil().setSp(30)),
)
: SizedBox(),
],
))
: SizedBox(),
Row(
// crossAxisAlignment: CrossAxisAlignment.end,
children: [
Text(
'28天前',
Utils.format(model.ddate),
style: TextStyle(
color: Color.fromRGBO(208, 31, 37, 1),
fontSize: ScreenUtil().setSp(24),
... ... @@ -208,15 +266,28 @@ class _ContactListPageState extends State<ContactListPage> {
),
HEmptyView(10),
Text(
'午餐',
model.ddateSolt != null ? model.ddateSolt : '',
style: TextStyle(
color: Color.fromRGBO(208, 31, 37, 1),
fontSize: ScreenUtil().setSp(24),
),
),
model.monthCount == '0' || model.monthCount == null
? SizedBox()
: Padding(
padding: EdgeInsets.only(
left: ScreenUtil().setWidth(10)),
child: Text(
'30天内${model.monthCount}单',
style: TextStyle(
color: MyColours.color_199095,
fontSize: ScreenUtil().setSp(24),
),
),
),
HEmptyView(10),
Text(
'累计80单',
'累计${model.leiji}单',
style: TextStyle(
color: MyColours.color_199095,
fontSize: ScreenUtil().setSp(24),
... ... @@ -224,24 +295,27 @@ class _ContactListPageState extends State<ContactListPage> {
)
],
),
VEmptyView(10),
Container(
padding: EdgeInsets.symmetric(
horizontal: ScreenUtil().setWidth(12),
),
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),
),
)
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()
],
))
],
... ... @@ -273,7 +347,7 @@ class _ContactListPageState extends State<ContactListPage> {
itemCount: widget.contacts.length,
itemBuilder: (BuildContext context, int index) {
// if (index == 0) return _buildHeader();
UserHistoryEntity model = widget.contacts[index];
CustomerListSunModel model = widget.contacts[index];
return InkWell(
onTap: () {
NavigatorUtil.goCustomerDetailPage(context, model);
... ...
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/screenutil.dart';
import 'package:one_key/models/customer_list_model.dart';
import 'package:one_key/models/user_history_entity.dart';
import 'package:one_key/res/colors.dart';
import 'package:one_key/route/navigator_util.dart';
... ... @@ -11,7 +12,7 @@ import 'package:one_key/widgets/system_app_bar.dart';
import 'package:one_key/widgets/v_empty_view.dart';
class CustomerDetailPage extends StatefulWidget {
final UserHistoryEntity userHistoryEntity;
final CustomerListSunModel userHistoryEntity;
CustomerDetailPage({Key key, this.userHistoryEntity}) : super(key: key);
@override
... ...
... ... @@ -26,6 +26,9 @@ import 'package:provider/provider.dart';
typedef ClickCallback = void Function(dynamic value);
class CustomerListPage extends StatefulWidget {
final FromPage fromPage;
const CustomerListPage({Key key, this.fromPage}) : super(key: key);
@override
_CustomerListPageState createState() => _CustomerListPageState();
}
... ... @@ -55,10 +58,10 @@ class _CustomerListPageState extends State<CustomerListPage>
_getContantData() async {
Map<String, String> params = {
"sid": Provider.of<UserModel>(context, listen: false).user.sellerid,
"uid": Provider.of<UserModel>(context, listen: false).user.openid,
};
await customerProvider.getUserHistorys(context, params);
await customerProvider.searchData(customerProvider.controller.text);
await customerProvider.getCustomerList(context, params);
// await customerProvider.searchData(customerProvider.controller.text);
}
///选中的联系人widget
... ... @@ -1025,7 +1028,7 @@ class _CustomerListPageState extends State<CustomerListPage>
model.notifyListeners();
_getContantData();
},
emptyMsg: "暂时没有联系人哦",
emptyMsg: "暂时没有客户哦",
emptyImg: "empty_search",
showMsg: "加载中,请稍后...",
);
... ... @@ -1038,16 +1041,80 @@ class _CustomerListPageState extends State<CustomerListPage>
children: <Widget>[
ContactListPage(
contacts: model.userHistorysShow,
provider: customerProvider),
ContactListPage(
contacts: model.userHistorysShow,
provider: customerProvider),
ContactListPage(
contacts: model.userHistorysShow,
provider: customerProvider),
ContactListPage(
contacts: model.userHistorysShow,
provider: customerProvider),
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 ContactListPage(
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 ContactListPage(
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 ContactListPage(
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()
... ...
... ... @@ -150,7 +150,7 @@ class _MyCustomerPageState extends State<MyCustomerPage> {
VEmptyView(10),
RoundButton(
onPressed: () async {
NavigatorUtil.goCustomerListPage(context);
NavigatorUtil.goCustomerListPage(context,FromPage.FromPageMyCustomer);
},
text: '我的客户',
fontSize: 24,
... ...
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/screenutil.dart';
import 'package:one_key/constant/state.dart';
import 'package:one_key/res/colors.dart';
import 'package:one_key/route/navigator_util.dart';
import 'package:one_key/utils/event_bus.dart';
... ... @@ -119,7 +120,8 @@ class _StoreCustomerPageState extends State<StoreCustomerPage> {
VEmptyView(10),
RoundButton(
onPressed: () async {
NavigatorUtil.goCustomerListPage(context);
NavigatorUtil.goCustomerListPage(
context, FromPage.FromPageStoreCustomer);
},
text: '全店客户',
fontSize: 24,
... ...
... ... @@ -4,6 +4,7 @@ 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/customer_list_model.dart';
import 'package:one_key/models/guest_manage_model.dart';
import 'package:one_key/models/user_history_entity.dart';
import 'package:one_key/net/base_resp.dart';
... ... @@ -16,17 +17,24 @@ import 'package:provider/provider.dart';
class CustomerProvider extends ChangeNotifier {
PageState pageState = PageState.Loading;
List<UserHistoryEntity> userHistorys = []; //历史录入(总)
List<UserHistoryEntity> userHistorysShow = []; //历史录入展示
List<CustomerListSunModel> userHistorys = []; //客户列表(总)
List<CustomerListSunModel> userHistorysShow = []; //全部展示
List<CustomerListSunModel> userHistorysShowHuoyue = []; //活跃展示
List<CustomerListSunModel> userHistorysShowChenshui = []; //沉睡展示
List<CustomerListSunModel> userHistorysShowLiushi = []; //流失展示
TextEditingController controller = TextEditingController(); //搜索框
PageState pageStateMyHome = PageState.Loading;
PageState pageStateHuoyue = PageState.Loading;
PageState pageStateChenshui = PageState.Loading;
PageState pageStateLiushi = PageState.Loading;
GuestManageSunModel guestSunmodel;
//获取历史录入
getUserHistorys(BuildContext context, Map<String, String> params) async {
//用来获取客户列表
getCustomerList(BuildContext context, Map<String, String> params) async {
BaseResp<List> baseResp = await DioUtil()
.request<List>(context, Method.get, HttpUrl.get_reserve_user,
.request<List>(context, Method.get, HttpUrl.get_customer_list,
data: params, showLoading: false)
.catchError((error) {
print(error.toString());
... ... @@ -46,14 +54,14 @@ class CustomerProvider extends ChangeNotifier {
notifyListeners();
});
if (baseResp != null && baseResp.code == Constant.status_success) {
userHistorys = baseResp.data.map<UserHistoryEntity>((value) {
return UserHistoryEntity.fromJson(value);
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++) {
UserHistoryEntity item = userHistorys[i];
CustomerListSunModel item = userHistorys[i];
item.pinyinFirst = '';
item.pinyinList = [];
item.pinyinList = [];
... ... @@ -78,63 +86,154 @@ class CustomerProvider extends ChangeNotifier {
userHistorys[i] = item;
}
userHistorysShow = userHistorys;
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;
}
pageState = PageState.Success;
}
notifyListeners();
}
}
// //获取历史录入
// 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;
notifyListeners();
} else {
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 {
pageState = PageState.Success;
}
// if (contactsShow.length == 0) {
// pageStateRight = PageState.Empty;
// } else {
// pageStateRight = PageState.Success;
// }
}
// if (contactsShow.length == 0) {
// pageStateRight = PageState.Empty;
// } else {
// pageStateRight = PageState.Success;
// }
}
handleList(userHistorysShow, needRefresh: true);
handleList(userHistorysShow, needRefresh: true);
}
}
handleList(List<UserHistoryEntity> list, {bool needRefresh = false}) {
handleList(List<CustomerListSunModel> list, {bool needRefresh = false}) {
if (list == null || list.isEmpty) return;
for (int i = 0, length = list.length; i < length; i++) {
String pinyin = '';
... ... @@ -173,7 +272,7 @@ class CustomerProvider extends ChangeNotifier {
notifyListeners();
}
Map<String, String> params = {
'uid': Provider.of<UserModel>(context, listen: false).user.openid
'uid': Provider.of<UserModel>(context, listen: false).user.openid
};
BaseResp<dynamic> baseResp = await DioUtil()
.request<dynamic>(context, Method.get, HttpUrl.guest_manage,
... ...
import 'package:fluro/fluro.dart';
import 'package:flutter/material.dart';
import 'package:one_key/constant/state.dart';
import 'package:one_key/models/cookbook_model.dart';
import 'package:one_key/models/coupon_model.dart';
import 'package:one_key/models/customer_list_model.dart';
import 'package:one_key/models/integral_model.dart';
import 'package:one_key/models/notebook.dart';
import 'package:one_key/models/notebook_detail.dart';
... ... @@ -529,9 +531,11 @@ class NavigatorUtil {
}
/// 客情列表
static Future<dynamic> goCustomerListPage(BuildContext context,
static Future<dynamic> goCustomerListPage(
BuildContext context, FromPage fromPage,
{replace = false, bool needBtn = false}) {
return _navigateTo(context, "${Routes.customer_list_page}",
return _navigateTo(context,
"${Routes.customer_list_page}?fromPage=${FluroConvertUtils.enumToString(fromPage)}",
replace: replace);
}
... ... @@ -566,7 +570,7 @@ class NavigatorUtil {
/// 客户详情
static Future<dynamic> goCustomerDetailPage(
BuildContext context,
UserHistoryEntity userHistoryEntity, {
CustomerListSunModel userHistoryEntity, {
replace = false,
}) {
return _navigateTo(context,
... ...
... ... @@ -2,8 +2,10 @@ import 'dart:convert';
import 'package:fluro/fluro.dart';
import 'package:flutter/material.dart';
import 'package:one_key/constant/state.dart';
import 'package:one_key/models/cookbook_model.dart';
import 'package:one_key/models/coupon_model.dart';
import 'package:one_key/models/customer_list_model.dart';
import 'package:one_key/models/integral_model.dart';
import 'package:one_key/models/notebook_detail.dart';
import 'package:one_key/models/personnel_manage_model.dart';
... ... @@ -848,9 +850,12 @@ var myCustomerPageHandle = new Handler(
///客情列表
var customerListPageHandle = new Handler(
handlerFunc: (BuildContext context, Map<dynamic, List<Object>> params) {
// String idstr = params["idstr"].first;
FromPage fromPage = FluroConvertUtils.enumFromString<FromPage>(
FromPage.values, params["fromPage"].first);
print(fromPage);
return ChangeNotifierProvider<CustomerProvider>(
create: (_) => CustomerProvider(), child: CustomerListPage());
create: (_) => CustomerProvider(),
child: CustomerListPage(fromPage: fromPage));
});
///客情设置
... ... @@ -889,8 +894,8 @@ var makeMarkingPageHandle = new Handler(
var customerDetailPageHandle = new Handler(
handlerFunc: (BuildContext context, Map<dynamic, List<Object>> params) {
// String idstr = params["idstr"].first;
UserHistoryEntity userHistoryEntity = UserHistoryEntity.fromJson(json.decode(
FluroConvertUtils.fluroCnParamsDecode(
CustomerListSunModel userHistoryEntity = CustomerListSunModel.fromJson(
json.decode(FluroConvertUtils.fluroCnParamsDecode(
params["userHistoryEntity"].first)));
return ChangeNotifierProvider<CustomerProvider>(
create: (_) => CustomerProvider(),
... ...
... ... @@ -49,10 +49,17 @@ class FluroConvertUtils {
return json.decode(fluroCnParamsDecode(str));
}
/// string json 转为 map
static Map<String, List<TableList>> string2mapTableList(String str) {
return json.decode(fluroCnParamsDecode(str));
}
///枚举类型转string
static String enumToString(o) => o.toString().split('.').last;
///string转枚举类型
static T enumFromString<T>(Iterable<T> values, String value) {
return values.firstWhere((type) => type.toString().split('.').last == value,
orElse: () => null);
}
}
... ...
... ... @@ -483,6 +483,88 @@ const List gLunarHolDay = [
];
class Utils {
//
//时间转换
static String format(String datestr) {
String date = '';
String _str =
datestr.replaceAll('年', '-').replaceAll('月', '-').replaceAll('日', '');
String _time = "${_str} 16:00:00"; //注意格式否则在DateTime.parse()时会报错
DateTime _strtimes = DateTime.parse(
_time); //首先先将字符串格式的时间转为DateTime类型,因为millisecondsSinceEpoch方法转换要求为该格式
int _intendtime = _strtimes.millisecondsSinceEpoch; //方法一
// var _intendtime = DateTime.fromMillisecondsSinceEpoch(_strtimes );//方法二
// //_intendtime 为以及转换好的时间戳
DateTime dateNow = DateTime.now();
// String ymd = "${day.year}-" +
// Utils.addZeroNumber(day.month) +
// "-" +
// Utils.addZeroNumber(day.day);
if (Utils.isOneDay(_strtimes, dateNow)) {
date = "今天 ";
} else if (Utils.isOneDay(_strtimes, dateNow.add(Duration(days: 1)))) {
date = "明天 ";
} else if (Utils.isOneDay(_strtimes, dateNow.add(Duration(days: 2)))) {
date = "后天 ";
} else {
final num ONE_HOUR = 3600000;
final num ONE_DAY = 86400000;
final String ONE_DAY_AGO = "天前";
num delta = DateTime.now().millisecondsSinceEpoch -
_strtimes.millisecondsSinceEpoch;
// if (delta < 1 * ONE_MINUTE) {
// num seconds = toSeconds(delta);
// return (seconds <= 0 ? 1 : seconds).toInt().toString() + ONE_SECOND_AGO;
// }
// if (delta < 45 * ONE_MINUTE) {
// num minutes = toMinutes(delta);
// return (minutes <= 0 ? 1 : minutes).toInt().toString() + ONE_MINUTE_AGO;
// }
// if (delta < 24 * ONE_HOUR) {
// num hours = toHours(delta);
// return (hours <= 0 ? 1 : hours).toInt().toString() + ONE_HOUR_AGO;
// }
// if (delta < 48 * ONE_HOUR) {
// return "昨天";
// }
if (delta > 0) {
// if (delta < 30 * ONE_DAY) {
num days = toDays(delta);
date = (days <= 0 ? 1 : days).toInt().toString() + ONE_DAY_AGO;
// }
} else {
date = datestr;
}
return date;
// if (delta < 12 * 4 * ONE_WEEK) {
// num months = toMonths(delta);
// return (months <= 0 ? 1 : months).toInt().toString() + ONE_MONTH_AGO;
// } else {
// num years = toYears(delta);
// return (years <= 0 ? 1 : years).toInt().toString() + ONE_YEAR_AGO;
// }
}
}
static num toSeconds(num date) {
return date / 1000;
}
static num toMinutes(num date) {
return toSeconds(date) / 60;
}
static num toHours(num date) {
return toMinutes(date) / 60;
}
static num toDays(num date) {
return toHours(date) / 24;
}
static String getLunarSpecialDate(DateTime dateTime) {
String _day = '';
int iYear = dateTime.year;
... ...