Commit 659be1c457444255d1f7262f94c9f3d86ac852ee

Authored by wdn127929
1 parent df60ac84

全店用户列表接口部分

... ... @@ -21,5 +21,6 @@ enum FromPage {
FromPageHome, //客户列表页面来源---主页
FromPageMakeRecord, //客户列表页面来源---营销页面
FromPageCustomerList,
FromPageMakeRecordDetail,
FromPageMakeRecordDetail,
FromPageShowCutomerList, //仅展示客户列表,没有选择按钮
}
... ...
import 'package:azlistview/azlistview.dart';
import 'package:json_annotation/json_annotation.dart';
part 'customer_by_seller_model.g.dart';
@JsonSerializable()
class CustomerBySellerModel extends Object {
@JsonKey(name: 'ret')
int ret;
@JsonKey(name: 'data')
List<CustomerBySellerSunModel> data;
@JsonKey(name: 'msg')
String msg;
CustomerBySellerModel(
this.ret,
this.data,
this.msg,
);
factory CustomerBySellerModel.fromJson(Map<String, dynamic> srcJson) =>
_$CustomerBySellerModelFromJson(srcJson);
Map<String, dynamic> toJson() => _$CustomerBySellerModelToJson(this);
}
@JsonSerializable()
class CustomerBySellerSunModel extends Object with ISuspensionBean {
@JsonKey(name: 'rname')
String rname;
@JsonKey(name: 'sex')
String sex;
@JsonKey(name: 'phone')
String phone;
@JsonKey(name: 'sellerid')
String sellerid;
@JsonKey(name: 'month_count')
String monthCount;
@JsonKey(name: 'leiji')
String leiji;
@JsonKey(name: 'attr')
String attr;
@JsonKey(name: 'ddate')
String ddate;
@JsonKey(name: 'ddate_solt')
String ddateSolt;
@JsonKey(name: 'uid')
String uid;
@JsonKey(name: 'nick_name')
String nickName;
bool select = true;
String pinyin;
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 "公司";
}
}
CustomerBySellerSunModel(
this.rname,
this.sex,
this.phone,
this.sellerid,
this.monthCount,
this.leiji,
this.attr,
this.ddate,
this.ddateSolt,
this.uid,
this.nickName);
factory CustomerBySellerSunModel.fromJson(Map<String, dynamic> srcJson) =>
_$CustomerBySellerSunModelFromJson(srcJson);
Map<String, dynamic> toJson() => _$CustomerBySellerSunModelToJson(this);
@override
String getSuspensionTag() => tagIndex;
}
... ...
// GENERATED CODE - DO NOT MODIFY BY HAND
part of 'customer_by_seller_model.dart';
// **************************************************************************
// JsonSerializableGenerator
// **************************************************************************
CustomerBySellerModel _$CustomerBySellerModelFromJson(
Map<String, dynamic> json) {
return CustomerBySellerModel(
json['ret'] as int,
(json['data'] as List)
?.map((e) => e == null
? null
: CustomerBySellerSunModel.fromJson(e as Map<String, dynamic>))
?.toList(),
json['msg'] as String,
);
}
Map<String, dynamic> _$CustomerBySellerModelToJson(
CustomerBySellerModel instance) =>
<String, dynamic>{
'ret': instance.ret,
'data': instance.data,
'msg': instance.msg,
};
CustomerBySellerSunModel _$CustomerBySellerSunModelFromJson(
Map<String, dynamic> json) {
return CustomerBySellerSunModel(
json['rname'] as String,
json['sex'] as String,
json['phone'] as String,
json['sellerid'] as String,
json['month_count'] as String,
json['leiji'] as String,
json['attr'] as String,
json['ddate'] as String,
json['ddate_solt'] as String,
json['uid'] as String,
json['nick_name'] as String,
);
}
Map<String, dynamic> _$CustomerBySellerSunModelToJson(
CustomerBySellerSunModel instance) =>
<String, dynamic>{
'rname': instance.rname,
'sex': instance.sex,
'phone': instance.phone,
'sellerid': instance.sellerid,
'month_count': instance.monthCount,
'leiji': instance.leiji,
'attr': instance.attr,
'ddate': instance.ddate,
'ddate_solt': instance.ddateSolt,
'uid': instance.uid,
'nick_name': instance.nickName
};
... ...
... ... @@ -208,5 +208,7 @@ class HttpUrl {
"?service=App.GuestManage.GetGuestByGid"; // 客户经理营销中的用户列表
static const String get_marketing_by_uid =
"?service=App.GuestManage.GetMarketingByUid"; // 客户经理营销列表
static const String get_customer_by_seller =
"?service=App.GuestManage.GetCustomerBySeller"; // 全店客户列表
}
... ...
... ... @@ -11,20 +11,21 @@ import 'package:one_key/utils/utils.dart';
import 'package:one_key/widgets/h_empty_view.dart';
import 'package:one_key/widgets/v_empty_view.dart';
class ContactListPage extends StatefulWidget {
class MyContactListPage extends StatefulWidget {
final List<CustomerListSunModel> contacts;
final CustomerProvider provider;
final FromPage fromPage;
const ContactListPage({Key key, this.contacts, this.provider, this.fromPage})
const MyContactListPage(
{Key key, this.contacts, this.provider, this.fromPage})
: super(key: key);
@override
State<StatefulWidget> createState() {
return new _ContactListPageState();
return new _MyContactListPageState();
}
}
class _ContactListPageState extends State<ContactListPage> {
class _MyContactListPageState extends State<MyContactListPage> {
// List<contan> _contacts = [];
double susItemHeight = ScreenUtil().setWidth(10);
... ... @@ -32,7 +33,7 @@ class _ContactListPageState extends State<ContactListPage> {
void initState() {
super.initState();
// loadData();
widget.provider.handleList(widget.contacts);
widget.provider.myHandleList(widget.contacts);
}
// void loadData() async {
... ... @@ -372,7 +373,7 @@ class _ContactListPageState extends State<ContactListPage> {
CustomerListSunModel model = widget.contacts[index];
return InkWell(
onTap: () {
NavigatorUtil.goCustomerDetailPage(context, model, widget.fromPage);
NavigatorUtil.goMyCustomerDetailPage(context, model, widget.fromPage);
},
child: _buildListItem(model, index),
);
... ...
... ... @@ -2,8 +2,8 @@ import 'package:flutter/material.dart';
import 'package:flutter_screenutil/screenutil.dart';
import 'package:one_key/constant/state.dart';
import 'package:one_key/pages/my/customer_type/my_customer/my_contant_list_page.dart';
import 'package:one_key/pages/my/customer_type/contant_list_page.dart';
import 'package:one_key/provider/customer_making_provider.dart';
import 'package:one_key/provider/customer_provider.dart';
... ... @@ -1090,7 +1090,7 @@ class _MyCustomerListPageState extends State<MyCustomerListPage>
controller: tabController,
physics: NeverScrollableScrollPhysics(),
children: <Widget>[
ContactListPage(
MyContactListPage(
contacts: model.userHistorysShow,
provider: customerProvider,
fromPage: widget.fromPage),
... ... @@ -1109,7 +1109,7 @@ class _MyCustomerListPageState extends State<MyCustomerListPage>
showMsg: "加载中,请稍后...",
);
} else {
return ContactListPage(
return MyContactListPage(
contacts: model.userHistorysShowHuoyue,
provider: customerProvider,
fromPage: widget.fromPage);
... ... @@ -1131,7 +1131,7 @@ class _MyCustomerListPageState extends State<MyCustomerListPage>
showMsg: "加载中,请稍后...",
);
} else {
return ContactListPage(
return MyContactListPage(
contacts: model.userHistorysShowChenshui,
provider: customerProvider,
fromPage: widget.fromPage);
... ... @@ -1152,7 +1152,7 @@ class _MyCustomerListPageState extends State<MyCustomerListPage>
showMsg: "加载中,请稍后...",
);
} else {
return ContactListPage(
return MyContactListPage(
contacts: model.userHistorysShowLiushi,
provider: customerProvider,
fromPage: widget.fromPage);
... ...
... ... @@ -176,6 +176,10 @@ class _MyMarketingRecordsDetailPageState
HEmptyView(10),
InkWell(
onTap: () {
NavigatorUtil.goShowCustomerListPage(
context,
FromPage.FromPageStoreCustomer,
widget.selfList.gid);
// NavigatorUtil.goMyMarketingRecordsDetailPage(context);
},
child: Text('查看',
... ... @@ -201,11 +205,9 @@ class _MyMarketingRecordsDetailPageState
horizontal: ScreenUtil().setWidth(200)),
isBold: false,
onPressed: () {
NavigatorUtil.goMyMakeMarkingPage(context,
selfList:
widget.selfList,
fromPage:
FromPage.FromPageMakeRecordDetail);
NavigatorUtil.goMyMakeMarkingPage(context,
selfList: widget.selfList,
fromPage: FromPage.FromPageMakeRecordDetail);
},
),
VEmptyView(30),
... ...
... ... @@ -231,6 +231,10 @@ class _SellerMyMarketingRecordsDetailPageState
HEmptyView(10),
InkWell(
onTap: () {
NavigatorUtil.goShowCustomerListPage(
context,
FromPage.FromPageStoreCustomer,
widget.sellerList.gid);
// NavigatorUtil.goSellerMyMarketingRecordsDetailPage(context);
},
child: Text('查看',
... ...
... ... @@ -2,8 +2,9 @@ import 'package:flutter/material.dart';
import 'package:flutter_screenutil/screenutil.dart';
import 'package:one_key/constant/state.dart';
import 'package:one_key/pages/my/customer_type/my_customer/my_contant_list_page.dart';
import 'package:one_key/pages/my/customer_type/contant_list_page.dart';
import 'package:one_key/pages/my/customer_type/store_customer/contant_list_page.dart';
import 'package:one_key/provider/customer_making_provider.dart';
import 'package:one_key/provider/customer_provider.dart';
... ... @@ -1065,11 +1066,11 @@ class _ShowCustomerListPageState extends State<ShowCustomerListPage>
_searchWidget(), _menuWidget(),
Expanded(child:
Consumer<CustomerProvider>(builder: (context, model, _) {
if (model.pageState != PageState.Success) {
if (model.pageStateListShow != PageState.Success) {
return ExceptionPage(
pageState: model.pageState,
pageState: model.pageStateListShow,
callback: () {
model.pageState = PageState.Loading;
model.pageStateListShow = PageState.Loading;
model.notifyListeners();
_getGuestByGid();
},
... ... @@ -1084,17 +1085,18 @@ class _ShowCustomerListPageState extends State<ShowCustomerListPage>
controller: tabController,
physics: NeverScrollableScrollPhysics(),
children: <Widget>[
ContactListPage(
contacts: model.userHistorysShow,
MyContactListPage(
contacts: model.selectCustomer,
provider: customerProvider,
fromPage: widget.fromPage),
fromPage: FromPage.FromPageShowCutomerList),
Consumer<CustomerProvider>(
builder: (context, model, _) {
if (model.pageStateHuoyue != PageState.Success) {
if (model.pageStateListShow !=
PageState.Success) {
return ExceptionPage(
pageState: model.pageStateHuoyue,
pageState: model.pageStateListShow,
callback: () {
model.pageStateHuoyue = PageState.Loading;
model.pageStateListShow = PageState.Loading;
model.notifyListeners();
_getGuestByGid();
},
... ... @@ -1103,10 +1105,10 @@ class _ShowCustomerListPageState extends State<ShowCustomerListPage>
showMsg: "加载中,请稍后...",
);
} else {
return ContactListPage(
return MyContactListPage(
contacts: model.userHistorysShowHuoyue,
provider: customerProvider,
fromPage: widget.fromPage);
fromPage: FromPage.FromPageShowCutomerList);
}
}),
Consumer<CustomerProvider>(
... ... @@ -1125,10 +1127,10 @@ class _ShowCustomerListPageState extends State<ShowCustomerListPage>
showMsg: "加载中,请稍后...",
);
} else {
return ContactListPage(
return MyContactListPage(
contacts: model.userHistorysShowChenshui,
provider: customerProvider,
fromPage: widget.fromPage);
fromPage: FromPage.FromPageShowCutomerList);
}
}),
Consumer<CustomerProvider>(
... ... @@ -1146,10 +1148,10 @@ class _ShowCustomerListPageState extends State<ShowCustomerListPage>
showMsg: "加载中,请稍后...",
);
} else {
return ContactListPage(
return MyContactListPage(
contacts: model.userHistorysShowLiushi,
provider: customerProvider,
fromPage: widget.fromPage);
fromPage: FromPage.FromPageShowCutomerList);
}
}),
// ContactListPage(
... ... @@ -1161,9 +1163,9 @@ class _ShowCustomerListPageState extends State<ShowCustomerListPage>
// provider: customerProvider,
// fromPage: widget.fromPage),
])),
customerProvider.pageState == PageState.Success
? _selectContantWidget()
: SizedBox(),
// customerProvider.pageState == PageState.Success
// ? _selectContantWidget()
// : SizedBox(),
]);
}
})),
... ...
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_by_seller_model.dart';
// import 'package:one_key/models/customer_list_model.dart';
import 'package:one_key/provider/customer_provider.dart';
import 'package:one_key/res/colors.dart';
import 'package:one_key/route/navigator_util.dart';
import 'package:one_key/utils/utils.dart';
import 'package:one_key/widgets/h_empty_view.dart';
import 'package:one_key/widgets/v_empty_view.dart';
class ContactListPage extends StatefulWidget {
final List<CustomerBySellerSunModel> contacts;
final CustomerProvider provider;
final FromPage fromPage;
const ContactListPage({Key key, this.contacts, this.provider, this.fromPage})
: 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();
widget.provider.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);
// });
// }
// 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(CustomerBySellerSunModel model, int index) {
String susTag = model.getSuspensionTag();
return Column(
children: <Widget>[
Offstage(
offstage: model.isShowSuspension != true,
child: _buildSusWidget(susTag),
),
model.isShowSuspension ? VEmptyView(20) : SizedBox(),
Container(
padding: EdgeInsets.only(
left: ScreenUtil().setWidth(30),
right: ScreenUtil().setWidth(30),
bottom: ScreenUtil().setWidth(30),
top: model.isShowSuspension ? 0 : ScreenUtil().setWidth(30)),
decoration: BoxDecoration(
border: Border(
bottom: BorderSide(
color: Color.fromRGBO(244, 244, 244, 1),
width: ScreenUtil().setWidth(2)))),
child: Row(
children: [
InkWell(
onTap: () {
List<CustomerBySellerSunModel> data =
widget.provider.customerBySellerList;
data[index].select = !data[index].select;
if (data[index].select) {
widget.provider.addData(index);
} else {
widget.provider.cancelData(index);
}
widget.provider.getCheckValue();
},
child: 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.rnameStr != ''
? model.rnameStr.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(
model.select ? 'select' : 'unselect'),
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: 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(
model.attr == null || model.attr == ''
? ''
: model.attr,
style: TextStyle(
color: MyColours.color_ffffff,
fontSize: ScreenUtil().setSp(28)))))
],
)),
HEmptyView(20),
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
crossAxisAlignment: CrossAxisAlignment.end,
children: [
model.rnameStr != null && model.rnameStr != ''
? 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),
Padding(
padding: EdgeInsets.only(
bottom: ScreenUtil().setWidth(4)),
child: Text(
model.sexStr != ''
? '[${model.sexStr}]'
: '',
style: TextStyle(
color: MyColours.color_333333,
fontSize: ScreenUtil().setSp(22),
),
)),
HEmptyView(10),
],
)
: SizedBox(),
// model.label != null
// ? Container(
// padding: EdgeInsets.only(
// bottom: ScreenUtil().setWidth(4)),
// 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),
Row(
// crossAxisAlignment: CrossAxisAlignment.end,
children: [
Text(
Utils.formatFromYmd(model.ddate),
style: TextStyle(
color: Color.fromRGBO(208, 31, 37, 1),
fontSize: ScreenUtil().setSp(24),
fontWeight: FontWeight.bold),
),
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(
'累计${model.leiji}单',
style: TextStyle(
color: MyColours.color_199095,
fontSize: ScreenUtil().setSp(24),
),
)
],
),
model.nickName == null
? SizedBox()
: 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(
'${model.nickName}经理',
style: TextStyle(
fontSize: ScreenUtil().setSp(24),
color: MyColours.color_333333),
),
)
],
))
],
),
)
// 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: color, 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();
CustomerBySellerSunModel model = widget.contacts[index];
return InkWell(
onTap: () {
NavigatorUtil.goCustomerDetailPage(context, model, widget.fromPage);
},
child: _buildListItem(model, index),
);
},
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,
textStyle: TextStyle(
fontSize: ScreenUtil().setSp(24), color: MyColours.color_199095),
decoration: getIndexBarDecoration(Colors.transparent),
downDecoration: getIndexBarDecoration(Colors.transparent),
),
);
}
}
... ...
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/screenutil.dart';
import 'package:one_key/constant/state.dart';
import 'package:one_key/models/customer_by_seller_model.dart';
import 'package:one_key/models/customer_list_model.dart';
import 'package:one_key/models/guest_info_model.dart';
import 'package:one_key/models/user_history_entity.dart';
... ... @@ -18,7 +19,7 @@ import 'package:one_key/widgets/v_empty_view.dart';
import 'package:provider/provider.dart';
class CustomerDetailPage extends StatefulWidget {
final CustomerListSunModel userHistoryEntity;
final CustomerBySellerSunModel userHistoryEntity;
final FromPage fromPage;
CustomerDetailPage({Key key, this.userHistoryEntity, this.fromPage})
... ... @@ -52,7 +53,7 @@ class _CustomerDetailPageState extends State<CustomerDetailPage> {
_getGuestInfo() async {
Map<String, String> params = {
"id": widget.userHistoryEntity.id,
// "id": widget.userHistoryEntity.id,
'phone': widget.userHistoryEntity.phone
};
await customerProvider.getGuestInfo(context, params);
... ... @@ -140,27 +141,26 @@ class _CustomerDetailPageState extends State<CustomerDetailPage> {
],
),
Container(
padding: EdgeInsets.only(
top: ScreenUtil().setWidth(40),
left: ScreenUtil().setWidth(10),
right: ScreenUtil().setWidth(10)),
decoration: BoxDecoration(
border: Border.all(
color: MyColours.color_199095,
width: ScreenUtil().setWidth(2)),
borderRadius:
BorderRadius.circular(ScreenUtil().setWidth(10))),
child: Text(
// widget.userHistoryEntity.rnameStr == ''
// ? '未指派经理'
// : widget.userHistoryEntity.rnameStr,
'xxx经理',
style: TextStyle(
color: MyColours.color_333333,
fontSize: ScreenUtil().setSp(26)),
),
)
padding: EdgeInsets.only(
top: ScreenUtil().setWidth(40),
left: ScreenUtil().setWidth(10),
right: ScreenUtil().setWidth(10)),
decoration: BoxDecoration(
border: Border.all(
color: MyColours.color_199095,
width: ScreenUtil().setWidth(2)),
borderRadius:
BorderRadius.circular(ScreenUtil().setWidth(10))),
child: Text(
// widget.userHistoryEntity.rnameStr == ''
// ? '未指派经理'
// : widget.userHistoryEntity.rnameStr,
'xxx经理',
style: TextStyle(
color: MyColours.color_333333,
fontSize: ScreenUtil().setSp(26)),
),
)
],
),
HEmptyView(30),
... ... @@ -501,11 +501,11 @@ class _CustomerDetailPageState extends State<CustomerDetailPage> {
fontSize: 26,
isBold: false,
onPressed: () {
NavigatorUtil.goFestivalEditPage(
context,
customerProvider.guestInfoSunModel.guest,
widget.userHistoryEntity.id,
widget.userHistoryEntity.phone);
// NavigatorUtil.goFestivalEditPage(
// context,
// customerProvider.guestInfoSunModel.guest,
// widget.userHistoryEntity.id,
// widget.userHistoryEntity.phone);
},
),
],
... ...
... ... @@ -3,7 +3,7 @@ import 'package:flutter/material.dart';
import 'package:flutter_screenutil/screenutil.dart';
import 'package:one_key/constant/state.dart';
import 'package:one_key/pages/my/customer_type/contant_list_page.dart';
import 'package:one_key/pages/my/customer_type/store_customer/contant_list_page.dart';
import 'package:one_key/provider/customer_making_provider.dart';
import 'package:one_key/provider/customer_provider.dart';
... ... @@ -55,9 +55,12 @@ class _CustomerListPageState extends State<CustomerListPage>
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);
_getContantData();
}
});
WidgetsBinding.instance.addPostFrameCallback((_) async {
... ... @@ -74,12 +77,31 @@ class _CustomerListPageState extends State<CustomerListPage>
super.dispose();
}
_getContantData() async {
_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,
"sellerid": Provider.of<UserModel>(context, listen: false).user.sellerid,
};
await customerProvider.getCustomerList(context, params);
// await customerProvider.searchData(customerProvider.controller.text);
if (customerProvider.index != 0 && customerProvider.index != null) {
params['active'] = '${customerProvider.index}'; //1 活跃 2 沉睡 3 流失
}
if (customerProvider.controller.text.trim().length > 0) {
params['keyword'] = customerProvider.controller.text; //搜索手机号/姓名
}
//
//
// params['uid'] 经理ID
// params['labelid'] 标签ID
// params['stime'] 起始天数,例: 60
// params['etime'] 截止天数,例: 120
// params['reserve_date'] XX天内,例:30
// params['reserve_num'] 时间内预定次数
// params['reserve_sort'] 1 等于 2 小于 3 大于
await customerProvider.getCustomerBySeller(context, params);
}
// ///选中的联系人widget
... ... @@ -1047,6 +1069,33 @@ class _CustomerListPageState extends State<CustomerListPage>
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 ContactListPage(
contacts: model.customerBySellerList,
provider: customerProvider,
fromPage: widget.fromPage);
}
}));
}
return list;
}
@override
Widget build(BuildContext context) {
customerProvider = Provider.of<CustomerProvider>(context, listen: true);
... ... @@ -1070,110 +1119,16 @@ class _CustomerListPageState extends State<CustomerListPage>
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>[
ContactListPage(
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 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()
: SizedBox(),
]);
}
})),
Expanded(
child: TabBarView(
controller: tabController,
physics: NeverScrollableScrollPhysics(),
children: _returnListWidget())),
customerProvider.pageState == PageState.Success
? _selectContantWidget()
: SizedBox(),
// _searchWidget(),
// Positioned(
// top: 0,
... ...
... ... @@ -5,6 +5,7 @@ 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/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/guest_info_model.dart';
... ... @@ -66,6 +67,10 @@ class CustomerProvider extends ChangeNotifier {
MarketingByUidsSunModel myRecordData; //我的营销记录数据(包含详情)
PageState pageStateListShow = PageState.Loading;
List<CustomerBySellerSunModel> customerBySellerList; //全店客情列表
///客户经理获取所创建活动列表(选择优惠券)
Future<List<CouponSunModel>> getCustomerSelectActivityNew(
BuildContext context, Map<String, String> params,
... ... @@ -189,17 +194,17 @@ class CustomerProvider extends ChangeNotifier {
.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;
// }
switch (error.type) {
case 1:
pageStateListShow = PageState.ConnectivityError;
break;
case 2:
pageStateListShow = PageState.ConnectivityTimeOut;
break;
default:
pageStateListShow = PageState.ConnectivityError;
break;
}
}
notifyListeners();
});
... ... @@ -209,7 +214,7 @@ class CustomerProvider extends ChangeNotifier {
return CustomerListSunModel.fromJson(value);
}).toList();
if (user.length == 0) {
pageState = PageState.Empty;
pageStateListShow = PageState.Empty;
} else {
for (int i = 0; i < user.length; i++) {
CustomerListSunModel item = user[i];
... ... @@ -246,9 +251,15 @@ class CustomerProvider extends ChangeNotifier {
}
tempLabel = tempLabel.toSet().toList();
labels = Utils.listToStringEnglish(tempLabel);
pageStateListShow = PageState.Success;
}
notifyListeners();
} else {
if (baseResp != null) {
Utils.showToast(baseResp.msg ?? "");
}
pageStateGuestInfo = PageState.ConnectivityTimeOut;
}
notifyListeners();
}
// 获取客户详情
... ... @@ -694,12 +705,13 @@ class CustomerProvider extends ChangeNotifier {
// }
}
handleList(userHistorysShow, needRefresh: true);
myHandleList(userHistorysShow, needRefresh: true);
}
}
//实时更新右边数据 ABCDEFGHIGK....
handleList(List<CustomerListSunModel> list, {bool needRefresh = false}) {
myHandleList(List<CustomerListSunModel> list, {bool needRefresh = false}) {
if (list == null || list.isEmpty) return;
for (int i = 0, length = list.length; i < length; i++) {
String pinyin = '';
... ... @@ -821,7 +833,13 @@ class CustomerProvider extends ChangeNotifier {
return myRecordData;
}
/** 商家客情 */
/**
*
*
* 商家客情
*
*
* */
///全店客情首页
Future<StoreCustomerHomeSunModel> getSellerGuestManage(BuildContext context,
... ... @@ -879,6 +897,128 @@ class CustomerProvider extends ChangeNotifier {
return storeSunmodel;
}
//获取商家客户列表
getCustomerBySeller(BuildContext context, Map<String, String> params) async {
BaseResp<List> baseResp = await DioUtil()
.request<List>(context, Method.get, HttpUrl.get_customer_by_seller,
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) {
customerBySellerList =
CustomerBySellerModel.fromJson(baseResp.responseData).data;
if (customerBySellerList.length == 0) {
pageState = PageState.Empty;
} else {
pageState = PageState.Success;
for (int i = 0; i < customerBySellerList.length; i++) {
CustomerBySellerSunModel item = customerBySellerList[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 += '';
// }
// }
}
customerBySellerList[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;
// }
handleList(customerBySellerList, needRefresh: true);
}
notifyListeners();
}
}
//实时更新右边数据 ABCDEFGHIGK....
handleList(List<CustomerBySellerSunModel> list, {bool needRefresh = false}) {
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(list);
// show sus tag.
SuspensionUtil.setShowSuspensionStatus(list);
// add header.
// _contacts.insert(0, UserHistoryEntity(name: 'header', tagIndex: '↑'));
if (needRefresh) {
notifyListeners();
}
}
//商家修改客情配置
Future<bool> setSellerGuest(BuildContext context, Map<String, String> params,
{bool showLoading = false}) async {
... ...
... ... @@ -3,6 +3,7 @@ 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_by_seller_model.dart';
import 'package:one_key/models/customer_list_model.dart';
import 'package:one_key/models/guest_info_model.dart';
import 'package:one_key/models/integral_model.dart';
... ... @@ -596,7 +597,7 @@ class NavigatorUtil {
/// 客户详情
static Future<dynamic> goCustomerDetailPage(
BuildContext context,
CustomerListSunModel userHistoryEntity,
CustomerBySellerSunModel userHistoryEntity,
FromPage fromPage, {
replace = false,
}) {
... ...
... ... @@ -5,6 +5,7 @@ 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_by_seller_model.dart';
import 'package:one_key/models/customer_list_model.dart';
import 'package:one_key/models/guest_info_model.dart';
import 'package:one_key/models/integral_model.dart';
... ... @@ -1027,9 +1028,10 @@ var myMakeMarkingPageOnlyShowHandle = new Handler(
var customerDetailPageHandle = new Handler(
handlerFunc: (BuildContext context, Map<dynamic, List<Object>> params) {
// String idstr = params["idstr"].first;
CustomerListSunModel userHistoryEntity = CustomerListSunModel.fromJson(
json.decode(FluroConvertUtils.fluroCnParamsDecode(
params["userHistoryEntity"].first)));
CustomerBySellerSunModel userHistoryEntity =
CustomerBySellerSunModel.fromJson(json.decode(
FluroConvertUtils.fluroCnParamsDecode(
params["userHistoryEntity"].first)));
FromPage fromPage = FluroConvertUtils.enumFromString<FromPage>(
FromPage.values, params["fromPage"].first);
print(fromPage);
... ...