Showing
8 changed files
with
2218 additions
and
7 deletions
assets/enter_order_arrow.png
0 → 100644
479 Bytes
assets/enter_order_edit.png
0 → 100644
1.23 KB
assets/enter_order_n.png
0 → 100644
1.77 KB
assets/enter_order_s.png
0 → 100644
2.03 KB
| @@ -6,16 +6,20 @@ import 'package:flutter/cupertino.dart'; | @@ -6,16 +6,20 @@ import 'package:flutter/cupertino.dart'; | ||
| 6 | import 'package:flutter/material.dart'; | 6 | import 'package:flutter/material.dart'; |
| 7 | import 'package:flutter_screenutil/flutter_screenutil.dart'; | 7 | import 'package:flutter_screenutil/flutter_screenutil.dart'; |
| 8 | import 'package:one_key/app.dart'; | 8 | import 'package:one_key/app.dart'; |
| 9 | +import 'package:one_key/pages/home_enter_order/home_enter_order.dart'; | ||
| 9 | 10 | ||
| 10 | import 'package:one_key/pages/message/message_page.dart'; | 11 | import 'package:one_key/pages/message/message_page.dart'; |
| 11 | import 'package:one_key/pages/my/my_page.dart'; | 12 | import 'package:one_key/pages/my/my_page.dart'; |
| 12 | import 'package:one_key/pages/notebook/notebook_page.dart'; | 13 | import 'package:one_key/pages/notebook/notebook_page.dart'; |
| 13 | import 'package:one_key/pages/table/table_manager_page.dart'; | 14 | import 'package:one_key/pages/table/table_manager_page.dart'; |
| 14 | import 'package:one_key/provider/contact_model.dart'; | 15 | import 'package:one_key/provider/contact_model.dart'; |
| 16 | +import 'package:one_key/provider/enter_model.dart'; | ||
| 17 | +import 'package:one_key/provider/home_enter_model.dart'; | ||
| 15 | import 'package:one_key/provider/message_dialog_model.dart'; | 18 | import 'package:one_key/provider/message_dialog_model.dart'; |
| 16 | import 'package:one_key/provider/message_model.dart'; | 19 | import 'package:one_key/provider/message_model.dart'; |
| 17 | import 'package:one_key/provider/my_model.dart'; | 20 | import 'package:one_key/provider/my_model.dart'; |
| 18 | import 'package:one_key/provider/notebook_model.dart'; | 21 | import 'package:one_key/provider/notebook_model.dart'; |
| 22 | +import 'package:one_key/provider/remark_manager_model.dart'; | ||
| 19 | import 'package:one_key/provider/table_manager_model.dart'; | 23 | import 'package:one_key/provider/table_manager_model.dart'; |
| 20 | import 'package:one_key/provider/tools.dart'; | 24 | import 'package:one_key/provider/tools.dart'; |
| 21 | import 'package:one_key/provider/update_model.dart'; | 25 | import 'package:one_key/provider/update_model.dart'; |
| @@ -44,7 +48,7 @@ class HomePage extends StatefulWidget { | @@ -44,7 +48,7 @@ class HomePage extends StatefulWidget { | ||
| 44 | 48 | ||
| 45 | class HomePageState extends State<HomePage> with WidgetsBindingObserver { | 49 | class HomePageState extends State<HomePage> with WidgetsBindingObserver { |
| 46 | List<Widget> pages = List<Widget>(); | 50 | List<Widget> pages = List<Widget>(); |
| 47 | - int _currIndex = 1; | 51 | + int _currIndex = 2; |
| 48 | Color _activeColor = MyColours.color_199095; | 52 | Color _activeColor = MyColours.color_199095; |
| 49 | Color _defaultColor = MyColours.color_999999; | 53 | Color _defaultColor = MyColours.color_999999; |
| 50 | int numPush = 0; //推送消息个数 | 54 | int numPush = 0; //推送消息个数 |
| @@ -63,6 +67,12 @@ class HomePageState extends State<HomePage> with WidgetsBindingObserver { | @@ -63,6 +67,12 @@ class HomePageState extends State<HomePage> with WidgetsBindingObserver { | ||
| 63 | WidgetsBinding.instance.addObserver(this); | 67 | WidgetsBinding.instance.addObserver(this); |
| 64 | _currIndex = widget.initialIndex; | 68 | _currIndex = widget.initialIndex; |
| 65 | pages | 69 | pages |
| 70 | + ..add(ChangeNotifierProvider<HomeEnterModel>( | ||
| 71 | + create: (_) => HomeEnterModel(), | ||
| 72 | + child: ChangeNotifierProvider<RemarkManagerModel>( | ||
| 73 | + create: (_) => RemarkManagerModel(), | ||
| 74 | + child: SafeArea(child: HomeEnterPage()), | ||
| 75 | + ))) | ||
| 66 | ..add(ChangeNotifierProvider<MessageModel>( | 76 | ..add(ChangeNotifierProvider<MessageModel>( |
| 67 | create: (_) => MessageModel(), | 77 | create: (_) => MessageModel(), |
| 68 | child: SafeArea(child: MessagePage()), | 78 | child: SafeArea(child: MessagePage()), |
| @@ -85,7 +95,7 @@ class HomePageState extends State<HomePage> with WidgetsBindingObserver { | @@ -85,7 +95,7 @@ class HomePageState extends State<HomePage> with WidgetsBindingObserver { | ||
| 85 | )); | 95 | )); |
| 86 | WidgetsBinding.instance.addPostFrameCallback((_) { | 96 | WidgetsBinding.instance.addPostFrameCallback((_) { |
| 87 | initPlatformState(); | 97 | initPlatformState(); |
| 88 | - if (widget.initialIndex == 0) return; | 98 | + if (widget.initialIndex == 1) return; |
| 89 | _getIntent(); | 99 | _getIntent(); |
| 90 | Future.delayed(Duration(milliseconds: 30000), () { | 100 | Future.delayed(Duration(milliseconds: 30000), () { |
| 91 | ContactModel.getInstance().uploadLocalContact(context); | 101 | ContactModel.getInstance().uploadLocalContact(context); |
| @@ -462,6 +472,24 @@ class HomePageState extends State<HomePage> with WidgetsBindingObserver { | @@ -462,6 +472,24 @@ class HomePageState extends State<HomePage> with WidgetsBindingObserver { | ||
| 462 | items: [ | 472 | items: [ |
| 463 | BottomNavigationBarItem( | 473 | BottomNavigationBarItem( |
| 464 | icon: Image( | 474 | icon: Image( |
| 475 | + image: AssetImage("assets/enter_order_n.png"), | ||
| 476 | + width: ScreenUtil().setWidth(48), | ||
| 477 | + height: ScreenUtil().setWidth(48), | ||
| 478 | + ), | ||
| 479 | + activeIcon: Image( | ||
| 480 | + image: AssetImage("assets/enter_order_s.png"), | ||
| 481 | + width: ScreenUtil().setWidth(48), | ||
| 482 | + height: ScreenUtil().setWidth(48), | ||
| 483 | + ), | ||
| 484 | + title: Text( | ||
| 485 | + "录入预订", | ||
| 486 | + style: TextStyle( | ||
| 487 | + color: _currIndex == 0 ? _activeColor : _defaultColor, | ||
| 488 | + fontSize: ScreenUtil().setSp(22)), | ||
| 489 | + ), | ||
| 490 | + ), | ||
| 491 | + BottomNavigationBarItem( | ||
| 492 | + icon: Image( | ||
| 465 | image: AssetImage("assets/message_default.png"), | 493 | image: AssetImage("assets/message_default.png"), |
| 466 | width: ScreenUtil().setWidth(48), | 494 | width: ScreenUtil().setWidth(48), |
| 467 | height: ScreenUtil().setWidth(48), | 495 | height: ScreenUtil().setWidth(48), |
| @@ -474,7 +502,7 @@ class HomePageState extends State<HomePage> with WidgetsBindingObserver { | @@ -474,7 +502,7 @@ class HomePageState extends State<HomePage> with WidgetsBindingObserver { | ||
| 474 | title: Text( | 502 | title: Text( |
| 475 | "消息中心", | 503 | "消息中心", |
| 476 | style: TextStyle( | 504 | style: TextStyle( |
| 477 | - color: _currIndex == 0 ? _activeColor : _defaultColor, | 505 | + color: _currIndex == 1 ? _activeColor : _defaultColor, |
| 478 | fontSize: ScreenUtil().setSp(22)), | 506 | fontSize: ScreenUtil().setSp(22)), |
| 479 | ), | 507 | ), |
| 480 | ), | 508 | ), |
| @@ -510,7 +538,7 @@ class HomePageState extends State<HomePage> with WidgetsBindingObserver { | @@ -510,7 +538,7 @@ class HomePageState extends State<HomePage> with WidgetsBindingObserver { | ||
| 510 | title: Text( | 538 | title: Text( |
| 511 | "已预订", | 539 | "已预订", |
| 512 | style: TextStyle( | 540 | style: TextStyle( |
| 513 | - color: _currIndex == 1 ? _activeColor : _defaultColor, | 541 | + color: _currIndex == 2 ? _activeColor : _defaultColor, |
| 514 | fontSize: ScreenUtil().setSp(22)), | 542 | fontSize: ScreenUtil().setSp(22)), |
| 515 | ), | 543 | ), |
| 516 | ), | 544 | ), |
| @@ -528,7 +556,7 @@ class HomePageState extends State<HomePage> with WidgetsBindingObserver { | @@ -528,7 +556,7 @@ class HomePageState extends State<HomePage> with WidgetsBindingObserver { | ||
| 528 | title: Text( | 556 | title: Text( |
| 529 | "桌位", | 557 | "桌位", |
| 530 | style: TextStyle( | 558 | style: TextStyle( |
| 531 | - color: _currIndex == 2 ? _activeColor : _defaultColor, | 559 | + color: _currIndex == 3 ? _activeColor : _defaultColor, |
| 532 | fontSize: ScreenUtil().setSp(22)), | 560 | fontSize: ScreenUtil().setSp(22)), |
| 533 | ), | 561 | ), |
| 534 | ), | 562 | ), |
| @@ -546,7 +574,7 @@ class HomePageState extends State<HomePage> with WidgetsBindingObserver { | @@ -546,7 +574,7 @@ class HomePageState extends State<HomePage> with WidgetsBindingObserver { | ||
| 546 | title: Text( | 574 | title: Text( |
| 547 | "我的", | 575 | "我的", |
| 548 | style: TextStyle( | 576 | style: TextStyle( |
| 549 | - color: _currIndex == 3 ? _activeColor : _defaultColor, | 577 | + color: _currIndex == 4 ? _activeColor : _defaultColor, |
| 550 | fontSize: ScreenUtil().setSp(22)), | 578 | fontSize: ScreenUtil().setSp(22)), |
| 551 | ), | 579 | ), |
| 552 | ), | 580 | ), |
| 1 | +import 'dart:convert'; | ||
| 2 | +import 'dart:ui'; | ||
| 3 | + | ||
| 4 | +import 'package:common_utils/common_utils.dart'; | ||
| 5 | + | ||
| 6 | +// import 'package:contacts_service/contacts_service.dart'; | ||
| 7 | +import 'package:flutter/material.dart'; | ||
| 8 | +import 'package:flutter/services.dart'; | ||
| 9 | +import 'package:flutter_screenutil/screenutil.dart'; | ||
| 10 | +import 'package:one_key/models/notebook_detail.dart'; | ||
| 11 | +import 'package:one_key/models/remark.dart'; | ||
| 12 | +import 'package:one_key/models/reserve_info_model.dart'; | ||
| 13 | +import 'package:one_key/provider/home_enter_model.dart'; | ||
| 14 | +import 'package:one_key/provider/notebook_detail_change_model.dart'; | ||
| 15 | +import 'package:one_key/provider/notebook_detail_model.dart'; | ||
| 16 | +import 'package:one_key/provider/remark_manager_model.dart'; | ||
| 17 | +import 'package:one_key/provider/user_model.dart'; | ||
| 18 | +import 'package:one_key/res/colors.dart'; | ||
| 19 | +import 'package:one_key/utils/dialog_util.dart'; | ||
| 20 | +import 'package:one_key/utils/event_bus.dart'; | ||
| 21 | +import 'package:one_key/utils/misc.dart'; | ||
| 22 | +import 'package:one_key/route/navigator_util.dart'; | ||
| 23 | +import 'package:one_key/utils/triangle_custom_painter.dart'; | ||
| 24 | +import 'package:one_key/utils/utils.dart'; | ||
| 25 | +import 'package:one_key/widgets/MyDivider.dart'; | ||
| 26 | +import 'package:one_key/widgets/app_bar.dart'; | ||
| 27 | +import 'package:one_key/widgets/common_button.dart'; | ||
| 28 | +import 'package:one_key/widgets/h_empty_view.dart'; | ||
| 29 | +import 'package:one_key/widgets/new_table_item.dart'; | ||
| 30 | +import 'package:one_key/widgets/round_button.dart'; | ||
| 31 | +import 'package:one_key/widgets/system_app_bar.dart'; | ||
| 32 | +import 'package:one_key/widgets/v_empty_view.dart'; | ||
| 33 | +import 'package:permission_handler/permission_handler.dart'; | ||
| 34 | +import 'package:provider/provider.dart'; | ||
| 35 | +import 'package:one_key/models/table_list.dart' as t; | ||
| 36 | +import 'dart:convert' as convert; | ||
| 37 | +import 'package:easy_contact_picker/easy_contact_picker.dart'; | ||
| 38 | + | ||
| 39 | +typedef ClickCallback = void Function(String value); | ||
| 40 | + | ||
| 41 | +class HomeEnterPage extends StatefulWidget { | ||
| 42 | + const HomeEnterPage({Key key}) : super(key: key); | ||
| 43 | + | ||
| 44 | + @override | ||
| 45 | + _HomeEnterPageState createState() => _HomeEnterPageState(); | ||
| 46 | +} | ||
| 47 | + | ||
| 48 | +class _HomeEnterPageState extends State<HomeEnterPage> { | ||
| 49 | + DateTime dateTimeNow; //当前日期 | ||
| 50 | + HomeEnterModel _homeEnterModel; | ||
| 51 | + FocusNode _phoneNode = FocusNode(); | ||
| 52 | + FocusNode _nameNode = FocusNode(); | ||
| 53 | + FocusNode _needNode = FocusNode(); | ||
| 54 | + NotebookDetailModel detailModel = NotebookDetailModel(); | ||
| 55 | + EasyContactPicker _contactPicker = EasyContactPicker(); | ||
| 56 | + RemarkManagerModel remarkManagerModel; | ||
| 57 | + String currentRemark = ''; | ||
| 58 | + | ||
| 59 | + bool showPhoneHistory = false; //显示客户历史记录 | ||
| 60 | + | ||
| 61 | + String sid = ""; //商户id | ||
| 62 | + | ||
| 63 | + ScrollController _controller = ScrollController(); | ||
| 64 | + NotebookDetail detailEntity; | ||
| 65 | + | ||
| 66 | + UserModel userModel; | ||
| 67 | + String dateText = ""; //当前显示日期时间 | ||
| 68 | + int currTimeIndex; //当前选中时间段 | ||
| 69 | + String morning; //早市时间段 | ||
| 70 | + String noon; //午市时间段 | ||
| 71 | + String night; //晚市时间段 | ||
| 72 | + String pnum = '6'; //人数 默认6 | ||
| 73 | + int selectPnum = 5; //选中的人数 | ||
| 74 | + @override | ||
| 75 | + void initState() { | ||
| 76 | + super.initState(); | ||
| 77 | + dateTimeNow = DateTime.now(); | ||
| 78 | + | ||
| 79 | + WidgetsBinding.instance.addPostFrameCallback((timeStamp) { | ||
| 80 | + _initTime(); | ||
| 81 | + setState(() {}); | ||
| 82 | + sid = Provider.of<UserModel>(context, listen: false).user.sellerid; | ||
| 83 | + _homeEnterModel.initDateHourMinuteList(context, currTimeIndex); | ||
| 84 | + String ddate = DateTime.now().millisecondsSinceEpoch.toString() + '000'; | ||
| 85 | + _homeEnterModel | ||
| 86 | + .getNewTableList(context, ddate, currTimeIndex.toString(), pnum, []); | ||
| 87 | + | ||
| 88 | + Map<String, String> params = { | ||
| 89 | + "uid": Provider.of<UserModel>(context, listen: false).user.openid | ||
| 90 | + }; | ||
| 91 | + remarkManagerModel.getRemarks(context, params); | ||
| 92 | + }); | ||
| 93 | + } | ||
| 94 | + | ||
| 95 | + @override | ||
| 96 | + void dispose() { | ||
| 97 | + _nameNode.unfocus(); | ||
| 98 | + _phoneNode.unfocus(); | ||
| 99 | + super.dispose(); | ||
| 100 | + } | ||
| 101 | + | ||
| 102 | + //初始化时间 | ||
| 103 | + _initTime() { | ||
| 104 | + dateTimeNow = DateTime.now(); | ||
| 105 | + dateText = "${dateTimeNow.year}" + | ||
| 106 | + "-" + | ||
| 107 | + Utils.addZeroNumber(dateTimeNow.month) + | ||
| 108 | + "-" + | ||
| 109 | + Utils.addZeroNumber(dateTimeNow.day); | ||
| 110 | + morning = | ||
| 111 | + userModel.user.morning.isEmpty ? "00:00-00:00" : userModel.user.morning; | ||
| 112 | + noon = userModel.user.noon.isEmpty ? "00:00-00:00" : userModel.user.noon; | ||
| 113 | + night = userModel.user.night.isEmpty ? "00:00-00:00" : userModel.user.night; | ||
| 114 | + if (morning != '' && | ||
| 115 | + dateTimeNow.isBefore(DateTime.parse(dateTimeNow.year.toString() + | ||
| 116 | + "-" + | ||
| 117 | + Utils.addZeroNumber(dateTimeNow.month) + | ||
| 118 | + "-" + | ||
| 119 | + Utils.addZeroNumber(dateTimeNow.day) + | ||
| 120 | + " " + | ||
| 121 | + morning.split("-")[1] + | ||
| 122 | + ":00"))) { | ||
| 123 | + //未过早市 | ||
| 124 | + currTimeIndex = 1; | ||
| 125 | + } else if (noon != '' && | ||
| 126 | + dateTimeNow.isAfter(DateTime.parse(dateTimeNow.year.toString() + | ||
| 127 | + "-" + | ||
| 128 | + Utils.addZeroNumber(dateTimeNow.month) + | ||
| 129 | + "-" + | ||
| 130 | + Utils.addZeroNumber(dateTimeNow.day) + | ||
| 131 | + " " + | ||
| 132 | + morning.split("-")[1] + | ||
| 133 | + ":00")) && | ||
| 134 | + dateTimeNow.isBefore(DateTime.parse(dateTimeNow.year.toString() + | ||
| 135 | + "-" + | ||
| 136 | + Utils.addZeroNumber(dateTimeNow.month) + | ||
| 137 | + "-" + | ||
| 138 | + Utils.addZeroNumber(dateTimeNow.day) + | ||
| 139 | + " " + | ||
| 140 | + noon.split("-")[1] + | ||
| 141 | + ":00"))) { | ||
| 142 | + //过了早市,未过午市 | ||
| 143 | + currTimeIndex = 2; | ||
| 144 | + } else if (night != '' && | ||
| 145 | + dateTimeNow.isAfter(DateTime.parse(dateTimeNow.year.toString() + | ||
| 146 | + "-" + | ||
| 147 | + Utils.addZeroNumber(dateTimeNow.month) + | ||
| 148 | + "-" + | ||
| 149 | + Utils.addZeroNumber(dateTimeNow.day) + | ||
| 150 | + " " + | ||
| 151 | + noon.split("-")[1] + | ||
| 152 | + ":00")) && | ||
| 153 | + dateTimeNow.isBefore(DateTime.parse(dateTimeNow.year.toString() + | ||
| 154 | + "-" + | ||
| 155 | + Utils.addZeroNumber(dateTimeNow.month) + | ||
| 156 | + "-" + | ||
| 157 | + Utils.addZeroNumber(dateTimeNow.day) + | ||
| 158 | + " " + | ||
| 159 | + night.split("-")[1] + | ||
| 160 | + ":00"))) { | ||
| 161 | + //过了午市,未过晚市 | ||
| 162 | + currTimeIndex = 3; | ||
| 163 | + } else { | ||
| 164 | + //过了晚市 | ||
| 165 | + currTimeIndex = 3; | ||
| 166 | + } | ||
| 167 | + } | ||
| 168 | + | ||
| 169 | + // _initData() { | ||
| 170 | + // print(widget.detailEntity); | ||
| 171 | + // for (var item in widget.detailEntity.tables) { | ||
| 172 | + // item.selected = true; | ||
| 173 | + // } | ||
| 174 | + // } | ||
| 175 | + | ||
| 176 | + _buttonChoose(String title, ClickCallback callback) { | ||
| 177 | + return InkWell( | ||
| 178 | + onTap: () { | ||
| 179 | + callback(title); | ||
| 180 | + }, | ||
| 181 | + child: Container( | ||
| 182 | + padding: EdgeInsets.symmetric( | ||
| 183 | + horizontal: ScreenUtil().setWidth(20), | ||
| 184 | + vertical: ScreenUtil().setWidth(10)), | ||
| 185 | + height: ScreenUtil().setWidth(60), | ||
| 186 | + decoration: BoxDecoration( | ||
| 187 | + border: Border.all( | ||
| 188 | + width: ScreenUtil().setWidth(2), | ||
| 189 | + color: MyColours.color_199095), | ||
| 190 | + borderRadius: BorderRadius.circular(ScreenUtil().setWidth(10))), | ||
| 191 | + child: Row( | ||
| 192 | + children: [ | ||
| 193 | + Text( | ||
| 194 | + title, | ||
| 195 | + style: TextStyle( | ||
| 196 | + color: title == '时间(选填)' | ||
| 197 | + ? MyColours.color_999999 | ||
| 198 | + : MyColours.color_199095, | ||
| 199 | + fontSize: ScreenUtil().setWidth(28)), | ||
| 200 | + ), | ||
| 201 | + HEmptyView(10), | ||
| 202 | + Image.asset( | ||
| 203 | + Utils.getImgPath('enter_order_arrow'), | ||
| 204 | + width: ScreenUtil().setWidth(20), | ||
| 205 | + height: ScreenUtil().setWidth(10), | ||
| 206 | + ) | ||
| 207 | + ], | ||
| 208 | + ))); | ||
| 209 | + } | ||
| 210 | + | ||
| 211 | + _topWidget() { | ||
| 212 | + return Container( | ||
| 213 | + padding: EdgeInsets.symmetric( | ||
| 214 | + horizontal: ScreenUtil().setWidth(40), | ||
| 215 | + vertical: ScreenUtil().setWidth(50)), | ||
| 216 | + child: Column( | ||
| 217 | + children: [ | ||
| 218 | + //第一行 顾客姓名 | ||
| 219 | + Row( | ||
| 220 | + mainAxisAlignment: MainAxisAlignment.spaceBetween, | ||
| 221 | + crossAxisAlignment: CrossAxisAlignment.center, | ||
| 222 | + children: [ | ||
| 223 | + Expanded( | ||
| 224 | + child: TextField( | ||
| 225 | + maxLines: 1, | ||
| 226 | + | ||
| 227 | + //输入文本的样式 | ||
| 228 | + style: TextStyle( | ||
| 229 | + fontSize: ScreenUtil().setSp(34), | ||
| 230 | + color: MyColours.color_353535), | ||
| 231 | + controller: _homeEnterModel.nameController, | ||
| 232 | + focusNode: _nameNode, | ||
| 233 | + // textAlignVertical: TextAlignVertical.top, | ||
| 234 | + decoration: InputDecoration( | ||
| 235 | + hintText: "顾客姓名", | ||
| 236 | + hintStyle: TextStyle( | ||
| 237 | + color: MyColours.color_999999, | ||
| 238 | + fontSize: ScreenUtil().setSp(34), | ||
| 239 | + ), | ||
| 240 | + // contentPadding: | ||
| 241 | + // EdgeInsets.only(bottom: ScreenUtil().setWidth(17)), | ||
| 242 | + border: InputBorder.none, | ||
| 243 | + ), | ||
| 244 | + onChanged: (value) { | ||
| 245 | + print('ggg'); | ||
| 246 | + }, | ||
| 247 | + onEditingComplete: () { | ||
| 248 | + print('fff'); | ||
| 249 | + _nameNode.unfocus(); | ||
| 250 | + }, | ||
| 251 | + keyboardType: TextInputType.text, | ||
| 252 | + ), | ||
| 253 | + ), | ||
| 254 | + HEmptyView(40), | ||
| 255 | + Row( | ||
| 256 | + children: _homeEnterModel.sexList.map((value) { | ||
| 257 | + return _callButton( | ||
| 258 | + onPress: () { | ||
| 259 | + for (var item in _homeEnterModel.sexList) { | ||
| 260 | + item['select'] = false; | ||
| 261 | + if (item['title'] == value['title']) { | ||
| 262 | + item['select'] = true; | ||
| 263 | + } | ||
| 264 | + } | ||
| 265 | + _homeEnterModel.notifyListeners(); | ||
| 266 | + }, | ||
| 267 | + content: value['title'], | ||
| 268 | + hasLeftBorder: value['hasLeftBorder'], | ||
| 269 | + isSelect: value['select']); | ||
| 270 | + }).toList()), | ||
| 271 | + ], | ||
| 272 | + ), | ||
| 273 | + VEmptyView(30), | ||
| 274 | + MyDivider(double.infinity, ScreenUtil().setWidth(2), | ||
| 275 | + color: MyColours.color_efefef), | ||
| 276 | + //电话 | ||
| 277 | + VEmptyView(50), | ||
| 278 | + Row( | ||
| 279 | + mainAxisAlignment: MainAxisAlignment.spaceBetween, | ||
| 280 | + crossAxisAlignment: CrossAxisAlignment.center, | ||
| 281 | + children: [ | ||
| 282 | + Expanded( | ||
| 283 | + child: TextField( | ||
| 284 | + maxLines: 1, | ||
| 285 | + //输入文本的样式 | ||
| 286 | + style: TextStyle( | ||
| 287 | + fontSize: ScreenUtil().setSp(34), | ||
| 288 | + color: MyColours.color_353535), | ||
| 289 | + controller: _homeEnterModel.phoneController, | ||
| 290 | + focusNode: _phoneNode, | ||
| 291 | + // textAlignVertical: TextAlignVertical.top, | ||
| 292 | + decoration: InputDecoration( | ||
| 293 | + hintText: "电话", | ||
| 294 | + hintStyle: TextStyle( | ||
| 295 | + color: MyColours.color_999999, | ||
| 296 | + fontSize: ScreenUtil().setSp(34), | ||
| 297 | + ), | ||
| 298 | + // contentPadding: | ||
| 299 | + // EdgeInsets.only(bottom: ScreenUtil().setWidth(17)), | ||
| 300 | + border: InputBorder.none, | ||
| 301 | + ), | ||
| 302 | + onChanged: (value) { | ||
| 303 | + LogUtil.v("value:$value"); | ||
| 304 | + if (value.isEmpty || value.length >= 11) { | ||
| 305 | + //内容为空,或 超过11位 | ||
| 306 | + setState(() { | ||
| 307 | + _homeEnterModel.userHistorys.clear(); | ||
| 308 | + }); | ||
| 309 | + return; | ||
| 310 | + } | ||
| 311 | + Map<String, String> params = { | ||
| 312 | + "keywords": value, | ||
| 313 | + "sid": sid | ||
| 314 | + }; | ||
| 315 | + _homeEnterModel.getUserHistorys(context, params); | ||
| 316 | + }, | ||
| 317 | + onEditingComplete: () { | ||
| 318 | + print('fff'); | ||
| 319 | + _phoneNode.unfocus(); | ||
| 320 | + }, | ||
| 321 | + onTap: () { | ||
| 322 | + setState(() { | ||
| 323 | + showPhoneHistory = true; | ||
| 324 | + }); | ||
| 325 | + // Future.delayed(Duration(milliseconds: 300), () { | ||
| 326 | + // _controller.jumpTo(_controller.position.maxScrollExtent); | ||
| 327 | + // }); | ||
| 328 | + }, | ||
| 329 | + keyboardType: TextInputType.number, | ||
| 330 | + ), | ||
| 331 | + ), | ||
| 332 | + HEmptyView(40), | ||
| 333 | + InkWell( | ||
| 334 | + onTap: () { | ||
| 335 | + _openAddressBook(); | ||
| 336 | + }, | ||
| 337 | + child: Container( | ||
| 338 | + height: ScreenUtil().setWidth(48), | ||
| 339 | + alignment: Alignment.center, | ||
| 340 | + child: Text( | ||
| 341 | + '一键录入', | ||
| 342 | + style: TextStyle( | ||
| 343 | + color: MyColours.color_199095, | ||
| 344 | + fontSize: ScreenUtil().setSp(30)), | ||
| 345 | + ), | ||
| 346 | + ), | ||
| 347 | + ), | ||
| 348 | + ], | ||
| 349 | + ), | ||
| 350 | + VEmptyView(30), | ||
| 351 | + MyDivider(double.infinity, ScreenUtil().setWidth(2), | ||
| 352 | + color: MyColours.color_efefef), | ||
| 353 | + //备注 | ||
| 354 | + VEmptyView(50), | ||
| 355 | + Row( | ||
| 356 | + children: [ | ||
| 357 | + Expanded( | ||
| 358 | + child: TextField( | ||
| 359 | + maxLines: 1, | ||
| 360 | + inputFormatters: [LengthLimitingTextInputFormatter(25)], | ||
| 361 | + //输入文本的样式 | ||
| 362 | + style: TextStyle( | ||
| 363 | + fontSize: ScreenUtil().setSp(34), | ||
| 364 | + color: MyColours.color_353535), | ||
| 365 | + controller: _homeEnterModel.customController, | ||
| 366 | + focusNode: _needNode, | ||
| 367 | + // textAlignVertical: TextAlignVertical.top, | ||
| 368 | + decoration: InputDecoration( | ||
| 369 | + hintText: "备注(选填)", | ||
| 370 | + hintStyle: TextStyle( | ||
| 371 | + color: MyColours.color_999999, | ||
| 372 | + fontSize: ScreenUtil().setSp(34), | ||
| 373 | + ), | ||
| 374 | + // contentPadding: | ||
| 375 | + // EdgeInsets.only(bottom: ScreenUtil().setWidth(17)), | ||
| 376 | + border: InputBorder.none, | ||
| 377 | + ), | ||
| 378 | + onChanged: (value) { | ||
| 379 | + print(value); | ||
| 380 | + currentRemark = value; | ||
| 381 | + // print(); | ||
| 382 | + }, | ||
| 383 | + onEditingComplete: () { | ||
| 384 | + print('fff'); | ||
| 385 | + _needNode.unfocus(); | ||
| 386 | + }, | ||
| 387 | + // keyboardType: TextInputType.number, | ||
| 388 | + )), | ||
| 389 | + InkWell( | ||
| 390 | + onTap: () { | ||
| 391 | + DialogUtil.showRemarkDialog( | ||
| 392 | + context, remarkManagerModel.ofenRemarks, (item) { | ||
| 393 | + int index = remarkManagerModel.ofenRemarks.indexOf(item); | ||
| 394 | + _refreshRemark(remarkManagerModel.ofenRemarks, index); | ||
| 395 | + }); | ||
| 396 | + }, | ||
| 397 | + child: Container( | ||
| 398 | + margin: EdgeInsets.only(left: ScreenUtil().setWidth(40)), | ||
| 399 | + width: ScreenUtil().setWidth(122), | ||
| 400 | + height: ScreenUtil().setWidth(42), | ||
| 401 | + child: Text( | ||
| 402 | + '常用备注', | ||
| 403 | + style: TextStyle( | ||
| 404 | + fontSize: ScreenUtil().setSp(30), | ||
| 405 | + color: MyColours.color_199095), | ||
| 406 | + ), | ||
| 407 | + ), | ||
| 408 | + ), | ||
| 409 | + ], | ||
| 410 | + ), | ||
| 411 | + VEmptyView(30), | ||
| 412 | + MyDivider(double.infinity, ScreenUtil().setWidth(2), | ||
| 413 | + color: MyColours.color_efefef), | ||
| 414 | + //日期2020-01-01 ***** 早餐/午餐/晚餐 ***** 时间段16:30 | ||
| 415 | + VEmptyView(50), | ||
| 416 | + Row( | ||
| 417 | + // mainAxisAlignment: MainAxisAlignment.spaceAround, | ||
| 418 | + children: [ | ||
| 419 | + _buttonChoose(dateText, (value) { | ||
| 420 | + if (dateText == '') { | ||
| 421 | + _calendWidget(DateTime.now()); | ||
| 422 | + } else { | ||
| 423 | + // bool isThird = true; | ||
| 424 | + _calendWidget(dateTimeNow); | ||
| 425 | + } | ||
| 426 | + }), | ||
| 427 | + HEmptyView(40), | ||
| 428 | + _buttonChoose( | ||
| 429 | + currTimeIndex == 1 | ||
| 430 | + ? '早餐' | ||
| 431 | + : currTimeIndex == 2 | ||
| 432 | + ? '午餐' | ||
| 433 | + : '晚餐', (value) { | ||
| 434 | + FocusScope.of(context).requestFocus(FocusNode()); //隐藏键盘 | ||
| 435 | + List<String> temp = []; | ||
| 436 | + for (int i = 0; i < _homeEnterModel.sunDateList.length; i++) { | ||
| 437 | + temp.add(_homeEnterModel.sunDateList[i]['dateText']); | ||
| 438 | + } | ||
| 439 | + _showMorningAndNightChooseWidget(context, temp); | ||
| 440 | + }), | ||
| 441 | + HEmptyView(40), | ||
| 442 | + _buttonChoose( | ||
| 443 | + _homeEnterModel.ddateStr == '' || | ||
| 444 | + _homeEnterModel.isSetDate == '0' | ||
| 445 | + ? '时间(选填)' | ||
| 446 | + : _homeEnterModel.ddateStr, (value) { | ||
| 447 | + FocusScope.of(context).requestFocus(FocusNode()); //隐藏键盘 | ||
| 448 | + _showDateChooseWidget(context); | ||
| 449 | + }), | ||
| 450 | + ], | ||
| 451 | + ), | ||
| 452 | + VEmptyView(40), | ||
| 453 | + Row( | ||
| 454 | + children: [ | ||
| 455 | + Text('预计人数', | ||
| 456 | + style: TextStyle( | ||
| 457 | + color: MyColours.color_199095, | ||
| 458 | + fontSize: ScreenUtil().setWidth(28))), | ||
| 459 | + HEmptyView(20), | ||
| 460 | + _buttonChoose(pnum, (value) { | ||
| 461 | + FocusScope.of(context).requestFocus(FocusNode()); //隐藏键盘 | ||
| 462 | + DialogUtil.showSelectCusmanDialog( | ||
| 463 | + context, _homeEnterModel.personNumList, (value) { | ||
| 464 | + if (value != null) { | ||
| 465 | + setState(() { | ||
| 466 | + selectPnum = value.first; | ||
| 467 | + pnum = _homeEnterModel.personNumList[value.first]; | ||
| 468 | + }); | ||
| 469 | + String ymyStr = dateText; //年月日 | ||
| 470 | + String timeStr = ymyStr + ' ' + "00:00:00"; | ||
| 471 | + int ddate = DateUtil.getDateMsByTimeStr(timeStr); //筛选日期时间戳 | ||
| 472 | + // String pnum = Utils.getPnum(_homeEnterModel.personNumList); | ||
| 473 | + _homeEnterModel.getNewTableList( | ||
| 474 | + context, | ||
| 475 | + '${ddate}', | ||
| 476 | + currTimeIndex.toString(), | ||
| 477 | + pnum, | ||
| 478 | + _homeEnterModel.tableList); | ||
| 479 | + _homeEnterModel.notifyListeners(); | ||
| 480 | + } | ||
| 481 | + }, selecteds: selectPnum == null ? [] : [selectPnum]) | ||
| 482 | + .then((value) {}); | ||
| 483 | + }), | ||
| 484 | + HEmptyView(20), | ||
| 485 | + Text('人', | ||
| 486 | + style: TextStyle( | ||
| 487 | + color: MyColours.color_199095, | ||
| 488 | + fontSize: ScreenUtil().setWidth(28))), | ||
| 489 | + ], | ||
| 490 | + ), | ||
| 491 | + // Row( | ||
| 492 | + // mainAxisAlignment: MainAxisAlignment.spaceBetween, | ||
| 493 | + // children: _homeEnterModel.dateList.map((value) { | ||
| 494 | + // return CustomButton( | ||
| 495 | + // dateText: value['title'].toString().length <= 5 | ||
| 496 | + // ? value['title'].toString() | ||
| 497 | + // : value['title'].toString().substring(5), | ||
| 498 | + // fontSize: value['fontSize'], | ||
| 499 | + // dayText: value['dayText'], | ||
| 500 | + // isImage: value['isImage'], | ||
| 501 | + // isSelect: value['select'], | ||
| 502 | + // onTap: () async { | ||
| 503 | + // print(value['title']); | ||
| 504 | + // FocusScope.of(context) | ||
| 505 | + // .requestFocus(FocusNode()); //点击空白处隐藏键盘 | ||
| 506 | + // if (value['title'] == '其他') { | ||
| 507 | + // _calendWidget(DateTime.now()); | ||
| 508 | + // } else { | ||
| 509 | + // for (int j = 0; | ||
| 510 | + // j < _homeEnterModel.dateList.length; | ||
| 511 | + // j++) { | ||
| 512 | + // _homeEnterModel.dateList[j]['select'] = false; | ||
| 513 | + | ||
| 514 | + // if (_homeEnterModel.dateList[j]['title'] == | ||
| 515 | + // value['title']) { | ||
| 516 | + // _homeEnterModel.dateList[j]['select'] = true; | ||
| 517 | + // if (j == 0 || j == 1) { | ||
| 518 | + // _homeEnterModel.dateList[2]['title'] = '其他'; | ||
| 519 | + // } | ||
| 520 | + // if (j == _homeEnterModel.dateList.length - 1) { | ||
| 521 | + // String selectStr = _homeEnterModel.dateList[2] | ||
| 522 | + // ['title'] + | ||
| 523 | + // " 00:00:00"; | ||
| 524 | + // _calendWidget(DateUtil.getDateTime(selectStr)); | ||
| 525 | + // } | ||
| 526 | + // } | ||
| 527 | + // } | ||
| 528 | + // _homeEnterModel.initHourAndMinuteSelect(); | ||
| 529 | + // //选完今天明天刷新页面 | ||
| 530 | + // int ddate = Utils.getDdate(_homeEnterModel.dateList); | ||
| 531 | + // String ddateSolt = | ||
| 532 | + // Utils.getDdateSolt(_homeEnterModel.sunDateList); | ||
| 533 | + // // String pnum = | ||
| 534 | + // // Utils.getPnum(_homeEnterModel.personNumList); | ||
| 535 | + // List<t.TableList> list = | ||
| 536 | + // await _homeEnterModel.getNewTableList( | ||
| 537 | + // context, | ||
| 538 | + // '${ddate}', | ||
| 539 | + // ddateSolt, | ||
| 540 | + // pnum, | ||
| 541 | + // _homeEnterModel.tableList); | ||
| 542 | + // if (list.length == 0) { | ||
| 543 | + // _homeEnterModel.isRecommend = true; | ||
| 544 | + // } | ||
| 545 | + // } | ||
| 546 | + // _homeEnterModel.notifyListeners(); | ||
| 547 | + // }, | ||
| 548 | + // ); | ||
| 549 | + // }).toList()), | ||
| 550 | + | ||
| 551 | + // VEmptyView(40), | ||
| 552 | + // //早市、午市、晚市 | ||
| 553 | + // Row( | ||
| 554 | + // // mainAxisAlignment: MainAxisAlignment.spaceBetween, | ||
| 555 | + // children: _homeEnterModel.sunDateList.map((value) { | ||
| 556 | + // return Container( | ||
| 557 | + // margin: _homeEnterModel.sunDateList.length == 3 && | ||
| 558 | + // value['ddateSolt'] == 3 | ||
| 559 | + // ? EdgeInsets.only(right: 0) | ||
| 560 | + // : EdgeInsets.only(right: ScreenUtil().setWidth(20)), | ||
| 561 | + // child: CustomButton( | ||
| 562 | + // onTap: () { | ||
| 563 | + // FocusScope.of(context).requestFocus(FocusNode()); //点击空白处隐藏键盘 | ||
| 564 | + // String key = ''; | ||
| 565 | + // for (var item in _homeEnterModel.sunDateList) { | ||
| 566 | + // item['isSelect'] = false; | ||
| 567 | + // if (item['dateText'] == value['dateText']) { | ||
| 568 | + // item['isSelect'] = true; | ||
| 569 | + | ||
| 570 | + // if (item['ddateSolt'] == 1) { | ||
| 571 | + // //早市 | ||
| 572 | + // key = 'morning'; | ||
| 573 | + // } else if (item['ddateSolt'] == 2) { | ||
| 574 | + // //午市 | ||
| 575 | + // key = 'noon'; | ||
| 576 | + // } else if (item['ddateSolt'] == 3) { | ||
| 577 | + // //晚市 | ||
| 578 | + // key = 'night'; | ||
| 579 | + // } | ||
| 580 | + // } | ||
| 581 | + // } | ||
| 582 | + // _homeEnterModel.initHourAndMinuteSelect(); | ||
| 583 | + // if (key != '') { | ||
| 584 | + // for (var sunitem in _homeEnterModel.dailyMap[key]) { | ||
| 585 | + // if (sunitem['select'] == true) { | ||
| 586 | + // _homeEnterModel.ddateStr = sunitem['title']; | ||
| 587 | + // } | ||
| 588 | + // } | ||
| 589 | + // } | ||
| 590 | + // _homeEnterModel.notifyListeners(); | ||
| 591 | + // int ddate = Utils.getDdate(_homeEnterModel.dateList); | ||
| 592 | + // // String pnum = Utils.getPnum(_homeEnterModel.personNumList); | ||
| 593 | + // String ddateSolt = | ||
| 594 | + // Utils.getDdateSolt(_homeEnterModel.sunDateList); | ||
| 595 | + // _homeEnterModel.getNewTableList(context, '${ddate}', | ||
| 596 | + // '${ddateSolt}', pnum, _homeEnterModel.tableList); | ||
| 597 | + // }, | ||
| 598 | + // dateText: value['dateText'], | ||
| 599 | + // dayText: '', | ||
| 600 | + // isSelect: value['isSelect'], | ||
| 601 | + // ), | ||
| 602 | + // ); | ||
| 603 | + // }).toList()), | ||
| 604 | + // VEmptyView(40), | ||
| 605 | + | ||
| 606 | + // ///人数选择 | ||
| 607 | + // Row( | ||
| 608 | + // mainAxisAlignment: MainAxisAlignment.spaceBetween, | ||
| 609 | + // children: _homeEnterModel.personNumList.map((value) { | ||
| 610 | + // return CustomButton( | ||
| 611 | + // onTap: () { | ||
| 612 | + // for (int j = 0; | ||
| 613 | + // j < _homeEnterModel.personNumList.length; | ||
| 614 | + // j++) { | ||
| 615 | + // _homeEnterModel.personNumList[j]['isSelect'] = false; | ||
| 616 | + | ||
| 617 | + // if (_homeEnterModel.personNumList[j]['dateText'] == | ||
| 618 | + // value['dateText']) { | ||
| 619 | + // _homeEnterModel.personNumList[j]['isSelect'] = true; | ||
| 620 | + | ||
| 621 | + // if (j < 5) { | ||
| 622 | + // _homeEnterModel.numController.text = value['dateText']; | ||
| 623 | + // FocusScope.of(context) | ||
| 624 | + // .requestFocus(FocusNode()); //点击空白处隐藏键盘 | ||
| 625 | + | ||
| 626 | + // } | ||
| 627 | + | ||
| 628 | + // // if (j < 5) { | ||
| 629 | + // // _homeEnterModel.personNumList[5] | ||
| 630 | + // // ['dateText'] = '更多'; | ||
| 631 | + // // } | ||
| 632 | + // } | ||
| 633 | + // } | ||
| 634 | + // _homeEnterModel.notifyListeners(); | ||
| 635 | + // //人数选择页面刷新 | ||
| 636 | + // // String pnum = Utils.getPnum(_homeEnterModel.personNumList); | ||
| 637 | + // int ddate = Utils.getDdate(_homeEnterModel.dateList); | ||
| 638 | + // String ddateSolt = | ||
| 639 | + // Utils.getDdateSolt(_homeEnterModel.sunDateList); | ||
| 640 | + | ||
| 641 | + // _homeEnterModel.getNewTableList(context, '${ddate}', | ||
| 642 | + // ddateSolt, pnum, _homeEnterModel.tableList); | ||
| 643 | + // }, | ||
| 644 | + // dateText: value['dateText'], | ||
| 645 | + // fontSize: value['fontSize'], | ||
| 646 | + // dayText: '', | ||
| 647 | + // width: value['width'], | ||
| 648 | + // isImage: value['isImage'], | ||
| 649 | + // isSelect: value['isSelect'], | ||
| 650 | + // isTextFiled: value['isTextFiled'], | ||
| 651 | + // model: _homeEnterModel, | ||
| 652 | + // ); | ||
| 653 | + // }).toList(), | ||
| 654 | + // ), | ||
| 655 | + // VEmptyView(20), | ||
| 656 | + ], | ||
| 657 | + ), | ||
| 658 | + ); | ||
| 659 | + } | ||
| 660 | + | ||
| 661 | + _calendWidget(DateTime dateTime) { | ||
| 662 | + FocusScope.of(context).requestFocus(FocusNode()); //隐藏键盘 | ||
| 663 | + DialogUtil.showCalendarDialog(context, dateTime).then((day) { | ||
| 664 | + if (day != null) { | ||
| 665 | + // _createDateText(day); | ||
| 666 | + dateTimeNow = day; | ||
| 667 | + int dateTimeMill = day.millisecondsSinceEpoch; | ||
| 668 | + dateText = DateUtil.formatDateMs(dateTimeMill, format: 'yyyy-MM-dd'); | ||
| 669 | + // bool isThird = true; | ||
| 670 | + // for (int i = 0; i < _homeEnterModel.dateList.length; i++) { | ||
| 671 | + // _homeEnterModel.dateList[i]['select'] = false; | ||
| 672 | + | ||
| 673 | + // if (_homeEnterModel.dateList[i]['title'] == dateText) { | ||
| 674 | + // _homeEnterModel.dateList[i]['select'] = true; | ||
| 675 | + // isThird = false; | ||
| 676 | + // } | ||
| 677 | + // } | ||
| 678 | + // if (isThird) { | ||
| 679 | + // _homeEnterModel.dateList[2]['select'] = true; | ||
| 680 | + // _homeEnterModel.dateList[2]['title'] = dateText; | ||
| 681 | + // } else { | ||
| 682 | + // _homeEnterModel.dateList[2]['title'] = '其他'; | ||
| 683 | + // } | ||
| 684 | + _homeEnterModel.initHourAndMinuteSelect(); | ||
| 685 | + // 选完日历刷新页面 | ||
| 686 | + | ||
| 687 | + // String pnum = Utils.getPnum(_homeEnterModel.personNumList); | ||
| 688 | + _homeEnterModel.getNewTableList(context, '${dateTimeMill}', | ||
| 689 | + currTimeIndex.toString(), pnum, _homeEnterModel.tableList); | ||
| 690 | + } | ||
| 691 | + _homeEnterModel.notifyListeners(); | ||
| 692 | + }); | ||
| 693 | + } | ||
| 694 | + | ||
| 695 | + /// 可订桌位 | ||
| 696 | + _middleWidget() { | ||
| 697 | + List canBookTable = []; | ||
| 698 | + if (_homeEnterModel.isRecommend) { | ||
| 699 | + canBookTable = _homeEnterModel.recommendList; | ||
| 700 | + } else { | ||
| 701 | + canBookTable = _homeEnterModel.tableList; | ||
| 702 | + } | ||
| 703 | + return Container( | ||
| 704 | + padding: EdgeInsets.all(ScreenUtil().setWidth(40)), | ||
| 705 | + color: MyColours.color_f5f5f5, | ||
| 706 | + child: Column( | ||
| 707 | + children: [ | ||
| 708 | + InkWell( | ||
| 709 | + onTap: () async { | ||
| 710 | + FocusScope.of(context).requestFocus(FocusNode()); //点击空白处隐藏键盘 | ||
| 711 | + String ymyStr = dateText; //年月日 | ||
| 712 | + String timeStr = ymyStr + ' ' + "00:00:00"; | ||
| 713 | + int ddate = DateUtil.getDateMsByTimeStr(timeStr); //筛选日期时间戳 | ||
| 714 | + String ddateSolt = currTimeIndex.toString(); | ||
| 715 | + | ||
| 716 | + // String tempDdate = ymyStr + ' ' + ddateStr + ':00'; | ||
| 717 | + // int ddate = DateUtil.getDateMsByTimeStr(timeStr); | ||
| 718 | + Map temp = await NavigatorUtil.goSelectTablePage( | ||
| 719 | + context, '', ddate, ddateSolt, | ||
| 720 | + canChoose: true, | ||
| 721 | + object: {'object': _homeEnterModel.tableList}); | ||
| 722 | + // if (temp['tid'] != null) { | ||
| 723 | + // setReserveStatus("5", tid: temp['tid']); | ||
| 724 | + // } | ||
| 725 | + if (temp == null || temp['object'].length == 0) { | ||
| 726 | + if (_homeEnterModel.tableList.length == 0) { | ||
| 727 | + _homeEnterModel.isRecommend = true; | ||
| 728 | + _homeEnterModel.tableList = []; | ||
| 729 | + for (t.TableList item in _homeEnterModel.recommendList) { | ||
| 730 | + item.selected = false; | ||
| 731 | + } | ||
| 732 | + setState(() {}); | ||
| 733 | + } | ||
| 734 | + } else { | ||
| 735 | + _homeEnterModel.isRecommend = false; | ||
| 736 | + _homeEnterModel.tableList = temp['object']; | ||
| 737 | + // if (_homeEnterModel.tableList.length == 0) { | ||
| 738 | + // isRecommend = true; | ||
| 739 | + // } | ||
| 740 | + for (t.TableList item in _homeEnterModel.tableList) { | ||
| 741 | + item.selected = true; | ||
| 742 | + } | ||
| 743 | + setState(() {}); | ||
| 744 | + } | ||
| 745 | + | ||
| 746 | + // _homeEnterModel.notifyListeners(); | ||
| 747 | + }, | ||
| 748 | + child: Row( | ||
| 749 | + mainAxisAlignment: MainAxisAlignment.spaceBetween, | ||
| 750 | + crossAxisAlignment: CrossAxisAlignment.end, | ||
| 751 | + children: [ | ||
| 752 | + Text( | ||
| 753 | + '可订桌位', | ||
| 754 | + style: TextStyle( | ||
| 755 | + color: MyColours.color_353535, | ||
| 756 | + fontSize: ScreenUtil().setSp(30)), | ||
| 757 | + ), | ||
| 758 | + Row( | ||
| 759 | + children: [ | ||
| 760 | + Text('更多', | ||
| 761 | + style: TextStyle( | ||
| 762 | + color: MyColours.color_353535, | ||
| 763 | + fontSize: ScreenUtil().setSp(26))), | ||
| 764 | + HEmptyView(20), | ||
| 765 | + Image.asset( | ||
| 766 | + 'assets/arr_right_gray.png', | ||
| 767 | + width: ScreenUtil().setWidth(12), | ||
| 768 | + height: ScreenUtil().setWidth(22), | ||
| 769 | + ) | ||
| 770 | + ], | ||
| 771 | + ), | ||
| 772 | + ], | ||
| 773 | + )), | ||
| 774 | + VEmptyView(32), | ||
| 775 | + Align( | ||
| 776 | + alignment: Alignment.centerRight, | ||
| 777 | + child: Container( | ||
| 778 | + // color: Colors.red, | ||
| 779 | + // height: ScreenUtil().setHeight(178), | ||
| 780 | + height: ScreenUtil().setWidth(185), | ||
| 781 | + child: ListView.builder( | ||
| 782 | + physics: const NeverScrollableScrollPhysics(), | ||
| 783 | + itemBuilder: (BuildContext contxt, int index) { | ||
| 784 | + return NewTableItem( | ||
| 785 | + canBookTable[index], | ||
| 786 | + isRegionName: true, | ||
| 787 | + canSelected: true, | ||
| 788 | + onSelected: (table) { | ||
| 789 | + if ((table as t.TableList).selected) { | ||
| 790 | + _homeEnterModel.tableList.add(table); | ||
| 791 | + } else { | ||
| 792 | + _homeEnterModel.tableList | ||
| 793 | + .removeWhere((t) => t.id == table.id); | ||
| 794 | + } | ||
| 795 | + }, | ||
| 796 | + ); | ||
| 797 | + }, | ||
| 798 | + itemCount: canBookTable.length > 3 ? 3 : canBookTable.length, | ||
| 799 | + shrinkWrap: true, | ||
| 800 | + scrollDirection: Axis.horizontal, | ||
| 801 | + ), | ||
| 802 | + ), | ||
| 803 | + ), | ||
| 804 | + ], | ||
| 805 | + ), | ||
| 806 | + ); | ||
| 807 | + } | ||
| 808 | + | ||
| 809 | + _refreshRemark(List<Remark> remark, int index) { | ||
| 810 | + if (remark[index].selected) { | ||
| 811 | + if (currentRemark.length == 0) { | ||
| 812 | + currentRemark += '${remark[index].custom}'; | ||
| 813 | + } else { | ||
| 814 | + if (!currentRemark.contains(remark[index].custom)) { | ||
| 815 | + if (currentRemark.endsWith('、')) { | ||
| 816 | + currentRemark += '${remark[index].custom}'; | ||
| 817 | + } else { | ||
| 818 | + currentRemark += '、${remark[index].custom}'; | ||
| 819 | + } | ||
| 820 | + } | ||
| 821 | + } | ||
| 822 | + } else { | ||
| 823 | + if (currentRemark.contains(remark[index].custom)) { | ||
| 824 | + int start = currentRemark.indexOf(remark[index].custom); | ||
| 825 | + int end = start + remark[index].custom.length; | ||
| 826 | + currentRemark = currentRemark.replaceRange(start, end, ''); | ||
| 827 | + if (currentRemark.endsWith('、')) { | ||
| 828 | + currentRemark = currentRemark.substring(0, currentRemark.length - 1); | ||
| 829 | + } | ||
| 830 | + if (currentRemark.startsWith('、')) { | ||
| 831 | + currentRemark = currentRemark.substring(1, currentRemark.length); | ||
| 832 | + } | ||
| 833 | + if (currentRemark.contains('、、')) { | ||
| 834 | + currentRemark = currentRemark.replaceRange( | ||
| 835 | + currentRemark.indexOf('、、'), | ||
| 836 | + currentRemark.indexOf('、、') + 2, | ||
| 837 | + '、'); | ||
| 838 | + } | ||
| 839 | + } | ||
| 840 | + } | ||
| 841 | + if (currentRemark.length > 25) { | ||
| 842 | + currentRemark = currentRemark.substring(0, 25); | ||
| 843 | + } | ||
| 844 | + setState(() { | ||
| 845 | + _homeEnterModel.customController.text = currentRemark; | ||
| 846 | + }); | ||
| 847 | + } | ||
| 848 | + | ||
| 849 | + _getCurruntIndex(String title) { | ||
| 850 | + switch (title) { | ||
| 851 | + case '早餐': | ||
| 852 | + return 1; | ||
| 853 | + case '午餐': | ||
| 854 | + return 2; | ||
| 855 | + case '晚餐': | ||
| 856 | + return 3; | ||
| 857 | + default: | ||
| 858 | + return 4; | ||
| 859 | + } | ||
| 860 | + } | ||
| 861 | + | ||
| 862 | + List<Widget> _eatTimeWidget(List list) { | ||
| 863 | + List<Widget> temp = []; | ||
| 864 | + for (int i = 0; i < list.length; i++) { | ||
| 865 | + temp.add(CustomButton( | ||
| 866 | + onTap: () { | ||
| 867 | + currTimeIndex = _getCurruntIndex(list[i]); | ||
| 868 | + // state(() { | ||
| 869 | + // for (var item in tempMndList) { | ||
| 870 | + // item['select'] = false; | ||
| 871 | + // if (item['title'] == | ||
| 872 | + // tempMndList[index]['title']) { | ||
| 873 | + // item['select'] = true; | ||
| 874 | + | ||
| 875 | + // _homeEnterModel.isSetDate = "1"; | ||
| 876 | + // _homeEnterModel.ddateStr = item['title']; | ||
| 877 | + // } | ||
| 878 | + // } | ||
| 879 | + // }); | ||
| 880 | + if (currTimeIndex == 1) { | ||
| 881 | + _homeEnterModel.ddateStr = '8:00'; | ||
| 882 | + } else if (currTimeIndex == 2) { | ||
| 883 | + _homeEnterModel.ddateStr = '12:00'; | ||
| 884 | + } else if (currTimeIndex == 3) { | ||
| 885 | + _homeEnterModel.ddateStr = '18:30'; | ||
| 886 | + } | ||
| 887 | + // _homeEnterModel.initHourAndMinuteSelect(); | ||
| 888 | +// 刷新页面 | ||
| 889 | + String ymyStr = dateText; //年月日 | ||
| 890 | + String timeStr = ymyStr + ' ' + "00:00:00"; | ||
| 891 | + int ddate = DateUtil.getDateMsByTimeStr(timeStr); //筛选日期时间戳 | ||
| 892 | + // String pnum = Utils.getPnum(_homeEnterModel.personNumList); | ||
| 893 | + _homeEnterModel.getNewTableList(context, '${ddate}', | ||
| 894 | + currTimeIndex.toString(), pnum, _homeEnterModel.tableList); | ||
| 895 | + _homeEnterModel.notifyListeners(); | ||
| 896 | + Navigator.pop(context); | ||
| 897 | + }, | ||
| 898 | + width: 80, | ||
| 899 | + height: 36, | ||
| 900 | + dateText: list[i], | ||
| 901 | + dayText: '', | ||
| 902 | + isSelect: _getCurruntIndex(list[i]) == currTimeIndex, | ||
| 903 | + )); | ||
| 904 | + if (i < list.length - 1) { | ||
| 905 | + temp.add(HEmptyView(80)); | ||
| 906 | + } | ||
| 907 | + } | ||
| 908 | + return temp; | ||
| 909 | + } | ||
| 910 | + | ||
| 911 | + ///底部弹框,早餐,午餐,晚餐 | ||
| 912 | + _showMorningAndNightChooseWidget( | ||
| 913 | + BuildContext context, List<String> list) async { | ||
| 914 | + // List tempMndList = []; | ||
| 915 | + | ||
| 916 | + String title = '用餐时段'; | ||
| 917 | + // String key; | ||
| 918 | + // for (var item in _homeEnterModel.sunDateList) { | ||
| 919 | + // if (item['isSelect'] == true) { | ||
| 920 | + // title = item['dateText']; | ||
| 921 | + // key = item['key']; | ||
| 922 | + // tempMndList = _homeEnterModel.dailyMap[key]; | ||
| 923 | + // } | ||
| 924 | + // } | ||
| 925 | + final option = await showModalBottomSheet( | ||
| 926 | + context: context, | ||
| 927 | + isScrollControlled: true, | ||
| 928 | + backgroundColor: Colors.white, | ||
| 929 | + builder: (context) { | ||
| 930 | + return StatefulBuilder(builder: (context, state) { | ||
| 931 | + return SafeArea( | ||
| 932 | + child: Container( | ||
| 933 | + decoration: BoxDecoration( | ||
| 934 | + borderRadius: | ||
| 935 | + BorderRadius.circular(ScreenUtil().setWidth(10))), | ||
| 936 | + child: Column( | ||
| 937 | + mainAxisSize: MainAxisSize.min, | ||
| 938 | + children: [ | ||
| 939 | + InkWell( | ||
| 940 | + onTap: () { | ||
| 941 | + Navigator.pop(context); | ||
| 942 | + }, | ||
| 943 | + child: Align( | ||
| 944 | + alignment: Alignment.centerRight, | ||
| 945 | + child: Container( | ||
| 946 | + padding: EdgeInsets.fromLTRB( | ||
| 947 | + ScreenUtil().setWidth(40), | ||
| 948 | + ScreenUtil().setWidth(40), | ||
| 949 | + ScreenUtil().setWidth(40), | ||
| 950 | + ScreenUtil().setWidth(10)), | ||
| 951 | + child: Image.asset( | ||
| 952 | + 'assets/close.png', | ||
| 953 | + width: ScreenUtil().setWidth(32), | ||
| 954 | + height: ScreenUtil().setWidth(32), | ||
| 955 | + ), | ||
| 956 | + ), | ||
| 957 | + ), | ||
| 958 | + ), | ||
| 959 | + Center( | ||
| 960 | + child: Text(title, | ||
| 961 | + style: TextStyle( | ||
| 962 | + fontSize: ScreenUtil().setSp(34), | ||
| 963 | + fontWeight: FontWeight.bold, | ||
| 964 | + color: MyColours.color_353535)), | ||
| 965 | + ), | ||
| 966 | + Padding( | ||
| 967 | + padding: EdgeInsets.symmetric( | ||
| 968 | + horizontal: ScreenUtil().setWidth(60), | ||
| 969 | + vertical: ScreenUtil().setWidth(40)), | ||
| 970 | + child: Row( | ||
| 971 | + mainAxisAlignment: MainAxisAlignment.center, | ||
| 972 | + children: _eatTimeWidget(list)), | ||
| 973 | + // child:GridView.builder( | ||
| 974 | + // padding: | ||
| 975 | + // EdgeInsets.only(top: ScreenUtil().setWidth(20)), | ||
| 976 | + // shrinkWrap: true, | ||
| 977 | + // cacheExtent: ScreenUtil().setWidth(0), | ||
| 978 | + // itemCount: list.length, | ||
| 979 | + // gridDelegate: | ||
| 980 | + // SliverGridDelegateWithFixedCrossAxisCount( | ||
| 981 | + // crossAxisCount: list.length, | ||
| 982 | + // childAspectRatio: 80 / 36, | ||
| 983 | + // mainAxisSpacing: | ||
| 984 | + // ScreenUtil().setWidth(15 * 2), | ||
| 985 | + // crossAxisSpacing: | ||
| 986 | + // ScreenUtil().setWidth(40 * 2)), | ||
| 987 | + // itemBuilder: (BuildContext context, int index) { | ||
| 988 | + // // locationState = state; | ||
| 989 | + // return CustomButton( | ||
| 990 | + // onTap: () { | ||
| 991 | + // currTimeIndex = _getCurruntIndex(list[index]); | ||
| 992 | + // // state(() { | ||
| 993 | + // // for (var item in tempMndList) { | ||
| 994 | + // // item['select'] = false; | ||
| 995 | + // // if (item['title'] == | ||
| 996 | + // // tempMndList[index]['title']) { | ||
| 997 | + // // item['select'] = true; | ||
| 998 | + | ||
| 999 | + // // _homeEnterModel.isSetDate = "1"; | ||
| 1000 | + // // _homeEnterModel.ddateStr = item['title']; | ||
| 1001 | + // // } | ||
| 1002 | + // // } | ||
| 1003 | + // // }); | ||
| 1004 | + // if (currTimeIndex == 1) { | ||
| 1005 | + // _homeEnterModel.ddateStr = '8:00'; | ||
| 1006 | + // } else if (currTimeIndex == 2) { | ||
| 1007 | + // _homeEnterModel.ddateStr = '12:00'; | ||
| 1008 | + // } else if (currTimeIndex == 3) { | ||
| 1009 | + // _homeEnterModel.ddateStr = '18:30'; | ||
| 1010 | + // } | ||
| 1011 | + // // _homeEnterModel.initHourAndMinuteSelect(); | ||
| 1012 | + | ||
| 1013 | + // _homeEnterModel.notifyListeners(); | ||
| 1014 | + // Navigator.pop(context); | ||
| 1015 | + // }, | ||
| 1016 | + // width: 80, | ||
| 1017 | + // height: 36, | ||
| 1018 | + // dateText: list[index], | ||
| 1019 | + // dayText: '', | ||
| 1020 | + // isSelect: _getCurruntIndex(list[index]) == | ||
| 1021 | + // currTimeIndex, | ||
| 1022 | + // ); | ||
| 1023 | + // }) | ||
| 1024 | + ), | ||
| 1025 | + VEmptyView(30) | ||
| 1026 | + ], | ||
| 1027 | + ), | ||
| 1028 | + )); | ||
| 1029 | + }); | ||
| 1030 | + }); | ||
| 1031 | + } | ||
| 1032 | + | ||
| 1033 | + ///底部弹框,设置时间30分钟间隔布局 | ||
| 1034 | + _showDateChooseWidget(BuildContext context) async { | ||
| 1035 | + List tempMndList = []; | ||
| 1036 | + | ||
| 1037 | + String title = '早市'; | ||
| 1038 | + String key; | ||
| 1039 | + for (var item in _homeEnterModel.sunDateList) { | ||
| 1040 | + int tempIndex = _getCurruntIndex(item['dateText']); | ||
| 1041 | + if (currTimeIndex == tempIndex) { | ||
| 1042 | + title = item['dateText']; | ||
| 1043 | + key = item['key']; | ||
| 1044 | + tempMndList = _homeEnterModel.dailyMap[key]; | ||
| 1045 | + } | ||
| 1046 | + // if (item['isSelect'] == true) { | ||
| 1047 | + | ||
| 1048 | + // } | ||
| 1049 | + } | ||
| 1050 | + final option = await showModalBottomSheet( | ||
| 1051 | + context: context, | ||
| 1052 | + isScrollControlled: true, | ||
| 1053 | + backgroundColor: Colors.white, | ||
| 1054 | + builder: (context) { | ||
| 1055 | + return StatefulBuilder(builder: (context, state) { | ||
| 1056 | + return SafeArea( | ||
| 1057 | + child: Container( | ||
| 1058 | + decoration: BoxDecoration( | ||
| 1059 | + borderRadius: | ||
| 1060 | + BorderRadius.circular(ScreenUtil().setWidth(10))), | ||
| 1061 | + child: Column( | ||
| 1062 | + mainAxisSize: MainAxisSize.min, | ||
| 1063 | + children: [ | ||
| 1064 | + InkWell( | ||
| 1065 | + onTap: () { | ||
| 1066 | + Navigator.pop(context); | ||
| 1067 | + }, | ||
| 1068 | + child: Align( | ||
| 1069 | + alignment: Alignment.centerRight, | ||
| 1070 | + child: Container( | ||
| 1071 | + padding: EdgeInsets.fromLTRB( | ||
| 1072 | + ScreenUtil().setWidth(40), | ||
| 1073 | + ScreenUtil().setWidth(40), | ||
| 1074 | + ScreenUtil().setWidth(40), | ||
| 1075 | + ScreenUtil().setWidth(10)), | ||
| 1076 | + child: Image.asset( | ||
| 1077 | + 'assets/close.png', | ||
| 1078 | + width: ScreenUtil().setWidth(32), | ||
| 1079 | + height: ScreenUtil().setWidth(32), | ||
| 1080 | + ), | ||
| 1081 | + ), | ||
| 1082 | + ), | ||
| 1083 | + ), | ||
| 1084 | + Center( | ||
| 1085 | + child: Text(title, | ||
| 1086 | + style: TextStyle( | ||
| 1087 | + fontSize: ScreenUtil().setSp(34), | ||
| 1088 | + fontWeight: FontWeight.bold, | ||
| 1089 | + color: MyColours.color_353535)), | ||
| 1090 | + ), | ||
| 1091 | + Padding( | ||
| 1092 | + padding: EdgeInsets.symmetric( | ||
| 1093 | + horizontal: ScreenUtil().setWidth(60), | ||
| 1094 | + vertical: ScreenUtil().setWidth(40)), | ||
| 1095 | + child: GridView.builder( | ||
| 1096 | + padding: | ||
| 1097 | + EdgeInsets.only(top: ScreenUtil().setWidth(20)), | ||
| 1098 | + shrinkWrap: true, | ||
| 1099 | + cacheExtent: ScreenUtil().setWidth(0), | ||
| 1100 | + itemCount: tempMndList.length, | ||
| 1101 | + gridDelegate: | ||
| 1102 | + SliverGridDelegateWithFixedCrossAxisCount( | ||
| 1103 | + crossAxisCount: 3, | ||
| 1104 | + childAspectRatio: 80 / 36, | ||
| 1105 | + mainAxisSpacing: | ||
| 1106 | + ScreenUtil().setWidth(15 * 2), | ||
| 1107 | + crossAxisSpacing: | ||
| 1108 | + ScreenUtil().setWidth(38 * 2)), | ||
| 1109 | + itemBuilder: (BuildContext context, int index) { | ||
| 1110 | + // locationState = state; | ||
| 1111 | + return CustomButton( | ||
| 1112 | + onTap: () { | ||
| 1113 | + // state(() { | ||
| 1114 | + for (var item in tempMndList) { | ||
| 1115 | + item['select'] = false; | ||
| 1116 | + if (item['title'] == | ||
| 1117 | + tempMndList[index]['title']) { | ||
| 1118 | + item['select'] = true; | ||
| 1119 | + | ||
| 1120 | + _homeEnterModel.isSetDate = "1"; | ||
| 1121 | + _homeEnterModel.ddateStr = item['title']; | ||
| 1122 | + } | ||
| 1123 | + } | ||
| 1124 | + // }); | ||
| 1125 | + String ymyStr = dateText; //年月日 | ||
| 1126 | + String timeStr = ymyStr + ' ' + "00:00:00"; | ||
| 1127 | + int ddate = DateUtil.getDateMsByTimeStr( | ||
| 1128 | + timeStr); //筛选日期时间戳 | ||
| 1129 | + // String pnum = Utils.getPnum(_homeEnterModel.personNumList); | ||
| 1130 | + _homeEnterModel.getNewTableList( | ||
| 1131 | + context, | ||
| 1132 | + '${ddate}', | ||
| 1133 | + currTimeIndex.toString(), | ||
| 1134 | + pnum, | ||
| 1135 | + _homeEnterModel.tableList); | ||
| 1136 | + | ||
| 1137 | + _homeEnterModel.notifyListeners(); | ||
| 1138 | + Navigator.pop(context); | ||
| 1139 | + }, | ||
| 1140 | + width: 80, | ||
| 1141 | + height: 36, | ||
| 1142 | + dateText: tempMndList[index]['title'].toString(), | ||
| 1143 | + dayText: '', | ||
| 1144 | + isSelect: tempMndList[index]['select'], | ||
| 1145 | + ); | ||
| 1146 | + })) | ||
| 1147 | + ], | ||
| 1148 | + ), | ||
| 1149 | + )); | ||
| 1150 | + }); | ||
| 1151 | + }); | ||
| 1152 | + } | ||
| 1153 | + | ||
| 1154 | + Widget _callButton( | ||
| 1155 | + {GestureTapCallback onPress, | ||
| 1156 | + content, | ||
| 1157 | + hasLeftBorder = true, | ||
| 1158 | + isSelect = false}) { | ||
| 1159 | + return InkWell( | ||
| 1160 | + onTap: onPress, | ||
| 1161 | + child: Container( | ||
| 1162 | + width: ScreenUtil().setWidth(84), | ||
| 1163 | + height: ScreenUtil().setHeight(48), | ||
| 1164 | + decoration: BoxDecoration( | ||
| 1165 | + color: isSelect ? MyColours.color_199095 : MyColours.color_fefefe, | ||
| 1166 | + border: Border( | ||
| 1167 | + bottom: BorderSide( | ||
| 1168 | + color: MyColours.color_6AB6B9, | ||
| 1169 | + width: ScreenUtil().setWidth(2)), | ||
| 1170 | + top: BorderSide( | ||
| 1171 | + color: MyColours.color_6AB6B9, | ||
| 1172 | + width: ScreenUtil().setWidth(2)), | ||
| 1173 | + left: hasLeftBorder | ||
| 1174 | + ? BorderSide( | ||
| 1175 | + color: MyColours.color_6AB6B9, | ||
| 1176 | + width: ScreenUtil().setWidth(2)) | ||
| 1177 | + : BorderSide.none, | ||
| 1178 | + right: BorderSide( | ||
| 1179 | + color: MyColours.color_6AB6B9, | ||
| 1180 | + width: ScreenUtil().setWidth(2)))), | ||
| 1181 | + child: Align( | ||
| 1182 | + alignment: Alignment.center, | ||
| 1183 | + child: Text( | ||
| 1184 | + content, | ||
| 1185 | + style: TextStyle( | ||
| 1186 | + color: isSelect ? Colors.white : MyColours.color_353535, | ||
| 1187 | + fontSize: ScreenUtil().setSp(28)), | ||
| 1188 | + ), | ||
| 1189 | + ), | ||
| 1190 | + ), | ||
| 1191 | + ); | ||
| 1192 | + } | ||
| 1193 | + | ||
| 1194 | + _openAddressBook() async { | ||
| 1195 | + if (!(await checkContactPermission())) { | ||
| 1196 | + PermissionStatus permissionStatus = await contactPermissionStatus(); | ||
| 1197 | + if (permissionStatus == PermissionStatus.permanentlyDenied) { | ||
| 1198 | + //用户选择不在弹出权限提示框 | ||
| 1199 | + print('never'); | ||
| 1200 | + DialogUtil.openAlertDialog( | ||
| 1201 | + context, '未获得通讯录权限', "请在手机的权限管理里,将通讯录权限开启", '去设置', 340.0, | ||
| 1202 | + onTap: () { | ||
| 1203 | + openSetting(); | ||
| 1204 | + Navigator.pop(context, ''); | ||
| 1205 | + }); | ||
| 1206 | + } else { | ||
| 1207 | + // 申请权限 | ||
| 1208 | + bool canContacts = await requestContactPermission(); | ||
| 1209 | + if (canContacts) { | ||
| 1210 | + _getContactData(); | ||
| 1211 | + } else { | ||
| 1212 | + //拒绝通讯录权限 , 苹果拒绝权限后,不再提示权限框,进入此处 | ||
| 1213 | + DialogUtil.openAlertDialog( | ||
| 1214 | + context, '未获得通讯录权限', "请在手机的权限管理里,将通讯录权限开启。", '去设置', 340.0, | ||
| 1215 | + onTap: () { | ||
| 1216 | + openSetting(); | ||
| 1217 | + Navigator.pop(context, ''); | ||
| 1218 | + }); | ||
| 1219 | + } | ||
| 1220 | + } | ||
| 1221 | + } else { | ||
| 1222 | + _getContactData(); | ||
| 1223 | + } | ||
| 1224 | + } | ||
| 1225 | + | ||
| 1226 | + _getContactData() async { | ||
| 1227 | + Contact contact = await _contactPicker.selectContactWithNative(); | ||
| 1228 | + setState(() { | ||
| 1229 | + String fullName = | ||
| 1230 | + contact.fullName.replaceAll(new RegExp(r"\s+\b|\b\s"), ""); | ||
| 1231 | + String phone = | ||
| 1232 | + contact.phoneNumber.replaceAll(new RegExp(r"\s+\b|\b\s"), ""); | ||
| 1233 | + if (fullName.compareTo(phone) == 0) { | ||
| 1234 | + fullName = ''; | ||
| 1235 | + } else { | ||
| 1236 | + fullName = contact.fullName; | ||
| 1237 | + } | ||
| 1238 | + _homeEnterModel.phoneController.text = contact.phoneNumber; | ||
| 1239 | + _homeEnterModel.nameController.text = fullName; | ||
| 1240 | + }); | ||
| 1241 | + } | ||
| 1242 | + | ||
| 1243 | + @override | ||
| 1244 | + Widget build(BuildContext context) { | ||
| 1245 | + _homeEnterModel = Provider.of<HomeEnterModel>(context, listen: true); | ||
| 1246 | + userModel = Provider.of<UserModel>(context, listen: false); | ||
| 1247 | + remarkManagerModel = Provider.of<RemarkManagerModel>(context, listen: true); | ||
| 1248 | + return GestureDetector( | ||
| 1249 | + behavior: HitTestBehavior.translucent, | ||
| 1250 | + onTap: () { | ||
| 1251 | + FocusScope.of(context).requestFocus(FocusNode()); //点击空白处隐藏键盘 | ||
| 1252 | + }, | ||
| 1253 | + child: Scaffold( | ||
| 1254 | + backgroundColor: Colors.white, | ||
| 1255 | + body: Column(children: <Widget>[ | ||
| 1256 | + SystemAppBar( | ||
| 1257 | + '录入预订', | ||
| 1258 | + showLeading: false, | ||
| 1259 | + rightImgName: '清空', | ||
| 1260 | + onTapRight: () async { | ||
| 1261 | + _initTime(); | ||
| 1262 | + | ||
| 1263 | + _homeEnterModel.nameController.text = ''; | ||
| 1264 | + _homeEnterModel.phoneController.text = ''; | ||
| 1265 | + _homeEnterModel.customController.text = ''; | ||
| 1266 | + dateText = ""; //当前显示日期时间 | ||
| 1267 | + // currTimeIndex = null; | ||
| 1268 | + _homeEnterModel.ddateStr = ''; | ||
| 1269 | + pnum = '6'; | ||
| 1270 | + selectPnum = 5; | ||
| 1271 | + dateTimeNow = DateTime.now(); | ||
| 1272 | + dateText = "${dateTimeNow.year}" + | ||
| 1273 | + "-" + | ||
| 1274 | + Utils.addZeroNumber(dateTimeNow.month) + | ||
| 1275 | + "-" + | ||
| 1276 | + Utils.addZeroNumber(dateTimeNow.day); | ||
| 1277 | + String ddate = | ||
| 1278 | + DateTime.now().millisecondsSinceEpoch.toString() + '000'; | ||
| 1279 | + await _homeEnterModel.getNewTableList( | ||
| 1280 | + context, ddate, currTimeIndex.toString(), pnum, []); | ||
| 1281 | + FocusScope.of(context).requestFocus(FocusNode()); //点击空白处隐藏键盘 | ||
| 1282 | + _homeEnterModel.notifyListeners(); | ||
| 1283 | + }, | ||
| 1284 | + ), | ||
| 1285 | + Expanded( | ||
| 1286 | + child: SingleChildScrollView( | ||
| 1287 | + controller: _controller, | ||
| 1288 | + child: Column( | ||
| 1289 | + children: [ | ||
| 1290 | + _topWidget(), | ||
| 1291 | + _middleWidget(), | ||
| 1292 | + // _bottomWidget() | ||
| 1293 | + ], | ||
| 1294 | + ))), | ||
| 1295 | + Container( | ||
| 1296 | + padding: EdgeInsets.symmetric( | ||
| 1297 | + horizontal: ScreenUtil().setWidth(36), | ||
| 1298 | + vertical: ScreenUtil().setWidth(30), | ||
| 1299 | + ), | ||
| 1300 | + child: CommonButton( | ||
| 1301 | + width: double.infinity, | ||
| 1302 | + height: 84, | ||
| 1303 | + fontSize: 34, | ||
| 1304 | + content: "完成预订", | ||
| 1305 | + state: 2, | ||
| 1306 | + onPress: () async { | ||
| 1307 | + String name = _homeEnterModel.nameController.text.trim(); | ||
| 1308 | + if (ObjectUtil.isEmpty(name)) { | ||
| 1309 | + Utils.showToast("请填写客户姓名"); | ||
| 1310 | + return; | ||
| 1311 | + } | ||
| 1312 | + if (_homeEnterModel.tableList.length == 0) { | ||
| 1313 | + Utils.showToast("请选择桌位"); | ||
| 1314 | + return; | ||
| 1315 | + } | ||
| 1316 | + SunReserveInfoModel _model = | ||
| 1317 | + await _homeEnterModel.setReserveInfo(context); | ||
| 1318 | + if (ObjectUtil.isNotEmpty(_model.row) || | ||
| 1319 | + ObjectUtil.isNotEmpty(_model.row.id)) { | ||
| 1320 | + print('成功'); | ||
| 1321 | + // _homeEnterModel.clearData(); | ||
| 1322 | + bus.emit("refresh_detail"); | ||
| 1323 | + bus.emit("refresh_book_list"); //刷新已预订列表 | ||
| 1324 | + String ddate_solt = ''; | ||
| 1325 | + if (_model.row.isSetDdate == '1') { | ||
| 1326 | + String createtime = _model.row.ddate.toString() + '000'; | ||
| 1327 | + DateTime createTime = | ||
| 1328 | + DateTime.fromMillisecondsSinceEpoch( | ||
| 1329 | + int.parse(createtime)); | ||
| 1330 | + ddate_solt = DateUtil.formatDate(createTime, | ||
| 1331 | + format: DateFormats.h_m); | ||
| 1332 | + } else { | ||
| 1333 | + if (_model.row.ddateSolt == '1') { | ||
| 1334 | + ddate_solt = '早餐'; | ||
| 1335 | + } else if (_model.row.ddateSolt == '2') { | ||
| 1336 | + ddate_solt = '午餐'; | ||
| 1337 | + } else if (_model.row.ddateSolt == '3') { | ||
| 1338 | + ddate_solt = '晚餐'; | ||
| 1339 | + } | ||
| 1340 | + } | ||
| 1341 | + List<dynamic> tableinfo = | ||
| 1342 | + convert.jsonDecode(_model.row.tableinfo); | ||
| 1343 | + print(tableinfo); | ||
| 1344 | + String _nameStr = t.TableList.fromJson(tableinfo[0]).name; | ||
| 1345 | + if (tableinfo.length > 1) { | ||
| 1346 | + _nameStr = t.TableList.fromJson(tableinfo[0]).name + | ||
| 1347 | + '等${tableinfo.length}桌'; | ||
| 1348 | + } | ||
| 1349 | + LogUtil.v(_nameStr); | ||
| 1350 | + NavigatorUtil.goInvicationPage( | ||
| 1351 | + context, | ||
| 1352 | + _model.row.id, | ||
| 1353 | + _nameStr, | ||
| 1354 | + _model.row.ddate, | ||
| 1355 | + ddate_solt, | ||
| 1356 | + _model.row.phone, | ||
| 1357 | + replace: true); | ||
| 1358 | + EventBus().emit("refresh_tablemanager"); //刷新桌位 | ||
| 1359 | + } else { | ||
| 1360 | + Utils.showToast("录入预订订单失败,请重试!"); | ||
| 1361 | + } | ||
| 1362 | + }, | ||
| 1363 | + )) | ||
| 1364 | + ]), | ||
| 1365 | + )); | ||
| 1366 | + } | ||
| 1367 | +} | ||
| 1368 | + | ||
| 1369 | +class CustomButton extends StatefulWidget { | ||
| 1370 | + final String dateText; | ||
| 1371 | + final String dayText; | ||
| 1372 | + final bool isSelect; | ||
| 1373 | + final double fontSize; | ||
| 1374 | + final bool isImage; | ||
| 1375 | + final double width; | ||
| 1376 | + final GestureTapCallback onTap; | ||
| 1377 | + final bool isTextFiled; | ||
| 1378 | + final HomeEnterModel model; | ||
| 1379 | + final double height; | ||
| 1380 | + final String pnum; | ||
| 1381 | + | ||
| 1382 | + const CustomButton({ | ||
| 1383 | + Key key, | ||
| 1384 | + this.dateText, | ||
| 1385 | + this.dayText, | ||
| 1386 | + this.isSelect, | ||
| 1387 | + this.fontSize = 34, | ||
| 1388 | + this.isImage = false, | ||
| 1389 | + this.width = 105, | ||
| 1390 | + this.onTap, | ||
| 1391 | + this.isTextFiled = false, | ||
| 1392 | + this.model, | ||
| 1393 | + this.height = 25, | ||
| 1394 | + this.pnum, | ||
| 1395 | + }) : super(key: key); | ||
| 1396 | + | ||
| 1397 | + @override | ||
| 1398 | + _ButtonState createState() => _ButtonState(); | ||
| 1399 | +} | ||
| 1400 | + | ||
| 1401 | +class _ButtonState extends State<CustomButton> { | ||
| 1402 | + FocusNode _cancelNode = FocusNode(); | ||
| 1403 | + | ||
| 1404 | + @override | ||
| 1405 | + Widget build(BuildContext context) { | ||
| 1406 | + String imgStrSelect = widget.isImage && !widget.isTextFiled | ||
| 1407 | + ? 'assets/calender_select.png' | ||
| 1408 | + : 'assets/more_select.png'; | ||
| 1409 | + String imgStrNormal = widget.isImage && !widget.isTextFiled | ||
| 1410 | + ? 'assets/calender_narmol.png' | ||
| 1411 | + : 'assets/more_narmol.png'; | ||
| 1412 | + return InkWell( | ||
| 1413 | + onTap: widget.onTap, | ||
| 1414 | + child: Container( | ||
| 1415 | + width: ScreenUtil().setWidth(widget.width * 2), | ||
| 1416 | + height: ScreenUtil().setWidth(widget.height * 2), | ||
| 1417 | + decoration: BoxDecoration( | ||
| 1418 | + color: widget.isSelect ? MyColours.color_199095 : Colors.white, | ||
| 1419 | + borderRadius: BorderRadius.circular(ScreenUtil().setWidth(10)), | ||
| 1420 | + border: Border.all( | ||
| 1421 | + color: MyColours.color_199095, | ||
| 1422 | + width: ScreenUtil().setWidth(2))), | ||
| 1423 | + child: Row( | ||
| 1424 | + mainAxisAlignment: MainAxisAlignment.center, | ||
| 1425 | + children: [ | ||
| 1426 | + widget.isTextFiled | ||
| 1427 | + ? Container( | ||
| 1428 | + alignment: Alignment.center, | ||
| 1429 | + // color: Colors.red, | ||
| 1430 | + width: ScreenUtil().setWidth(114), | ||
| 1431 | + height: ScreenUtil().setWidth(50), | ||
| 1432 | + // padding: EdgeInsets.zero, | ||
| 1433 | + child: TextField( | ||
| 1434 | + controller: widget.model.numController, | ||
| 1435 | + maxLines: 1, | ||
| 1436 | + | ||
| 1437 | + inputFormatters: [ | ||
| 1438 | + LengthLimitingTextInputFormatter(3), | ||
| 1439 | + WhitelistingTextInputFormatter.digitsOnly | ||
| 1440 | + ], | ||
| 1441 | + //光标颜色 | ||
| 1442 | + cursorColor: widget.isSelect | ||
| 1443 | + ? Colors.white | ||
| 1444 | + : MyColours.color_199095, | ||
| 1445 | + //输入文本的样式 | ||
| 1446 | + style: TextStyle( | ||
| 1447 | + fontSize: ScreenUtil().setSp(30), | ||
| 1448 | + color: widget.isSelect | ||
| 1449 | + ? Colors.white | ||
| 1450 | + : MyColours.color_199095), | ||
| 1451 | + // controller: _cancelController, | ||
| 1452 | + focusNode: _cancelNode, | ||
| 1453 | + textAlignVertical: TextAlignVertical.bottom, | ||
| 1454 | + decoration: InputDecoration( | ||
| 1455 | + // fillColor: Colors.lightGreenAccent, | ||
| 1456 | + // filled: true, | ||
| 1457 | + border: OutlineInputBorder(borderSide: BorderSide.none), | ||
| 1458 | + hintText: "更多", | ||
| 1459 | + hintStyle: TextStyle( | ||
| 1460 | + color: widget.isSelect | ||
| 1461 | + ? Colors.white | ||
| 1462 | + : MyColours.color_199095, | ||
| 1463 | + fontSize: ScreenUtil().setSp(30), | ||
| 1464 | + ), | ||
| 1465 | + // contentPadding: EdgeInsets.only( | ||
| 1466 | + // bottom: ScreenUtil().setWidth(30)), //ios 17 | ||
| 1467 | + // border: InputBorder.none, | ||
| 1468 | + ), | ||
| 1469 | + onChanged: (value) { | ||
| 1470 | + bool isThird = true; | ||
| 1471 | + for (int i = 0; | ||
| 1472 | + i < widget.model.personNumList.length; | ||
| 1473 | + i++) { | ||
| 1474 | + widget.model.personNumList[i]['isSelect'] = false; | ||
| 1475 | + | ||
| 1476 | + if (widget.model.personNumList[i]['dateText'] == | ||
| 1477 | + value) { | ||
| 1478 | + widget.model.personNumList[i]['isSelect'] = true; | ||
| 1479 | + isThird = false; | ||
| 1480 | + } | ||
| 1481 | + } | ||
| 1482 | + if (isThird) { | ||
| 1483 | + widget.model.personNumList[5]['isSelect'] = true; | ||
| 1484 | + widget.model.personNumList[5]['dateText'] = value; | ||
| 1485 | + } else { | ||
| 1486 | + widget.model.personNumList[5]['dateText'] = '更多'; | ||
| 1487 | + } | ||
| 1488 | + widget.model.notifyListeners(); | ||
| 1489 | + }, | ||
| 1490 | + onEditingComplete: () { | ||
| 1491 | + _cancelNode.unfocus(); | ||
| 1492 | + int ddate = Utils.getDdate(widget.model.dateList); | ||
| 1493 | + String ddateSolt = | ||
| 1494 | + Utils.getDdateSolt(widget.model.sunDateList); | ||
| 1495 | + // String pnum = Utils.getPnum(widget.model.personNumList); | ||
| 1496 | + | ||
| 1497 | + widget.model.getNewTableList(context, '${ddate}', | ||
| 1498 | + ddateSolt, widget.pnum, widget.model.tableList); | ||
| 1499 | + }, | ||
| 1500 | + keyboardType: TextInputType.number, | ||
| 1501 | + ), | ||
| 1502 | + ) | ||
| 1503 | + : Text(widget.dateText, | ||
| 1504 | + style: TextStyle( | ||
| 1505 | + fontWeight: widget.isImage && widget.dateText == "其他" | ||
| 1506 | + ? FontWeight.normal | ||
| 1507 | + : FontWeight.bold, | ||
| 1508 | + color: widget.isSelect | ||
| 1509 | + ? MyColours.color_fefefe | ||
| 1510 | + : MyColours.color_199095, | ||
| 1511 | + fontSize: ScreenUtil().setSp(widget.fontSize))), | ||
| 1512 | + widget.isImage && !widget.isTextFiled | ||
| 1513 | + ? HEmptyView(20) | ||
| 1514 | + : Container(), | ||
| 1515 | + widget.isImage | ||
| 1516 | + ? Image.asset(widget.isSelect ? imgStrSelect : imgStrNormal, | ||
| 1517 | + width: ScreenUtil().setWidth(36)) | ||
| 1518 | + : Text(widget.dayText, | ||
| 1519 | + style: TextStyle( | ||
| 1520 | + fontWeight: FontWeight.bold, | ||
| 1521 | + color: widget.isSelect | ||
| 1522 | + ? MyColours.color_fefefe | ||
| 1523 | + : MyColours.color_199095, | ||
| 1524 | + fontSize: ScreenUtil().setSp(30))) | ||
| 1525 | + ], | ||
| 1526 | + ), | ||
| 1527 | + ), | ||
| 1528 | + ); | ||
| 1529 | + } | ||
| 1530 | +} | ||
| 1531 | + | ||
| 1532 | +Widget remarkButton({GestureTapCallback onPress, content, isSelect = false}) { | ||
| 1533 | + return InkWell( | ||
| 1534 | + onTap: onPress, | ||
| 1535 | + child: Container( | ||
| 1536 | + height: ScreenUtil().setHeight(48), | ||
| 1537 | + margin: EdgeInsets.only(right: ScreenUtil().setWidth(20)), | ||
| 1538 | + padding: EdgeInsets.symmetric( | ||
| 1539 | + horizontal: ScreenUtil().setWidth(20), | ||
| 1540 | + vertical: ScreenUtil().setWidth(6)), | ||
| 1541 | + decoration: BoxDecoration( | ||
| 1542 | + borderRadius: BorderRadius.circular(ScreenUtil().setWidth(10)), | ||
| 1543 | + color: isSelect ? MyColours.color_199095 : MyColours.color_f5f5f5, | ||
| 1544 | + ), | ||
| 1545 | + child: Align( | ||
| 1546 | + alignment: Alignment.center, | ||
| 1547 | + child: Text( | ||
| 1548 | + content, | ||
| 1549 | + style: TextStyle( | ||
| 1550 | + color: isSelect ? Colors.white : MyColours.color_353535, | ||
| 1551 | + fontSize: ScreenUtil().setSp(28)), | ||
| 1552 | + ), | ||
| 1553 | + ), | ||
| 1554 | + ), | ||
| 1555 | + ); | ||
| 1556 | +} |
lib/provider/home_enter_model.dart
0 → 100644
| 1 | +import 'package:common_utils/common_utils.dart'; | ||
| 2 | +import 'package:flutter/material.dart'; | ||
| 3 | +import 'package:one_key/app.dart'; | ||
| 4 | +import 'package:one_key/constant/constant.dart'; | ||
| 5 | +import 'package:one_key/models/notebook_detail.dart'; | ||
| 6 | +import 'package:one_key/models/reserve_info_model.dart'; | ||
| 7 | +import 'package:one_key/models/seller_info.dart'; | ||
| 8 | +import 'package:one_key/models/table_list.dart'; | ||
| 9 | +import 'package:one_key/models/user_history_entity.dart'; | ||
| 10 | +import 'package:one_key/net/base_resp.dart'; | ||
| 11 | +import 'package:one_key/net/dio_util.dart'; | ||
| 12 | +import 'package:one_key/net/http_url.dart'; | ||
| 13 | +import 'package:one_key/provider/notebook_detail_model.dart'; | ||
| 14 | +import 'package:one_key/provider/user_model.dart'; | ||
| 15 | +import 'package:one_key/utils/utils.dart'; | ||
| 16 | +import 'package:provider/provider.dart'; | ||
| 17 | + | ||
| 18 | +class HomeEnterModel with ChangeNotifier { | ||
| 19 | + List dateList = []; //日期选择 月-日 某天 | ||
| 20 | + List sunDateList = []; // 早市、午市、晚市 | ||
| 21 | + List personNumList = []; // 人数 | ||
| 22 | + TextEditingController numController = TextEditingController(); //人数 | ||
| 23 | + TextEditingController phoneController = TextEditingController(); //电话 | ||
| 24 | + TextEditingController nameController = TextEditingController(); //客户姓名 | ||
| 25 | + TextEditingController customController = TextEditingController(); //客户要求 | ||
| 26 | + List sexList = []; // 先生、女士、公司 | ||
| 27 | + Map dailyMap = {}; // 早市对应半点钟,午市对应半点钟、晚市对应半点钟 | ||
| 28 | + List<String> mornings = []; //早市时间段 | ||
| 29 | + List<String> noons = []; //午市时间段 | ||
| 30 | + List<String> nights = []; //晚市时间段 | ||
| 31 | + String ddateStr = ''; //16:30 | ||
| 32 | + | ||
| 33 | + List<TableList> tableList = []; | ||
| 34 | + String isSetDate = '0'; | ||
| 35 | + List<TableList> recommendList = []; //推荐列表 | ||
| 36 | + bool isRecommend = false; //是否展示推荐 | ||
| 37 | + List oldTableList = []; | ||
| 38 | + | ||
| 39 | + List<UserHistoryEntity> userHistorys = []; //历史录入 | ||
| 40 | + | ||
| 41 | + clearData() { | ||
| 42 | + dateList = []; //日期选择 月-日 某天 | ||
| 43 | + sunDateList = []; // 早市、午市、晚市 | ||
| 44 | + personNumList = []; // 人数 | ||
| 45 | + numController = TextEditingController(); //人数 | ||
| 46 | + phoneController = TextEditingController(); //电话 | ||
| 47 | + nameController = TextEditingController(); //客户姓名 | ||
| 48 | + customController = TextEditingController(); //客户要求 | ||
| 49 | + sexList = []; // 先生、女士、公司 | ||
| 50 | + dailyMap = {}; // 早市对应半点钟,午市对应半点钟、晚市对应半点钟 | ||
| 51 | + ddateStr = ''; //16:30 | ||
| 52 | + tableList = []; | ||
| 53 | + isSetDate = '0'; | ||
| 54 | + } | ||
| 55 | + | ||
| 56 | + //构造函数,初始化 | ||
| 57 | + HomeEnterModel() { | ||
| 58 | + _initDateList(); | ||
| 59 | + _initPersonNumList(); | ||
| 60 | + _initSexList(); | ||
| 61 | + } | ||
| 62 | + | ||
| 63 | + ///初始化 日期选择 月-日 某天 | ||
| 64 | + _initDateList() { | ||
| 65 | + //今天 | ||
| 66 | + DateTime dateTime = DateTime.now(); | ||
| 67 | + int dateTimeMill = dateTime.millisecondsSinceEpoch; | ||
| 68 | + String dateText = DateUtil.formatDateMs(dateTimeMill, format: 'yyyy-MM-dd'); | ||
| 69 | + dateList.add({ | ||
| 70 | + 'title': dateText, | ||
| 71 | + 'select': false, | ||
| 72 | + 'fontSize': 34.0, | ||
| 73 | + 'dayText': ' 今天', | ||
| 74 | + 'isImage': false | ||
| 75 | + }); | ||
| 76 | + //明天 | ||
| 77 | + int tomorrowMill = dateTimeMill + 24 * 60 * 60 * 1000; | ||
| 78 | + String dateTextTomorrow = | ||
| 79 | + DateUtil.formatDateMs(tomorrowMill, format: 'yyyy-MM-dd'); | ||
| 80 | + dateList.add({ | ||
| 81 | + 'title': dateTextTomorrow, | ||
| 82 | + 'select': false, | ||
| 83 | + 'fontSize': 34.0, | ||
| 84 | + 'dayText': ' 明天', | ||
| 85 | + 'isImage': false | ||
| 86 | + }); | ||
| 87 | + //第三个 | ||
| 88 | + dateList.add({ | ||
| 89 | + 'title': '其他', | ||
| 90 | + 'select': false, | ||
| 91 | + 'fontSize': 30.0, | ||
| 92 | + 'dayText': '', | ||
| 93 | + 'isImage': true | ||
| 94 | + }); | ||
| 95 | + } | ||
| 96 | + | ||
| 97 | + /// 初始化 早市、午市、晚市 | ||
| 98 | + _initSunDateList(morning, noon, night, ddateSolt) { | ||
| 99 | + if (morning != '') { | ||
| 100 | + sunDateList.add({ | ||
| 101 | + 'dateText': '早餐', | ||
| 102 | + 'dayText': '', | ||
| 103 | + 'ddateSolt': 1, | ||
| 104 | + 'key': 'morning', | ||
| 105 | + 'isSelect': ddateSolt == 1 ? true : false | ||
| 106 | + }); | ||
| 107 | + } | ||
| 108 | + if (noon != '') { | ||
| 109 | + sunDateList.add({ | ||
| 110 | + 'dateText': '午餐', | ||
| 111 | + 'dayText': '', | ||
| 112 | + 'ddateSolt': 2, | ||
| 113 | + 'key': 'noon', | ||
| 114 | + 'isSelect': ddateSolt == 2 ? true : false | ||
| 115 | + }); | ||
| 116 | + } | ||
| 117 | + if (night != '') { | ||
| 118 | + sunDateList.add({ | ||
| 119 | + 'dateText': '晚餐', | ||
| 120 | + 'dayText': '', | ||
| 121 | + 'ddateSolt': 3, | ||
| 122 | + 'key': 'night', | ||
| 123 | + 'isSelect': ddateSolt == 3 ? true : false | ||
| 124 | + }); | ||
| 125 | + } | ||
| 126 | + initHourAndMinuteSelect(); | ||
| 127 | + notifyListeners(); | ||
| 128 | + } | ||
| 129 | + | ||
| 130 | + //人数 | ||
| 131 | + _initPersonNumList() { | ||
| 132 | + personNumList = []; | ||
| 133 | + for (int i = 1; i < 31; i++) { | ||
| 134 | + personNumList.add(i.toString()); | ||
| 135 | + } | ||
| 136 | + personNumList.add('30以上'); | ||
| 137 | + } | ||
| 138 | + | ||
| 139 | + ///称谓 | ||
| 140 | + _initSexList() { | ||
| 141 | + String sexStr = '1'; | ||
| 142 | + sexList = [ | ||
| 143 | + { | ||
| 144 | + 'title': '先生', | ||
| 145 | + 'select': sexStr == '1' ? true : false, | ||
| 146 | + 'code': '1', | ||
| 147 | + 'hasLeftBorder': true | ||
| 148 | + }, | ||
| 149 | + { | ||
| 150 | + 'title': '女士', | ||
| 151 | + 'select': sexStr == '2' ? true : false, | ||
| 152 | + 'code': '2', | ||
| 153 | + 'hasLeftBorder': false | ||
| 154 | + }, | ||
| 155 | + { | ||
| 156 | + 'title': '公司', | ||
| 157 | + 'select': sexStr == '3' ? true : false, | ||
| 158 | + 'code': '3', | ||
| 159 | + 'hasLeftBorder': false | ||
| 160 | + } | ||
| 161 | + ]; | ||
| 162 | + } | ||
| 163 | + | ||
| 164 | + /// 早市、午市、晚市对应的半个小时间隔时间段 | ||
| 165 | + initDateHourMinuteList(BuildContext context, int index) async { | ||
| 166 | + UserModel userModel = Provider.of<UserModel>(context, listen: false); | ||
| 167 | + userModel.user.morning == '' | ||
| 168 | + ? dailyMap.putIfAbsent('morning', () => '') | ||
| 169 | + : dailyMap.putIfAbsent( | ||
| 170 | + 'morning', () => _getHourAndMinute(userModel.user.morning, 1)); | ||
| 171 | + userModel.user.noon == '' | ||
| 172 | + ? dailyMap.putIfAbsent('noon', () => '') | ||
| 173 | + : dailyMap.putIfAbsent( | ||
| 174 | + 'noon', () => _getHourAndMinute(userModel.user.noon, 2)); | ||
| 175 | + userModel.user.night == '' | ||
| 176 | + ? dailyMap.putIfAbsent('night', () => '') | ||
| 177 | + : dailyMap.putIfAbsent( | ||
| 178 | + 'night', () => _getHourAndMinute(userModel.user.night, 3)); | ||
| 179 | + _initSunDateList(userModel.user.morning, userModel.user.noon, | ||
| 180 | + userModel.user.night, index); | ||
| 181 | + } | ||
| 182 | + | ||
| 183 | + //根据获取时间 11:00-12:30 获取30分钟间隔组装的数组 | ||
| 184 | + _getHourAndMinute(String hourAndMinuteStr, int mnd) { | ||
| 185 | + List tempDate = hourAndMinuteStr.split("-"); | ||
| 186 | + String beginDate = tempDate[0]; | ||
| 187 | + String endDate = tempDate[1]; | ||
| 188 | + List tempHour = beginDate.split(':'); | ||
| 189 | + | ||
| 190 | + /*获取开始小时*/ | ||
| 191 | + int beginHour = int.parse(tempHour[0]); | ||
| 192 | + /*获取开始分钟*/ | ||
| 193 | + int beginMinute = int.parse(tempHour[1]); | ||
| 194 | + List res = []; | ||
| 195 | + bool tempLimit = true; | ||
| 196 | + while (tempLimit) { | ||
| 197 | + String temp = _dealTime(beginHour, beginMinute); | ||
| 198 | + if (mnd == 1) { | ||
| 199 | + //早市 | ||
| 200 | + mornings.add(temp); | ||
| 201 | + } else if (mnd == 2) { | ||
| 202 | + //午市 | ||
| 203 | + noons.add(temp); | ||
| 204 | + } else if (mnd == 3) { | ||
| 205 | + //晚市 | ||
| 206 | + nights.add(temp); | ||
| 207 | + } | ||
| 208 | + bool tempSelect = false; | ||
| 209 | + if (int.parse(isSetDate) == 1) //设置预订时间 | ||
| 210 | + { | ||
| 211 | + if (temp == ddateStr) { | ||
| 212 | + tempSelect = true; | ||
| 213 | + } | ||
| 214 | + } else { | ||
| 215 | + if (mnd == 1) { | ||
| 216 | + if (temp == '08:00') { | ||
| 217 | + tempSelect = true; | ||
| 218 | + } | ||
| 219 | + } else if (mnd == 2) { | ||
| 220 | + if (temp == '12:00') { | ||
| 221 | + tempSelect = true; | ||
| 222 | + } | ||
| 223 | + } else if (mnd == 3) { | ||
| 224 | + if (temp == '18:30') { | ||
| 225 | + tempSelect = true; | ||
| 226 | + } | ||
| 227 | + } | ||
| 228 | + } | ||
| 229 | + Map tempMap = {'title': temp, 'select': tempSelect}; | ||
| 230 | + res.add(tempMap); | ||
| 231 | + if (temp == endDate) { | ||
| 232 | + tempLimit = false; | ||
| 233 | + break; | ||
| 234 | + } | ||
| 235 | + if (beginMinute == 30) { | ||
| 236 | + beginHour++; | ||
| 237 | + if (beginHour >= 24) { | ||
| 238 | + beginHour = 0; | ||
| 239 | + } | ||
| 240 | + } | ||
| 241 | + beginMinute = (beginMinute + 30) % 60; | ||
| 242 | + } | ||
| 243 | + return res; | ||
| 244 | + } | ||
| 245 | + | ||
| 246 | + //初始化早市午市晚市选中时间 | ||
| 247 | + initHourAndMinuteSelect() { | ||
| 248 | + int timeMillsNow = DateTime.now().millisecondsSinceEpoch; | ||
| 249 | + //当前选中 年-月-日 | ||
| 250 | + String ymyStr = ""; | ||
| 251 | + //今天 明天 其他天 | ||
| 252 | + for (var item in dateList) { | ||
| 253 | + if (item['select'] == true) { | ||
| 254 | + ymyStr = item['title']; | ||
| 255 | + } | ||
| 256 | + } | ||
| 257 | + String timeStr = ymyStr + ' 00:00:00'; | ||
| 258 | + LogUtil.v(timeStr); | ||
| 259 | + DateTime dateTime = DateUtil.getDateTime(timeStr); //当前年月日 | ||
| 260 | + for (var sunDate in sunDateList) { | ||
| 261 | + if (sunDate['isSelect'] == false) continue; | ||
| 262 | + switch (sunDate['key']) { | ||
| 263 | + case "morning": //选中早市 | ||
| 264 | + bool select = false; | ||
| 265 | + for (var temp in dailyMap['morning']) { | ||
| 266 | + //早市选中距离当前时间最近 | ||
| 267 | + temp['select'] = false; | ||
| 268 | + if (select) continue; //只选中第一个 | ||
| 269 | + if (timeMillsNow <= | ||
| 270 | + DateUtil.getDateMsByTimeStr(DateUtil.formatDate(dateTime) | ||
| 271 | + .replaceRange(11, 19, "${temp['title']}:00"))) { | ||
| 272 | + temp['select'] = true; | ||
| 273 | + select = true; | ||
| 274 | + } | ||
| 275 | + } | ||
| 276 | + break; | ||
| 277 | + case "noon": //选中午市 | ||
| 278 | + bool select = false; | ||
| 279 | + for (var temp in dailyMap['noon']) { | ||
| 280 | + //午市选中12:30 | ||
| 281 | + temp['select'] = false; | ||
| 282 | + if (select) continue; | ||
| 283 | + if (noons.contains("12:30") && | ||
| 284 | + timeMillsNow <= | ||
| 285 | + DateUtil.getDateMsByTimeStr(DateUtil.formatDate(dateTime) | ||
| 286 | + .replaceRange(11, 19, "12:30:00"))) { | ||
| 287 | + if (temp['title'] == "12:30") { | ||
| 288 | + temp['select'] = true; | ||
| 289 | + select = true; | ||
| 290 | + } | ||
| 291 | + } else { | ||
| 292 | + if (timeMillsNow <= | ||
| 293 | + DateUtil.getDateMsByTimeStr(DateUtil.formatDate(dateTime) | ||
| 294 | + .replaceRange(11, 19, "${temp['title']}:00"))) { | ||
| 295 | + temp['select'] = true; | ||
| 296 | + select = true; | ||
| 297 | + } | ||
| 298 | + } | ||
| 299 | + } | ||
| 300 | + break; | ||
| 301 | + case "night": //选中晚市 | ||
| 302 | + bool select = false; | ||
| 303 | + for (var temp in dailyMap['night']) { | ||
| 304 | + //晚市选中18:30 | ||
| 305 | + temp['select'] = false; | ||
| 306 | + if (select) continue; | ||
| 307 | + if (nights.contains("18:30") && | ||
| 308 | + timeMillsNow <= | ||
| 309 | + DateUtil.getDateMsByTimeStr(DateUtil.formatDate(dateTime) | ||
| 310 | + .replaceRange(11, 19, "18:30:00"))) { | ||
| 311 | + if (temp['title'] == "18:30") { | ||
| 312 | + temp['select'] = true; | ||
| 313 | + select = true; | ||
| 314 | + } | ||
| 315 | + } else { | ||
| 316 | + if (timeMillsNow <= | ||
| 317 | + DateUtil.getDateMsByTimeStr(DateUtil.formatDate(dateTime) | ||
| 318 | + .replaceRange(11, 19, "${temp['title']}:00"))) { | ||
| 319 | + temp['select'] = true; | ||
| 320 | + select = true; | ||
| 321 | + } | ||
| 322 | + } | ||
| 323 | + } | ||
| 324 | + break; | ||
| 325 | + } | ||
| 326 | + } | ||
| 327 | + LogUtil.v(dailyMap); | ||
| 328 | + } | ||
| 329 | + | ||
| 330 | + /// 根据时间和分钟组装 格式:11:00 | ||
| 331 | + _dealTime(int begin, int mm) { | ||
| 332 | + String sb = ''; | ||
| 333 | + if (begin < 10) { | ||
| 334 | + sb = '0$begin'; | ||
| 335 | + } else { | ||
| 336 | + sb = '$begin'; | ||
| 337 | + } | ||
| 338 | + sb = '$sb:'; | ||
| 339 | + if (mm < 10) { | ||
| 340 | + sb = '${sb}0${mm}'; | ||
| 341 | + } else { | ||
| 342 | + sb = '${sb}${mm}'; | ||
| 343 | + } | ||
| 344 | + return sb; | ||
| 345 | + } | ||
| 346 | + | ||
| 347 | + ///获取某个商家下所有服务员信息 **** 取得某个商家的早市、午市、晚市营业时间 | ||
| 348 | + Future<SunSellerInfoModel> getManagersInfo(BuildContext context) async { | ||
| 349 | + UserModel userModel = Provider.of<UserModel>(context, listen: false); | ||
| 350 | + Map<String, String> params = { | ||
| 351 | + "seller_id": userModel.user.sellerid, | ||
| 352 | + "seller_openid": userModel.user.openid | ||
| 353 | + }; | ||
| 354 | + BaseResp<Map<String, dynamic>> baseResp = await DioUtil() | ||
| 355 | + .request<Map<String, dynamic>>(context, Method.get, HttpUrl.sellerinfo, | ||
| 356 | + data: params) | ||
| 357 | + .catchError((error) { | ||
| 358 | + print(error.toString()); | ||
| 359 | + }); | ||
| 360 | + SunSellerInfoModel itemModel; | ||
| 361 | + if (baseResp == null) return itemModel; | ||
| 362 | + if (baseResp.code == Constant.status_success) { | ||
| 363 | + if (int.parse(baseResp.status) != Constant.status_success) { | ||
| 364 | + Utils.showToast(baseResp.msg ?? ""); | ||
| 365 | + return itemModel; | ||
| 366 | + } | ||
| 367 | + if (baseResp.responseData['data'] != null) { | ||
| 368 | + itemModel = SellerInfoModel.fromJson(baseResp.responseData).data; | ||
| 369 | + } else { | ||
| 370 | + Utils.showToast(baseResp.msg ?? ""); | ||
| 371 | + } | ||
| 372 | + return itemModel; | ||
| 373 | + } | ||
| 374 | + } | ||
| 375 | + | ||
| 376 | + ///根据商家ID 获取桌位信息列表: 1:散座 2:包间 默认:获取所有数据 | ||
| 377 | + Future<List<TableList>> getNewTableList(BuildContext context, String ddate, | ||
| 378 | + String ddate_solt, String pnum, List oldTableList) async { | ||
| 379 | + if (pnum == '') { | ||
| 380 | + pnum = '6'; | ||
| 381 | + } | ||
| 382 | + DateTime createTime = DateTime.fromMillisecondsSinceEpoch(int.parse(ddate)); | ||
| 383 | + String rdate = DateUtil.formatDate(createTime, format: "yyyyMMdd"); | ||
| 384 | + UserModel userModel = Provider.of<UserModel>(context, listen: false); | ||
| 385 | + Map<String, String> params = { | ||
| 386 | + "sid": userModel.user.sellerid, | ||
| 387 | + "rdate": rdate, | ||
| 388 | + 'ddate_solt': ddate_solt, | ||
| 389 | + 'pnum': pnum | ||
| 390 | + }; | ||
| 391 | + | ||
| 392 | + BaseResp<dynamic> baseResp = await DioUtil() | ||
| 393 | + .request<dynamic>(context, Method.get, HttpUrl.get_table_list, | ||
| 394 | + data: params) | ||
| 395 | + .catchError((error) { | ||
| 396 | + print(error.toString()); | ||
| 397 | + }); | ||
| 398 | + List<TableListSunModel> itemModelList; | ||
| 399 | + if (baseResp == null) return tableList; | ||
| 400 | + if (baseResp.code == Constant.status_success) { | ||
| 401 | + if (int.parse(baseResp.status) != Constant.status_success) { | ||
| 402 | + Utils.showToast(baseResp.msg ?? ""); | ||
| 403 | + return tableList; | ||
| 404 | + } | ||
| 405 | + if (baseResp.responseData['data'] != null) { | ||
| 406 | + itemModelList = TableListModel.fromJson(baseResp.responseData).data; | ||
| 407 | + } else { | ||
| 408 | + Utils.showToast(baseResp.msg ?? ""); | ||
| 409 | + } | ||
| 410 | + tableList = []; | ||
| 411 | + | ||
| 412 | + for (int i = 0; i < itemModelList.length; i++) { | ||
| 413 | + if (itemModelList[i].name == "推荐") { | ||
| 414 | + recommendList = itemModelList[i].list; | ||
| 415 | + itemModelList.removeAt(i); | ||
| 416 | + } | ||
| 417 | + } | ||
| 418 | + for (TableListSunModel item in itemModelList) { | ||
| 419 | + if (item.name == "推荐") { | ||
| 420 | + itemModelList.remove(item); | ||
| 421 | + } | ||
| 422 | + for (var item in item.list) { | ||
| 423 | + for (var table in oldTableList) { | ||
| 424 | + if (item.id == table.id) { | ||
| 425 | + item.selected = true; | ||
| 426 | + if (!tableList.contains(item)) { | ||
| 427 | + tableList.add(item); | ||
| 428 | + } | ||
| 429 | + } | ||
| 430 | + } | ||
| 431 | + } | ||
| 432 | + } | ||
| 433 | + // List usedTableList = []; //被占用的包间 | ||
| 434 | + // for (var itemOld in oldTableList) { | ||
| 435 | + // if (tableList.length == 0) { | ||
| 436 | + // usedTableList = oldTableList; | ||
| 437 | + // } else { | ||
| 438 | + // for (var item in tableList) { | ||
| 439 | + // if (item.id != itemOld.id) { | ||
| 440 | + // usedTableList.add(item); | ||
| 441 | + // } | ||
| 442 | + // } | ||
| 443 | + // } | ||
| 444 | + // } | ||
| 445 | + List idold = []; | ||
| 446 | + for (var itemOld in oldTableList) { | ||
| 447 | + idold.add(itemOld.id); | ||
| 448 | + } | ||
| 449 | + List idnew = []; | ||
| 450 | + for (var item in tableList) { | ||
| 451 | + idnew.add(item.id); | ||
| 452 | + } | ||
| 453 | + for (var item in idnew) { | ||
| 454 | + idold.remove(item); | ||
| 455 | + } | ||
| 456 | + print(idold); //被占用的桌子的id | ||
| 457 | + if (idold.length > 0) { | ||
| 458 | + String msg = ''; | ||
| 459 | + for (var item in oldTableList) { | ||
| 460 | + if (idold.contains(item.id)) { | ||
| 461 | + msg += '${item.name},'; | ||
| 462 | + } | ||
| 463 | + } | ||
| 464 | + if (msg.endsWith(',')) { | ||
| 465 | + msg = msg.substring(0, msg.length - 1); | ||
| 466 | + } | ||
| 467 | + Utils.showToast('${msg}已被占用啦'); | ||
| 468 | + } | ||
| 469 | + | ||
| 470 | + // if (usedTableList.length > 0) { | ||
| 471 | + // print(usedTableList); | ||
| 472 | + // String msg = ''; | ||
| 473 | + // for (var item in usedTableList) { | ||
| 474 | + // msg += '${item.name},'; | ||
| 475 | + // } | ||
| 476 | + // if (msg.endsWith(',')) { | ||
| 477 | + // msg = msg.substring(0, msg.length - 1); | ||
| 478 | + // } | ||
| 479 | + // Utils.showToast('${msg}已被占用啦'); | ||
| 480 | + // } | ||
| 481 | + | ||
| 482 | + // if(usedTableList.length > 0){ | ||
| 483 | + // for (TableList item in usedTableList) { | ||
| 484 | + // item | ||
| 485 | + // } | ||
| 486 | + // } | ||
| 487 | + | ||
| 488 | + if (tableList.length == 0) { | ||
| 489 | + // Utils.showToast('包间已经被预订'); | ||
| 490 | + isRecommend = true; | ||
| 491 | + } else { | ||
| 492 | + isRecommend = false; | ||
| 493 | + } | ||
| 494 | + print(tableList); | ||
| 495 | + notifyListeners(); | ||
| 496 | + return tableList; | ||
| 497 | + } | ||
| 498 | + } | ||
| 499 | + | ||
| 500 | + ///录入更改内部预订 | ||
| 501 | + Future<SunReserveInfoModel> setReserveInfo(BuildContext context) async { | ||
| 502 | + UserModel userModel = Provider.of<UserModel>(context, listen: false); | ||
| 503 | + String pnum = '6'; | ||
| 504 | + for (var item in personNumList) { | ||
| 505 | + if (item['isSelect']) { | ||
| 506 | + pnum = item['dateText']; | ||
| 507 | + } | ||
| 508 | + } | ||
| 509 | + if (pnum == '') { | ||
| 510 | + pnum = '6'; | ||
| 511 | + } | ||
| 512 | + String sex = '1'; | ||
| 513 | + for (var item in sexList) { | ||
| 514 | + if (item['select']) { | ||
| 515 | + sex = item['code']; | ||
| 516 | + } | ||
| 517 | + } | ||
| 518 | + //当前选中 年-月-日string | ||
| 519 | + String ymyStr = ""; | ||
| 520 | + //今天 明天 其他天 | ||
| 521 | + for (var item in dateList) { | ||
| 522 | + if (item['select'] == true) { | ||
| 523 | + ymyStr = item['title']; | ||
| 524 | + } | ||
| 525 | + } | ||
| 526 | + String timeStr = ymyStr + ' ' + ddateStr + ':00'; | ||
| 527 | + // int start = DateUtil.getDateMsByTimeStr(timeStr); | ||
| 528 | + | ||
| 529 | + LogUtil.v(timeStr); | ||
| 530 | + // String tempDdate = ymyStr + ' ' + ddateStr + ':00'; | ||
| 531 | + int ddate = DateUtil.getDateMsByTimeStr(timeStr); | ||
| 532 | + String tableSelectInfo = ''; | ||
| 533 | + for (TableList item in tableList) { | ||
| 534 | + // if (item.selected) { | ||
| 535 | + tableSelectInfo += ',${item.id}'; | ||
| 536 | + // } | ||
| 537 | + } | ||
| 538 | + print(tableSelectInfo); | ||
| 539 | + if (tableSelectInfo.startsWith(',')) { | ||
| 540 | + tableSelectInfo = tableSelectInfo.substring(1); | ||
| 541 | + } | ||
| 542 | + print(tableSelectInfo); | ||
| 543 | + String rdate = ''; | ||
| 544 | + String ddateSolt = ''; | ||
| 545 | + print(sunDateList); | ||
| 546 | + for (var item in sunDateList) { | ||
| 547 | + if (item['isSelect'] == true) { | ||
| 548 | + String keys = ''; | ||
| 549 | + ddateSolt = '${item['ddateSolt']}'; | ||
| 550 | + if (item['ddateSolt'] == 1) { | ||
| 551 | + //早市 | ||
| 552 | + keys = 'morning'; | ||
| 553 | + } else if (item['ddateSolt'] == 2) { | ||
| 554 | + //午市 | ||
| 555 | + keys = 'noon'; | ||
| 556 | + } else if (item['ddateSolt'] == 3) { | ||
| 557 | + //晚市 | ||
| 558 | + keys = 'night'; | ||
| 559 | + } | ||
| 560 | + if (keys != '') { | ||
| 561 | + List temp = dailyMap[keys]; | ||
| 562 | + String timeStrStart = ymyStr + ' ' + temp.first['title'] + ':00'; | ||
| 563 | + String timeStrEnd = ymyStr + ' ' + temp.last['title'] + ':00'; | ||
| 564 | + int startM = DateUtil.getDateMsByTimeStr(timeStrStart); | ||
| 565 | + int endM = DateUtil.getDateMsByTimeStr(timeStrEnd); | ||
| 566 | + String start = '${startM}'.substring(0, 10); | ||
| 567 | + String end = '${endM}'.substring(0, 10); | ||
| 568 | + rdate = start + '-' + end; | ||
| 569 | + } | ||
| 570 | + } | ||
| 571 | + } | ||
| 572 | + Map<String, String> params = { | ||
| 573 | + "sid": userModel.user.sellerid, //商家ID | ||
| 574 | + "tid": tableSelectInfo, //桌子ID: 格式 2,3,4 | ||
| 575 | + "pnum": pnum, //预定用餐人数 | ||
| 576 | + "rname": nameController.text, //预订人姓名 | ||
| 577 | + "sex": sex, //预订人姓名:1:男 2:女 | ||
| 578 | + "phone": phoneController.text, //预订人电话 | ||
| 579 | + "cusdem": customController.text, //预订人需求:25汉字 | ||
| 580 | + 'note_name': userModel.user.account, | ||
| 581 | + 'type': "0", //内部预订 | ||
| 582 | + "rdate": rdate, //预定用餐时间范围:时间戳 开始时间戳(time)-结束时间戳(time) | ||
| 583 | + "ddate": '${ddate}'.substring(0, 10), //到店时间 | ||
| 584 | + 'is_set_ddate': "1" | ||
| 585 | + }; | ||
| 586 | + | ||
| 587 | + print(params); | ||
| 588 | + BaseResp<Map<String, dynamic>> baseResp = await DioUtil() | ||
| 589 | + .request<Map<String, dynamic>>( | ||
| 590 | + context, Method.get, HttpUrl.set_reserve_info, | ||
| 591 | + data: params) | ||
| 592 | + .catchError((error) { | ||
| 593 | + print(error.toString()); | ||
| 594 | + }); | ||
| 595 | + SunReserveInfoModel itemModel; | ||
| 596 | + if (baseResp == null) return itemModel; | ||
| 597 | + if (baseResp.code == Constant.status_success) { | ||
| 598 | + if (int.parse(baseResp.status) != Constant.status_success) { | ||
| 599 | + Utils.showToast(baseResp.msg ?? ""); | ||
| 600 | + return itemModel; | ||
| 601 | + } | ||
| 602 | + if (baseResp.responseData['data'] != null && | ||
| 603 | + baseResp.responseData['data']['row'] != null) { | ||
| 604 | + itemModel = ReserveInfoModel.fromJson(baseResp.responseData).data; | ||
| 605 | + } else { | ||
| 606 | + Utils.showToast("录入预订订单失败,请重试!"); | ||
| 607 | + } | ||
| 608 | + return itemModel; | ||
| 609 | + } | ||
| 610 | + } | ||
| 611 | + | ||
| 612 | + //获取历史录入 | ||
| 613 | + getUserHistorys(BuildContext context, Map<String, String> params) async { | ||
| 614 | + BaseResp<List> baseResp = await DioUtil() | ||
| 615 | + .request<List>(context, Method.get, HttpUrl.get_reserve_user, | ||
| 616 | + data: params, showLoading: false) | ||
| 617 | + .catchError((error) { | ||
| 618 | + print(error.toString()); | ||
| 619 | + }); | ||
| 620 | + if (baseResp != null && baseResp.code == Constant.status_success) { | ||
| 621 | + userHistorys = baseResp.data.map<UserHistoryEntity>((value) { | ||
| 622 | + return UserHistoryEntity.fromJson(value); | ||
| 623 | + }).toList(); | ||
| 624 | + notifyListeners(); | ||
| 625 | + } | ||
| 626 | + } | ||
| 627 | +} |
| @@ -35,7 +35,7 @@ class NavigatorUtil { | @@ -35,7 +35,7 @@ class NavigatorUtil { | ||
| 35 | } | 35 | } |
| 36 | 36 | ||
| 37 | /// 首页 | 37 | /// 首页 |
| 38 | - static void goHomePage(BuildContext context, {int initialIndex = 1}) { | 38 | + static void goHomePage(BuildContext context, {int initialIndex = 2}) { |
| 39 | _navigateTo(context, "${Routes.home}?initialIndex=$initialIndex", | 39 | _navigateTo(context, "${Routes.home}?initialIndex=$initialIndex", |
| 40 | clearStack: true); | 40 | clearStack: true); |
| 41 | } | 41 | } |
-
Please register or login to post a comment