Showing
13 changed files
with
999 additions
and
571 deletions
| 1 | +import 'package:common_utils/common_utils.dart'; | ||
| 1 | import 'package:flutter/material.dart'; | 2 | import 'package:flutter/material.dart'; |
| 3 | +import 'package:flutter_picker/flutter_picker.dart'; | ||
| 2 | import 'package:flutter_screenutil/screenutil.dart'; | 4 | import 'package:flutter_screenutil/screenutil.dart'; |
| 3 | import 'package:one_key/res/colors.dart'; | 5 | import 'package:one_key/res/colors.dart'; |
| 6 | +import 'package:one_key/utils/dialog_util.dart'; | ||
| 4 | import 'package:one_key/utils/navigator_util.dart'; | 7 | import 'package:one_key/utils/navigator_util.dart'; |
| 5 | import 'package:one_key/utils/utils.dart'; | 8 | import 'package:one_key/utils/utils.dart'; |
| 6 | import 'package:one_key/widgets/h_empty_view.dart'; | 9 | import 'package:one_key/widgets/h_empty_view.dart'; |
| @@ -21,9 +24,48 @@ class CouponEidtPage extends StatefulWidget { | @@ -21,9 +24,48 @@ class CouponEidtPage extends StatefulWidget { | ||
| 21 | 24 | ||
| 22 | class _CouponEidtPageState extends State<CouponEidtPage> { | 25 | class _CouponEidtPageState extends State<CouponEidtPage> { |
| 23 | ScrollController controller = ScrollController(); | 26 | ScrollController controller = ScrollController(); |
| 24 | - TextEditingController _couponNameEditControl; | 27 | + TextEditingController _couponNameEditControl = TextEditingController(); |
| 28 | + TextEditingController _couponRequireEditControl = TextEditingController(); | ||
| 29 | + TextEditingController _couponExplainEditControl = TextEditingController(); | ||
| 25 | final heightCell = ScreenUtil().setWidth(80); | 30 | final heightCell = ScreenUtil().setWidth(80); |
| 26 | - bool swichState = true; //默认启用 | 31 | + bool swichState = true; //默认启用 开关状态 |
| 32 | + final GlobalKey<ScaffoldState> scaffoldKey = GlobalKey<ScaffoldState>(); | ||
| 33 | + String fromDate = '点击选择'; //有效期开始时间 | ||
| 34 | + String endDate = '点击选择'; //有效期结束时间 | ||
| 35 | + List<int> fromDateSelect; | ||
| 36 | + List<int> endDateSelect; | ||
| 37 | + FocusNode _nameFocusNode = FocusNode(); | ||
| 38 | + FocusNode _requireFocusNode = FocusNode(); | ||
| 39 | + bool showDateSelWidget = false; | ||
| 40 | + | ||
| 41 | + @override | ||
| 42 | + void initState() { | ||
| 43 | + super.initState(); | ||
| 44 | + _nameFocusNode.addListener(() { | ||
| 45 | + if (_nameFocusNode.hasFocus) { | ||
| 46 | + //有焦点 | ||
| 47 | + if (showDateSelWidget) { | ||
| 48 | + Navigator.pop(context); | ||
| 49 | + showDateSelWidget = false; | ||
| 50 | + } | ||
| 51 | + } else { | ||
| 52 | + //失去焦点 | ||
| 53 | + // _editingController.text = ''; | ||
| 54 | + } | ||
| 55 | + }); | ||
| 56 | + _requireFocusNode.addListener(() { | ||
| 57 | + if (_requireFocusNode.hasFocus) { | ||
| 58 | + //有焦点 | ||
| 59 | + if (showDateSelWidget) { | ||
| 60 | + Navigator.pop(context); | ||
| 61 | + showDateSelWidget = false; | ||
| 62 | + } | ||
| 63 | + } else { | ||
| 64 | + //失去焦点 | ||
| 65 | + // _editingController.text = ''; | ||
| 66 | + } | ||
| 67 | + }); | ||
| 68 | + } | ||
| 27 | 69 | ||
| 28 | ///输入框 | 70 | ///输入框 |
| 29 | Widget _textfield(String title, String hintText) { | 71 | Widget _textfield(String title, String hintText) { |
| @@ -46,7 +88,9 @@ class _CouponEidtPageState extends State<CouponEidtPage> { | @@ -46,7 +88,9 @@ class _CouponEidtPageState extends State<CouponEidtPage> { | ||
| 46 | HEmptyView(20), | 88 | HEmptyView(20), |
| 47 | Expanded( | 89 | Expanded( |
| 48 | child: TextField( | 90 | child: TextField( |
| 49 | - controller: _couponNameEditControl, | 91 | + controller: title == '券名称' |
| 92 | + ? _couponNameEditControl | ||
| 93 | + : _couponRequireEditControl, | ||
| 50 | textAlign: TextAlign.right, | 94 | textAlign: TextAlign.right, |
| 51 | maxLines: 1, | 95 | maxLines: 1, |
| 52 | // //光标颜色 | 96 | // //光标颜色 |
| @@ -56,7 +100,7 @@ class _CouponEidtPageState extends State<CouponEidtPage> { | @@ -56,7 +100,7 @@ class _CouponEidtPageState extends State<CouponEidtPage> { | ||
| 56 | style: TextStyle( | 100 | style: TextStyle( |
| 57 | fontSize: ScreenUtil().setSp(26), | 101 | fontSize: ScreenUtil().setSp(26), |
| 58 | ), | 102 | ), |
| 59 | - // focusNode: _cancelNode, | 103 | + focusNode: title == '券名称' ? _nameFocusNode : _requireFocusNode, |
| 60 | // textAlignVertical: TextAlignVertical.bottom, | 104 | // textAlignVertical: TextAlignVertical.bottom, |
| 61 | decoration: InputDecoration( | 105 | decoration: InputDecoration( |
| 62 | // fillColor: Colors.lightGreenAccent, | 106 | // fillColor: Colors.lightGreenAccent, |
| @@ -87,7 +131,38 @@ class _CouponEidtPageState extends State<CouponEidtPage> { | @@ -87,7 +131,38 @@ class _CouponEidtPageState extends State<CouponEidtPage> { | ||
| 87 | Widget _select(String title, String hintText) { | 131 | Widget _select(String title, String hintText) { |
| 88 | return InkWell( | 132 | return InkWell( |
| 89 | onTap: () { | 133 | onTap: () { |
| 134 | + FocusScope.of(context).requestFocus(FocusNode()); //点击空白处隐藏键盘 | ||
| 90 | //弹出时间选择器 | 135 | //弹出时间选择器 |
| 136 | + // showPickerDateTime(context); | ||
| 137 | + showDateSelWidget = true; | ||
| 138 | + DialogUtil.showPickerDateTime24( | ||
| 139 | + context, | ||
| 140 | + scaffoldKey, | ||
| 141 | + (value) { | ||
| 142 | + // {'text': picker.adapter.text, 'select': selecteds} | ||
| 143 | + if (value != null) { | ||
| 144 | + if (title == '有效期从') { | ||
| 145 | + setState(() { | ||
| 146 | + print(value); | ||
| 147 | + fromDate = | ||
| 148 | + DateUtil.formatDateStr(value, format: DateFormats.full); | ||
| 149 | + }); | ||
| 150 | + } else if (title == '有效期至') { | ||
| 151 | + setState(() { | ||
| 152 | + print(value); | ||
| 153 | + endDate = | ||
| 154 | + DateUtil.formatDateStr(value, format: DateFormats.full); | ||
| 155 | + }); | ||
| 156 | + } | ||
| 157 | + } | ||
| 158 | + showDateSelWidget = false; | ||
| 159 | + }, | ||
| 160 | + dateTime: title == '有效期从' | ||
| 161 | + ? DateUtil.getDateTime(fromDate) | ||
| 162 | + : DateUtil.getDateTime(endDate), | ||
| 163 | + onCancel: () { | ||
| 164 | + showDateSelWidget = false; | ||
| 165 | + }); | ||
| 91 | }, | 166 | }, |
| 92 | child: Container( | 167 | child: Container( |
| 93 | height: heightCell, | 168 | height: heightCell, |
| @@ -109,7 +184,9 @@ class _CouponEidtPageState extends State<CouponEidtPage> { | @@ -109,7 +184,9 @@ class _CouponEidtPageState extends State<CouponEidtPage> { | ||
| 109 | Spacer(), | 184 | Spacer(), |
| 110 | Text(hintText, | 185 | Text(hintText, |
| 111 | style: TextStyle( | 186 | style: TextStyle( |
| 112 | - color: MyColours.color_999999, | 187 | + color: hintText == '点击选择' |
| 188 | + ? MyColours.color_999999 | ||
| 189 | + : MyColours.color_333333, | ||
| 113 | fontSize: ScreenUtil().setSp(26), | 190 | fontSize: ScreenUtil().setSp(26), |
| 114 | )), | 191 | )), |
| 115 | HEmptyView(20), | 192 | HEmptyView(20), |
| @@ -145,6 +222,7 @@ class _CouponEidtPageState extends State<CouponEidtPage> { | @@ -145,6 +222,7 @@ class _CouponEidtPageState extends State<CouponEidtPage> { | ||
| 145 | ), | 222 | ), |
| 146 | VEmptyView(10), | 223 | VEmptyView(10), |
| 147 | TextField( | 224 | TextField( |
| 225 | + controller: _couponExplainEditControl, | ||
| 148 | // keyboardType: TextInputType.number, //键盘类型,数字键盘 | 226 | // keyboardType: TextInputType.number, //键盘类型,数字键盘 |
| 149 | maxLines: 7, | 227 | maxLines: 7, |
| 150 | // maxLength: 200, | 228 | // maxLength: 200, |
| @@ -208,6 +286,7 @@ class _CouponEidtPageState extends State<CouponEidtPage> { | @@ -208,6 +286,7 @@ class _CouponEidtPageState extends State<CouponEidtPage> { | ||
| 208 | @override | 286 | @override |
| 209 | Widget build(BuildContext context) { | 287 | Widget build(BuildContext context) { |
| 210 | return Scaffold( | 288 | return Scaffold( |
| 289 | + key: scaffoldKey, | ||
| 211 | appBar: SystemAppBar( | 290 | appBar: SystemAppBar( |
| 212 | '创建新券', | 291 | '创建新券', |
| 213 | onTap: () { | 292 | onTap: () { |
| @@ -231,8 +310,8 @@ class _CouponEidtPageState extends State<CouponEidtPage> { | @@ -231,8 +310,8 @@ class _CouponEidtPageState extends State<CouponEidtPage> { | ||
| 231 | VEmptyView(20), | 310 | VEmptyView(20), |
| 232 | _textfield('券名称', '例:9折券/200元代金券/菜品券'), | 311 | _textfield('券名称', '例:9折券/200元代金券/菜品券'), |
| 233 | _textfield('券要求', '例:无门槛/满2000元'), | 312 | _textfield('券要求', '例:无门槛/满2000元'), |
| 234 | - _select('有效期从', '点击选择'), | ||
| 235 | - _select('有效期至', '点击选择'), | 313 | + _select('有效期从', fromDate), |
| 314 | + _select('有效期至', endDate), | ||
| 236 | _explain('券说明', '例:可用包间,停车免费,不与店内其他活动共享等'), | 315 | _explain('券说明', '例:可用包间,停车免费,不与店内其他活动共享等'), |
| 237 | _canUse('是否立即启用'), | 316 | _canUse('是否立即启用'), |
| 238 | ], | 317 | ], |
| @@ -244,6 +323,15 @@ class _CouponEidtPageState extends State<CouponEidtPage> { | @@ -244,6 +323,15 @@ class _CouponEidtPageState extends State<CouponEidtPage> { | ||
| 244 | ScreenUtil().setWidth(40), ScreenUtil().setWidth(40)), | 323 | ScreenUtil().setWidth(40), ScreenUtil().setWidth(40)), |
| 245 | child: RoundButton( | 324 | child: RoundButton( |
| 246 | onPressed: () { | 325 | onPressed: () { |
| 326 | + // ***参数*** | ||
| 327 | + // _couponNameEditControl.text | ||
| 328 | + // _couponRequireEditControl.text | ||
| 329 | + // fromDate | ||
| 330 | + // endDate | ||
| 331 | + // _couponExplainEditControl.text | ||
| 332 | + // swichState | ||
| 333 | + | ||
| 334 | + //成功之后跳回前一个页面 | ||
| 247 | Navigator.pop(context, true); | 335 | Navigator.pop(context, true); |
| 248 | }, | 336 | }, |
| 249 | text: '保存', | 337 | text: '保存', |
| @@ -10,7 +10,13 @@ class CouponItem extends StatefulWidget { | @@ -10,7 +10,13 @@ class CouponItem extends StatefulWidget { | ||
| 10 | final int index; | 10 | final int index; |
| 11 | final VoidCallback onPressed; | 11 | final VoidCallback onPressed; |
| 12 | final CouponProvider couponProvider; | 12 | final CouponProvider couponProvider; |
| 13 | - CouponItem({Key key, this.index, this.onPressed, this.couponProvider}) | 13 | + final bool showBtn; |
| 14 | + CouponItem( | ||
| 15 | + {Key key, | ||
| 16 | + this.index, | ||
| 17 | + this.onPressed, | ||
| 18 | + this.couponProvider, | ||
| 19 | + this.showBtn = false}) | ||
| 14 | : super(key: key); | 20 | : super(key: key); |
| 15 | 21 | ||
| 16 | @override | 22 | @override |
| @@ -21,80 +27,86 @@ class _CouponItemState extends State<CouponItem> { | @@ -21,80 +27,86 @@ class _CouponItemState extends State<CouponItem> { | ||
| 21 | @override | 27 | @override |
| 22 | Widget build(BuildContext context) { | 28 | Widget build(BuildContext context) { |
| 23 | bool switchState = widget.couponProvider.swichStateData[widget.index]; | 29 | bool switchState = widget.couponProvider.swichStateData[widget.index]; |
| 24 | - return Padding( | ||
| 25 | - padding: EdgeInsets.all(ScreenUtil().setWidth(20)), | ||
| 26 | - child: Container( | ||
| 27 | - height: ScreenUtil().setWidth(300), | 30 | + return Stack( |
| 31 | + children: [ | ||
| 32 | + Container( | ||
| 33 | + // width: ScreenUtil().setWidth(610), | ||
| 34 | + margin: EdgeInsets.symmetric( | ||
| 35 | + horizontal: ScreenUtil().setWidth(30), | ||
| 36 | + vertical: ScreenUtil().setWidth(12)), | ||
| 28 | padding: EdgeInsets.all(ScreenUtil().setWidth(20)), | 37 | padding: EdgeInsets.all(ScreenUtil().setWidth(20)), |
| 29 | decoration: BoxDecoration( | 38 | decoration: BoxDecoration( |
| 30 | color: switchState ? MyColours.app_main : MyColours.color_E0E0E0, | 39 | color: switchState ? MyColours.app_main : MyColours.color_E0E0E0, |
| 31 | borderRadius: BorderRadius.circular(ScreenUtil().setWidth(10))), | 40 | borderRadius: BorderRadius.circular(ScreenUtil().setWidth(10))), |
| 32 | - child: Stack( | 41 | + child: Column( |
| 42 | + mainAxisSize: MainAxisSize.min, | ||
| 43 | + crossAxisAlignment: CrossAxisAlignment.start, | ||
| 33 | children: [ | 44 | children: [ |
| 34 | - Column( | ||
| 35 | - crossAxisAlignment: CrossAxisAlignment.start, | 45 | + Row( |
| 46 | + crossAxisAlignment: CrossAxisAlignment.end, | ||
| 36 | children: [ | 47 | children: [ |
| 37 | - Row( | ||
| 38 | - crossAxisAlignment: CrossAxisAlignment.end, | ||
| 39 | - children: [ | ||
| 40 | - Text( | ||
| 41 | - '九折券', | ||
| 42 | - style: TextStyle( | ||
| 43 | - color: MyColours.color_ffffff, | ||
| 44 | - fontSize: ScreenUtil().setSp(50), | ||
| 45 | - fontWeight: FontWeight.bold), | ||
| 46 | - ), | ||
| 47 | - Text('(无门槛)', | ||
| 48 | - style: TextStyle( | ||
| 49 | - color: MyColours.color_ffffff, | ||
| 50 | - fontSize: ScreenUtil().setSp(22), | ||
| 51 | - fontWeight: FontWeight.bold)) | ||
| 52 | - ], | ||
| 53 | - ), | ||
| 54 | - VEmptyView(20), | ||
| 55 | - Container( | ||
| 56 | - padding: EdgeInsets.all(ScreenUtil().setWidth(20)), | ||
| 57 | - child: Text( | ||
| 58 | - '说明:大家发哈接电话发费哈咖啡的哈快递费哈就快递费哈加客服哈艰苦奋斗哈佛等哈快回复解答快回复', | ||
| 59 | - style: TextStyle( | ||
| 60 | - color: switchState | ||
| 61 | - ? MyColours.app_main | ||
| 62 | - : MyColours.color_e5e5e5, | ||
| 63 | - fontSize: ScreenUtil().setSp(22))), | ||
| 64 | - decoration: BoxDecoration( | 48 | + Text( |
| 49 | + '九折券', | ||
| 50 | + style: TextStyle( | ||
| 65 | color: MyColours.color_ffffff, | 51 | color: MyColours.color_ffffff, |
| 66 | - borderRadius: | ||
| 67 | - BorderRadius.circular(ScreenUtil().setWidth(10))), | ||
| 68 | - ), | ||
| 69 | - Container( | ||
| 70 | - padding: EdgeInsets.only(top: ScreenUtil().setWidth(20)), | ||
| 71 | - child: Text('有效期:2021.01.01 00:00:00 至 2021.01.31 23:59:59', | ||
| 72 | - style: TextStyle( | ||
| 73 | - color: MyColours.color_ffffff, | ||
| 74 | - fontSize: ScreenUtil().setSp(22))), | 52 | + fontSize: ScreenUtil().setSp(50), |
| 53 | + fontWeight: FontWeight.bold), | ||
| 75 | ), | 54 | ), |
| 55 | + Text('(无门槛)', | ||
| 56 | + style: TextStyle( | ||
| 57 | + color: MyColours.color_ffffff, | ||
| 58 | + fontSize: ScreenUtil().setSp(22), | ||
| 59 | + fontWeight: FontWeight.bold)) | ||
| 60 | + ], | ||
| 61 | + ), | ||
| 62 | + VEmptyView(20), | ||
| 63 | + Container( | ||
| 64 | + padding: EdgeInsets.all(ScreenUtil().setWidth(20)), | ||
| 65 | + child: Text('说明:大哈就快费复大家发哈接电话费哈就快递费快回复解答快回复', | ||
| 66 | + maxLines: 30, | ||
| 67 | + overflow: TextOverflow.ellipsis, | ||
| 68 | + softWrap: false, | ||
| 69 | + style: TextStyle( | ||
| 70 | + color: switchState | ||
| 71 | + ? MyColours.app_main | ||
| 72 | + : MyColours.color_e5e5e5, | ||
| 73 | + fontSize: ScreenUtil().setSp(22))), | ||
| 74 | + decoration: BoxDecoration( | ||
| 75 | + color: MyColours.color_ffffff, | ||
| 76 | + borderRadius: | ||
| 77 | + BorderRadius.circular(ScreenUtil().setWidth(10))), | ||
| 78 | + ), | ||
| 79 | + Container( | ||
| 80 | + padding: EdgeInsets.only(top: ScreenUtil().setWidth(20)), | ||
| 81 | + child: Text('有效期:2021.01.01 00:00:00 至 2021.01.31 23:59:59', | ||
| 82 | + style: TextStyle( | ||
| 83 | + color: MyColours.color_ffffff, | ||
| 84 | + fontSize: ScreenUtil().setSp(22))), | ||
| 85 | + ), | ||
| 86 | + ], | ||
| 87 | + ), | ||
| 88 | + ), | ||
| 89 | + Positioned( | ||
| 90 | + top: ScreenUtil().setWidth(40), | ||
| 91 | + right: ScreenUtil().setWidth(40), | ||
| 92 | + child: Row( | ||
| 93 | + children: [ | ||
| 94 | + Column( | ||
| 95 | + crossAxisAlignment: CrossAxisAlignment.start, | ||
| 96 | + children: [ | ||
| 97 | + Text('被领取:99张', | ||
| 98 | + style: TextStyle( | ||
| 99 | + color: MyColours.color_ffffff, | ||
| 100 | + fontSize: ScreenUtil().setSp(22))), | ||
| 101 | + Text('已使用:9张', | ||
| 102 | + style: TextStyle( | ||
| 103 | + color: MyColours.color_ffffff, | ||
| 104 | + fontSize: ScreenUtil().setSp(22))), | ||
| 76 | ], | 105 | ], |
| 77 | ), | 106 | ), |
| 78 | - Positioned( | ||
| 79 | - top: 0, | ||
| 80 | - right: 0, | ||
| 81 | - child: Row( | ||
| 82 | - children: [ | ||
| 83 | - Column( | ||
| 84 | - crossAxisAlignment: CrossAxisAlignment.start, | ||
| 85 | - children: [ | ||
| 86 | - Text('被领取:99张', | ||
| 87 | - style: TextStyle( | ||
| 88 | - color: MyColours.color_ffffff, | ||
| 89 | - fontSize: ScreenUtil().setSp(22))), | ||
| 90 | - Text('已使用:9张', | ||
| 91 | - style: TextStyle( | ||
| 92 | - color: MyColours.color_ffffff, | ||
| 93 | - fontSize: ScreenUtil().setSp(22))), | ||
| 94 | - ], | ||
| 95 | - ), | ||
| 96 | - HEmptyView(20), | ||
| 97 | - RoundButton( | 107 | + HEmptyView(20), |
| 108 | + widget.showBtn | ||
| 109 | + ? RoundButton( | ||
| 98 | width: ScreenUtil().setWidth(100), | 110 | width: ScreenUtil().setWidth(100), |
| 99 | height: ScreenUtil().setWidth(50), | 111 | height: ScreenUtil().setWidth(50), |
| 100 | radius: ScreenUtil().setWidth(10), | 112 | radius: ScreenUtil().setWidth(10), |
| @@ -104,11 +116,11 @@ class _CouponItemState extends State<CouponItem> { | @@ -104,11 +116,11 @@ class _CouponItemState extends State<CouponItem> { | ||
| 104 | gradientEnd: Colors.white, | 116 | gradientEnd: Colors.white, |
| 105 | onPressed: widget.onPressed, | 117 | onPressed: widget.onPressed, |
| 106 | ) | 118 | ) |
| 107 | - ], | ||
| 108 | - ), | ||
| 109 | - ) | 119 | + : Container() |
| 110 | ], | 120 | ], |
| 111 | ), | 121 | ), |
| 112 | - )); | 122 | + ) |
| 123 | + ], | ||
| 124 | + ); | ||
| 113 | } | 125 | } |
| 114 | } | 126 | } |
| @@ -88,6 +88,7 @@ class _CouponPageState extends State<CouponPage> { | @@ -88,6 +88,7 @@ class _CouponPageState extends State<CouponPage> { | ||
| 88 | return CouponItem( | 88 | return CouponItem( |
| 89 | index: index, | 89 | index: index, |
| 90 | couponProvider: couponProvider, | 90 | couponProvider: couponProvider, |
| 91 | + showBtn: true, | ||
| 91 | onPressed: () { | 92 | onPressed: () { |
| 92 | couponProvider.swichStateData[index] = | 93 | couponProvider.swichStateData[index] = |
| 93 | !couponProvider.swichStateData[index]; | 94 | !couponProvider.swichStateData[index]; |
| @@ -118,7 +119,7 @@ class _CouponPageState extends State<CouponPage> { | @@ -118,7 +119,7 @@ class _CouponPageState extends State<CouponPage> { | ||
| 118 | bool needRefresh = | 119 | bool needRefresh = |
| 119 | await NavigatorUtil.goCouponEditPage(context); | 120 | await NavigatorUtil.goCouponEditPage(context); |
| 120 | print(needRefresh); | 121 | print(needRefresh); |
| 121 | - if (needRefresh) { | 122 | + if (needRefresh != null && needRefresh) { |
| 122 | //刷新页面数据 | 123 | //刷新页面数据 |
| 123 | _controller.callRefresh(); | 124 | _controller.callRefresh(); |
| 124 | } | 125 | } |
lib/pages/coupon/coupon_selecet_page.dart
0 → 100644
| 1 | +import 'package:flutter/material.dart'; | ||
| 2 | +import 'package:flutter_easyrefresh/easy_refresh.dart'; | ||
| 3 | +import 'package:flutter_screenutil/screenutil.dart'; | ||
| 4 | +import 'package:one_key/constant/state.dart'; | ||
| 5 | +import 'package:one_key/pages/coupon/coupon_item.dart'; | ||
| 6 | +import 'package:one_key/provider/coupon_provider.dart'; | ||
| 7 | +import 'package:one_key/utils/navigator_util.dart'; | ||
| 8 | +import 'package:one_key/widgets/h_empty_view.dart'; | ||
| 9 | +import 'package:one_key/widgets/page_exception.dart'; | ||
| 10 | +import 'package:one_key/widgets/round_button.dart'; | ||
| 11 | +import 'package:one_key/widgets/system_app_bar.dart'; | ||
| 12 | +import 'package:one_key/widgets/v_empty_view.dart'; | ||
| 13 | +import 'package:provider/provider.dart'; | ||
| 14 | + | ||
| 15 | +class CouponSelectPage extends StatefulWidget { | ||
| 16 | + CouponSelectPage({Key key}) : super(key: key); | ||
| 17 | + | ||
| 18 | + @override | ||
| 19 | + _CouponSelectPageState createState() => _CouponSelectPageState(); | ||
| 20 | +} | ||
| 21 | + | ||
| 22 | +class _CouponSelectPageState extends State<CouponSelectPage> { | ||
| 23 | + EasyRefreshController _controller = EasyRefreshController(); | ||
| 24 | + CouponProvider couponProvider; | ||
| 25 | + | ||
| 26 | + ///获取优惠券列表数据 | ||
| 27 | + _couponNetworkData() { | ||
| 28 | + return Future.delayed(Duration(seconds: 1), | ||
| 29 | + () => couponProvider.pageStateSelect = PageState.Success); | ||
| 30 | + } | ||
| 31 | + | ||
| 32 | + @override | ||
| 33 | + void initState() { | ||
| 34 | + // TODO: implement initState | ||
| 35 | + super.initState(); | ||
| 36 | + WidgetsBinding.instance.addPostFrameCallback((_) { | ||
| 37 | + _couponNetworkData(); | ||
| 38 | + }); | ||
| 39 | + } | ||
| 40 | + | ||
| 41 | + @override | ||
| 42 | + Widget build(BuildContext context) { | ||
| 43 | + couponProvider = Provider.of<CouponProvider>(context, listen: true); | ||
| 44 | + return Scaffold( | ||
| 45 | + appBar: SystemAppBar( | ||
| 46 | + '优惠券', | ||
| 47 | + onTap: () { | ||
| 48 | + Navigator.pop(context); | ||
| 49 | + }, | ||
| 50 | + rightImgName: couponProvider.checkValue ? '取消全选' : '全选', | ||
| 51 | + onTapRight: () { | ||
| 52 | + if (couponProvider.checkValue) { | ||
| 53 | + couponProvider.cancelAll(); | ||
| 54 | + } else { | ||
| 55 | + couponProvider.addAll(); | ||
| 56 | + } | ||
| 57 | + }, | ||
| 58 | + ), | ||
| 59 | + body: Column( | ||
| 60 | + children: [ | ||
| 61 | + Expanded(child: Consumer<CouponProvider>( | ||
| 62 | + builder: (context, model, _) { | ||
| 63 | + if (model.pageStateSelect != PageState.Success) { | ||
| 64 | + return ExceptionPage( | ||
| 65 | + pageState: model.pageStateSelect, | ||
| 66 | + callback: () { | ||
| 67 | + // offset = 0; | ||
| 68 | + // getMessage(showLoading: true); | ||
| 69 | + }, | ||
| 70 | + emptyMsg: "暂时没有列表信息哦", | ||
| 71 | + emptyImg: "empty_search", | ||
| 72 | + showMsg: "加载中,请稍后...", | ||
| 73 | + ); | ||
| 74 | + } else { | ||
| 75 | + return EasyRefresh.custom( | ||
| 76 | + controller: _controller, | ||
| 77 | + shrinkWrap: true, | ||
| 78 | + slivers: [ | ||
| 79 | + SliverList( | ||
| 80 | + delegate: SliverChildBuilderDelegate( | ||
| 81 | + (BuildContext context, int index) { | ||
| 82 | + return InkWell( | ||
| 83 | + onTap: () { | ||
| 84 | + couponProvider.listData[index]['checked'] = | ||
| 85 | + !couponProvider.listData[index]['checked']; | ||
| 86 | + if (couponProvider.listData[index]['checked']) { | ||
| 87 | + couponProvider.addData(index); | ||
| 88 | + } else { | ||
| 89 | + couponProvider.cancelData(index); | ||
| 90 | + } | ||
| 91 | + couponProvider.getCheckValue(); | ||
| 92 | + }, | ||
| 93 | + child: Row( | ||
| 94 | + children: [ | ||
| 95 | + HEmptyView(30), | ||
| 96 | + Image.asset( | ||
| 97 | + couponProvider.listData[index]['checked'] | ||
| 98 | + ? 'assets/select.png' | ||
| 99 | + : 'assets/unselect.png', | ||
| 100 | + width: ScreenUtil().setWidth(44)), | ||
| 101 | + Expanded( | ||
| 102 | + child: CouponItem( | ||
| 103 | + index: index, | ||
| 104 | + couponProvider: couponProvider, | ||
| 105 | + onPressed: () { | ||
| 106 | + couponProvider.listData[index]['checked'] = | ||
| 107 | + !couponProvider.listData[index] | ||
| 108 | + ['checked']; | ||
| 109 | + if (couponProvider.listData[index] | ||
| 110 | + ['checked']) { | ||
| 111 | + couponProvider.addData(index); | ||
| 112 | + } else { | ||
| 113 | + couponProvider.cancelData(index); | ||
| 114 | + } | ||
| 115 | + couponProvider.getCheckValue(); | ||
| 116 | + }, | ||
| 117 | + )) | ||
| 118 | + ], | ||
| 119 | + ), | ||
| 120 | + ); | ||
| 121 | + }, childCount: couponProvider.listData.length), | ||
| 122 | + ) | ||
| 123 | + ], | ||
| 124 | + onRefresh: () async { | ||
| 125 | + // offset = 0; | ||
| 126 | + // getMessage(showLoading: false); | ||
| 127 | + }, | ||
| 128 | + onLoad: () async { | ||
| 129 | + // offset++; | ||
| 130 | + // getMessage(showLoading: false); | ||
| 131 | + }, | ||
| 132 | + ); | ||
| 133 | + } | ||
| 134 | + }, | ||
| 135 | + )), | ||
| 136 | + VEmptyView(20), | ||
| 137 | + Padding( | ||
| 138 | + padding: EdgeInsets.fromLTRB(ScreenUtil().setWidth(40), 0, | ||
| 139 | + ScreenUtil().setWidth(40), ScreenUtil().setWidth(40)), | ||
| 140 | + child: RoundButton( | ||
| 141 | + onPressed: () { | ||
| 142 | + Navigator.pop(context); | ||
| 143 | + }, | ||
| 144 | + text: '已选${couponProvider.coupons.length}个 确定', | ||
| 145 | + fontSize: 34, | ||
| 146 | + isBold: false, | ||
| 147 | + height: ScreenUtil().setWidth(80), | ||
| 148 | + width: double.infinity, | ||
| 149 | + radius: ScreenUtil().setWidth(10), | ||
| 150 | + )) | ||
| 151 | + ], | ||
| 152 | + ), | ||
| 153 | + ); | ||
| 154 | + } | ||
| 155 | +} |
| @@ -76,7 +76,7 @@ class HomePageState extends State<HomePage> with WidgetsBindingObserver { | @@ -76,7 +76,7 @@ class HomePageState extends State<HomePage> with WidgetsBindingObserver { | ||
| 76 | )) | 76 | )) |
| 77 | ..add(ChangeNotifierProvider<TableManagerModel>( | 77 | ..add(ChangeNotifierProvider<TableManagerModel>( |
| 78 | create: (_) => TableManagerModel(), | 78 | create: (_) => TableManagerModel(), |
| 79 | - child: SafeArea(child: TableManagerPage()), | 79 | + child: TableManagerPage(), |
| 80 | )) | 80 | )) |
| 81 | ..add(ChangeNotifierProvider<MyModel>( | 81 | ..add(ChangeNotifierProvider<MyModel>( |
| 82 | create: (_) => MyModel(), | 82 | create: (_) => MyModel(), |
| 1 | import 'package:flutter/material.dart'; | 1 | import 'package:flutter/material.dart'; |
| 2 | import 'package:flutter_screenutil/flutter_screenutil.dart'; | 2 | import 'package:flutter_screenutil/flutter_screenutil.dart'; |
| 3 | import 'package:one_key/models/user.dart'; | 3 | import 'package:one_key/models/user.dart'; |
| 4 | +import 'package:one_key/provider/coupon_provider.dart'; | ||
| 4 | import 'package:one_key/provider/user_model.dart'; | 5 | import 'package:one_key/provider/user_model.dart'; |
| 5 | import 'package:one_key/res/colors.dart'; | 6 | import 'package:one_key/res/colors.dart'; |
| 6 | import 'package:one_key/utils/navigator_util.dart'; | 7 | import 'package:one_key/utils/navigator_util.dart'; |
| @@ -15,7 +16,8 @@ class InvicationPage extends StatefulWidget { | @@ -15,7 +16,8 @@ class InvicationPage extends StatefulWidget { | ||
| 15 | final String ddateStr; | 16 | final String ddateStr; |
| 16 | final String phone; | 17 | final String phone; |
| 17 | 18 | ||
| 18 | - InvicationPage(this.rid, this.tableInfo, this.ddate, this.ddateStr, this.phone); | 19 | + InvicationPage( |
| 20 | + this.rid, this.tableInfo, this.ddate, this.ddateStr, this.phone); | ||
| 19 | 21 | ||
| 20 | @override | 22 | @override |
| 21 | State<StatefulWidget> createState() { | 23 | State<StatefulWidget> createState() { |
| @@ -28,6 +30,9 @@ class InvicationPageState extends State<InvicationPage> { | @@ -28,6 +30,9 @@ class InvicationPageState extends State<InvicationPage> { | ||
| 28 | User user; | 30 | User user; |
| 29 | DateTime dateTime; | 31 | DateTime dateTime; |
| 30 | String dateTimeStr = ""; | 32 | String dateTimeStr = ""; |
| 33 | + ScrollController controller = ScrollController(); | ||
| 34 | + final double couponHeight = 180.0; | ||
| 35 | + CouponProvider couponProvider; | ||
| 31 | 36 | ||
| 32 | @override | 37 | @override |
| 33 | void initState() { | 38 | void initState() { |
| @@ -84,177 +89,218 @@ class InvicationPageState extends State<InvicationPage> { | @@ -84,177 +89,218 @@ class InvicationPageState extends State<InvicationPage> { | ||
| 84 | @override | 89 | @override |
| 85 | Widget build(BuildContext context) { | 90 | Widget build(BuildContext context) { |
| 86 | // TODO: implement build | 91 | // TODO: implement build |
| 87 | - return SafeArea( | ||
| 88 | - child: Container( | ||
| 89 | - width: double.infinity, | ||
| 90 | - height: double.infinity, | ||
| 91 | - decoration: BoxDecoration( | ||
| 92 | - image: DecorationImage( | ||
| 93 | - image: AssetImage("assets/bg_invication.png"), fit: BoxFit.cover), | ||
| 94 | - ), | ||
| 95 | - child: DefaultTextStyle( | ||
| 96 | - style: TextStyle(decoration: TextDecoration.none), | ||
| 97 | - child: Column( | ||
| 98 | - children: <Widget>[ | ||
| 99 | - GestureDetector( | ||
| 100 | - onTap: () { | ||
| 101 | - Navigator.of(context).pop(); | ||
| 102 | - }, | ||
| 103 | - behavior: HitTestBehavior.opaque, | ||
| 104 | - child: Container( | ||
| 105 | - width: double.infinity, | ||
| 106 | - alignment: Alignment.centerLeft, | ||
| 107 | - child: Padding( | ||
| 108 | - padding: EdgeInsets.symmetric( | ||
| 109 | - horizontal: ScreenUtil().setWidth(40), | ||
| 110 | - vertical: ScreenUtil().setHeight(15)), | ||
| 111 | - child: Image.asset( | ||
| 112 | - "assets/invication_back.png", | ||
| 113 | - width: ScreenUtil().setWidth(20), | ||
| 114 | - height: ScreenUtil().setHeight(31), | ||
| 115 | - )), | ||
| 116 | - ), | ||
| 117 | - ), | ||
| 118 | - Expanded( | ||
| 119 | - child: Center( | ||
| 120 | - child: Column( | ||
| 121 | - children: <Widget>[ | ||
| 122 | - Image.asset( | ||
| 123 | - "assets/img_ydap.png", | ||
| 124 | - width: ScreenUtil().setWidth(500), | ||
| 125 | - height: ScreenUtil().setHeight(300), | ||
| 126 | - ), | ||
| 127 | - VEmptyView(69), | ||
| 128 | - Row( | ||
| 129 | - mainAxisSize: MainAxisSize.min, | ||
| 130 | - children: <Widget>[ | ||
| 131 | - Container( | ||
| 132 | - width: ScreenUtil().setWidth(108), | ||
| 133 | - height: ScreenUtil().setHeight(2), | ||
| 134 | - color: MyColours.color_ffffff, | ||
| 135 | - ), | ||
| 136 | - Container( | ||
| 137 | - width: ScreenUtil().setWidth(442), | ||
| 138 | - height: ScreenUtil().setHeight(43), | ||
| 139 | - alignment: Alignment.center, | ||
| 140 | - decoration: BoxDecoration( | ||
| 141 | - border: Border.all( | ||
| 142 | - color: MyColours.color_ffffff, | ||
| 143 | - width: ScreenUtil().setWidth(2)), | ||
| 144 | - borderRadius: BorderRadius.all( | ||
| 145 | - Radius.circular( | ||
| 146 | - ScreenUtil().setWidth(18)))), | ||
| 147 | - child: Text( | ||
| 148 | - "订包间,用周到安排", | ||
| 149 | - style: TextStyle( | ||
| 150 | - color: MyColours.color_ffffff, | ||
| 151 | - fontSize: ScreenUtil().setSp(28)), | 92 | + couponProvider = Provider.of<CouponProvider>(context, listen: true); |
| 93 | + return Scaffold( | ||
| 94 | + body: Container( | ||
| 95 | + width: double.infinity, | ||
| 96 | + height: double.infinity, | ||
| 97 | + decoration: BoxDecoration( | ||
| 98 | + image: DecorationImage( | ||
| 99 | + image: AssetImage("assets/bg_invication.png"), | ||
| 100 | + fit: BoxFit.cover), | ||
| 101 | + ), | ||
| 102 | + child: Stack( | ||
| 103 | + children: [ | ||
| 104 | + Padding( | ||
| 105 | + padding: EdgeInsets.only(top: ScreenUtil().setWidth(0)), | ||
| 106 | + child: Column(children: [ | ||
| 107 | + Expanded( | ||
| 108 | + child: ListView( | ||
| 109 | + controller: controller, | ||
| 110 | + physics: BouncingScrollPhysics(), | ||
| 111 | + children: <Widget>[ | ||
| 112 | + VEmptyView(60), | ||
| 113 | + Center( | ||
| 114 | + child: Column( | ||
| 115 | + children: <Widget>[ | ||
| 116 | + Image.asset( | ||
| 117 | + "assets/img_ydap.png", | ||
| 118 | + width: ScreenUtil().setWidth(500), | ||
| 119 | + height: ScreenUtil().setHeight(300), | ||
| 120 | + ), | ||
| 121 | + VEmptyView(69), | ||
| 122 | + Row( | ||
| 123 | + mainAxisSize: MainAxisSize.min, | ||
| 124 | + children: <Widget>[ | ||
| 125 | + Container( | ||
| 126 | + width: ScreenUtil().setWidth(108), | ||
| 127 | + height: ScreenUtil().setHeight(2), | ||
| 128 | + color: MyColours.color_ffffff, | ||
| 129 | + ), | ||
| 130 | + Container( | ||
| 131 | + width: ScreenUtil().setWidth(442), | ||
| 132 | + height: ScreenUtil().setHeight(43), | ||
| 133 | + alignment: Alignment.center, | ||
| 134 | + decoration: BoxDecoration( | ||
| 135 | + border: Border.all( | ||
| 136 | + color: MyColours.color_ffffff, | ||
| 137 | + width: | ||
| 138 | + ScreenUtil().setWidth(2)), | ||
| 139 | + borderRadius: BorderRadius.all( | ||
| 140 | + Radius.circular(ScreenUtil() | ||
| 141 | + .setWidth(18)))), | ||
| 142 | + child: Text( | ||
| 143 | + "订包间,用周到安排", | ||
| 144 | + style: TextStyle( | ||
| 145 | + color: MyColours.color_ffffff, | ||
| 146 | + fontSize: ScreenUtil().setSp(28)), | ||
| 147 | + ), | ||
| 148 | + ), | ||
| 149 | + Container( | ||
| 150 | + width: ScreenUtil().setWidth(108), | ||
| 151 | + height: ScreenUtil().setHeight(2), | ||
| 152 | + color: MyColours.color_ffffff, | ||
| 153 | + ), | ||
| 154 | + ], | ||
| 155 | + ), | ||
| 156 | + _middleWidget("餐厅", user.sellername), | ||
| 157 | + _middleWidget("包间", | ||
| 158 | + widget.tableInfo.replaceAll("\n", "")), | ||
| 159 | + _middleWidget("时间", dateTimeStr), | ||
| 160 | + VEmptyView(38), | ||
| 161 | + Column( | ||
| 162 | + children: <Widget>[ | ||
| 163 | + Row( | ||
| 164 | + mainAxisSize: MainAxisSize.min, | ||
| 165 | + children: <Widget>[ | ||
| 166 | + Image.asset( | ||
| 167 | + "assets/invication_map.png", | ||
| 168 | + width: ScreenUtil().setWidth(22), | ||
| 169 | + height: ScreenUtil().setWidth(28), | ||
| 170 | + ), | ||
| 171 | + Container( | ||
| 172 | + margin: EdgeInsets.symmetric( | ||
| 173 | + horizontal: | ||
| 174 | + ScreenUtil().setWidth(13)), | ||
| 175 | + child: Text("地址导航", | ||
| 176 | + style: TextStyle( | ||
| 177 | + color: | ||
| 178 | + MyColours.color_eadab9, | ||
| 179 | + fontSize: ScreenUtil() | ||
| 180 | + .setSp(32))), | ||
| 181 | + ), | ||
| 182 | + Image.asset( | ||
| 183 | + "assets/invication_arrow_right.png", | ||
| 184 | + width: ScreenUtil().setWidth(14), | ||
| 185 | + height: ScreenUtil().setWidth(22), | ||
| 186 | + ), | ||
| 187 | + ], | ||
| 188 | + ), | ||
| 189 | + Container( | ||
| 190 | + margin: EdgeInsets.only( | ||
| 191 | + top: ScreenUtil().setHeight(20)), | ||
| 192 | + child: Text( | ||
| 193 | + user.sellerAddr, | ||
| 194 | + style: TextStyle( | ||
| 195 | + color: MyColours.color_ffffff, | ||
| 196 | + fontSize: ScreenUtil().setSp(34)), | ||
| 197 | + ), | ||
| 198 | + ) | ||
| 199 | + ], | ||
| 200 | + ) | ||
| 201 | + ], | ||
| 152 | ), | 202 | ), |
| 153 | ), | 203 | ), |
| 154 | - Container( | ||
| 155 | - width: ScreenUtil().setWidth(108), | ||
| 156 | - height: ScreenUtil().setHeight(2), | ||
| 157 | - color: MyColours.color_ffffff, | ||
| 158 | - ), | ||
| 159 | - ], | ||
| 160 | - ), | ||
| 161 | - _middleWidget("餐厅", user.sellername), | ||
| 162 | - _middleWidget( | ||
| 163 | - "包间", widget.tableInfo.replaceAll("\n", "")), | ||
| 164 | - _middleWidget("时间", dateTimeStr), | ||
| 165 | - VEmptyView(38), | ||
| 166 | - Column( | 204 | + VEmptyView(couponHeight), |
| 205 | + ])), | ||
| 206 | + Container( | ||
| 207 | + width: double.infinity, | ||
| 208 | + height: ScreenUtil().setHeight(99), | ||
| 209 | + child: Row( | ||
| 167 | children: <Widget>[ | 210 | children: <Widget>[ |
| 168 | - Row( | ||
| 169 | - mainAxisSize: MainAxisSize.min, | ||
| 170 | - children: <Widget>[ | ||
| 171 | - Image.asset( | ||
| 172 | - "assets/invication_map.png", | ||
| 173 | - width: ScreenUtil().setWidth(22), | ||
| 174 | - height: ScreenUtil().setWidth(28), | ||
| 175 | - ), | ||
| 176 | - Container( | ||
| 177 | - margin: EdgeInsets.symmetric( | ||
| 178 | - horizontal: ScreenUtil().setWidth(13)), | ||
| 179 | - child: Text("地址导航", | ||
| 180 | - style: TextStyle( | ||
| 181 | - color: MyColours.color_eadab9, | ||
| 182 | - fontSize: ScreenUtil().setSp(32))), | 211 | + GestureDetector( |
| 212 | + onTap: () { | ||
| 213 | + if (widget.phone.isEmpty) { | ||
| 214 | + Utils.showToast("没有预订人电话信息"); | ||
| 215 | + return; | ||
| 216 | + } | ||
| 217 | + NavigatorUtil.goSmsPage(context, widget.rid); | ||
| 218 | + }, | ||
| 219 | + child: Container( | ||
| 220 | + width: ScreenUtil().setWidth(232), | ||
| 221 | + height: double.infinity, | ||
| 222 | + color: MyColours.color_000000, | ||
| 223 | + alignment: Alignment.center, | ||
| 224 | + child: Text( | ||
| 225 | + "发短信", | ||
| 226 | + style: TextStyle( | ||
| 227 | + color: MyColours.color_eadab9, | ||
| 228 | + fontSize: ScreenUtil().setSp(34)), | ||
| 183 | ), | 229 | ), |
| 184 | - Image.asset( | ||
| 185 | - "assets/invication_arrow_right.png", | ||
| 186 | - width: ScreenUtil().setWidth(14), | ||
| 187 | - height: ScreenUtil().setWidth(22), | ||
| 188 | - ), | ||
| 189 | - ], | 230 | + ), |
| 190 | ), | 231 | ), |
| 191 | - Container( | ||
| 192 | - margin: EdgeInsets.only( | ||
| 193 | - top: ScreenUtil().setHeight(20)), | ||
| 194 | - child: Text( | ||
| 195 | - user.sellerAddr, | ||
| 196 | - style: TextStyle( | ||
| 197 | - color: MyColours.color_ffffff, | ||
| 198 | - fontSize: ScreenUtil().setSp(34)), | 232 | + Expanded( |
| 233 | + child: GestureDetector( | ||
| 234 | + onTap: () { | ||
| 235 | + Utils.goShareInvicationToWeChat(widget.rid); | ||
| 236 | + }, | ||
| 237 | + child: Container( | ||
| 238 | + width: double.infinity, | ||
| 239 | + height: double.infinity, | ||
| 240 | + color: MyColours.color_e3d2ac, | ||
| 241 | + alignment: Alignment.center, | ||
| 242 | + child: Text( | ||
| 243 | + "通知客户", | ||
| 244 | + style: TextStyle( | ||
| 245 | + color: MyColours.color_83734d, | ||
| 246 | + fontSize: ScreenUtil().setSp(34)), | ||
| 247 | + ), | ||
| 248 | + ), | ||
| 199 | ), | 249 | ), |
| 200 | ) | 250 | ) |
| 201 | ], | 251 | ], |
| 202 | - ) | ||
| 203 | - ], | ||
| 204 | - ), | 252 | + ), |
| 253 | + ) | ||
| 254 | + ])), | ||
| 255 | + Positioned( | ||
| 256 | + left: ScreenUtil().setWidth(40), | ||
| 257 | + top: ScreenUtil().setWidth(65), | ||
| 258 | + child: GestureDetector( | ||
| 259 | + onTap: () { | ||
| 260 | + Navigator.of(context).pop(); | ||
| 261 | + }, | ||
| 262 | + behavior: HitTestBehavior.opaque, | ||
| 263 | + child: Container( | ||
| 264 | + alignment: Alignment.centerLeft, | ||
| 265 | + child: Image.asset( | ||
| 266 | + "assets/invication_back.png", | ||
| 267 | + width: ScreenUtil().setWidth(20), | ||
| 268 | + height: ScreenUtil().setHeight(31), | ||
| 269 | + )), | ||
| 205 | ), | 270 | ), |
| 206 | ), | 271 | ), |
| 207 | - Container( | ||
| 208 | - width: double.infinity, | ||
| 209 | - height: ScreenUtil().setHeight(99), | ||
| 210 | - child: Row( | ||
| 211 | - children: <Widget>[ | ||
| 212 | - GestureDetector( | ||
| 213 | - onTap: () { | ||
| 214 | - if(widget.phone.isEmpty){ | ||
| 215 | - Utils.showToast("没有预订人电话信息"); | ||
| 216 | - return; | ||
| 217 | - } | ||
| 218 | - NavigatorUtil.goSmsPage(context, widget.rid); | ||
| 219 | - }, | ||
| 220 | - child: Container( | ||
| 221 | - width: ScreenUtil().setWidth(232), | ||
| 222 | - height: double.infinity, | ||
| 223 | - color: MyColours.color_000000, | ||
| 224 | - alignment: Alignment.center, | ||
| 225 | - child: Text( | ||
| 226 | - "发短信", | ||
| 227 | - style: TextStyle( | ||
| 228 | - color: MyColours.color_eadab9, | ||
| 229 | - fontSize: ScreenUtil().setSp(34)), | 272 | + Positioned( |
| 273 | + left: ScreenUtil().setWidth(180), | ||
| 274 | + bottom: ScreenUtil().setWidth(130), | ||
| 275 | + right: ScreenUtil().setWidth(180), | ||
| 276 | + child: GestureDetector( | ||
| 277 | + onTap: () { | ||
| 278 | + NavigatorUtil.goCouponSelectPage(context); | ||
| 279 | + }, | ||
| 280 | + behavior: HitTestBehavior.opaque, | ||
| 281 | + child: Center( | ||
| 282 | + child: Container( | ||
| 283 | + // width: ScreenUtil().setWidth(400), | ||
| 284 | + padding: EdgeInsets.symmetric( | ||
| 285 | + horizontal: ScreenUtil().setWidth(40), | ||
| 286 | + vertical: ScreenUtil().setWidth(20)), | ||
| 287 | + // height: ScreenUtil().setWidth(100), | ||
| 288 | + decoration: BoxDecoration( | ||
| 289 | + color: MyColours.color_ffffff, | ||
| 290 | + borderRadius: BorderRadius.circular( | ||
| 291 | + ScreenUtil().setWidth(20))), | ||
| 292 | + child: Text( | ||
| 293 | + '共赠送${couponProvider.coupons.length}张优惠券\n点击查看', | ||
| 294 | + textAlign: TextAlign.center, | ||
| 295 | + style: TextStyle( | ||
| 296 | + fontSize: ScreenUtil().setSp(28), | ||
| 230 | ), | 297 | ), |
| 231 | ), | 298 | ), |
| 232 | ), | 299 | ), |
| 233 | - Expanded( | ||
| 234 | - child: GestureDetector( | ||
| 235 | - onTap: () { | ||
| 236 | - Utils.goShareInvicationToWeChat(widget.rid); | ||
| 237 | - }, | ||
| 238 | - child: Container( | ||
| 239 | - width: double.infinity, | ||
| 240 | - height: double.infinity, | ||
| 241 | - color: MyColours.color_e3d2ac, | ||
| 242 | - alignment: Alignment.center, | ||
| 243 | - child: Text( | ||
| 244 | - "通知客户", | ||
| 245 | - style: TextStyle( | ||
| 246 | - color: MyColours.color_83734d, | ||
| 247 | - fontSize: ScreenUtil().setSp(34)), | ||
| 248 | - ), | ||
| 249 | - ), | ||
| 250 | - ), | ||
| 251 | - ) | ||
| 252 | - ], | 300 | + ), |
| 253 | ), | 301 | ), |
| 254 | ) | 302 | ) |
| 255 | ], | 303 | ], |
| 256 | - )), | ||
| 257 | - ), | ||
| 258 | - ); | 304 | + ))); |
| 259 | } | 305 | } |
| 260 | } | 306 | } |
| @@ -14,6 +14,7 @@ import 'package:one_key/widgets/app_bar.dart'; | @@ -14,6 +14,7 @@ import 'package:one_key/widgets/app_bar.dart'; | ||
| 14 | import 'package:one_key/widgets/area_item.dart'; | 14 | import 'package:one_key/widgets/area_item.dart'; |
| 15 | import 'package:one_key/widgets/common_button.dart'; | 15 | import 'package:one_key/widgets/common_button.dart'; |
| 16 | import 'package:one_key/widgets/page_exception.dart'; | 16 | import 'package:one_key/widgets/page_exception.dart'; |
| 17 | +import 'package:one_key/widgets/system_app_bar.dart'; | ||
| 17 | import 'package:one_key/widgets/table_item.dart'; | 18 | import 'package:one_key/widgets/table_item.dart'; |
| 18 | import 'package:one_key/models/table.dart' as t; | 19 | import 'package:one_key/models/table.dart' as t; |
| 19 | import 'package:provider/provider.dart'; | 20 | import 'package:provider/provider.dart'; |
| @@ -47,347 +48,334 @@ class TableManagerPageState extends State<TableManagerPage> { | @@ -47,347 +48,334 @@ class TableManagerPageState extends State<TableManagerPage> { | ||
| 47 | 48 | ||
| 48 | @override | 49 | @override |
| 49 | Widget build(BuildContext context) { | 50 | Widget build(BuildContext context) { |
| 50 | - return SafeArea( | ||
| 51 | - child: Consumer<TableManagerModel>( | ||
| 52 | - builder: (context, model, child) { | ||
| 53 | - return Column( | ||
| 54 | - children: <Widget>[ | ||
| 55 | - MyAppBar("桌位", showBack: false), | ||
| 56 | - Container( | ||
| 57 | - color: MyColours.color_ffffff, | ||
| 58 | - width: double.infinity, | ||
| 59 | - padding: | ||
| 60 | - EdgeInsets.symmetric(vertical: ScreenUtil().setHeight(16)), | ||
| 61 | - child: Row( | ||
| 62 | - crossAxisAlignment: CrossAxisAlignment.center, | ||
| 63 | - children: <Widget>[ | ||
| 64 | - Expanded( | ||
| 65 | - child: Center( | ||
| 66 | - child: GestureDetector( | ||
| 67 | - onTap: () { | ||
| 68 | - DialogUtil.showCalendarDialog( | ||
| 69 | - context, tableManagerModel.dateTime) | ||
| 70 | - .then((day) { | ||
| 71 | - if (day != null) { | ||
| 72 | - tableManagerModel.createDateText(context, day); | ||
| 73 | - } | ||
| 74 | - }); | ||
| 75 | - }, | ||
| 76 | - child: Container( | ||
| 77 | - child: Text( | ||
| 78 | - tableManagerModel.dateText, | ||
| 79 | - style: TextStyle( | ||
| 80 | - color: MyColours.color_199095, | ||
| 81 | - fontSize: ScreenUtil().setSp(34)), | ||
| 82 | - ), | 51 | + return Consumer<TableManagerModel>( |
| 52 | + builder: (context, model, child) { | ||
| 53 | + return Column( | ||
| 54 | + children: <Widget>[ | ||
| 55 | + SystemAppBar("桌位", showLeading: false), | ||
| 56 | + Container( | ||
| 57 | + color: MyColours.color_ffffff, | ||
| 58 | + width: double.infinity, | ||
| 59 | + padding: | ||
| 60 | + EdgeInsets.symmetric(vertical: ScreenUtil().setHeight(16)), | ||
| 61 | + child: Row( | ||
| 62 | + crossAxisAlignment: CrossAxisAlignment.center, | ||
| 63 | + children: <Widget>[ | ||
| 64 | + Expanded( | ||
| 65 | + child: Center( | ||
| 66 | + child: GestureDetector( | ||
| 67 | + onTap: () { | ||
| 68 | + DialogUtil.showCalendarDialog( | ||
| 69 | + context, tableManagerModel.dateTime) | ||
| 70 | + .then((day) { | ||
| 71 | + if (day != null) { | ||
| 72 | + tableManagerModel.createDateText(context, day); | ||
| 73 | + } | ||
| 74 | + }); | ||
| 75 | + }, | ||
| 76 | + child: Container( | ||
| 77 | + child: Text( | ||
| 78 | + tableManagerModel.dateText, | ||
| 79 | + style: TextStyle( | ||
| 80 | + color: MyColours.color_199095, | ||
| 81 | + fontSize: ScreenUtil().setSp(34)), | ||
| 83 | ), | 82 | ), |
| 84 | ), | 83 | ), |
| 85 | ), | 84 | ), |
| 86 | ), | 85 | ), |
| 87 | - MyDivider( | ||
| 88 | - ScreenUtil().setWidth(2), | ||
| 89 | - ScreenUtil().setHeight(68), | ||
| 90 | - color: MyColours.color_E0E0E0, | ||
| 91 | - ), | ||
| 92 | - Expanded( | ||
| 93 | - child: Padding( | ||
| 94 | - padding: EdgeInsets.symmetric( | ||
| 95 | - horizontal: ScreenUtil().setWidth(30)), | ||
| 96 | - child: Row( | ||
| 97 | - mainAxisAlignment: MainAxisAlignment.center, | ||
| 98 | - crossAxisAlignment: CrossAxisAlignment.center, | ||
| 99 | - children: <Widget>[ | ||
| 100 | - Offstage( | ||
| 101 | - offstage: | ||
| 102 | - tableManagerModel.morning == "00:00-00:00" | ||
| 103 | - ? true | ||
| 104 | - : false, | ||
| 105 | - child: Padding( | ||
| 106 | - padding: EdgeInsets.only( | ||
| 107 | - right: ScreenUtil().setWidth(18)), | ||
| 108 | - child: CommonButton( | ||
| 109 | - content: "早市", | ||
| 110 | - state: | ||
| 111 | - tableManagerModel.currTimeIndex == 1 | ||
| 112 | - ? 1 | ||
| 113 | - : 0, | ||
| 114 | - width: 92, | ||
| 115 | - height: 48, | ||
| 116 | - fontSize: 32, | ||
| 117 | - onPress: () { | ||
| 118 | - if (tableManagerModel.currTimeIndex == | ||
| 119 | - 1) return; | ||
| 120 | - tableManagerModel.currTimeIndex = 1; | ||
| 121 | - tableManagerModel | ||
| 122 | - .getReserveList(context); | ||
| 123 | - }, | ||
| 124 | - ))), | ||
| 125 | - Offstage( | ||
| 126 | - offstage: | ||
| 127 | - tableManagerModel.noon == "00:00-00:00" | ||
| 128 | - ? true | ||
| 129 | - : false, | ||
| 130 | - child: Padding( | ||
| 131 | - padding: EdgeInsets.only( | ||
| 132 | - right: ScreenUtil().setWidth(18)), | ||
| 133 | - child: CommonButton( | ||
| 134 | - content: "午市", | ||
| 135 | - state: | ||
| 136 | - tableManagerModel.currTimeIndex == 2 | ||
| 137 | - ? 1 | ||
| 138 | - : 0, | ||
| 139 | - width: 92, | ||
| 140 | - height: 48, | ||
| 141 | - fontSize: 32, | ||
| 142 | - onPress: () { | ||
| 143 | - if (tableManagerModel.currTimeIndex == | ||
| 144 | - 2) return; | ||
| 145 | - tableManagerModel.currTimeIndex = 2; | ||
| 146 | - tableManagerModel | ||
| 147 | - .getReserveList(context); | ||
| 148 | - }, | ||
| 149 | - ))), | ||
| 150 | - Offstage( | ||
| 151 | - offstage: tableManagerModel.night == "00:00-00:00" | 86 | + ), |
| 87 | + MyDivider( | ||
| 88 | + ScreenUtil().setWidth(2), | ||
| 89 | + ScreenUtil().setHeight(68), | ||
| 90 | + color: MyColours.color_E0E0E0, | ||
| 91 | + ), | ||
| 92 | + Expanded( | ||
| 93 | + child: Padding( | ||
| 94 | + padding: EdgeInsets.symmetric( | ||
| 95 | + horizontal: ScreenUtil().setWidth(30)), | ||
| 96 | + child: Row( | ||
| 97 | + mainAxisAlignment: MainAxisAlignment.center, | ||
| 98 | + crossAxisAlignment: CrossAxisAlignment.center, | ||
| 99 | + children: <Widget>[ | ||
| 100 | + Offstage( | ||
| 101 | + offstage: | ||
| 102 | + tableManagerModel.morning == "00:00-00:00" | ||
| 103 | + ? true | ||
| 104 | + : false, | ||
| 105 | + child: Padding( | ||
| 106 | + padding: EdgeInsets.only( | ||
| 107 | + right: ScreenUtil().setWidth(18)), | ||
| 108 | + child: CommonButton( | ||
| 109 | + content: "早市", | ||
| 110 | + state: tableManagerModel.currTimeIndex == 1 | ||
| 111 | + ? 1 | ||
| 112 | + : 0, | ||
| 113 | + width: 92, | ||
| 114 | + height: 48, | ||
| 115 | + fontSize: 32, | ||
| 116 | + onPress: () { | ||
| 117 | + if (tableManagerModel.currTimeIndex == 1) | ||
| 118 | + return; | ||
| 119 | + tableManagerModel.currTimeIndex = 1; | ||
| 120 | + tableManagerModel.getReserveList(context); | ||
| 121 | + }, | ||
| 122 | + ))), | ||
| 123 | + Offstage( | ||
| 124 | + offstage: tableManagerModel.noon == "00:00-00:00" | ||
| 152 | ? true | 125 | ? true |
| 153 | : false, | 126 | : false, |
| 154 | - child: Container( | ||
| 155 | - // padding: EdgeInsets.symmetric( | ||
| 156 | - // horizontal: ScreenUtil().setWidth(10)), | 127 | + child: Padding( |
| 128 | + padding: EdgeInsets.only( | ||
| 129 | + right: ScreenUtil().setWidth(18)), | ||
| 157 | child: CommonButton( | 130 | child: CommonButton( |
| 158 | - content: "晚市", | ||
| 159 | - state: tableManagerModel.currTimeIndex == 3 | ||
| 160 | - ? 1 | ||
| 161 | - : 0, | ||
| 162 | - width: 92, | ||
| 163 | - height: 48, | ||
| 164 | - fontSize: 32, | ||
| 165 | - onPress: () { | ||
| 166 | - if (tableManagerModel.currTimeIndex == 3) | ||
| 167 | - return; | ||
| 168 | - tableManagerModel.currTimeIndex = 3; | ||
| 169 | - tableManagerModel.getReserveList(context); | ||
| 170 | - }, | ||
| 171 | - )), | ||
| 172 | - ), | ||
| 173 | - ], | ||
| 174 | - ), | 131 | + content: "午市", |
| 132 | + state: tableManagerModel.currTimeIndex == 2 | ||
| 133 | + ? 1 | ||
| 134 | + : 0, | ||
| 135 | + width: 92, | ||
| 136 | + height: 48, | ||
| 137 | + fontSize: 32, | ||
| 138 | + onPress: () { | ||
| 139 | + if (tableManagerModel.currTimeIndex == 2) | ||
| 140 | + return; | ||
| 141 | + tableManagerModel.currTimeIndex = 2; | ||
| 142 | + tableManagerModel.getReserveList(context); | ||
| 143 | + }, | ||
| 144 | + ))), | ||
| 145 | + Offstage( | ||
| 146 | + offstage: tableManagerModel.night == "00:00-00:00" | ||
| 147 | + ? true | ||
| 148 | + : false, | ||
| 149 | + child: Container( | ||
| 150 | + // padding: EdgeInsets.symmetric( | ||
| 151 | + // horizontal: ScreenUtil().setWidth(10)), | ||
| 152 | + child: CommonButton( | ||
| 153 | + content: "晚市", | ||
| 154 | + state: | ||
| 155 | + tableManagerModel.currTimeIndex == 3 ? 1 : 0, | ||
| 156 | + width: 92, | ||
| 157 | + height: 48, | ||
| 158 | + fontSize: 32, | ||
| 159 | + onPress: () { | ||
| 160 | + if (tableManagerModel.currTimeIndex == 3) | ||
| 161 | + return; | ||
| 162 | + tableManagerModel.currTimeIndex = 3; | ||
| 163 | + tableManagerModel.getReserveList(context); | ||
| 164 | + }, | ||
| 165 | + )), | ||
| 166 | + ), | ||
| 167 | + ], | ||
| 175 | ), | 168 | ), |
| 176 | - ) | ||
| 177 | - ], | ||
| 178 | - ), | ||
| 179 | - ), | ||
| 180 | - Container( | ||
| 181 | - height: ScreenUtil().setWidth(20), | ||
| 182 | - width: double.infinity, | ||
| 183 | - color: MyColours.color_f5f5f5, | 169 | + ), |
| 170 | + ) | ||
| 171 | + ], | ||
| 184 | ), | 172 | ), |
| 185 | - Expanded( | ||
| 186 | - child: Consumer<TableManagerModel>( | ||
| 187 | - builder: (context, model, child) { | ||
| 188 | - if (model.pageState != PageState.Success) { | ||
| 189 | - return ExceptionPage( | ||
| 190 | - pageState: model.pageState, | ||
| 191 | - callback: () { | ||
| 192 | - if (tableManagerModel.tableOuterList.isEmpty) { | ||
| 193 | - tableManagerModel.getTableList(context); | ||
| 194 | - } else { | ||
| 195 | - tableManagerModel.getReserveList(context); | ||
| 196 | - } | ||
| 197 | - }, | ||
| 198 | - emptyMsg: "暂时没有桌位哦", | ||
| 199 | - emptyImg: "empty_search", | ||
| 200 | - showMsg: "加载中,请稍后...", | ||
| 201 | - ); | ||
| 202 | - } else { | ||
| 203 | - return Container( | ||
| 204 | - color: MyColours.color_ffffff, | ||
| 205 | - child: Row( | ||
| 206 | - children: <Widget>[ | ||
| 207 | - Container( | ||
| 208 | - width: ScreenUtil().setWidth(170), | ||
| 209 | - height: double.infinity, | ||
| 210 | - color: MyColours.color_f1f1f1, | ||
| 211 | - child: ListView.builder( | ||
| 212 | - itemBuilder: (context, index) { | ||
| 213 | - return Selector<TableManagerModel, Area>( | ||
| 214 | - selector: (context, model) => | ||
| 215 | - model.areas[index], | ||
| 216 | - builder: (context, area, _) { | ||
| 217 | - return AreaItem( | ||
| 218 | - area, tableManagerModel.currentArea, | ||
| 219 | - (area) { | ||
| 220 | - setState(() { | ||
| 221 | - tableManagerModel.currentArea = | ||
| 222 | - (area as Area).name; | ||
| 223 | - tableManagerModel.currentTables = | ||
| 224 | - tableManagerModel.areaTableMap[ | ||
| 225 | - tableManagerModel | ||
| 226 | - .currentArea]; | ||
| 227 | - }); | 173 | + ), |
| 174 | + Container( | ||
| 175 | + height: ScreenUtil().setWidth(20), | ||
| 176 | + width: double.infinity, | ||
| 177 | + color: MyColours.color_f5f5f5, | ||
| 178 | + ), | ||
| 179 | + Expanded( | ||
| 180 | + child: Consumer<TableManagerModel>( | ||
| 181 | + builder: (context, model, child) { | ||
| 182 | + if (model.pageState != PageState.Success) { | ||
| 183 | + return ExceptionPage( | ||
| 184 | + pageState: model.pageState, | ||
| 185 | + callback: () { | ||
| 186 | + if (tableManagerModel.tableOuterList.isEmpty) { | ||
| 187 | + tableManagerModel.getTableList(context); | ||
| 188 | + } else { | ||
| 189 | + tableManagerModel.getReserveList(context); | ||
| 190 | + } | ||
| 191 | + }, | ||
| 192 | + emptyMsg: "暂时没有桌位哦", | ||
| 193 | + emptyImg: "empty_search", | ||
| 194 | + showMsg: "加载中,请稍后...", | ||
| 195 | + ); | ||
| 196 | + } else { | ||
| 197 | + return Container( | ||
| 198 | + color: MyColours.color_ffffff, | ||
| 199 | + child: Row( | ||
| 200 | + children: <Widget>[ | ||
| 201 | + Container( | ||
| 202 | + width: ScreenUtil().setWidth(170), | ||
| 203 | + height: double.infinity, | ||
| 204 | + color: MyColours.color_f1f1f1, | ||
| 205 | + child: ListView.builder( | ||
| 206 | + itemBuilder: (context, index) { | ||
| 207 | + return Selector<TableManagerModel, Area>( | ||
| 208 | + selector: (context, model) => | ||
| 209 | + model.areas[index], | ||
| 210 | + builder: (context, area, _) { | ||
| 211 | + return AreaItem( | ||
| 212 | + area, tableManagerModel.currentArea, | ||
| 213 | + (area) { | ||
| 214 | + setState(() { | ||
| 215 | + tableManagerModel.currentArea = | ||
| 216 | + (area as Area).name; | ||
| 217 | + tableManagerModel.currentTables = | ||
| 218 | + tableManagerModel.areaTableMap[ | ||
| 219 | + tableManagerModel.currentArea]; | ||
| 228 | }); | 220 | }); |
| 229 | - }, | ||
| 230 | - ); | ||
| 231 | - }, | ||
| 232 | - itemExtent: ScreenUtil().setHeight(207), | ||
| 233 | - itemCount: tableManagerModel.areas.length, | ||
| 234 | - ), | 221 | + }); |
| 222 | + }, | ||
| 223 | + ); | ||
| 224 | + }, | ||
| 225 | + itemExtent: ScreenUtil().setHeight(207), | ||
| 226 | + itemCount: tableManagerModel.areas.length, | ||
| 235 | ), | 227 | ), |
| 236 | - Expanded( | ||
| 237 | - child: Padding( | ||
| 238 | - padding: EdgeInsets.symmetric( | ||
| 239 | - vertical: ScreenUtil().setHeight(10), | ||
| 240 | - horizontal: ScreenUtil().setWidth(9)), | ||
| 241 | - child: Column( | ||
| 242 | - children: [ | ||
| 243 | - Expanded( | ||
| 244 | - child: GridView.builder( | ||
| 245 | - gridDelegate: | ||
| 246 | - SliverGridDelegateWithFixedCrossAxisCount( | ||
| 247 | - crossAxisCount: 3, | ||
| 248 | - childAspectRatio: 8 / 9), | ||
| 249 | - itemBuilder: (context, index) { | ||
| 250 | - return Selector<TableManagerModel, | ||
| 251 | - t.Table>( | ||
| 252 | - shouldRebuild: (pre, next) => true, | ||
| 253 | - selector: (context, model) => | ||
| 254 | - model.currentTables[index], | ||
| 255 | - builder: (context, table, _) { | ||
| 256 | - return TableItem(table, | ||
| 257 | - onSelected: (table) { | ||
| 258 | - if ((table as t.Table) | ||
| 259 | - .selected) { | ||
| 260 | - tableManagerModel.selectTables | ||
| 261 | - .add(table); | ||
| 262 | - } else { | ||
| 263 | - tableManagerModel.selectTables | ||
| 264 | - .removeWhere((t) => | ||
| 265 | - t.id == table.id); | ||
| 266 | - } | ||
| 267 | - DialogUtil | ||
| 268 | - .showTableManagerDialog( | ||
| 269 | - context, table) | ||
| 270 | - .then((value) { | ||
| 271 | - if (value != null) { | ||
| 272 | - switch (value) { | ||
| 273 | - case 1: //查看详情 | ||
| 274 | - NavigatorUtil | ||
| 275 | - .goNotebookDetailPage( | ||
| 276 | - context, | ||
| 277 | - tableManagerModel | ||
| 278 | - .tableMap[ | ||
| 279 | - table | ||
| 280 | - .id] | ||
| 281 | - .id); | ||
| 282 | - break; | ||
| 283 | - case 2: //订座 | ||
| 284 | - NavigatorUtil.goNoteBookChangePage( | ||
| 285 | - context, | ||
| 286 | - NotebookDetail.fromTableManager( | ||
| 287 | - tableManagerModel | ||
| 288 | - .getCurrDdateStr(), | ||
| 289 | - tableManagerModel | ||
| 290 | - .currTimeIndex | ||
| 291 | - .toString(), | ||
| 292 | - table), | ||
| 293 | - ""); | ||
| 294 | - break; | ||
| 295 | - case 3: //停用,启用桌位 | ||
| 296 | - Map<String, String> | ||
| 297 | - params = { | ||
| 298 | - "id": | ||
| 299 | - (table as t.Table) | ||
| 300 | - .id, | ||
| 301 | - "status": (table as t | ||
| 302 | - .Table) | ||
| 303 | - .enable == | ||
| 304 | - "1" | ||
| 305 | - ? "0" | ||
| 306 | - : "1" | ||
| 307 | - }; | ||
| 308 | - tableManagerModel | ||
| 309 | - .setSwitchStatus( | ||
| 310 | - context, params) | ||
| 311 | - .then((value) { | ||
| 312 | - if (value != null) { | ||
| 313 | - (table as t.Table) | ||
| 314 | - .enable = | ||
| 315 | - ((int.parse((table as t.Table).enable) + | ||
| 316 | - 1) % | ||
| 317 | - 2) | ||
| 318 | - .toString(); | ||
| 319 | - if ((table as t | 228 | + ), |
| 229 | + Expanded( | ||
| 230 | + child: Padding( | ||
| 231 | + padding: EdgeInsets.symmetric( | ||
| 232 | + vertical: ScreenUtil().setHeight(10), | ||
| 233 | + horizontal: ScreenUtil().setWidth(9)), | ||
| 234 | + child: Column( | ||
| 235 | + children: [ | ||
| 236 | + Expanded( | ||
| 237 | + child: GridView.builder( | ||
| 238 | + gridDelegate: | ||
| 239 | + SliverGridDelegateWithFixedCrossAxisCount( | ||
| 240 | + crossAxisCount: 3, | ||
| 241 | + childAspectRatio: 8 / 9), | ||
| 242 | + itemBuilder: (context, index) { | ||
| 243 | + return Selector<TableManagerModel, | ||
| 244 | + t.Table>( | ||
| 245 | + shouldRebuild: (pre, next) => true, | ||
| 246 | + selector: (context, model) => | ||
| 247 | + model.currentTables[index], | ||
| 248 | + builder: (context, table, _) { | ||
| 249 | + return TableItem(table, | ||
| 250 | + onSelected: (table) { | ||
| 251 | + if ((table as t.Table).selected) { | ||
| 252 | + tableManagerModel.selectTables | ||
| 253 | + .add(table); | ||
| 254 | + } else { | ||
| 255 | + tableManagerModel.selectTables | ||
| 256 | + .removeWhere((t) => | ||
| 257 | + t.id == table.id); | ||
| 258 | + } | ||
| 259 | + DialogUtil.showTableManagerDialog( | ||
| 260 | + context, table) | ||
| 261 | + .then((value) { | ||
| 262 | + if (value != null) { | ||
| 263 | + switch (value) { | ||
| 264 | + case 1: //查看详情 | ||
| 265 | + NavigatorUtil | ||
| 266 | + .goNotebookDetailPage( | ||
| 267 | + context, | ||
| 268 | + tableManagerModel | ||
| 269 | + .tableMap[ | ||
| 270 | + table.id] | ||
| 271 | + .id); | ||
| 272 | + break; | ||
| 273 | + case 2: //订座 | ||
| 274 | + NavigatorUtil.goNoteBookChangePage( | ||
| 275 | + context, | ||
| 276 | + NotebookDetail.fromTableManager( | ||
| 277 | + tableManagerModel | ||
| 278 | + .getCurrDdateStr(), | ||
| 279 | + tableManagerModel | ||
| 280 | + .currTimeIndex | ||
| 281 | + .toString(), | ||
| 282 | + table), | ||
| 283 | + ""); | ||
| 284 | + break; | ||
| 285 | + case 3: //停用,启用桌位 | ||
| 286 | + Map<String, String> | ||
| 287 | + params = { | ||
| 288 | + "id": (table as t.Table) | ||
| 289 | + .id, | ||
| 290 | + "status": (table as t | ||
| 320 | .Table) | 291 | .Table) |
| 321 | .enable == | 292 | .enable == |
| 322 | - "1") { | ||
| 323 | - for (Area area | ||
| 324 | - in tableManagerModel | ||
| 325 | - .areas) { | ||
| 326 | - if (area.name == | ||
| 327 | - tableManagerModel | ||
| 328 | - .currentArea) { | ||
| 329 | - if (table.sign != | ||
| 330 | - '5' && | ||
| 331 | - table.sign != | ||
| 332 | - '1') { | ||
| 333 | - //已预订 | ||
| 334 | - area.count++; | ||
| 335 | - } | ||
| 336 | - break; | 293 | + "1" |
| 294 | + ? "0" | ||
| 295 | + : "1" | ||
| 296 | + }; | ||
| 297 | + tableManagerModel | ||
| 298 | + .setSwitchStatus( | ||
| 299 | + context, params) | ||
| 300 | + .then((value) { | ||
| 301 | + if (value != null) { | ||
| 302 | + (table as t.Table) | ||
| 303 | + .enable = | ||
| 304 | + ((int.parse((table as t.Table) | ||
| 305 | + .enable) + | ||
| 306 | + 1) % | ||
| 307 | + 2) | ||
| 308 | + .toString(); | ||
| 309 | + if ((table as t.Table) | ||
| 310 | + .enable == | ||
| 311 | + "1") { | ||
| 312 | + for (Area area | ||
| 313 | + in tableManagerModel | ||
| 314 | + .areas) { | ||
| 315 | + if (area.name == | ||
| 316 | + tableManagerModel | ||
| 317 | + .currentArea) { | ||
| 318 | + if (table.sign != | ||
| 319 | + '5' && | ||
| 320 | + table.sign != | ||
| 321 | + '1') { | ||
| 322 | + //已预订 | ||
| 323 | + area.count++; | ||
| 337 | } | 324 | } |
| 325 | + break; | ||
| 338 | } | 326 | } |
| 339 | - } else { | ||
| 340 | - for (Area area | ||
| 341 | - in tableManagerModel | ||
| 342 | - .areas) { | ||
| 343 | - if (area.name == | ||
| 344 | - tableManagerModel | ||
| 345 | - .currentArea) { | ||
| 346 | - if (table.sign != | ||
| 347 | - '5' && | ||
| 348 | - table.sign != | ||
| 349 | - '1') { | ||
| 350 | - //已预订 | ||
| 351 | - area.count--; | ||
| 352 | - } | ||
| 353 | - break; | 327 | + } |
| 328 | + } else { | ||
| 329 | + for (Area area | ||
| 330 | + in tableManagerModel | ||
| 331 | + .areas) { | ||
| 332 | + if (area.name == | ||
| 333 | + tableManagerModel | ||
| 334 | + .currentArea) { | ||
| 335 | + if (table.sign != | ||
| 336 | + '5' && | ||
| 337 | + table.sign != | ||
| 338 | + '1') { | ||
| 339 | + //已预订 | ||
| 340 | + area.count--; | ||
| 354 | } | 341 | } |
| 342 | + break; | ||
| 355 | } | 343 | } |
| 356 | } | 344 | } |
| 357 | - tableManagerModel | ||
| 358 | - .notifyListeners(); | ||
| 359 | } | 345 | } |
| 360 | - }); | ||
| 361 | - break; | ||
| 362 | - } | 346 | + tableManagerModel |
| 347 | + .notifyListeners(); | ||
| 348 | + } | ||
| 349 | + }); | ||
| 350 | + break; | ||
| 363 | } | 351 | } |
| 364 | - }); | ||
| 365 | - }, | ||
| 366 | - canSelected: false, | ||
| 367 | - fromPage: 'table_manage', | ||
| 368 | - tableMap: tableManagerModel | ||
| 369 | - .tableMap, | ||
| 370 | - rid: ""); | 352 | + } |
| 353 | + }); | ||
| 371 | }, | 354 | }, |
| 372 | - ); | ||
| 373 | - }, | ||
| 374 | - itemCount: tableManagerModel | ||
| 375 | - .currentTables.length, | ||
| 376 | - )), | ||
| 377 | - ], | ||
| 378 | - )), | ||
| 379 | - ) | ||
| 380 | - ], | ||
| 381 | - ), | ||
| 382 | - ); | ||
| 383 | - } | ||
| 384 | - }, | ||
| 385 | - ), | 355 | + canSelected: false, |
| 356 | + fromPage: 'table_manage', | ||
| 357 | + tableMap: | ||
| 358 | + tableManagerModel.tableMap, | ||
| 359 | + rid: ""); | ||
| 360 | + }, | ||
| 361 | + ); | ||
| 362 | + }, | ||
| 363 | + itemCount: tableManagerModel | ||
| 364 | + .currentTables.length, | ||
| 365 | + )), | ||
| 366 | + ], | ||
| 367 | + )), | ||
| 368 | + ) | ||
| 369 | + ], | ||
| 370 | + ), | ||
| 371 | + ); | ||
| 372 | + } | ||
| 373 | + }, | ||
| 386 | ), | 374 | ), |
| 387 | - ], | ||
| 388 | - ); | ||
| 389 | - }, | ||
| 390 | - ), | 375 | + ), |
| 376 | + ], | ||
| 377 | + ); | ||
| 378 | + }, | ||
| 391 | ); | 379 | ); |
| 392 | } | 380 | } |
| 393 | 381 |
| @@ -5,10 +5,66 @@ class CouponProvider with ChangeNotifier { | @@ -5,10 +5,66 @@ class CouponProvider with ChangeNotifier { | ||
| 5 | List<bool> swichStateData = []; //优惠券是否启用 true启用 false停用 | 5 | List<bool> swichStateData = []; //优惠券是否启用 true启用 false停用 |
| 6 | PageState pageState = PageState.Loading; | 6 | PageState pageState = PageState.Loading; |
| 7 | PageState pageStateHistory = PageState.Loading; | 7 | PageState pageStateHistory = PageState.Loading; |
| 8 | + PageState pageStateSelect = PageState.Loading; | ||
| 9 | + | ||
| 10 | + bool checkValue = true; //优惠券页面“全选”按钮状态 ----- 数据状态全部选中为true | ||
| 11 | + List<Map<String, dynamic>> listData = []; //优惠券页面数据 | ||
| 12 | + List coupons = []; //选中的优惠券id集合 | ||
| 8 | 13 | ||
| 9 | CouponProvider() { | 14 | CouponProvider() { |
| 10 | for (int i = 0; i < 20; i++) { | 15 | for (int i = 0; i < 20; i++) { |
| 11 | swichStateData.add(true); | 16 | swichStateData.add(true); |
| 17 | + listData.add({'checked': true, 'id': '${i}'}); | ||
| 18 | + } | ||
| 19 | + } | ||
| 20 | + | ||
| 21 | + //全选按钮执行“全选” | ||
| 22 | + addAll() async { | ||
| 23 | + //把数据状态全部改成true,即选中状态 | ||
| 24 | + coupons = []; | ||
| 25 | + for (var i = 0; i < listData.length; i++) { | ||
| 26 | + listData[i]['checked'] = true; | ||
| 27 | + coupons.add(listData[i]['id']); | ||
| 28 | + } | ||
| 29 | + checkValue = true; | ||
| 30 | + notifyListeners(); | ||
| 31 | + } | ||
| 32 | + | ||
| 33 | +//全选按钮执行“全不选” | ||
| 34 | + cancelAll() async { | ||
| 35 | + //把数据状态全部改成false,即不选中状态 | ||
| 36 | + for (var i = 0; i < listData.length; i++) { | ||
| 37 | + listData[i]['checked'] = false; | ||
| 38 | + } | ||
| 39 | + coupons = []; | ||
| 40 | + checkValue = false; | ||
| 41 | + notifyListeners(); | ||
| 42 | + } | ||
| 43 | + | ||
| 44 | +//选中 | ||
| 45 | + addData(int index) { | ||
| 46 | + listData[index]['checked'] = true; | ||
| 47 | + coupons.add(listData[index]['id']); | ||
| 48 | + notifyListeners(); | ||
| 49 | + } | ||
| 50 | + | ||
| 51 | +//未选中 | ||
| 52 | + cancelData(int index) { | ||
| 53 | + listData[index]['checked'] = false; | ||
| 54 | + coupons.removeWhere((element) => element == listData[index]['id']); | ||
| 55 | + notifyListeners(); | ||
| 56 | + } | ||
| 57 | + | ||
| 58 | + //获取全选按钮的状态 true or false | ||
| 59 | + getCheckValue() { | ||
| 60 | + bool temp = listData.any((value) { | ||
| 61 | + return value['checked'] == false; | ||
| 62 | + }); | ||
| 63 | + if (temp == true) { | ||
| 64 | + checkValue = false; | ||
| 65 | + } else { | ||
| 66 | + checkValue = true; | ||
| 12 | } | 67 | } |
| 68 | + notifyListeners(); | ||
| 13 | } | 69 | } |
| 14 | } | 70 | } |
| @@ -8,6 +8,7 @@ import 'package:one_key/models/table_list.dart'; | @@ -8,6 +8,7 @@ import 'package:one_key/models/table_list.dart'; | ||
| 8 | import 'package:one_key/pages/coupon/coupon_edit_page.dart'; | 8 | import 'package:one_key/pages/coupon/coupon_edit_page.dart'; |
| 9 | import 'package:one_key/pages/coupon/coupon_history_page.dart'; | 9 | import 'package:one_key/pages/coupon/coupon_history_page.dart'; |
| 10 | import 'package:one_key/pages/coupon/coupon_page.dart'; | 10 | import 'package:one_key/pages/coupon/coupon_page.dart'; |
| 11 | +import 'package:one_key/pages/coupon/coupon_selecet_page.dart'; | ||
| 11 | import 'package:one_key/pages/detail/notebook_detail_change_page.dart'; | 12 | import 'package:one_key/pages/detail/notebook_detail_change_page.dart'; |
| 12 | import 'package:one_key/pages/home/home_page.dart'; | 13 | import 'package:one_key/pages/home/home_page.dart'; |
| 13 | import 'package:one_key/pages/invicate/invitation_page.dart'; | 14 | import 'package:one_key/pages/invicate/invitation_page.dart'; |
| @@ -239,3 +240,11 @@ var handleCouponEditPageHandler = new Handler( | @@ -239,3 +240,11 @@ var handleCouponEditPageHandler = new Handler( | ||
| 239 | // bool fromNotify = FluroConvertUtils.string2bool(params["fromNotify"].first); | 240 | // bool fromNotify = FluroConvertUtils.string2bool(params["fromNotify"].first); |
| 240 | return CouponEidtPage(); | 241 | return CouponEidtPage(); |
| 241 | }); | 242 | }); |
| 243 | + | ||
| 244 | +///选择优惠券 | ||
| 245 | +var handleCouponSelectPageHandler = new Handler( | ||
| 246 | + handlerFunc: (BuildContext context, Map<String, List<Object>> params) { | ||
| 247 | + // String rid = params["rid"].first; | ||
| 248 | + // bool fromNotify = FluroConvertUtils.string2bool(params["fromNotify"].first); | ||
| 249 | + return CouponSelectPage(); | ||
| 250 | +}); |
| @@ -25,6 +25,7 @@ class Routes { | @@ -25,6 +25,7 @@ class Routes { | ||
| 25 | static String coupon = "/coupon"; //优惠券列表页 | 25 | static String coupon = "/coupon"; //优惠券列表页 |
| 26 | static String coupon_history = "/coupon_history"; //优惠券历史列表页 | 26 | static String coupon_history = "/coupon_history"; //优惠券历史列表页 |
| 27 | static String coupon_edit = "/coupon_edit"; //创建优惠券 | 27 | static String coupon_edit = "/coupon_edit"; //创建优惠券 |
| 28 | + static String coupon_select = "/coupon_select"; //优惠券选择 | ||
| 28 | 29 | ||
| 29 | static void configureRoutes(FluroRouter router) { | 30 | static void configureRoutes(FluroRouter router) { |
| 30 | router.notFoundHandler = new Handler( | 31 | router.notFoundHandler = new Handler( |
| @@ -54,5 +55,8 @@ class Routes { | @@ -54,5 +55,8 @@ class Routes { | ||
| 54 | router.define(coupon, handler: handleCouponPageHandler); | 55 | router.define(coupon, handler: handleCouponPageHandler); |
| 55 | router.define(coupon_history, handler: handleCouponHistoryPageHandler); | 56 | router.define(coupon_history, handler: handleCouponHistoryPageHandler); |
| 56 | router.define(coupon_edit, handler: handleCouponEditPageHandler); | 57 | router.define(coupon_edit, handler: handleCouponEditPageHandler); |
| 58 | + router.define(coupon_select, handler: handleCouponSelectPageHandler); | ||
| 59 | + | ||
| 60 | + | ||
| 57 | } | 61 | } |
| 58 | } | 62 | } |
| @@ -798,6 +798,62 @@ class DialogUtil { | @@ -798,6 +798,62 @@ class DialogUtil { | ||
| 798 | }); | 798 | }); |
| 799 | } | 799 | } |
| 800 | 800 | ||
| 801 | + ///年月日时分秒选择器 | ||
| 802 | + static Future showPickerDateTime24(BuildContext context, | ||
| 803 | + GlobalKey<ScaffoldState> scaffoldKey, ValueChanged valueChanged, | ||
| 804 | + {List<int> selecteds, VoidCallback onCancel, DateTime dateTime}) { | ||
| 805 | + new Picker( | ||
| 806 | + selecteds: selecteds, | ||
| 807 | + adapter: new DateTimePickerAdapter( | ||
| 808 | + type: PickerDateTimeType.kYMDHMS, | ||
| 809 | + isNumberMonth: true, | ||
| 810 | + yearSuffix: "年", | ||
| 811 | + monthSuffix: "月", | ||
| 812 | + daySuffix: "日", | ||
| 813 | + minHour: 00, | ||
| 814 | + maxHour: 23, | ||
| 815 | + yearBegin: 2021, | ||
| 816 | + yearEnd: 2030, | ||
| 817 | + value: dateTime), | ||
| 818 | + title: new Text(""), | ||
| 819 | + height: ScreenUtil().setWidth(480), | ||
| 820 | + hideHeader: false, | ||
| 821 | + cancelText: "取消", | ||
| 822 | + cancelTextStyle: TextStyle( | ||
| 823 | + color: MyColours.color_828282, | ||
| 824 | + fontSize: ScreenUtil().setSp(36)), | ||
| 825 | + confirmText: "确定", | ||
| 826 | + itemExtent: ScreenUtil().setWidth(90), | ||
| 827 | + confirmTextStyle: TextStyle( | ||
| 828 | + color: MyColours.color_2bb5b7, | ||
| 829 | + fontSize: ScreenUtil().setSp(36)), | ||
| 830 | + selectedTextStyle: TextStyle( | ||
| 831 | + color: MyColours.color_199095, | ||
| 832 | + fontSize: ScreenUtil().setSp(32)), | ||
| 833 | + textStyle: TextStyle( | ||
| 834 | + color: MyColours.color_353535, | ||
| 835 | + fontSize: ScreenUtil().setSp(32)), | ||
| 836 | + onConfirm: (Picker picker, List<int> selecteds) { | ||
| 837 | + // print(value.toString()); | ||
| 838 | + // print(picker.adapter.toString()); | ||
| 839 | + if (valueChanged != null) { | ||
| 840 | + valueChanged(picker.adapter.text); | ||
| 841 | + } | ||
| 842 | + }, | ||
| 843 | + onCancel: onCancel, | ||
| 844 | + onSelect: (Picker picker, int index, List<int> selecteds) { | ||
| 845 | + // this.setState(() { | ||
| 846 | + // // stateText = picker.adapter.toString(); | ||
| 847 | + // }); | ||
| 848 | + }) | ||
| 849 | + // .showModal<List<int>>(context) | ||
| 850 | + // .then((value) { | ||
| 851 | + // LogUtil.v("value:${value.toString()}"); | ||
| 852 | + // return value; | ||
| 853 | + // }); | ||
| 854 | + .show(scaffoldKey.currentState); | ||
| 855 | + } | ||
| 856 | + | ||
| 801 | static Future confirmDialog(BuildContext context, String title, double height, | 857 | static Future confirmDialog(BuildContext context, String title, double height, |
| 802 | {GestureTapCallback onTap, double fontSize = 36}) async { | 858 | {GestureTapCallback onTap, double fontSize = 36}) async { |
| 803 | String showTitle = title; | 859 | String showTitle = title; |
| @@ -168,4 +168,10 @@ class NavigatorUtil { | @@ -168,4 +168,10 @@ class NavigatorUtil { | ||
| 168 | {replace = false}) { | 168 | {replace = false}) { |
| 169 | return _navigateTo(context, "${Routes.coupon_edit}", replace: replace); | 169 | return _navigateTo(context, "${Routes.coupon_edit}", replace: replace); |
| 170 | } | 170 | } |
| 171 | + | ||
| 172 | + /// 选择优惠券 | ||
| 173 | + static Future<dynamic> goCouponSelectPage(BuildContext context, | ||
| 174 | + {replace = false}) { | ||
| 175 | + return _navigateTo(context, "${Routes.coupon_select}", replace: replace); | ||
| 176 | + } | ||
| 171 | } | 177 | } |
| @@ -8,32 +8,39 @@ class SystemAppBar extends StatelessWidget implements PreferredSizeWidget { | @@ -8,32 +8,39 @@ class SystemAppBar extends StatelessWidget implements PreferredSizeWidget { | ||
| 8 | final String title; | 8 | final String title; |
| 9 | final String rightImgName; | 9 | final String rightImgName; |
| 10 | final GestureTapCallback onTap; | 10 | final GestureTapCallback onTap; |
| 11 | + final bool showLeading; | ||
| 11 | final GestureTapCallback onTapRight; | 12 | final GestureTapCallback onTapRight; |
| 12 | 13 | ||
| 13 | const SystemAppBar(this.title, | 14 | const SystemAppBar(this.title, |
| 14 | - {Key key, this.rightImgName, this.onTap, this.onTapRight}) | 15 | + {Key key, |
| 16 | + this.rightImgName, | ||
| 17 | + this.onTap, | ||
| 18 | + this.onTapRight, | ||
| 19 | + this.showLeading = true}) | ||
| 15 | : super(key: key); | 20 | : super(key: key); |
| 16 | 21 | ||
| 17 | @override | 22 | @override |
| 18 | Widget build(BuildContext context) { | 23 | Widget build(BuildContext context) { |
| 19 | return AppBar( | 24 | return AppBar( |
| 20 | elevation: 0, | 25 | elevation: 0, |
| 21 | - leading: InkWell( | ||
| 22 | - onTap: onTap, | ||
| 23 | - child: Padding( | ||
| 24 | - padding: EdgeInsets.symmetric( | ||
| 25 | - horizontal: ScreenUtil().setWidth(40), | ||
| 26 | - vertical: ScreenUtil().setWidth(15)), | ||
| 27 | - child: Row( | ||
| 28 | - children: <Widget>[ | ||
| 29 | - Image.asset( | ||
| 30 | - "assets/icon_back.png", | ||
| 31 | - width: ScreenUtil().setWidth(20), | ||
| 32 | - height: ScreenUtil().setWidth(31), | ||
| 33 | - ) | ||
| 34 | - ], | ||
| 35 | - )), | ||
| 36 | - ), | 26 | + leading: showLeading |
| 27 | + ? InkWell( | ||
| 28 | + onTap: onTap, | ||
| 29 | + child: Padding( | ||
| 30 | + padding: EdgeInsets.symmetric( | ||
| 31 | + horizontal: ScreenUtil().setWidth(40), | ||
| 32 | + vertical: ScreenUtil().setWidth(15)), | ||
| 33 | + child: Row( | ||
| 34 | + children: <Widget>[ | ||
| 35 | + Image.asset( | ||
| 36 | + "assets/icon_back.png", | ||
| 37 | + width: ScreenUtil().setWidth(20), | ||
| 38 | + height: ScreenUtil().setWidth(31), | ||
| 39 | + ) | ||
| 40 | + ], | ||
| 41 | + )), | ||
| 42 | + ) | ||
| 43 | + : Container(), | ||
| 37 | title: Text( | 44 | title: Text( |
| 38 | title, | 45 | title, |
| 39 | style: TextStyle( | 46 | style: TextStyle( |
-
Please register or login to post a comment