对接 服务进程,完善家政服务详情

hmxc
张萌 3 years ago
parent 215df782fa
commit d3673c653d

@ -286,6 +286,13 @@ class _Manager {
///app
String get submitHouseKeeping =>
'/user/housekeepingService/submitHousekeeping';
///appid
String get houseKeepingProcess =>
'/user/housekeepingService/findHousekeepingProcessRecord';
///app
String get housekeepingCancel => '/user/housekeepingService/cancel';
}
class _Community {

@ -96,6 +96,17 @@ class HouseKeepingListModel extends Equatable {
}
}
String get completionString {
switch (this.completion) {
case 1:
return '未完成';
case 2:
return '已完成';
default:
return '未知';
}
}
@override
List<Object?> get props {
return [

@ -0,0 +1,45 @@
import 'package:equatable/equatable.dart';
import 'package:json_annotation/json_annotation.dart';
part 'house_keeping_process_model.g.dart';
@JsonSerializable()
class HouseKeepingProcessModel extends Equatable {
final int id;
final int housekeepingServiceId;
final String operationDate;
final int operationType;
@JsonKey(name: 'operator')
final int opName;
final int operatorType;
final String operatorContent;
HouseKeepingProcessModel({
required this.id,
required this.housekeepingServiceId,
required this.operationDate,
required this.operationType,
required this.opName,
required this.operatorType,
required this.operatorContent,
});
factory HouseKeepingProcessModel.fromJson(Map<String, dynamic> json) =>
_$HouseKeepingProcessModelFromJson(json);
factory HouseKeepingProcessModel.fail() => HouseKeepingProcessModel(
id: -1,
housekeepingServiceId: -1,
operationDate: '',
opName: 0,
operationType: 0,
operatorContent: '',
operatorType: 1);
@override
List<Object> get props {
return [
id,
housekeepingServiceId,
operationDate,
operationType,
operatorType,
operatorContent,
];
}
}

@ -0,0 +1,20 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
part of 'house_keeping_process_model.dart';
// **************************************************************************
// JsonSerializableGenerator
// **************************************************************************
HouseKeepingProcessModel _$HouseKeepingProcessModelFromJson(
Map<String, dynamic> json) {
return HouseKeepingProcessModel(
id: json['id'] as int,
housekeepingServiceId: json['housekeepingServiceId'] as int,
operationDate: json['operationDate'] as String,
operationType: json['operationType'] as int,
opName: json['operator'] as int,
operatorType: json['operatorType'] as int,
operatorContent: json['operatorContent'] as String,
);
}

@ -2,10 +2,13 @@ import 'package:aku_community/base/base_style.dart';
import 'package:aku_community/const/resource.dart';
import 'package:aku_community/constants/api.dart';
import 'package:aku_community/models/house_keeping/house_keeping_list_model.dart';
import 'package:aku_community/models/house_keeping/house_keeping_process_model.dart';
import 'package:aku_community/ui/manager/house_keeping/house_keeping_detail_page.dart';
import 'package:aku_community/ui/manager/house_keeping/house_keeping_func.dart';
import 'package:aku_community/utils/headers.dart';
import 'package:aku_community/widget/buttons/card_bottom_button.dart';
import 'package:aku_community/widget/others/aku_chip_box.dart';
import 'package:bot_toast/bot_toast.dart';
import 'package:flustars/flustars.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
@ -14,7 +17,10 @@ import 'package:velocity_x/velocity_x.dart';
class HouseKeepingCard extends StatelessWidget {
final HouseKeepingListModel model;
const HouseKeepingCard({Key? key, required this.model}) : super(key: key);
final VoidCallback callRefresh;
const HouseKeepingCard(
{Key? key, required this.model, required this.callRefresh})
: super(key: key);
String get dateStart =>
DateUtil.formatDateStr(model.createDate, format: 'yyyy-MM-dd HH:mm:ss');
@ -22,11 +28,17 @@ class HouseKeepingCard extends StatelessWidget {
Widget build(BuildContext context) {
return GestureDetector(
onTap: () async {
Get.to(() => HouseKeepingDetailPage(model: model));
List<HouseKeepingProcessModel> processModels =
await HouseKeepingFunc.getHouseKeepingProcess(
model.id,
);
Get.to(() => HouseKeepingDetailPage(
model: model,
processModels: processModels,
));
},
child: Container(
padding: EdgeInsets.all(24.w),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisSize: MainAxisSize.min,
@ -131,17 +143,36 @@ class HouseKeepingCard extends StatelessWidget {
switch (model.status) {
case 1:
return [
CardBottomButton.white(onPressed: () async {}, text: ('取消服务')),
CardBottomButton.white(
onPressed: () async {
Function cancel = BotToast.showLoading();
await HouseKeepingFunc.cancelHouseKeepingProcess(model.id);
cancel();
callRefresh();
},
text: ('取消服务')),
];
case 2:
return [
CardBottomButton.white(onPressed: () async {}, text: ('取消服务')),
CardBottomButton.white(
onPressed: () async {
Function cancel = BotToast.showLoading();
await HouseKeepingFunc.cancelHouseKeepingProcess(model.id);
cancel();
callRefresh();
},
text: ('取消服务')),
];
case 3:
return [
CardBottomButton.white(
onPressed: () async {
Get.to(() => HouseKeepingDetailPage(model: model));
List<HouseKeepingProcessModel> processModels =
await HouseKeepingFunc.getHouseKeepingProcess(model.id);
Get.to(() => HouseKeepingDetailPage(
model: model,
processModels: processModels,
));
},
text: ('查看详情')),
];

@ -1,17 +1,25 @@
import 'package:aku_community/widget/bee_divider.dart';
import 'package:flustars/flustars.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_rating_bar/flutter_rating_bar.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:velocity_x/velocity_x.dart';
import 'package:aku_community/base/base_style.dart';
import 'package:aku_community/const/resource.dart';
import 'package:aku_community/models/house_keeping/house_keeping_list_model.dart';
import 'package:aku_community/models/house_keeping/house_keeping_process_model.dart';
import 'package:aku_community/utils/headers.dart';
import 'package:aku_community/widget/bee_scaffold.dart';
import 'package:aku_community/widget/views/bee_grid_image_view.dart';
import 'package:flustars/flustars.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:velocity_x/velocity_x.dart';
class HouseKeepingDetailPage extends StatefulWidget {
final HouseKeepingListModel model;
HouseKeepingDetailPage({Key? key, required this.model}) : super(key: key);
final List<HouseKeepingProcessModel> processModels;
HouseKeepingDetailPage(
{Key? key, required this.model, required this.processModels})
: super(key: key);
@override
_HouseKeepingDetailPageState createState() => _HouseKeepingDetailPageState();
@ -26,6 +34,42 @@ class _HouseKeepingDetailPageState extends State<HouseKeepingDetailPage> {
padding: EdgeInsets.symmetric(vertical: 24.w),
children: [
_buildInfo(),
16.w.heightBox,
_buildProcess(),
16.w.heightBox,
Offstage(
offstage: widget.model.handlingTime == null,
child: Column(
children: [
16.w.heightBox,
_serviceFeedBack(),
],
),
),
Container(
padding: EdgeInsets.symmetric(horizontal: 24.w, vertical: 24.w),
color: Colors.white,
child: Row(
children: [
'服务费用'.text.size(28.sp).black.make(),
Spacer(),
'¥ ${widget.model.payFee ?? 0}'
.text
.size(32.sp)
.color(Colors.red)
.make()
],
),
),
Offstage(
offstage: widget.model.evaluationTime == null,
child: Column(
children: [
16.w.heightBox,
_buildEvaluate(),
],
),
)
],
),
);
@ -80,9 +124,10 @@ class _HouseKeepingDetailPageState extends State<HouseKeepingDetailPage> {
);
}
Widget _buidProcess() {
Widget _buildProcess() {
return Container(
padding: EdgeInsets.symmetric(vertical: 24.w, horizontal: 24.w),
color: Colors.white,
width: double.infinity,
child: Column(
children: [
@ -91,20 +136,136 @@ class _HouseKeepingDetailPageState extends State<HouseKeepingDetailPage> {
'服务进程'.text.size(36.sp).bold.black.make(),
],
),
24.w.heightBox,
...widget.processModels
.map((e) => _buildProcessTile(e.operatorContent, e.operationDate))
.toList()
.sepWidget(separate: 24.w.heightBox)
],
),
);
}
Widget _buidProcessTile(String title, DateTime date) {
Widget _buildProcessTile(String content, String date) {
return Row(children: [
title.text.size(28.sp).color(ktextSubColor).make(),
content.text.size(28.sp).color(ktextSubColor).make(),
Spacer(),
'${DateUtil.formatDate(date, format: 'yyyy-MM-dd HH:mm:ss')}'
'${DateUtil.formatDateStr(date, format: 'yyyy-MM-dd HH:mm:ss')}'
.text
.size(28.sp)
.black
.make(),
]);
}
Widget _buildEvaluate() {
return Container(
width: double.infinity,
padding: EdgeInsets.symmetric(vertical: 24.w, horizontal: 24.w),
color: Colors.white,
child: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
'服务评价'.text.size(36.sp).bold.black.make(),
40.w.heightBox,
Row(
children: [
'综合评价'.text.size(28.sp).color(ktextSubColor).make(),
40.w.widthBox,
RatingBar(
ignoreGestures: true,
allowHalfRating: true,
itemPadding: EdgeInsets.symmetric(horizontal: 15.w),
itemSize: 32.w,
initialRating: (widget.model.evaluation ?? 0).toDouble(),
ratingWidget: RatingWidget(
empty: Icon(
CupertinoIcons.star,
),
full: Icon(
CupertinoIcons.star_fill,
color: kPrimaryColor,
),
half: Icon(
CupertinoIcons.star_lefthalf_fill,
color: kPrimaryColor,
)),
onRatingUpdate: (value) {})
],
),
40.w.heightBox,
BeeDivider.horizontal(),
40.w.heightBox,
(widget.model.evaluationContent ?? '')
.text
.size(28.sp)
.black
.softWrap(true)
.make(),
BeeGridImageView(urls: [])
],
),
);
}
Widget _serviceFeedBack() {
return Container(
width: double.infinity,
color: Colors.white,
padding: EdgeInsets.symmetric(vertical: 24.w, horizontal: 24.w),
child: Column(
children: [
'服务反馈'.text.size(36.sp).bold.black.make(),
40.w.heightBox,
Row(
children: [
'完成情况'.text.size(28.sp).color(ktextSubColor).make(),
Spacer(),
widget.model.completionString.text.size(32.sp).black.make()
],
),
40.w.heightBox,
Row(
children: [
Image.asset(
R.ASSETS_IMAGES_PLACEHOLDER_WEBP,
width: 40.w,
height: 40.w,
),
8.w.widthBox,
'维修人'.text.size(28.sp).color(ktextSubColor).make(),
Spacer(),
widget.model.proposerName.text.size(28.sp).black.make(),
],
),
16.w.heightBox,
Row(
children: [
Image.asset(
R.ASSETS_IMAGES_PLACEHOLDER_WEBP,
width: 40.w,
height: 40.w,
),
8.w.widthBox,
'联系电话'.text.size(28.sp).color(ktextSubColor).make(),
Spacer(),
widget.model.proposerTel.text.size(28.sp).black.make(),
],
),
16.w.heightBox,
40.w.heightBox,
'处理描述'.text.size(28.sp).color(ktextSubColor).make(),
24.w.heightBox,
(widget.model.processDescription ?? '')
.text
.size(2)
.black
.softWrap(true)
.make(),
BeeGridImageView(urls: [])
],
),
);
}
}

@ -1,20 +1,51 @@
import 'package:aku_community/constants/api.dart';
import 'package:aku_community/models/house_keeping/house_keeping_process_model.dart';
import 'package:aku_community/utils/network/base_model.dart';
import 'package:aku_community/utils/network/net_util.dart';
import 'package:bot_toast/bot_toast.dart';
class HouseKeepingFunc {
///
static Future submitHouseKeeping(
int estateId,
int type,
String content,
List<String> urls
) async {
int estateId, int type, String content, List<String> urls) async {
BaseModel baseModel = await NetUtil().post(API.manager.submitHouseKeeping,
params: {"estateId": estateId, "type": type, "content": content,"submitImgUrls":urls});
params: {
"estateId": estateId,
"type": type,
"content": content,
"submitImgUrls": urls
});
if (baseModel.status ?? false) {
return true;
} else {
return false;
}
}
///
static Future getHouseKeepingProcess(int id) async {
BaseModel baseModel = await NetUtil().get(API.manager.houseKeepingProcess,
params: {"housekeepingServiceId": id});
if (baseModel.status ?? false) {
return (baseModel.data as List)
.map((e) => HouseKeepingProcessModel.fromJson(e))
.toList();
} else {
return [];
}
}
///
static Future cancelHouseKeepingProcess(int id) async {
BaseModel baseModel =
await NetUtil().get(API.manager.housekeepingCancel, params: {
"housekeepingServiceId": id,
});
if (baseModel.status ?? false) {
BotToast.showText(text: '取消成功');
return true;
} else {
return false;
}
}
}

@ -48,7 +48,12 @@ class _HouseKeepingViewState extends State<HouseKeepingView>
return ListView.separated(
padding: EdgeInsets.symmetric(horizontal: 24.w),
itemBuilder: (context, index) {
return HouseKeepingCard(model: items[index]);
return HouseKeepingCard(
model: items[index],
callRefresh: () {
_controller.callRefresh();
},
);
},
separatorBuilder: (_, __) {
return 24.w.heightBox;
@ -56,6 +61,7 @@ class _HouseKeepingViewState extends State<HouseKeepingView>
itemCount: items.length);
});
}
@override
bool get wantKeepAlive => true;
}

Loading…
Cancel
Save