diff --git a/lib/constants/api.dart b/lib/constants/api.dart index 57cea225..9c20a711 100644 --- a/lib/constants/api.dart +++ b/lib/constants/api.dart @@ -297,6 +297,9 @@ class _Manager { ///app新版家政服务:取消服务 String get housekeepingCancel => '/user/housekeepingService/cancel'; + + ///app新版家政服务:评价 + String get houseKeepingEvaluation => '/user/housekeepingService/evaluation'; } class _Community { @@ -417,6 +420,10 @@ class _Upload { ///家政服务上传提交照片 String get uploadHouseKeepingPhotos => '/user/upload/uploadAppHousekeepingServiceSubmitPhone'; + + ///家政服务上传评价照片 + String get uploadHouseKeepingEvaluationPhotos => + '/user/upload/uploadAppHousekeepingServiceEvaluationPhone'; } class _Message { diff --git a/lib/models/house_keeping/house_keeping_list_model.dart b/lib/models/house_keeping/house_keeping_list_model.dart index a09e9f61..3aa20d81 100644 --- a/lib/models/house_keeping/house_keeping_list_model.dart +++ b/lib/models/house_keeping/house_keeping_list_model.dart @@ -17,8 +17,8 @@ class HouseKeepingListModel extends Equatable { final int status; final int? completion; final String? processDescription; - final String handlerName; - final String handlerTel; + final String? handlerName; + final String? handlerTel; final String? handlingTime; final List handlerImgList; final double? payFee; @@ -38,8 +38,8 @@ class HouseKeepingListModel extends Equatable { required this.status, this.completion, this.processDescription, - required this.handlerName, - required this.handlerTel, + this.handlerName, + this.handlerTel, this.handlingTime, required this.handlerImgList, this.payFee, diff --git a/lib/models/house_keeping/house_keeping_list_model.g.dart b/lib/models/house_keeping/house_keeping_list_model.g.dart index 6d1604cf..9e2a5c71 100644 --- a/lib/models/house_keeping/house_keeping_list_model.g.dart +++ b/lib/models/house_keeping/house_keeping_list_model.g.dart @@ -18,8 +18,8 @@ HouseKeepingListModel _$HouseKeepingListModelFromJson( status: json['status'] as int, completion: json['completion'] as int?, processDescription: json['processDescription'] as String?, - handlerName: json['handlerName'] as String, - handlerTel: json['handlerTel'] as String, + handlerName: json['handlerName'] as String?, + handlerTel: json['handlerTel'] as String?, handlingTime: json['handlingTime'] as String?, handlerImgList: (json['handlerImgList'] as List) .map((e) => ImgModel.fromJson(e as Map)) diff --git a/lib/ui/manager/house_keeping/evaluate_page.dart b/lib/ui/manager/house_keeping/evaluate_page.dart index 7a56fe90..99e449cf 100644 --- a/lib/ui/manager/house_keeping/evaluate_page.dart +++ b/lib/ui/manager/house_keeping/evaluate_page.dart @@ -1,5 +1,8 @@ import 'dart:io'; +import 'package:aku_community/ui/manager/house_keeping/house_keeping_func.dart'; +import 'package:aku_community/widget/buttons/bottom_button.dart'; +import 'package:bot_toast/bot_toast.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; @@ -9,9 +12,12 @@ import 'package:aku_community/base/base_style.dart'; import 'package:aku_community/utils/headers.dart'; import 'package:aku_community/widget/bee_scaffold.dart'; import 'package:aku_community/widget/picker/grid_image_picker.dart'; +import 'package:get/get.dart'; +import 'package:power_logger/power_logger.dart'; class EvaluatePage extends StatefulWidget { - EvaluatePage({Key? key}) : super(key: key); + final int id; + EvaluatePage({Key? key, required this.id}) : super(key: key); @override _EvaluatePageState createState() => _EvaluatePageState(); @@ -106,6 +112,24 @@ class _EvaluatePageState extends State { }), ], ), + bottomNavi: BottomButton( + onPressed: () async { + Function cancel = BotToast.showLoading(); + List _urls = []; + try { + _urls = await HouseKeepingFunc.uploadHouseKeepingEvaluationPhotos( + _files); + bool result = await HouseKeepingFunc.houseKeepingEvaluation( + widget.id, _rating, _textEditingController.text, _urls); + if (result) { + Get.back(); + } + } catch (e) { + LoggerData.addData(e); + } + cancel(); + }, + child: '提交'.text.size(32.sp).black.bold.make()), ); } } diff --git a/lib/ui/manager/house_keeping/house_keeping_detail_page.dart b/lib/ui/manager/house_keeping/house_keeping_detail_page.dart index 844a5a15..06f90640 100644 --- a/lib/ui/manager/house_keeping/house_keeping_detail_page.dart +++ b/lib/ui/manager/house_keeping/house_keeping_detail_page.dart @@ -42,15 +42,14 @@ class _HouseKeepingDetailPageState extends State { 16.w.heightBox, _buildProcess(), 16.w.heightBox, - Offstage( - offstage: widget.model.handlingTime == null, - child: Column( + if (widget.model.handlingTime != null) + Column( children: [ 16.w.heightBox, _serviceFeedBack(), ], ), - ), + Container( padding: EdgeInsets.symmetric(horizontal: 24.w, vertical: 24.w), color: Colors.white, @@ -66,15 +65,14 @@ class _HouseKeepingDetailPageState extends State { ], ), ), - Offstage( - offstage: widget.model.evaluationTime == null, - child: Column( + if (widget.model.evaluationTime != null) + Column( children: [ 16.w.heightBox, _buildEvaluate(), ], ), - ), + // 40.w.heightBox, // _background(), ], @@ -93,7 +91,9 @@ class _HouseKeepingDetailPageState extends State { case 5: return BottomButton( onPressed: () { - Get.to(() => EvaluatePage()); + Get.to(() => EvaluatePage( + id: widget.model.id, + )); }, child: '立即评价'.text.size(28.sp).bold.black.make()); default: @@ -265,7 +265,7 @@ class _HouseKeepingDetailPageState extends State { 8.w.widthBox, '维修人'.text.size(28.sp).color(ktextSubColor).make(), Spacer(), - widget.model.handlerName.text.size(28.sp).black.make(), + widget.model.handlerName!.text.size(28.sp).black.make(), ], ), 16.w.heightBox, @@ -279,7 +279,7 @@ class _HouseKeepingDetailPageState extends State { 8.w.widthBox, '联系电话'.text.size(28.sp).color(ktextSubColor).make(), Spacer(), - widget.model.handlerTel.text.size(28.sp).black.make(), + widget.model.handlerTel!.text.size(28.sp).black.make(), ], ), 16.w.heightBox, @@ -300,92 +300,4 @@ class _HouseKeepingDetailPageState extends State { ), ); } - - // int _airPlane = 1; - // int _train = 2; - // int _xxx = 3; - // int _select = 1; - - // Widget _background() { - // return Center( - // child: Container( - // width: 600.w, - // height: 600.w, - // decoration: BoxDecoration( - // color: Colors.transparent, - // borderRadius: BorderRadius.circular(16.w)), - // child: Column( - // children: [ - // Row( - // children: [ - // _header( - // _airPlane, - // _select, - // 'aaa', - // 'left' - // ).expand(), - // _header(_train, _select, 'bbb', 'mid').expand(), - // _header(_xxx, _select, 'ccc', 'right').expand(), - // ], - // ), - // Container( - // width: double.infinity, - // alignment: Alignment.center, - // child: 'xxxxxxxx'.text.size(36.sp).black.make(), - // color: Colors.white, - // ).expand(), - // ], - // ), - // ), - // ); - // } - - // Widget _header(int value, int selectValue, String title, String position) { - // bool isSelect = value == selectValue; - // return Column( - // children: [ - // isSelect - // ? Container( - // height: 40.w, - // decoration: BoxDecoration( - // color: Colors.white, - // borderRadius: BorderRadius.only( - // topLeft: position == 'left' - // ? Radius.zero - // : Radius.circular(20.w), - // topRight: position == 'right' - // ? Radius.zero - // : Radius.circular(20.w))), - // ) - // : Container(height: 40.w, color: Colors.transparent), - // isSelect - // ? Container( - // height: 120.w, - // alignment: Alignment.center, - // width: double.infinity, - // child: title.text.size(32.sp).red500.make(), - // color: Colors.white, - // ) - // : GestureDetector( - // onTap: () { - // _select = value; - // setState(() {}); - // }, - // child: Container( - // height: 120.w, - // width: double.infinity, - // alignment: Alignment.center, - // child: title.text.size(30.sp).black.make(), - // decoration: BoxDecoration( - // color: Colors.pinkAccent, - // borderRadius: BorderRadius.only( - // topLeft:!(position=='right')? Radius.circular(16.w):Radius.zero, - // topRight: !(position=='left')?Radius.circular(16.w):Radius.zero, - // bottomLeft: !(position=='left')?Radius.circular(16.w):Radius.zero, - // bottomRight:!(position=='right')?Radius.circular(16.w):Radius.zero)), - // ), - // ), - // ], - // ); - // } } diff --git a/lib/ui/manager/house_keeping/house_keeping_func.dart b/lib/ui/manager/house_keeping/house_keeping_func.dart index 4eb6c02d..f59002d8 100644 --- a/lib/ui/manager/house_keeping/house_keeping_func.dart +++ b/lib/ui/manager/house_keeping/house_keeping_func.dart @@ -1,3 +1,5 @@ +import 'dart:io'; + import 'package:bot_toast/bot_toast.dart'; import 'package:aku_community/constants/api.dart'; @@ -49,4 +51,30 @@ class HouseKeepingFunc { return false; } } + + ///上传家政服务评价照片 + static Future> uploadHouseKeepingEvaluationPhotos( + List files) async { + List urls = await NetUtil() + .uploadFiles(files, API.upload.uploadHouseKeepingEvaluationPhotos); + + if (urls.isNotEmpty) { + return urls; + } else { + return []; + } + } + + ///家政服务:评价 + static Future houseKeepingEvaluation(int id, int evaluation, + String evaluationContent, List imgs) async { + BaseModel baseModel = + await NetUtil().post(API.manager.houseKeepingEvaluation, params: { + "id": id, + "evaluation": evaluation, + "evaluationContent": evaluationContent, + " evaluationImgUrls": imgs, + }); + return baseModel.status ?? false; + } }