flutter/lib/pages/order/index.dart

503 lines
20 KiB
Dart
Raw Normal View History

2025-07-21 15:46:30 +08:00
/// 我的订单
library;
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import '../../behavior/custom_scroll_behavior.dart';
class Order extends StatefulWidget {
const Order({super.key});
@override
State<Order> createState() => _OrderState();
}
class _OrderState extends State<Order> with SingleTickerProviderStateMixin {
GlobalKey<ScaffoldState> scaffoldKey = GlobalKey();
List tabList = [
{'name': "全部"},
2025-09-06 14:57:47 +08:00
{'name': "待退款", 'badge': 1},
{'name': "待核销", 'badge': 1},
2025-07-21 15:46:30 +08:00
{'name': "已完成"},
{'name': "取消"}
];
late ScrollController scrollController = ScrollController();
late TabController tabController = TabController(initialIndex: 0, length: tabList.length, vsync: this);
Widget emptyTip() {
return Column(
mainAxisAlignment: MainAxisAlignment.center,
spacing: 5.0,
children: [
Image.asset(
'assets/images/empty.png',
width: 100.0,
),
Text(
'还没有相关订单~',
style: TextStyle(color: Colors.grey, fontSize: 12.0),
)
],
);
}
@override
void initState() {
super.initState();
}
@override
void dispose() {
scrollController.dispose();
tabController.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
return Scaffold(
key: scaffoldKey,
backgroundColor: Colors.white,
appBar: AppBar(
forceMaterialTransparency: true,
titleSpacing: 1.0,
title: Container(
2025-09-06 14:57:47 +08:00
// height: 35.0,
2025-07-21 15:46:30 +08:00
decoration: BoxDecoration(
2025-09-06 14:57:47 +08:00
// color: Colors.grey[50],
color: Colors.white,
2025-07-21 15:46:30 +08:00
borderRadius: BorderRadius.circular(30.0),
),
2025-09-06 14:57:47 +08:00
child: Text(
'订单',
style: TextStyle(fontSize: 18),
2025-07-21 15:46:30 +08:00
),
2025-09-06 14:57:47 +08:00
// child: TextField(
// decoration: InputDecoration(
// isDense: true,
// hintText: "搜索订单",
// hintStyle: TextStyle(color: Colors.black38, fontSize: 14.0),
// prefixIcon: Icon(
// Icons.search,
// color: Colors.black38,
// size: 21.0,
// ),
// contentPadding: EdgeInsets.symmetric(vertical: 0, horizontal: 10.0),
// border: OutlineInputBorder(borderSide: BorderSide.none, borderRadius: BorderRadius.circular(30.0))),
// cursorColor: Colors.black,
// onChanged: (val) {
// debugPrint(val);
// },
// ),
2025-07-21 15:46:30 +08:00
),
bottom: PreferredSize(
preferredSize: Size.fromHeight(45.0),
child: Row(children: [
Expanded(
child: TabBar(
controller: tabController,
tabs: tabList
.map((item) => Container(
alignment: Alignment.center,
height: 45.0,
child: Badge.count(
2025-09-06 14:57:47 +08:00
backgroundColor: Colors.red,
count: item['badge'] ?? 0,
isLabelVisible: item['badge'] != null ? true : false,
child: Text(
item['name'],
style: TextStyle(fontSize: 16),
overflow: TextOverflow.ellipsis,
softWrap: false,
),
),
2025-07-21 15:46:30 +08:00
))
.toList(),
isScrollable: false,
overlayColor: WidgetStateProperty.all(Colors.transparent),
unselectedLabelColor: Colors.black87,
labelColor: Color(0xFFFF5000),
indicator: UnderlineTabIndicator(
borderRadius: BorderRadius.circular(10.0),
borderSide: BorderSide(color: Color(0xFFFF5000), width: 2.0),
),
indicatorSize: TabBarIndicatorSize.tab,
unselectedLabelStyle: TextStyle(fontSize: 16.0, fontFamily: 'Microsoft YaHei'),
labelStyle: TextStyle(fontSize: 18.0, fontFamily: 'Microsoft YaHei', fontWeight: FontWeight.w700),
dividerHeight: 0,
padding: EdgeInsets.symmetric(horizontal: 10.0),
labelPadding: EdgeInsets.symmetric(horizontal: 10.0),
indicatorPadding: EdgeInsets.symmetric(horizontal: 15.0, vertical: 5.0),
),
),
]),
),
),
body: ScrollConfiguration(
behavior: CustomScrollBehavior().copyWith(scrollbars: false),
child: Container(
color: Colors.grey[50],
2025-09-06 14:57:47 +08:00
child: TabBarView(
controller: tabController,
children: [
ListView(
controller: scrollController,
physics: BouncingScrollPhysics(),
padding: EdgeInsets.all(10.0),
children: [
GestureDetector(
child: Container(
margin: EdgeInsets.only(bottom: 10.0),
padding: EdgeInsets.all(10.0),
decoration: BoxDecoration(color: Colors.white, borderRadius: BorderRadius.circular(15.0), boxShadow: [
BoxShadow(
color: Colors.black.withAlpha(10),
offset: Offset(0.0, 1.0),
blurRadius: 1.0,
spreadRadius: 0.0,
2025-07-21 15:46:30 +08:00
),
2025-09-06 14:57:47 +08:00
]),
child: Column(
spacing: 10.0,
children: [
Row(
children: [
Wrap(
crossAxisAlignment: WrapCrossAlignment.center,
2025-07-21 15:46:30 +08:00
spacing: 5.0,
children: [
2025-09-06 14:57:47 +08:00
ClipOval(
child: Image.asset(
'assets/images/avatar/img11.jpg',
width: 25.0,
),
2025-07-21 15:46:30 +08:00
),
2025-09-06 14:57:47 +08:00
Text('老白干自营旗舰店'),
Icon(
Icons.arrow_forward_ios_rounded,
color: Colors.grey,
size: 12.0,
2025-07-21 15:46:30 +08:00
),
],
),
2025-09-06 14:57:47 +08:00
Spacer(),
Text(
'待付款',
style: TextStyle(color: Colors.red),
)
],
2025-07-21 15:46:30 +08:00
),
2025-09-06 14:57:47 +08:00
Row(
crossAxisAlignment: CrossAxisAlignment.start,
spacing: 10.0,
2025-07-21 15:46:30 +08:00
children: [
2025-09-06 14:57:47 +08:00
Image.network(
'https://img13.360buyimg.com/n1/jfs/t1/263909/5/4187/123220/676eb220F3e481086/0cee829b1894fc4c.jpg',
width: 80.0,
2025-07-21 15:46:30 +08:00
),
2025-09-06 14:57:47 +08:00
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
spacing: 5.0,
children: [
Text(
'茅台MOUTAI飞天 53度 酱香型白酒 500ml*2 海外版送礼袋年货送礼',
maxLines: 2,
overflow: TextOverflow.ellipsis,
),
Row(
children: [
Text(
'¥3800',
style: TextStyle(color: Colors.red),
),
Spacer(),
Text(
'x10',
style: TextStyle(color: Colors.grey),
),
],
),
],
),
)
2025-07-21 15:46:30 +08:00
],
),
2025-09-06 14:57:47 +08:00
// 提示信息
Container(
padding: EdgeInsets.all(5.0),
decoration: BoxDecoration(
color: Colors.grey[50],
borderRadius: BorderRadius.circular(5.0),
2025-07-21 15:46:30 +08:00
),
2025-09-06 14:57:47 +08:00
child: Row(
children: [
Spacer(),
Text.rich(
TextSpan(children: [
TextSpan(text: '实付款: '),
TextSpan(
text: '¥38000',
style: TextStyle(color: Colors.red),
),
]),
),
],
2025-07-21 15:46:30 +08:00
),
2025-09-06 14:57:47 +08:00
),
// 按钮组
Row(
spacing: 10.0,
mainAxisAlignment: MainAxisAlignment.end,
children: [
ElevatedButton(
onPressed: () {},
style: ButtonStyle(backgroundColor: WidgetStateProperty.all(Colors.white)),
child: Text('取消订单'),
),
ElevatedButton(
onPressed: () {},
style: ButtonStyle(
backgroundColor: WidgetStateProperty.all(Color(0xff07c160)), foregroundColor: WidgetStateProperty.all(Colors.white)),
child: Text('去支付'),
),
],
),
Row(
spacing: 10.0,
mainAxisAlignment: MainAxisAlignment.end,
children: [
ElevatedButton(
onPressed: () {},
style: ButtonStyle(
backgroundColor: WidgetStateProperty.all(Color(0xFF10B9FC)), foregroundColor: WidgetStateProperty.all(Colors.white)),
child: Text('评价'),
),
],
),
Row(
spacing: 10.0,
mainAxisAlignment: MainAxisAlignment.end,
children: [
ElevatedButton(
onPressed: () {},
style: ButtonStyle(backgroundColor: WidgetStateProperty.all(Colors.white)),
child: Text('申请退款'),
),
ElevatedButton(
onPressed: () {},
style: ButtonStyle(
backgroundColor: WidgetStateProperty.all(Color(0xFFFCBE13)), foregroundColor: WidgetStateProperty.all(Colors.white)),
child: Text('联系客服'),
),
],
),
Row(
spacing: 10.0,
mainAxisAlignment: MainAxisAlignment.end,
children: [
ElevatedButton(
onPressed: () {},
style: ButtonStyle(backgroundColor: WidgetStateProperty.all(Colors.white)),
child: Text('删除'),
),
],
),
],
),
),
onTap: () {
Get.toNamed('/order/detail');
},
),
],
),
emptyTip(),
hexiao(),
emptyTip(),
emptyTip(),
emptyTip(),
],
),
),
),
);
}
}
Widget hexiao() {
return ListView(
physics: BouncingScrollPhysics(),
padding: EdgeInsets.all(10.0),
children: [
GestureDetector(
child: Container(
margin: EdgeInsets.only(bottom: 10.0),
padding: EdgeInsets.all(10.0),
decoration: BoxDecoration(color: Colors.white, borderRadius: BorderRadius.circular(15.0), boxShadow: [
BoxShadow(
color: Colors.black.withAlpha(10),
offset: Offset(0.0, 1.0),
blurRadius: 1.0,
spreadRadius: 0.0,
),
]),
child: Column(
spacing: 10.0,
children: [
Row(
children: [
Wrap(
crossAxisAlignment: WrapCrossAlignment.center,
spacing: 5.0,
children: [
ClipOval(
child: Image.asset(
'assets/images/avatar/img11.jpg',
width: 25.0,
2025-07-21 15:46:30 +08:00
),
2025-09-06 14:57:47 +08:00
),
Text('老白干自营旗舰店'),
Icon(
Icons.arrow_forward_ios_rounded,
color: Colors.grey,
size: 12.0,
),
],
),
Spacer(),
Text(
'待付款',
style: TextStyle(color: Colors.red),
)
],
),
Row(
crossAxisAlignment: CrossAxisAlignment.start,
spacing: 10.0,
children: [
Image.network(
'https://img13.360buyimg.com/n1/jfs/t1/263909/5/4187/123220/676eb220F3e481086/0cee829b1894fc4c.jpg',
width: 80.0,
),
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
spacing: 5.0,
children: [
Text(
'茅台MOUTAI飞天 53度 酱香型白酒 500ml*2 海外版送礼袋年货送礼',
maxLines: 2,
overflow: TextOverflow.ellipsis,
2025-07-21 15:46:30 +08:00
),
Row(
children: [
2025-09-06 14:57:47 +08:00
Text(
'¥3800',
style: TextStyle(color: Colors.red),
2025-07-21 15:46:30 +08:00
),
2025-09-06 14:57:47 +08:00
Spacer(),
Text(
'x10',
style: TextStyle(color: Colors.grey),
2025-07-21 15:46:30 +08:00
),
],
),
],
),
2025-09-06 14:57:47 +08:00
)
],
),
// 提示信息
Container(
padding: EdgeInsets.all(5.0),
decoration: BoxDecoration(
color: Colors.grey[50],
borderRadius: BorderRadius.circular(5.0),
2025-07-21 15:46:30 +08:00
),
2025-09-06 14:57:47 +08:00
child: Row(
children: [
Spacer(),
Text.rich(
TextSpan(children: [
TextSpan(text: '实付款: '),
TextSpan(
text: '¥38000',
style: TextStyle(color: Colors.red),
),
]),
),
],
),
),
// 按钮组
Row(
spacing: 10.0,
mainAxisAlignment: MainAxisAlignment.end,
children: [
ElevatedButton(
onPressed: () {},
style: ButtonStyle(backgroundColor: WidgetStateProperty.all(Colors.white)),
child: Text('取消订单'),
),
ElevatedButton(
onPressed: () {},
style: ButtonStyle(backgroundColor: WidgetStateProperty.all(Color(0xff07c160)), foregroundColor: WidgetStateProperty.all(Colors.white)),
child: Text('去支付'),
),
],
),
Row(
spacing: 10.0,
mainAxisAlignment: MainAxisAlignment.end,
children: [
ElevatedButton(
onPressed: () {},
style: ButtonStyle(backgroundColor: WidgetStateProperty.all(Color(0xFF10B9FC)), foregroundColor: WidgetStateProperty.all(Colors.white)),
child: Text('评价'),
),
],
),
Row(
spacing: 10.0,
mainAxisAlignment: MainAxisAlignment.end,
children: [
ElevatedButton(
onPressed: () {},
style: ButtonStyle(backgroundColor: WidgetStateProperty.all(Colors.white)),
child: Text('申请退款'),
),
ElevatedButton(
onPressed: () {},
style: ButtonStyle(backgroundColor: WidgetStateProperty.all(Color(0xFFFCBE13)), foregroundColor: WidgetStateProperty.all(Colors.white)),
child: Text('联系客服'),
),
],
),
Row(
spacing: 10.0,
mainAxisAlignment: MainAxisAlignment.end,
children: [
ElevatedButton(
onPressed: () {},
style: ButtonStyle(backgroundColor: WidgetStateProperty.all(Colors.white)),
child: Text('删除'),
),
],
),
],
),
2025-07-21 15:46:30 +08:00
),
2025-09-06 14:57:47 +08:00
onTap: () {
Get.toNamed('/order/detail');
},
2025-07-21 15:46:30 +08:00
),
2025-09-06 14:57:47 +08:00
],
);
2025-07-21 15:46:30 +08:00
}