Commit e8361d208c473c0f1594d9c91a1c64268459d177

Authored by wdn127929
1 parent f4b4a699

微调

@@ -2,6 +2,7 @@ import 'package:common_utils/common_utils.dart'; @@ -2,6 +2,7 @@ import 'package:common_utils/common_utils.dart';
2 import 'package:flutter/material.dart'; 2 import 'package:flutter/material.dart';
3 import 'package:flutter_picker/flutter_picker.dart'; 3 import 'package:flutter_picker/flutter_picker.dart';
4 import 'package:flutter_screenutil/screenutil.dart'; 4 import 'package:flutter_screenutil/screenutil.dart';
  5 +import 'package:fluttertoast/fluttertoast.dart';
5 import 'package:one_key/res/colors.dart'; 6 import 'package:one_key/res/colors.dart';
6 import 'package:one_key/utils/dialog_util.dart'; 7 import 'package:one_key/utils/dialog_util.dart';
7 import 'package:one_key/utils/navigator_util.dart'; 8 import 'package:one_key/utils/navigator_util.dart';
@@ -32,8 +33,6 @@ class _CouponEidtPageState extends State<CouponEidtPage> { @@ -32,8 +33,6 @@ class _CouponEidtPageState extends State<CouponEidtPage> {
32 final GlobalKey<ScaffoldState> scaffoldKey = GlobalKey<ScaffoldState>(); 33 final GlobalKey<ScaffoldState> scaffoldKey = GlobalKey<ScaffoldState>();
33 String fromDate = '点击选择'; //有效期开始时间 34 String fromDate = '点击选择'; //有效期开始时间
34 String endDate = '点击选择'; //有效期结束时间 35 String endDate = '点击选择'; //有效期结束时间
35 - List<int> fromDateSelect;  
36 - List<int> endDateSelect;  
37 FocusNode _nameFocusNode = FocusNode(); 36 FocusNode _nameFocusNode = FocusNode();
38 FocusNode _requireFocusNode = FocusNode(); 37 FocusNode _requireFocusNode = FocusNode();
39 bool showDateSelWidget = false; 38 bool showDateSelWidget = false;
@@ -323,6 +322,32 @@ class _CouponEidtPageState extends State<CouponEidtPage> { @@ -323,6 +322,32 @@ class _CouponEidtPageState extends State<CouponEidtPage> {
323 ScreenUtil().setWidth(40), ScreenUtil().setWidth(40)), 322 ScreenUtil().setWidth(40), ScreenUtil().setWidth(40)),
324 child: RoundButton( 323 child: RoundButton(
325 onPressed: () { 324 onPressed: () {
  325 + if (_couponNameEditControl.text.trim().length == 0) {
  326 + Utils.showToast('请填写券名称');
  327 + return;
  328 + }
  329 + if (_couponRequireEditControl.text.trim().length == 0) {
  330 + Utils.showToast('请填写券要求');
  331 + return;
  332 + }
  333 + if (fromDate == '点击选择') {
  334 + Utils.showToast('请选择有效期起始时间');
  335 + return;
  336 + }
  337 + if (endDate == '点击选择') {
  338 + Utils.showToast('请选择有效期结束时间');
  339 + return;
  340 + }
  341 + if (_couponExplainEditControl.text.trim().length == 0) {
  342 + Utils.showToast('请填写券说明');
  343 + return;
  344 + }
  345 + if (DateUtil.getDateTime(endDate)
  346 + .compareTo(DateUtil.getDateTime(fromDate)) <
  347 + 0) {
  348 + Utils.showToast('有效期结束时间不能早于起始时间');
  349 + return;
  350 + }
326 // ***参数*** 351 // ***参数***
327 // _couponNameEditControl.text 352 // _couponNameEditControl.text
328 // _couponRequireEditControl.text 353 // _couponRequireEditControl.text
@@ -23,8 +23,10 @@ class _CouponHistoryPageState extends State<CouponHistoryPage> { @@ -23,8 +23,10 @@ class _CouponHistoryPageState extends State<CouponHistoryPage> {
23 23
24 ///获取优惠券列表数据 24 ///获取优惠券列表数据
25 _couponNetworkData() { 25 _couponNetworkData() {
26 - return Future.delayed(Duration(seconds: 1),  
27 - () => couponProvider.pageStateHistory = PageState.Success); 26 + return Future.delayed(Duration(seconds: 1), () {
  27 + couponProvider.pageStateHistory = PageState.Success;
  28 + couponProvider.notifyListeners();
  29 + });
28 } 30 }
29 31
30 @override 32 @override
@@ -50,7 +52,7 @@ class _CouponHistoryPageState extends State<CouponHistoryPage> { @@ -50,7 +52,7 @@ class _CouponHistoryPageState extends State<CouponHistoryPage> {
50 builder: (context, model, _) { 52 builder: (context, model, _) {
51 if (model.pageStateHistory != PageState.Success) { 53 if (model.pageStateHistory != PageState.Success) {
52 return ExceptionPage( 54 return ExceptionPage(
53 - pageState: model.pageState, 55 + pageState: model.pageStateHistory,
54 callback: () { 56 callback: () {
55 // offset = 0; 57 // offset = 0;
56 // getMessage(showLoading: true); 58 // getMessage(showLoading: true);
@@ -29,8 +29,10 @@ class _CouponPageState extends State<CouponPage> { @@ -29,8 +29,10 @@ class _CouponPageState extends State<CouponPage> {
29 29
30 ///获取优惠券列表数据 30 ///获取优惠券列表数据
31 _couponNetworkData() { 31 _couponNetworkData() {
32 - return Future.delayed(Duration(seconds: 1),  
33 - () => couponProvider.pageState = PageState.Success); 32 + return Future.delayed(Duration(seconds: 1), () {
  33 + couponProvider.pageState = PageState.Success;
  34 + couponProvider.notifyListeners();
  35 + });
34 } 36 }
35 37
36 @override 38 @override
@@ -4,6 +4,7 @@ import 'package:flutter_screenutil/screenutil.dart'; @@ -4,6 +4,7 @@ import 'package:flutter_screenutil/screenutil.dart';
4 import 'package:one_key/constant/state.dart'; 4 import 'package:one_key/constant/state.dart';
5 import 'package:one_key/pages/coupon/coupon_item.dart'; 5 import 'package:one_key/pages/coupon/coupon_item.dart';
6 import 'package:one_key/provider/coupon_provider.dart'; 6 import 'package:one_key/provider/coupon_provider.dart';
  7 +import 'package:one_key/res/colors.dart';
7 import 'package:one_key/utils/navigator_util.dart'; 8 import 'package:one_key/utils/navigator_util.dart';
8 import 'package:one_key/widgets/h_empty_view.dart'; 9 import 'package:one_key/widgets/h_empty_view.dart';
9 import 'package:one_key/widgets/page_exception.dart'; 10 import 'package:one_key/widgets/page_exception.dart';
@@ -25,8 +26,10 @@ class _CouponSelectPageState extends State<CouponSelectPage> { @@ -25,8 +26,10 @@ class _CouponSelectPageState extends State<CouponSelectPage> {
25 26
26 ///获取优惠券列表数据 27 ///获取优惠券列表数据
27 _couponNetworkData() { 28 _couponNetworkData() {
28 - return Future.delayed(Duration(seconds: 1),  
29 - () => couponProvider.pageStateSelect = PageState.Success); 29 + return Future.delayed(Duration(seconds: 1), () {
  30 + couponProvider.pageStateSelect = PageState.Success;
  31 + couponProvider.notifyListeners();
  32 + });
30 } 33 }
31 34
32 @override 35 @override
@@ -93,11 +96,29 @@ class _CouponSelectPageState extends State<CouponSelectPage> { @@ -93,11 +96,29 @@ class _CouponSelectPageState extends State<CouponSelectPage> {
93 child: Row( 96 child: Row(
94 children: [ 97 children: [
95 HEmptyView(30), 98 HEmptyView(30),
96 - Image.asset(  
97 - couponProvider.listData[index]['checked']  
98 - ? 'assets/select.png'  
99 - : 'assets/unselect.png',  
100 - width: ScreenUtil().setWidth(44)), 99 + Checkbox(
  100 + value: couponProvider.listData[index]
  101 + ['checked'],
  102 + checkColor: MyColours.color_ffffff,
  103 + activeColor: MyColours.app_main,
  104 + onChanged: (bool value) {
  105 + couponProvider.listData[index]['checked'] =
  106 + !couponProvider.listData[index]
  107 + ['checked'];
  108 + if (couponProvider.listData[index]
  109 + ['checked']) {
  110 + couponProvider.addData(index);
  111 + } else {
  112 + couponProvider.cancelData(index);
  113 + }
  114 + couponProvider.getCheckValue();
  115 + },
  116 + ),
  117 + // Image.asset(
  118 + // couponProvider.listData[index]['checked']
  119 + // ? 'assets/select.png'
  120 + // : 'assets/unselect.png',
  121 + // width: ScreenUtil().setWidth(44)),
101 Expanded( 122 Expanded(
102 child: CouponItem( 123 child: CouponItem(
103 index: index, 124 index: index,
@@ -253,15 +253,22 @@ class InvicationPageState extends State<InvicationPage> { @@ -253,15 +253,22 @@ class InvicationPageState extends State<InvicationPage> {
253 ) 253 )
254 ])), 254 ])),
255 Positioned( 255 Positioned(
256 - left: ScreenUtil().setWidth(40),  
257 - top: ScreenUtil().setWidth(65), 256 + left: ScreenUtil().setWidth(0),
  257 + top: ScreenUtil().setWidth(0),
258 child: GestureDetector( 258 child: GestureDetector(
259 onTap: () { 259 onTap: () {
260 Navigator.of(context).pop(); 260 Navigator.of(context).pop();
261 }, 261 },
262 behavior: HitTestBehavior.opaque, 262 behavior: HitTestBehavior.opaque,
263 child: Container( 263 child: Container(
  264 + padding: EdgeInsets.fromLTRB(
  265 + ScreenUtil().setWidth(40),
  266 + ScreenUtil().setWidth(95),
  267 + ScreenUtil().setWidth(200),
  268 + ScreenUtil().setWidth(100),
  269 + ),
264 alignment: Alignment.centerLeft, 270 alignment: Alignment.centerLeft,
  271 + // color: Colors.red,
265 child: Image.asset( 272 child: Image.asset(
266 "assets/invication_back.png", 273 "assets/invication_back.png",
267 width: ScreenUtil().setWidth(20), 274 width: ScreenUtil().setWidth(20),
@@ -86,6 +86,7 @@ class NotebookItemState extends State<NoteBookItem> { @@ -86,6 +86,7 @@ class NotebookItemState extends State<NoteBookItem> {
86 alignment: Alignment.center, 86 alignment: Alignment.center,
87 child: Column( 87 child: Column(
88 mainAxisSize: MainAxisSize.min, 88 mainAxisSize: MainAxisSize.min,
  89 + mainAxisAlignment: MainAxisAlignment.center,
89 children: <Widget>[ 90 children: <Widget>[
90 Text( 91 Text(
91 notebook.rnameStr, 92 notebook.rnameStr,
@@ -97,16 +98,20 @@ class NotebookItemState extends State<NoteBookItem> { @@ -97,16 +98,20 @@ class NotebookItemState extends State<NoteBookItem> {
97 // fontWeight: FontWeight.bold, 98 // fontWeight: FontWeight.bold,
98 fontSize: ScreenUtil().setSp(30)), 99 fontSize: ScreenUtil().setSp(30)),
99 ), 100 ),
100 - VEmptyView(10),  
101 - Text(  
102 - notebook.phoneStr,  
103 - maxLines: 1,  
104 - overflow: TextOverflow.ellipsis,  
105 - style: TextStyle(  
106 - color: textColor,  
107 - // fontWeight: FontWeight.bold,  
108 - fontSize: ScreenUtil().setSp(26)),  
109 - ) 101 + notebook.phoneStr.isNotEmpty
  102 + ? Padding(
  103 + padding: EdgeInsets.only(
  104 + top: ScreenUtil().setWidth(10)),
  105 + child: Text(
  106 + notebook.phoneStr,
  107 + maxLines: 1,
  108 + overflow: TextOverflow.ellipsis,
  109 + style: TextStyle(
  110 + color: textColor,
  111 + // fontWeight: FontWeight.bold,
  112 + fontSize: ScreenUtil().setSp(26)),
  113 + ))
  114 + : Container()
110 ], 115 ],
111 ), 116 ),
112 ), 117 ),
@@ -136,8 +141,12 @@ class NotebookItemState extends State<NoteBookItem> { @@ -136,8 +141,12 @@ class NotebookItemState extends State<NoteBookItem> {
136 ), 141 ),
137 GestureDetector( 142 GestureDetector(
138 onTap: _onOperateClick, 143 onTap: _onOperateClick,
  144 + behavior: HitTestBehavior.opaque,
139 child: Container( 145 child: Container(
  146 + padding:
  147 + EdgeInsets.symmetric(vertical: ScreenUtil().setWidth(20)),
140 width: ScreenUtil().setWidth(184), 148 width: ScreenUtil().setWidth(184),
  149 + // color: Colors.red,
141 alignment: Alignment.center, 150 alignment: Alignment.center,
142 child: Text( 151 child: Text(
143 notebook.operationText, 152 notebook.operationText,
@@ -69,7 +69,8 @@ class NoteBookPageState extends State<NoteBookPage> { @@ -69,7 +69,8 @@ class NoteBookPageState extends State<NoteBookPage> {
69 //初始化时间 69 //初始化时间
70 _initTime() { 70 _initTime() {
71 dateTime = DateTime.now(); 71 dateTime = DateTime.now();
72 - dateText = "${dateTime.year}年 "+Utils.addZeroNumber(dateTime.month) + 72 + dateText = "${dateTime.year}年 " +
  73 + Utils.addZeroNumber(dateTime.month) +
73 "月" + 74 "月" +
74 Utils.addZeroNumber(dateTime.day) + 75 Utils.addZeroNumber(dateTime.day) +
75 "日" + 76 "日" +
@@ -142,8 +143,8 @@ class NoteBookPageState extends State<NoteBookPage> { @@ -142,8 +143,8 @@ class NoteBookPageState extends State<NoteBookPage> {
142 "keywords": "", 143 "keywords": "",
143 "sort": "1" 144 "sort": "1"
144 }; 145 };
145 - if(tabIndex==1){  
146 - params["account"]=userModel.user.account; 146 + if (tabIndex == 1) {
  147 + params["account"] = userModel.user.account;
147 } 148 }
148 model.getReserveList(context, params); 149 model.getReserveList(context, params);
149 } 150 }
@@ -184,8 +185,8 @@ class NoteBookPageState extends State<NoteBookPage> { @@ -184,8 +185,8 @@ class NoteBookPageState extends State<NoteBookPage> {
184 ? "0" + dateTime.day.toString() 185 ? "0" + dateTime.day.toString()
185 : dateTime.day.toString()) 186 : dateTime.day.toString())
186 }; 187 };
187 - if(tabIndex==1){  
188 - params["account"]=userModel.user.account; 188 + if (tabIndex == 1) {
  189 + params["account"] = userModel.user.account;
189 } 190 }
190 model.getReserveCountDay(context, params); 191 model.getReserveCountDay(context, params);
191 } 192 }
@@ -263,7 +264,8 @@ class NoteBookPageState extends State<NoteBookPage> { @@ -263,7 +264,8 @@ class NoteBookPageState extends State<NoteBookPage> {
263 if (Utils.isOneDay(day, dateTime)) return; //日期没变 264 if (Utils.isOneDay(day, dateTime)) return; //日期没变
264 setState(() { 265 setState(() {
265 DateTime dateNow = DateTime.now(); 266 DateTime dateNow = DateTime.now();
266 - dateText = "${day.year}年 "+Utils.addZeroNumber(day.month) + 267 + dateText = "${day.year}年 " +
  268 + Utils.addZeroNumber(day.month) +
267 "月" + 269 "月" +
268 Utils.addZeroNumber(day.day) + 270 Utils.addZeroNumber(day.day) +
269 "日"; 271 "日";
@@ -286,15 +288,17 @@ class NoteBookPageState extends State<NoteBookPage> { @@ -286,15 +288,17 @@ class NoteBookPageState extends State<NoteBookPage> {
286 Container container = Container( 288 Container container = Container(
287 color: MyColours.color_ffffff, 289 color: MyColours.color_ffffff,
288 width: double.infinity, 290 width: double.infinity,
289 - padding: EdgeInsets.only(left: ScreenUtil().setWidth(20),top: ScreenUtil().setWidth(20)), 291 + padding: EdgeInsets.only(
  292 + left: ScreenUtil().setWidth(20), top: ScreenUtil().setWidth(20)),
290 child: Row( 293 child: Row(
291 mainAxisSize: MainAxisSize.min, 294 mainAxisSize: MainAxisSize.min,
292 children: <Widget>[ 295 children: <Widget>[
293 Container( 296 Container(
294 - padding: EdgeInsets.symmetric(horizontal: ScreenUtil().setWidth(20)), 297 + padding:
  298 + EdgeInsets.symmetric(horizontal: ScreenUtil().setWidth(20)),
295 child: GestureDetector( 299 child: GestureDetector(
296 onTap: () { 300 onTap: () {
297 - if(tabIndex==0)return; 301 + if (tabIndex == 0) return;
298 setState(() { 302 setState(() {
299 tabIndex = 0; 303 tabIndex = 0;
300 _getReserveList(); 304 _getReserveList();
@@ -322,30 +326,27 @@ class NoteBookPageState extends State<NoteBookPage> { @@ -322,30 +326,27 @@ class NoteBookPageState extends State<NoteBookPage> {
322 child: Container( 326 child: Container(
323 height: ScreenUtil().setWidth(6), 327 height: ScreenUtil().setWidth(6),
324 width: ScreenUtil().setWidth(60), 328 width: ScreenUtil().setWidth(60),
325 - margin:  
326 - EdgeInsets.only(top: ScreenUtil().setWidth(8)), 329 + margin: EdgeInsets.only(top: ScreenUtil().setWidth(8)),
327 decoration: tabIndex == 0 330 decoration: tabIndex == 0
328 - ? BoxDecoration(color: MyColours.color_199095,borderRadius: BorderRadius.circular(  
329 - ScreenUtil()  
330 - .setWidth(  
331 - 6))) 331 + ? BoxDecoration(
  332 + color: MyColours.color_199095,
  333 + borderRadius: BorderRadius.circular(
  334 + ScreenUtil().setWidth(6)))
332 : BoxDecoration( 335 : BoxDecoration(
333 - color: MyColours.color_ffffff,  
334 - borderRadius: BorderRadius.circular(  
335 - ScreenUtil()  
336 - .setWidth(  
337 - 6))  
338 - ), 336 + color: MyColours.color_ffffff,
  337 + borderRadius: BorderRadius.circular(
  338 + ScreenUtil().setWidth(6))),
339 ), 339 ),
340 ), 340 ),
341 ], 341 ],
342 )), 342 )),
343 ), 343 ),
344 Container( 344 Container(
345 - padding: EdgeInsets.symmetric(horizontal: ScreenUtil().setWidth(20)), 345 + padding:
  346 + EdgeInsets.symmetric(horizontal: ScreenUtil().setWidth(20)),
346 child: GestureDetector( 347 child: GestureDetector(
347 onTap: () { 348 onTap: () {
348 - if(tabIndex==1)return; 349 + if (tabIndex == 1) return;
349 setState(() { 350 setState(() {
350 tabIndex = 1; 351 tabIndex = 1;
351 _getReserveList(); 352 _getReserveList();
@@ -373,20 +374,16 @@ class NoteBookPageState extends State<NoteBookPage> { @@ -373,20 +374,16 @@ class NoteBookPageState extends State<NoteBookPage> {
373 child: Container( 374 child: Container(
374 height: ScreenUtil().setWidth(6), 375 height: ScreenUtil().setWidth(6),
375 width: ScreenUtil().setWidth(60), 376 width: ScreenUtil().setWidth(60),
376 - margin:  
377 - EdgeInsets.only(top: ScreenUtil().setWidth(8)), 377 + margin: EdgeInsets.only(top: ScreenUtil().setWidth(8)),
378 decoration: tabIndex == 1 378 decoration: tabIndex == 1
379 - ? BoxDecoration(color: MyColours.color_199095,borderRadius: BorderRadius.circular(  
380 - ScreenUtil()  
381 - .setWidth(  
382 - 6))) 379 + ? BoxDecoration(
  380 + color: MyColours.color_199095,
  381 + borderRadius: BorderRadius.circular(
  382 + ScreenUtil().setWidth(6)))
383 : BoxDecoration( 383 : BoxDecoration(
384 - color: MyColours.color_ffffff,  
385 - borderRadius: BorderRadius.circular(  
386 - ScreenUtil()  
387 - .setWidth(  
388 - 6))  
389 - ), 384 + color: MyColours.color_ffffff,
  385 + borderRadius: BorderRadius.circular(
  386 + ScreenUtil().setWidth(6))),
390 ), 387 ),
391 ), 388 ),
392 ], 389 ],