Showing
12 changed files
with
710 additions
and
5 deletions
| @@ -10,6 +10,7 @@ import 'package:flutter_easyrefresh/easy_refresh.dart'; | @@ -10,6 +10,7 @@ import 'package:flutter_easyrefresh/easy_refresh.dart'; | ||
| 10 | import 'package:flutter_easyrefresh/material_header.dart'; | 10 | import 'package:flutter_easyrefresh/material_header.dart'; |
| 11 | import 'package:fluwx/fluwx.dart'; | 11 | import 'package:fluwx/fluwx.dart'; |
| 12 | import 'package:one_key/pages/detail/handle_online_page.dart'; | 12 | import 'package:one_key/pages/detail/handle_online_page.dart'; |
| 13 | +import 'package:one_key/provider/coupon_provider.dart'; | ||
| 13 | import 'package:one_key/provider/message_dialog_model.dart'; | 14 | import 'package:one_key/provider/message_dialog_model.dart'; |
| 14 | import 'package:intl/date_symbol_data_local.dart'; | 15 | import 'package:intl/date_symbol_data_local.dart'; |
| 15 | import 'package:one_key/provider/notebook_detail_model.dart'; | 16 | import 'package:one_key/provider/notebook_detail_model.dart'; |
| @@ -61,6 +62,9 @@ Future<void> main() async { | @@ -61,6 +62,9 @@ Future<void> main() async { | ||
| 61 | ChangeNotifierProvider<NotebookDetailModel>( | 62 | ChangeNotifierProvider<NotebookDetailModel>( |
| 62 | create: (_) => NotebookDetailModel(), | 63 | create: (_) => NotebookDetailModel(), |
| 63 | ), | 64 | ), |
| 65 | + ChangeNotifierProvider<CouponProvider>( | ||
| 66 | + create: (_) => CouponProvider(), | ||
| 67 | + ), | ||
| 64 | ], | 68 | ], |
| 65 | child: MyApp(), | 69 | child: MyApp(), |
| 66 | )); | 70 | )); |
lib/pages/coupon/coupon_edit_page.dart
0 → 100644
| 1 | +import 'package:flutter/material.dart'; | ||
| 2 | +import 'package:flutter_screenutil/screenutil.dart'; | ||
| 3 | +import 'package:one_key/res/colors.dart'; | ||
| 4 | +import 'package:one_key/utils/navigator_util.dart'; | ||
| 5 | +import 'package:one_key/utils/utils.dart'; | ||
| 6 | +import 'package:one_key/widgets/h_empty_view.dart'; | ||
| 7 | +import 'package:one_key/widgets/round_button.dart'; | ||
| 8 | +import 'package:one_key/widgets/system_app_bar.dart'; | ||
| 9 | +import 'package:one_key/widgets/v_empty_view.dart'; | ||
| 10 | + | ||
| 11 | +/** | ||
| 12 | + * 新建券 | ||
| 13 | + */ | ||
| 14 | + | ||
| 15 | +class CouponEidtPage extends StatefulWidget { | ||
| 16 | + CouponEidtPage({Key key}) : super(key: key); | ||
| 17 | + | ||
| 18 | + @override | ||
| 19 | + _CouponEidtPageState createState() => _CouponEidtPageState(); | ||
| 20 | +} | ||
| 21 | + | ||
| 22 | +class _CouponEidtPageState extends State<CouponEidtPage> { | ||
| 23 | + ScrollController controller = ScrollController(); | ||
| 24 | + TextEditingController _couponNameEditControl; | ||
| 25 | + final heightCell = ScreenUtil().setWidth(80); | ||
| 26 | + bool swichState = true; //默认启用 | ||
| 27 | + | ||
| 28 | + ///输入框 | ||
| 29 | + Widget _textfield(String title, String hintText) { | ||
| 30 | + return Container( | ||
| 31 | + height: heightCell, | ||
| 32 | + child: Row( | ||
| 33 | + crossAxisAlignment: CrossAxisAlignment.center, | ||
| 34 | + mainAxisAlignment: MainAxisAlignment.center, | ||
| 35 | + children: [ | ||
| 36 | + Container( | ||
| 37 | + // height: ScreenUtil().setWidth(40), | ||
| 38 | + // color: Colors.red, | ||
| 39 | + child: Text( | ||
| 40 | + title, | ||
| 41 | + style: TextStyle( | ||
| 42 | + fontWeight: FontWeight.bold, | ||
| 43 | + fontSize: ScreenUtil().setSp(30)), | ||
| 44 | + ), | ||
| 45 | + ), | ||
| 46 | + HEmptyView(20), | ||
| 47 | + Expanded( | ||
| 48 | + child: TextField( | ||
| 49 | + controller: _couponNameEditControl, | ||
| 50 | + textAlign: TextAlign.right, | ||
| 51 | + maxLines: 1, | ||
| 52 | + // //光标颜色 | ||
| 53 | + // cursorColor: | ||
| 54 | + // widget.isSelect ? Colors.white : MyColours.color_199095, | ||
| 55 | + //输入文本的样式 | ||
| 56 | + style: TextStyle( | ||
| 57 | + fontSize: ScreenUtil().setSp(26), | ||
| 58 | + ), | ||
| 59 | + // focusNode: _cancelNode, | ||
| 60 | + // textAlignVertical: TextAlignVertical.bottom, | ||
| 61 | + decoration: InputDecoration( | ||
| 62 | + // fillColor: Colors.lightGreenAccent, | ||
| 63 | + // filled: true, | ||
| 64 | + border: OutlineInputBorder(borderSide: BorderSide.none), | ||
| 65 | + hintText: hintText, | ||
| 66 | + hintStyle: TextStyle( | ||
| 67 | + color: MyColours.color_999999, | ||
| 68 | + fontSize: ScreenUtil().setSp(26), | ||
| 69 | + ), | ||
| 70 | + // contentPadding: EdgeInsets.only( | ||
| 71 | + // bottom: ScreenUtil().setWidth(30)), //ios 17 | ||
| 72 | + // border: InputBorder.none, | ||
| 73 | + ), | ||
| 74 | + onChanged: (value) {}, | ||
| 75 | + onEditingComplete: () { | ||
| 76 | + FocusScope.of(context).requestFocus(FocusNode()); //点击空白处隐藏键盘 | ||
| 77 | + }, | ||
| 78 | + keyboardType: TextInputType.text, | ||
| 79 | + ), | ||
| 80 | + ) | ||
| 81 | + ], | ||
| 82 | + ), | ||
| 83 | + ); | ||
| 84 | + } | ||
| 85 | + | ||
| 86 | + ///时间选择 | ||
| 87 | + Widget _select(String title, String hintText) { | ||
| 88 | + return InkWell( | ||
| 89 | + onTap: () { | ||
| 90 | + //弹出时间选择器 | ||
| 91 | + }, | ||
| 92 | + child: Container( | ||
| 93 | + height: heightCell, | ||
| 94 | + child: Row( | ||
| 95 | + crossAxisAlignment: CrossAxisAlignment.center, | ||
| 96 | + mainAxisAlignment: MainAxisAlignment.center, | ||
| 97 | + children: [ | ||
| 98 | + Container( | ||
| 99 | + // height: ScreenUtil().setWidth(40), | ||
| 100 | + // color: Colors.red, | ||
| 101 | + child: Text( | ||
| 102 | + title, | ||
| 103 | + style: TextStyle( | ||
| 104 | + fontWeight: FontWeight.bold, | ||
| 105 | + fontSize: ScreenUtil().setSp(30)), | ||
| 106 | + ), | ||
| 107 | + ), | ||
| 108 | + HEmptyView(20), | ||
| 109 | + Spacer(), | ||
| 110 | + Text(hintText, | ||
| 111 | + style: TextStyle( | ||
| 112 | + color: MyColours.color_999999, | ||
| 113 | + fontSize: ScreenUtil().setSp(26), | ||
| 114 | + )), | ||
| 115 | + HEmptyView(20), | ||
| 116 | + Image.asset( | ||
| 117 | + Utils.getImgPath('arr_right_gray'), | ||
| 118 | + width: ScreenUtil().setWidth(12), | ||
| 119 | + height: ScreenUtil().setWidth(22), | ||
| 120 | + ) | ||
| 121 | + ], | ||
| 122 | + ), | ||
| 123 | + ), | ||
| 124 | + ); | ||
| 125 | + } | ||
| 126 | + | ||
| 127 | + ///券说明 | ||
| 128 | + Widget _explain(String title, String hintText) { | ||
| 129 | + return Container( | ||
| 130 | + // height: ScreenUtil().setWidth(380), | ||
| 131 | + child: Column( | ||
| 132 | + crossAxisAlignment: CrossAxisAlignment.start, | ||
| 133 | + children: [ | ||
| 134 | + Container( | ||
| 135 | + height: heightCell, | ||
| 136 | + child: Align( | ||
| 137 | + alignment: Alignment.centerLeft, | ||
| 138 | + child: Text( | ||
| 139 | + title, | ||
| 140 | + textAlign: TextAlign.left, | ||
| 141 | + style: TextStyle( | ||
| 142 | + fontWeight: FontWeight.bold, | ||
| 143 | + fontSize: ScreenUtil().setSp(30)), | ||
| 144 | + )), | ||
| 145 | + ), | ||
| 146 | + VEmptyView(10), | ||
| 147 | + TextField( | ||
| 148 | + // keyboardType: TextInputType.number, //键盘类型,数字键盘 | ||
| 149 | + maxLines: 7, | ||
| 150 | + // maxLength: 200, | ||
| 151 | + // maxLengthEnforced: true, | ||
| 152 | + | ||
| 153 | + decoration: InputDecoration( | ||
| 154 | + contentPadding: EdgeInsets.all(ScreenUtil().setWidth(20)), | ||
| 155 | + hintText: hintText, | ||
| 156 | + fillColor: MyColours.color_EEEEEE, | ||
| 157 | + filled: true, | ||
| 158 | + border: OutlineInputBorder( | ||
| 159 | + borderRadius: BorderRadius.circular(15), | ||
| 160 | + borderSide: BorderSide.none), | ||
| 161 | + ), | ||
| 162 | + onChanged: (value) {}, | ||
| 163 | + ), | ||
| 164 | + ], | ||
| 165 | + ), | ||
| 166 | + ); | ||
| 167 | + } | ||
| 168 | + | ||
| 169 | + ///是否立即启用 | ||
| 170 | + Widget _canUse(String title) { | ||
| 171 | + return InkWell( | ||
| 172 | + onTap: () { | ||
| 173 | + setState(() { | ||
| 174 | + swichState = !swichState; | ||
| 175 | + }); | ||
| 176 | + }, | ||
| 177 | + child: Container( | ||
| 178 | + padding: EdgeInsets.only(top: ScreenUtil().setWidth(30)), | ||
| 179 | + // height: heightCell, | ||
| 180 | + child: Row( | ||
| 181 | + crossAxisAlignment: CrossAxisAlignment.center, | ||
| 182 | + mainAxisAlignment: MainAxisAlignment.center, | ||
| 183 | + children: [ | ||
| 184 | + Container( | ||
| 185 | + // height: ScreenUtil().setWidth(40), | ||
| 186 | + // color: Colors.red, | ||
| 187 | + child: Text( | ||
| 188 | + title, | ||
| 189 | + style: TextStyle( | ||
| 190 | + fontWeight: FontWeight.bold, | ||
| 191 | + fontSize: ScreenUtil().setSp(30)), | ||
| 192 | + ), | ||
| 193 | + ), | ||
| 194 | + Spacer(), | ||
| 195 | + Image.asset( | ||
| 196 | + swichState | ||
| 197 | + ? Utils.getImgPath('swich_on') | ||
| 198 | + : Utils.getImgPath('swich_off'), | ||
| 199 | + width: ScreenUtil().setWidth(122), | ||
| 200 | + height: ScreenUtil().setWidth(82), | ||
| 201 | + ) | ||
| 202 | + ], | ||
| 203 | + ), | ||
| 204 | + ), | ||
| 205 | + ); | ||
| 206 | + } | ||
| 207 | + | ||
| 208 | + @override | ||
| 209 | + Widget build(BuildContext context) { | ||
| 210 | + return Scaffold( | ||
| 211 | + appBar: SystemAppBar( | ||
| 212 | + '创建新券', | ||
| 213 | + onTap: () { | ||
| 214 | + Navigator.pop(context, false); | ||
| 215 | + }, | ||
| 216 | + ), | ||
| 217 | + body: InkWell( | ||
| 218 | + onTap: () { | ||
| 219 | + FocusScope.of(context).requestFocus(FocusNode()); //点击空白处隐藏键盘 | ||
| 220 | + }, | ||
| 221 | + child: Column(children: [ | ||
| 222 | + Expanded( | ||
| 223 | + child: SingleChildScrollView( | ||
| 224 | + controller: controller, | ||
| 225 | + physics: BouncingScrollPhysics(), | ||
| 226 | + child: Padding( | ||
| 227 | + padding: EdgeInsets.symmetric( | ||
| 228 | + horizontal: ScreenUtil().setWidth(40)), | ||
| 229 | + child: Column( | ||
| 230 | + children: [ | ||
| 231 | + VEmptyView(20), | ||
| 232 | + _textfield('券名称', '例:9折券/200元代金券/菜品券'), | ||
| 233 | + _textfield('券要求', '例:无门槛/满2000元'), | ||
| 234 | + _select('有效期从', '点击选择'), | ||
| 235 | + _select('有效期至', '点击选择'), | ||
| 236 | + _explain('券说明', '例:可用包间,停车免费,不与店内其他活动共享等'), | ||
| 237 | + _canUse('是否立即启用'), | ||
| 238 | + ], | ||
| 239 | + ))), | ||
| 240 | + ), | ||
| 241 | + VEmptyView(20), | ||
| 242 | + Padding( | ||
| 243 | + padding: EdgeInsets.fromLTRB(ScreenUtil().setWidth(40), 0, | ||
| 244 | + ScreenUtil().setWidth(40), ScreenUtil().setWidth(40)), | ||
| 245 | + child: RoundButton( | ||
| 246 | + onPressed: () { | ||
| 247 | + Navigator.pop(context, true); | ||
| 248 | + }, | ||
| 249 | + text: '保存', | ||
| 250 | + fontSize: 34, | ||
| 251 | + isBold: false, | ||
| 252 | + height: ScreenUtil().setWidth(80), | ||
| 253 | + width: double.infinity, | ||
| 254 | + radius: ScreenUtil().setWidth(10), | ||
| 255 | + )) | ||
| 256 | + ])), | ||
| 257 | + ); | ||
| 258 | + } | ||
| 259 | +} |
lib/pages/coupon/coupon_history_page.dart
0 → 100644
| 1 | +import 'package:flutter/material.dart'; | ||
| 2 | +import 'package:flutter_easyrefresh/easy_refresh.dart'; | ||
| 3 | +import 'package:one_key/constant/state.dart'; | ||
| 4 | +import 'package:one_key/pages/coupon/coupon_item.dart'; | ||
| 5 | +import 'package:one_key/provider/coupon_provider.dart'; | ||
| 6 | +import 'package:one_key/widgets/page_exception.dart'; | ||
| 7 | +import 'package:one_key/widgets/system_app_bar.dart'; | ||
| 8 | +import 'package:provider/provider.dart'; | ||
| 9 | + | ||
| 10 | +/** | ||
| 11 | + * 历史券 | ||
| 12 | + */ | ||
| 13 | +class CouponHistoryPage extends StatefulWidget { | ||
| 14 | + CouponHistoryPage({Key key}) : super(key: key); | ||
| 15 | + | ||
| 16 | + @override | ||
| 17 | + _CouponHistoryPageState createState() => _CouponHistoryPageState(); | ||
| 18 | +} | ||
| 19 | + | ||
| 20 | +class _CouponHistoryPageState extends State<CouponHistoryPage> { | ||
| 21 | + EasyRefreshController _controller = EasyRefreshController(); | ||
| 22 | + CouponProvider couponProvider; | ||
| 23 | + | ||
| 24 | + ///获取优惠券列表数据 | ||
| 25 | + _couponNetworkData() { | ||
| 26 | + return Future.delayed(Duration(seconds: 1), | ||
| 27 | + () => couponProvider.pageStateHistory = PageState.Success); | ||
| 28 | + } | ||
| 29 | + | ||
| 30 | + @override | ||
| 31 | + void initState() { | ||
| 32 | + // TODO: implement initState | ||
| 33 | + super.initState(); | ||
| 34 | + WidgetsBinding.instance.addPostFrameCallback((_) { | ||
| 35 | + _couponNetworkData(); | ||
| 36 | + }); | ||
| 37 | + } | ||
| 38 | + | ||
| 39 | + @override | ||
| 40 | + Widget build(BuildContext context) { | ||
| 41 | + couponProvider = Provider.of<CouponProvider>(context, listen: true); | ||
| 42 | + return Scaffold( | ||
| 43 | + appBar: SystemAppBar( | ||
| 44 | + ' 历史券', | ||
| 45 | + onTap: () { | ||
| 46 | + Navigator.of(context).pop(); | ||
| 47 | + }, | ||
| 48 | + ), | ||
| 49 | + body: Consumer<CouponProvider>( | ||
| 50 | + builder: (context, model, _) { | ||
| 51 | + if (model.pageStateHistory != PageState.Success) { | ||
| 52 | + return ExceptionPage( | ||
| 53 | + pageState: model.pageState, | ||
| 54 | + callback: () { | ||
| 55 | + // offset = 0; | ||
| 56 | + // getMessage(showLoading: true); | ||
| 57 | + }, | ||
| 58 | + emptyMsg: "暂时没有列表信息哦", | ||
| 59 | + emptyImg: "empty_search", | ||
| 60 | + showMsg: "加载中,请稍后...", | ||
| 61 | + ); | ||
| 62 | + } else { | ||
| 63 | + return EasyRefresh.custom( | ||
| 64 | + controller: _controller, | ||
| 65 | + slivers: [ | ||
| 66 | + SliverList( | ||
| 67 | + delegate: SliverChildBuilderDelegate( | ||
| 68 | + (BuildContext context, int index) { | ||
| 69 | + return CouponItem( | ||
| 70 | + index: index, | ||
| 71 | + couponProvider: couponProvider, | ||
| 72 | + onPressed: () { | ||
| 73 | + couponProvider.swichStateData[index] = | ||
| 74 | + !couponProvider.swichStateData[index]; | ||
| 75 | + couponProvider.notifyListeners(); | ||
| 76 | + }, | ||
| 77 | + ); | ||
| 78 | + }, childCount: couponProvider.swichStateData.length), | ||
| 79 | + ) | ||
| 80 | + ], | ||
| 81 | + onRefresh: () async { | ||
| 82 | + // offset = 0; | ||
| 83 | + // getMessage(showLoading: false); | ||
| 84 | + }, | ||
| 85 | + onLoad: () async { | ||
| 86 | + // offset++; | ||
| 87 | + // getMessage(showLoading: false); | ||
| 88 | + }, | ||
| 89 | + ); | ||
| 90 | + } | ||
| 91 | + }, | ||
| 92 | + )); | ||
| 93 | + } | ||
| 94 | +} |
lib/pages/coupon/coupon_item.dart
0 → 100644
| 1 | +import 'package:flutter/material.dart'; | ||
| 2 | +import 'package:flutter_screenutil/flutter_screenutil.dart'; | ||
| 3 | +import 'package:one_key/provider/coupon_provider.dart'; | ||
| 4 | +import 'package:one_key/res/colors.dart'; | ||
| 5 | +import 'package:one_key/widgets/h_empty_view.dart'; | ||
| 6 | +import 'package:one_key/widgets/round_button.dart'; | ||
| 7 | +import 'package:one_key/widgets/v_empty_view.dart'; | ||
| 8 | + | ||
| 9 | +class CouponItem extends StatefulWidget { | ||
| 10 | + final int index; | ||
| 11 | + final VoidCallback onPressed; | ||
| 12 | + final CouponProvider couponProvider; | ||
| 13 | + CouponItem({Key key, this.index, this.onPressed, this.couponProvider}) | ||
| 14 | + : super(key: key); | ||
| 15 | + | ||
| 16 | + @override | ||
| 17 | + _CouponItemState createState() => _CouponItemState(); | ||
| 18 | +} | ||
| 19 | + | ||
| 20 | +class _CouponItemState extends State<CouponItem> { | ||
| 21 | + @override | ||
| 22 | + Widget build(BuildContext context) { | ||
| 23 | + 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), | ||
| 28 | + padding: EdgeInsets.all(ScreenUtil().setWidth(20)), | ||
| 29 | + decoration: BoxDecoration( | ||
| 30 | + color: switchState ? MyColours.app_main : MyColours.color_E0E0E0, | ||
| 31 | + borderRadius: BorderRadius.circular(ScreenUtil().setWidth(10))), | ||
| 32 | + child: Stack( | ||
| 33 | + children: [ | ||
| 34 | + Column( | ||
| 35 | + crossAxisAlignment: CrossAxisAlignment.start, | ||
| 36 | + 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( | ||
| 65 | + 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))), | ||
| 75 | + ), | ||
| 76 | + ], | ||
| 77 | + ), | ||
| 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( | ||
| 98 | + width: ScreenUtil().setWidth(100), | ||
| 99 | + height: ScreenUtil().setWidth(50), | ||
| 100 | + radius: ScreenUtil().setWidth(10), | ||
| 101 | + text: switchState ? '停用' : '启用', | ||
| 102 | + textColor: MyColours.color_666666, | ||
| 103 | + gradientStart: Colors.white, | ||
| 104 | + gradientEnd: Colors.white, | ||
| 105 | + onPressed: widget.onPressed, | ||
| 106 | + ) | ||
| 107 | + ], | ||
| 108 | + ), | ||
| 109 | + ) | ||
| 110 | + ], | ||
| 111 | + ), | ||
| 112 | + )); | ||
| 113 | + } | ||
| 114 | +} |
lib/pages/coupon/coupon_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/event_bus.dart'; | ||
| 8 | +import 'package:one_key/utils/navigator_util.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 | +/** | ||
| 16 | + * 优惠券列表 | ||
| 17 | + */ | ||
| 18 | + | ||
| 19 | +class CouponPage extends StatefulWidget { | ||
| 20 | + CouponPage({Key key}) : super(key: key); | ||
| 21 | + | ||
| 22 | + @override | ||
| 23 | + _CouponPageState createState() => _CouponPageState(); | ||
| 24 | +} | ||
| 25 | + | ||
| 26 | +class _CouponPageState extends State<CouponPage> { | ||
| 27 | + EasyRefreshController _controller = EasyRefreshController(); | ||
| 28 | + CouponProvider couponProvider; | ||
| 29 | + | ||
| 30 | + ///获取优惠券列表数据 | ||
| 31 | + _couponNetworkData() { | ||
| 32 | + return Future.delayed(Duration(seconds: 1), | ||
| 33 | + () => couponProvider.pageState = PageState.Success); | ||
| 34 | + } | ||
| 35 | + | ||
| 36 | + @override | ||
| 37 | + void initState() { | ||
| 38 | + // TODO: implement initState | ||
| 39 | + super.initState(); | ||
| 40 | + WidgetsBinding.instance.addPostFrameCallback((_) { | ||
| 41 | + _couponNetworkData(); | ||
| 42 | + }); | ||
| 43 | + } | ||
| 44 | + | ||
| 45 | + @override | ||
| 46 | + Widget build(BuildContext context) { | ||
| 47 | + couponProvider = Provider.of<CouponProvider>(context, listen: true); | ||
| 48 | + return Scaffold( | ||
| 49 | + appBar: SystemAppBar('线上券', rightImgName: '历史券', onTap: () { | ||
| 50 | + EventBus().emit('changeStatusColor'); | ||
| 51 | + Navigator.of(context).pop(); | ||
| 52 | + }, onTapRight: () { | ||
| 53 | + NavigatorUtil.goCouponHistoryPage(context); | ||
| 54 | + }), | ||
| 55 | + body: Column( | ||
| 56 | + children: [ | ||
| 57 | + Expanded(child: Consumer<CouponProvider>( | ||
| 58 | + builder: (context, model, _) { | ||
| 59 | + if (model.pageState != PageState.Success) { | ||
| 60 | + return ExceptionPage( | ||
| 61 | + pageState: model.pageState, | ||
| 62 | + callback: () { | ||
| 63 | + // offset = 0; | ||
| 64 | + // getMessage(showLoading: true); | ||
| 65 | + }, | ||
| 66 | + emptyMsg: "暂时没有列表信息哦", | ||
| 67 | + emptyImg: "empty_search", | ||
| 68 | + showMsg: "加载中,请稍后...", | ||
| 69 | + ); | ||
| 70 | + } else { | ||
| 71 | + return EasyRefresh.custom( | ||
| 72 | + controller: _controller, | ||
| 73 | + shrinkWrap: true, | ||
| 74 | + slivers: [ | ||
| 75 | + SliverList( | ||
| 76 | + delegate: SliverChildBuilderDelegate( | ||
| 77 | + (BuildContext context, int index) { | ||
| 78 | + return Container( | ||
| 79 | + padding: | ||
| 80 | + EdgeInsets.all(ScreenUtil().setWidth(20)), | ||
| 81 | + child: Text( | ||
| 82 | + '使用说明:回家啊喝点酒啊喝酒啊电话噶记得发快递费哈咖啡和大号发客服哈空腹喝酒啊快递费哈快递费哈看警方还会发卡号发快回复')); | ||
| 83 | + }, childCount: 1), | ||
| 84 | + ), | ||
| 85 | + SliverList( | ||
| 86 | + delegate: SliverChildBuilderDelegate( | ||
| 87 | + (BuildContext context, int index) { | ||
| 88 | + return CouponItem( | ||
| 89 | + index: index, | ||
| 90 | + couponProvider: couponProvider, | ||
| 91 | + onPressed: () { | ||
| 92 | + couponProvider.swichStateData[index] = | ||
| 93 | + !couponProvider.swichStateData[index]; | ||
| 94 | + couponProvider.notifyListeners(); | ||
| 95 | + }, | ||
| 96 | + ); | ||
| 97 | + }, childCount: couponProvider.swichStateData.length), | ||
| 98 | + ) | ||
| 99 | + ], | ||
| 100 | + onRefresh: () async { | ||
| 101 | + // offset = 0; | ||
| 102 | + // getMessage(showLoading: false); | ||
| 103 | + }, | ||
| 104 | + onLoad: () async { | ||
| 105 | + // offset++; | ||
| 106 | + // getMessage(showLoading: false); | ||
| 107 | + }, | ||
| 108 | + ); | ||
| 109 | + } | ||
| 110 | + }, | ||
| 111 | + )), | ||
| 112 | + VEmptyView(20), | ||
| 113 | + Padding( | ||
| 114 | + padding: EdgeInsets.fromLTRB(ScreenUtil().setWidth(40), 0, | ||
| 115 | + ScreenUtil().setWidth(40), ScreenUtil().setWidth(40)), | ||
| 116 | + child: RoundButton( | ||
| 117 | + onPressed: () async { | ||
| 118 | + bool needRefresh = | ||
| 119 | + await NavigatorUtil.goCouponEditPage(context); | ||
| 120 | + print(needRefresh); | ||
| 121 | + if (needRefresh) { | ||
| 122 | + //刷新页面数据 | ||
| 123 | + _controller.callRefresh(); | ||
| 124 | + } | ||
| 125 | + }, | ||
| 126 | + text: '创建新券', | ||
| 127 | + fontSize: 34, | ||
| 128 | + isBold: false, | ||
| 129 | + height: ScreenUtil().setWidth(80), | ||
| 130 | + width: double.infinity, | ||
| 131 | + radius: ScreenUtil().setWidth(10), | ||
| 132 | + )) | ||
| 133 | + ], | ||
| 134 | + )); | ||
| 135 | + } | ||
| 136 | +} |
| @@ -209,6 +209,18 @@ class MyPageState extends State<MyPage> with WidgetsBindingObserver { | @@ -209,6 +209,18 @@ class MyPageState extends State<MyPage> with WidgetsBindingObserver { | ||
| 209 | // ), | 209 | // ), |
| 210 | VEmptyView(40), | 210 | VEmptyView(40), |
| 211 | MyItem( | 211 | MyItem( |
| 212 | + title: "活动创建", | ||
| 213 | + content: '', | ||
| 214 | + callback: () { | ||
| 215 | + NavigatorUtil.goCouponPage(context); | ||
| 216 | + }, | ||
| 217 | + ), | ||
| 218 | + MyDivider( | ||
| 219 | + double.infinity, | ||
| 220 | + ScreenUtil().setHeight(1), | ||
| 221 | + color: MyColours.color_f3f3f3, | ||
| 222 | + ), | ||
| 223 | + MyItem( | ||
| 212 | title: "短信管理", | 224 | title: "短信管理", |
| 213 | content: | 225 | content: |
| 214 | myModel.smsInfo.isNotEmpty ? '剩余${myModel.smsInfo}条' : '', | 226 | myModel.smsInfo.isNotEmpty ? '剩余${myModel.smsInfo}条' : '', |
lib/provider/coupon_provider.dart
0 → 100644
| 1 | +import 'package:flutter/material.dart'; | ||
| 2 | +import 'package:one_key/constant/state.dart'; | ||
| 3 | + | ||
| 4 | +class CouponProvider with ChangeNotifier { | ||
| 5 | + List<bool> swichStateData = []; //优惠券是否启用 true启用 false停用 | ||
| 6 | + PageState pageState = PageState.Loading; | ||
| 7 | + PageState pageStateHistory = PageState.Loading; | ||
| 8 | + | ||
| 9 | + CouponProvider() { | ||
| 10 | + for (int i = 0; i < 20; i++) { | ||
| 11 | + swichStateData.add(true); | ||
| 12 | + } | ||
| 13 | + } | ||
| 14 | +} |
| @@ -5,6 +5,9 @@ import 'package:flutter/material.dart'; | @@ -5,6 +5,9 @@ import 'package:flutter/material.dart'; | ||
| 5 | import 'package:one_key/models/notebook.dart'; | 5 | import 'package:one_key/models/notebook.dart'; |
| 6 | import 'package:one_key/models/notebook_detail.dart'; | 6 | import 'package:one_key/models/notebook_detail.dart'; |
| 7 | import 'package:one_key/models/table_list.dart'; | 7 | import 'package:one_key/models/table_list.dart'; |
| 8 | +import 'package:one_key/pages/coupon/coupon_edit_page.dart'; | ||
| 9 | +import 'package:one_key/pages/coupon/coupon_history_page.dart'; | ||
| 10 | +import 'package:one_key/pages/coupon/coupon_page.dart'; | ||
| 8 | import 'package:one_key/pages/detail/notebook_detail_change_page.dart'; | 11 | import 'package:one_key/pages/detail/notebook_detail_change_page.dart'; |
| 9 | import 'package:one_key/pages/home/home_page.dart'; | 12 | import 'package:one_key/pages/home/home_page.dart'; |
| 10 | import 'package:one_key/pages/invicate/invitation_page.dart'; | 13 | import 'package:one_key/pages/invicate/invitation_page.dart'; |
| @@ -212,3 +215,27 @@ var handleInvoiceDetailPageHandler = new Handler( | @@ -212,3 +215,27 @@ var handleInvoiceDetailPageHandler = new Handler( | ||
| 212 | create: (_) => OrderFoodProvider(), | 215 | create: (_) => OrderFoodProvider(), |
| 213 | child: InvoiceDetailPage(fromNotify: fromNotify, rid: rid)); | 216 | child: InvoiceDetailPage(fromNotify: fromNotify, rid: rid)); |
| 214 | }); | 217 | }); |
| 218 | + | ||
| 219 | +///优惠券列表 | ||
| 220 | +var handleCouponPageHandler = new Handler( | ||
| 221 | + handlerFunc: (BuildContext context, Map<String, List<Object>> params) { | ||
| 222 | + // String rid = params["rid"].first; | ||
| 223 | + // bool fromNotify = FluroConvertUtils.string2bool(params["fromNotify"].first); | ||
| 224 | + return CouponPage(); | ||
| 225 | +}); | ||
| 226 | + | ||
| 227 | +///优惠券历史列表 | ||
| 228 | +var handleCouponHistoryPageHandler = new Handler( | ||
| 229 | + handlerFunc: (BuildContext context, Map<String, List<Object>> params) { | ||
| 230 | + // String rid = params["rid"].first; | ||
| 231 | + // bool fromNotify = FluroConvertUtils.string2bool(params["fromNotify"].first); | ||
| 232 | + return CouponHistoryPage(); | ||
| 233 | +}); | ||
| 234 | + | ||
| 235 | +///创建优惠券 | ||
| 236 | +var handleCouponEditPageHandler = new Handler( | ||
| 237 | + handlerFunc: (BuildContext context, Map<String, List<Object>> params) { | ||
| 238 | + // String rid = params["rid"].first; | ||
| 239 | + // bool fromNotify = FluroConvertUtils.string2bool(params["fromNotify"].first); | ||
| 240 | + return CouponEidtPage(); | ||
| 241 | +}); |
| @@ -22,6 +22,9 @@ class Routes { | @@ -22,6 +22,9 @@ class Routes { | ||
| 22 | static String online_check_edit = "/online_check_edit"; //提前买单处理 | 22 | static String online_check_edit = "/online_check_edit"; //提前买单处理 |
| 23 | static String online_check_detail = "/online_check_detail"; //提前买单查看 | 23 | static String online_check_detail = "/online_check_detail"; //提前买单查看 |
| 24 | static String invoice_detail = "/invoice_detail"; //查看发票详情 | 24 | static String invoice_detail = "/invoice_detail"; //查看发票详情 |
| 25 | + static String coupon = "/coupon"; //优惠券列表页 | ||
| 26 | + static String coupon_history = "/coupon_history"; //优惠券历史列表页 | ||
| 27 | + static String coupon_edit = "/coupon_edit"; //创建优惠券 | ||
| 25 | 28 | ||
| 26 | static void configureRoutes(FluroRouter router) { | 29 | static void configureRoutes(FluroRouter router) { |
| 27 | router.notFoundHandler = new Handler( | 30 | router.notFoundHandler = new Handler( |
| @@ -47,8 +50,9 @@ class Routes { | @@ -47,8 +50,9 @@ class Routes { | ||
| 47 | router.define(online_check_edit, handler: handleOnlineCheckEditHandler); | 50 | router.define(online_check_edit, handler: handleOnlineCheckEditHandler); |
| 48 | router.define(online_check_detail, | 51 | router.define(online_check_detail, |
| 49 | handler: handleOnlineCheckDetailPageHandler); | 52 | handler: handleOnlineCheckDetailPageHandler); |
| 50 | - router.define(invoice_detail, | ||
| 51 | - handler: handleInvoiceDetailPageHandler); | ||
| 52 | - | 53 | + router.define(invoice_detail, handler: handleInvoiceDetailPageHandler); |
| 54 | + router.define(coupon, handler: handleCouponPageHandler); | ||
| 55 | + router.define(coupon_history, handler: handleCouponHistoryPageHandler); | ||
| 56 | + router.define(coupon_edit, handler: handleCouponEditPageHandler); | ||
| 53 | } | 57 | } |
| 54 | } | 58 | } |
| @@ -152,4 +152,20 @@ class NavigatorUtil { | @@ -152,4 +152,20 @@ class NavigatorUtil { | ||
| 152 | context, "${Routes.invoice_detail}?fromNotify=${fromNotify}&rid=${rid}", | 152 | context, "${Routes.invoice_detail}?fromNotify=${fromNotify}&rid=${rid}", |
| 153 | replace: replace); | 153 | replace: replace); |
| 154 | } | 154 | } |
| 155 | + | ||
| 156 | + /// 优惠券列表 | ||
| 157 | + static void goCouponPage(BuildContext context, {replace = false}) { | ||
| 158 | + _navigateTo(context, "${Routes.coupon}", replace: replace); | ||
| 159 | + } | ||
| 160 | + | ||
| 161 | + /// 优惠券历史列表 | ||
| 162 | + static void goCouponHistoryPage(BuildContext context, {replace = false}) { | ||
| 163 | + _navigateTo(context, "${Routes.coupon_history}", replace: replace); | ||
| 164 | + } | ||
| 165 | + | ||
| 166 | + /// 创建优惠券 | ||
| 167 | + static Future<dynamic> goCouponEditPage(BuildContext context, | ||
| 168 | + {replace = false}) { | ||
| 169 | + return _navigateTo(context, "${Routes.coupon_edit}", replace: replace); | ||
| 170 | + } | ||
| 155 | } | 171 | } |
| @@ -79,7 +79,8 @@ class SetTimeWidget { | @@ -79,7 +79,8 @@ class SetTimeWidget { | ||
| 79 | '晚上23时': [00, 30] | 79 | '晚上23时': [00, 30] |
| 80 | } | 80 | } |
| 81 | ]; | 81 | ]; |
| 82 | - showTimeSelector(context, data, hourAndMinute, SetTimeCallback setTimeCallback) { | 82 | + showTimeSelector( |
| 83 | + context, data, hourAndMinute, SetTimeCallback setTimeCallback) { | ||
| 83 | DialogUtil.showSelectCusmanDialog(context, data, (value) { | 84 | DialogUtil.showSelectCusmanDialog(context, data, (value) { |
| 84 | setTimeCallback(value); | 85 | setTimeCallback(value); |
| 85 | }, selecteds: [ | 86 | }, selecteds: [ |
| 1 | +import 'package:common_utils/common_utils.dart'; | ||
| 1 | import 'package:flutter/material.dart'; | 2 | import 'package:flutter/material.dart'; |
| 2 | import 'package:flutter_screenutil/screenutil.dart'; | 3 | import 'package:flutter_screenutil/screenutil.dart'; |
| 3 | import 'package:one_key/res/colors.dart'; | 4 | import 'package:one_key/res/colors.dart'; |
| 5 | +import 'package:one_key/utils/utils.dart'; | ||
| 4 | 6 | ||
| 5 | class SystemAppBar extends StatelessWidget implements PreferredSizeWidget { | 7 | class SystemAppBar extends StatelessWidget implements PreferredSizeWidget { |
| 6 | final String title; | 8 | final String title; |
| 7 | final String rightImgName; | 9 | final String rightImgName; |
| 8 | final GestureTapCallback onTap; | 10 | final GestureTapCallback onTap; |
| 11 | + final GestureTapCallback onTapRight; | ||
| 9 | 12 | ||
| 10 | - const SystemAppBar(this.title, {Key key, this.rightImgName, this.onTap}) | 13 | + const SystemAppBar(this.title, |
| 14 | + {Key key, this.rightImgName, this.onTap, this.onTapRight}) | ||
| 11 | : super(key: key); | 15 | : super(key: key); |
| 12 | 16 | ||
| 13 | @override | 17 | @override |
| @@ -37,6 +41,26 @@ class SystemAppBar extends StatelessWidget implements PreferredSizeWidget { | @@ -37,6 +41,26 @@ class SystemAppBar extends StatelessWidget implements PreferredSizeWidget { | ||
| 37 | fontSize: ScreenUtil().setSp(34), | 41 | fontSize: ScreenUtil().setSp(34), |
| 38 | decoration: TextDecoration.none), | 42 | decoration: TextDecoration.none), |
| 39 | ), | 43 | ), |
| 44 | + actions: <Widget>[ | ||
| 45 | + ObjectUtil.isNotEmpty(rightImgName) | ||
| 46 | + ? InkWell( | ||
| 47 | + onTap: onTapRight, | ||
| 48 | + child: Padding( | ||
| 49 | + padding: EdgeInsets.only(right: ScreenUtil().setWidth(40)), | ||
| 50 | + child: rightImgName.endsWith('png') | ||
| 51 | + ? Image.asset(Utils.getImgPath(rightImgName), | ||
| 52 | + width: ScreenUtil().setWidth(40)) | ||
| 53 | + : Container( | ||
| 54 | + // color: Colors.red, | ||
| 55 | + alignment: Alignment.center, | ||
| 56 | + child: Text( | ||
| 57 | + rightImgName, | ||
| 58 | + style: TextStyle(color: MyColours.app_main), | ||
| 59 | + ), | ||
| 60 | + )), | ||
| 61 | + ) | ||
| 62 | + : Text('') | ||
| 63 | + ], | ||
| 40 | centerTitle: true, // 标题居中 | 64 | centerTitle: true, // 标题居中 |
| 41 | ); | 65 | ); |
| 42 | } | 66 | } |
-
Please register or login to post a comment