From 90429642c26efbc2644c0f7af4e017e590de09cd Mon Sep 17 00:00:00 2001 From: zhangmeng <494089941@qq.com> Date: Mon, 14 Mar 2022 13:28:11 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E4=BB=BB=E5=8A=A1=E5=8F=91?= =?UTF-8?q?=E5=B8=83=E5=8F=96=E6=B6=88=E5=BC=B9=E7=AA=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/models/task/my_take_task_list_model.dart | 7 +- .../task/my_take_task_list_model.g.dart | 2 + lib/models/task/my_task_list_model.dart | 6 + lib/models/task/my_task_list_model.g.dart | 2 + lib/pages/home/home_page.dart | 2 +- .../service/dialogs/task_cancel_dialog.dart | 90 ++++++ .../dialogs/task_evaluation_dialog.dart | 27 +- lib/ui/service/hall/hall_detail_page.dart | 4 +- .../my_take_task_detail_page.dart | 247 +++++++++++++--- .../service/my_task/my_task_detail_page.dart | 278 +++++++++++++++--- lib/ui/service/task_map.dart | 12 - 11 files changed, 560 insertions(+), 117 deletions(-) create mode 100644 lib/ui/service/dialogs/task_cancel_dialog.dart diff --git a/lib/models/task/my_take_task_list_model.dart b/lib/models/task/my_take_task_list_model.dart index 5fdf1daf..bdecdd59 100644 --- a/lib/models/task/my_take_task_list_model.dart +++ b/lib/models/task/my_take_task_list_model.dart @@ -1,4 +1,5 @@ import 'package:aku_new_community/model/common/img_model.dart'; +import 'package:common_utils/common_utils.dart'; import 'package:json_annotation/json_annotation.dart'; part 'my_take_task_list_model.g.dart'; @@ -21,10 +22,12 @@ class MyTakeTaskListModel { final List? imgList; final int rewardType; final int reward; + final int createId; + final String createDate; factory MyTakeTaskListModel.fromJson(Map json) => _$MyTakeTaskListModelFromJson(json); - + DateTime? get endTime => DateUtil.getDateTime(readyEndTime); const MyTakeTaskListModel({ required this.id, required this.code, @@ -42,5 +45,7 @@ class MyTakeTaskListModel { this.imgList, required this.rewardType, required this.reward, + required this.createId, + required this.createDate, }); } diff --git a/lib/models/task/my_take_task_list_model.g.dart b/lib/models/task/my_take_task_list_model.g.dart index a573a030..05b327db 100644 --- a/lib/models/task/my_take_task_list_model.g.dart +++ b/lib/models/task/my_take_task_list_model.g.dart @@ -26,4 +26,6 @@ MyTakeTaskListModel _$MyTakeTaskListModelFromJson(Map json) => .toList(), rewardType: json['rewardType'] as int, reward: json['reward'] as int, + createId: json['createId'] as int, + createDate: json['createDate'] as String, ); diff --git a/lib/models/task/my_task_list_model.dart b/lib/models/task/my_task_list_model.dart index 44563714..d3a6aedb 100644 --- a/lib/models/task/my_task_list_model.dart +++ b/lib/models/task/my_task_list_model.dart @@ -1,4 +1,5 @@ import 'package:aku_new_community/model/common/img_model.dart'; +import 'package:common_utils/common_utils.dart'; import 'package:json_annotation/json_annotation.dart'; part 'my_task_list_model.g.dart'; @@ -21,9 +22,12 @@ class MyTaskListModel { final List? imgList; final int rewardType; final int reward; + final int createId; + final String createDate; factory MyTaskListModel.fromJson(Map json) => _$MyTaskListModelFromJson(json); + DateTime? get endTime => DateUtil.getDateTime(readyEndTime); const MyTaskListModel({ required this.id, required this.code, @@ -41,5 +45,7 @@ class MyTaskListModel { this.imgList, required this.rewardType, required this.reward, + required this.createId, + required this.createDate, }); } diff --git a/lib/models/task/my_task_list_model.g.dart b/lib/models/task/my_task_list_model.g.dart index 8ca15d13..1e837cd1 100644 --- a/lib/models/task/my_task_list_model.g.dart +++ b/lib/models/task/my_task_list_model.g.dart @@ -26,4 +26,6 @@ MyTaskListModel _$MyTaskListModelFromJson(Map json) => .toList(), rewardType: json['rewardType'] as int, reward: json['reward'] as int, + createId: json['createId'] as int, + createDate: json['createDate'] as String, ); diff --git a/lib/pages/home/home_page.dart b/lib/pages/home/home_page.dart index e9ad7411..4deff9a7 100644 --- a/lib/pages/home/home_page.dart +++ b/lib/pages/home/home_page.dart @@ -218,7 +218,7 @@ class _HomePageState extends State mainAxisSize: MainAxisSize.min, children: [ head, - // HomeSwiper(), //要做点击事件 + HomeSwiper(), //要做点击事件 // SizedBox(height: 100.w), Container( padding: EdgeInsets.only(top: 24.w, bottom: 32.w), diff --git a/lib/ui/service/dialogs/task_cancel_dialog.dart b/lib/ui/service/dialogs/task_cancel_dialog.dart new file mode 100644 index 00000000..81638005 --- /dev/null +++ b/lib/ui/service/dialogs/task_cancel_dialog.dart @@ -0,0 +1,90 @@ +import 'package:aku_new_community/base/base_style.dart'; +import 'package:aku_new_community/extensions/num_ext.dart'; +import 'package:aku_new_community/gen/assets.gen.dart'; +import 'package:aku_new_community/ui/service/task_func.dart'; +import 'package:flutter/cupertino.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter_screenutil/flutter_screenutil.dart'; +import 'package:get/get.dart'; +import 'package:velocity_x/src/extensions/string_ext.dart'; + +class TaskCancelDialog extends StatefulWidget { + final int taskId; + + const TaskCancelDialog({Key? key, required this.taskId}) : super(key: key); + + @override + _TaskCancelDialogState createState() => _TaskCancelDialogState(); +} + +class _TaskCancelDialogState extends State { + @override + Widget build(BuildContext context) { + return Container( + width: double.infinity, + color: Colors.white, + padding: EdgeInsets.all(32.w), + child: Column( + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Assets.icons.cancelTask.image( + width: double.infinity, + height: 420.w, + ), + 64.hb, + '确定要取消任务吗?'.text.size(36.sp).black.bold.make(), + 24.hb, + '不再等等吗?马上就会有人来接单了!' + .text + .size(28.sp) + .color(Colors.black.withOpacity(0.45)) + .make(), + 80.hb, + Row( + children: [ + MaterialButton( + onPressed: () { + Get.back(); + }, + minWidth: 330.w, + height: 80.w, + elevation: 0, + color: Colors.white, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(40.w), + side: BorderSide(color: Colors.black.withOpacity(0.25)), + ), + child: Text( + '继续等待', + style: TextStyle( + fontSize: 28.sp, color: Colors.black.withOpacity(0.65)), + ), + ), + Spacer(), + MaterialButton( + onPressed: () async { + var re = await TaskFunc.cancel(taskId: widget.taskId); + if (re) { + Get.back(); + } + }, + minWidth: 330.w, + height: 80.w, + elevation: 0, + color: kPrimaryColor, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(40.w), + ), + child: Text( + '确认取消', + style: TextStyle( + fontSize: 28.sp, color: Colors.black.withOpacity(0.85)), + ), + ) + ], + ) + ], + ), + ); + } +} diff --git a/lib/ui/service/dialogs/task_evaluation_dialog.dart b/lib/ui/service/dialogs/task_evaluation_dialog.dart index 9026197d..98c9216d 100644 --- a/lib/ui/service/dialogs/task_evaluation_dialog.dart +++ b/lib/ui/service/dialogs/task_evaluation_dialog.dart @@ -1,13 +1,20 @@ import 'package:aku_new_community/base/base_style.dart'; import 'package:aku_new_community/extensions/num_ext.dart'; import 'package:aku_new_community/gen/assets.gen.dart'; +import 'package:bot_toast/bot_toast.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; +import 'package:get/get.dart'; import 'package:velocity_x/src/extensions/string_ext.dart'; +import '../task_func.dart'; + class TaskEvaluationDialog extends StatefulWidget { - const TaskEvaluationDialog({Key? key}) : super(key: key); + final int taskId; + + const TaskEvaluationDialog({Key? key, required this.taskId}) + : super(key: key); @override _TaskEvaluationDialogState createState() => _TaskEvaluationDialogState(); @@ -88,14 +95,26 @@ class _TaskEvaluationDialogState extends State { side: BorderSide(color: Colors.black.withOpacity(0.25)), ), child: Text( - '', + '暂不评价', style: TextStyle( fontSize: 28.sp, color: Colors.black.withOpacity(0.65)), ), ), Spacer(), MaterialButton( - onPressed: () {}, + onPressed: () async { + if (_currentIndex == null) { + BotToast.showText(text: '请选择评价满意度'); + return; + } + var re = await TaskFunc.evaluate( + taskId: widget.taskId, + star: _currentIndex!, + evaluation: _controller.text); + if (re) { + Get.back(); + } + }, minWidth: 330.w, height: 80.w, elevation: 0, @@ -104,7 +123,7 @@ class _TaskEvaluationDialogState extends State { borderRadius: BorderRadius.circular(40.w), ), child: Text( - '暂不评价', + '确认提交', style: TextStyle( fontSize: 28.sp, color: Colors.black.withOpacity(0.85)), ), diff --git a/lib/ui/service/hall/hall_detail_page.dart b/lib/ui/service/hall/hall_detail_page.dart index 5318e7de..105513a3 100644 --- a/lib/ui/service/hall/hall_detail_page.dart +++ b/lib/ui/service/hall/hall_detail_page.dart @@ -1,5 +1,6 @@ import 'package:aku_new_community/gen/assets.gen.dart'; import 'package:aku_new_community/models/task/hall_list_model.dart'; +import 'package:aku_new_community/ui/service/dialogs/task_cancel_dialog.dart'; import 'package:aku_new_community/ui/service/task_func.dart'; import 'package:aku_new_community/ui/service/task_map.dart'; import 'package:aku_new_community/widget/bee_divider.dart'; @@ -110,7 +111,8 @@ class _HallDetailPageState extends State { child: myself ? BeeLongButton.white( onPressed: () async { - var re = await TaskFunc.cancel(taskId: widget.model.id); + var re = await Get.bottomSheet( + TaskCancelDialog(taskId: widget.model.id)); if (re) { Get.back(); } diff --git a/lib/ui/service/my_take_task/my_take_task_detail_page.dart b/lib/ui/service/my_take_task/my_take_task_detail_page.dart index 8dcef8b4..4158a52d 100644 --- a/lib/ui/service/my_take_task/my_take_task_detail_page.dart +++ b/lib/ui/service/my_take_task/my_take_task_detail_page.dart @@ -1,13 +1,23 @@ +import 'package:aku_new_community/base/base_style.dart'; import 'package:aku_new_community/gen/assets.gen.dart'; import 'package:aku_new_community/models/task/my_take_task_list_model.dart'; +import 'package:aku_new_community/ui/service/dialogs/task_cancel_dialog.dart'; import 'package:aku_new_community/ui/service/task_map.dart'; import 'package:aku_new_community/widget/bee_divider.dart'; import 'package:aku_new_community/widget/bee_scaffold.dart'; +import 'package:aku_new_community/widget/buttons/bee_long_button.dart'; +import 'package:aku_new_community/widget/views/bee_grid_image_view.dart'; +import 'package:aku_new_community/widget/voice_player.dart'; +import 'package:bot_toast/bot_toast.dart'; import 'package:common_utils/common_utils.dart'; import 'package:flutter/material.dart'; +import 'package:flutter/services.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; +import 'package:get/get.dart'; import 'package:velocity_x/velocity_x.dart'; +import '../task_func.dart'; + class MyTakeTaskDetailPage extends StatefulWidget { final MyTakeTaskListModel model; @@ -18,6 +28,52 @@ class MyTakeTaskDetailPage extends StatefulWidget { } class _MyTakeTaskDetailPageState extends State { + String get detailStatusToString { + switch (widget.model.status) { + case 1: + return '待服务'; + case 2: + if (widget.model.endTime?.isBefore(DateTime.now()) ?? false) { + return '已超时(原预计${DateUtil.formatDate(widget.model.endTime, format: DateFormats.h_m)}'; + } else { + return '服务中'; + } + case 3: + return '等待用户确认'; + case 4: + return '已完成'; + case 5: + return '已评价'; + case 9: + return '已取消'; + default: + return ''; + } + } + + String get subStatusString { + switch (widget.model.status) { + case 1: + return '请与发布人确认后开始服务'; + case 2: + if (widget.model.endTime?.isBefore(DateTime.now()) ?? false) { + return '请及时提醒帮手完成任务'; + } else { + return '帮手正在为您服务中'; + } + case 3: + return '请注意及时确认帮手的工作内容'; + case 4: + return '欢迎对骑手及本次任务进行评价'; + case 5: + return '感谢信任与支持,欢迎再次光临'; + case 9: + return '请及时提醒帮手完成任务'; + default: + return ''; + } + } + @override Widget build(BuildContext context) { return BeeScaffold( @@ -34,7 +90,7 @@ class _MyTakeTaskDetailPageState extends State { gradient: LinearGradient( begin: Alignment.centerLeft, end: Alignment.centerRight, - colors: widget.model.status == 4 + colors: widget.model.status == 9 ? [ Colors.white, Color(0xFFADACAC), @@ -54,13 +110,13 @@ class _MyTakeTaskDetailPageState extends State { child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - '${TaskMap.detailStatusToString[widget.model.status]}' + '${detailStatusToString}' .text .size(40.sp) .color(Colors.black) .bold .make(), - '${TaskMap.subStatus[widget.model.status]}' + '${subStatusString}' .text .size(24.sp) .color(Colors.black.withOpacity(0.45)) @@ -69,28 +125,6 @@ class _MyTakeTaskDetailPageState extends State { ), ), Spacer(), - // Padding( - // padding: EdgeInsets.only(right: 32.w), - // child: MaterialButton( - // color: Colors.white, - // elevation: 0, - // shape: RoundedRectangleBorder( - // borderRadius: BorderRadius.circular(8.w), - // ), - // onPressed: () async { - // var re = await TaskFunc.cancel( - // taskId: widget.model.id); - // if (re) { - // Get.back(); - // } - // }, - // child: '取消订单' - // .text - // .size(24.sp) - // .color(Colors.black.withOpacity(0.65)) - // .make(), - // ), - // ) ], ), ], @@ -118,9 +152,94 @@ class _MyTakeTaskDetailPageState extends State { )), ], ), + bottomNavi: Container( + width: double.infinity, + color: Colors.white, + padding: EdgeInsets.all(32.w), + child: Row( + children: [ + MaterialButton( + onPressed: () async { + var re = await Get.bottomSheet( + TaskCancelDialog(taskId: widget.model.id)); + if (re) { + Get.back(); + } + }, + minWidth: 330.w, + height: 80.w, + elevation: 0, + color: Colors.white, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(40.w), + side: BorderSide(color: Colors.black.withOpacity(0.25)), + ), + child: Text( + '取消订单', + style: TextStyle( + fontSize: 28.sp, color: Colors.black.withOpacity(0.65)), + ), + ), + Spacer(), + buttonByStatus, + ], + ), + ), ); } + Widget get buttonByStatus { + switch (widget.model.status) { + case 1: + return MaterialButton( + onPressed: () async { + var re = await TaskFunc.start(taskId: widget.model.id); + if (re) { + Get.back(); + } + }, + minWidth: 330.w, + height: 80.w, + elevation: 0, + color: kPrimaryColor, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(40.w), + ), + child: Text( + '开始服务', + style: TextStyle( + fontSize: 28.sp, color: Colors.black.withOpacity(0.85)), + ), + ); + case 2: + return MaterialButton( + onPressed: () {}, + minWidth: 330.w, + height: 80.w, + elevation: 0, + color: kPrimaryColor, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(40.w), + ), + child: Text( + '完成任务', + style: TextStyle( + fontSize: 28.sp, color: Colors.black.withOpacity(0.85)), + ), + ); + case 3: + return BeeLongButton( + onPressed: () async {}, + text: '提醒用户', + ); + case 4: + case 5: + case 9: + default: + return SizedBox.shrink(); + } + } + Widget _taskInfo() { return Container( width: 686.w, @@ -148,13 +267,38 @@ class _MyTakeTaskDetailPageState extends State { .color(Colors.black.withOpacity(0.45)) .make(), Spacer(), - '${DateUtil.formatDateStr(widget.model.updateDate)}' + '${DateUtil.formatDateStr(widget.model.createDate)}' .text .size(24.sp) .color(Colors.black.withOpacity(0.45)) - .make() + .make(), + 64.w.widthBox, ], ), + 24.w.heightBox, + Row( + children: [ + '任务单号' + .text + .size(24.sp) + .color(Colors.black.withOpacity(0.45)) + .make(), + Spacer(), + '${widget.model.code}' + .text + .size(24.sp) + .color(Colors.black.withOpacity(0.45)) + .make(), + 24.w.widthBox, + GestureDetector( + onTap: () async { + await Clipboard.setData( + ClipboardData(text: widget.model.code)); + BotToast.showText(text: '已复制到粘贴板'); + }, + child: Assets.icons.copy.image(width: 40.w, height: 40.w)), + ], + ) ], ), ); @@ -171,21 +315,18 @@ class _MyTakeTaskDetailPageState extends State { color: Color(0xFFFFF7E6), borderRadius: BorderRadius.circular(8.w), ), - child: '#${TaskMap.typeToString[widget.model.type]}' + child: '#${TaskMap.taskType[widget.model.type]}' .text .size(28.sp) .color(Color(0xFFFA8C16)) .make(), ), Spacer(), - Assets.icons.intergral.image(width: 24.w, height: 24.w), - 8.w.widthBox, - '${widget.model.reward}'.text.size(32.sp).color(Colors.red).make() ], ); return Container( width: 686.w, - height: 500.w, + // height: 500.w, decoration: BoxDecoration( color: Colors.white, borderRadius: BorderRadius.circular(8.w), @@ -197,16 +338,19 @@ class _MyTakeTaskDetailPageState extends State { 34.w.heightBox, Row( children: [ - Assets.icons.clockCircle.image(width: 36.w, height: 36.w), + Assets.icons.watch.image(width: 40.w, height: 40.w), 24.w.widthBox, - '${DateUtil.formatDateStr(widget.model.readyEndTime)}' - .text - .size(24.sp) - .color(Colors.black.withOpacity(0.65)) + '${widget.model.serviceTime ?? '0'}' + .richText + .withTextSpanChildren([ + ' 分钟'.textSpan.size(28.sp).color(Colors.black).make(), + ]) + .size(28.sp) + .color(Color(0xFFFA8C16)) .make(), ], ), - 20.w.heightBox, + 24.w.heightBox, Row( children: [ Assets.icons.environment.image(width: 36.w, height: 36.w), @@ -228,16 +372,18 @@ class _MyTakeTaskDetailPageState extends State { child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - '#${TaskMap.typeToString[widget.model.type]}' - .text - .size(28.sp) - .color(Colors.black.withOpacity(0.85)) - .make(), - 16.w.heightBox, widget.model.remarks.text .size(28.sp) .color(Colors.black.withOpacity(0.65)) .make(), + 24.w.heightBox, + VoicePlayer( + url: widget.model.voiceUrl, + ), + 24.w.heightBox, + BeeGridImageView( + urls: + widget.model.imgList?.map((e) => e.url).toList() ?? []), ], ), ), @@ -254,11 +400,14 @@ class _MyTakeTaskDetailPageState extends State { .color(Colors.black.withOpacity(0.45)) .make(), Spacer(), - '¥${widget.model.reward}' - .text - .size(32.sp) - .color(Colors.red) - .make(), + widget.model.rewardType == 1 + ? Text( + '¥ ', + style: TextStyle(color: Colors.red, fontSize: 32.sp), + ) + : Assets.icons.intergral.image(width: 24.w, height: 24.w), + 8.w.widthBox, + '${widget.model.reward}'.text.size(32.sp).color(Colors.red).make() ], ), ], diff --git a/lib/ui/service/my_task/my_task_detail_page.dart b/lib/ui/service/my_task/my_task_detail_page.dart index f7993374..227b59f5 100644 --- a/lib/ui/service/my_task/my_task_detail_page.dart +++ b/lib/ui/service/my_task/my_task_detail_page.dart @@ -1,13 +1,24 @@ +import 'package:aku_new_community/base/base_style.dart'; import 'package:aku_new_community/gen/assets.gen.dart'; import 'package:aku_new_community/models/task/my_task_list_model.dart'; +import 'package:aku_new_community/ui/service/dialogs/task_cancel_dialog.dart'; +import 'package:aku_new_community/ui/service/dialogs/task_evaluation_dialog.dart'; import 'package:aku_new_community/ui/service/task_map.dart'; import 'package:aku_new_community/widget/bee_divider.dart'; import 'package:aku_new_community/widget/bee_scaffold.dart'; +import 'package:aku_new_community/widget/buttons/bee_long_button.dart'; +import 'package:aku_new_community/widget/views/bee_grid_image_view.dart'; +import 'package:aku_new_community/widget/voice_player.dart'; +import 'package:bot_toast/bot_toast.dart'; import 'package:common_utils/common_utils.dart'; import 'package:flutter/material.dart'; +import 'package:flutter/services.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; +import 'package:get/get.dart'; import 'package:velocity_x/velocity_x.dart'; +import '../task_func.dart'; + class MyTaskDetailPage extends StatefulWidget { final MyTaskListModel model; @@ -18,6 +29,52 @@ class MyTaskDetailPage extends StatefulWidget { } class _MyTaskDetailPageState extends State { + String get detailStatusToString { + switch (widget.model.status) { + case 1: + return '已发布'; + case 2: + if (widget.model.endTime?.isBefore(DateTime.now()) ?? false) { + return '已超时(原预计${DateUtil.formatDate(widget.model.endTime, format: DateFormats.h_m)}'; + } else { + return '服务中'; + } + case 3: + return '待确认'; + case 4: + return '已完成'; + case 5: + return '已评价'; + case 9: + return '已取消'; + default: + return ''; + } + } + + String get subStatusString { + switch (widget.model.status) { + case 1: + return '请与发布人确认后开始服务'; + case 2: + if (widget.model.endTime?.isBefore(DateTime.now()) ?? false) { + return '请及时提醒帮手完成任务'; + } else { + return '帮手正在为您服务中'; + } + case 3: + return '请注意及时确认帮手的工作内容'; + case 4: + return '欢迎对骑手及本次任务进行评价'; + case 5: + return '感谢信任与支持,欢迎再次光临'; + case 9: + return '请及时提醒帮手完成任务'; + default: + return ''; + } + } + @override Widget build(BuildContext context) { return BeeScaffold( @@ -34,7 +91,7 @@ class _MyTaskDetailPageState extends State { gradient: LinearGradient( begin: Alignment.centerLeft, end: Alignment.centerRight, - colors: widget.model.status == 4 + colors: widget.model.status == 9 ? [ Colors.white, Color(0xFFADACAC), @@ -54,13 +111,13 @@ class _MyTaskDetailPageState extends State { child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - '${TaskMap.detailStatusToString[widget.model.status]}' + '${detailStatusToString}' .text .size(40.sp) .color(Colors.black) .bold .make(), - '${TaskMap.subStatus[widget.model.status]}' + '${subStatusString}' .text .size(24.sp) .color(Colors.black.withOpacity(0.45)) @@ -69,28 +126,6 @@ class _MyTaskDetailPageState extends State { ), ), Spacer(), - // Padding( - // padding: EdgeInsets.only(right: 32.w), - // child: MaterialButton( - // color: Colors.white, - // elevation: 0, - // shape: RoundedRectangleBorder( - // borderRadius: BorderRadius.circular(8.w), - // ), - // onPressed: () async { - // var re = await TaskFunc.cancel( - // taskId: widget.model.id); - // if (re) { - // Get.back(); - // } - // }, - // child: '取消订单' - // .text - // .size(24.sp) - // .color(Colors.black.withOpacity(0.65)) - // .make(), - // ), - // ) ], ), ], @@ -118,9 +153,124 @@ class _MyTaskDetailPageState extends State { )), ], ), + bottomNavi: Container( + width: double.infinity, + color: Colors.white, + padding: EdgeInsets.all(32.w), + child: Row( + children: [ + Offstage( + offstage: widget.model.status > 3, + child: MaterialButton( + onPressed: () async { + var re = await Get.bottomSheet( + TaskCancelDialog(taskId: widget.model.id)); + if (re) { + Get.back(); + } + }, + minWidth: 330.w, + height: 80.w, + elevation: 0, + color: Colors.white, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(40.w), + side: BorderSide(color: Colors.black.withOpacity(0.25)), + ), + child: Text( + '取消订单', + style: TextStyle( + fontSize: 28.sp, color: Colors.black.withOpacity(0.65)), + ), + ), + ), + Spacer(), + buttonByStatus, + ], + ), + ), ); } + Widget get buttonByStatus { + switch (widget.model.status) { + case 1: + return MaterialButton( + onPressed: () async {}, + minWidth: 330.w, + height: 80.w, + elevation: 0, + color: kPrimaryColor, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(40.w), + ), + child: Text( + '修改任务', + style: TextStyle( + fontSize: 28.sp, color: Colors.black.withOpacity(0.85)), + ), + ); + case 2: + return MaterialButton( + onPressed: () {}, + minWidth: 330.w, + height: 80.w, + elevation: 0, + color: kPrimaryColor, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(40.w), + ), + child: Text( + '催促服务', + style: TextStyle( + fontSize: 28.sp, color: Colors.black.withOpacity(0.85)), + ), + ); + case 3: + return MaterialButton( + onPressed: () async { + var re = await TaskFunc.confirm(taskId: widget.model.id); + if (re) { + Get.back(); + } + }, + minWidth: 330.w, + height: 80.w, + elevation: 0, + color: kPrimaryColor, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(40.w), + ), + child: Text( + '确认完成', + style: TextStyle( + fontSize: 28.sp, color: Colors.black.withOpacity(0.85)), + ), + ); + case 4: + return BeeLongButton( + onPressed: () async { + var re = await Get.bottomSheet(TaskEvaluationDialog( + taskId: widget.model.id, + )); + }, + text: '点击评价', + ); + case 5: + return BeeLongButton.white( + onPressed: () async {}, + text: '再次发布', + ); + case 9: + return BeeLongButton.white( + onPressed: () async {}, + text: '再次发布', + ); + default: + return SizedBox.shrink(); + } + } + Widget _taskInfo() { return Container( width: 686.w, @@ -148,13 +298,38 @@ class _MyTaskDetailPageState extends State { .color(Colors.black.withOpacity(0.45)) .make(), Spacer(), - '${DateUtil.formatDateStr(widget.model.updateDate)}' + '${DateUtil.formatDateStr(widget.model.createDate)}' .text .size(24.sp) .color(Colors.black.withOpacity(0.45)) - .make() + .make(), + 64.w.widthBox, ], ), + 24.w.heightBox, + Row( + children: [ + '任务单号' + .text + .size(24.sp) + .color(Colors.black.withOpacity(0.45)) + .make(), + Spacer(), + '${widget.model.code}' + .text + .size(24.sp) + .color(Colors.black.withOpacity(0.45)) + .make(), + 24.w.widthBox, + GestureDetector( + onTap: () async { + await Clipboard.setData( + ClipboardData(text: widget.model.code)); + BotToast.showText(text: '已复制到粘贴板'); + }, + child: Assets.icons.copy.image(width: 40.w, height: 40.w)), + ], + ) ], ), ); @@ -171,21 +346,18 @@ class _MyTaskDetailPageState extends State { color: Color(0xFFFFF7E6), borderRadius: BorderRadius.circular(8.w), ), - child: '#${TaskMap.typeToString[widget.model.type]}' + child: '#${TaskMap.taskType[widget.model.type]}' .text .size(28.sp) .color(Color(0xFFFA8C16)) .make(), ), Spacer(), - Assets.icons.intergral.image(width: 24.w, height: 24.w), - 8.w.widthBox, - '${widget.model.reward}'.text.size(32.sp).color(Colors.red).make() ], ); return Container( width: 686.w, - height: 500.w, + // height: 500.w, decoration: BoxDecoration( color: Colors.white, borderRadius: BorderRadius.circular(8.w), @@ -197,16 +369,19 @@ class _MyTaskDetailPageState extends State { 34.w.heightBox, Row( children: [ - Assets.icons.clockCircle.image(width: 36.w, height: 36.w), + Assets.icons.watch.image(width: 40.w, height: 40.w), 24.w.widthBox, - '${DateUtil.formatDateStr(widget.model.readyEndTime)}' - .text - .size(24.sp) - .color(Colors.black.withOpacity(0.65)) + '${widget.model.serviceTime ?? '0'}' + .richText + .withTextSpanChildren([ + ' 分钟'.textSpan.size(28.sp).color(Colors.black).make(), + ]) + .size(28.sp) + .color(Color(0xFFFA8C16)) .make(), ], ), - 20.w.heightBox, + 24.w.heightBox, Row( children: [ Assets.icons.environment.image(width: 36.w, height: 36.w), @@ -228,16 +403,18 @@ class _MyTaskDetailPageState extends State { child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - '#${TaskMap.typeToString[widget.model.type]}' - .text - .size(28.sp) - .color(Colors.black.withOpacity(0.85)) - .make(), - 16.w.heightBox, widget.model.remarks.text .size(28.sp) .color(Colors.black.withOpacity(0.65)) .make(), + 24.w.heightBox, + VoicePlayer( + url: widget.model.voiceUrl, + ), + 24.w.heightBox, + BeeGridImageView( + urls: + widget.model.imgList?.map((e) => e.url).toList() ?? []), ], ), ), @@ -254,11 +431,14 @@ class _MyTaskDetailPageState extends State { .color(Colors.black.withOpacity(0.45)) .make(), Spacer(), - '¥${widget.model.reward}' - .text - .size(32.sp) - .color(Colors.red) - .make(), + widget.model.rewardType == 1 + ? Text( + '¥ ', + style: TextStyle(color: Colors.red, fontSize: 32.sp), + ) + : Assets.icons.intergral.image(width: 24.w, height: 24.w), + 8.w.widthBox, + '${widget.model.reward}'.text.size(32.sp).color(Colors.red).make() ], ), ], diff --git a/lib/ui/service/task_map.dart b/lib/ui/service/task_map.dart index d62e3790..f6d54ba4 100644 --- a/lib/ui/service/task_map.dart +++ b/lib/ui/service/task_map.dart @@ -18,17 +18,5 @@ class TaskMap { static Map serviceObject = {1: '住户', 2: '物业', 3: '不限'}; static Map rewardType = {1: '赏金', 2: '积分'}; - static Map detailStatusToString = { - 1: '已发布', - 2: '待处理', - 3: '已完成', - 4: '已取消' - }; - static Map subStatus = { - 1: '请耐心等待帮手领取任务', - 2: '帮手正在为您服务中', - 3: '帮手已完成任务', - 4: '该任务已取消' - }; }