Commit a19c84af78351e3225d562c6f44cc6e6a05fb6ac

Authored by wdn127929
1 parent 82390f26

创建营销部分、编辑客户部分

@@ -17,6 +17,7 @@ import 'package:one_key/pages/login/first_page.dart'; @@ -17,6 +17,7 @@ import 'package:one_key/pages/login/first_page.dart';
17 import 'package:one_key/provider/base_info_provider.dart'; 17 import 'package:one_key/provider/base_info_provider.dart';
18 import 'package:one_key/provider/coupon_provider.dart'; 18 import 'package:one_key/provider/coupon_provider.dart';
19 import 'package:one_key/provider/create_store_model.dart'; 19 import 'package:one_key/provider/create_store_model.dart';
  20 +import 'package:one_key/provider/customer_making_provider.dart';
20 import 'package:one_key/provider/message_dialog_model.dart'; 21 import 'package:one_key/provider/message_dialog_model.dart';
21 import 'package:intl/date_symbol_data_local.dart'; 22 import 'package:intl/date_symbol_data_local.dart';
22 import 'package:one_key/provider/message_model.dart'; 23 import 'package:one_key/provider/message_model.dart';
@@ -109,6 +110,9 @@ Future<void> main() async { @@ -109,6 +110,9 @@ Future<void> main() async {
109 ChangeNotifierProvider<RemarkManagerModel>( 110 ChangeNotifierProvider<RemarkManagerModel>(
110 create: (_) => RemarkManagerModel(), 111 create: (_) => RemarkManagerModel(),
111 ), 112 ),
  113 + ChangeNotifierProvider<CustomerMakingProvider>(
  114 + create: (_) => CustomerMakingProvider(),
  115 + ),
112 ], 116 ],
113 child: MyApp(), 117 child: MyApp(),
114 )); 118 ));
  1 +import 'package:common_utils/common_utils.dart';
  2 +import 'package:flutter/material.dart';
1 import 'package:json_annotation/json_annotation.dart'; 3 import 'package:json_annotation/json_annotation.dart';
2 import 'dart:convert' as convert; 4 import 'dart:convert' as convert;
3 import 'package:one_key/models/table_list.dart' as t; 5 import 'package:one_key/models/table_list.dart' as t;
@@ -113,6 +115,42 @@ class ListData extends Object { @@ -113,6 +115,42 @@ class ListData extends Object {
113 @JsonKey(name: 'phone') 115 @JsonKey(name: 'phone')
114 String phone; 116 String phone;
115 117
  118 + @JsonKey(name: 'status')
  119 + String status;
  120 +
  121 + String get statusStr {
  122 + switch (status) {
  123 + case "0":
  124 + return "待确认";
  125 + break;
  126 + case "1":
  127 + return "已定座";
  128 + break;
  129 + case "2":
  130 + return "已到店";
  131 + break;
  132 + case "3":
  133 + return "已完成";
  134 + break;
  135 + case "4":
  136 + return "已取消";
  137 + break;
  138 + case "5":
  139 + return "已安排";
  140 + break;
  141 + case "6":
  142 + return "已拒绝";
  143 + break;
  144 + }
  145 + return '';
  146 + }
  147 +
  148 + String get ddateStr {
  149 + DateTime dateTime =
  150 + DateTime.fromMillisecondsSinceEpoch(int.parse(ddate.toString()) * 1000);
  151 + return DateUtil.formatDate(dateTime, format: DateFormats.y_mo_d);
  152 + }
  153 +
116 String get ddateSoltStr { 154 String get ddateSoltStr {
117 switch (ddateSolt) { 155 switch (ddateSolt) {
118 case "1": 156 case "1":
@@ -129,6 +167,9 @@ class ListData extends Object { @@ -129,6 +167,9 @@ class ListData extends Object {
129 } 167 }
130 168
131 String get tableinfoName { 169 String get tableinfoName {
  170 + if (tableinfo == null) {
  171 + return '';
  172 + }
132 List<dynamic> tableinfoList = convert.jsonDecode(tableinfo); 173 List<dynamic> tableinfoList = convert.jsonDecode(tableinfo);
133 print(tableinfo); 174 print(tableinfo);
134 String _nameStr = ''; 175 String _nameStr = '';
@@ -152,6 +193,7 @@ class ListData extends Object { @@ -152,6 +193,7 @@ class ListData extends Object {
152 this.uid, 193 this.uid,
153 this.nickName, 194 this.nickName,
154 this.phone, 195 this.phone,
  196 + this.status,
155 ); 197 );
156 198
157 factory ListData.fromJson(Map<String, dynamic> srcJson) => 199 factory ListData.fromJson(Map<String, dynamic> srcJson) =>
@@ -75,6 +75,7 @@ ListData _$ListDataFromJson(Map<String, dynamic> json) { @@ -75,6 +75,7 @@ ListData _$ListDataFromJson(Map<String, dynamic> json) {
75 json['uid'] as String, 75 json['uid'] as String,
76 json['nick_name'] as String, 76 json['nick_name'] as String,
77 json['phone'] as String, 77 json['phone'] as String,
  78 + json['status'] as String,
78 ); 79 );
79 } 80 }
80 81
@@ -88,4 +89,5 @@ Map<String, dynamic> _$ListDataToJson(ListData instance) => <String, dynamic>{ @@ -88,4 +89,5 @@ Map<String, dynamic> _$ListDataToJson(ListData instance) => <String, dynamic>{
88 'uid': instance.uid, 89 'uid': instance.uid,
89 'nick_name': instance.nickName, 90 'nick_name': instance.nickName,
90 'phone': instance.phone, 91 'phone': instance.phone,
  92 + 'status': instance.status,
91 }; 93 };
@@ -176,5 +176,11 @@ class HttpUrl { @@ -176,5 +176,11 @@ class HttpUrl {
176 "?service=App.GuestManage.GetCustomerList"; //用来获取客户列表 176 "?service=App.GuestManage.GetCustomerList"; //用来获取客户列表
177 static const String get_guest_info = 177 static const String get_guest_info =
178 "?service=App.GuestManage.GetGuestInfo"; // 获取客户详情 178 "?service=App.GuestManage.GetGuestInfo"; // 获取客户详情
  179 + static const String get_guest_reserve =
  180 + "?service=App.GuestManage.GetGuestReserve"; // 客户订单统计
  181 + static const String create_marketing =
  182 + "?service=App.GuestManage.CreateMarketing"; // 创建营销
  183 + static const String set_guest_info =
  184 + "?service=App.GuestManage.SetGuestInfo"; // 修改客户信息
179 185
180 } 186 }
@@ -232,8 +232,14 @@ class _EditReserverPageState extends State<EditReserverPage> { @@ -232,8 +232,14 @@ class _EditReserverPageState extends State<EditReserverPage> {
232 ), 232 ),
233 onChanged: (value) { 233 onChanged: (value) {
234 print('ggg'); 234 print('ggg');
235 -  
236 - nameStr = value; 235 + if (value.endsWith('先生') ||
  236 + value.endsWith('女士') ||
  237 + value.endsWith('公司')) {
  238 + nameStr = value.substring(
  239 + 0, value.length - 2);
  240 + } else {
  241 + nameStr = value;
  242 + }
237 }, 243 },
238 onEditingComplete: () { 244 onEditingComplete: () {
239 print('fff'); 245 print('fff');
@@ -1528,7 +1528,14 @@ class _NoteBookChangeFPageState extends State<NoteBookChangeFPage> { @@ -1528,7 +1528,14 @@ class _NoteBookChangeFPageState extends State<NoteBookChangeFPage> {
1528 onChanged: (value) { 1528 onChanged: (value) {
1529 print('ggg'); 1529 print('ggg');
1530 1530
1531 - nameStr = value; 1531 + if (value.endsWith('先生') ||
  1532 + value.endsWith('女士') ||
  1533 + value.endsWith('公司')) {
  1534 + nameStr = value.substring(
  1535 + 0, value.length - 2);
  1536 + } else {
  1537 + nameStr = value;
  1538 + }
1532 }, 1539 },
1533 onEditingComplete: () { 1540 onEditingComplete: () {
1534 print('fff'); 1541 print('fff');
@@ -1854,8 +1854,16 @@ class NotebookDetailPageState extends State<NotebookDetailPage> { @@ -1854,8 +1854,16 @@ class NotebookDetailPageState extends State<NotebookDetailPage> {
1854 print( 1854 print(
1855 'ggg'); 1855 'ggg');
1856 1856
1857 - nameStr =  
1858 - value; 1857 + if (value.endsWith('先生') ||
  1858 + value.endsWith('女士') ||
  1859 + value.endsWith('公司')) {
  1860 + nameStr = value.substring(
  1861 + 0,
  1862 + value.length - 2);
  1863 + } else {
  1864 + nameStr =
  1865 + value;
  1866 + }
1859 }, 1867 },
1860 onEditingComplete: 1868 onEditingComplete:
1861 () { 1869 () {
@@ -1651,7 +1651,14 @@ class InvicationPageState extends State<InvicationPage> @@ -1651,7 +1651,14 @@ class InvicationPageState extends State<InvicationPage>
1651 onChanged: (value) { 1651 onChanged: (value) {
1652 print('ggg'); 1652 print('ggg');
1653 1653
1654 - nameStr = value; 1654 + if (value.endsWith('先生') ||
  1655 + value.endsWith('女士') ||
  1656 + value.endsWith('公司')) {
  1657 + nameStr = value.substring(
  1658 + 0, value.length - 2);
  1659 + } else {
  1660 + nameStr = value;
  1661 + }
1655 }, 1662 },
1656 onEditingComplete: () { 1663 onEditingComplete: () {
1657 print('fff'); 1664 print('fff');
@@ -88,7 +88,7 @@ class _ContactListPageState extends State<ContactListPage> { @@ -88,7 +88,7 @@ class _ContactListPageState extends State<ContactListPage> {
88 ); 88 );
89 } 89 }
90 90
91 - Widget _buildListItem(CustomerListSunModel model) { 91 + Widget _buildListItem(CustomerListSunModel model, int index) {
92 String susTag = model.getSuspensionTag(); 92 String susTag = model.getSuspensionTag();
93 93
94 return Column( 94 return Column(
@@ -111,63 +111,78 @@ class _ContactListPageState extends State<ContactListPage> { @@ -111,63 +111,78 @@ class _ContactListPageState extends State<ContactListPage> {
111 width: ScreenUtil().setWidth(2)))), 111 width: ScreenUtil().setWidth(2)))),
112 child: Row( 112 child: Row(
113 children: [ 113 children: [
114 - Stack(  
115 - alignment: Alignment.bottomCenter,  
116 - clipBehavior: Clip.none,  
117 - children: [  
118 - Stack(  
119 - alignment: Alignment.centerLeft,  
120 - clipBehavior: Clip.none,  
121 - children: [  
122 - CircleAvatar(  
123 - radius: ScreenUtil().setWidth(60),  
124 - backgroundColor: Color.fromRGBO(239, 239, 239, 1),  
125 - child: Text(  
126 - model.rnameStr != ''  
127 - ? model.rnameStr.substring(0, 1)  
128 - : '',  
129 - style: TextStyle(  
130 - color: Color.fromRGBO(206, 206, 206, 1),  
131 - fontSize: ScreenUtil().setSp(42)),  
132 - ),  
133 - ),  
134 - Positioned(  
135 - left: ScreenUtil().setWidth(-18),  
136 - child: Image.asset(  
137 - Utils.getImgPath('select'),  
138 - width: ScreenUtil().setWidth(36),  
139 - ))  
140 - ]),  
141 - Positioned(  
142 - bottom: ScreenUtil().setWidth(-20),  
143 - child: Container(  
144 - padding: EdgeInsets.symmetric(  
145 - horizontal: ScreenUtil().setWidth(10),  
146 - vertical: ScreenUtil().setWidth(2),  
147 - ),  
148 - decoration: BoxDecoration(  
149 - color: model.attr != null && model.attr != ''  
150 - ? model.attr == '沉睡'  
151 - ? Color.fromRGBO(223, 33, 81, 1)  
152 - : model.attr == '活跃'  
153 - ? Color.fromRGBO(81, 170, 94, 1)  
154 - : model.attr == '流失'  
155 - ? Color.fromRGBO(109, 101, 248, 1)  
156 - : Color.fromRGBO(239, 143, 49, 1)  
157 - : Colors.transparent,  
158 - borderRadius: BorderRadius.circular(  
159 - ScreenUtil().setWidth(10), 114 + InkWell(
  115 + onTap: () {
  116 + List<CustomerListSunModel> data =
  117 + widget.provider.returnNowList();
  118 + data[index].select = !data[index].select;
  119 + if (data[index].select) {
  120 + widget.provider.addData(index);
  121 + } else {
  122 + widget.provider.cancelData(index);
  123 + }
  124 + widget.provider.getCheckValue();
  125 + },
  126 + child: Stack(
  127 + alignment: Alignment.bottomCenter,
  128 + clipBehavior: Clip.none,
  129 + children: [
  130 + Stack(
  131 + alignment: Alignment.centerLeft,
  132 + clipBehavior: Clip.none,
  133 + children: [
  134 + CircleAvatar(
  135 + radius: ScreenUtil().setWidth(60),
  136 + backgroundColor: Color.fromRGBO(239, 239, 239, 1),
  137 + child: Text(
  138 + model.rnameStr != ''
  139 + ? model.rnameStr.substring(0, 1)
  140 + : '',
  141 + style: TextStyle(
  142 + color: Color.fromRGBO(206, 206, 206, 1),
  143 + fontSize: ScreenUtil().setSp(42)),
  144 + ),
160 ), 145 ),
161 - ),  
162 - child: Text(  
163 - model.attr == null || model.attr == ''  
164 - ? ''  
165 - : model.attr,  
166 - style: TextStyle(  
167 - color: MyColours.color_ffffff,  
168 - fontSize: ScreenUtil().setSp(28)))))  
169 - ],  
170 - ), 146 + Positioned(
  147 + left: ScreenUtil().setWidth(-18),
  148 + child: Image.asset(
  149 + Utils.getImgPath(
  150 + model.select ? 'select' : 'unselect'),
  151 + width: ScreenUtil().setWidth(36),
  152 + ))
  153 + ]),
  154 + Positioned(
  155 + bottom: ScreenUtil().setWidth(-20),
  156 + child: Container(
  157 + padding: EdgeInsets.symmetric(
  158 + horizontal: ScreenUtil().setWidth(10),
  159 + vertical: ScreenUtil().setWidth(2),
  160 + ),
  161 + decoration: BoxDecoration(
  162 + color: model.attr != null && model.attr != ''
  163 + ? model.attr == '沉睡'
  164 + ? Color.fromRGBO(223, 33, 81, 1)
  165 + : model.attr == '活跃'
  166 + ? Color.fromRGBO(81, 170, 94, 1)
  167 + : model.attr == '流失'
  168 + ? Color.fromRGBO(
  169 + 109, 101, 248, 1)
  170 + : Color.fromRGBO(
  171 + 239, 143, 49, 1)
  172 + : Colors.transparent,
  173 + borderRadius: BorderRadius.circular(
  174 + ScreenUtil().setWidth(10),
  175 + ),
  176 + ),
  177 + child: Text(
  178 + model.attr == null || model.attr == ''
  179 + ? ''
  180 + : model.attr,
  181 + style: TextStyle(
  182 + color: MyColours.color_ffffff,
  183 + fontSize: ScreenUtil().setSp(28)))))
  184 + ],
  185 + )),
171 HEmptyView(20), 186 HEmptyView(20),
172 Expanded( 187 Expanded(
173 child: Column( 188 child: Column(
@@ -351,7 +366,7 @@ class _ContactListPageState extends State<ContactListPage> { @@ -351,7 +366,7 @@ class _ContactListPageState extends State<ContactListPage> {
351 onTap: () { 366 onTap: () {
352 NavigatorUtil.goCustomerDetailPage(context, model, widget.fromPage); 367 NavigatorUtil.goCustomerDetailPage(context, model, widget.fromPage);
353 }, 368 },
354 - child: _buildListItem(model), 369 + child: _buildListItem(model, index),
355 ); 370 );
356 }, 371 },
357 physics: BouncingScrollPhysics(), 372 physics: BouncingScrollPhysics(),
1 import 'package:flutter/material.dart'; 1 import 'package:flutter/material.dart';
2 import 'package:flutter_screenutil/screenutil.dart'; 2 import 'package:flutter_screenutil/screenutil.dart';
  3 +import 'package:one_key/constant/state.dart';
  4 +import 'package:one_key/models/guest_info_model.dart';
  5 +import 'package:one_key/provider/customer_provider.dart';
3 import 'package:one_key/res/colors.dart'; 6 import 'package:one_key/res/colors.dart';
4 import 'package:one_key/utils/dialog_util.dart'; 7 import 'package:one_key/utils/dialog_util.dart';
  8 +import 'package:one_key/utils/event_bus.dart';
5 import 'package:one_key/utils/utils.dart'; 9 import 'package:one_key/utils/utils.dart';
6 import 'package:one_key/widgets/h_empty_view.dart'; 10 import 'package:one_key/widgets/h_empty_view.dart';
7 import 'package:one_key/widgets/round_button.dart'; 11 import 'package:one_key/widgets/round_button.dart';
8 import 'package:one_key/widgets/system_app_bar.dart'; 12 import 'package:one_key/widgets/system_app_bar.dart';
9 import 'package:one_key/widgets/v_empty_view.dart'; 13 import 'package:one_key/widgets/v_empty_view.dart';
  14 +import 'package:provider/provider.dart';
10 15
11 class CustomerDetailEditPage extends StatefulWidget { 16 class CustomerDetailEditPage extends StatefulWidget {
12 - CustomerDetailEditPage({Key key}) : super(key: key); 17 + final Guest guest;
  18 + final FromPage fromPage;
  19 + CustomerDetailEditPage({Key key, this.guest, this.fromPage})
  20 + : super(key: key);
13 21
14 @override 22 @override
15 _CustomerDetailEditPageState createState() => _CustomerDetailEditPageState(); 23 _CustomerDetailEditPageState createState() => _CustomerDetailEditPageState();
@@ -32,6 +40,9 @@ class _CustomerDetailEditPageState extends State<CustomerDetailEditPage> { @@ -32,6 +40,9 @@ class _CustomerDetailEditPageState extends State<CustomerDetailEditPage> {
32 TextEditingController xhController = TextEditingController(); 40 TextEditingController xhController = TextEditingController();
33 TextEditingController fwController = TextEditingController(); 41 TextEditingController fwController = TextEditingController();
34 bool showLabel = false; 42 bool showLabel = false;
  43 +
  44 + CustomerProvider customerProvider;
  45 + String labelShow = '';
35 @override 46 @override
36 void initState() { 47 void initState() {
37 super.initState(); 48 super.initState();
@@ -47,23 +58,85 @@ class _CustomerDetailEditPageState extends State<CustomerDetailEditPage> { @@ -47,23 +58,85 @@ class _CustomerDetailEditPageState extends State<CustomerDetailEditPage> {
47 setState(() {}); 58 setState(() {});
48 }); 59 });
49 WidgetsBinding.instance.addPostFrameCallback((_) { 60 WidgetsBinding.instance.addPostFrameCallback((_) {
50 - // if (widget.name != '' &&  
51 - // widget.name != null &&  
52 - // widget.sex != '' &&  
53 - // widget.sex != null) {  
54 - // nameStr = widget.name;  
55 - // for (var item in detailModel.sexList) {  
56 - // item['select'] = false;  
57 - // if (item['code'] == widget.sex) {  
58 - // item['select'] = true;  
59 - // }  
60 - // }  
61 - // _addNameSuffix(nameStr, _nameSuffix());  
62 - // setState(() {});  
63 - // } 61 + if (widget.guest.rname != '' &&
  62 + widget.guest.rname != null &&
  63 + widget.guest.sex != '' &&
  64 + widget.guest.sex != null) {
  65 + nameStr = widget.guest.rname;
  66 + for (var item in sexList) {
  67 + item['select'] = false;
  68 + if (item['code'] == widget.guest.sex) {
  69 + item['select'] = true;
  70 + }
  71 + }
  72 + _addNameSuffix(nameStr, _nameSuffix());
  73 + }
  74 + phoneController.text = widget.guest.phone ?? '';
  75 + adressController.text = widget.guest.company ?? '';
  76 + departmentController.text = widget.guest.section ?? '';
  77 + positionController.text = widget.guest.position ?? '';
  78 + jkController.text = widget.guest.taboos ?? '';
  79 + xhController.text = widget.guest.like ?? '';
  80 + fwController.text = widget.guest.serve ?? '';
  81 + labelShow = widget.guest.label ?? '';
  82 + setState(() {});
64 }); 83 });
65 } 84 }
66 85
  86 + _setGuestInfo() async {
  87 + if (nameStr.trim().length == 0) {
  88 + Utils.showToast('请填写客户姓名');
  89 + return;
  90 + }
  91 + if (phoneController.text.trim().length == 0) {
  92 + Utils.showToast('请填写客户电话');
  93 + return;
  94 + }
  95 + String sex = '1';
  96 + for (var item in sexList) {
  97 + if (item['select']) {
  98 + sex = item['code'];
  99 + }
  100 + }
  101 + Map<String, String> params = {
  102 + "id": widget.guest.id,
  103 + 'sex': sex,
  104 + 'rname': nameStr,
  105 + 'phone': phoneController.text
  106 + };
  107 +
  108 + if (adressController.text.trim().length > 0) {
  109 + params['company'] = adressController.text;
  110 + }
  111 + if (departmentController.text.trim().length > 0) {
  112 + params['section'] = departmentController.text;
  113 + }
  114 + if (positionController.text.trim().length > 0) {
  115 + params['position'] = positionController.text;
  116 + }
  117 + if (labelShow != '') {
  118 + // params['label'] =
  119 + }
  120 + if (jkController.text.trim().length > 0) {
  121 + params['taboos'] = jkController.text;
  122 + }
  123 + if (xhController.text.trim().length > 0) {
  124 + params['like'] = xhController.text;
  125 + }
  126 + if (fwController.text.trim().length > 0) {
  127 + params['serve'] = fwController.text;
  128 + }
  129 + bool sucess =
  130 + await customerProvider.setGuestInfo(context, params, showLoading: true);
  131 + if (sucess) {
  132 + Utils.showToast('保存成功');
  133 + bus.emit('refresh_guest_info');
  134 + bus.emit('refresh_guest_list');
  135 + Navigator.pop(context);
  136 + // 刷新前一页
  137 + }
  138 + }
  139 +
67 ///称谓 140 ///称谓
68 _initSexList() { 141 _initSexList() {
69 // String sexStr = detailEntity.sex; 142 // String sexStr = detailEntity.sex;
@@ -192,17 +265,15 @@ class _CustomerDetailEditPageState extends State<CustomerDetailEditPage> { @@ -192,17 +265,15 @@ class _CustomerDetailEditPageState extends State<CustomerDetailEditPage> {
192 contentPadding: EdgeInsets.zero, 265 contentPadding: EdgeInsets.zero,
193 border: OutlineInputBorder(borderSide: BorderSide.none), 266 border: OutlineInputBorder(borderSide: BorderSide.none),
194 ), 267 ),
195 - onChanged: (value) {  
196 - print('ggg');  
197 -  
198 - nameStr = value;  
199 - }, 268 + onChanged: (value) {},
200 onEditingComplete: () { 269 onEditingComplete: () {
  270 + // if (controller == nameController) {
  271 + // nameFocus.unfocus();
  272 + // // _homeEnterModel.nameController.text =
  273 + // // nameStr + _nameSuffix();
  274 + // _addNameSuffix(nameStr, _nameSuffix());
  275 + // }
201 print('fff'); 276 print('fff');
202 - nameFocus.unfocus();  
203 - // _homeEnterModel.nameController.text =  
204 - // nameStr + _nameSuffix();  
205 - _addNameSuffix(nameStr, _nameSuffix());  
206 }, 277 },
207 keyboardType: TextInputType.text, 278 keyboardType: TextInputType.text,
208 ), 279 ),
@@ -279,6 +350,7 @@ class _CustomerDetailEditPageState extends State<CustomerDetailEditPage> { @@ -279,6 +350,7 @@ class _CustomerDetailEditPageState extends State<CustomerDetailEditPage> {
279 350
280 @override 351 @override
281 Widget build(BuildContext context) { 352 Widget build(BuildContext context) {
  353 + customerProvider = Provider.of<CustomerProvider>(context, listen: true);
282 return Scaffold( 354 return Scaffold(
283 backgroundColor: MyColours.color_ffffff, 355 backgroundColor: MyColours.color_ffffff,
284 appBar: SystemAppBar( 356 appBar: SystemAppBar(
@@ -348,7 +420,14 @@ class _CustomerDetailEditPageState extends State<CustomerDetailEditPage> { @@ -348,7 +420,14 @@ class _CustomerDetailEditPageState extends State<CustomerDetailEditPage> {
348 onChanged: (value) { 420 onChanged: (value) {
349 print('ggg'); 421 print('ggg');
350 422
351 - nameStr = value; 423 + if (value.endsWith('先生') ||
  424 + value.endsWith('女士') ||
  425 + value.endsWith('公司')) {
  426 + nameStr = value.substring(
  427 + 0, value.length - 2);
  428 + } else {
  429 + nameStr = value;
  430 + }
352 }, 431 },
353 onEditingComplete: () { 432 onEditingComplete: () {
354 print('fff'); 433 print('fff');
@@ -440,7 +519,7 @@ class _CustomerDetailEditPageState extends State<CustomerDetailEditPage> { @@ -440,7 +519,7 @@ class _CustomerDetailEditPageState extends State<CustomerDetailEditPage> {
440 ), 519 ),
441 Expanded( 520 Expanded(
442 child: Text( 521 child: Text(
443 - '低频高消费', 522 + labelShow,
444 overflow: TextOverflow.ellipsis, 523 overflow: TextOverflow.ellipsis,
445 style: TextStyle( 524 style: TextStyle(
446 color: Color.fromRGBO(193, 194, 63, 1), 525 color: Color.fromRGBO(193, 194, 63, 1),
@@ -458,67 +537,71 @@ class _CustomerDetailEditPageState extends State<CustomerDetailEditPage> { @@ -458,67 +537,71 @@ class _CustomerDetailEditPageState extends State<CustomerDetailEditPage> {
458 ], 537 ],
459 ), 538 ),
460 )), 539 )),
461 - InkWell(  
462 - onTap: () {  
463 - // DialogUtil.showSelectCusmanDialog(  
464 - // context, couponList, (value) {  
465 - // if (value != null) {  
466 - // setState(() {  
467 - // couponSelectIndex = value.first;  
468 - // });  
469 - // }  
470 - // },  
471 - // selecteds: couponSelectIndex == null  
472 - // ? []  
473 - // : [couponSelectIndex])  
474 - // .then((value) {});  
475 - },  
476 - child: Container(  
477 - // height: ScreenUtil().setWidth(60),  
478 - padding: EdgeInsets.symmetric(  
479 - vertical: ScreenUtil().setWidth(50)),  
480 - decoration: BoxDecoration(  
481 - border: Border(  
482 - bottom: BorderSide(  
483 - width: ScreenUtil().setWidth(2),  
484 - color: Color.fromRGBO(  
485 - 220, 220, 220, 1)))),  
486 - child: Row(  
487 - mainAxisAlignment:  
488 - MainAxisAlignment.spaceBetween,  
489 - crossAxisAlignment: CrossAxisAlignment.center,  
490 - children: [  
491 - Container(  
492 - // color: Colors.red,  
493 - width: ScreenUtil().setWidth(150),  
494 - height: ScreenUtil().setWidth(35),  
495 - child: Text(  
496 - '客户经理',  
497 - style: TextStyle( 540 + widget.fromPage == FromPage.FromPageMyCustomer
  541 + ? SizedBox()
  542 + : InkWell(
  543 + onTap: () {
  544 + // DialogUtil.showSelectCusmanDialog(
  545 + // context, couponList, (value) {
  546 + // if (value != null) {
  547 + // setState(() {
  548 + // couponSelectIndex = value.first;
  549 + // });
  550 + // }
  551 + // },
  552 + // selecteds: couponSelectIndex == null
  553 + // ? []
  554 + // : [couponSelectIndex])
  555 + // .then((value) {});
  556 + },
  557 + child: Container(
  558 + // height: ScreenUtil().setWidth(60),
  559 + padding: EdgeInsets.symmetric(
  560 + vertical: ScreenUtil().setWidth(50)),
  561 + decoration: BoxDecoration(
  562 + border: Border(
  563 + bottom: BorderSide(
  564 + width: ScreenUtil().setWidth(2),
  565 + color: Color.fromRGBO(
  566 + 220, 220, 220, 1)))),
  567 + child: Row(
  568 + mainAxisAlignment:
  569 + MainAxisAlignment.spaceBetween,
  570 + crossAxisAlignment:
  571 + CrossAxisAlignment.center,
  572 + children: [
  573 + Container(
  574 + // color: Colors.red,
  575 + width: ScreenUtil().setWidth(150),
  576 + height: ScreenUtil().setWidth(35),
  577 + child: Text(
  578 + '客户经理',
  579 + style: TextStyle(
  580 + fontSize:
  581 + ScreenUtil().setSp(28),
  582 + color: MyColours.color_333333),
  583 + ),
  584 + ),
  585 + Expanded(
  586 + child: Text(
  587 + 'xxxj',
  588 + overflow: TextOverflow.ellipsis,
  589 + style: TextStyle(
  590 + color: MyColours.color_333333,
498 fontSize: ScreenUtil().setSp(28), 591 fontSize: ScreenUtil().setSp(28),
499 - color: MyColours.color_333333),  
500 - ), 592 + ),
  593 + )),
  594 + HEmptyView(10),
  595 + Image.asset(
  596 + Utils.getImgPath(showLabel
  597 + ? 'c_arrow_up'
  598 + : 'c_arrow_down'),
  599 + width: ScreenUtil().setWidth(24),
  600 + // height: ScreenUtil().setWidth(10),
  601 + )
  602 + ],
501 ), 603 ),
502 - Expanded(  
503 - child: Text(  
504 - 'xxxj',  
505 - overflow: TextOverflow.ellipsis,  
506 - style: TextStyle(  
507 - color: MyColours.color_333333,  
508 - fontSize: ScreenUtil().setSp(28),  
509 - ),  
510 - )),  
511 - HEmptyView(10),  
512 - Image.asset(  
513 - Utils.getImgPath(showLabel  
514 - ? 'c_arrow_up'  
515 - : 'c_arrow_down'),  
516 - width: ScreenUtil().setWidth(24),  
517 - // height: ScreenUtil().setWidth(10),  
518 - )  
519 - ],  
520 - ),  
521 - )), 604 + )),
522 VEmptyView(60), 605 VEmptyView(60),
523 _textMulLine('忌口', '输入忌口的东西', jkController), 606 _textMulLine('忌口', '输入忌口的东西', jkController),
524 VEmptyView(30), 607 VEmptyView(30),
@@ -536,7 +619,9 @@ class _CustomerDetailEditPageState extends State<CustomerDetailEditPage> { @@ -536,7 +619,9 @@ class _CustomerDetailEditPageState extends State<CustomerDetailEditPage> {
536 height: ScreenUtil().setWidth(80), 619 height: ScreenUtil().setWidth(80),
537 fontSize: 26, 620 fontSize: 26,
538 isBold: false, 621 isBold: false,
539 - onPressed: () {}, 622 + onPressed: () {
  623 + _setGuestInfo();
  624 + },
540 ), 625 ),
541 VEmptyView(30) 626 VEmptyView(30)
542 ], 627 ],
@@ -8,6 +8,7 @@ import 'package:one_key/provider/customer_provider.dart'; @@ -8,6 +8,7 @@ import 'package:one_key/provider/customer_provider.dart';
8 import 'package:one_key/res/colors.dart'; 8 import 'package:one_key/res/colors.dart';
9 import 'package:one_key/route/navigator_util.dart'; 9 import 'package:one_key/route/navigator_util.dart';
10 import 'package:one_key/utils/dialog_util.dart'; 10 import 'package:one_key/utils/dialog_util.dart';
  11 +import 'package:one_key/utils/event_bus.dart';
11 import 'package:one_key/utils/utils.dart'; 12 import 'package:one_key/utils/utils.dart';
12 import 'package:one_key/widgets/h_empty_view.dart'; 13 import 'package:one_key/widgets/h_empty_view.dart';
13 import 'package:one_key/widgets/page_exception.dart'; 14 import 'package:one_key/widgets/page_exception.dart';
@@ -38,6 +39,15 @@ class _CustomerDetailPageState extends State<CustomerDetailPage> { @@ -38,6 +39,15 @@ class _CustomerDetailPageState extends State<CustomerDetailPage> {
38 WidgetsBinding.instance.addPostFrameCallback((_) async { 39 WidgetsBinding.instance.addPostFrameCallback((_) async {
39 _getGuestInfo(); 40 _getGuestInfo();
40 }); 41 });
  42 + bus.on("refresh_guest_info", (arg) {
  43 + _getGuestInfo();
  44 + });
  45 + }
  46 +
  47 + @override
  48 + void dispose() {
  49 + EventBus().emit('refresh_guest_info');
  50 + super.dispose();
41 } 51 }
42 52
43 _getGuestInfo() async { 53 _getGuestInfo() async {
@@ -240,7 +250,8 @@ class _CustomerDetailPageState extends State<CustomerDetailPage> { @@ -240,7 +250,8 @@ class _CustomerDetailPageState extends State<CustomerDetailPage> {
240 fontSize: 26, 250 fontSize: 26,
241 isBold: false, 251 isBold: false,
242 onPressed: () { 252 onPressed: () {
243 - NavigatorUtil.goCustomerDetailEditPage(context); 253 + NavigatorUtil.goCustomerDetailEditPage(context,
  254 + customerProvider.guestInfoSunModel.guest, widget.fromPage);
244 }, 255 },
245 ), 256 ),
246 ], 257 ],
@@ -335,7 +346,11 @@ class _CustomerDetailPageState extends State<CustomerDetailPage> { @@ -335,7 +346,11 @@ class _CustomerDetailPageState extends State<CustomerDetailPage> {
335 )), 346 )),
336 InkWell( 347 InkWell(
337 onTap: () { 348 onTap: () {
338 - NavigatorUtil.goCustomerOrderPage(context); 349 + NavigatorUtil.goCustomerOrderPage(
  350 + context,
  351 + customerProvider.guestInfoSunModel.guest.id,
  352 + customerProvider
  353 + .guestInfoSunModel.guest.phone);
339 }, 354 },
340 child: Text('更多', 355 child: Text('更多',
341 style: TextStyle( 356 style: TextStyle(
@@ -4,6 +4,7 @@ import 'package:flutter_screenutil/screenutil.dart'; @@ -4,6 +4,7 @@ import 'package:flutter_screenutil/screenutil.dart';
4 import 'package:one_key/constant/state.dart'; 4 import 'package:one_key/constant/state.dart';
5 5
6 import 'package:one_key/pages/my/customer_type/contant_list_page.dart'; 6 import 'package:one_key/pages/my/customer_type/contant_list_page.dart';
  7 +import 'package:one_key/provider/customer_making_provider.dart';
7 8
8 import 'package:one_key/provider/customer_provider.dart'; 9 import 'package:one_key/provider/customer_provider.dart';
9 import 'package:one_key/provider/user_model.dart'; 10 import 'package:one_key/provider/user_model.dart';
@@ -34,11 +35,12 @@ class CustomerListPage extends StatefulWidget { @@ -34,11 +35,12 @@ class CustomerListPage extends StatefulWidget {
34 } 35 }
35 36
36 class _CustomerListPageState extends State<CustomerListPage> 37 class _CustomerListPageState extends State<CustomerListPage>
37 - with TickerProviderStateMixin { 38 + with TickerProviderStateMixin, SingleTickerProviderStateMixin {
38 List _tabBarTitle; 39 List _tabBarTitle;
39 TabController tabController; 40 TabController tabController;
40 41
41 CustomerProvider customerProvider; 42 CustomerProvider customerProvider;
  43 + CustomerMakingProvider customerMakingProvider;
42 bool showFilter = false; 44 bool showFilter = false;
43 ScrollController _scrollCrl = ScrollController(); 45 ScrollController _scrollCrl = ScrollController();
44 int dropValue = 0; 46 int dropValue = 0;
@@ -51,9 +53,25 @@ class _CustomerListPageState extends State<CustomerListPage> @@ -51,9 +53,25 @@ class _CustomerListPageState extends State<CustomerListPage>
51 // timeTilte = ['大于', '等于', '小于']; 53 // timeTilte = ['大于', '等于', '小于'];
52 super.initState(); 54 super.initState();
53 tabController = TabController(length: 4, vsync: this); 55 tabController = TabController(length: 4, vsync: this);
  56 + tabController.addListener(() {
  57 + if (tabController.index == tabController.animation.value) {
  58 + print(tabController.index);
  59 + customerProvider.index = tabController.index;
  60 + customerProvider.searchData(customerProvider.controller.text);
  61 + }
  62 + });
54 WidgetsBinding.instance.addPostFrameCallback((_) async { 63 WidgetsBinding.instance.addPostFrameCallback((_) async {
55 _getContantData(); 64 _getContantData();
56 }); 65 });
  66 + bus.on("refresh_guest_list", (arg) {
  67 + _getContantData();
  68 + });
  69 + }
  70 +
  71 + @override
  72 + void dispose() {
  73 + EventBus().emit('refresh_guest_list');
  74 + super.dispose();
57 } 75 }
58 76
59 _getContantData() async { 77 _getContantData() async {
@@ -84,20 +102,47 @@ class _CustomerListPageState extends State<CustomerListPage> @@ -84,20 +102,47 @@ class _CustomerListPageState extends State<CustomerListPage>
84 )), 102 )),
85 child: Row( 103 child: Row(
86 children: [ 104 children: [
87 - Image.asset(Utils.getImgPath('select'),  
88 - width: ScreenUtil().setWidth(30)),  
89 - HEmptyView(10),  
90 - Text(  
91 - '全选',  
92 - style: TextStyle(  
93 - fontSize: ScreenUtil().setSp(26),  
94 - color: MyColours.color_333333), 105 + InkWell(
  106 + onTap: () {
  107 + if (customerProvider.checkValue) {
  108 + customerProvider.cancelAll();
  109 + } else {
  110 + customerProvider.addAll();
  111 + }
  112 + },
  113 + child: Row(
  114 + children: [
  115 + Image.asset(
  116 + Utils.getImgPath(customerProvider.checkValue
  117 + ? 'c_mul_select'
  118 + : 'c_mul_select_un'),
  119 + width: ScreenUtil().setWidth(30)),
  120 + HEmptyView(10),
  121 + Text(
  122 + '全选',
  123 + style: TextStyle(
  124 + fontSize: ScreenUtil().setSp(26),
  125 + color: MyColours.color_333333),
  126 + ),
  127 + HEmptyView(20),
  128 + ],
  129 + ),
95 ), 130 ),
96 - HEmptyView(20), 131 +
97 Expanded( 132 Expanded(
98 child: InkWell( 133 child: InkWell(
99 onTap: () { 134 onTap: () {
100 - NavigatorUtil.goMakeMarkingPage(context); 135 + if (customerProvider.selectCustomer == null ||
  136 + customerProvider.selectCustomer.length == 0) {
  137 + Utils.showToast('请选择顾客');
  138 + return;
  139 + }
  140 + customerMakingProvider.labels = customerProvider.labels;
  141 + customerMakingProvider.selectCustomer =
  142 + customerProvider.selectCustomer;
  143 + customerMakingProvider.fromPage = widget.fromPage;
  144 + NavigatorUtil.goMakeMarkingPage(context,
  145 + Utils.listToStringEnglish(customerProvider.selectCustomer));
101 }, 146 },
102 child: Container( 147 child: Container(
103 alignment: Alignment.center, 148 alignment: Alignment.center,
@@ -107,7 +152,7 @@ class _CustomerListPageState extends State<CustomerListPage> @@ -107,7 +152,7 @@ class _CustomerListPageState extends State<CustomerListPage>
107 BorderRadius.circular(ScreenUtil().setWidth(40)), 152 BorderRadius.circular(ScreenUtil().setWidth(40)),
108 color: MyColours.color_199095), 153 color: MyColours.color_199095),
109 child: Text( 154 child: Text(
110 - '已选[全部]10000位顾客,下发营销任务', 155 + '已选[${customerProvider.labels}]${customerProvider.selectCustomer.length}位顾客,下发营销任务',
111 overflow: TextOverflow.ellipsis, 156 overflow: TextOverflow.ellipsis,
112 maxLines: 1, 157 maxLines: 1,
113 style: TextStyle( 158 style: TextStyle(
@@ -1001,6 +1046,9 @@ class _CustomerListPageState extends State<CustomerListPage> @@ -1001,6 +1046,9 @@ class _CustomerListPageState extends State<CustomerListPage>
1001 @override 1046 @override
1002 Widget build(BuildContext context) { 1047 Widget build(BuildContext context) {
1003 customerProvider = Provider.of<CustomerProvider>(context, listen: true); 1048 customerProvider = Provider.of<CustomerProvider>(context, listen: true);
  1049 + customerMakingProvider =
  1050 + Provider.of<CustomerMakingProvider>(context, listen: true);
  1051 +
1004 return Material( 1052 return Material(
1005 child: InkWell( 1053 child: InkWell(
1006 onTap: () { 1054 onTap: () {
  1 +import 'package:common_utils/common_utils.dart';
1 import 'package:flutter/material.dart'; 2 import 'package:flutter/material.dart';
2 import 'package:flutter_screenutil/flutter_screenutil.dart'; 3 import 'package:flutter_screenutil/flutter_screenutil.dart';
  4 +import 'package:one_key/constant/state.dart';
  5 +import 'package:one_key/models/guest_reserve_model.dart';
  6 +import 'package:one_key/provider/customer_provider.dart';
3 import 'package:one_key/res/colors.dart'; 7 import 'package:one_key/res/colors.dart';
4 import 'package:one_key/utils/utils.dart'; 8 import 'package:one_key/utils/utils.dart';
5 import 'package:one_key/widgets/MyDivider.dart'; 9 import 'package:one_key/widgets/MyDivider.dart';
6 import 'package:one_key/widgets/h_empty_view.dart'; 10 import 'package:one_key/widgets/h_empty_view.dart';
  11 +import 'package:one_key/widgets/page_exception.dart';
7 import 'package:one_key/widgets/system_app_bar.dart'; 12 import 'package:one_key/widgets/system_app_bar.dart';
8 import 'package:one_key/widgets/v_empty_view.dart'; 13 import 'package:one_key/widgets/v_empty_view.dart';
  14 +import 'package:provider/provider.dart';
9 15
10 class CustomerOrderPage extends StatefulWidget { 16 class CustomerOrderPage extends StatefulWidget {
11 - CustomerOrderPage({Key key}) : super(key: key); 17 + final String id;
  18 + final String phone;
  19 + CustomerOrderPage({Key key, this.id, this.phone}) : super(key: key);
12 20
13 @override 21 @override
14 _CustomerOrderPageState createState() => _CustomerOrderPageState(); 22 _CustomerOrderPageState createState() => _CustomerOrderPageState();
@@ -16,8 +24,30 @@ class CustomerOrderPage extends StatefulWidget { @@ -16,8 +24,30 @@ class CustomerOrderPage extends StatefulWidget {
16 24
17 class _CustomerOrderPageState extends State<CustomerOrderPage> { 25 class _CustomerOrderPageState extends State<CustomerOrderPage> {
18 int year = DateTime.now().year; 26 int year = DateTime.now().year;
  27 + CustomerProvider customerProvider;
  28 +
  29 + @override
  30 + void initState() {
  31 + super.initState();
  32 + WidgetsBinding.instance.addPostFrameCallback((_) async {
  33 + _getGuestReserve();
  34 + });
  35 + }
  36 +
  37 + _getGuestReserve({bool showLoading = false}) async {
  38 + Map<String, String> params = {
  39 + "id": widget.id,
  40 + "phone": widget.phone,
  41 + 'year': year.toString()
  42 + };
  43 + await customerProvider.getGuestReserve(context, params,
  44 + showLoading: showLoading);
  45 + // await customerProvider.searchData(customerProvider.controller.text);
  46 + }
  47 +
19 @override 48 @override
20 Widget build(BuildContext context) { 49 Widget build(BuildContext context) {
  50 + customerProvider = Provider.of<CustomerProvider>(context, listen: true);
21 return Scaffold( 51 return Scaffold(
22 backgroundColor: Color.fromRGBO(246, 248, 250, 1), 52 backgroundColor: Color.fromRGBO(246, 248, 250, 1),
23 appBar: SystemAppBar( 53 appBar: SystemAppBar(
@@ -26,253 +56,157 @@ class _CustomerOrderPageState extends State<CustomerOrderPage> { @@ -26,253 +56,157 @@ class _CustomerOrderPageState extends State<CustomerOrderPage> {
26 Navigator.pop(context); 56 Navigator.pop(context);
27 }, 57 },
28 ), 58 ),
29 - body: Padding(  
30 - padding: EdgeInsets.symmetric(  
31 - horizontal: ScreenUtil().setWidth(40),  
32 - vertical: ScreenUtil().setWidth(40)),  
33 - child: Column(  
34 - crossAxisAlignment: CrossAxisAlignment.start,  
35 - children: [  
36 - Row(  
37 - children: [  
38 - InkWell(  
39 - onTap: () {  
40 - setState(() {  
41 - year--;  
42 - });  
43 - },  
44 - child: Image.asset(  
45 - Utils.getImgPath('c_arrow_left'),  
46 - width: ScreenUtil().setWidth(24),  
47 - )),  
48 - Padding(  
49 - padding: EdgeInsets.symmetric(  
50 - horizontal: ScreenUtil().setWidth(20)),  
51 - child: Text(  
52 - '${year}年',  
53 - style: TextStyle(  
54 - fontSize: ScreenUtil().setSp(34),  
55 - color: MyColours.color_333333),  
56 - ),  
57 - ),  
58 - InkWell(  
59 - onTap: () {  
60 - if (year >= DateTime.now().year) {  
61 - return;  
62 - }  
63 - setState(() {  
64 - year++;  
65 - });  
66 - },  
67 - child: Image.asset(  
68 - Utils.getImgPath(year != DateTime.now().year  
69 - ? 'c_arrow_right'  
70 - : 'c_arrow_right_gray'),  
71 - width: ScreenUtil().setWidth(24),  
72 - ))  
73 - ],  
74 - ),  
75 - VEmptyView(20),  
76 - Wrap( 59 + body: Consumer<CustomerProvider>(builder: (context, model, _) {
  60 + if (model.pageStateGuestReserve != PageState.Success) {
  61 + return ExceptionPage(
  62 + pageState: model.pageStateGuestReserve,
  63 + callback: () {
  64 + model.pageStateGuestReserve = PageState.Loading;
  65 + model.notifyListeners();
  66 + _getGuestReserve();
  67 + },
  68 + emptyMsg: "暂时没有客户订单哦",
  69 + emptyImg: "empty_search",
  70 + showMsg: "加载中,请稍后...",
  71 + );
  72 + } else {
  73 + return Padding(
  74 + padding: EdgeInsets.symmetric(
  75 + // horizontal: ScreenUtil().setWidth(40),
  76 + vertical: ScreenUtil().setWidth(40)),
  77 + child: Column(
  78 + crossAxisAlignment: CrossAxisAlignment.start,
77 children: [ 79 children: [
78 - Text(  
79 - '全年累计',  
80 - style: TextStyle(  
81 - fontSize: ScreenUtil().setSp(24),  
82 - color: MyColours.color_353535),  
83 - ),  
84 - Text(  
85 - ' 2000 ',  
86 - style: TextStyle(  
87 - fontSize: ScreenUtil().setSp(24),  
88 - color: MyColours.color_199095),  
89 - ),  
90 - Text(  
91 - '单',  
92 - style: TextStyle(  
93 - fontSize: ScreenUtil().setSp(24),  
94 - color: MyColours.color_353535),  
95 - ),  
96 - HEmptyView(20),  
97 - Text(  
98 - '全年取消',  
99 - style: TextStyle(  
100 - fontSize: ScreenUtil().setSp(24),  
101 - color: MyColours.color_353535),  
102 - ),  
103 - Text(  
104 - ' 2000 ',  
105 - style: TextStyle(  
106 - fontSize: ScreenUtil().setSp(24),  
107 - color: MyColours.color_199095),  
108 - ),  
109 - Text(  
110 - '单',  
111 - style: TextStyle(  
112 - fontSize: ScreenUtil().setSp(24),  
113 - color: MyColours.color_353535),  
114 - ),  
115 - ],  
116 - ),  
117 - VEmptyView(20),  
118 - Wrap(  
119 - children: [  
120 - Text(  
121 - '记录全额订单:',  
122 - style: TextStyle(  
123 - fontSize: ScreenUtil().setSp(24),  
124 - color: MyColours.color_353535),  
125 - ),  
126 - Text(  
127 - '2000 ',  
128 - style: TextStyle(  
129 - fontSize: ScreenUtil().setSp(24),  
130 - color: MyColours.color_353535),  
131 - ),  
132 - Text(  
133 - '单',  
134 - style: TextStyle(  
135 - fontSize: ScreenUtil().setSp(24),  
136 - color: MyColours.color_353535),  
137 - ),  
138 - HEmptyView(20),  
139 - Text(  
140 - '记录人数订单:',  
141 - style: TextStyle(  
142 - fontSize: ScreenUtil().setSp(24),  
143 - color: MyColours.color_353535),  
144 - ),  
145 - Text(  
146 - '2000 ',  
147 - style: TextStyle(  
148 - fontSize: ScreenUtil().setSp(24),  
149 - color: MyColours.color_353535),  
150 - ),  
151 - Text(  
152 - '单',  
153 - style: TextStyle(  
154 - fontSize: ScreenUtil().setSp(24),  
155 - color: MyColours.color_353535),  
156 - ),  
157 - ],  
158 - ),  
159 - VEmptyView(20),  
160 - Wrap(  
161 - children: [  
162 - Text(  
163 - '总消费:',  
164 - style: TextStyle(  
165 - fontSize: ScreenUtil().setSp(24),  
166 - color: MyColours.color_353535),  
167 - ),  
168 - Text(  
169 - '2000 ',  
170 - style: TextStyle(  
171 - fontSize: ScreenUtil().setSp(24),  
172 - color: MyColours.color_353535),  
173 - ),  
174 - Text(  
175 - '元',  
176 - style: TextStyle(  
177 - fontSize: ScreenUtil().setSp(24),  
178 - color: MyColours.color_353535),  
179 - ),  
180 - HEmptyView(20),  
181 - Text(  
182 - '总人数:',  
183 - style: TextStyle(  
184 - fontSize: ScreenUtil().setSp(24),  
185 - color: MyColours.color_353535),  
186 - ),  
187 - Text(  
188 - '2000 ',  
189 - style: TextStyle(  
190 - fontSize: ScreenUtil().setSp(24),  
191 - color: MyColours.color_353535),  
192 - ),  
193 - Text(  
194 - '人',  
195 - style: TextStyle(  
196 - fontSize: ScreenUtil().setSp(24),  
197 - color: MyColours.color_353535),  
198 - ),  
199 - HEmptyView(20),  
200 - Text(  
201 - '人均:',  
202 - style: TextStyle(  
203 - fontSize: ScreenUtil().setSp(24),  
204 - color: MyColours.color_353535),  
205 - ),  
206 - Text(  
207 - '2000 ',  
208 - style: TextStyle(  
209 - fontSize: ScreenUtil().setSp(24),  
210 - color: MyColours.color_353535),  
211 - ),  
212 - Text(  
213 - '元/人',  
214 - style: TextStyle(  
215 - fontSize: ScreenUtil().setSp(24),  
216 - color: MyColours.color_353535),  
217 - ),  
218 - ],  
219 - ),  
220 - VEmptyView(20),  
221 - MyDivider(  
222 - double.infinity,  
223 - ScreenUtil().setWidth(1),  
224 - color: MyColours.color_E0E0E0,  
225 - ),  
226 - VEmptyView(20),  
227 - Expanded(  
228 - child: ListView.builder(  
229 - shrinkWrap: true,  
230 - itemCount: 10,  
231 - // controller: controller,  
232 - itemBuilder: (BuildContext context, int index) {  
233 - return Row(  
234 - crossAxisAlignment: CrossAxisAlignment.start, 80 + Row(
235 children: [ 81 children: [
236 - CircleAvatar(  
237 - radius: ScreenUtil().setWidth(10),  
238 - backgroundColor: MyColours.color_199095, 82 + InkWell(
  83 + onTap: () {
  84 + setState(() {
  85 + year--;
  86 + });
  87 + _getGuestReserve(showLoading: true);
  88 + },
  89 + child: Padding(
  90 + padding: EdgeInsets.only(
  91 + left: ScreenUtil().setWidth(40),
  92 + right: ScreenUtil().setWidth(20)),
  93 + child: Image.asset(
  94 + Utils.getImgPath('c_arrow_left'),
  95 + width: ScreenUtil().setWidth(24),
  96 + ))),
  97 + Text(
  98 + '${year}年',
  99 + style: TextStyle(
  100 + fontSize: ScreenUtil().setSp(34),
  101 + color: MyColours.color_333333),
239 ), 102 ),
240 - HEmptyView(20),  
241 - Column( 103 + InkWell(
  104 + onTap: () {
  105 + if (year >= DateTime.now().year) {
  106 + return;
  107 + }
  108 + setState(() {
  109 + year++;
  110 + });
  111 + _getGuestReserve(showLoading: true);
  112 + },
  113 + child: Padding(
  114 + padding: EdgeInsets.only(
  115 + left: ScreenUtil().setWidth(20),
  116 + right: ScreenUtil().setWidth(40)),
  117 + child: Image.asset(
  118 + Utils.getImgPath(year != DateTime.now().year
  119 + ? 'c_arrow_right'
  120 + : 'c_arrow_right_gray'),
  121 + width: ScreenUtil().setWidth(24),
  122 + )))
  123 + ],
  124 + ),
  125 + Padding(
  126 + padding: EdgeInsets.symmetric(
  127 + horizontal: ScreenUtil().setWidth(40),
  128 + ),
  129 + child: Column(
242 crossAxisAlignment: CrossAxisAlignment.start, 130 crossAxisAlignment: CrossAxisAlignment.start,
243 children: [ 131 children: [
  132 + VEmptyView(20),
  133 + Wrap(
  134 + children: [
  135 + Text(
  136 + '全年累计',
  137 + style: TextStyle(
  138 + fontSize: ScreenUtil().setSp(24),
  139 + color: MyColours.color_353535),
  140 + ),
  141 + Text(
  142 + ' ${customerProvider.guestReserveSunModel.count.cumulative} ',
  143 + style: TextStyle(
  144 + fontSize: ScreenUtil().setSp(24),
  145 + color: MyColours.color_199095),
  146 + ),
  147 + Text(
  148 + '单',
  149 + style: TextStyle(
  150 + fontSize: ScreenUtil().setSp(24),
  151 + color: MyColours.color_353535),
  152 + ),
  153 + HEmptyView(20),
  154 + Text(
  155 + '全年取消',
  156 + style: TextStyle(
  157 + fontSize: ScreenUtil().setSp(24),
  158 + color: MyColours.color_353535),
  159 + ),
  160 + Text(
  161 + ' ${customerProvider.guestReserveSunModel.count.cancel} ',
  162 + style: TextStyle(
  163 + fontSize: ScreenUtil().setSp(24),
  164 + color: MyColours.color_199095),
  165 + ),
  166 + Text(
  167 + '单',
  168 + style: TextStyle(
  169 + fontSize: ScreenUtil().setSp(24),
  170 + color: MyColours.color_353535),
  171 + ),
  172 + ],
  173 + ),
  174 + VEmptyView(20),
244 Wrap( 175 Wrap(
245 children: [ 176 children: [
246 Text( 177 Text(
247 - '[已完成]', 178 + '记录全额订单:',
248 style: TextStyle( 179 style: TextStyle(
249 fontSize: ScreenUtil().setSp(24), 180 fontSize: ScreenUtil().setSp(24),
250 color: MyColours.color_353535), 181 color: MyColours.color_353535),
251 ), 182 ),
252 - HEmptyView(10),  
253 Text( 183 Text(
254 - '42天前', 184 + '${customerProvider.guestReserveSunModel.count.money} ',
255 style: TextStyle( 185 style: TextStyle(
256 fontSize: ScreenUtil().setSp(24), 186 fontSize: ScreenUtil().setSp(24),
257 color: MyColours.color_353535), 187 color: MyColours.color_353535),
258 ), 188 ),
259 - HEmptyView(10),  
260 Text( 189 Text(
261 - '2021-09-29', 190 + '单',
  191 + style: TextStyle(
  192 + fontSize: ScreenUtil().setSp(24),
  193 + color: MyColours.color_353535),
  194 + ),
  195 + HEmptyView(20),
  196 + Text(
  197 + '记录人数订单:',
262 style: TextStyle( 198 style: TextStyle(
263 fontSize: ScreenUtil().setSp(24), 199 fontSize: ScreenUtil().setSp(24),
264 color: MyColours.color_353535), 200 color: MyColours.color_353535),
265 ), 201 ),
266 - HEmptyView(10),  
267 Text( 202 Text(
268 - '午餐', 203 + '${customerProvider.guestReserveSunModel.count.pnum} ',
269 style: TextStyle( 204 style: TextStyle(
270 fontSize: ScreenUtil().setSp(24), 205 fontSize: ScreenUtil().setSp(24),
271 color: MyColours.color_353535), 206 color: MyColours.color_353535),
272 ), 207 ),
273 - HEmptyView(10),  
274 Text( 208 Text(
275 - '【201】', 209 + '单',
276 style: TextStyle( 210 style: TextStyle(
277 fontSize: ScreenUtil().setSp(24), 211 fontSize: ScreenUtil().setSp(24),
278 color: MyColours.color_353535), 212 color: MyColours.color_353535),
@@ -280,29 +214,60 @@ class _CustomerOrderPageState extends State<CustomerOrderPage> { @@ -280,29 +214,60 @@ class _CustomerOrderPageState extends State<CustomerOrderPage> {
280 ], 214 ],
281 ), 215 ),
282 VEmptyView(20), 216 VEmptyView(20),
283 - Row( 217 + Wrap(
284 children: [ 218 children: [
285 Text( 219 Text(
286 - '人数:', 220 + '总消费:',
  221 + style: TextStyle(
  222 + fontSize: ScreenUtil().setSp(24),
  223 + color: MyColours.color_353535),
  224 + ),
  225 + Text(
  226 + '${customerProvider.guestReserveSunModel.count.countMoney} ',
  227 + style: TextStyle(
  228 + fontSize: ScreenUtil().setSp(24),
  229 + color: MyColours.color_353535),
  230 + ),
  231 + Text(
  232 + '元',
  233 + style: TextStyle(
  234 + fontSize: ScreenUtil().setSp(24),
  235 + color: MyColours.color_353535),
  236 + ),
  237 + HEmptyView(20),
  238 + Text(
  239 + '总人数:',
287 style: TextStyle( 240 style: TextStyle(
288 fontSize: ScreenUtil().setSp(24), 241 fontSize: ScreenUtil().setSp(24),
289 color: MyColours.color_353535), 242 color: MyColours.color_353535),
290 ), 243 ),
291 Text( 244 Text(
292 - '未记录', 245 + '${customerProvider.guestReserveSunModel.count.countPnum} ',
  246 + style: TextStyle(
  247 + fontSize: ScreenUtil().setSp(24),
  248 + color: MyColours.color_353535),
  249 + ),
  250 + Text(
  251 + '人',
293 style: TextStyle( 252 style: TextStyle(
294 fontSize: ScreenUtil().setSp(24), 253 fontSize: ScreenUtil().setSp(24),
295 color: MyColours.color_353535), 254 color: MyColours.color_353535),
296 ), 255 ),
297 HEmptyView(20), 256 HEmptyView(20),
298 Text( 257 Text(
299 - '消费:', 258 + '人均:',
300 style: TextStyle( 259 style: TextStyle(
301 fontSize: ScreenUtil().setSp(24), 260 fontSize: ScreenUtil().setSp(24),
302 color: MyColours.color_353535), 261 color: MyColours.color_353535),
303 ), 262 ),
304 Text( 263 Text(
305 - '未记录', 264 + '${customerProvider.guestReserveSunModel.count.capita} ',
  265 + style: TextStyle(
  266 + fontSize: ScreenUtil().setSp(24),
  267 + color: MyColours.color_353535),
  268 + ),
  269 + Text(
  270 + '元/人',
306 style: TextStyle( 271 style: TextStyle(
307 fontSize: ScreenUtil().setSp(24), 272 fontSize: ScreenUtil().setSp(24),
308 color: MyColours.color_353535), 273 color: MyColours.color_353535),
@@ -310,20 +275,112 @@ class _CustomerOrderPageState extends State<CustomerOrderPage> { @@ -310,20 +275,112 @@ class _CustomerOrderPageState extends State<CustomerOrderPage> {
310 ], 275 ],
311 ), 276 ),
312 VEmptyView(20), 277 VEmptyView(20),
313 - Text(  
314 - '客户经理:xxx 18739837273',  
315 - style: TextStyle(  
316 - fontSize: ScreenUtil().setSp(24),  
317 - color: MyColours.color_353535), 278 + MyDivider(
  279 + double.infinity,
  280 + ScreenUtil().setWidth(1),
  281 + color: MyColours.color_E0E0E0,
318 ), 282 ),
319 - VEmptyView(40), 283 + VEmptyView(20),
320 ], 284 ],
321 - )  
322 - ],  
323 - );  
324 - },  
325 - ))  
326 - ],  
327 - ))); 285 + )),
  286 + Expanded(
  287 + child: ListView.builder(
  288 + padding: EdgeInsets.symmetric(
  289 + horizontal: ScreenUtil().setWidth(40),
  290 + ),
  291 + shrinkWrap: true,
  292 + itemCount:
  293 + customerProvider.guestReserveSunModel.list?.length,
  294 + // controller: controller,
  295 + itemBuilder: (BuildContext context, int index) {
  296 + ListData listData =
  297 + customerProvider.guestReserveSunModel.list[index];
  298 + String tableinfo = listData.tableinfoName != ''
  299 + ? ' 【${listData.tableinfoName}】'
  300 + : '';
  301 + return Row(
  302 + crossAxisAlignment: CrossAxisAlignment.start,
  303 + children: [
  304 + Padding(
  305 + padding: EdgeInsets.only(
  306 + top: ScreenUtil().setWidth(6)),
  307 + child: CircleAvatar(
  308 + radius: ScreenUtil().setWidth(10),
  309 + backgroundColor: MyColours.color_199095,
  310 + ),
  311 + ),
  312 + HEmptyView(20),
  313 + Column(
  314 + crossAxisAlignment: CrossAxisAlignment.start,
  315 + children: [
  316 + Container(
  317 + constraints: BoxConstraints(
  318 + maxWidth: ScreenUtil.screenWidthDp -
  319 + ScreenUtil().setWidth(140)),
  320 + child: Text(
  321 + '[${listData.statusStr}] ${listData.ddateStr} ${listData.ddateSoltStr}${tableinfo}',
  322 + maxLines: 10,
  323 + overflow: TextOverflow.ellipsis,
  324 + style: TextStyle(
  325 + fontSize: ScreenUtil().setSp(24),
  326 + color: MyColours.color_353535),
  327 + )),
  328 + VEmptyView(20),
  329 + Row(
  330 + children: [
  331 + Text(
  332 + '人数:',
  333 + style: TextStyle(
  334 + fontSize: ScreenUtil().setSp(24),
  335 + color: MyColours.color_353535),
  336 + ),
  337 + Text(
  338 + listData.actualPum == null
  339 + ? '未记录'
  340 + : listData.actualPum,
  341 + style: TextStyle(
  342 + fontSize: ScreenUtil().setSp(24),
  343 + color: MyColours.color_353535),
  344 + ),
  345 + HEmptyView(20),
  346 + Text(
  347 + '消费:',
  348 + style: TextStyle(
  349 + fontSize: ScreenUtil().setSp(24),
  350 + color: MyColours.color_353535),
  351 + ),
  352 + Text(
  353 + listData.conAmount == null
  354 + ? '未记录'
  355 + : listData.conAmount,
  356 + style: TextStyle(
  357 + fontSize: ScreenUtil().setSp(24),
  358 + color: MyColours.color_353535),
  359 + ),
  360 + ],
  361 + ),
  362 + listData.nickName == null &&
  363 + listData.phone == null
  364 + ? SizedBox()
  365 + : Padding(
  366 + padding: EdgeInsets.only(
  367 + top: ScreenUtil().setWidth(20)),
  368 + child: Text(
  369 + '客户经理:${listData.nickName == null ? '' : listData.nickName} ${listData.phone == null ? '' : listData.phone}',
  370 + style: TextStyle(
  371 + fontSize: ScreenUtil().setSp(24),
  372 + color: MyColours.color_353535),
  373 + )),
  374 + VEmptyView(40),
  375 + ],
  376 + )
  377 + ],
  378 + );
  379 + },
  380 + ))
  381 + ],
  382 + ));
  383 + }
  384 + }));
328 } 385 }
329 } 386 }
1 import 'package:common_utils/common_utils.dart'; 1 import 'package:common_utils/common_utils.dart';
2 import 'package:flutter/material.dart'; 2 import 'package:flutter/material.dart';
3 import 'package:flutter_screenutil/screenutil.dart'; 3 import 'package:flutter_screenutil/screenutil.dart';
  4 +import 'package:one_key/constant/state.dart';
4 import 'package:one_key/pages/coupon/coupon_page.dart'; 5 import 'package:one_key/pages/coupon/coupon_page.dart';
  6 +import 'package:one_key/provider/customer_making_provider.dart';
  7 +import 'package:one_key/provider/customer_provider.dart';
  8 +import 'package:one_key/provider/user_model.dart';
5 import 'package:one_key/res/colors.dart'; 9 import 'package:one_key/res/colors.dart';
  10 +import 'package:one_key/route/navigator_util.dart';
6 import 'package:one_key/utils/dialog_util.dart'; 11 import 'package:one_key/utils/dialog_util.dart';
7 import 'package:one_key/utils/utils.dart'; 12 import 'package:one_key/utils/utils.dart';
8 import 'package:one_key/widgets/h_empty_view.dart'; 13 import 'package:one_key/widgets/h_empty_view.dart';
9 import 'package:one_key/widgets/round_button.dart'; 14 import 'package:one_key/widgets/round_button.dart';
10 import 'package:one_key/widgets/system_app_bar.dart'; 15 import 'package:one_key/widgets/system_app_bar.dart';
11 import 'package:one_key/widgets/v_empty_view.dart'; 16 import 'package:one_key/widgets/v_empty_view.dart';
  17 +import 'package:provider/provider.dart';
12 18
13 typedef ClickCallback = void Function(dynamic value); 19 typedef ClickCallback = void Function(dynamic value);
14 20
15 class MakeMarkingPage extends StatefulWidget { 21 class MakeMarkingPage extends StatefulWidget {
16 - MakeMarkingPage({Key key}) : super(key: key); 22 + final String gid;
  23 + MakeMarkingPage({Key key, this.gid}) : super(key: key);
17 24
18 @override 25 @override
19 _MakeMarkingPageState createState() => _MakeMarkingPageState(); 26 _MakeMarkingPageState createState() => _MakeMarkingPageState();
20 } 27 }
21 28
22 class _MakeMarkingPageState extends State<MakeMarkingPage> { 29 class _MakeMarkingPageState extends State<MakeMarkingPage> {
23 - TextEditingController controller = TextEditingController();  
24 - List<String> couponList = [  
25 - '98折(ccccckkkkshjhjsjsvc)kkkkkk',  
26 - 'fffff',  
27 - 'fffff',  
28 - 'ffsdfasfaf'  
29 - ];  
30 - int couponSelectIndex = 0; 30 + List<String> couponList = [];
  31 +
31 final GlobalKey<ScaffoldState> scaffoldKey = GlobalKey<ScaffoldState>(); 32 final GlobalKey<ScaffoldState> scaffoldKey = GlobalKey<ScaffoldState>();
32 FocusNode _focusNode = FocusNode(); 33 FocusNode _focusNode = FocusNode();
33 bool showDateSelWidget = false; 34 bool showDateSelWidget = false;
34 String limitDate = ''; 35 String limitDate = '';
  36 + CustomerProvider customerProvider;
  37 + CustomerMakingProvider customerMakingProvider;
35 38
36 @override 39 @override
37 void initState() { 40 void initState() {
@@ -48,6 +51,55 @@ class _MakeMarkingPageState extends State<MakeMarkingPage> { @@ -48,6 +51,55 @@ class _MakeMarkingPageState extends State<MakeMarkingPage> {
48 // _editingController.text = ''; 51 // _editingController.text = '';
49 } 52 }
50 }); 53 });
  54 + WidgetsBinding.instance.addPostFrameCallback((_) async {
  55 + _couponNetworkData(isShowLoading: false);
  56 + });
  57 + }
  58 +
  59 + @override
  60 + void dispose() {
  61 + super.dispose();
  62 + customerMakingProvider.clearData();
  63 + }
  64 +
  65 + ///消费券
  66 + _couponNetworkData({bool isShowLoading = true}) async {
  67 + // customerMakingProvider.couponSelectIndex = 0;
  68 + Map<String, String> params = {
  69 + "uid": Provider.of<UserModel>(context, listen: false).user.openid,
  70 + 'status': '1'
  71 + };
  72 + await customerProvider.getCustomerSelectActivityNew(context, params,
  73 + isShowLoading: isShowLoading);
  74 + //此人已经新建好券
  75 + if (customerProvider.couponListSelect.length > 0) {
  76 + // couponProvider.initCouponSelect(context);
  77 + couponList = [];
  78 + for (int i = 0; i < customerProvider.couponListSelect.length; i++) {
  79 + couponList.add(customerProvider.couponListSelect[i].aname);
  80 + }
  81 + customerProvider.notifyListeners();
  82 + } else {
  83 + //没有新建的优惠券
  84 + }
  85 + }
  86 +
  87 + _createMarketing() async {
  88 + if (customerMakingProvider.controller.text.trim().length == 0) {
  89 + Utils.showToast('请输入营销内容');
  90 + return;
  91 + }
  92 + Map<String, String> params = {
  93 + "uid": Provider.of<UserModel>(context, listen: false).user.openid,
  94 + "gid": widget.gid,
  95 + "content": customerMakingProvider.controller.text
  96 + };
  97 + if (customerMakingProvider.youhui != '选择优惠' &&
  98 + customerMakingProvider.isUse) {
  99 + params['aid'] =
  100 + '${customerProvider.couponListSelect[customerMakingProvider.couponSelectIndex].id}';
  101 + }
  102 + await customerProvider.createMarketing(context, params);
51 } 103 }
52 104
53 _buttonChoose(String title, ClickCallback callback) { 105 _buttonChoose(String title, ClickCallback callback) {
@@ -72,13 +124,19 @@ class _MakeMarkingPageState extends State<MakeMarkingPage> { @@ -72,13 +124,19 @@ class _MakeMarkingPageState extends State<MakeMarkingPage> {
72 title, 124 title,
73 overflow: TextOverflow.ellipsis, 125 overflow: TextOverflow.ellipsis,
74 style: TextStyle( 126 style: TextStyle(
75 - color: title == '时间(选填)' || title == '(选填)' 127 + color: title == '时间(选填)' ||
  128 + title == '(选填)' ||
  129 + title == '选择优惠' ||
  130 + !customerMakingProvider.isUse
76 ? MyColours.color_999999 131 ? MyColours.color_999999
77 : MyColours.color_199095, 132 : MyColours.color_199095,
78 fontSize: ScreenUtil().setWidth(30)), 133 fontSize: ScreenUtil().setWidth(30)),
79 )), 134 )),
80 HEmptyView(10), 135 HEmptyView(10),
81 Image.asset( 136 Image.asset(
  137 + // Utils.getImgPath(!customerMakingProvider.isUse
  138 + // ? 'c_arrow_down_unsel'
  139 + // : 'c_arrow_down'),
82 Utils.getImgPath('c_arrow_down'), 140 Utils.getImgPath('c_arrow_down'),
83 width: ScreenUtil().setWidth(30), 141 width: ScreenUtil().setWidth(30),
84 // height: ScreenUtil().setWidth(10), 142 // height: ScreenUtil().setWidth(10),
@@ -106,7 +164,7 @@ class _MakeMarkingPageState extends State<MakeMarkingPage> { @@ -106,7 +164,7 @@ class _MakeMarkingPageState extends State<MakeMarkingPage> {
106 // )), 164 // )),
107 // VEmptyView(30), 165 // VEmptyView(30),
108 TextField( 166 TextField(
109 - controller: controller, 167 + controller: customerMakingProvider.controller,
110 // keyboardType: TextInputType.number, //键盘类型,数字键盘 168 // keyboardType: TextInputType.number, //键盘类型,数字键盘
111 maxLines: 10, 169 maxLines: 10,
112 focusNode: _focusNode, 170 focusNode: _focusNode,
@@ -156,6 +214,8 @@ class _MakeMarkingPageState extends State<MakeMarkingPage> { @@ -156,6 +214,8 @@ class _MakeMarkingPageState extends State<MakeMarkingPage> {
156 children: [ 214 children: [
157 InkWell( 215 InkWell(
158 onTap: () { 216 onTap: () {
  217 + customerMakingProvider.controller.text = '';
  218 + setState(() {});
159 // NavigatorUtil.goMarketingRecordsDetailPage(context); 219 // NavigatorUtil.goMarketingRecordsDetailPage(context);
160 }, 220 },
161 child: Padding( 221 child: Padding(
@@ -166,26 +226,34 @@ class _MakeMarkingPageState extends State<MakeMarkingPage> { @@ -166,26 +226,34 @@ class _MakeMarkingPageState extends State<MakeMarkingPage> {
166 color: MyColours.color_199095, 226 color: MyColours.color_199095,
167 fontSize: ScreenUtil().setSp(26))), 227 fontSize: ScreenUtil().setSp(26))),
168 )), 228 )),
169 - Text('共 ${controller.text.length} 字 0 条短信', 229 + Text(
  230 + '共 ${customerMakingProvider.controller.text.length} 字 ${customerMakingProvider.selectCustomer.length} 条短信',
170 style: TextStyle( 231 style: TextStyle(
171 color: MyColours.color_333333, 232 color: MyColours.color_333333,
172 fontSize: ScreenUtil().setSp(26))), 233 fontSize: ScreenUtil().setSp(26))),
173 ], 234 ],
174 ), 235 ),
175 VEmptyView(40), 236 VEmptyView(40),
176 - Row(children: [  
177 - Image.asset(  
178 - Utils.getImgPath(true ? 'c_mul_select' : 'c_mul_select_un'),  
179 - width: ScreenUtil().setWidth(30)),  
180 - HEmptyView(15),  
181 - Text(  
182 - '营销加入优惠',  
183 - style: TextStyle(  
184 - fontSize: ScreenUtil().setSp(36),  
185 - fontWeight: FontWeight.bold,  
186 - color: MyColours.color_333333),  
187 - ),  
188 - ]), 237 + InkWell(
  238 + onTap: () {
  239 + customerMakingProvider.isUse = !customerMakingProvider.isUse;
  240 + setState(() {});
  241 + },
  242 + child: Row(children: [
  243 + Image.asset(
  244 + Utils.getImgPath(customerMakingProvider.isUse
  245 + ? 'c_mul_select'
  246 + : 'c_mul_select_un'),
  247 + width: ScreenUtil().setWidth(30)),
  248 + HEmptyView(15),
  249 + Text(
  250 + '营销加入优惠',
  251 + style: TextStyle(
  252 + fontSize: ScreenUtil().setSp(36),
  253 + fontWeight: FontWeight.bold,
  254 + color: MyColours.color_333333),
  255 + ),
  256 + ])),
189 VEmptyView(30), 257 VEmptyView(30),
190 Row(children: [ 258 Row(children: [
191 Expanded( 259 Expanded(
@@ -197,25 +265,42 @@ class _MakeMarkingPageState extends State<MakeMarkingPage> { @@ -197,25 +265,42 @@ class _MakeMarkingPageState extends State<MakeMarkingPage> {
197 BorderRadius.circular(ScreenUtil().setWidth(10)), 265 BorderRadius.circular(ScreenUtil().setWidth(10)),
198 color: Color.fromRGBO(239, 239, 239, 1)), 266 color: Color.fromRGBO(239, 239, 239, 1)),
199 child: 267 child:
200 - _buttonChoose(couponList[couponSelectIndex], (value) { 268 + _buttonChoose(customerMakingProvider.youhui, (value) {
201 FocusScope.of(context).requestFocus(FocusNode()); //隐藏键盘 269 FocusScope.of(context).requestFocus(FocusNode()); //隐藏键盘
  270 + if (couponList == null || couponList.length == 0) {
  271 + Utils.showToast('暂无优惠券,请创建新优惠');
  272 + return;
  273 + }
202 DialogUtil.showSelectCusmanDialog(context, couponList, 274 DialogUtil.showSelectCusmanDialog(context, couponList,
203 (value) { 275 (value) {
204 if (value != null) { 276 if (value != null) {
205 setState(() { 277 setState(() {
206 - couponSelectIndex = value.first; 278 + customerMakingProvider.couponSelectIndex =
  279 + value.first;
  280 + customerMakingProvider.youhui = couponList[
  281 + customerMakingProvider.couponSelectIndex];
207 }); 282 });
208 } 283 }
209 }, 284 },
210 - selecteds: couponSelectIndex == null 285 + selecteds: customerMakingProvider
  286 + .couponSelectIndex ==
  287 + null
211 ? [] 288 ? []
212 - : [couponSelectIndex]) 289 + : [customerMakingProvider.couponSelectIndex])
213 .then((value) {}); 290 .then((value) {});
214 }))), 291 }))),
215 HEmptyView(30), 292 HEmptyView(30),
216 InkWell( 293 InkWell(
217 - onTap: () { 294 + onTap: () async {
218 // NavigatorUtil.goMarketingRecordsDetailPage(context); 295 // NavigatorUtil.goMarketingRecordsDetailPage(context);
  296 + bool needRefresh =
  297 + await NavigatorUtil.goCouponEditPage(context);
  298 + print(needRefresh);
  299 + if (needRefresh != null && needRefresh) {
  300 + //刷新页面数据
  301 + // _controller.callRefresh();
  302 + _couponNetworkData();
  303 + }
219 }, 304 },
220 child: Text('创建新优惠', 305 child: Text('创建新优惠',
221 style: TextStyle( 306 style: TextStyle(
@@ -223,85 +308,96 @@ class _MakeMarkingPageState extends State<MakeMarkingPage> { @@ -223,85 +308,96 @@ class _MakeMarkingPageState extends State<MakeMarkingPage> {
223 color: MyColours.color_199095, 308 color: MyColours.color_199095,
224 fontSize: ScreenUtil().setSp(26)))), 309 fontSize: ScreenUtil().setSp(26)))),
225 ]), 310 ]),
226 - VEmptyView(30),  
227 - Row(children: [  
228 - Image.asset(  
229 - Utils.getImgPath(true ? 'c_mul_select' : 'c_mul_select_un'),  
230 - width: ScreenUtil().setWidth(30)),  
231 - HEmptyView(15),  
232 - Text(  
233 - '客户经理不可修改短信内容',  
234 - style: TextStyle(  
235 - fontSize: ScreenUtil().setSp(26),  
236 - color: MyColours.color_333333),  
237 - ),  
238 - ]),  
239 - VEmptyView(30),  
240 - Row(children: [  
241 - Image.asset(  
242 - Utils.getImgPath(true ? 'c_mul_select' : 'c_mul_select_un'),  
243 - width: ScreenUtil().setWidth(30)),  
244 - HEmptyView(15),  
245 - Text(  
246 - '最晚完成期限',  
247 - style: TextStyle(  
248 - fontSize: ScreenUtil().setSp(26),  
249 - color: MyColours.color_333333),  
250 - ),  
251 - HEmptyView(15),  
252 - InkWell(  
253 - onTap: () {  
254 - FocusScope.of(context).requestFocus(FocusNode()); //点击空白处隐藏键盘  
255 - //弹出时间选择器  
256 - // showPickerDateTime(context);  
257 - showDateSelWidget = true;  
258 - DialogUtil.showPickerDateTime24(  
259 - context,  
260 - scaffoldKey,  
261 - (value) {  
262 - // {'text': picker.adapter.text, 'select': selecteds}  
263 - if (value != null) {  
264 - setState(() {  
265 - print(value);  
266 - limitDate = DateUtil.formatDateStr(value,  
267 - format: DateFormats.full);  
268 - });  
269 - }  
270 - showDateSelWidget = false;  
271 - },  
272 - dateTime: DateUtil.getDateTime(limitDate),  
273 - onCancel: () {  
274 - showDateSelWidget = false;  
275 - });  
276 - },  
277 - child: Row(  
278 - children: [  
279 - Container(  
280 - // height: ScreenUtil().setWidth(70),  
281 - alignment: Alignment.center,  
282 - // width: ScreenUtil().setWidth(280),  
283 - padding: EdgeInsets.symmetric(  
284 - horizontal: ScreenUtil().setWidth(30)),  
285 - decoration: BoxDecoration(  
286 - border: Border(  
287 - bottom: BorderSide(  
288 - color: Color.fromRGBO(175, 176, 177, 1),  
289 - width: ScreenUtil().setWidth(2)))),  
290 - child: Text(  
291 - limitDate, 311 + customerMakingProvider.fromPage == FromPage.FromPageMyCustomer
  312 + ? SizedBox()
  313 + : Column(
  314 + children: [
  315 + VEmptyView(30),
  316 + Row(children: [
  317 + Image.asset(
  318 + Utils.getImgPath(
  319 + true ? 'c_mul_select' : 'c_mul_select_un'),
  320 + width: ScreenUtil().setWidth(30)),
  321 + HEmptyView(15),
  322 + Text(
  323 + '客户经理不可修改短信内容',
292 style: TextStyle( 324 style: TextStyle(
293 fontSize: ScreenUtil().setSp(26), 325 fontSize: ScreenUtil().setSp(26),
294 color: MyColours.color_333333), 326 color: MyColours.color_333333),
295 - )),  
296 - Image.asset(  
297 - Utils.getImgPath('c_arrow_down'),  
298 - width: ScreenUtil().setWidth(30),  
299 - // height: ScreenUtil().setWidth(10),  
300 - )  
301 - ],  
302 - ),  
303 - ),  
304 - ]), 327 + ),
  328 + ]),
  329 + VEmptyView(30),
  330 + Row(children: [
  331 + Image.asset(
  332 + Utils.getImgPath(
  333 + true ? 'c_mul_select' : 'c_mul_select_un'),
  334 + width: ScreenUtil().setWidth(30)),
  335 + HEmptyView(15),
  336 + Text(
  337 + '最晚完成期限',
  338 + style: TextStyle(
  339 + fontSize: ScreenUtil().setSp(26),
  340 + color: MyColours.color_333333),
  341 + ),
  342 + HEmptyView(15),
  343 + InkWell(
  344 + onTap: () {
  345 + FocusScope.of(context)
  346 + .requestFocus(FocusNode()); //点击空白处隐藏键盘
  347 + //弹出时间选择器
  348 + // showPickerDateTime(context);
  349 + showDateSelWidget = true;
  350 + DialogUtil.showPickerDateTime24(
  351 + context,
  352 + scaffoldKey,
  353 + (value) {
  354 + // {'text': picker.adapter.text, 'select': selecteds}
  355 + if (value != null) {
  356 + setState(() {
  357 + print(value);
  358 + limitDate = DateUtil.formatDateStr(value,
  359 + format: DateFormats.full);
  360 + });
  361 + }
  362 + showDateSelWidget = false;
  363 + },
  364 + dateTime: DateUtil.getDateTime(limitDate),
  365 + onCancel: () {
  366 + showDateSelWidget = false;
  367 + });
  368 + },
  369 + child: Row(
  370 + children: [
  371 + Container(
  372 + // height: ScreenUtil().setWidth(70),
  373 + alignment: Alignment.center,
  374 + // width: ScreenUtil().setWidth(280),
  375 + padding: EdgeInsets.symmetric(
  376 + horizontal: ScreenUtil().setWidth(30)),
  377 + decoration: BoxDecoration(
  378 + border: Border(
  379 + bottom: BorderSide(
  380 + color: Color.fromRGBO(
  381 + 175, 176, 177, 1),
  382 + width: ScreenUtil().setWidth(2)))),
  383 + child: Text(
  384 + limitDate,
  385 + style: TextStyle(
  386 + fontSize: ScreenUtil().setSp(26),
  387 + color: MyColours.color_333333),
  388 + )),
  389 + Image.asset(
  390 + Utils.getImgPath('c_arrow_down'),
  391 + width: ScreenUtil().setWidth(30),
  392 + // height: ScreenUtil().setWidth(10),
  393 + )
  394 + ],
  395 + ),
  396 + ),
  397 + ]),
  398 + VEmptyView(30),
  399 + ],
  400 + )
305 ], 401 ],
306 ), 402 ),
307 ); 403 );
@@ -309,12 +405,16 @@ class _MakeMarkingPageState extends State<MakeMarkingPage> { @@ -309,12 +405,16 @@ class _MakeMarkingPageState extends State<MakeMarkingPage> {
309 405
310 @override 406 @override
311 Widget build(BuildContext context) { 407 Widget build(BuildContext context) {
  408 + customerProvider = Provider.of<CustomerProvider>(context, listen: true);
  409 + customerMakingProvider =
  410 + Provider.of<CustomerMakingProvider>(context, listen: true);
312 return Scaffold( 411 return Scaffold(
313 backgroundColor: Color.fromRGBO(246, 248, 250, 1), 412 backgroundColor: Color.fromRGBO(246, 248, 250, 1),
314 key: scaffoldKey, 413 key: scaffoldKey,
315 appBar: SystemAppBar( 414 appBar: SystemAppBar(
316 '创建营销任务', 415 '创建营销任务',
317 onTap: () { 416 onTap: () {
  417 + customerMakingProvider.clearData();
318 Navigator.pop(context); 418 Navigator.pop(context);
319 }, 419 },
320 ), 420 ),
@@ -334,7 +434,7 @@ class _MakeMarkingPageState extends State<MakeMarkingPage> { @@ -334,7 +434,7 @@ class _MakeMarkingPageState extends State<MakeMarkingPage> {
334 children: [ 434 children: [
335 Expanded( 435 Expanded(
336 child: Text( 436 child: Text(
337 - '已选[沉睡、活跃、流失]100位顾客', 437 + '已选[${customerMakingProvider.labels}]${customerMakingProvider.selectCustomer.length}位顾客',
338 style: TextStyle( 438 style: TextStyle(
339 color: MyColours.color_ffffff, 439 color: MyColours.color_ffffff,
340 fontSize: ScreenUtil().setSp(32)), 440 fontSize: ScreenUtil().setSp(32)),
@@ -342,6 +442,7 @@ class _MakeMarkingPageState extends State<MakeMarkingPage> { @@ -342,6 +442,7 @@ class _MakeMarkingPageState extends State<MakeMarkingPage> {
342 HEmptyView(10), 442 HEmptyView(10),
343 InkWell( 443 InkWell(
344 onTap: () { 444 onTap: () {
  445 + Navigator.pop(context);
345 // NavigatorUtil.goMarketingRecordsDetailPage(context); 446 // NavigatorUtil.goMarketingRecordsDetailPage(context);
346 }, 447 },
347 child: Text('查看', 448 child: Text('查看',
@@ -364,7 +465,9 @@ class _MakeMarkingPageState extends State<MakeMarkingPage> { @@ -364,7 +465,9 @@ class _MakeMarkingPageState extends State<MakeMarkingPage> {
364 ), 465 ),
365 )), 466 )),
366 RoundButton( 467 RoundButton(
367 - text: '确认下发任务', 468 + text: customerMakingProvider.fromPage == FromPage.FromPageMyCustomer
  469 + ? '群发短信'
  470 + : '确认下发任务',
368 gradientStart: MyColours.color_199095, 471 gradientStart: MyColours.color_199095,
369 gradientEnd: MyColours.color_199095, 472 gradientEnd: MyColours.color_199095,
370 // borderColor: MyColours.color_999999, 473 // borderColor: MyColours.color_999999,
@@ -376,6 +479,11 @@ class _MakeMarkingPageState extends State<MakeMarkingPage> { @@ -376,6 +479,11 @@ class _MakeMarkingPageState extends State<MakeMarkingPage> {
376 isBold: false, 479 isBold: false,
377 onPressed: () { 480 onPressed: () {
378 // NavigatorUtil.goEnterStoreEnvironmentPage(context); 481 // NavigatorUtil.goEnterStoreEnvironmentPage(context);
  482 + if (customerMakingProvider.fromPage ==
  483 + FromPage.FromPageMyCustomer) {
  484 + //群发短信
  485 + _createMarketing();
  486 + }
379 }, 487 },
380 ), 488 ),
381 VEmptyView(30), 489 VEmptyView(30),
@@ -392,15 +500,8 @@ class _MakeMarkingPageState extends State<MakeMarkingPage> { @@ -392,15 +500,8 @@ class _MakeMarkingPageState extends State<MakeMarkingPage> {
392 EdgeInsets.symmetric(horizontal: ScreenUtil().setWidth(230)), 500 EdgeInsets.symmetric(horizontal: ScreenUtil().setWidth(230)),
393 isBold: false, 501 isBold: false,
394 onPressed: () { 502 onPressed: () {
395 - // DialogUtil.cupertinoAlertDialog(context,  
396 - // title: "取消任务",  
397 - // content: "点击确定立即取消任务,已完成的客户经理继续生效",  
398 - // lTitle: "返回",  
399 - // rTitle: "确定取消", lCallback: () {  
400 - // print("返回");  
401 - // }, rCallback: () {  
402 - // print("确定取消任务");  
403 - // }); 503 + customerMakingProvider.clearData();
  504 + Navigator.pop(context);
404 }, 505 },
405 ), 506 ),
406 VEmptyView(40), 507 VEmptyView(40),
  1 +import 'package:flutter/material.dart';
  2 +import 'package:one_key/constant/state.dart';
  3 +
  4 +class CustomerMakingProvider extends ChangeNotifier {
  5 + String labels;
  6 + List<String> selectCustomer = [];
  7 + TextEditingController controller = TextEditingController();
  8 + FromPage fromPage;
  9 + int couponSelectIndex = 0;
  10 + String youhui = '选择优惠';
  11 + bool isUse = true; //营销加入优惠
  12 +
  13 + clearData() {
  14 + labels = '';
  15 + selectCustomer = [];
  16 + controller.text = '';
  17 + fromPage = null;
  18 + couponSelectIndex = 0;
  19 + youhui = '选择优惠';
  20 + isUse = true; //营销加入优惠
  21 + }
  22 +}
@@ -4,9 +4,11 @@ import 'package:lpinyin/lpinyin.dart'; @@ -4,9 +4,11 @@ import 'package:lpinyin/lpinyin.dart';
4 import 'package:one_key/constant/constant.dart'; 4 import 'package:one_key/constant/constant.dart';
5 import 'package:one_key/constant/error.dart'; 5 import 'package:one_key/constant/error.dart';
6 import 'package:one_key/constant/state.dart'; 6 import 'package:one_key/constant/state.dart';
  7 +import 'package:one_key/models/coupon_model.dart';
7 import 'package:one_key/models/customer_list_model.dart'; 8 import 'package:one_key/models/customer_list_model.dart';
8 import 'package:one_key/models/guest_info_model.dart'; 9 import 'package:one_key/models/guest_info_model.dart';
9 import 'package:one_key/models/guest_manage_model.dart'; 10 import 'package:one_key/models/guest_manage_model.dart';
  11 +import 'package:one_key/models/guest_reserve_model.dart';
10 import 'package:one_key/models/user_history_entity.dart'; 12 import 'package:one_key/models/user_history_entity.dart';
11 import 'package:one_key/net/base_resp.dart'; 13 import 'package:one_key/net/base_resp.dart';
12 import 'package:one_key/net/dio_util.dart'; 14 import 'package:one_key/net/dio_util.dart';
@@ -31,8 +33,41 @@ class CustomerProvider extends ChangeNotifier { @@ -31,8 +33,41 @@ class CustomerProvider extends ChangeNotifier {
31 PageState pageStateChenshui = PageState.Loading; 33 PageState pageStateChenshui = PageState.Loading;
32 PageState pageStateLiushi = PageState.Loading; 34 PageState pageStateLiushi = PageState.Loading;
33 GuestManageSunModel guestSunmodel; 35 GuestManageSunModel guestSunmodel;
34 - PageState pageStateGuestInfo = PageState.Loading; 36 + PageState pageStateGuestInfo = PageState.Loading; //客户详情
  37 + PageState pageStateGuestReserve = PageState.Loading; //订单统计
35 GuestInfoSunModel guestInfoSunModel; 38 GuestInfoSunModel guestInfoSunModel;
  39 + GuestReserveSunModel guestReserveSunModel;
  40 + List<String> selectCustomer = [];
  41 + int index = 0;
  42 + bool checkValue = true;
  43 + String labels = '';
  44 + List<CouponSunModel> couponListSelect = [];
  45 + int couponSelectIndex;
  46 +
  47 + ///客户经理获取所创建活动列表(选择优惠券)
  48 + Future<List<CouponSunModel>> getCustomerSelectActivityNew(
  49 + BuildContext context, Map<String, String> params,
  50 + {isShowLoading = true}) async {
  51 + BaseResp<dynamic> baseResp = await DioUtil()
  52 + .request<dynamic>(context, Method.get, HttpUrl.get_customer_activity,
  53 + data: params, showLoading: false)
  54 + .catchError((error) {
  55 + print(error.toString());
  56 + if (error is MyError) {
  57 + switch (error.type) {
  58 + }
  59 + }
  60 + });
  61 + if (baseResp.code == Constant.status_success) {
  62 + couponListSelect = CouponModel.fromJson(baseResp.responseData).data;
  63 + notifyListeners();
  64 + } else {
  65 + if (baseResp != null) {
  66 + Utils.showToast(baseResp.msg ?? "");
  67 + }
  68 + }
  69 + return couponListSelect;
  70 + }
36 71
37 //用来获取客户列表 72 //用来获取客户列表
38 getCustomerList(BuildContext context, Map<String, String> params) async { 73 getCustomerList(BuildContext context, Map<String, String> params) async {
@@ -117,6 +152,7 @@ class CustomerProvider extends ChangeNotifier { @@ -117,6 +152,7 @@ class CustomerProvider extends ChangeNotifier {
117 } else { 152 } else {
118 pageStateLiushi = PageState.Empty; 153 pageStateLiushi = PageState.Empty;
119 } 154 }
  155 + addAll();
120 pageState = PageState.Success; 156 pageState = PageState.Success;
121 } 157 }
122 notifyListeners(); 158 notifyListeners();
@@ -220,7 +256,206 @@ class CustomerProvider extends ChangeNotifier { @@ -220,7 +256,206 @@ class CustomerProvider extends ChangeNotifier {
220 // } 256 // }
221 // } 257 // }
222 258
  259 + // 获取客户订单统计
  260 + getGuestReserve(BuildContext context, Map<String, String> params,
  261 + {bool showLoading = false}) async {
  262 + BaseResp<dynamic> baseResp = await DioUtil()
  263 + .request<dynamic>(context, Method.get, HttpUrl.get_guest_reserve,
  264 + data: params, showLoading: showLoading)
  265 + .catchError((error) {
  266 + print(error.toString());
  267 + if (error is MyError) {
  268 + switch (error.type) {
  269 + case 1:
  270 + pageStateGuestReserve = PageState.ConnectivityError;
  271 + break;
  272 + case 2:
  273 + pageStateGuestReserve = PageState.ConnectivityTimeOut;
  274 + break;
  275 + default:
  276 + pageStateGuestReserve = PageState.ConnectivityError;
  277 + break;
  278 + }
  279 + }
  280 + notifyListeners();
  281 + });
  282 + if (baseResp != null && baseResp.code == Constant.status_success) {
  283 + pageStateGuestReserve = PageState.Success;
  284 + guestReserveSunModel =
  285 + GuestReserveModel.fromJson(baseResp.responseData).data;
  286 + notifyListeners();
  287 + } else {
  288 + if (baseResp != null) {
  289 + Utils.showToast(baseResp.msg ?? "");
  290 + }
  291 + pageStateGuestReserve = PageState.ConnectivityTimeOut;
  292 + }
  293 + notifyListeners();
  294 + }
  295 +
  296 + // 创建营销
  297 + createMarketing(BuildContext context, Map<String, String> params,
  298 + {bool showLoading = false}) async {
  299 + BaseResp<dynamic> baseResp = await DioUtil()
  300 + .request<dynamic>(context, Method.get, HttpUrl.create_marketing,
  301 + data: params, showLoading: showLoading)
  302 + .catchError((error) {
  303 + print(error.toString());
  304 + if (error is MyError) {}
  305 + notifyListeners();
  306 + });
  307 + if (baseResp != null && baseResp.code == Constant.status_success) {
  308 + // guestReserveSunModel =
  309 + // GuestReserveModel.fromJson(baseResp.responseData).data;
  310 + notifyListeners();
  311 + } else {
  312 + if (baseResp != null) {
  313 + Utils.showToast(baseResp.msg ?? "");
  314 + }
  315 + }
  316 + notifyListeners();
  317 + }
  318 +
  319 + //修改客户信息
  320 + Future<bool> setGuestInfo(BuildContext context, Map<String, String> params,
  321 + {bool showLoading = false}) async {
  322 + BaseResp<dynamic> baseResp = await DioUtil()
  323 + .request<dynamic>(context, Method.get, HttpUrl.set_guest_info,
  324 + data: params, showLoading: showLoading)
  325 + .catchError((error) {
  326 + print(error.toString());
  327 + if (error is MyError) {}
  328 + notifyListeners();
  329 + });
  330 + if (baseResp != null && baseResp.code == Constant.status_success) {
  331 + // guestReserveSunModel =
  332 + // GuestReserveModel.fromJson(baseResp.responseData).data;
  333 + if (baseResp.responseData['data'] == 1 ||
  334 + baseResp.responseData['data'] == 0) {
  335 + return true;
  336 + }
  337 + return false;
  338 + } else {
  339 + if (baseResp != null) {
  340 + Utils.showToast(baseResp.msg ?? "");
  341 + }
  342 + return false;
  343 + }
  344 + }
  345 +
  346 + //全选按钮执行“全选”
  347 + addAll() async {
  348 + List<CustomerListSunModel> temp = returnNowList();
  349 + //把数据状态全部改成true,即选中状态
  350 + selectCustomer = [];
  351 + for (var i = 0; i < temp.length; i++) {
  352 + temp[i].select = true;
  353 + selectCustomer.add(temp[i].id);
  354 + }
  355 + _giveValue(temp);
  356 + checkValue = true;
  357 + labelsValue();
  358 + notifyListeners();
  359 + }
  360 +
  361 + labelsValue() {
  362 + List<CustomerListSunModel> temp = returnNowList();
  363 + List<String> tempLabel = [];
  364 + for (CustomerListSunModel item in temp) {
  365 + if (item.select && item.attr != null) {
  366 + tempLabel.add(item.attr);
  367 + }
  368 + }
  369 + tempLabel = tempLabel.toSet().toList();
  370 + labels = Utils.listToStringEnglish(tempLabel);
  371 + }
  372 +
  373 + _giveValue(List<CustomerListSunModel> temp) {
  374 + if (index == 0) {
  375 + userHistorysShow = temp; //全部
  376 + } else if (index == 1) {
  377 + userHistorysShowHuoyue = temp; //活跃
  378 + } else if (index == 2) {
  379 + userHistorysShowChenshui = temp; //沉睡
  380 + } else if (index == 3) {
  381 + userHistorysShowLiushi = temp; //流失
  382 + }
  383 + }
  384 +
  385 + ///清除选择
  386 + clearSelect() {
  387 + selectCustomer = [];
  388 + labelsValue();
  389 + // couponsShow = [];
  390 + }
  391 +
  392 +//全选按钮执行“全不选”
  393 + cancelAll() async {
  394 + List<CustomerListSunModel> temp = returnNowList();
  395 + selectCustomer = [];
  396 + //把数据状态全部改成false,即不选中状态
  397 + for (var i = 0; i < temp.length; i++) {
  398 + temp[i].select = false;
  399 + }
  400 + _giveValue(temp);
  401 + checkValue = false;
  402 + labelsValue();
  403 + notifyListeners();
  404 + }
  405 +
  406 +//选中
  407 + addData(int index) {
  408 + List<CustomerListSunModel> temp = returnNowList();
  409 + temp[index].select = true;
  410 + _giveValue(temp);
  411 + selectCustomer.add(temp[index].id);
  412 + labelsValue();
  413 + notifyListeners();
  414 + }
  415 +
  416 + ///返回目前选中的list
  417 + List<CustomerListSunModel> returnNowList() {
  418 + List<CustomerListSunModel> temp = [];
  419 + if (index == 0) {
  420 + temp = userHistorysShow; //全部
  421 + } else if (index == 1) {
  422 + temp = userHistorysShowHuoyue; //活跃
  423 + } else if (index == 2) {
  424 + temp = userHistorysShowChenshui; //沉睡
  425 + } else if (index == 3) {
  426 + temp = userHistorysShowLiushi; //流失
  427 + }
  428 + return temp;
  429 + }
  430 +
  431 +//未选中
  432 + cancelData(int index) {
  433 + List<CustomerListSunModel> temp = returnNowList();
  434 + temp[index].select = false;
  435 + _giveValue(temp);
  436 + selectCustomer.removeWhere((element) => element == temp[index].id);
  437 + labelsValue();
  438 + notifyListeners();
  439 + }
  440 +
  441 + //获取全选按钮的状态 true or false
  442 + getCheckValue() {
  443 + List<CustomerListSunModel> listData = returnNowList();
  444 + bool temp = listData.any((value) {
  445 + return value.select == false;
  446 + });
  447 + if (temp == true) {
  448 + checkValue = false;
  449 + } else {
  450 + checkValue = true;
  451 + }
  452 + notifyListeners();
  453 + }
  454 +
223 searchData(String key) { 455 searchData(String key) {
  456 + // userHistorys 接口请求结果
  457 + // userHistorysShow 侧边栏功能结果
  458 + // 全部,活跃,沉睡,流失的数据是在userHistorysShow 中筛选出来的
224 if (userHistorys.length > 0) { 459 if (userHistorys.length > 0) {
225 if (key == '') { 460 if (key == '') {
226 userHistorysShow = userHistorys; 461 userHistorysShow = userHistorys;
@@ -258,6 +493,33 @@ class CustomerProvider extends ChangeNotifier { @@ -258,6 +493,33 @@ class CustomerProvider extends ChangeNotifier {
258 pageState = PageState.Empty; 493 pageState = PageState.Empty;
259 notifyListeners(); 494 notifyListeners();
260 } else { 495 } else {
  496 + userHistorysShowHuoyue = [];
  497 + userHistorysShowChenshui = [];
  498 + userHistorysShowLiushi = [];
  499 + for (CustomerListSunModel item in userHistorysShow) {
  500 + if (item.attr == '活跃') {
  501 + userHistorysShowHuoyue.add(item);
  502 + } else if (item.attr == '沉睡') {
  503 + userHistorysShowChenshui.add(item);
  504 + } else if (item.attr == '流失') {
  505 + userHistorysShowLiushi.add(item);
  506 + }
  507 + }
  508 + if (userHistorysShowHuoyue.length > 0) {
  509 + pageStateHuoyue = PageState.Success;
  510 + } else {
  511 + pageStateHuoyue = PageState.Empty;
  512 + }
  513 + if (userHistorysShowChenshui.length > 0) {
  514 + pageStateChenshui = PageState.Success;
  515 + } else {
  516 + pageStateChenshui = PageState.Empty;
  517 + }
  518 + if (userHistorysShowLiushi.length > 0) {
  519 + pageStateLiushi = PageState.Success;
  520 + } else {
  521 + pageStateLiushi = PageState.Empty;
  522 + }
261 pageState = PageState.Success; 523 pageState = PageState.Success;
262 } 524 }
263 // if (contactsShow.length == 0) { 525 // if (contactsShow.length == 0) {
@@ -271,6 +533,7 @@ class CustomerProvider extends ChangeNotifier { @@ -271,6 +533,7 @@ class CustomerProvider extends ChangeNotifier {
271 } 533 }
272 } 534 }
273 535
  536 +//实时更新右边数据 ABCDEFGHIGK....
274 handleList(List<CustomerListSunModel> list, {bool needRefresh = false}) { 537 handleList(List<CustomerListSunModel> list, {bool needRefresh = false}) {
275 if (list == null || list.isEmpty) return; 538 if (list == null || list.isEmpty) return;
276 for (int i = 0, length = list.length; i < length; i++) { 539 for (int i = 0, length = list.length; i < length; i++) {
@@ -4,6 +4,7 @@ import 'package:one_key/constant/state.dart'; @@ -4,6 +4,7 @@ import 'package:one_key/constant/state.dart';
4 import 'package:one_key/models/cookbook_model.dart'; 4 import 'package:one_key/models/cookbook_model.dart';
5 import 'package:one_key/models/coupon_model.dart'; 5 import 'package:one_key/models/coupon_model.dart';
6 import 'package:one_key/models/customer_list_model.dart'; 6 import 'package:one_key/models/customer_list_model.dart';
  7 +import 'package:one_key/models/guest_info_model.dart';
7 import 'package:one_key/models/integral_model.dart'; 8 import 'package:one_key/models/integral_model.dart';
8 import 'package:one_key/models/notebook.dart'; 9 import 'package:one_key/models/notebook.dart';
9 import 'package:one_key/models/notebook_detail.dart'; 10 import 'package:one_key/models/notebook_detail.dart';
@@ -12,6 +13,7 @@ import 'package:one_key/models/sms_info.dart'; @@ -12,6 +13,7 @@ import 'package:one_key/models/sms_info.dart';
12 import 'package:one_key/models/statics_model.dart'; 13 import 'package:one_key/models/statics_model.dart';
13 import 'package:one_key/models/table_list.dart'; 14 import 'package:one_key/models/table_list.dart';
14 import 'package:one_key/models/user_history_entity.dart'; 15 import 'package:one_key/models/user_history_entity.dart';
  16 +import 'package:one_key/provider/customer_provider.dart';
15 import 'package:one_key/res/colors.dart'; 17 import 'package:one_key/res/colors.dart';
16 import 'package:one_key/route/routes.dart'; 18 import 'package:one_key/route/routes.dart';
17 import 'package:one_key/utils/fluro_convert_utils.dart'; 19 import 'package:one_key/utils/fluro_convert_utils.dart';
@@ -565,9 +567,9 @@ class NavigatorUtil { @@ -565,9 +567,9 @@ class NavigatorUtil {
565 } 567 }
566 568
567 /// 创建营销 569 /// 创建营销
568 - static Future<dynamic> goMakeMarkingPage(BuildContext context, 570 + static Future<dynamic> goMakeMarkingPage(BuildContext context, String gid,
569 {replace = false}) { 571 {replace = false}) {
570 - return _navigateTo(context, "${Routes.make_marketing_page}", 572 + return _navigateTo(context, "${Routes.make_marketing_page}?gid=$gid",
571 replace: replace); 573 replace: replace);
572 } 574 }
573 575
@@ -585,10 +587,13 @@ class NavigatorUtil { @@ -585,10 +587,13 @@ class NavigatorUtil {
585 587
586 ///编辑客户详情 588 ///编辑客户详情
587 static Future<dynamic> goCustomerDetailEditPage( 589 static Future<dynamic> goCustomerDetailEditPage(
588 - BuildContext context, { 590 + BuildContext context,
  591 + Guest guest,
  592 + FromPage fromPage, {
589 replace = false, 593 replace = false,
590 }) { 594 }) {
591 - return _navigateTo(context, "${Routes.customer_edit_detail_page}", 595 + return _navigateTo(context,
  596 + "${Routes.customer_edit_detail_page}?guest=${FluroConvertUtils.object2string(guest)}&fromPage=${FluroConvertUtils.enumToString(fromPage)}",
592 replace: replace); 597 replace: replace);
593 } 598 }
594 599
@@ -603,10 +608,13 @@ class NavigatorUtil { @@ -603,10 +608,13 @@ class NavigatorUtil {
603 608
604 ///客户订单 609 ///客户订单
605 static Future<dynamic> goCustomerOrderPage( 610 static Future<dynamic> goCustomerOrderPage(
606 - BuildContext context, { 611 + BuildContext context,
  612 + String id,
  613 + String phone, {
607 replace = false, 614 replace = false,
608 }) { 615 }) {
609 - return _navigateTo(context, "${Routes.customer_order_page}", 616 + return _navigateTo(
  617 + context, "${Routes.customer_order_page}?idstr=${id}&phone=${phone}",
610 replace: replace); 618 replace: replace);
611 } 619 }
612 } 620 }
@@ -6,6 +6,7 @@ import 'package:one_key/constant/state.dart'; @@ -6,6 +6,7 @@ import 'package:one_key/constant/state.dart';
6 import 'package:one_key/models/cookbook_model.dart'; 6 import 'package:one_key/models/cookbook_model.dart';
7 import 'package:one_key/models/coupon_model.dart'; 7 import 'package:one_key/models/coupon_model.dart';
8 import 'package:one_key/models/customer_list_model.dart'; 8 import 'package:one_key/models/customer_list_model.dart';
  9 +import 'package:one_key/models/guest_info_model.dart';
9 import 'package:one_key/models/integral_model.dart'; 10 import 'package:one_key/models/integral_model.dart';
10 import 'package:one_key/models/notebook_detail.dart'; 11 import 'package:one_key/models/notebook_detail.dart';
11 import 'package:one_key/models/personnel_manage_model.dart'; 12 import 'package:one_key/models/personnel_manage_model.dart';
@@ -890,9 +891,10 @@ var marketingRecordsDetailPageHandle = new Handler( @@ -890,9 +891,10 @@ var marketingRecordsDetailPageHandle = new Handler(
890 ///创建营销 891 ///创建营销
891 var makeMarkingPageHandle = new Handler( 892 var makeMarkingPageHandle = new Handler(
892 handlerFunc: (BuildContext context, Map<dynamic, List<Object>> params) { 893 handlerFunc: (BuildContext context, Map<dynamic, List<Object>> params) {
893 - // String idstr = params["idstr"].first; 894 + String gid = params["gid"].first;
  895 +
894 return ChangeNotifierProvider<CustomerProvider>( 896 return ChangeNotifierProvider<CustomerProvider>(
895 - create: (_) => CustomerProvider(), child: MakeMarkingPage()); 897 + create: (_) => CustomerProvider(), child: MakeMarkingPage(gid: gid));
896 }); 898 });
897 899
898 ///客户详情 900 ///客户详情
@@ -917,11 +919,16 @@ var customerDetailPageHandle = new Handler( @@ -917,11 +919,16 @@ var customerDetailPageHandle = new Handler(
917 var customerDetailEditPageHandle = new Handler( 919 var customerDetailEditPageHandle = new Handler(
918 handlerFunc: (BuildContext context, Map<dynamic, List<Object>> params) { 920 handlerFunc: (BuildContext context, Map<dynamic, List<Object>> params) {
919 // String idstr = params["idstr"].first; 921 // String idstr = params["idstr"].first;
920 - // UserHistoryEntity userHistoryEntity = UserHistoryEntity.fromJson(json.decode(  
921 - // FluroConvertUtils.fluroCnParamsDecode(  
922 - // params["userHistoryEntity"].first))); 922 + Guest guest = Guest.fromJson(json
  923 + .decode(FluroConvertUtils.fluroCnParamsDecode(params["guest"].first)));
  924 + FromPage fromPage = FluroConvertUtils.enumFromString<FromPage>(
  925 + FromPage.values, params["fromPage"].first);
923 return ChangeNotifierProvider<CustomerProvider>( 926 return ChangeNotifierProvider<CustomerProvider>(
924 - create: (_) => CustomerProvider(), child: CustomerDetailEditPage()); 927 + create: (_) => CustomerProvider(),
  928 + child: CustomerDetailEditPage(
  929 + guest: guest,
  930 + fromPage: fromPage,
  931 + ));
925 }); 932 });
926 933
927 ///纪念日 934 ///纪念日
@@ -938,10 +945,12 @@ var festivalEditPageHandle = new Handler( @@ -938,10 +945,12 @@ var festivalEditPageHandle = new Handler(
938 ///客户订单 945 ///客户订单
939 var customerOrderPageHandle = new Handler( 946 var customerOrderPageHandle = new Handler(
940 handlerFunc: (BuildContext context, Map<dynamic, List<Object>> params) { 947 handlerFunc: (BuildContext context, Map<dynamic, List<Object>> params) {
941 - // String idstr = params["idstr"].first; 948 + String idstr = params["idstr"].first;
  949 + String phone = params["phone"].first;
942 // UserHistoryEntity userHistoryEntity = UserHistoryEntity.fromJson(json.decode( 950 // UserHistoryEntity userHistoryEntity = UserHistoryEntity.fromJson(json.decode(
943 // FluroConvertUtils.fluroCnParamsDecode( 951 // FluroConvertUtils.fluroCnParamsDecode(
944 // params["userHistoryEntity"].first))); 952 // params["userHistoryEntity"].first)));
945 return ChangeNotifierProvider<CustomerProvider>( 953 return ChangeNotifierProvider<CustomerProvider>(
946 - create: (_) => CustomerProvider(), child: CustomerOrderPage()); 954 + create: (_) => CustomerProvider(),
  955 + child: CustomerOrderPage(id: idstr, phone: phone));
947 }); 956 });