Showing
8 changed files
with
166 additions
and
84 deletions
| @@ -11,14 +11,14 @@ if (flutterRoot == null) { | @@ -11,14 +11,14 @@ if (flutterRoot == null) { | ||
| 11 | throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.") | 11 | throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.") |
| 12 | } | 12 | } |
| 13 | 13 | ||
| 14 | -def flutterVersionCode = "121" | 14 | +def flutterVersionCode = "132" |
| 15 | if (flutterVersionCode == null) { | 15 | if (flutterVersionCode == null) { |
| 16 | - flutterVersionCode = '131' | 16 | + flutterVersionCode = '132' |
| 17 | } | 17 | } |
| 18 | 18 | ||
| 19 | -def flutterVersionName = "1.2.1" | 19 | +def flutterVersionName = "1.3.2" |
| 20 | if (flutterVersionName == null) { | 20 | if (flutterVersionName == null) { |
| 21 | - flutterVersionName = '1.3.1' | 21 | + flutterVersionName = '1.3.2' |
| 22 | } | 22 | } |
| 23 | 23 | ||
| 24 | apply plugin: 'com.android.application' | 24 | apply plugin: 'com.android.application' |
| @@ -27,7 +27,7 @@ class NotebookDetail { | @@ -27,7 +27,7 @@ class NotebookDetail { | ||
| 27 | tables=[]; | 27 | tables=[]; |
| 28 | } | 28 | } |
| 29 | 29 | ||
| 30 | - NotebookDetail.fromTableManager(DateTime dateTime,String ddate_solt,t.Table table){ | 30 | + NotebookDetail.fromTableManager(DateTime dateTime,String ddatesolt,t.Table table){ |
| 31 | id="-1"; | 31 | id="-1"; |
| 32 | pnum="6"; | 32 | pnum="6"; |
| 33 | rname=""; | 33 | rname=""; |
| @@ -35,7 +35,7 @@ class NotebookDetail { | @@ -35,7 +35,7 @@ class NotebookDetail { | ||
| 35 | phone=""; | 35 | phone=""; |
| 36 | cusdem=""; | 36 | cusdem=""; |
| 37 | ddate=(DateUtil.getDateMsByTimeStr(DateUtil.formatDate(dateTime).replaceRange(11,19, "00:00:00"))/1000).floor().toString(); | 37 | ddate=(DateUtil.getDateMsByTimeStr(DateUtil.formatDate(dateTime).replaceRange(11,19, "00:00:00"))/1000).floor().toString(); |
| 38 | - ddate_solt=ddate_solt; | 38 | + ddate_solt=ddatesolt; |
| 39 | is_set_ddate="0"; | 39 | is_set_ddate="0"; |
| 40 | tables=[table]; | 40 | tables=[table]; |
| 41 | } | 41 | } |
| @@ -32,7 +32,7 @@ class HttpUrl { | @@ -32,7 +32,7 @@ class HttpUrl { | ||
| 32 | static const String get_table_list = | 32 | static const String get_table_list = |
| 33 | "?service=Android.Reserve.NewGetTableList"; //根据商家ID 获取桌位信息列表: 1:散座 2:包间 默认:获取所有数据 | 33 | "?service=Android.Reserve.NewGetTableList"; //根据商家ID 获取桌位信息列表: 1:散座 2:包间 默认:获取所有数据 |
| 34 | static const String set_reserve_info = | 34 | static const String set_reserve_info = |
| 35 | - "?service=Android.Customer.SetReserveInfo"; //录入顾客订座相关信息,同时更新商家桌位状态 | 35 | + "?service=Android.Reserve.SetReserveInfo"; //录入顾客订座相关信息,同时更新商家桌位状态 |
| 36 | static const String set_switch_status = | 36 | static const String set_switch_status = |
| 37 | "?service=App.Reserve.SetSwitchStatus"; //启用/停用桌位 | 37 | "?service=App.Reserve.SetSwitchStatus"; //启用/停用桌位 |
| 38 | } | 38 | } |
| @@ -820,9 +820,7 @@ class _NoteBookChangePageState extends State<NoteBookChangePage> { | @@ -820,9 +820,7 @@ class _NoteBookChangePageState extends State<NoteBookChangePage> { | ||
| 820 | NavigatorUtil.goInvicationPage(context, _model.row.id, | 820 | NavigatorUtil.goInvicationPage(context, _model.row.id, |
| 821 | _nameStr, _model.row.ddate, ddate_solt, | 821 | _nameStr, _model.row.ddate, ddate_solt, |
| 822 | replace: true); | 822 | replace: true); |
| 823 | - if(widget.detailEntity.id=="-1"){ | ||
| 824 | - EventBus().emit("refresh_tablemanager"); | ||
| 825 | - } | 823 | + EventBus().emit("refresh_tablemanager");//刷新桌位 |
| 826 | } else { | 824 | } else { |
| 827 | Utils.showToast(widget.detailEntity.id=="-1"?"变更预订订单失败,请重试!":"变更预订订单失败,请重试!"); | 825 | Utils.showToast(widget.detailEntity.id=="-1"?"变更预订订单失败,请重试!":"变更预订订单失败,请重试!"); |
| 828 | } | 826 | } |
| 1 | -import 'dart:ffi'; | ||
| 2 | - | ||
| 3 | import 'package:common_utils/common_utils.dart'; | 1 | import 'package:common_utils/common_utils.dart'; |
| 4 | import 'package:flutter/material.dart'; | 2 | import 'package:flutter/material.dart'; |
| 5 | import 'package:flutter_screenutil/flutter_screenutil.dart'; | 3 | import 'package:flutter_screenutil/flutter_screenutil.dart'; |
| 4 | +import 'package:one_key/constant/state.dart'; | ||
| 6 | import 'package:one_key/models/area.dart'; | 5 | import 'package:one_key/models/area.dart'; |
| 7 | -import 'package:one_key/models/notebook.dart'; | ||
| 8 | import 'package:one_key/models/notebook_detail.dart'; | 6 | import 'package:one_key/models/notebook_detail.dart'; |
| 9 | -import 'package:one_key/models/tableOuter.dart'; | ||
| 10 | -import 'package:one_key/models/table_list.dart'; | ||
| 11 | -import 'package:one_key/provider/choose_table_model.dart'; | ||
| 12 | -import 'package:one_key/provider/notebook_detail_change_model.dart'; | ||
| 13 | -import 'package:one_key/provider/notebook_model.dart'; | ||
| 14 | import 'package:one_key/provider/table_manager_model.dart'; | 7 | import 'package:one_key/provider/table_manager_model.dart'; |
| 15 | -import 'package:one_key/provider/user_model.dart'; | ||
| 16 | import 'package:one_key/res/colors.dart'; | 8 | import 'package:one_key/res/colors.dart'; |
| 17 | import 'package:one_key/utils/dialog_util.dart'; | 9 | import 'package:one_key/utils/dialog_util.dart'; |
| 18 | import 'package:one_key/utils/event_bus.dart'; | 10 | import 'package:one_key/utils/event_bus.dart'; |
| 19 | import 'package:one_key/utils/navigator_util.dart'; | 11 | import 'package:one_key/utils/navigator_util.dart'; |
| 20 | -import 'package:one_key/utils/utils.dart'; | ||
| 21 | import 'package:one_key/widgets/MyDivider.dart'; | 12 | import 'package:one_key/widgets/MyDivider.dart'; |
| 22 | import 'package:one_key/widgets/app_bar.dart'; | 13 | import 'package:one_key/widgets/app_bar.dart'; |
| 23 | import 'package:one_key/widgets/area_item.dart'; | 14 | import 'package:one_key/widgets/area_item.dart'; |
| 24 | 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'; | ||
| 25 | import 'package:one_key/widgets/table_item.dart'; | 17 | import 'package:one_key/widgets/table_item.dart'; |
| 26 | import 'package:one_key/models/table.dart' as t; | 18 | import 'package:one_key/models/table.dart' as t; |
| 27 | import 'package:provider/provider.dart'; | 19 | import 'package:provider/provider.dart'; |
| @@ -64,7 +56,7 @@ class TableManagerPageState extends State<TableManagerPage> { | @@ -64,7 +56,7 @@ class TableManagerPageState extends State<TableManagerPage> { | ||
| 64 | children: <Widget>[ | 56 | children: <Widget>[ |
| 65 | MyAppBar( | 57 | MyAppBar( |
| 66 | "桌位", | 58 | "桌位", |
| 67 | - showBack: true, | 59 | + showBack: false |
| 68 | ), | 60 | ), |
| 69 | Container( | 61 | Container( |
| 70 | color: MyColours.color_ffffff, | 62 | color: MyColours.color_ffffff, |
| @@ -167,18 +159,43 @@ class TableManagerPageState extends State<TableManagerPage> { | @@ -167,18 +159,43 @@ class TableManagerPageState extends State<TableManagerPage> { | ||
| 167 | ], | 159 | ], |
| 168 | ), | 160 | ), |
| 169 | ), | 161 | ), |
| 162 | + Container( | ||
| 163 | + height: ScreenUtil().setWidth(20), | ||
| 164 | + width: double.infinity, | ||
| 165 | + color: MyColours.color_f5f5f5, | ||
| 166 | + ), | ||
| 170 | Expanded( | 167 | Expanded( |
| 171 | - child: Container( | ||
| 172 | - color: MyColours.color_ffffff, | ||
| 173 | - child: Row( | ||
| 174 | - children: <Widget>[ | ||
| 175 | - Container( | ||
| 176 | - width: ScreenUtil().setWidth(170), | ||
| 177 | - height: double.infinity, | ||
| 178 | - color: MyColours.color_f1f1f1, | ||
| 179 | - child: ListView.builder( | ||
| 180 | - itemBuilder: (context, index) { | ||
| 181 | - return AreaItem(tableManagerModel.areas[index], tableManagerModel.currentArea, | 168 | + child: Consumer<TableManagerModel>( |
| 169 | + builder: (context,model,child){ | ||
| 170 | + if (model.pageState != PageState.Success) { | ||
| 171 | + return ExceptionPage( | ||
| 172 | + pageState: model.pageState, | ||
| 173 | + callback: () { | ||
| 174 | + if(tableManagerModel.tableOuterList.isEmpty){ | ||
| 175 | + tableManagerModel.getTableList(context); | ||
| 176 | + }else{ | ||
| 177 | + tableManagerModel.getReserveList(context); | ||
| 178 | + } | ||
| 179 | + }, | ||
| 180 | + emptyMsg: "暂时没有桌位哦", | ||
| 181 | + emptyImg: "empty_search", | ||
| 182 | + showMsg: "加载中,请稍后...", | ||
| 183 | + ); | ||
| 184 | + }else{ | ||
| 185 | + return Container( | ||
| 186 | + color: MyColours.color_ffffff, | ||
| 187 | + child: Row( | ||
| 188 | + children: <Widget>[ | ||
| 189 | + Container( | ||
| 190 | + width: ScreenUtil().setWidth(170), | ||
| 191 | + height: double.infinity, | ||
| 192 | + color: MyColours.color_f1f1f1, | ||
| 193 | + child: ListView.builder( | ||
| 194 | + itemBuilder: (context, index) { | ||
| 195 | + return Selector<TableManagerModel,Area>( | ||
| 196 | + selector: (context,model)=>model.areas[index], | ||
| 197 | + builder: (context,area,_){ | ||
| 198 | + return AreaItem(area, tableManagerModel.currentArea, | ||
| 182 | (area) { | 199 | (area) { |
| 183 | setState(() { | 200 | setState(() { |
| 184 | tableManagerModel.currentArea = (area as Area).name; | 201 | tableManagerModel.currentArea = (area as Area).name; |
| @@ -186,26 +203,31 @@ class TableManagerPageState extends State<TableManagerPage> { | @@ -186,26 +203,31 @@ class TableManagerPageState extends State<TableManagerPage> { | ||
| 186 | }); | 203 | }); |
| 187 | }); | 204 | }); |
| 188 | }, | 205 | }, |
| 189 | - itemExtent: ScreenUtil().setHeight(207), | ||
| 190 | - itemCount: tableManagerModel.areas.length, | ||
| 191 | - ), | ||
| 192 | - ), | ||
| 193 | - Expanded( | ||
| 194 | - child: Padding( | ||
| 195 | - padding: EdgeInsets.symmetric( | ||
| 196 | - vertical: ScreenUtil().setHeight(10), | ||
| 197 | - horizontal: ScreenUtil().setWidth(9)), | ||
| 198 | - child: Column( | ||
| 199 | - children: [ | ||
| 200 | - Expanded( | ||
| 201 | - child: GridView.builder( | ||
| 202 | - gridDelegate: | ||
| 203 | - SliverGridDelegateWithFixedCrossAxisCount( | ||
| 204 | - crossAxisCount: 3, | ||
| 205 | - childAspectRatio: 8 / 9), | ||
| 206 | - itemBuilder: (context, index) { | 206 | + ); |
| 207 | + }, | ||
| 208 | + itemExtent: ScreenUtil().setHeight(207), | ||
| 209 | + itemCount: tableManagerModel.areas.length, | ||
| 210 | + ), | ||
| 211 | + ), | ||
| 212 | + Expanded( | ||
| 213 | + child: Padding( | ||
| 214 | + padding: EdgeInsets.symmetric( | ||
| 215 | + vertical: ScreenUtil().setHeight(10), | ||
| 216 | + horizontal: ScreenUtil().setWidth(9)), | ||
| 217 | + child: Column( | ||
| 218 | + children: [ | ||
| 219 | + Expanded( | ||
| 220 | + child: GridView.builder( | ||
| 221 | + gridDelegate: | ||
| 222 | + SliverGridDelegateWithFixedCrossAxisCount( | ||
| 223 | + crossAxisCount: 3, | ||
| 224 | + childAspectRatio: 8 / 9), | ||
| 225 | + itemBuilder: (context, index) { | ||
| 226 | + return Selector<TableManagerModel,t.Table>( | ||
| 227 | + selector: (context,model)=>model.currentTables[index], | ||
| 228 | + builder: (context,table,_){ | ||
| 207 | return TableItem( | 229 | return TableItem( |
| 208 | - tableManagerModel.areaTableMap[tableManagerModel.currentArea][index], | 230 | + table, |
| 209 | onSelected: (table) { | 231 | onSelected: (table) { |
| 210 | if ((table as t.Table).selected) { | 232 | if ((table as t.Table).selected) { |
| 211 | tableManagerModel.selectTables.add(table); | 233 | tableManagerModel.selectTables.add(table); |
| @@ -223,11 +245,35 @@ class TableManagerPageState extends State<TableManagerPage> { | @@ -223,11 +245,35 @@ class TableManagerPageState extends State<TableManagerPage> { | ||
| 223 | NavigatorUtil.goNoteBookChangePage(context, NotebookDetail.fromTableManager(tableManagerModel.dateTime, tableManagerModel.currTimeIndex.toString(),table), ""); | 245 | NavigatorUtil.goNoteBookChangePage(context, NotebookDetail.fromTableManager(tableManagerModel.dateTime, tableManagerModel.currTimeIndex.toString(),table), ""); |
| 224 | break; | 246 | break; |
| 225 | case 3://停用,启用桌位 | 247 | case 3://停用,启用桌位 |
| 226 | - Map params={ | ||
| 227 | - "id":table.id, | ||
| 228 | - "status":table.enable=="1"?"0":"1" | 248 | + Map<String,String> params={ |
| 249 | + "id":(table as t.Table).id, | ||
| 250 | + "status":(table as t.Table).enable=="1"?"0":"1" | ||
| 229 | }; | 251 | }; |
| 230 | - tableManagerModel.setSwitchStatus(context, params); | 252 | + tableManagerModel.setSwitchStatus(context, params).then((value){ |
| 253 | + if(value!=null){ | ||
| 254 | + (table as t.Table).enable=((int.parse((table as t.Table).enable)+1)%2).toString(); | ||
| 255 | + if((table as t.Table).enable=="1"){ | ||
| 256 | + for(Area area in tableManagerModel.areas){ | ||
| 257 | + if(area.name==tableManagerModel.currentArea){ | ||
| 258 | + if(table.sign != '5'&&table.sign != '1'){//已预订 | ||
| 259 | + area.count++; | ||
| 260 | + } | ||
| 261 | + break; | ||
| 262 | + } | ||
| 263 | + } | ||
| 264 | + }else{ | ||
| 265 | + for(Area area in tableManagerModel.areas){ | ||
| 266 | + if(area.name==tableManagerModel.currentArea){ | ||
| 267 | + if(table.sign != '5'&&table.sign != '1'){//已预订 | ||
| 268 | + area.count--; | ||
| 269 | + } | ||
| 270 | + break; | ||
| 271 | + } | ||
| 272 | + } | ||
| 273 | + } | ||
| 274 | + tableManagerModel.notifyListeners(); | ||
| 275 | + } | ||
| 276 | + }); | ||
| 231 | break; | 277 | break; |
| 232 | } | 278 | } |
| 233 | } | 279 | } |
| @@ -238,14 +284,19 @@ class TableManagerPageState extends State<TableManagerPage> { | @@ -238,14 +284,19 @@ class TableManagerPageState extends State<TableManagerPage> { | ||
| 238 | tableMap: tableManagerModel.tableMap, | 284 | tableMap: tableManagerModel.tableMap, |
| 239 | rid: ""); | 285 | rid: ""); |
| 240 | }, | 286 | }, |
| 241 | - itemCount: tableManagerModel.areaTableMap[tableManagerModel.currentArea].length, | ||
| 242 | - )), | ||
| 243 | - ], | ||
| 244 | - )), | ||
| 245 | - ) | ||
| 246 | - ], | ||
| 247 | - ), | ||
| 248 | - ), | 287 | + ); |
| 288 | + }, | ||
| 289 | + itemCount: tableManagerModel.currentTables.length, | ||
| 290 | + )), | ||
| 291 | + ], | ||
| 292 | + )), | ||
| 293 | + ) | ||
| 294 | + ], | ||
| 295 | + ), | ||
| 296 | + ); | ||
| 297 | + } | ||
| 298 | + }, | ||
| 299 | + ), | ||
| 249 | ), | 300 | ), |
| 250 | ], | 301 | ], |
| 251 | ); | 302 | ); |
| @@ -357,11 +357,13 @@ class NotebookDetailChangeModel with ChangeNotifier { | @@ -357,11 +357,13 @@ class NotebookDetailChangeModel with ChangeNotifier { | ||
| 357 | UserModel userModel = Provider.of<UserModel>(context, listen: false); | 357 | UserModel userModel = Provider.of<UserModel>(context, listen: false); |
| 358 | Map<String, String> params = { | 358 | Map<String, String> params = { |
| 359 | "sid": userModel.user.sellerid, | 359 | "sid": userModel.user.sellerid, |
| 360 | - "rid": detailEntity.id, | ||
| 361 | "rdate": rdate, | 360 | "rdate": rdate, |
| 362 | 'ddate_solt': ddate_solt, | 361 | 'ddate_solt': ddate_solt, |
| 363 | 'pnum': pnum | 362 | 'pnum': pnum |
| 364 | }; | 363 | }; |
| 364 | + if(detailEntity.id.isNotEmpty&&detailEntity.id!="-1"){ | ||
| 365 | + params['rid']=detailEntity.id; | ||
| 366 | + } | ||
| 365 | BaseResp<dynamic> baseResp = await DioUtil() | 367 | BaseResp<dynamic> baseResp = await DioUtil() |
| 366 | .request<dynamic>(context, Method.get, HttpUrl.get_table_list, | 368 | .request<dynamic>(context, Method.get, HttpUrl.get_table_list, |
| 367 | data: params) | 369 | data: params) |
| @@ -543,7 +545,6 @@ class NotebookDetailChangeModel with ChangeNotifier { | @@ -543,7 +545,6 @@ class NotebookDetailChangeModel with ChangeNotifier { | ||
| 543 | } | 545 | } |
| 544 | Map<String, String> params = { | 546 | Map<String, String> params = { |
| 545 | 'is_set_ddate': isSetDate, | 547 | 'is_set_ddate': isSetDate, |
| 546 | - "rid": detailEntity.id, //变更订单必传预定ID | ||
| 547 | "sid": userModel.user.sellerid, //商家ID | 548 | "sid": userModel.user.sellerid, //商家ID |
| 548 | "tid": tableSelectInfo, //桌子ID: 格式 2,3,4 | 549 | "tid": tableSelectInfo, //桌子ID: 格式 2,3,4 |
| 549 | "pnum": pnum, //预定用餐人数 | 550 | "pnum": pnum, //预定用餐人数 |
| @@ -555,6 +556,9 @@ class NotebookDetailChangeModel with ChangeNotifier { | @@ -555,6 +556,9 @@ class NotebookDetailChangeModel with ChangeNotifier { | ||
| 555 | "ddate": '${ddate}'.substring(0, 10), //到店时间 | 556 | "ddate": '${ddate}'.substring(0, 10), //到店时间 |
| 556 | "ddate_solt": ddateSolt | 557 | "ddate_solt": ddateSolt |
| 557 | }; | 558 | }; |
| 559 | + if(detailEntity.id.isNotEmpty&&detailEntity.id!="-1"){ | ||
| 560 | + params['rid']=detailEntity.id; | ||
| 561 | + } | ||
| 558 | print(params); | 562 | print(params); |
| 559 | BaseResp<Map<String, dynamic>> baseResp = await DioUtil() | 563 | BaseResp<Map<String, dynamic>> baseResp = await DioUtil() |
| 560 | .request<Map<String, dynamic>>( | 564 | .request<Map<String, dynamic>>( |
| @@ -574,7 +578,7 @@ class NotebookDetailChangeModel with ChangeNotifier { | @@ -574,7 +578,7 @@ class NotebookDetailChangeModel with ChangeNotifier { | ||
| 574 | baseResp.responseData['data']['row'] != null) { | 578 | baseResp.responseData['data']['row'] != null) { |
| 575 | itemModel = ReserveInfoModel.fromJson(baseResp.responseData).data; | 579 | itemModel = ReserveInfoModel.fromJson(baseResp.responseData).data; |
| 576 | } else { | 580 | } else { |
| 577 | - Utils.showToast(baseResp.msg ?? "变更预订失败,请重试"); | 581 | + Utils.showToast(baseResp.msg ?? detailEntity.id=="-1"?"变更预订订单失败,请重试!":"变更预订订单失败,请重试!"); |
| 578 | } | 582 | } |
| 579 | return itemModel; | 583 | return itemModel; |
| 580 | } | 584 | } |
| 1 | + | ||
| 2 | + | ||
| 3 | +import 'package:common_utils/common_utils.dart'; | ||
| 1 | import 'package:flutter/material.dart'; | 4 | import 'package:flutter/material.dart'; |
| 2 | import 'package:one_key/constant/constant.dart'; | 5 | import 'package:one_key/constant/constant.dart'; |
| 6 | +import 'package:one_key/constant/error.dart'; | ||
| 7 | +import 'package:one_key/constant/state.dart'; | ||
| 3 | import 'package:one_key/models/area.dart'; | 8 | import 'package:one_key/models/area.dart'; |
| 4 | import 'package:one_key/models/notebook.dart'; | 9 | import 'package:one_key/models/notebook.dart'; |
| 5 | import 'package:one_key/models/tableOuter.dart'; | 10 | import 'package:one_key/models/tableOuter.dart'; |
| @@ -25,8 +30,6 @@ class TableManagerModel with ChangeNotifier{ | @@ -25,8 +30,6 @@ class TableManagerModel with ChangeNotifier{ | ||
| 25 | Map<String, List<t.Table>> areaTableMap = {}; //区域-桌位Map | 30 | Map<String, List<t.Table>> areaTableMap = {}; //区域-桌位Map |
| 26 | List<t.Table> currentTables=[];//当前显示的区域-桌位 | 31 | List<t.Table> currentTables=[];//当前显示的区域-桌位 |
| 27 | 32 | ||
| 28 | - TableManagerModel tableManagerModel; | ||
| 29 | - | ||
| 30 | Map<String, Notebook> tableMap = {}; //记录已预订桌位对应的订单 | 33 | Map<String, Notebook> tableMap = {}; //记录已预订桌位对应的订单 |
| 31 | 34 | ||
| 32 | String currentArea; //当前选中区域 | 35 | String currentArea; //当前选中区域 |
| @@ -40,6 +43,8 @@ class TableManagerModel with ChangeNotifier{ | @@ -40,6 +43,8 @@ class TableManagerModel with ChangeNotifier{ | ||
| 40 | String night; //晚市时间段 | 43 | String night; //晚市时间段 |
| 41 | UserModel userModel; | 44 | UserModel userModel; |
| 42 | 45 | ||
| 46 | + PageState pageState = PageState.Loading; | ||
| 47 | + | ||
| 43 | //初始化时间 | 48 | //初始化时间 |
| 44 | initTime(BuildContext context) async { | 49 | initTime(BuildContext context) async { |
| 45 | userModel = Provider.of<UserModel>(context, listen: false); | 50 | userModel = Provider.of<UserModel>(context, listen: false); |
| @@ -103,21 +108,42 @@ class TableManagerModel with ChangeNotifier{ | @@ -103,21 +108,42 @@ class TableManagerModel with ChangeNotifier{ | ||
| 103 | //过了晚市 | 108 | //过了晚市 |
| 104 | currTimeIndex = 3; | 109 | currTimeIndex = 3; |
| 105 | } | 110 | } |
| 106 | - Map<String, String> params = {"sellerid": userModel.user.sellerid}; | ||
| 107 | - tableOuterList = await tableManagerModel.getTableList(context, params); | 111 | + await getTableList(context); |
| 108 | getReserveList(context); | 112 | getReserveList(context); |
| 109 | } | 113 | } |
| 110 | 114 | ||
| 111 | //获取桌位数据 | 115 | //获取桌位数据 |
| 112 | - Future<List<TableOuter>> getTableList(BuildContext context,Map<String,String> params) async { | 116 | + Future<List<TableOuter>> getTableList(BuildContext context) async { |
| 117 | + pageState = PageState.Loading; | ||
| 118 | + notifyListeners(); | ||
| 119 | + Map<String, String> params = {"sellerid": userModel.user.sellerid}; | ||
| 113 | BaseResp<List> baseResp = await DioUtil() | 120 | BaseResp<List> baseResp = await DioUtil() |
| 114 | .request<List>(context, Method.get, HttpUrl.table_list, | 121 | .request<List>(context, Method.get, HttpUrl.table_list, |
| 115 | - data: params,showLoading: true) | 122 | + data: params,showLoading: false) |
| 116 | .catchError((error) { | 123 | .catchError((error) { |
| 117 | print(error.toString()); | 124 | print(error.toString()); |
| 125 | + if (error is MyError) { | ||
| 126 | + switch (error.type) { | ||
| 127 | + case 1: | ||
| 128 | + pageState = PageState.ConnectivityError; | ||
| 129 | + break; | ||
| 130 | + case 2: | ||
| 131 | + pageState = PageState.ConnectivityTimeOut; | ||
| 132 | + break; | ||
| 133 | + default: | ||
| 134 | + pageState = PageState.ConnectivityError; | ||
| 135 | + break; | ||
| 136 | + } | ||
| 137 | + } | ||
| 138 | + notifyListeners(); | ||
| 118 | }); | 139 | }); |
| 140 | + tableOuterList=[]; | ||
| 119 | if(baseResp.code==Constant.status_success){ | 141 | if(baseResp.code==Constant.status_success){ |
| 120 | - return (baseResp.data[0] as List).map((value){ | 142 | + if ((baseResp.data[0] as List).isEmpty) { |
| 143 | + pageState = PageState.Empty; | ||
| 144 | + notifyListeners(); | ||
| 145 | + } | ||
| 146 | + tableOuterList=(baseResp.data[0] as List).map((value){ | ||
| 121 | TableOuter tableOuter=TableOuter(); | 147 | TableOuter tableOuter=TableOuter(); |
| 122 | tableOuter.name=value["name"]; | 148 | tableOuter.name=value["name"]; |
| 123 | tableOuter.list=(value["list"] as List).map((table){ | 149 | tableOuter.list=(value["list"] as List).map((table){ |
| @@ -126,11 +152,12 @@ class TableManagerModel with ChangeNotifier{ | @@ -126,11 +152,12 @@ class TableManagerModel with ChangeNotifier{ | ||
| 126 | return tableOuter; | 152 | return tableOuter; |
| 127 | }).toList(); | 153 | }).toList(); |
| 128 | } | 154 | } |
| 129 | - return []; | 155 | + return tableOuterList; |
| 130 | } | 156 | } |
| 131 | 157 | ||
| 132 | //获取已预订列表 | 158 | //获取已预订列表 |
| 133 | getReserveList(BuildContext context) async { | 159 | getReserveList(BuildContext context) async { |
| 160 | + tableMap.clear(); | ||
| 134 | NoteBookModel model = new NoteBookModel(); | 161 | NoteBookModel model = new NoteBookModel(); |
| 135 | Map<String, String> params = { | 162 | Map<String, String> params = { |
| 136 | "sid": userModel.user.sellerid, | 163 | "sid": userModel.user.sellerid, |
| @@ -141,6 +168,8 @@ class TableManagerModel with ChangeNotifier{ | @@ -141,6 +168,8 @@ class TableManagerModel with ChangeNotifier{ | ||
| 141 | "keywords": "", | 168 | "keywords": "", |
| 142 | "sort": "1" | 169 | "sort": "1" |
| 143 | }; | 170 | }; |
| 171 | + pageState = PageState.Loading; | ||
| 172 | + notifyListeners(); | ||
| 144 | List<Notebook> noteBooks = await model.getReserveList(context, params); | 173 | List<Notebook> noteBooks = await model.getReserveList(context, params); |
| 145 | for (Notebook notebook in noteBooks) { | 174 | for (Notebook notebook in noteBooks) { |
| 146 | if (notebook.tid.isEmpty) continue; | 175 | if (notebook.tid.isEmpty) continue; |
| @@ -214,8 +243,9 @@ class TableManagerModel with ChangeNotifier{ | @@ -214,8 +243,9 @@ class TableManagerModel with ChangeNotifier{ | ||
| 214 | areas.add(area); | 243 | areas.add(area); |
| 215 | } | 244 | } |
| 216 | currentArea = areaTableMap.keys.first; | 245 | currentArea = areaTableMap.keys.first; |
| 217 | - currentTables=areaTableMap[tableManagerModel.currentArea]; | ||
| 218 | - notifyListeners(); | 246 | + currentTables=areaTableMap[currentArea]; |
| 247 | + pageState = PageState.Success; | ||
| 248 | + notifyListeners();; | ||
| 219 | } | 249 | } |
| 220 | 250 | ||
| 221 | //生成日期文本 | 251 | //生成日期文本 |
| @@ -242,7 +272,7 @@ class TableManagerModel with ChangeNotifier{ | @@ -242,7 +272,7 @@ class TableManagerModel with ChangeNotifier{ | ||
| 242 | //获取桌位数据 | 272 | //获取桌位数据 |
| 243 | Future<dynamic> setSwitchStatus(BuildContext context,Map<String,String> params) async { | 273 | Future<dynamic> setSwitchStatus(BuildContext context,Map<String,String> params) async { |
| 244 | BaseResp<dynamic> baseResp = await DioUtil() | 274 | BaseResp<dynamic> baseResp = await DioUtil() |
| 245 | - .request<List>(context, Method.get, HttpUrl.set_switch_status, | 275 | + .request<dynamic>(context, Method.get, HttpUrl.set_switch_status, |
| 246 | data: params,showLoading: true) | 276 | data: params,showLoading: true) |
| 247 | .catchError((error) { | 277 | .catchError((error) { |
| 248 | print(error.toString()); | 278 | print(error.toString()); |
| @@ -228,13 +228,12 @@ class TableItemState extends State<TableItem> { | @@ -228,13 +228,12 @@ class TableItemState extends State<TableItem> { | ||
| 228 | Positioned( | 228 | Positioned( |
| 229 | top: 3, | 229 | top: 3, |
| 230 | right: 5, | 230 | right: 5, |
| 231 | - child: !(table.selected ?? false) | ||
| 232 | - ? Container() | ||
| 233 | - : Image.asset( | ||
| 234 | - "assets/icon_selected.png", | ||
| 235 | - width: ScreenUtil().setWidth(40), | ||
| 236 | - height: ScreenUtil().setWidth(40), | ||
| 237 | - )) | 231 | + child: widget.canSelected&&(table.selected ?? false) |
| 232 | + ? Image.asset( | ||
| 233 | + "assets/icon_selected.png", | ||
| 234 | + width: ScreenUtil().setWidth(40), | ||
| 235 | + height: ScreenUtil().setWidth(40), | ||
| 236 | + ):Container()) | ||
| 238 | ], | 237 | ], |
| 239 | ), | 238 | ), |
| 240 | ); | 239 | ); |
-
Please register or login to post a comment