From 855fd859ccd2d6a890d373f6fcb18af00adda65b Mon Sep 17 00:00:00 2001 From: zhang <494089941@qq.com> Date: Tue, 26 Jan 2021 11:19:07 +0800 Subject: [PATCH] update fixed detail page --- lib/constants/api.dart | 3 + lib/pages/manager_func.dart | 8 +++ .../things_page/widget/fixed_detail_page.dart | 72 ++++++++++++++++++- 3 files changed, 80 insertions(+), 3 deletions(-) diff --git a/lib/constants/api.dart b/lib/constants/api.dart index 3f11be11..cb4ebce6 100644 --- a/lib/constants/api.dart +++ b/lib/constants/api.dart @@ -108,6 +108,9 @@ class _Manager { ///删除建议 String get deleteAdvice => '/user/advice/falseDelete'; + + ///报事报修:取消订单 + String get reportRepairCancel => 'user/reportRepair/cancel'; } class _Upload { diff --git a/lib/pages/manager_func.dart b/lib/pages/manager_func.dart index 5f471328..0e94b2df 100644 --- a/lib/pages/manager_func.dart +++ b/lib/pages/manager_func.dart @@ -58,4 +58,12 @@ class ManagerFunc { ); return FixedDetailModel.fromJson(response.data); } + + static Future reportRepairCancel(int id) async { + BaseModel baseModel = await NetUtil().get(API.manager.reportRepairCancel, + params: { + 'repairId': id, + }, + showMessage: true); + } } diff --git a/lib/pages/things_page/widget/fixed_detail_page.dart b/lib/pages/things_page/widget/fixed_detail_page.dart index bd035c3d..b61dc89c 100644 --- a/lib/pages/things_page/widget/fixed_detail_page.dart +++ b/lib/pages/things_page/widget/fixed_detail_page.dart @@ -1,9 +1,12 @@ // Flutter imports: +import 'package:bot_toast/bot_toast.dart'; +import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; // Package imports: import 'package:flutter_easyrefresh/easy_refresh.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; +import 'package:get/get.dart'; import 'package:velocity_x/velocity_x.dart'; // Project imports: @@ -28,6 +31,12 @@ class FixedDetailPage extends StatefulWidget { _FixedDetailPageState createState() => _FixedDetailPageState(); } +class CancelModel { + bool cancel; + String message; + CancelModel(this.cancel, this.message); +} + class _FixedDetailPageState extends State { bool _onLoading = true; EasyRefreshController _easyRefreshController; @@ -226,9 +235,40 @@ class _FixedDetailPageState extends State { child: Row( children: [ MaterialButton( + height: double.infinity, padding: EdgeInsets.zero, materialTapTargetSize: MaterialTapTargetSize.shrinkWrap, - onPressed: () {}, + onPressed: () async { + CancelModel _cancel = + _allowCancel(_model.appReportRepairVo.status); + if (_cancel.cancel) { + BotToast.showLoading(); + await ManagerFunc.reportRepairCancel( + _model.appReportRepairVo.id); + BotToast.closeAllLoading(); + Get.back(); + } else { + Get.dialog( + CupertinoAlertDialog( + title: _cancel.message.text.black + .size(30.sp) + .isIntrinsic + .make(), + actions: [ + CupertinoDialogAction( + child: '我知道了' + .text + .color(kDarkPrimaryColor) + .size(36.sp) + .isIntrinsic + .make(), + onPressed: () => Get.back(), + ) + ], + ), + ); + } + }, textColor: ktextPrimary, disabledColor: kDarkSubColor.withOpacity(0.1), disabledTextColor: ktextSubColor.withOpacity(0.3), @@ -250,7 +290,9 @@ class _FixedDetailPageState extends State { hoverElevation: 0, disabledElevation: 0, ).expand(), + BeeDivider.vertical(), MaterialButton( + height: double.infinity, padding: EdgeInsets.zero, materialTapTargetSize: MaterialTapTargetSize.shrinkWrap, onPressed: showProcessCard ? () {} : null, @@ -264,7 +306,9 @@ class _FixedDetailPageState extends State { R.ASSETS_ICONS_MANAGER_PHONE_CALL_PNG, width: 40.w, height: 40.w, - color: showProcessCard?Colors.black:kDarkSubColor.withOpacity(0.5), + color: showProcessCard + ? Colors.black + : kDarkSubColor.withOpacity(0.5), ), 16.w.widthBox, '致电管家'.text.size(28.sp).bold.make() @@ -276,6 +320,7 @@ class _FixedDetailPageState extends State { hoverElevation: 0, disabledElevation: 0, ).expand(), + BeeDivider.vertical(), MaterialButton( height: 96.w, padding: EdgeInsets.zero, @@ -291,7 +336,9 @@ class _FixedDetailPageState extends State { R.ASSETS_ICONS_MANAGER_PHONE_CALL_PNG, width: 40.w, height: 40.w, - color: showRepairCard?Colors.black:kDarkSubColor.withOpacity(0.5), + color: showRepairCard + ? Colors.black + : kDarkSubColor.withOpacity(0.5), ), 16.w.widthBox, '致电师傅'.text.size(28.sp).bold.make() @@ -308,6 +355,25 @@ class _FixedDetailPageState extends State { ); } + CancelModel _allowCancel(int state) { + switch (state) { + case 1: + case 2: + return CancelModel(true, ''); + case 3: + return CancelModel(false, '订单处理中,当前无法取消订单'); + case 4: + case 5: + return CancelModel(false, '处理已完成,当前无法取消订单'); + case 6: + return CancelModel(false, '处理已关闭,当前无法取消订单'); + case 7: + return CancelModel(false, '处理已作废,当前无法取消订单'); + default: + return CancelModel(false, '未知错误'); + } + } + @override Widget build(BuildContext context) { return BeeScaffold(