Commit b3ddaaa14066cfebdcd9290ed7cde8c5d9a6cc31

Authored by wdn127929
1 parent ff3170bd

我的客户接口percent%

import 'package:json_annotation/json_annotation.dart';
import 'package:json_annotation/json_annotation.dart';
import 'package:json_annotation/json_annotation.dart';
import 'package:json_annotation/json_annotation.dart';
part 'guest_manage_model.g.dart';
@JsonSerializable()
class GuestManageModel extends Object {
class GuestManageModel extends Object {
@JsonKey(name: 'ret')
int ret;
... ... @@ -18,18 +15,20 @@ part 'guest_manage_model.g.dart';
@JsonKey(name: 'msg')
String msg;
GuestManageModel(this.ret,this.data,this.msg,);
GuestManageModel(
this.ret,
this.data,
this.msg,
);
factory GuestManageModel.fromJson(Map<String, dynamic> srcJson) => _$GuestManageModelFromJson(srcJson);
factory GuestManageModel.fromJson(Map<String, dynamic> srcJson) =>
_$GuestManageModelFromJson(srcJson);
Map<String, dynamic> toJson() => _$GuestManageModelToJson(this);
}
@JsonSerializable()
class GuestManageSunModel extends Object {
class GuestManageSunModel extends Object {
@JsonKey(name: 'myCustomer')
int myCustomer;
... ... @@ -45,72 +44,79 @@ part 'guest_manage_model.g.dart';
@JsonKey(name: 'Tips')
Tips tips;
GuestManageSunModel(this.myCustomer,this.active,this.sleep,this.drain,this.tips,);
GuestManageSunModel(
this.myCustomer,
this.active,
this.sleep,
this.drain,
this.tips,
);
factory GuestManageSunModel.fromJson(Map<String, dynamic> srcJson) => _$GuestManageSunModelFromJson(srcJson);
factory GuestManageSunModel.fromJson(Map<String, dynamic> srcJson) =>
_$GuestManageSunModelFromJson(srcJson);
Map<String, dynamic> toJson() => _$GuestManageSunModelToJson(this);
}
@JsonSerializable()
class Active extends Object {
class Active extends Object {
@JsonKey(name: 'count')
int count;
@JsonKey(name: 'scale')
String scale;
dynamic scale;
Active(this.count,this.scale,);
Active(
this.count,
this.scale,
);
factory Active.fromJson(Map<String, dynamic> srcJson) => _$ActiveFromJson(srcJson);
factory Active.fromJson(Map<String, dynamic> srcJson) =>
_$ActiveFromJson(srcJson);
Map<String, dynamic> toJson() => _$ActiveToJson(this);
}
@JsonSerializable()
class Sleep extends Object {
class Sleep extends Object {
@JsonKey(name: 'count')
int count;
@JsonKey(name: 'scale')
String scale;
dynamic scale;
Sleep(this.count,this.scale,);
Sleep(
this.count,
this.scale,
);
factory Sleep.fromJson(Map<String, dynamic> srcJson) => _$SleepFromJson(srcJson);
factory Sleep.fromJson(Map<String, dynamic> srcJson) =>
_$SleepFromJson(srcJson);
Map<String, dynamic> toJson() => _$SleepToJson(this);
}
@JsonSerializable()
class Drain extends Object {
class Drain extends Object {
@JsonKey(name: 'count')
int count;
@JsonKey(name: 'scale')
String scale;
dynamic scale;
Drain(this.count,this.scale,);
Drain(
this.count,
this.scale,
);
factory Drain.fromJson(Map<String, dynamic> srcJson) => _$DrainFromJson(srcJson);
factory Drain.fromJson(Map<String, dynamic> srcJson) =>
_$DrainFromJson(srcJson);
Map<String, dynamic> toJson() => _$DrainToJson(this);
}
@JsonSerializable()
class Tips extends Object {
class Tips extends Object {
@JsonKey(name: 'task')
List<List<String>> task;
... ... @@ -120,12 +126,14 @@ part 'guest_manage_model.g.dart';
@JsonKey(name: 'awaken')
List<String> awaken;
Tips(this.task,this.recover,this.awaken,);
Tips(
this.task,
this.recover,
this.awaken,
);
factory Tips.fromJson(Map<String, dynamic> srcJson) => _$TipsFromJson(srcJson);
factory Tips.fromJson(Map<String, dynamic> srcJson) =>
_$TipsFromJson(srcJson);
Map<String, dynamic> toJson() => _$TipsToJson(this);
}
... ...
... ... @@ -54,7 +54,7 @@ Map<String, dynamic> _$GuestManageSunModelToJson(
Active _$ActiveFromJson(Map<String, dynamic> json) {
return Active(
json['count'] as int,
json['scale'] as String,
json['scale'] as dynamic,
);
}
... ... @@ -66,7 +66,7 @@ Map<String, dynamic> _$ActiveToJson(Active instance) => <String, dynamic>{
Sleep _$SleepFromJson(Map<String, dynamic> json) {
return Sleep(
json['count'] as int,
json['scale'] as String,
json['scale'] as dynamic,
);
}
... ... @@ -78,7 +78,7 @@ Map<String, dynamic> _$SleepToJson(Sleep instance) => <String, dynamic>{
Drain _$DrainFromJson(Map<String, dynamic> json) {
return Drain(
json['count'] as int,
json['scale'] as String,
json['scale'] as dynamic,
);
}
... ...
... ... @@ -169,4 +169,7 @@ class HttpUrl {
static const String update_password =
"?service=App.Seller.UpdatePassword"; // 员工密码修改
static const String guest_manage =
"?service=App.GuestManage.GuestManage"; //我的客户首页
}
... ...
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/screenutil.dart';
import 'package:one_key/constant/state.dart';
import 'package:one_key/models/guest_manage_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/event_bus.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 MyCustomerPage extends StatefulWidget {
MyCustomerPage({Key key}) : super(key: key);
... ... @@ -18,12 +23,30 @@ class MyCustomerPage extends StatefulWidget {
class _MyCustomerPageState extends State<MyCustomerPage> {
ScrollController _controller = ScrollController();
CustomerProvider customerProvider;
@override
void initState() {
super.initState();
WidgetsBinding.instance.addPostFrameCallback((_) {
_getGuestManageData();
});
}
///我的客户首页
_getGuestManageData() async {
GuestManageSunModel model =
await customerProvider.getGuestManageData(context);
// setState(() {});
}
///活跃客户、沉睡客户、流失客户
Widget _percentWidget(String pnum, String btnTitle, String percent) {
return Container(
color: MyColours.color_ffffff,
// height: ScreenUtil().setWidth(230),
width: (ScreenUtil.screenWidthDp - ScreenUtil().setWidth(20)) / 3,
height: (ScreenUtil.screenWidthDp - ScreenUtil().setWidth(20)) / 3,
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
... ... @@ -71,169 +94,348 @@ class _MyCustomerPageState extends State<MyCustomerPage> {
@override
Widget build(BuildContext context) {
customerProvider = Provider.of<CustomerProvider>(context, listen: false);
return Scaffold(
backgroundColor: Color.fromRGBO(246, 248, 250, 1),
appBar: SystemAppBar('我的客情', onTap: () {
EventBus().emit('changeStatusColor');
Navigator.pop(context);
}),
body: WillPopScope(
onWillPop: () async {
EventBus().emit('changeStatusColor');
return true;
},
child: Column(children: [
Expanded(
child: SingleChildScrollView(
controller: _controller,
child: Column(
children: [
Container(
color: MyColours.color_ffffff,
padding: EdgeInsets.symmetric(
vertical: ScreenUtil().setWidth(30)),
child: Column(
backgroundColor: Color.fromRGBO(246, 248, 250, 1),
appBar: SystemAppBar('我的客情', onTap: () {
EventBus().emit('changeStatusColor');
Navigator.pop(context);
}),
body: WillPopScope(onWillPop: () async {
EventBus().emit('changeStatusColor');
return true;
}, child: Consumer<CustomerProvider>(builder: (context, model, _) {
if (model.pageStateMyHome != PageState.Success) {
return ExceptionPage(
pageState: model.pageStateMyHome,
callback: () {
// getTableList();
},
emptyMsg: "暂时没有桌位哦",
emptyImg: "empty_search",
showMsg: "加载中,请稍后...",
);
} else {
return Column(children: [
Expanded(
child: SingleChildScrollView(
controller: _controller,
child: Column(
children: [
Container(
color: MyColours.color_ffffff,
padding: EdgeInsets.symmetric(
vertical: ScreenUtil().setWidth(30)),
child: Column(
children: [
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(
'${customerProvider.guestSunmodel.myCustomer}',
style: TextStyle(
color: MyColours.color_199095,
fontSize: ScreenUtil().setSp(60),
fontWeight: FontWeight.bold),
),
Text(
'位',
style: TextStyle(
color: MyColours.color_199095,
fontWeight: FontWeight.bold,
fontSize: ScreenUtil().setSp(30)),
)
],
),
VEmptyView(10),
RoundButton(
onPressed: () async {
NavigatorUtil.goCustomerListPage(context);
},
text: '我的客户',
fontSize: 24,
isBold: false,
textColor: MyColours.color_333333,
gradientStart: MyColours.color_ffffff,
gradientEnd: MyColours.color_ffffff,
borderColor: Color.fromRGBO(118, 118, 118, 1),
height: ScreenUtil().setWidth(45),
width: ScreenUtil().setWidth(160),
radius: ScreenUtil().setWidth(30),
)
],
),
),
VEmptyView(10),
// GridView.builder(
// controller: _controller,
// shrinkWrap: true,
// cacheExtent: ScreenUtil().setWidth(0),
// itemCount: 3,
// gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
// crossAxisCount: 3,
// childAspectRatio: 1,
// mainAxisSpacing: ScreenUtil().setWidth(10),
// crossAxisSpacing: ScreenUtil().setWidth(10)),
// itemBuilder: (BuildContext context, int index) {
// // locationState = state;
// return _percentWidget(
// '${customerProvider.guestSunmodel.active.count}',
// '活跃客户',
// '${customerProvider.guestSunmodel.active.scale}');
// }),
Row(
children: [
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(
'19',
style: TextStyle(
color: MyColours.color_199095,
fontSize: ScreenUtil().setSp(60),
fontWeight: FontWeight.bold),
),
Text(
'位',
style: TextStyle(
color: MyColours.color_199095,
fontWeight: FontWeight.bold,
fontSize: ScreenUtil().setSp(30)),
)
],
),
VEmptyView(10),
RoundButton(
onPressed: () async {
NavigatorUtil.goCustomerListPage(context);
},
text: '我的客户',
fontSize: 24,
isBold: false,
textColor: MyColours.color_333333,
gradientStart: MyColours.color_ffffff,
gradientEnd: MyColours.color_ffffff,
borderColor: Color.fromRGBO(118, 118, 118, 1),
height: ScreenUtil().setWidth(45),
width: ScreenUtil().setWidth(160),
radius: ScreenUtil().setWidth(30),
)
_percentWidget(
'${customerProvider.guestSunmodel.active.count}',
'活跃客户',
'${customerProvider.guestSunmodel.active.scale}'),
HEmptyView(10),
_percentWidget(
'${customerProvider.guestSunmodel.sleep.count}',
'沉睡客户',
'${customerProvider.guestSunmodel.sleep.scale}'),
HEmptyView(10),
_percentWidget(
'${customerProvider.guestSunmodel.drain.count}',
'流失客户',
'${customerProvider.guestSunmodel.drain.scale}'),
],
),
),
VEmptyView(10),
GridView.builder(
controller: _controller,
shrinkWrap: true,
cacheExtent: ScreenUtil().setWidth(0),
itemCount: 3,
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 3,
childAspectRatio: 1,
mainAxisSpacing: ScreenUtil().setWidth(10),
crossAxisSpacing: ScreenUtil().setWidth(10)),
itemBuilder: (BuildContext context, int index) {
// locationState = state;
return _percentWidget('1999', '活跃客户', '39.20');
}),
// Row(
// children: [
// _percentWidget('19992', '活跃客户', '90.90'),
// HEmptyView(10),
// _percentWidget('19992', '沉睡客户', '90.90'),
// HEmptyView(10),
// _percentWidget('19992', '流失客户', '5.90'),
// ],
// ),
ListView.builder(
controller: _controller,
shrinkWrap: true,
cacheExtent: ScreenUtil().setWidth(0),
itemCount:
customerProvider.guestSunmodel.tips.task.length,
itemBuilder: (BuildContext context, int index) {
// locationState = state;
List<String> data =
customerProvider.guestSunmodel.tips.task[index];
return Column(
children: [
VEmptyView(10),
Stack(children: [
Container(
color: MyColours.color_ffffff,
padding: EdgeInsets.symmetric(
horizontal: ScreenUtil().setWidth(20),
vertical: ScreenUtil().setWidth(30)),
child: Row(
children: [
Image.asset(
Utils.getImgPath('warning'),
width: ScreenUtil().setWidth(42),
),
HEmptyView(15),
Expanded(
child: Column(
crossAxisAlignment:
CrossAxisAlignment.start,
children: [
Text(
'${data[0]}',
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: TextStyle(
color: MyColours.color_333333,
fontSize:
ScreenUtil().setSp(32)),
),
VEmptyView(8),
Text(
'${data[1]}',
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: TextStyle(
color: MyColours.color_333333,
fontSize:
ScreenUtil().setSp(24)),
),
VEmptyView(8),
Text(
'${data[2]}',
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: TextStyle(
color: MyColours.color_333333,
fontSize:
ScreenUtil().setSp(26)),
)
],
)),
HEmptyView(20),
RoundButton(
text: '立即完成',
ListView.builder(
controller: _controller,
shrinkWrap: true,
cacheExtent: ScreenUtil().setWidth(0),
itemCount: 20,
itemBuilder: (BuildContext context, int index) {
// locationState = state;
return Column(
children: [
VEmptyView(10),
Container(
color: MyColours.color_ffffff,
padding: EdgeInsets.symmetric(
horizontal: ScreenUtil().setWidth(20),
vertical: ScreenUtil().setWidth(30)),
child: Row(
children: [
Image.asset(
Utils.getImgPath('warning'),
width: ScreenUtil().setWidth(34),
padding: EdgeInsets.symmetric(
horizontal:
ScreenUtil().setWidth(26)),
gradientStart: MyColours.color_199095,
gradientEnd: MyColours.color_199095,
// borderColor: MyColours.color_999999,
radius: ScreenUtil().setWidth(40),
height: ScreenUtil().setWidth(64),
fontSize: 26,
isBold: false,
onPressed: () {
// NavigatorUtil.goEnterStoreEnvironmentPage(context);
},
),
],
),
HEmptyView(10),
Expanded(
child: Text(
'2为顾客马上快递费哈健身房哈尽快发货阿花房间卡都会发觉客服哈空间发哈尽快发货卡上的房间卡上发哈尽快',
maxLines: 10,
overflow: TextOverflow.ellipsis,
style: TextStyle(
color: MyColours.color_333333,
fontSize: ScreenUtil().setSp(28)),
)),
HEmptyView(30),
RoundButton(
text: '立即完成',
),
Positioned(
bottom: ScreenUtil().setWidth(24),
right: ScreenUtil().setWidth(70),
child: Text(
'${data[3]}',
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: TextStyle(
color: Color.fromRGBO(215, 30, 40, 1),
fontSize: ScreenUtil().setSp(26)),
))
])
],
);
}),
ListView.builder(
controller: _controller,
shrinkWrap: true,
cacheExtent: ScreenUtil().setWidth(0),
itemCount:
customerProvider.guestSunmodel.tips.recover.length,
itemBuilder: (BuildContext context, int index) {
// locationState = state;
padding: EdgeInsets.symmetric(
horizontal: ScreenUtil().setWidth(26)),
gradientStart: MyColours.color_199095,
gradientEnd: MyColours.color_199095,
// borderColor: MyColours.color_999999,
radius: ScreenUtil().setWidth(40),
height: ScreenUtil().setWidth(64),
fontSize: 26,
isBold: false,
onPressed: () {
// NavigatorUtil.goEnterStoreEnvironmentPage(context);
},
),
],
return Column(
children: [
VEmptyView(10),
Container(
color: MyColours.color_ffffff,
padding: EdgeInsets.symmetric(
horizontal: ScreenUtil().setWidth(20),
vertical: ScreenUtil().setWidth(30)),
child: Row(
children: [
Image.asset(
Utils.getImgPath('warning'),
width: ScreenUtil().setWidth(42),
),
HEmptyView(15),
Expanded(
child: Text(
'${customerProvider.guestSunmodel.tips.recover[index]}',
maxLines: 10,
overflow: TextOverflow.ellipsis,
style: TextStyle(
color: MyColours.color_333333,
fontSize: ScreenUtil().setSp(32)),
)),
HEmptyView(20),
RoundButton(
text: '一键追回',
padding: EdgeInsets.symmetric(
horizontal:
ScreenUtil().setWidth(26)),
gradientStart: MyColours.color_199095,
gradientEnd: MyColours.color_199095,
// borderColor: MyColours.color_999999,
radius: ScreenUtil().setWidth(40),
height: ScreenUtil().setWidth(64),
fontSize: 26,
isBold: false,
onPressed: () {
// NavigatorUtil.goEnterStoreEnvironmentPage(context);
},
),
],
),
),
)
],
);
})
],
),
)),
Padding(
padding: EdgeInsets.only(bottom: ScreenUtil().setWidth(30)),
child: RoundButton(
onPressed: () {
NavigatorUtil.goMarketingRecordsPage(context);
},
text: '营销记录',
fontSize: 24,
isBold: false,
textColor: MyColours.color_199095,
gradientStart: MyColours.color_ffffff,
gradientEnd: MyColours.color_ffffff,
borderColor: MyColours.color_199095,
height: ScreenUtil().setWidth(75),
width: ScreenUtil().setWidth(260),
radius: ScreenUtil().setWidth(10),
// image: Utils.getImgPath('add_area')
),
)
])),
);
],
);
}),
ListView.builder(
controller: _controller,
shrinkWrap: true,
cacheExtent: ScreenUtil().setWidth(0),
itemCount:
customerProvider.guestSunmodel.tips.recover.length,
itemBuilder: (BuildContext context, int index) {
// locationState = state;
return Column(
children: [
VEmptyView(10),
Container(
color: MyColours.color_ffffff,
padding: EdgeInsets.symmetric(
horizontal: ScreenUtil().setWidth(20),
vertical: ScreenUtil().setWidth(30)),
child: Row(
children: [
Image.asset(
Utils.getImgPath('warning'),
width: ScreenUtil().setWidth(42),
),
HEmptyView(15),
Expanded(
child: Text(
'${customerProvider.guestSunmodel.tips.awaken[index]}',
maxLines: 10,
overflow: TextOverflow.ellipsis,
style: TextStyle(
color: MyColours.color_333333,
fontSize: ScreenUtil().setSp(32)),
)),
HEmptyView(20),
RoundButton(
text: '一键唤醒',
padding: EdgeInsets.symmetric(
horizontal:
ScreenUtil().setWidth(26)),
gradientStart: MyColours.color_199095,
gradientEnd: MyColours.color_199095,
// borderColor: MyColours.color_999999,
radius: ScreenUtil().setWidth(40),
height: ScreenUtil().setWidth(64),
fontSize: 26,
isBold: false,
onPressed: () {
// NavigatorUtil.goEnterStoreEnvironmentPage(context);
},
),
],
),
),
],
);
})
],
),
)),
Padding(
padding: EdgeInsets.only(bottom: ScreenUtil().setWidth(30)),
child: RoundButton(
onPressed: () {
NavigatorUtil.goMarketingRecordsPage(context);
},
text: '营销记录',
fontSize: 24,
isBold: false,
textColor: MyColours.color_199095,
gradientStart: MyColours.color_ffffff,
gradientEnd: MyColours.color_ffffff,
borderColor: MyColours.color_199095,
height: ScreenUtil().setWidth(75),
width: ScreenUtil().setWidth(260),
radius: ScreenUtil().setWidth(10),
// image: Utils.getImgPath('add_area')
),
)
]);
}
})));
}
}
... ...
... ... @@ -4,11 +4,15 @@ 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/guest_manage_model.dart';
import 'package:one_key/models/user_history_entity.dart';
import 'package:one_key/net/base_resp.dart';
import 'package:one_key/net/dio_util.dart';
import 'package:one_key/net/http_url.dart';
import 'package:one_key/provider/user_model.dart';
import 'package:one_key/utils/utils.dart';
import 'package:one_key/widgets/loading.dart';
import 'package:provider/provider.dart';
class CustomerProvider extends ChangeNotifier {
PageState pageState = PageState.Loading;
... ... @@ -16,6 +20,9 @@ class CustomerProvider extends ChangeNotifier {
List<UserHistoryEntity> userHistorysShow = []; //历史录入展示
TextEditingController controller = TextEditingController(); //搜索框
PageState pageStateMyHome = PageState.Loading;
GuestManageSunModel guestSunmodel;
//获取历史录入
getUserHistorys(BuildContext context, Map<String, String> params) async {
BaseResp<List> baseResp = await DioUtil()
... ... @@ -157,4 +164,59 @@ class CustomerProvider extends ChangeNotifier {
notifyListeners();
}
}
///客户经理获取所创建活动列表
Future<GuestManageSunModel> getGuestManageData(BuildContext context,
{isShowLoading = true}) async {
if (isShowLoading) {
pageStateMyHome = PageState.Loading;
notifyListeners();
}
Map<String, String> params = {
'uid': Provider.of<UserModel>(context, listen: false).user.openid
};
BaseResp<dynamic> baseResp = await DioUtil()
.request<dynamic>(context, Method.get, HttpUrl.guest_manage,
data: params, showLoading: false)
.catchError((error) {
print(error.toString());
if (error is MyError) {
if (isShowLoading) {
switch (error.type) {
case 1:
pageStateMyHome = PageState.ConnectivityError;
break;
case 2:
pageStateMyHome = PageState.ConnectivityTimeOut;
break;
default:
pageStateMyHome = PageState.ConnectivityError;
break;
}
}
}
notifyListeners();
});
if (baseResp.code == Constant.status_success) {
if (baseResp.data.isEmpty) {
if (isShowLoading) {
pageStateMyHome = PageState.Empty;
}
} else {
if (isShowLoading) {
pageStateMyHome = PageState.Success;
}
}
guestSunmodel = GuestManageModel.fromJson(baseResp.responseData).data;
notifyListeners();
} else {
if (isShowLoading) {
pageStateMyHome = PageState.ConnectivityError;
}
if (baseResp != null) {
Utils.showToast(baseResp.msg ?? "");
}
}
return guestSunmodel;
}
}
... ...