245 lines
7.6 KiB
Dart
245 lines
7.6 KiB
Dart
import 'package:flutter/material.dart';
|
|
|
|
import '../../components/appbar.dart';
|
|
import 'history.dart';
|
|
|
|
class HistoryDetailPage extends StatelessWidget {
|
|
final Order order; // 接收传递的订单数据
|
|
|
|
const HistoryDetailPage({super.key, required this.order});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Scaffold(
|
|
appBar: const CustomAppBar(title: '订单详情'),
|
|
body: Container(
|
|
padding: const EdgeInsets.all(10),
|
|
color: const Color(0xFF0C0C16),
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
Container(
|
|
color: const Color(0xFF1F212E),
|
|
padding: const EdgeInsets.all(12),
|
|
child: Column(
|
|
children: [
|
|
// 使用 ListView.separated 循环展示订单信息
|
|
ListView.separated(
|
|
shrinkWrap: true,
|
|
physics: const NeverScrollableScrollPhysics(),
|
|
itemCount: order.orderInfoList.length,
|
|
separatorBuilder: (context, index) => const Divider(
|
|
color: Color(0xFF2A2C37),
|
|
height: 16,
|
|
),
|
|
itemBuilder: (context, index) {
|
|
final orderInfo = order.orderInfoList[index];
|
|
print("orderInfo------------------------: $orderInfo");
|
|
print(
|
|
"order.remainTimeString------------------------: ${order.remainTimeString}");
|
|
return _buildOrderItemInfo(orderInfo);
|
|
},
|
|
),
|
|
|
|
const SizedBox(height: 16),
|
|
_buildOrderInfo(), // 底部共用的订单信息
|
|
],
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
);
|
|
}
|
|
|
|
Widget _buildOrderItemInfo(OrderInfo orderInfo) {
|
|
return Column(
|
|
children: [
|
|
Row(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
Image.network(orderInfo.workAddress,
|
|
width: 60, height: 83, fit: BoxFit.cover),
|
|
const SizedBox(width: 8),
|
|
Expanded(
|
|
child: SizedBox(
|
|
height: 83,
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
children: [
|
|
Text(
|
|
orderInfo.workName,
|
|
style: const TextStyle(
|
|
fontSize: 14,
|
|
color: Colors.white,
|
|
),
|
|
),
|
|
Text(
|
|
_getWorkStatusText(orderInfo.workStatus),
|
|
style: TextStyle(
|
|
fontSize: 12,
|
|
color: _getWorkStatusColor(orderInfo.workStatus),
|
|
),
|
|
),
|
|
Text(
|
|
"展示时间:${_formatDateTime(order.startTime)}",
|
|
style: const TextStyle(
|
|
fontSize: 12,
|
|
color: Color(0xffC1C1C1),
|
|
),
|
|
),
|
|
Text(
|
|
"展示位置:${orderInfo.scenic}",
|
|
style: const TextStyle(
|
|
fontSize: 12,
|
|
color: Color(0xffC1C1C1),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
const SizedBox(height: 10),
|
|
Row(
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
children: [
|
|
Text(
|
|
order.remainTimeString ?? '剩余时间计算中...',
|
|
style: const TextStyle(
|
|
fontSize: 12,
|
|
color: Color(0xffC1C1C1),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
],
|
|
);
|
|
}
|
|
|
|
Widget _buildButton(String text, {VoidCallback? onPressed}) {
|
|
return Container(
|
|
height: 25,
|
|
width: 50,
|
|
decoration: BoxDecoration(
|
|
borderRadius: BorderRadius.circular(8),
|
|
gradient: LinearGradient(colors: [
|
|
const Color(0xff80DAA4).withOpacity(0.2),
|
|
const Color(0xff79DDED).withOpacity(0.2),
|
|
]),
|
|
border: Border.all(
|
|
color: const Color(0xff80DAA4),
|
|
width: 1,
|
|
),
|
|
),
|
|
child: ElevatedButton(
|
|
style: ElevatedButton.styleFrom(
|
|
backgroundColor: Colors.transparent,
|
|
elevation: 0,
|
|
shape: const RoundedRectangleBorder(
|
|
borderRadius: BorderRadius.all(Radius.circular(8)),
|
|
),
|
|
minimumSize: const Size(50, 25), // 设置最小尺寸
|
|
padding: const EdgeInsets.symmetric(horizontal: 5),
|
|
),
|
|
onPressed: onPressed ?? () {},
|
|
child: const Text(
|
|
"退款",
|
|
style: TextStyle(color: Colors.white, fontSize: 12),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
|
|
String _formatDateTime(String? dateTimeStr) {
|
|
if (dateTimeStr == null || dateTimeStr.isEmpty) {
|
|
return "暂无";
|
|
}
|
|
try {
|
|
final dateTime = DateTime.parse(dateTimeStr);
|
|
return "${dateTime.year}-${dateTime.month.toString().padLeft(2, '0')}-${dateTime.day.toString().padLeft(2, '0')} "
|
|
"${dateTime.hour.toString().padLeft(2, '0')}:${dateTime.minute.toString().padLeft(2, '0')}:${dateTime.second.toString().padLeft(2, '0')}";
|
|
} catch (e) {
|
|
print("时间格式化错误: $e");
|
|
return dateTimeStr;
|
|
}
|
|
}
|
|
|
|
String _getWorkStatusText(String workStatus) {
|
|
switch (workStatus) {
|
|
case '3':
|
|
return '审核成功';
|
|
case '4':
|
|
return '审核失败';
|
|
default:
|
|
return '审核中';
|
|
}
|
|
}
|
|
|
|
Color _getWorkStatusColor(String workStatus) {
|
|
switch (workStatus) {
|
|
case '3': // 审核成功
|
|
return const Color(0xff78E7A4);
|
|
case '4': // 审核失败
|
|
return const Color(0xffF42845);
|
|
default: // 审核中
|
|
return const Color(0xff79B7FF);
|
|
}
|
|
}
|
|
|
|
Widget _buildOrderInfo() {
|
|
return Column(
|
|
children: [
|
|
Row(
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
children: [
|
|
const Text('实付款', style: TextStyle(color: Colors.white)),
|
|
Text(
|
|
'¥${order.money / 1000}',
|
|
style: const TextStyle(fontSize: 16, color: Color(0xffF42845)),
|
|
),
|
|
],
|
|
),
|
|
const SizedBox(height: 8),
|
|
Row(
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
children: [
|
|
const Text('订单编号', style: TextStyle(color: Colors.white)),
|
|
Text(
|
|
order.orderInfoList.isNotEmpty
|
|
? order.orderInfoList[0].orderInfoId
|
|
: '',
|
|
|
|
style: const TextStyle(color: Colors.white),
|
|
),
|
|
],
|
|
),
|
|
const SizedBox(height: 8),
|
|
Row(
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
children: [
|
|
const Text('创建时间', style: TextStyle(color: Colors.white)),
|
|
Text(
|
|
_formatDateTime(order.createTime),
|
|
style: const TextStyle(color: Colors.grey),
|
|
),
|
|
],
|
|
),
|
|
const SizedBox(height: 8),
|
|
Row(
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
children: [
|
|
const Text('付款时间', style: TextStyle(color: Colors.white)),
|
|
Text(
|
|
_formatDateTime(order.startTime),
|
|
style: const TextStyle(color: Colors.grey),
|
|
),
|
|
],
|
|
),
|
|
],
|
|
);
|
|
}
|
|
}
|