Commit 8c5797881fdc5d54a6f519e968de3d04849f2783

Authored by wdn127929
1 parent f646d950

客户详情页

import 'package:common_utils/common_utils.dart';
import 'package:json_annotation/json_annotation.dart';
import 'dart:convert' as convert;
import 'package:one_key/models/table_list.dart' as t;
part 'guest_info_model.g.dart';
@JsonSerializable()
class GuestInfoModel extends Object {
@JsonKey(name: 'ret')
int ret;
@JsonKey(name: 'data')
GuestInfoSunModel data;
@JsonKey(name: 'msg')
String msg;
GuestInfoModel(
this.ret,
this.data,
this.msg,
);
factory GuestInfoModel.fromJson(Map<String, dynamic> srcJson) =>
_$GuestInfoModelFromJson(srcJson);
Map<String, dynamic> toJson() => _$GuestInfoModelToJson(this);
}
@JsonSerializable()
class GuestInfoSunModel extends Object {
@JsonKey(name: 'guest')
Guest guest;
@JsonKey(name: 'last')
Last last;
@JsonKey(name: 'count')
Count count;
@JsonKey(name: 'marketing')
List<Marketing> marketing;
GuestInfoSunModel(
this.guest,
this.last,
this.count,
this.marketing,
);
factory GuestInfoSunModel.fromJson(Map<String, dynamic> srcJson) =>
_$GuestInfoSunModelFromJson(srcJson);
Map<String, dynamic> toJson() => _$GuestInfoSunModelToJson(this);
}
@JsonSerializable()
class Guest extends Object {
@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: 'attr')
String attr;
@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')
List cDay;
@JsonKey(name: 'udate')
String udate;
@JsonKey(name: 'label')
String label;
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 "公司";
}
}
Guest(
this.id,
this.sellerid,
this.uid,
this.rname,
this.sex,
this.phone,
this.attr,
this.company,
this.section,
this.position,
this.taboos,
this.like,
this.serve,
this.cDay,
this.udate,
this.label);
factory Guest.fromJson(Map<String, dynamic> srcJson) =>
_$GuestFromJson(srcJson);
Map<String, dynamic> toJson() => _$GuestToJson(this);
}
@JsonSerializable()
class Last extends Object {
@JsonKey(name: 'id')
String id;
@JsonKey(name: 'ddate')
String ddate;
@JsonKey(name: 'ddate_solt')
String ddateSolt;
@JsonKey(name: 'tableinfo')
String tableinfo;
@JsonKey(name: 'uid')
String uid;
@JsonKey(name: 'seller_user_nick_name')
String sellerUserNickName;
@JsonKey(name: 'seller_user_phone')
String sellerUserPhone;
@JsonKey(name: 'actual_pum')
String actualPum;
@JsonKey(name: 'con_amount')
String conAmount;
String get ddateSoltStr {
switch (ddateSolt) {
case "1":
return " 早餐";
break;
case "2":
return " 午餐";
break;
case "3":
return " 晚餐";
break;
}
return '';
}
String get tableinfoName {
List<dynamic> tableinfoList = convert.jsonDecode(tableinfo);
print(tableinfo);
String _nameStr = '';
for (int i = 0; i < tableinfoList.length; i++) {
_nameStr += '${t.TableList.fromJson(tableinfoList[i]).name},';
}
if (_nameStr.endsWith(',')) {
_nameStr = _nameStr.substring(0, _nameStr.length - 1);
}
return _nameStr;
}
Last(
this.id,
this.ddate,
this.ddateSolt,
this.tableinfo,
this.uid,
this.sellerUserNickName,
this.sellerUserPhone,
this.actualPum,
this.conAmount);
factory Last.fromJson(Map<String, dynamic> srcJson) =>
_$LastFromJson(srcJson);
Map<String, dynamic> toJson() => _$LastToJson(this);
}
@JsonSerializable()
class Count extends Object {
@JsonKey(name: 'leiji')
String leiji;
@JsonKey(name: 'quxiao')
int quxiao;
@JsonKey(name: 'create_time')
int createTime;
Count(
this.leiji,
this.quxiao,
this.createTime,
);
factory Count.fromJson(Map<String, dynamic> srcJson) =>
_$CountFromJson(srcJson);
Map<String, dynamic> toJson() => _$CountToJson(this);
}
@JsonSerializable()
class Marketing extends Object {
@JsonKey(name: 'id')
String id;
@JsonKey(name: 'uid')
String uid;
@JsonKey(name: 'aid')
String aid;
@JsonKey(name: 'gid')
String gid;
@JsonKey(name: 'content')
String content;
@JsonKey(name: 'cdate')
String cdate;
String get cdateStr {
DateTime dateTime =
DateTime.fromMillisecondsSinceEpoch(int.parse(cdate.toString()) * 1000);
return DateUtil.formatDate(dateTime, format: DateFormats.y_mo_d);
}
Marketing(
this.id,
this.uid,
this.aid,
this.gid,
this.content,
this.cdate,
);
factory Marketing.fromJson(Map<String, dynamic> srcJson) =>
_$MarketingFromJson(srcJson);
Map<String, dynamic> toJson() => _$MarketingToJson(this);
}
... ...
// GENERATED CODE - DO NOT MODIFY BY HAND
part of 'guest_info_model.dart';
// **************************************************************************
// JsonSerializableGenerator
// **************************************************************************
GuestInfoModel _$GuestInfoModelFromJson(Map<String, dynamic> json) {
return GuestInfoModel(
json['ret'] as int,
json['data'] == null
? null
: GuestInfoSunModel.fromJson(json['data'] as Map<String, dynamic>),
json['msg'] as String,
);
}
Map<String, dynamic> _$GuestInfoModelToJson(GuestInfoModel instance) =>
<String, dynamic>{
'ret': instance.ret,
'data': instance.data,
'msg': instance.msg,
};
GuestInfoSunModel _$GuestInfoSunModelFromJson(Map<String, dynamic> json) {
return GuestInfoSunModel(
json['guest'] == null
? null
: Guest.fromJson(json['guest'] as Map<String, dynamic>),
json['last'] == null
? null
: Last.fromJson(json['last'] as Map<String, dynamic>),
json['count'] == null
? null
: Count.fromJson(json['count'] as Map<String, dynamic>),
(json['marketing'] as List)
?.map((e) =>
e == null ? null : Marketing.fromJson(e as Map<String, dynamic>))
?.toList(),
);
}
Map<String, dynamic> _$GuestInfoSunModelToJson(GuestInfoSunModel instance) =>
<String, dynamic>{
'guest': instance.guest,
'last': instance.last,
'count': instance.count,
'marketing': instance.marketing,
};
Guest _$GuestFromJson(Map<String, dynamic> json) {
return Guest(
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['attr'] 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 List,
json['udate'] as String,
json['label'] as String,
);
}
Map<String, dynamic> _$GuestToJson(Guest instance) => <String, dynamic>{
'id': instance.id,
'sellerid': instance.sellerid,
'uid': instance.uid,
'rname': instance.rname,
'sex': instance.sex,
'phone': instance.phone,
'attr': instance.attr,
'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,
'label': instance.label,
};
Last _$LastFromJson(Map<String, dynamic> json) {
return Last(
json['id'] as String,
json['ddate'] as String,
json['ddate_solt'] as String,
json['tableinfo'] as String,
json['uid'] as String,
json['seller_user_nick_name'] as String,
json['seller_user_phone'] as String,
json['actual_pum'] as String,
json['con_amount'] as String,
);
}
Map<String, dynamic> _$LastToJson(Last instance) => <String, dynamic>{
'id': instance.id,
'ddate': instance.ddate,
'ddate_solt': instance.ddateSolt,
'tableinfo': instance.tableinfo,
'uid': instance.uid,
'seller_user_nick_name': instance.sellerUserNickName,
'seller_user_phone': instance.sellerUserPhone,
'actual_pum': instance.actualPum,
'con_amount': instance.conAmount,
};
Count _$CountFromJson(Map<String, dynamic> json) {
return Count(
json['leiji'] as String,
json['quxiao'] as int,
json['create_time'] as int,
);
}
Map<String, dynamic> _$CountToJson(Count instance) => <String, dynamic>{
'leiji': instance.leiji,
'quxiao': instance.quxiao,
'create_time': instance.createTime,
};
Marketing _$MarketingFromJson(Map<String, dynamic> json) {
return Marketing(
json['id'] as String,
json['uid'] as String,
json['aid'] as String,
json['gid'] as String,
json['content'] as String,
json['cdate'] as String,
);
}
Map<String, dynamic> _$MarketingToJson(Marketing instance) => <String, dynamic>{
'id': instance.id,
'uid': instance.uid,
'aid': instance.aid,
'gid': instance.gid,
'content': instance.content,
'cdate': instance.cdate,
};
... ...
... ... @@ -191,7 +191,7 @@ class DioUtil {
queryParameters: data,
options: _checkOptions(method, options, needHeader: needHeader),
cancelToken: cancelToken);
_printHttpLog(response);
_printHttpLog(response);
String _status;
int _code;
String _msg;
... ...
... ... @@ -174,5 +174,7 @@ class HttpUrl {
static const String get_customer_list =
"?service=App.GuestManage.GetCustomerList"; //用来获取客户列表
static const String get_guest_info =
"?service=App.GuestManage.GetGuestInfo"; // 获取客户详情
}
... ...
... ... @@ -257,7 +257,7 @@ class _ContactListPageState extends State<ContactListPage> {
// crossAxisAlignment: CrossAxisAlignment.end,
children: [
Text(
Utils.format(model.ddate),
Utils.formatFromYmd(model.ddate),
style: TextStyle(
color: Color.fromRGBO(208, 31, 37, 1),
fontSize: ScreenUtil().setSp(24),
... ... @@ -349,7 +349,7 @@ class _ContactListPageState extends State<ContactListPage> {
CustomerListSunModel model = widget.contacts[index];
return InkWell(
onTap: () {
NavigatorUtil.goCustomerDetailPage(context, model);
NavigatorUtil.goCustomerDetailPage(context, model, widget.fromPage);
},
child: _buildListItem(model),
);
... ...
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/screenutil.dart';
import 'package:one_key/constant/state.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';
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/dialog_util.dart';
import 'package:one_key/utils/utils.dart';
import 'package:one_key/widgets/h_empty_view.dart';
import 'package:one_key/widgets/page_exception.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';
import 'package:provider/provider.dart';
class CustomerDetailPage extends StatefulWidget {
final CustomerListSunModel userHistoryEntity;
CustomerDetailPage({Key key, this.userHistoryEntity}) : super(key: key);
final FromPage fromPage;
CustomerDetailPage({Key key, this.userHistoryEntity, this.fromPage})
: super(key: key);
@override
_CustomerDetailPageState createState() => _CustomerDetailPageState();
... ... @@ -21,6 +29,26 @@ class CustomerDetailPage extends StatefulWidget {
class _CustomerDetailPageState extends State<CustomerDetailPage> {
ScrollController controller = ScrollController();
CustomerProvider customerProvider;
@override
void initState() {
super.initState();
WidgetsBinding.instance.addPostFrameCallback((_) async {
_getGuestInfo();
});
}
_getGuestInfo() async {
Map<String, String> params = {
"id": widget.userHistoryEntity.id,
'phone': widget.userHistoryEntity.phone
};
await customerProvider.getGuestInfo(context, params);
// await customerProvider.searchData(customerProvider.controller.text);
}
Widget _headerWidget() {
return Container(
padding: EdgeInsets.symmetric(
... ... @@ -46,18 +74,20 @@ class _CustomerDetailPageState extends State<CustomerDetailPage> {
Container(
width: ScreenUtil().setWidth(120),
height: ScreenUtil().setWidth(120),
padding: EdgeInsets.only(bottom: ScreenUtil().setWidth(20)),
alignment: Alignment.center,
decoration: BoxDecoration(
color: Color.fromRGBO(239, 239, 239, 1),
borderRadius:
BorderRadius.circular(ScreenUtil().setWidth(20))),
child: Text(
widget.userHistoryEntity.rnameStr != ''
? widget.userHistoryEntity.rnameStr.substring(0, 1)
customerProvider.guestInfoSunModel.guest.rnameStr != ''
? customerProvider.guestInfoSunModel.guest.rnameStr
.substring(0, 1)
: '',
style: TextStyle(
color: Color.fromRGBO(206, 206, 206, 1),
fontSize: ScreenUtil().setSp(78)),
fontSize: ScreenUtil().setSp(72)),
),
),
Positioned(
... ... @@ -68,37 +98,60 @@ class _CustomerDetailPageState extends State<CustomerDetailPage> {
vertical: ScreenUtil().setWidth(2),
),
decoration: BoxDecoration(
color: Color.fromRGBO(223, 33, 81, 1),
color: customerProvider
.guestInfoSunModel.guest.attr !=
null &&
customerProvider
.guestInfoSunModel.guest.attr !=
''
? customerProvider
.guestInfoSunModel.guest.attr ==
'沉睡'
? Color.fromRGBO(223, 33, 81, 1)
: customerProvider
.guestInfoSunModel.guest.attr ==
'活跃'
? Color.fromRGBO(81, 170, 94, 1)
: customerProvider.guestInfoSunModel
.guest.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(
customerProvider.guestInfoSunModel.guest.attr,
style: TextStyle(
color: MyColours.color_ffffff,
fontSize: ScreenUtil().setSp(28)))))
],
),
VEmptyView(40),
Container(
padding:
EdgeInsets.symmetric(horizontal: 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)),
),
)
widget.fromPage == FromPage.FromPageStoreCustomer
? 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)),
),
)
: SizedBox()
],
),
HEmptyView(30),
... ... @@ -112,16 +165,16 @@ class _CustomerDetailPageState extends State<CustomerDetailPage> {
constraints:
BoxConstraints(maxWidth: ScreenUtil().setWidth(260)),
child: Text(
widget.userHistoryEntity.rnameStr,
customerProvider.guestInfoSunModel.guest.rnameStr,
overflow: TextOverflow.ellipsis,
style: TextStyle(
color: MyColours.color_333333,
fontSize: ScreenUtil().setSp(68)),
fontSize: ScreenUtil().setSp(64)),
)),
HEmptyView(10),
Text(
widget.userHistoryEntity.sexStr != ''
? '[${widget.userHistoryEntity.sexStr}]'
customerProvider.guestInfoSunModel.guest.sexStr != ''
? '[${customerProvider.guestInfoSunModel.guest.sexStr}]'
: '',
style: TextStyle(
color: MyColours.color_333333,
... ... @@ -130,22 +183,25 @@ class _CustomerDetailPageState extends State<CustomerDetailPage> {
),
],
),
VEmptyView(10),
Container(
constraints:
BoxConstraints(maxWidth: ScreenUtil().setWidth(200)),
child: Text(
'低频高消费',
overflow: TextOverflow.ellipsis,
style: TextStyle(
color: Color.fromRGBO(193, 194, 63, 1),
fontSize: ScreenUtil().setSp(22),
),
)),
customerProvider.guestInfoSunModel.guest.label != null
? Container(
padding: EdgeInsets.only(top: ScreenUtil().setWidth(10)),
constraints:
BoxConstraints(maxWidth: ScreenUtil().setWidth(200)),
child: Text(
customerProvider.guestInfoSunModel.guest.label,
overflow: TextOverflow.ellipsis,
style: TextStyle(
color: Color.fromRGBO(193, 194, 63, 1),
fontSize: ScreenUtil().setSp(22),
),
))
: SizedBox(),
VEmptyView(20),
InkWell(
onTap: () {
DialogUtil.goPhone(widget.userHistoryEntity.phone);
DialogUtil.goPhone(
customerProvider.guestInfoSunModel.guest.phone);
},
child: Container(
padding: EdgeInsets.symmetric(
... ... @@ -163,12 +219,12 @@ class _CustomerDetailPageState extends State<CustomerDetailPage> {
),
HEmptyView(10),
Text(
widget.userHistoryEntity.phone,
customerProvider.guestInfoSunModel.guest.phone,
overflow: TextOverflow.ellipsis,
style: TextStyle(
color: MyColours.color_ffffff,
fontWeight: FontWeight.bold,
fontSize: ScreenUtil().setSp(36),
fontSize: ScreenUtil().setSp(34),
),
)
],
... ... @@ -219,6 +275,7 @@ class _CustomerDetailPageState extends State<CustomerDetailPage> {
@override
Widget build(BuildContext context) {
customerProvider = Provider.of<CustomerProvider>(context, listen: true);
return Scaffold(
backgroundColor: Color.fromRGBO(246, 248, 250, 1),
appBar: SystemAppBar(
... ... @@ -227,253 +284,298 @@ class _CustomerDetailPageState extends State<CustomerDetailPage> {
Navigator.of(context).pop();
},
),
body: Column(
children: [
Expanded(
child: SingleChildScrollView(
controller: controller,
child: Column(
children: [
Container(
width: double.infinity,
height: ScreenUtil().setWidth(20),
color: MyColours.color_ffffff,
),
_headerWidget(),
VEmptyView(20),
Container(
padding: EdgeInsets.symmetric(
horizontal: ScreenUtil().setWidth(40),
vertical: ScreenUtil().setWidth(20)),
decoration: BoxDecoration(
color: MyColours.color_199095,
borderRadius: BorderRadius.only(
topRight: Radius.circular(ScreenUtil().setWidth(20)),
topLeft: Radius.circular(ScreenUtil().setWidth(20)))),
child: Row(
children: [
Expanded(
child: Text(
'已创建 97 天 累计 2 单',
overflow: TextOverflow.ellipsis,
style: TextStyle(
color: MyColours.color_ffffff,
fontSize: ScreenUtil().setSp(32)),
)),
InkWell(
onTap: () {
NavigatorUtil.goCustomerOrderPage(context);
},
child: Text('更多',
style: TextStyle(
decoration: TextDecoration.underline,
color: MyColours.color_ffffff,
fontSize: ScreenUtil().setSp(26)))),
],
),
),
Container(
color: MyColours.color_ffffff,
padding: EdgeInsets.symmetric(
horizontal: ScreenUtil().setWidth(20),
vertical: ScreenUtil().setWidth(20)),
child: Column(
children: [
Wrap(
body: Consumer<CustomerProvider>(builder: (context, model, _) {
if (model.pageStateGuestInfo != PageState.Success) {
return ExceptionPage(
pageState: model.pageStateGuestInfo,
callback: () {
model.pageStateGuestInfo = PageState.Loading;
model.notifyListeners();
_getGuestInfo();
},
emptyMsg: "暂时没有客户哦",
emptyImg: "empty_search",
showMsg: "加载中,请稍后...",
);
} else {
return Column(
children: [
Expanded(
child: SingleChildScrollView(
controller: controller,
child: Column(
children: [
Container(
width: double.infinity,
height: ScreenUtil().setWidth(20),
color: MyColours.color_ffffff,
),
_headerWidget(),
VEmptyView(20),
Container(
padding: EdgeInsets.symmetric(
horizontal: ScreenUtil().setWidth(40),
vertical: ScreenUtil().setWidth(20)),
decoration: BoxDecoration(
color: MyColours.color_199095,
borderRadius: BorderRadius.only(
topRight:
Radius.circular(ScreenUtil().setWidth(20)),
topLeft:
Radius.circular(ScreenUtil().setWidth(20)))),
child: Row(
children: [
Text(
'最近一次:',
style: TextStyle(
fontSize: ScreenUtil().setSp(26),
color: MyColours.color_333333),
),
Text(
'3天后 ',
Expanded(
child: Text(
'已创建 ${customerProvider.guestInfoSunModel.count.createTime} 天 | 累计 ${customerProvider.guestInfoSunModel.count.leiji} 单 | 取消 ${customerProvider.guestInfoSunModel.count.quxiao} 单',
overflow: TextOverflow.ellipsis,
style: TextStyle(
fontSize: ScreenUtil().setSp(26),
color: Color.fromRGBO(193, 194, 63, 1)),
),
Text(
'午餐',
style: TextStyle(
fontSize: ScreenUtil().setSp(26),
color: MyColours.color_199095),
),
Text(
' 桌位:',
style: TextStyle(
fontSize: ScreenUtil().setSp(26),
color: MyColours.color_333333),
),
Text(
'vip5',
style: TextStyle(
fontSize: ScreenUtil().setSp(26),
color: MyColours.color_199095),
),
Text(
' 人数:',
style: TextStyle(
fontSize: ScreenUtil().setSp(26),
color: MyColours.color_333333),
),
Text(
'未记录',
style: TextStyle(
fontSize: ScreenUtil().setSp(26),
color: MyColours.color_199095),
),
Text(
' 消费:',
style: TextStyle(
fontSize: ScreenUtil().setSp(26),
color: MyColours.color_333333),
),
Text(
'未记录',
style: TextStyle(
fontSize: ScreenUtil().setSp(26),
color: MyColours.color_199095),
)
color: MyColours.color_ffffff,
fontSize: ScreenUtil().setSp(30)),
)),
InkWell(
onTap: () {
NavigatorUtil.goCustomerOrderPage(context);
},
child: Text('更多',
style: TextStyle(
decoration: TextDecoration.underline,
color: MyColours.color_ffffff,
fontSize: ScreenUtil().setSp(26)))),
],
),
Row(
mainAxisAlignment: MainAxisAlignment.center,
),
Container(
color: MyColours.color_ffffff,
padding: EdgeInsets.symmetric(
horizontal: ScreenUtil().setWidth(20),
vertical: ScreenUtil().setWidth(20)),
child: Column(
children: [
Text(
'客户经理:',
style: TextStyle(
fontSize: ScreenUtil().setSp(26),
color: MyColours.color_333333),
Wrap(
children: [
Text(
'最近一次:',
style: TextStyle(
fontSize: ScreenUtil().setSp(24),
color: MyColours.color_333333),
),
Text(
Utils.formatFromMill(customerProvider
.guestInfoSunModel.last.ddate),
overflow: TextOverflow.ellipsis,
style: TextStyle(
fontSize: ScreenUtil().setSp(24),
color: Color.fromRGBO(208, 31, 37, 1)),
),
Text(
customerProvider
.guestInfoSunModel.last.ddateSoltStr,
style: TextStyle(
fontSize: ScreenUtil().setSp(24),
color: MyColours.color_199095),
),
Text(
' 桌位:',
style: TextStyle(
fontSize: ScreenUtil().setSp(24),
color: MyColours.color_333333),
),
Text(
customerProvider
.guestInfoSunModel.last.tableinfoName,
style: TextStyle(
fontSize: ScreenUtil().setSp(24),
color: MyColours.color_199095),
),
Text(
' 人数:',
style: TextStyle(
fontSize: ScreenUtil().setSp(24),
color: MyColours.color_333333),
),
Text(
customerProvider
.guestInfoSunModel.last.actualPum ==
null
? '未记录'
: customerProvider
.guestInfoSunModel.last.actualPum,
style: TextStyle(
fontSize: ScreenUtil().setSp(24),
color: MyColours.color_199095),
),
Text(
' 消费:',
style: TextStyle(
fontSize: ScreenUtil().setSp(24),
color: MyColours.color_333333),
),
Text(
customerProvider
.guestInfoSunModel.last.conAmount ==
null
? '未记录'
: customerProvider
.guestInfoSunModel.last.conAmount,
style: TextStyle(
fontSize: ScreenUtil().setSp(24),
color: MyColours.color_199095),
)
],
),
Text(
'xxx 18799999999',
style: TextStyle(
fontSize: ScreenUtil().setSp(26),
color: MyColours.color_199095),
VEmptyView(6),
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(
'客户经理:',
style: TextStyle(
fontSize: ScreenUtil().setSp(24),
color: MyColours.color_333333),
),
Text(
'${customerProvider.guestInfoSunModel.last.sellerUserNickName} ${customerProvider.guestInfoSunModel.last.sellerUserPhone}',
style: TextStyle(
fontSize: ScreenUtil().setSp(24),
color: MyColours.color_199095),
)
],
)
],
)
],
),
),
VEmptyView(20),
_lineItemWidget('工作单位', '政府部门 办公室主任'),
VEmptyView(20),
_lineItemWidget('忌口', '葱姜蒜'),
VEmptyView(20),
_lineItemWidget('喜好', '酸甜苦辣'),
VEmptyView(20),
_lineItemWidget('服务', '湿巾、茶水'),
VEmptyView(20),
Container(
padding: EdgeInsets.symmetric(
horizontal: ScreenUtil().setWidth(40),
vertical: ScreenUtil().setWidth(30)),
color: MyColours.color_ffffff,
child: Column(children: [
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
'纪念日',
style: TextStyle(
fontSize: ScreenUtil().setSp(36),
color: MyColours.color_333333),
),
),
VEmptyView(20),
_lineItemWidget('工作单位',
'${customerProvider.guestInfoSunModel.guest.company == null ? '' : customerProvider.guestInfoSunModel.guest.company} ${customerProvider.guestInfoSunModel.guest.section == null ? '' : customerProvider.guestInfoSunModel.guest.section} ${customerProvider.guestInfoSunModel.guest.position == null ? '' : customerProvider.guestInfoSunModel.guest.position}'),
VEmptyView(20),
_lineItemWidget('忌口',
'${customerProvider.guestInfoSunModel.guest.taboos == null ? '' : customerProvider.guestInfoSunModel.guest.taboos}'),
VEmptyView(20),
_lineItemWidget('喜好',
'${customerProvider.guestInfoSunModel.guest.like == null ? '' : customerProvider.guestInfoSunModel.guest.like}'),
VEmptyView(20),
_lineItemWidget('服务',
'${customerProvider.guestInfoSunModel.guest.serve == null ? '' : customerProvider.guestInfoSunModel.guest.serve}'),
VEmptyView(20),
Container(
padding: EdgeInsets.symmetric(
horizontal: ScreenUtil().setWidth(40),
vertical: ScreenUtil().setWidth(30)),
color: MyColours.color_ffffff,
child: Column(children: [
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
'纪念日',
style: TextStyle(
fontSize: ScreenUtil().setSp(36),
color: MyColours.color_333333),
),
RoundButton(
text: '编辑',
radius: ScreenUtil().setWidth(20),
width: ScreenUtil().setWidth(90),
height: ScreenUtil().setWidth(50),
fontSize: 26,
isBold: false,
onPressed: () {
NavigatorUtil.goFestivalEditPage(context);
},
),
],
),
RoundButton(
text: '编辑',
radius: ScreenUtil().setWidth(20),
width: ScreenUtil().setWidth(90),
height: ScreenUtil().setWidth(50),
fontSize: 26,
isBold: false,
onPressed: () {
NavigatorUtil.goFestivalEditPage(context);
ListView.builder(
shrinkWrap: true,
itemCount:
customerProvider.guestInfoSunModel.guest.cDay !=
null
? customerProvider
.guestInfoSunModel.guest.cDay.length
: 0,
controller: controller,
itemBuilder: (BuildContext context, int index) {
return Center(
child: Padding(
padding: EdgeInsets.symmetric(
vertical: ScreenUtil().setWidth(10)),
child: Text(
'本人生日:12月18日(公历)',
style: TextStyle(
fontSize: ScreenUtil().setSp(26),
color: MyColours.color_333333),
),
));
},
),
],
),
ListView.builder(
shrinkWrap: true,
itemCount: 10,
controller: controller,
itemBuilder: (BuildContext context, int index) {
return Center(
child: Padding(
padding: EdgeInsets.symmetric(
vertical: ScreenUtil().setWidth(10)),
child: Text(
'本人生日:12月18日(公历)',
style: TextStyle(
fontSize: ScreenUtil().setSp(26),
color: MyColours.color_333333),
),
));
},
)
])),
VEmptyView(20),
Container(
padding: EdgeInsets.symmetric(
horizontal: ScreenUtil().setWidth(40),
vertical: ScreenUtil().setWidth(30)),
color: MyColours.color_ffffff,
child: Column(
children: [
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
)
])),
VEmptyView(20),
Container(
padding: EdgeInsets.symmetric(
horizontal: ScreenUtil().setWidth(40),
vertical: ScreenUtil().setWidth(30)),
color: MyColours.color_ffffff,
child: Column(
children: [
Text(
'营销记录',
style: TextStyle(
fontSize: ScreenUtil().setSp(36),
color: MyColours.color_333333),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
'营销记录',
style: TextStyle(
fontSize: ScreenUtil().setSp(36),
color: MyColours.color_333333),
),
Text(
'共 ${customerProvider.guestInfoSunModel.marketing?.length} 个',
style: TextStyle(
fontSize: ScreenUtil().setSp(26),
color: MyColours.color_199095),
)
],
),
Text(
'共 1 个',
style: TextStyle(
fontSize: ScreenUtil().setSp(26),
color: MyColours.color_199095),
ListView.builder(
shrinkWrap: true,
itemCount: customerProvider
.guestInfoSunModel.marketing?.length,
controller: controller,
itemBuilder: (BuildContext context, int index) {
Marketing marketing = customerProvider
.guestInfoSunModel.marketing[index];
return Center(
child: Padding(
padding: EdgeInsets.symmetric(
vertical: ScreenUtil().setWidth(10)),
child: Text(
'${marketing.cdateStr} ${marketing.content}',
style: TextStyle(
fontSize: ScreenUtil().setSp(26),
color: MyColours.color_333333),
),
));
},
)
],
),
ListView.builder(
shrinkWrap: true,
itemCount: 10,
controller: controller,
itemBuilder: (BuildContext context, int index) {
return Center(
child: Padding(
padding: EdgeInsets.symmetric(
vertical: ScreenUtil().setWidth(10)),
child: Text(
'2021-12-12 短信营销 承诺优惠98折',
style: TextStyle(
fontSize: ScreenUtil().setSp(26),
color: MyColours.color_333333),
),
));
},
)
],
))
],
),
)),
RoundButton(
text: '创建预订',
radius: ScreenUtil().setWidth(10),
margin: EdgeInsets.symmetric(horizontal: ScreenUtil().setWidth(90)),
height: ScreenUtil().setWidth(80),
fontSize: 26,
isBold: false,
onPressed: () {},
),
VEmptyView(30)
],
),
))
],
),
)),
RoundButton(
text: '创建预订',
radius: ScreenUtil().setWidth(10),
margin:
EdgeInsets.symmetric(horizontal: ScreenUtil().setWidth(90)),
height: ScreenUtil().setWidth(80),
fontSize: 26,
isBold: false,
onPressed: () {},
),
VEmptyView(30)
],
);
}
}),
);
}
}
... ...
... ... @@ -1010,7 +1010,9 @@ class _CustomerListPageState extends State<CustomerListPage>
resizeToAvoidBottomInset: false,
backgroundColor: MyColours.color_ffffff,
appBar: SystemAppBar(
'全店客户',
widget.fromPage == FromPage.FromPageMyCustomer
? '我的客户'
: '全店客户',
onTap: () {
Navigator.of(context).pop();
},
... ...
... ... @@ -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/customer_list_model.dart';
import 'package:one_key/models/guest_info_model.dart';
import 'package:one_key/models/guest_manage_model.dart';
import 'package:one_key/models/user_history_entity.dart';
import 'package:one_key/net/base_resp.dart';
... ... @@ -30,6 +31,8 @@ class CustomerProvider extends ChangeNotifier {
PageState pageStateChenshui = PageState.Loading;
PageState pageStateLiushi = PageState.Loading;
GuestManageSunModel guestSunmodel;
PageState pageStateGuestInfo = PageState.Loading;
GuestInfoSunModel guestInfoSunModel;
//用来获取客户列表
getCustomerList(BuildContext context, Map<String, String> params) async {
... ... @@ -120,6 +123,41 @@ class CustomerProvider extends ChangeNotifier {
}
}
// 获取客户详情
getGuestInfo(BuildContext context, Map<String, String> params) async {
BaseResp<dynamic> baseResp = await DioUtil()
.request<dynamic>(context, Method.get, HttpUrl.get_guest_info,
data: params, showLoading: false)
.catchError((error) {
print(error.toString());
if (error is MyError) {
switch (error.type) {
case 1:
pageStateGuestInfo = PageState.ConnectivityError;
break;
case 2:
pageStateGuestInfo = PageState.ConnectivityTimeOut;
break;
default:
pageStateGuestInfo = PageState.ConnectivityError;
break;
}
}
notifyListeners();
});
if (baseResp != null && baseResp.code == Constant.status_success) {
pageStateGuestInfo = PageState.Success;
guestInfoSunModel = GuestInfoModel.fromJson(baseResp.responseData).data;
notifyListeners();
} else {
if (baseResp != null) {
Utils.showToast(baseResp.msg ?? "");
}
pageStateGuestInfo = PageState.ConnectivityTimeOut;
}
notifyListeners();
}
// //获取历史录入
// getUserHistorys(BuildContext context, Map<String, String> params) async {
// BaseResp<List> baseResp = await DioUtil()
... ...
... ... @@ -574,11 +574,12 @@ class NavigatorUtil {
/// 客户详情
static Future<dynamic> goCustomerDetailPage(
BuildContext context,
CustomerListSunModel userHistoryEntity, {
CustomerListSunModel userHistoryEntity,
FromPage fromPage, {
replace = false,
}) {
return _navigateTo(context,
"${Routes.customer_detail_page}?userHistoryEntity=${FluroConvertUtils.object2string(userHistoryEntity)}",
"${Routes.customer_detail_page}?userHistoryEntity=${FluroConvertUtils.object2string(userHistoryEntity)}&fromPage=${FluroConvertUtils.enumToString(fromPage)}",
replace: replace);
}
... ...
... ... @@ -902,10 +902,14 @@ var customerDetailPageHandle = new Handler(
CustomerListSunModel userHistoryEntity = CustomerListSunModel.fromJson(
json.decode(FluroConvertUtils.fluroCnParamsDecode(
params["userHistoryEntity"].first)));
FromPage fromPage = FluroConvertUtils.enumFromString<FromPage>(
FromPage.values, params["fromPage"].first);
print(fromPage);
return ChangeNotifierProvider<CustomerProvider>(
create: (_) => CustomerProvider(),
child: CustomerDetailPage(
userHistoryEntity: userHistoryEntity,
fromPage: fromPage,
));
});
... ...
... ... @@ -33,7 +33,68 @@ class Utils {
//
//时间转换
static String format(String datestr) {
static String formatFromMill(String datestr) {
String date = '';
DateTime _strtimes = DateTime.fromMillisecondsSinceEpoch(
int.parse(datestr) *
1000); //首先先将字符串格式的时间转为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 String formatFromYmd(String datestr) {
String date = '';
String _str =
datestr.replaceAll('年', '-').replaceAll('月', '-').replaceAll('日', '');
... ...