修改我的订单详情信息

设施预约 所选时段已被预约时,弹窗跳转获取所有已被预约时间
hmxc
张萌 4 years ago
parent bf84640e91
commit 7bc3dc08e9

@ -248,6 +248,10 @@ class _Manager {
///appid
String get electronicCommercDetail =>
'/user/electronicCommerce/findElectronicCommerceById';
///
String get facilityOrderDateList =>
'/user/facilitiesAppointment/findFacilitiesAppointmentDate';
}
class _Community {

@ -0,0 +1,30 @@
import 'package:equatable/equatable.dart';
import 'package:flustars/flustars.dart';
import 'package:json_annotation/json_annotation.dart';
part 'facility_order_date_list_model.g.dart';
@JsonSerializable()
class FacilityOrderDateListModel extends Equatable {
final int id;
final String appointmentStartDate;
final String appointmentEndDate;
final String appointmentName;
FacilityOrderDateListModel({
required this.id,
required this.appointmentStartDate,
required this.appointmentEndDate,
required this.appointmentName,
});
factory FacilityOrderDateListModel.fromJson(Map<String, dynamic> json) =>
_$FacilityOrderDateListModelFromJson(json);
String get startDateString =>
DateUtil.formatDateStr(this.appointmentStartDate,
format: 'yyyy-MM-dd HH:mm');
String get endDateString => DateUtil.formatDateStr(this.appointmentEndDate,
format: 'yyyy-MM-dd HH:mm');
String get tiemSlot =>
'${this.startDateString}-${DateUtil.formatDateStr(this.appointmentEndDate, format: 'HH:mm')}';
@override
List<Object> get props =>
[id, appointmentStartDate, appointmentEndDate, appointmentName];
}

@ -0,0 +1,17 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
part of 'facility_order_date_list_model.dart';
// **************************************************************************
// JsonSerializableGenerator
// **************************************************************************
FacilityOrderDateListModel _$FacilityOrderDateListModelFromJson(
Map<String, dynamic> json) {
return FacilityOrderDateListModel(
id: json['id'] as int,
appointmentStartDate: json['appointmentStartDate'] as String,
appointmentEndDate: json['appointmentEndDate'] as String,
appointmentName: json['appointmentName'] as String,
);
}

@ -22,6 +22,17 @@ class MyOrderListModel extends Equatable {
final String levelOneCategory;
final String levelTwoCategory;
final int status;
final String? sendDate;
final String? sendDetail;
final String? arrivalDate;
final String? receivingDate;
final String? backDate;
final String? backReason;
final String? reason;
final int? score;
final String? evaluationDate;
final String? evaluationReason;
final String? createDate;
final String arrivalTime;
MyOrderListModel({
required this.id,
@ -37,15 +48,37 @@ class MyOrderListModel extends Equatable {
required this.levelOneCategory,
required this.levelTwoCategory,
required this.status,
this.sendDate,
this.sendDetail,
this.arrivalDate,
this.receivingDate,
this.backDate,
this.backReason,
this.reason,
this.score,
this.evaluationDate,
this.evaluationReason,
this.createDate,
required this.arrivalTime,
});
factory MyOrderListModel.fromJson(Map<String, dynamic> json) =>
_$MyOrderListModelFromJson(json);
String get arrivlaTimeString =>
DateUtil.formatDateStr(this.arrivalTime, format: 'yyyy-MM-dd HH:mm');
String get sendDateString =>
DateUtil.formatDateStr(this.sendDate ?? '', format: 'yyyy-MM-dd HH:mm');
String get arrivalDateString => DateUtil.formatDateStr(this.arrivalDate ?? '',
format: 'yyyy-MM-dd HH:mm');
String get receiveDateString =>
DateUtil.formatDateStr(this.receivingDate ?? '',
format: 'yyyy-MM-dd HH:mm');
String get backDateString =>
DateUtil.formatDateStr(this.backDate ?? '', format: 'yyyy-MM-dd HH:mm');
String get evaluateDateString =>
DateUtil.formatDateStr(this.evaluationDate ?? '',
format: 'yyyy-MM-dd HH:mm');
String get createDateString =>
DateUtil.formatDateStr(this.createDate ?? '', format: 'yyyy-MM-dd HH:mm');
String get statusString {
switch (this.status) {
case 1:
@ -110,6 +143,17 @@ class MyOrderListModel extends Equatable {
levelOneCategory,
levelTwoCategory,
status,
sendDate,
sendDetail,
arrivalDate,
receivingDate,
backDate,
backReason,
reason,
score,
evaluationDate,
evaluationReason,
createDate,
arrivalTime,
];
}

@ -23,6 +23,17 @@ MyOrderListModel _$MyOrderListModelFromJson(Map<String, dynamic> json) {
levelOneCategory: json['levelOneCategory'] as String,
levelTwoCategory: json['levelTwoCategory'] as String,
status: json['status'] as int,
sendDate: json['sendDate'] as String?,
sendDetail: json['sendDetail'] as String?,
arrivalDate: json['arrivalDate'] as String?,
receivingDate: json['receivingDate'] as String?,
backDate: json['backDate'] as String?,
backReason: json['backReason'] as String?,
reason: json['reason'] as String?,
score: json['score'] as int?,
evaluationDate: json['evaluationDate'] as String?,
evaluationReason: json['evaluationReason'] as String?,
createDate: json['createDate'] as String?,
arrivalTime: json['arrivalTime'] as String,
);
}

@ -38,7 +38,10 @@ class _FacilityAppointmentPageState extends State<FacilityAppointmentPage>
actions: [
IconButton(
icon: Icon(CupertinoIcons.add_circled),
onPressed: () => Get.to(() => PickFacilityPage()),
onPressed: () async{
await Get.to(() => PickFacilityPage());
childKey.currentState!.callRefresh();
},
),
],
appBarBottom: BeeTabBar(
@ -47,8 +50,11 @@ class _FacilityAppointmentPageState extends State<FacilityAppointmentPage>
),
body: TabBarView(
children: [
FacilityAppointmentView(type: FacilityAppointmentType.MY),
FacilityAppointmentView(type: FacilityAppointmentType.HISTORY),
FacilityAppointmentView(
type: FacilityAppointmentType.MY,
key: childKey,
),
FacilityAppointmentView(type: FacilityAppointmentType.HISTORY,),
],
controller: _tabController,
),

@ -1,3 +1,4 @@
import 'package:flutter/material.dart';
import 'package:flutter_easyrefresh/easy_refresh.dart';
@ -12,6 +13,7 @@ enum FacilityAppointmentType {
MY,
HISTORY,
}
GlobalKey<_FacilityAppointmentViewState> childKey = GlobalKey();
class FacilityAppointmentView extends StatefulWidget {
final FacilityAppointmentType type;
@ -39,6 +41,10 @@ class _FacilityAppointmentViewState extends State<FacilityAppointmentView> {
super.dispose();
}
void callRefresh() {
return _refreshController.callRefresh();
}
@override
Widget build(BuildContext context) {
return BeeListView(

@ -1,3 +1,4 @@
import 'package:aku_community/ui/community/facility/fcility_order_date_list_page.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
@ -92,11 +93,12 @@ class _FacilityPreorderPageState extends State<FacilityPreorderPage> {
materialTapTargetSize: MaterialTapTargetSize.shrinkWrap,
height: 120.w,
onPressed: () async {
DateTime _currentTime = DateTime.now();
DateTime? date = await BeeDatePicker.pick(
DateTime.now(),
_currentTime.add(Duration(minutes: 60)),
mode: CupertinoDatePickerMode.dateAndTime,
min: DateTime.now().subtract(Duration(seconds: 1)),
max: DateTime.now().add(Duration(days: 30)),
min: _currentTime.add(Duration(minutes: 30)),
max: _currentTime.add(Duration(days: 30)),
);
if (date != null) {
startDate = date;
@ -120,14 +122,17 @@ class _FacilityPreorderPageState extends State<FacilityPreorderPage> {
materialTapTargetSize: MaterialTapTargetSize.shrinkWrap,
height: 120.w,
onPressed: () async {
DateTime? date = await BeeDatePicker.pick(
startDate == null ? DateTime.now() : startDate!,
startDate == null
? DateTime.now().add(Duration(minutes: 90))
: startDate!.add(Duration(minutes: 30)),
min: startDate == null
? DateTime.now().subtract(Duration(seconds: 1))
: startDate!,
? DateTime.now().add(Duration(minutes: 60))
: startDate!.add(Duration(minutes: 30)),
max: startDate == null
? DateTime.now().add(Duration(days: 1))
: (startDate!).add(Duration(days: 1)),
? DateTime.now().add(Duration(days: 2))
: (startDate!).add(Duration(days: 2)),
mode: CupertinoDatePickerMode.dateAndTime,
);
if (date != null) {
@ -159,6 +164,7 @@ class _FacilityPreorderPageState extends State<FacilityPreorderPage> {
bottomNavi: BottomButton(
onPressed: canTap
? () async {
// if (dateDifferenceIsTrue) {
final cancel = BotToast.showLoading();
var model = await NetUtil().post(
API.manager.facility.add,
@ -168,14 +174,55 @@ class _FacilityPreorderPageState extends State<FacilityPreorderPage> {
'appointmentStartDate': NetUtil.getDate(startDate!),
'appointmentEndDate': NetUtil.getDate(endDate!),
},
showMessage: true,
);
cancel();
if (model.status == true) Get.back(result: true);
if (model.status == true) {
BotToast.showText(text: '预约成功');
Get.back(result: true);
} else if (model.message == '该时段已被预约') {
Get.dialog(_hasBeenOrder());
} else {
BotToast.showText(text: '预约失败');
}
// } else {
// BotToast.showText(text: '预约时间必须为半小时的整数倍');
// }
}
: null,
child: Text('确认提交'),
),
);
}
bool get dateDifferenceIsTrue {
if (startDate != null && endDate != null) {
int _diff = endDate!.difference(startDate!).inMinutes;
if (_diff < 30) {
return false;
} else if (_diff % 30 != 0) {
return false;
}
return true;
}
return false;
}
Widget _hasBeenOrder() {
return CupertinoAlertDialog(
title: '此设施已被预约'.text.size(32.sp).bold.color(ktextPrimary).make(),
content: '是否查看此设施已被预约时段?'.text.size(28.sp).color(ktextPrimary).make(),
actions: [
CupertinoActionSheetAction(
onPressed: () {
Get.back();
},
child: '取消'.text.size(26.sp).color(ktextPrimary).make()),
CupertinoActionSheetAction(
onPressed: () {
Get.to(() => FacilityOrderDateListPage(facilitiesId: widget.id));
},
child: '查看'.text.size(26.sp).color(kPrimaryColor).make()),
],
);
}
}

@ -0,0 +1,105 @@
import 'package:aku_community/base/base_style.dart';
import 'package:aku_community/constants/api.dart';
import 'package:aku_community/models/facility/facility_order_date_list_model.dart';
import 'package:aku_community/pages/things_page/widget/bee_list_view.dart';
import 'package:aku_community/widget/bee_divider.dart';
import 'package:aku_community/widget/bee_scaffold.dart';
import 'package:flutter/material.dart';
import 'package:flutter_easyrefresh/easy_refresh.dart';
import 'package:velocity_x/velocity_x.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
class FacilityOrderDateListPage extends StatefulWidget {
final int facilitiesId;
FacilityOrderDateListPage({Key? key, required this.facilitiesId})
: super(key: key);
@override
_FacilityOrderDateListPageState createState() =>
_FacilityOrderDateListPageState();
}
class _FacilityOrderDateListPageState extends State<FacilityOrderDateListPage> {
late EasyRefreshController _refreshController;
@override
void initState() {
super.initState();
_refreshController = EasyRefreshController();
}
@override
void dispose() {
_refreshController.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
return BeeScaffold(
title: '预约时段',
body: BeeListView(
path: API.manager.facilityOrderDateList,
extraParams: {
"facilitiesId": widget.facilitiesId,
},
controller: _refreshController,
convert: (models) {
return models.tableList!
.map((e) => FacilityOrderDateListModel.fromJson(e))
.toList();
},
builder: (items) {
return ListView.separated(
itemBuilder: (context, index) {
return _buildCard(items[index]);
},
separatorBuilder: (_, __) {
return 24.w.heightBox;
},
itemCount: items.length);
}));
}
Widget _buildCard(FacilityOrderDateListModel model) {
return Container(
width: double.infinity,
padding: EdgeInsets.symmetric(vertical: 24.w, horizontal: 32.w),
decoration: BoxDecoration(
color: Colors.white, borderRadius: BorderRadius.circular(8.w)),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
children: [
'预约记录'.text.size(32.sp).color(ktextPrimary).bold.make(),
Spacer(),
],
),
16.w.heightBox,
BeeDivider.horizontal(),
20.w.heightBox,
Row(
children: [
'预约人姓名'.text.size(28.sp).color(ktextPrimary).make(),
Spacer(),
model.appointmentName.text
.size(28.sp)
.color(ktextSubColor)
.bold
.make(),
],
),
12.w.heightBox,
Row(
children: [
'预约时段'.text.size(28.sp).color(ktextPrimary).make(),
Spacer(),
model.tiemSlot.text.size(28.sp).color(ktextSubColor).bold.make(),
],
)
],
),
);
}
}

@ -42,7 +42,7 @@ class _NoticeDetailPageState extends State<NoticeDetailPage> {
padding: EdgeInsets.symmetric(horizontal: 32.w),
child: Row(
children: [
title!.text.size(32.sp).make().expand(),
title.text.size(32.sp).make().expand(),
Image.asset(
R.ASSETS_ICONS_FILE_PNG,
height: 52.w,

@ -124,9 +124,9 @@ class _MyOrderCardState extends State<MyOrderCard> {
),
40.w.heightBox,
...[
_rowTile('下单时间', widget.model.arrivlaTimeString),
_rowTile('下单时间', widget.model.arrivalDateString),
_rowTile('到达地点', '人才公寓小区北侧门口'),
_rowTile('发货时间', widget.model.arrivlaTimeString),
_rowTile('发货时间', widget.model.sendDateString),
].sepWidget(separate: 16.w.heightBox),
..._bottomWidget(),
],

@ -50,16 +50,18 @@ class _MyOrderDetailPageState extends State<MyOrderDetailPage> {
onRefresh: () async {
_topGoods = await MyOrderFunc.getHotTops();
_onload = false;
setState(() {
});
setState(() {});
},
child: _onload
? Container()
: ListView(
padding: EdgeInsets.symmetric(vertical: 32.w, horizontal: 32.w),
children: [
children: <Widget>[
_statusInfo(),
..._refunReason(widget.model.backReason ?? '',
widget.model.backDateString),
..._evaluationContent(widget.model.evaluationReason ?? '',
widget.model.evaluateDateString),
_goodsInfoWidget(),
_orderInfo(),
_extraWidget(_topGoods),
@ -115,31 +117,68 @@ class _MyOrderDetailPageState extends State<MyOrderDetailPage> {
);
}
Widget _extraInfo(String reason, String text) {
return Container(
width: double.infinity,
decoration: BoxDecoration(
color: Colors.white, borderRadius: BorderRadius.circular(8.w)),
padding: EdgeInsets.symmetric(vertical: 24.w, horizontal: 32.w),
child: Column(
children: [
Row(
children: [
reason.text.size(32.sp).bold.color(ktextPrimary).make(),
],
),
20.w.heightBox,
text.text.size(28.sp).color(ktextSubColor).make(),
20.w.heightBox,
'2020-05-14 14:22:11'
.text
.size(28.sp)
.bold
.color(ktextPrimary.withOpacity(0.8))
.make()
],
),
);
_refunReason(String text, String date) {
return widget.model.backReason == null
? []
: [
Container(
width: double.infinity,
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(8.w)),
padding: EdgeInsets.symmetric(vertical: 24.w, horizontal: 32.w),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
children: [
'退换理由'.text.size(32.sp).bold.color(ktextPrimary).make(),
],
),
20.w.heightBox,
text.text.size(28.sp).color(ktextSubColor).make(),
20.w.heightBox,
date.text
.size(24.sp)
.bold
.color(ktextPrimary.withOpacity(0.8))
.make()
],
),
)
];
}
_evaluationContent(String text, String date) {
return widget.model.evaluationReason == null
? []
: [
Container(
width: double.infinity,
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(8.w)),
padding: EdgeInsets.symmetric(vertical: 24.w, horizontal: 32.w),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
children: [
'评价内容'.text.size(32.sp).bold.color(ktextPrimary).make(),
],
),
20.w.heightBox,
text.text.size(28.sp).color(ktextSubColor).make(),
20.w.heightBox,
date.text
.size(24.sp)
.bold
.color(ktextPrimary.withOpacity(0.8))
.make()
],
),
)
];
}
IconData get _icondata {
@ -176,10 +215,15 @@ class _MyOrderDetailPageState extends State<MyOrderDetailPage> {
],
),
24.w.heightBox,
...[
...<Widget>[
_rowTile('订单编号', widget.model.code),
_rowTile('预约时间', ''),
_rowTile('交易时间', ''),
_rowTile('创建时间', widget.model.createDateString),
...widget.model.sendDate == null
? []
: [_rowTile('发货时间', widget.model.sendDateString)],
...widget.model.arrivalDate == null
? []
: [_rowTile('到货时间', widget.model.arrivalDateString)],
].sepWidget(
separate: 20.w.heightBox,
)
@ -306,7 +350,7 @@ class _MyOrderDetailPageState extends State<MyOrderDetailPage> {
children: [
Row(
children: [
'其他${models.length}'
'其他热门${models.length}'
.text
.size(24.sp)
.color(ktextPrimary)

Loading…
Cancel
Save