Showing
21 changed files
with
187 additions
and
48 deletions
| @@ -107,15 +107,15 @@ dependencies { | @@ -107,15 +107,15 @@ dependencies { | ||
| 107 | androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1' | 107 | androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1' |
| 108 | 108 | ||
| 109 | //华为推送 | 109 | //华为推送 |
| 110 | - implementation 'cn.jiguang.sdk.plugin:huawei:3.5.4' | 110 | + implementation 'cn.jiguang.sdk.plugin:huawei:3.5.8' |
| 111 | implementation 'com.huawei.hms:push:3.0.3.301' | 111 | implementation 'com.huawei.hms:push:3.0.3.301' |
| 112 | 112 | ||
| 113 | //小米推送 | 113 | //小米推送 |
| 114 | - implementation 'cn.jiguang.sdk.plugin:xiaomi:3.5.4' | 114 | + implementation 'cn.jiguang.sdk.plugin:xiaomi:3.5.8' |
| 115 | 115 | ||
| 116 | // //OPPO推送 | 116 | // //OPPO推送 |
| 117 | -// implementation 'cn.jiguang.sdk.plugin:oppo:3.4.0' | 117 | +// implementation 'cn.jiguang.sdk.plugin:oppo:3.5.8' |
| 118 | // | 118 | // |
| 119 | // //vivo推送 | 119 | // //vivo推送 |
| 120 | -// implementation 'cn.jiguang.sdk.plugin:vivo:3.5.4' | 120 | +// implementation 'cn.jiguang.sdk.plugin:vivo:3.5.8' |
| 121 | } | 121 | } |
| @@ -13,7 +13,7 @@ class Manager{ | @@ -13,7 +13,7 @@ class Manager{ | ||
| 13 | } | 13 | } |
| 14 | 14 | ||
| 15 | String get userName{ | 15 | String get userName{ |
| 16 | - return nick_name.isEmpty?user_name:nick_name; | 16 | + return (nick_name==null||nick_name.isEmpty)?user_name:nick_name; |
| 17 | } | 17 | } |
| 18 | 18 | ||
| 19 | factory Manager.fromJson(Map<String,dynamic> json)=> | 19 | factory Manager.fromJson(Map<String,dynamic> json)=> |
| 1 | import 'package:json_annotation/json_annotation.dart'; | 1 | import 'package:json_annotation/json_annotation.dart'; |
| 2 | +import 'package:one_key/utils/utils.dart'; | ||
| 2 | 3 | ||
| 3 | part 'message.g.dart'; | 4 | part 'message.g.dart'; |
| 4 | 5 | ||
| @@ -7,7 +8,7 @@ class Message { | @@ -7,7 +8,7 @@ class Message { | ||
| 7 | Message(); | 8 | Message(); |
| 8 | 9 | ||
| 9 | String id; | 10 | String id; |
| 10 | - String message_type; | 11 | + dynamic message_type; |
| 11 | String handle_time;//10在线预订 11取消预订 | 12 | String handle_time;//10在线预订 11取消预订 |
| 12 | String read_time; | 13 | String read_time; |
| 13 | String is_read; | 14 | String is_read; |
| @@ -26,20 +27,38 @@ class Message { | @@ -26,20 +27,38 @@ class Message { | ||
| 26 | String get rnameStr{ | 27 | String get rnameStr{ |
| 27 | switch(sex.toString()){ | 28 | switch(sex.toString()){ |
| 28 | case "1"://先生 | 29 | case "1"://先生 |
| 30 | + case "男": | ||
| 29 | return rname+"先生"; | 31 | return rname+"先生"; |
| 30 | case "2"://女士 | 32 | case "2"://女士 |
| 33 | + case "女": | ||
| 31 | return rname+"女士"; | 34 | return rname+"女士"; |
| 32 | case "3"://公司 | 35 | case "3"://公司 |
| 36 | + case "公司": | ||
| 33 | return rname+"公司"; | 37 | return rname+"公司"; |
| 34 | } | 38 | } |
| 35 | } | 39 | } |
| 36 | 40 | ||
| 41 | + String get ddateStr{ | ||
| 42 | + DateTime dateTime=DateTime.fromMillisecondsSinceEpoch(int.parse(ddate_long.toString())*1000); | ||
| 43 | + String ymd=dateTime.year.toString()+"/"+Utils.addZeroNumber(dateTime.month)+"/"+Utils.addZeroNumber(dateTime.day); | ||
| 44 | + switch(ddate_solt){ | ||
| 45 | + case "1"://早餐 | ||
| 46 | + return ymd+" 早餐"; | ||
| 47 | + case "2"://午餐 | ||
| 48 | + return ymd+" 午餐"; | ||
| 49 | + case "3"://晚餐 | ||
| 50 | + return ymd+" 晚餐"; | ||
| 51 | + default: | ||
| 52 | + return ymd; | ||
| 53 | + } | ||
| 54 | + } | ||
| 55 | + | ||
| 37 | String get cdateStr{ | 56 | String get cdateStr{ |
| 38 | DateTime dateTime=DateTime.fromMillisecondsSinceEpoch(int.parse(cdate.toString())*1000); | 57 | DateTime dateTime=DateTime.fromMillisecondsSinceEpoch(int.parse(cdate.toString())*1000); |
| 39 | if((DateTime.now().difference(dateTime)).inMilliseconds<60000){ | 58 | if((DateTime.now().difference(dateTime)).inMilliseconds<60000){ |
| 40 | return "刚刚"; | 59 | return "刚刚"; |
| 41 | }else{ | 60 | }else{ |
| 42 | - return dateTime.year.toString()+"/"+(dateTime.month<10?"0"+dateTime.month.toString():dateTime.month.toString())+"/"+(dateTime.day<10?"0"+dateTime.day.toString():dateTime.day.toString()); | 61 | + return dateTime.year.toString()+"/"+Utils.addZeroNumber(dateTime.month)+"/"+Utils.addZeroNumber(dateTime.day)+" "+Utils.addZeroNumber(dateTime.hour)+":"+Utils.addZeroNumber(dateTime.minute); |
| 43 | } | 62 | } |
| 44 | } | 63 | } |
| 45 | 64 |
| @@ -9,7 +9,7 @@ part of 'message.dart'; | @@ -9,7 +9,7 @@ part of 'message.dart'; | ||
| 9 | Message _$MessageFromJson(Map<String, dynamic> json) { | 9 | Message _$MessageFromJson(Map<String, dynamic> json) { |
| 10 | return Message() | 10 | return Message() |
| 11 | ..id = json['id'] as String | 11 | ..id = json['id'] as String |
| 12 | - ..message_type = json['message_type'] as String | 12 | + ..message_type = json['message_type'] as dynamic |
| 13 | ..handle_time = json['handle_time'] as String | 13 | ..handle_time = json['handle_time'] as String |
| 14 | ..read_time = json['read_time'] as String | 14 | ..read_time = json['read_time'] as String |
| 15 | ..is_read = json['is_read'] as String | 15 | ..is_read = json['is_read'] as String |
| @@ -40,9 +40,9 @@ class Table { | @@ -40,9 +40,9 @@ class Table { | ||
| 40 | 40 | ||
| 41 | //获取桌位可坐人数 | 41 | //获取桌位可坐人数 |
| 42 | String get tableNum{ | 42 | String get tableNum{ |
| 43 | - if(max!=null){ | 43 | + if(max!=null&&max.isNotEmpty&&max!="0"){ |
| 44 | return "最多可坐$max人"; | 44 | return "最多可坐$max人"; |
| 45 | - }else if(table_pnum==null){ | 45 | + }else if(table_pnum==null||table_pnum.isEmpty||table_pnum=="0"){ |
| 46 | return ""; | 46 | return ""; |
| 47 | }else{ | 47 | }else{ |
| 48 | if(table_pnum==most_pnum){ | 48 | if(table_pnum==most_pnum){ |
| @@ -55,7 +55,7 @@ class Table { | @@ -55,7 +55,7 @@ class Table { | ||
| 55 | 55 | ||
| 56 | //获取最低消费 | 56 | //获取最低消费 |
| 57 | String get lowStr{ | 57 | String get lowStr{ |
| 58 | - return low==null?"":"最低消费$low元"; | 58 | + return (low==null||low.isEmpty||low=="0")?"":"最低消费$low元"; |
| 59 | } | 59 | } |
| 60 | 60 | ||
| 61 | String get signStr{ | 61 | String get signStr{ |
| @@ -3,6 +3,8 @@ import 'dart:io'; | @@ -3,6 +3,8 @@ import 'dart:io'; | ||
| 3 | 3 | ||
| 4 | import 'package:dio/dio.dart'; | 4 | import 'package:dio/dio.dart'; |
| 5 | import 'package:flutter/material.dart'; | 5 | import 'package:flutter/material.dart'; |
| 6 | +import 'package:one_key/utils/log_util.dart'; | ||
| 7 | +import 'package:one_key/utils/utils.dart'; | ||
| 6 | import 'package:one_key/widgets/loading.dart'; | 8 | import 'package:one_key/widgets/loading.dart'; |
| 7 | 9 | ||
| 8 | import 'base_resp.dart'; | 10 | import 'base_resp.dart'; |
| @@ -167,6 +169,11 @@ class DioUtil { | @@ -167,6 +169,11 @@ class DioUtil { | ||
| 167 | /// <BaseResp<T> 返回 status code msg data . | 169 | /// <BaseResp<T> 返回 status code msg data . |
| 168 | Future<BaseResp<T>> request<T>(BuildContext context,String method, String path, | 170 | Future<BaseResp<T>> request<T>(BuildContext context,String method, String path, |
| 169 | {data, Options options, CancelToken cancelToken,bool showLoading=true}) async { | 171 | {data, Options options, CancelToken cancelToken,bool showLoading=true}) async { |
| 172 | + bool connectivity=await Utils.checkConnectiviy(); | ||
| 173 | + if(!connectivity){ | ||
| 174 | + Utils.showToast("网络错误,请稍后重试"); | ||
| 175 | + return new Future.error("网络错误,请稍后重试"); | ||
| 176 | + } | ||
| 170 | if(showLoading)Loading.showLoading(context); | 177 | if(showLoading)Loading.showLoading(context); |
| 171 | Response response = await _dio.request(path, | 178 | Response response = await _dio.request(path, |
| 172 | data: data, | 179 | data: data, |
| @@ -18,6 +18,7 @@ import 'package:one_key/widgets/table_item.dart'; | @@ -18,6 +18,7 @@ import 'package:one_key/widgets/table_item.dart'; | ||
| 18 | import 'package:one_key/models/table.dart' as t; | 18 | import 'package:one_key/models/table.dart' as t; |
| 19 | import 'package:one_key/widgets/v_empty_view.dart'; | 19 | import 'package:one_key/widgets/v_empty_view.dart'; |
| 20 | import 'package:provider/provider.dart'; | 20 | import 'package:provider/provider.dart'; |
| 21 | +import 'package:one_key/utils/event_bus.dart'; | ||
| 21 | 22 | ||
| 22 | class HandleOnlinePage extends StatefulWidget { | 23 | class HandleOnlinePage extends StatefulWidget { |
| 23 | 24 | ||
| @@ -98,7 +99,9 @@ class HandleOnlinePageState extends State<HandleOnlinePage> { | @@ -98,7 +99,9 @@ class HandleOnlinePageState extends State<HandleOnlinePage> { | ||
| 98 | onPressed: () async { | 99 | onPressed: () async { |
| 99 | Navigator.of(context).pop(); | 100 | Navigator.of(context).pop(); |
| 100 | String tid=await NavigatorUtil.goSelectTablePage(context,widget.rid,DateTime.fromMillisecondsSinceEpoch(int.parse(detailEntity.ddate)*1000),detailEntity.ddate_solt); | 101 | String tid=await NavigatorUtil.goSelectTablePage(context,widget.rid,DateTime.fromMillisecondsSinceEpoch(int.parse(detailEntity.ddate)*1000),detailEntity.ddate_solt); |
| 101 | - setReserveStatus("5",tid:tid); | 102 | + if(tid!=null){ |
| 103 | + setReserveStatus("5",tid:tid); | ||
| 104 | + } | ||
| 102 | }, | 105 | }, |
| 103 | ) | 106 | ) |
| 104 | ], | 107 | ], |
| @@ -108,6 +111,7 @@ class HandleOnlinePageState extends State<HandleOnlinePage> { | @@ -108,6 +111,7 @@ class HandleOnlinePageState extends State<HandleOnlinePage> { | ||
| 108 | 111 | ||
| 109 | //处理在线预订 | 112 | //处理在线预订 |
| 110 | setReserveStatus(String status,{String tid=""}){ | 113 | setReserveStatus(String status,{String tid=""}){ |
| 114 | + bus.emit("remove_untreated_message",widget.mid); | ||
| 111 | UserModel userModel=Provider.of<UserModel>(context,listen: false); | 115 | UserModel userModel=Provider.of<UserModel>(context,listen: false); |
| 112 | Map<String,String> causeMap={ | 116 | Map<String,String> causeMap={ |
| 113 | "uid":userModel.user.openid, | 117 | "uid":userModel.user.openid, |
| @@ -126,6 +130,7 @@ class HandleOnlinePageState extends State<HandleOnlinePage> { | @@ -126,6 +130,7 @@ class HandleOnlinePageState extends State<HandleOnlinePage> { | ||
| 126 | 130 | ||
| 127 | //处理在线预订 | 131 | //处理在线预订 |
| 128 | setMessageStatus(){ | 132 | setMessageStatus(){ |
| 133 | + bus.emit("remove_untreated_message",widget.mid); | ||
| 129 | Map<String,String> params={ | 134 | Map<String,String> params={ |
| 130 | "sid":Provider.of<UserModel>(context,listen: false).user.sellerid, | 135 | "sid":Provider.of<UserModel>(context,listen: false).user.sellerid, |
| 131 | "id":widget.mid, | 136 | "id":widget.mid, |
| @@ -187,8 +192,7 @@ class HandleOnlinePageState extends State<HandleOnlinePage> { | @@ -187,8 +192,7 @@ class HandleOnlinePageState extends State<HandleOnlinePage> { | ||
| 187 | color: MyColours.color_ffffff, | 192 | color: MyColours.color_ffffff, |
| 188 | width: double.infinity, | 193 | width: double.infinity, |
| 189 | height: ScreenUtil().setHeight(80), | 194 | height: ScreenUtil().setHeight(80), |
| 190 | - padding: EdgeInsets.symmetric( | ||
| 191 | - vertical: ScreenUtil().setHeight(26)), | 195 | + alignment: Alignment.center, |
| 192 | child: Stack( | 196 | child: Stack( |
| 193 | alignment: Alignment.center, | 197 | alignment: Alignment.center, |
| 194 | children: <Widget>[ | 198 | children: <Widget>[ |
| @@ -144,8 +144,7 @@ class NotebookDetailPageState extends State<NotebookDetailPage> { | @@ -144,8 +144,7 @@ class NotebookDetailPageState extends State<NotebookDetailPage> { | ||
| 144 | color: MyColours.color_ffffff, | 144 | color: MyColours.color_ffffff, |
| 145 | width: double.infinity, | 145 | width: double.infinity, |
| 146 | height: ScreenUtil().setHeight(80), | 146 | height: ScreenUtil().setHeight(80), |
| 147 | - padding: EdgeInsets.symmetric( | ||
| 148 | - vertical: ScreenUtil().setHeight(26)), | 147 | + alignment: Alignment.center, |
| 149 | child: Stack( | 148 | child: Stack( |
| 150 | alignment: Alignment.center, | 149 | alignment: Alignment.center, |
| 151 | children: <Widget>[ | 150 | children: <Widget>[ |
| @@ -167,10 +166,12 @@ class NotebookDetailPageState extends State<NotebookDetailPage> { | @@ -167,10 +166,12 @@ class NotebookDetailPageState extends State<NotebookDetailPage> { | ||
| 167 | list.add(manager.roleUserName); | 166 | list.add(manager.roleUserName); |
| 168 | } | 167 | } |
| 169 | DialogUtil.showSelectCusmanDialog(context,list).then((value){ | 168 | DialogUtil.showSelectCusmanDialog(context,list).then((value){ |
| 170 | - setState(() { | ||
| 171 | - cusmanText=managers[value.first].userName; | ||
| 172 | - }); | ||
| 173 | - _setCurrManager(); | 169 | + if(value!=null){ |
| 170 | + setState(() { | ||
| 171 | + cusmanText=managers[value.first].userName; | ||
| 172 | + }); | ||
| 173 | + _setCurrManager(); | ||
| 174 | + } | ||
| 174 | }); | 175 | }); |
| 175 | }, | 176 | }, |
| 176 | child: Text( | 177 | child: Text( |
| @@ -193,7 +194,7 @@ class NotebookDetailPageState extends State<NotebookDetailPage> { | @@ -193,7 +194,7 @@ class NotebookDetailPageState extends State<NotebookDetailPage> { | ||
| 193 | children: <Widget>[ | 194 | children: <Widget>[ |
| 194 | MyDivider(double.infinity, ScreenUtil().setHeight(2)), | 195 | MyDivider(double.infinity, ScreenUtil().setHeight(2)), |
| 195 | RowMultiText("取消原因", detailEntity.cancel?.desc??""), | 196 | RowMultiText("取消原因", detailEntity.cancel?.desc??""), |
| 196 | - RowMultiText("取消时间", detailEntity.cancel?.cdateStr), | 197 | + RowMultiText("取消时间", detailEntity.cancel?.cdateStr??""), |
| 197 | RowMultiText("操作人", detailEntity.cancel?.uname??""), | 198 | RowMultiText("操作人", detailEntity.cancel?.uname??""), |
| 198 | ], | 199 | ], |
| 199 | ), | 200 | ), |
| @@ -3,6 +3,7 @@ import 'package:flutter_screenutil/flutter_screenutil.dart'; | @@ -3,6 +3,7 @@ import 'package:flutter_screenutil/flutter_screenutil.dart'; | ||
| 3 | import 'package:one_key/app.dart'; | 3 | import 'package:one_key/app.dart'; |
| 4 | import 'package:one_key/provider/user_model.dart'; | 4 | import 'package:one_key/provider/user_model.dart'; |
| 5 | import 'package:one_key/res/colors.dart'; | 5 | import 'package:one_key/res/colors.dart'; |
| 6 | +import 'package:one_key/utils/log_util.dart'; | ||
| 6 | import 'package:one_key/utils/navigator_util.dart'; | 7 | import 'package:one_key/utils/navigator_util.dart'; |
| 7 | import 'package:one_key/widgets/h_empty_view.dart'; | 8 | import 'package:one_key/widgets/h_empty_view.dart'; |
| 8 | import 'package:one_key/widgets/v_empty_view.dart'; | 9 | import 'package:one_key/widgets/v_empty_view.dart'; |
| @@ -35,9 +36,19 @@ class LoginState extends State<LoginPage> with WidgetsBindingObserver{ | @@ -35,9 +36,19 @@ class LoginState extends State<LoginPage> with WidgetsBindingObserver{ | ||
| 35 | @override | 36 | @override |
| 36 | void initState(){ | 37 | void initState(){ |
| 37 | // TODO: implement initState | 38 | // TODO: implement initState |
| 38 | - WidgetsBinding.instance.addObserver(this); | ||
| 39 | super.initState(); | 39 | super.initState(); |
| 40 | isLogin(); | 40 | isLogin(); |
| 41 | + WidgetsBinding.instance.addObserver(this); | ||
| 42 | + WidgetsBinding.instance.addPostFrameCallback((_){ | ||
| 43 | + final UserModel userModel=Provider.of<UserModel>(context,listen: false); | ||
| 44 | + if(userModel!=null&&userModel.user!=null){ | ||
| 45 | + Future.delayed(Duration(milliseconds: 50),(){ | ||
| 46 | + _sellerCodeController.text=userModel.user.sellercode; | ||
| 47 | + _accountController.text=userModel.user.account; | ||
| 48 | + FocusScope.of(context).requestFocus(_pwdFocusNode); | ||
| 49 | + }); | ||
| 50 | + } | ||
| 51 | + }); | ||
| 41 | } | 52 | } |
| 42 | 53 | ||
| 43 | handlePostFrame(_){ | 54 | handlePostFrame(_){ |
| @@ -94,14 +105,6 @@ class LoginState extends State<LoginPage> with WidgetsBindingObserver{ | @@ -94,14 +105,6 @@ class LoginState extends State<LoginPage> with WidgetsBindingObserver{ | ||
| 94 | App.statusBarHeight=MediaQuery.of(context).padding.top; | 105 | App.statusBarHeight=MediaQuery.of(context).padding.top; |
| 95 | App.bottomBarHeight=MediaQuery.of(context).padding.bottom; | 106 | App.bottomBarHeight=MediaQuery.of(context).padding.bottom; |
| 96 | 107 | ||
| 97 | - final UserModel userModel=Provider.of<UserModel>(context); | ||
| 98 | - if(userModel!=null&&userModel.user!=null){ | ||
| 99 | -// _sellerCodeController.text=userModel.user.sellercode; | ||
| 100 | - _accountController.text=userModel.user.account; | ||
| 101 | - | ||
| 102 | - _sellerCodeController=TextEditingController.fromValue(TextEditingValue(text:userModel.user.sellercode,selection: TextSelection.fromPosition(TextPosition(affinity: TextAffinity.downstream,offset: userModel.user.sellercode.length)))); | ||
| 103 | - } | ||
| 104 | - | ||
| 105 | final double prefixIconWidth=ScreenUtil().setWidth(24); | 108 | final double prefixIconWidth=ScreenUtil().setWidth(24); |
| 106 | return Scaffold( | 109 | return Scaffold( |
| 107 | backgroundColor: MyColours.color_ffffff, | 110 | backgroundColor: MyColours.color_ffffff, |
| @@ -140,7 +143,7 @@ class LoginState extends State<LoginPage> with WidgetsBindingObserver{ | @@ -140,7 +143,7 @@ class LoginState extends State<LoginPage> with WidgetsBindingObserver{ | ||
| 140 | hintText: "请输入6位商户编码", | 143 | hintText: "请输入6位商户编码", |
| 141 | hintStyle: TextStyle(color: MyColours.color_c1c1c1,fontSize: ScreenUtil().setSp(26)), | 144 | hintStyle: TextStyle(color: MyColours.color_c1c1c1,fontSize: ScreenUtil().setSp(26)), |
| 142 | border: InputBorder.none, | 145 | border: InputBorder.none, |
| 143 | - contentPadding: EdgeInsets.all(10) | 146 | + contentPadding: EdgeInsets.symmetric(vertical: ScreenUtil().setHeight(30),horizontal: ScreenUtil().setWidth(10)) |
| 144 | ), | 147 | ), |
| 145 | onChanged: (_){ | 148 | onChanged: (_){ |
| 146 | setActivate(); | 149 | setActivate(); |
| @@ -175,7 +178,7 @@ class LoginState extends State<LoginPage> with WidgetsBindingObserver{ | @@ -175,7 +178,7 @@ class LoginState extends State<LoginPage> with WidgetsBindingObserver{ | ||
| 175 | hintText: "请输入4位工号", | 178 | hintText: "请输入4位工号", |
| 176 | hintStyle: TextStyle(color: MyColours.color_c1c1c1,fontSize: ScreenUtil().setSp(26)), | 179 | hintStyle: TextStyle(color: MyColours.color_c1c1c1,fontSize: ScreenUtil().setSp(26)), |
| 177 | border: InputBorder.none, | 180 | border: InputBorder.none, |
| 178 | - contentPadding: EdgeInsets.all(10) | 181 | + contentPadding: EdgeInsets.symmetric(vertical: ScreenUtil().setHeight(30),horizontal: ScreenUtil().setWidth(10)) |
| 179 | ), | 182 | ), |
| 180 | onChanged: (_){ | 183 | onChanged: (_){ |
| 181 | setActivate(); | 184 | setActivate(); |
| @@ -210,8 +213,8 @@ class LoginState extends State<LoginPage> with WidgetsBindingObserver{ | @@ -210,8 +213,8 @@ class LoginState extends State<LoginPage> with WidgetsBindingObserver{ | ||
| 210 | decoration: InputDecoration( | 213 | decoration: InputDecoration( |
| 211 | hintText: "请输入密码", | 214 | hintText: "请输入密码", |
| 212 | hintStyle: TextStyle(color: MyColours.color_c1c1c1,fontSize: ScreenUtil().setSp(26)), | 215 | hintStyle: TextStyle(color: MyColours.color_c1c1c1,fontSize: ScreenUtil().setSp(26)), |
| 213 | - border: InputBorder.none, | ||
| 214 | - contentPadding: EdgeInsets.all(10) | 216 | + border: InputBorder.none, |
| 217 | + contentPadding: EdgeInsets.symmetric(vertical: ScreenUtil().setHeight(30),horizontal: ScreenUtil().setWidth(10)) | ||
| 215 | ), | 218 | ), |
| 216 | onChanged: (_){ | 219 | onChanged: (_){ |
| 217 | setActivate(); | 220 | setActivate(); |
| @@ -69,7 +69,7 @@ class MessageDialogItem extends StatelessWidget { | @@ -69,7 +69,7 @@ class MessageDialogItem extends StatelessWidget { | ||
| 69 | ), | 69 | ), |
| 70 | VEmptyView(10), | 70 | VEmptyView(10), |
| 71 | Text( | 71 | Text( |
| 72 | - "就餐时间:${message.ddate}", | 72 | + "就餐时间:${message.ddateStr}", |
| 73 | style: TextStyle( | 73 | style: TextStyle( |
| 74 | color: textColor, | 74 | color: textColor, |
| 75 | fontSize: ScreenUtil().setSp(26)), | 75 | fontSize: ScreenUtil().setSp(26)), |
| @@ -2,9 +2,8 @@ import 'package:flutter/material.dart'; | @@ -2,9 +2,8 @@ import 'package:flutter/material.dart'; | ||
| 2 | import 'package:flutter_easyrefresh/easy_refresh.dart'; | 2 | import 'package:flutter_easyrefresh/easy_refresh.dart'; |
| 3 | import 'package:one_key/provider/message_model.dart'; | 3 | import 'package:one_key/provider/message_model.dart'; |
| 4 | import 'package:one_key/provider/user_model.dart'; | 4 | import 'package:one_key/provider/user_model.dart'; |
| 5 | -import 'package:one_key/utils/log_util.dart'; | ||
| 6 | import 'package:provider/provider.dart'; | 5 | import 'package:provider/provider.dart'; |
| 7 | - | 6 | +import 'package:one_key/utils/event_bus.dart'; |
| 8 | import 'message_dialog_item.dart'; | 7 | import 'message_dialog_item.dart'; |
| 9 | 8 | ||
| 10 | class MessageLeftPage extends StatefulWidget { | 9 | class MessageLeftPage extends StatefulWidget { |
| @@ -23,6 +22,10 @@ class MessageLeftPageState extends State<MessageLeftPage> { | @@ -23,6 +22,10 @@ class MessageLeftPageState extends State<MessageLeftPage> { | ||
| 23 | void initState() { | 22 | void initState() { |
| 24 | // TODO: implement initState | 23 | // TODO: implement initState |
| 25 | super.initState(); | 24 | super.initState(); |
| 25 | + bus.on("remove_untreated_message",(args){ | ||
| 26 | + MessageModel messageModel=Provider.of<MessageModel>(context,listen: false); | ||
| 27 | + messageModel.removeUntreatedMessageByMid(args.toString()); | ||
| 28 | + }); | ||
| 26 | _controller=EasyRefreshController(); | 29 | _controller=EasyRefreshController(); |
| 27 | WidgetsBinding.instance.addPostFrameCallback((_){ | 30 | WidgetsBinding.instance.addPostFrameCallback((_){ |
| 28 | getUntreatedMessage(); | 31 | getUntreatedMessage(); |
| @@ -64,4 +67,11 @@ class MessageLeftPageState extends State<MessageLeftPage> { | @@ -64,4 +67,11 @@ class MessageLeftPageState extends State<MessageLeftPage> { | ||
| 64 | }, | 67 | }, |
| 65 | ); | 68 | ); |
| 66 | } | 69 | } |
| 70 | + | ||
| 71 | + @override | ||
| 72 | + void dispose() { | ||
| 73 | + // TODO: implement dispose | ||
| 74 | + super.dispose(); | ||
| 75 | + bus.off("remove_untreated_message"); | ||
| 76 | + } | ||
| 67 | } | 77 | } |
| @@ -277,7 +277,9 @@ class NoteBookPageState extends State<NoteBookPage> { | @@ -277,7 +277,9 @@ class NoteBookPageState extends State<NoteBookPage> { | ||
| 277 | child: GestureDetector( | 277 | child: GestureDetector( |
| 278 | onTap: () { | 278 | onTap: () { |
| 279 | DialogUtil.showCalendarDialog(context,dateTime).then((day) { | 279 | DialogUtil.showCalendarDialog(context,dateTime).then((day) { |
| 280 | - _createDateText(day); | 280 | + if(day!=null){ |
| 281 | + _createDateText(day); | ||
| 282 | + } | ||
| 281 | }); | 283 | }); |
| 282 | }, | 284 | }, |
| 283 | child: Text( | 285 | child: Text( |
| @@ -26,15 +26,17 @@ class SmsModel with ChangeNotifier { | @@ -26,15 +26,17 @@ class SmsModel with ChangeNotifier { | ||
| 26 | 26 | ||
| 27 | //发送短信 | 27 | //发送短信 |
| 28 | sendSms(BuildContext context, Map<String, String> params) async { | 28 | sendSms(BuildContext context, Map<String, String> params) async { |
| 29 | - BaseResp<Map<String, dynamic>> baseResp = await DioUtil() | ||
| 30 | - .request<Map<String, dynamic>>(context, Method.get, HttpUrl.send_sms, | 29 | + BaseResp<dynamic> baseResp = await DioUtil() |
| 30 | + .request<dynamic>(context, Method.get, HttpUrl.send_sms, | ||
| 31 | data: params) | 31 | data: params) |
| 32 | .catchError((error) { | 32 | .catchError((error) { |
| 33 | print(error.toString()); | 33 | print(error.toString()); |
| 34 | }); | 34 | }); |
| 35 | if (baseResp.code == Constant.status_success) { | 35 | if (baseResp.code == Constant.status_success) { |
| 36 | Utils.showToast("短信发送成功"); | 36 | Utils.showToast("短信发送成功"); |
| 37 | - } else { | 37 | + } else if(baseResp.code==396){ |
| 38 | + Utils.showToast("短信余量不足,请前去充值"); | ||
| 39 | + }else{ | ||
| 38 | Utils.showToast(baseResp.msg ?? ""); | 40 | Utils.showToast(baseResp.msg ?? ""); |
| 39 | } | 41 | } |
| 40 | } | 42 | } |
| @@ -56,7 +56,7 @@ class MessageDialogModel extends ChangeNotifier{ | @@ -56,7 +56,7 @@ class MessageDialogModel extends ChangeNotifier{ | ||
| 56 | messages=baseResp.data.map<Message>((value){ | 56 | messages=baseResp.data.map<Message>((value){ |
| 57 | return Message.fromJson(value); | 57 | return Message.fromJson(value); |
| 58 | }).toList(); | 58 | }).toList(); |
| 59 | - messages.removeWhere((message)=>message.message_type!="10"); | 59 | + messages.removeWhere((message)=>message.message_type.toString()!="10"); |
| 60 | if(messages.isNotEmpty){ | 60 | if(messages.isNotEmpty){ |
| 61 | play(); | 61 | play(); |
| 62 | if(!showMessageDialog){ | 62 | if(!showMessageDialog){ |
| @@ -24,7 +24,7 @@ class MessageModel extends ChangeNotifier{ | @@ -24,7 +24,7 @@ class MessageModel extends ChangeNotifier{ | ||
| 24 | untreatedMsgs=baseResp.data.map<Message>((value){ | 24 | untreatedMsgs=baseResp.data.map<Message>((value){ |
| 25 | return Message.fromJson(value); | 25 | return Message.fromJson(value); |
| 26 | }).toList(); | 26 | }).toList(); |
| 27 | - untreatedMsgs.removeWhere((message)=>message.message_type!="10"); | 27 | + untreatedMsgs.removeWhere((message)=>message.message_type.toString()!="10"); |
| 28 | notifyListeners(); | 28 | notifyListeners(); |
| 29 | } | 29 | } |
| 30 | } | 30 | } |
| @@ -47,8 +47,14 @@ class MessageModel extends ChangeNotifier{ | @@ -47,8 +47,14 @@ class MessageModel extends ChangeNotifier{ | ||
| 47 | return Message.fromJson(value); | 47 | return Message.fromJson(value); |
| 48 | }).toList()); | 48 | }).toList()); |
| 49 | } | 49 | } |
| 50 | - treatedMsgs.removeWhere((message)=>message.message_type!="10"); | 50 | + treatedMsgs.removeWhere((message)=>message.message_type.toString()!="10"); |
| 51 | notifyListeners(); | 51 | notifyListeners(); |
| 52 | } | 52 | } |
| 53 | } | 53 | } |
| 54 | + | ||
| 55 | + //移除未处理在线预订消息 | ||
| 56 | + removeUntreatedMessageByMid(String mid){ | ||
| 57 | + untreatedMsgs.removeWhere((message)=>message.id==mid); | ||
| 58 | + notifyListeners(); | ||
| 59 | + } | ||
| 54 | } | 60 | } |
| @@ -44,7 +44,7 @@ class UserModel with ChangeNotifier { | @@ -44,7 +44,7 @@ class UserModel with ChangeNotifier { | ||
| 44 | Map<String, dynamic> seller = baseResp.data[0]["seller"]; | 44 | Map<String, dynamic> seller = baseResp.data[0]["seller"]; |
| 45 | Map<String, dynamic> user = baseResp.data[0]["user"]; | 45 | Map<String, dynamic> user = baseResp.data[0]["user"]; |
| 46 | Map<String, dynamic> userMap = { | 46 | Map<String, dynamic> userMap = { |
| 47 | - "openid": seller['openid'], | 47 | + "openid": user['id'], |
| 48 | "account": user['account'], | 48 | "account": user['account'], |
| 49 | "role_name": user['role_name'], | 49 | "role_name": user['role_name'], |
| 50 | "sellerid": seller['id'], | 50 | "sellerid": seller['id'], |
lib/utils/event_bus.dart
0 → 100644
| 1 | +//订阅者回调签名 | ||
| 2 | +typedef void EventCallback(arg); | ||
| 3 | + | ||
| 4 | +class EventBus { | ||
| 5 | + //私有构造函数 | ||
| 6 | + EventBus._internal(); | ||
| 7 | + | ||
| 8 | + //保存单例 | ||
| 9 | + static EventBus _singleton = new EventBus._internal(); | ||
| 10 | + | ||
| 11 | + //工厂构造函数 | ||
| 12 | + factory EventBus()=> _singleton; | ||
| 13 | + | ||
| 14 | + //保存事件订阅者队列,key:事件名(id),value: 对应事件的订阅者队列 | ||
| 15 | + var _emap = new Map<Object, List<EventCallback>>(); | ||
| 16 | + | ||
| 17 | + //添加订阅者 | ||
| 18 | + void on(eventName, EventCallback f) { | ||
| 19 | + if (eventName == null || f == null) return; | ||
| 20 | + _emap[eventName] ??= new List<EventCallback>(); | ||
| 21 | + _emap[eventName].add(f); | ||
| 22 | + } | ||
| 23 | + | ||
| 24 | + //移除订阅者 | ||
| 25 | + void off(eventName, [EventCallback f]) { | ||
| 26 | + var list = _emap[eventName]; | ||
| 27 | + if (eventName == null || list == null) return; | ||
| 28 | + if (f == null) { | ||
| 29 | + _emap[eventName] = null; | ||
| 30 | + } else { | ||
| 31 | + list.remove(f); | ||
| 32 | + } | ||
| 33 | + } | ||
| 34 | + | ||
| 35 | + //触发事件,事件触发后该事件所有订阅者会被调用 | ||
| 36 | + void emit(eventName, [arg]) { | ||
| 37 | + var list = _emap[eventName]; | ||
| 38 | + if (list == null) return; | ||
| 39 | + int len = list.length - 1; | ||
| 40 | + //反向遍历,防止在订阅者在回调中移除自身带来的下标错位 | ||
| 41 | + for (var i = len; i > -1; --i) { | ||
| 42 | + list[i](arg); | ||
| 43 | + } | ||
| 44 | + } | ||
| 45 | +} | ||
| 46 | + | ||
| 47 | +//定义一个top-level变量,页面引入该文件后可以直接使用bus | ||
| 48 | +var bus = new EventBus(); |
| 1 | +import 'package:connectivity/connectivity.dart'; | ||
| 1 | import 'package:extended_image/extended_image.dart'; | 2 | import 'package:extended_image/extended_image.dart'; |
| 2 | import 'package:flutter/cupertino.dart'; | 3 | import 'package:flutter/cupertino.dart'; |
| 3 | import 'package:flutter/material.dart'; | 4 | import 'package:flutter/material.dart'; |
| @@ -100,4 +101,17 @@ class Utils { | @@ -100,4 +101,17 @@ class Utils { | ||
| 100 | ); | 101 | ); |
| 101 | shareToWeChat(model); | 102 | shareToWeChat(model); |
| 102 | } | 103 | } |
| 104 | + | ||
| 105 | + //检查网络连接 | ||
| 106 | + static Future<bool> checkConnectiviy()async{ | ||
| 107 | + var connectivityResult = await (new Connectivity().checkConnectivity()); | ||
| 108 | + if (connectivityResult == ConnectivityResult.mobile) { | ||
| 109 | + // I am connected to a mobile network. | ||
| 110 | + return true; | ||
| 111 | + } else if (connectivityResult == ConnectivityResult.wifi) { | ||
| 112 | + // I am connected to a wifi network. | ||
| 113 | + return true; | ||
| 114 | + } | ||
| 115 | + return false; | ||
| 116 | + } | ||
| 103 | } | 117 | } |
| @@ -15,8 +15,8 @@ class RowMultiText extends StatelessWidget{ | @@ -15,8 +15,8 @@ class RowMultiText extends StatelessWidget{ | ||
| 15 | return Container( | 15 | return Container( |
| 16 | color: MyColours.color_ffffff, | 16 | color: MyColours.color_ffffff, |
| 17 | width: double.infinity, | 17 | width: double.infinity, |
| 18 | - height: ScreenUtil().setHeight(74), | ||
| 19 | - padding: EdgeInsets.symmetric(vertical: ScreenUtil().setHeight(26)), | 18 | + height: ScreenUtil().setHeight(80), |
| 19 | + alignment: Alignment.center, | ||
| 20 | child: Stack( | 20 | child: Stack( |
| 21 | alignment: Alignment.center, | 21 | alignment: Alignment.center, |
| 22 | children: <Widget>[ | 22 | children: <Widget>[ |
| @@ -134,6 +134,27 @@ packages: | @@ -134,6 +134,27 @@ packages: | ||
| 134 | url: "https://pub.flutter-io.cn" | 134 | url: "https://pub.flutter-io.cn" |
| 135 | source: hosted | 135 | source: hosted |
| 136 | version: "1.14.11" | 136 | version: "1.14.11" |
| 137 | + connectivity: | ||
| 138 | + dependency: "direct main" | ||
| 139 | + description: | ||
| 140 | + name: connectivity | ||
| 141 | + url: "https://pub.flutter-io.cn" | ||
| 142 | + source: hosted | ||
| 143 | + version: "0.4.8+2" | ||
| 144 | + connectivity_macos: | ||
| 145 | + dependency: transitive | ||
| 146 | + description: | ||
| 147 | + name: connectivity_macos | ||
| 148 | + url: "https://pub.flutter-io.cn" | ||
| 149 | + source: hosted | ||
| 150 | + version: "0.1.0+2" | ||
| 151 | + connectivity_platform_interface: | ||
| 152 | + dependency: transitive | ||
| 153 | + description: | ||
| 154 | + name: connectivity_platform_interface | ||
| 155 | + url: "https://pub.flutter-io.cn" | ||
| 156 | + source: hosted | ||
| 157 | + version: "1.0.3" | ||
| 137 | convert: | 158 | convert: |
| 138 | dependency: transitive | 159 | dependency: transitive |
| 139 | description: | 160 | description: |
| @@ -793,4 +814,4 @@ packages: | @@ -793,4 +814,4 @@ packages: | ||
| 793 | version: "2.2.0" | 814 | version: "2.2.0" |
| 794 | sdks: | 815 | sdks: |
| 795 | dart: ">=2.7.0 <3.0.0" | 816 | dart: ">=2.7.0 <3.0.0" |
| 796 | - flutter: ">=1.12.13+hotfix.4 <1.16.0" | 817 | + flutter: ">=1.12.13+hotfix.5 <1.16.0" |
| @@ -69,6 +69,8 @@ dependencies: | @@ -69,6 +69,8 @@ dependencies: | ||
| 69 | url_launcher: ^5.4.2 | 69 | url_launcher: ^5.4.2 |
| 70 | # 滚轮选择器 | 70 | # 滚轮选择器 |
| 71 | flutter_picker: ^1.1.3 | 71 | flutter_picker: ^1.1.3 |
| 72 | +# 网络状态 | ||
| 73 | + connectivity: ^0.4.8 | ||
| 72 | 74 | ||
| 73 | dev_dependencies: | 75 | dev_dependencies: |
| 74 | flutter_test: | 76 | flutter_test: |
-
Please register or login to post a comment