提交 ebbd9edf authored 作者: maodou's avatar maodou

订单分类及待付款订单取消、付款后列表状态刷新

上级 e9ef4778
......@@ -3,18 +3,8 @@ part of user_order;
/// 订单详情
class UserOrderController extends GetxController
with GetTickerProviderStateMixin {
int tag;
// final List<OrderListModel> models;
UserOrderController(this.tag);/*{
onRefresh();
}*/
/* List<Tab> tabs = [
const Tab(text: '全部',),
const Tab(text: '待支付',),
const Tab(text: '已取消',),
const Tab(text: '已完成',),
const Tab(text: '已退款',),
];*/
final int tag;
UserOrderController(this.tag);
List<OrderListModel> orderList = [];
......@@ -44,7 +34,6 @@ class UserOrderController extends GetxController
/// 获取订单列表
Future<void> _getOrders({bool isRefresh = false, String keys ='',int ?tabIndex}) async {
if(tabIndex != null)tag=tabIndex;
if (isRefresh) _page = 1;
// 网路请求
final result = await MineAPI.orderList(
......
......@@ -23,7 +23,7 @@ class _UserOrderState extends State<UserOrderPage> with SingleTickerProviderStat
@override
void initState() {
_tabController = TabController(length: 5, vsync: this);
_tabController = TabController(length: tabs.length, vsync: this);
super.initState();
// 在这里可以使用 localVariable 进行操作
......@@ -31,52 +31,7 @@ class _UserOrderState extends State<UserOrderPage> with SingleTickerProviderStat
@override
Widget build(BuildContext context) {
return /*GetBuilder<UserOrderController>(
init: UserOrderController(tab),
builder: (controller) => Scaffold(
appBar: CustomAppBar(
automaticallyImplyLeading: false,
titleSpacing: 0,
title: Padding(
padding: EdgeInsets.symmetric(horizontal: AppTheme.margin),
child: CustomInputSearch(
controller: searchController,
readOnly: false,
hintText: '搜索我的订单',
onTap: () {
// context.pushNamed(Routes.msgs);
},
onEditingComplete: () {
controller._getOrders(
isRefresh: true,
keys: searchController.text,
tabIndex: _tabController.index);
// FocusScope.of(context).unfocus();
FocusNode blankNode = FocusNode();
FocusScope.of(context).requestFocus(blankNode); //指定为空白焦点
},
),
),
actions: [
GestureDetector(
onTap: () {
context.pop();
},
child: Container(
padding: EdgeInsets.only(left: 10.w, top: 10.w, bottom: 10.w),
child: Text(
'取消',
style:
TextStyle(fontSize: 14.w, height: 1.5, color: Colours.c3),
),
),
)
],
),
body: _buildBody(controller),
),
);*/
WillPopScope(
return WillPopScope(
onWillPop: () async {
context.pop(true);
return false;
......@@ -132,13 +87,6 @@ class _UserOrderState extends State<UserOrderPage> with SingleTickerProviderStat
color: Colors.white,
height: 35.w,
child: TabBar(
indicator: UnderlineTabIndicator(
borderRadius: BorderRadius.circular(0.75),
borderSide:
BorderSide(width: 1.5.w, color: AppTheme.primary),
insets: EdgeInsets.symmetric(
horizontal:24.w), // 设置标签下面指示器的水平内边距
),
labelPadding: EdgeInsets.symmetric(horizontal: 15.w),
indicatorSize: TabBarIndicatorSize.label,
indicatorColor: AppTheme.primary,
......@@ -147,7 +95,7 @@ class _UserOrderState extends State<UserOrderPage> with SingleTickerProviderStat
color: AppTheme.primary,
fontSize: 15.w,
height: 1.5,
fontWeight: Fonts.medium),
fontWeight: Fonts.boldSemi),
unselectedLabelColor: Colours.c9,
unselectedLabelStyle: TextStyle(
color: Colours.c9, fontSize: 15.w, height: 1.5),
......
part of user_order;
/// 待付款item
class BuiltAwaiting extends StatelessWidget {
final OrderListModel model;
final UserOrderController controller;
const BuiltAwaiting({Key? key, required this.model}) : super(key: key);
const BuiltAwaiting({Key? key, required this.model, required this.controller})
: super(key: key);
@override
Widget build(BuildContext context) {
return GestureDetector(
onTap: () {
context.pushNamed(Routes.orderAwaiting,
onTap: () async {
final result = await context.pushNamed(Routes.orderAwaiting,
queryParameters: {'orderNum': model.ordersnum});
if (result == true) {
controller.onRefresh(); }
},
child: Container(
margin: EdgeInsets.only(left: 10.w, right: 10.w, top: 10.w),
......@@ -123,8 +128,7 @@ class BuiltAwaiting extends StatelessWidget {
child: Align(
alignment: Alignment.center,
child: Text(
'${30 - (DateTime.now().difference(
DateTime.parse(model.createTime.toString()))).inMinutes}分钟',
'${30 - (DateTime.now().difference(DateTime.parse(model.createTime.toString()))).inMinutes}分钟',
style: TextStyle(
color: Colours.cC31F4C,
fontSize: 10.w,
......
......@@ -2,8 +2,8 @@ part of user_order;
/// 紫荆币item
class BuiltCoin extends StatelessWidget {
final OrderListModel model;
const BuiltCoin({Key? key, required this.model}) : super(key: key);
final UserOrderController controller;
const BuiltCoin({Key? key, required this.model,required this.controller}) : super(key: key);
@override
Widget build(BuildContext context) {
......@@ -16,10 +16,13 @@ class BuiltCoin extends StatelessWidget {
status ='已完成';
}
return GestureDetector(
onTap: () {
onTap: () async {
if(model.status == 1){
context.pushNamed(Routes.orderCoinAwaiting,
final result = await context.pushNamed(Routes.orderCoinAwaiting,
queryParameters: {'orderNum': model.ordersnum});
if(result==true){
controller.onRefresh();
}
}
},
child: Container(
......
......@@ -32,7 +32,7 @@ class _BuildListPageState extends State<BuildListPage>
Widget build(BuildContext context) {
return GetBuilder<UserOrderController>(
tag: widget.tag.toString(),
init: Get.put(UserOrderController(widget.tag)),
init: UserOrderController(widget.tag),
builder: (controller) => CustomPullScrollView(
controller: controller.refreshController,
onRefresh: controller.onRefresh,
......@@ -42,10 +42,10 @@ class _BuildListPageState extends State<BuildListPage>
OrderListModel model = controller.orderList[index];
// OrderListModel model = widget.models[index];
if (model.types == 2) {
return BuiltCoin(model: model,);
return BuiltCoin(model: model,controller: controller,);
} else {
if (model.status == 1) {
return BuiltAwaiting(model: model,);
return BuiltAwaiting(model: model,controller: controller,);
} else if (model.status == 2) {
return BuiltCanceled(model: model,);
} else if (model.status == 3) {
......@@ -60,33 +60,6 @@ class _BuildListPageState extends State<BuildListPage>
),
),
);
/*return CustomPullScrollView(
controller: widget.controller.refreshController,
onRefresh: widget.controller.onRefresh,
onLoading: widget.controller.onLoading,
child: ListView.builder(
itemBuilder: (BuildContext context, int index) {
OrderListModel model = widget.controller.orderList[index];
// OrderListModel model = widget.models[index];
if (model.types == 2) {
return BuiltCoin(model: model,);
} else {
if (model.status == 1) {
return BuiltAwaiting(model: model,);
} else if (model.status == 2) {
return BuiltCanceled(model: model,);
} else if (model.status == 3) {
return BuiltCompleted(model: model,);
} else if (model.status == 4) {
return BuiltRefunded(model: model,);
}
}
},
itemCount: widget.controller.orderList.length,
// itemCount: widget.models.length,
),
);*/
}
@override
......
......@@ -56,10 +56,10 @@ class _SearchPageState extends State<OrderSearchPage> {
OrderListModel model = controller.orderList[index];
// OrderListModel model = widget.models[index];
if (model.types == 2) {
return BuiltCoin(model: model,);
return BuiltCoin(model: model,controller: UserOrderController(0),);
} else {
if (model.status == 1) {
return BuiltAwaiting(model: model,);
return BuiltAwaiting(model: model,controller: UserOrderController(0),);
} else if (model.status == 2) {
return BuiltCanceled(model: model,);
} else if (model.status == 3) {
......
......@@ -32,13 +32,12 @@ class UserOrderAwaitingController extends GetxController {
}
/// 取消订单
void cancelPay() async {
Future<bool> cancelPay() async {
final result = await MineAPI.cancelPay(ordersnum: orderNum);
if (result) {
Get.find<UserOrderController>().onRefresh();
Toast.show('取消成功');
context.pop(true);
}
return result;
}
......@@ -100,7 +99,6 @@ class UserOrderAwaitingController extends GetxController {
// 支付宝支付
void requestAliPay(){
print('================================================================${payOrderModel.encryptionOrder!}');
tobias.pay(payOrderModel.encryptionOrder!).then((payResult){
if (payResult['resultStatus'] == '9000') {
......
......@@ -2,7 +2,8 @@ part of user_order_awaiting;
class UserOrderAwaitingPage extends StatefulWidget {
final String orderNum; // 订单编号
const UserOrderAwaitingPage({Key? key , required this.orderNum}) : super(key: key);
const UserOrderAwaitingPage({Key? key, required this.orderNum})
: super(key: key);
@override
State<UserOrderAwaitingPage> createState() => _UserOrderAwaitingState();
......@@ -20,15 +21,22 @@ class _UserOrderAwaitingState extends State<UserOrderAwaitingPage> {
@override
Widget build(BuildContext context) {
return FutureBuilder(future: myController.getOrderInfo(),
return WillPopScope(
onWillPop: () async {
context.pop(true);
return false;
},
child: FutureBuilder(
future: myController.getOrderInfo(),
builder: (context, snapshot) {
if (snapshot.connectionState == ConnectionState.waiting) {
return Scaffold(
appBar: AppBar(
centerTitle: true,
title: const Text('等待付款'),
),);
}else{
),
);
} else {
return WillPopScope(
onWillPop: () async {
context.pop(true);
......@@ -71,7 +79,7 @@ class _UserOrderAwaitingState extends State<UserOrderAwaitingPage> {
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Image.network(
myController.model?.bookList?[0].img??'',
myController.model?.bookList?[0].img ?? '',
fit: BoxFit.cover, // 设置适应方式为充满
width: 72.0.w,
height: 86.0.w,
......@@ -89,7 +97,9 @@ class _UserOrderAwaitingState extends State<UserOrderAwaitingPage> {
CrossAxisAlignment.end, // 下面的Text靠左
children: [
Text(
myController.model.bookList?[0].name??'',
myController
.model.bookList?[0].name ??
'',
style: TextStyle(
color: Colours.c3,
fontWeight: Fonts.bold,
......@@ -166,7 +176,7 @@ class _UserOrderAwaitingState extends State<UserOrderAwaitingPage> {
height: 39.w,
),
GestureDetector(
onTap: (){
onTap: () {
myController.payOrder();
},
child: Container(
......@@ -175,8 +185,8 @@ class _UserOrderAwaitingState extends State<UserOrderAwaitingPage> {
decoration: BoxDecoration(
color: AppTheme.primary,
borderRadius: BorderRadius.circular(180.w),
border:
Border.all(color: Colours.cC31F4C, width: 0.5.w)),
border: Border.all(
color: Colours.cC31F4C, width: 0.5.w)),
child: Center(
child: Text(
'立即支付 ¥${myController.model.finalTotalPrice}',
......@@ -200,10 +210,13 @@ class _UserOrderAwaitingState extends State<UserOrderAwaitingPage> {
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(8.0.w),
),
contentPadding: EdgeInsets.zero, // 移除内容部分的内边距
content: Wrap(children: [
contentPadding: EdgeInsets.zero,
// 移除内容部分的内边距
content: Wrap(
children: [
Container(
margin: EdgeInsets.only(top: 44.w, bottom: 29.w), // 调整上下间距
margin: EdgeInsets.only(
top: 44.w, bottom: 29.w), // 调整上下间距
child: Center(
child: Text(
'确定取消订单吗',
......@@ -220,12 +233,15 @@ class _UserOrderAwaitingState extends State<UserOrderAwaitingPage> {
width: double.infinity, // 设置分割线的宽度
color: Colours.cLine, // 设置分割线的颜色
),
],),
],
),
// 去除操作按钮区域的内边距
actionsPadding: EdgeInsets.zero,
actions: <Widget>[
Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly, // 或者使用MainAxisAlignment.spaceEvenly
mainAxisAlignment:
MainAxisAlignment.spaceEvenly,
// 或者使用MainAxisAlignment.spaceEvenly
children: [
GestureDetector(
onTap: () => Navigator.of(context).pop(),
......@@ -249,10 +265,12 @@ class _UserOrderAwaitingState extends State<UserOrderAwaitingPage> {
color: Colours.cLine, // 设置分割线的颜色
),
GestureDetector(
onTap: () {
myController.cancelPay();
onTap: () async {
Future<bool> result = myController.cancelPay();
if(await result){
Navigator.of(context).pop();
// Navigator.pop(context);
context.pop(true);
}
},
child: Container(
width: 105.w,
......@@ -270,7 +288,6 @@ class _UserOrderAwaitingState extends State<UserOrderAwaitingPage> {
),
],
),
],
);
},
......@@ -290,16 +307,13 @@ class _UserOrderAwaitingState extends State<UserOrderAwaitingPage> {
),
),
),
],
),
),
);
}
},);
},
),
);
}
}
......@@ -53,6 +53,7 @@ class UserOrderCoinAwaitingController extends GetxController {
@override
void onClose() {
// controller.onRefresh();
if (_connectionSubscription != null) {
_connectionSubscription.cancel();
_connectionSubscription = null;
......@@ -94,14 +95,12 @@ class UserOrderCoinAwaitingController extends GetxController {
/// 取消订单
void cancelPay() async {
Future<bool> cancelPay() async {
final result = await MineAPI.cancelPay(ordersnum: orderNum);
if (result) {
Get.find<UserOrderController>().onRefresh();
Toast.show('取消成功');
context.pop(true);
// update();
}
return result;
}
/// 获取订单信息
......@@ -231,7 +230,6 @@ class UserOrderCoinAwaitingController extends GetxController {
final result = await ShopAPI.orderStatus(orderNumber: model.ordersnum??'',receipt:_resultItem != null?_resultItem!.transactionReceipt.toString():'');
if (result.paySuccess == 1){
Toast.show('订单支付完成');
Get.find<UserOrderController>().onRefresh();
if(context.mounted){
context.pop(true);
}
......
......@@ -23,7 +23,12 @@ class _UserOrderCoinAwaitingState extends State<UserOrderCoinAwaitingPage> {
@override
Widget build(BuildContext context) {
return FutureBuilder(
return WillPopScope(
onWillPop: () async {
context.pop(true);
return false;
},
child: FutureBuilder(
future: myController.getOrderInfo(),
builder: (context, snapshot) {
if (snapshot.connectionState == ConnectionState.waiting) {
......@@ -269,10 +274,12 @@ class _UserOrderCoinAwaitingState extends State<UserOrderCoinAwaitingPage> {
color: Colours.cLine, // 设置分割线的颜色
),
GestureDetector(
onTap: () {
myController.cancelPay();
onTap: () async {
Future<bool> result = myController.cancelPay();
if(await result){
Navigator.of(context).pop();
context.pop(true);
}
},
child:Container(
width: 105.w,
......@@ -315,6 +322,7 @@ class _UserOrderCoinAwaitingState extends State<UserOrderCoinAwaitingPage> {
);
}
},
),
);
}
}
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论