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

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

上级 e9ef4778
...@@ -3,18 +3,8 @@ part of user_order; ...@@ -3,18 +3,8 @@ part of user_order;
/// 订单详情 /// 订单详情
class UserOrderController extends GetxController class UserOrderController extends GetxController
with GetTickerProviderStateMixin { with GetTickerProviderStateMixin {
int tag; final int tag;
// final List<OrderListModel> models; UserOrderController(this.tag);
UserOrderController(this.tag);/*{
onRefresh();
}*/
/* List<Tab> tabs = [
const Tab(text: '全部',),
const Tab(text: '待支付',),
const Tab(text: '已取消',),
const Tab(text: '已完成',),
const Tab(text: '已退款',),
];*/
List<OrderListModel> orderList = []; List<OrderListModel> orderList = [];
...@@ -44,7 +34,6 @@ class UserOrderController extends GetxController ...@@ -44,7 +34,6 @@ class UserOrderController extends GetxController
/// 获取订单列表 /// 获取订单列表
Future<void> _getOrders({bool isRefresh = false, String keys ='',int ?tabIndex}) async { Future<void> _getOrders({bool isRefresh = false, String keys ='',int ?tabIndex}) async {
if(tabIndex != null)tag=tabIndex;
if (isRefresh) _page = 1; if (isRefresh) _page = 1;
// 网路请求 // 网路请求
final result = await MineAPI.orderList( final result = await MineAPI.orderList(
......
...@@ -23,7 +23,7 @@ class _UserOrderState extends State<UserOrderPage> with SingleTickerProviderStat ...@@ -23,7 +23,7 @@ class _UserOrderState extends State<UserOrderPage> with SingleTickerProviderStat
@override @override
void initState() { void initState() {
_tabController = TabController(length: 5, vsync: this); _tabController = TabController(length: tabs.length, vsync: this);
super.initState(); super.initState();
// 在这里可以使用 localVariable 进行操作 // 在这里可以使用 localVariable 进行操作
...@@ -31,52 +31,7 @@ class _UserOrderState extends State<UserOrderPage> with SingleTickerProviderStat ...@@ -31,52 +31,7 @@ class _UserOrderState extends State<UserOrderPage> with SingleTickerProviderStat
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return /*GetBuilder<UserOrderController>( return WillPopScope(
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(
onWillPop: () async { onWillPop: () async {
context.pop(true); context.pop(true);
return false; return false;
...@@ -132,13 +87,6 @@ class _UserOrderState extends State<UserOrderPage> with SingleTickerProviderStat ...@@ -132,13 +87,6 @@ class _UserOrderState extends State<UserOrderPage> with SingleTickerProviderStat
color: Colors.white, color: Colors.white,
height: 35.w, height: 35.w,
child: TabBar( 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), labelPadding: EdgeInsets.symmetric(horizontal: 15.w),
indicatorSize: TabBarIndicatorSize.label, indicatorSize: TabBarIndicatorSize.label,
indicatorColor: AppTheme.primary, indicatorColor: AppTheme.primary,
...@@ -147,7 +95,7 @@ class _UserOrderState extends State<UserOrderPage> with SingleTickerProviderStat ...@@ -147,7 +95,7 @@ class _UserOrderState extends State<UserOrderPage> with SingleTickerProviderStat
color: AppTheme.primary, color: AppTheme.primary,
fontSize: 15.w, fontSize: 15.w,
height: 1.5, height: 1.5,
fontWeight: Fonts.medium), fontWeight: Fonts.boldSemi),
unselectedLabelColor: Colours.c9, unselectedLabelColor: Colours.c9,
unselectedLabelStyle: TextStyle( unselectedLabelStyle: TextStyle(
color: Colours.c9, fontSize: 15.w, height: 1.5), color: Colours.c9, fontSize: 15.w, height: 1.5),
...@@ -163,7 +111,7 @@ class _UserOrderState extends State<UserOrderPage> with SingleTickerProviderStat ...@@ -163,7 +111,7 @@ class _UserOrderState extends State<UserOrderPage> with SingleTickerProviderStat
tab = index; tab = index;
return BuildListPage( return BuildListPage(
tag: tag:
tab,/* models:controller.orderList,*//*controller: controller,*//*,context: context,*/ tab,/* models:controller.orderList,*//*controller: controller,*//*,context: context,*/
); );
})), })),
) )
......
part of user_order; part of user_order;
/// 待付款item /// 待付款item
class BuiltAwaiting extends StatelessWidget { class BuiltAwaiting extends StatelessWidget {
final OrderListModel model; 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 @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return GestureDetector( return GestureDetector(
onTap: () { onTap: () async {
context.pushNamed(Routes.orderAwaiting, final result = await context.pushNamed(Routes.orderAwaiting,
queryParameters: {'orderNum': model.ordersnum}); queryParameters: {'orderNum': model.ordersnum});
if (result == true) {
controller.onRefresh(); }
}, },
child: Container( child: Container(
margin: EdgeInsets.only(left: 10.w, right: 10.w, top: 10.w), margin: EdgeInsets.only(left: 10.w, right: 10.w, top: 10.w),
...@@ -123,8 +128,7 @@ class BuiltAwaiting extends StatelessWidget { ...@@ -123,8 +128,7 @@ class BuiltAwaiting extends StatelessWidget {
child: Align( child: Align(
alignment: Alignment.center, alignment: Alignment.center,
child: Text( child: Text(
'${30 - (DateTime.now().difference( '${30 - (DateTime.now().difference(DateTime.parse(model.createTime.toString()))).inMinutes}分钟',
DateTime.parse(model.createTime.toString()))).inMinutes}分钟',
style: TextStyle( style: TextStyle(
color: Colours.cC31F4C, color: Colours.cC31F4C,
fontSize: 10.w, fontSize: 10.w,
......
...@@ -2,8 +2,8 @@ part of user_order; ...@@ -2,8 +2,8 @@ part of user_order;
/// 紫荆币item /// 紫荆币item
class BuiltCoin extends StatelessWidget { class BuiltCoin extends StatelessWidget {
final OrderListModel model; final OrderListModel model;
final UserOrderController controller;
const BuiltCoin({Key? key, required this.model}) : super(key: key); const BuiltCoin({Key? key, required this.model,required this.controller}) : super(key: key);
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
...@@ -16,10 +16,13 @@ class BuiltCoin extends StatelessWidget { ...@@ -16,10 +16,13 @@ class BuiltCoin extends StatelessWidget {
status ='已完成'; status ='已完成';
} }
return GestureDetector( return GestureDetector(
onTap: () { onTap: () async {
if(model.status == 1){ if(model.status == 1){
context.pushNamed(Routes.orderCoinAwaiting, final result = await context.pushNamed(Routes.orderCoinAwaiting,
queryParameters: {'orderNum': model.ordersnum}); queryParameters: {'orderNum': model.ordersnum});
if(result==true){
controller.onRefresh();
}
} }
}, },
child: Container( child: Container(
......
...@@ -32,7 +32,7 @@ class _BuildListPageState extends State<BuildListPage> ...@@ -32,7 +32,7 @@ class _BuildListPageState extends State<BuildListPage>
Widget build(BuildContext context) { Widget build(BuildContext context) {
return GetBuilder<UserOrderController>( return GetBuilder<UserOrderController>(
tag: widget.tag.toString(), tag: widget.tag.toString(),
init: Get.put(UserOrderController(widget.tag)), init: UserOrderController(widget.tag),
builder: (controller) => CustomPullScrollView( builder: (controller) => CustomPullScrollView(
controller: controller.refreshController, controller: controller.refreshController,
onRefresh: controller.onRefresh, onRefresh: controller.onRefresh,
...@@ -42,10 +42,10 @@ class _BuildListPageState extends State<BuildListPage> ...@@ -42,10 +42,10 @@ class _BuildListPageState extends State<BuildListPage>
OrderListModel model = controller.orderList[index]; OrderListModel model = controller.orderList[index];
// OrderListModel model = widget.models[index]; // OrderListModel model = widget.models[index];
if (model.types == 2) { if (model.types == 2) {
return BuiltCoin(model: model,); return BuiltCoin(model: model,controller: controller,);
} else { } else {
if (model.status == 1) { if (model.status == 1) {
return BuiltAwaiting(model: model,); return BuiltAwaiting(model: model,controller: controller,);
} else if (model.status == 2) { } else if (model.status == 2) {
return BuiltCanceled(model: model,); return BuiltCanceled(model: model,);
} else if (model.status == 3) { } else if (model.status == 3) {
...@@ -60,33 +60,6 @@ class _BuildListPageState extends State<BuildListPage> ...@@ -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 @override
......
...@@ -56,10 +56,10 @@ class _SearchPageState extends State<OrderSearchPage> { ...@@ -56,10 +56,10 @@ class _SearchPageState extends State<OrderSearchPage> {
OrderListModel model = controller.orderList[index]; OrderListModel model = controller.orderList[index];
// OrderListModel model = widget.models[index]; // OrderListModel model = widget.models[index];
if (model.types == 2) { if (model.types == 2) {
return BuiltCoin(model: model,); return BuiltCoin(model: model,controller: UserOrderController(0),);
} else { } else {
if (model.status == 1) { if (model.status == 1) {
return BuiltAwaiting(model: model,); return BuiltAwaiting(model: model,controller: UserOrderController(0),);
} else if (model.status == 2) { } else if (model.status == 2) {
return BuiltCanceled(model: model,); return BuiltCanceled(model: model,);
} else if (model.status == 3) { } else if (model.status == 3) {
......
...@@ -32,13 +32,12 @@ class UserOrderAwaitingController extends GetxController { ...@@ -32,13 +32,12 @@ class UserOrderAwaitingController extends GetxController {
} }
/// 取消订单 /// 取消订单
void cancelPay() async { Future<bool> cancelPay() async {
final result = await MineAPI.cancelPay(ordersnum: orderNum); final result = await MineAPI.cancelPay(ordersnum: orderNum);
if (result) { if (result) {
Get.find<UserOrderController>().onRefresh();
Toast.show('取消成功'); Toast.show('取消成功');
context.pop(true);
} }
return result;
} }
...@@ -100,7 +99,6 @@ class UserOrderAwaitingController extends GetxController { ...@@ -100,7 +99,6 @@ class UserOrderAwaitingController extends GetxController {
// 支付宝支付 // 支付宝支付
void requestAliPay(){ void requestAliPay(){
print('================================================================${payOrderModel.encryptionOrder!}'); print('================================================================${payOrderModel.encryptionOrder!}');
tobias.pay(payOrderModel.encryptionOrder!).then((payResult){ tobias.pay(payOrderModel.encryptionOrder!).then((payResult){
if (payResult['resultStatus'] == '9000') { if (payResult['resultStatus'] == '9000') {
......
...@@ -53,6 +53,7 @@ class UserOrderCoinAwaitingController extends GetxController { ...@@ -53,6 +53,7 @@ class UserOrderCoinAwaitingController extends GetxController {
@override @override
void onClose() { void onClose() {
// controller.onRefresh();
if (_connectionSubscription != null) { if (_connectionSubscription != null) {
_connectionSubscription.cancel(); _connectionSubscription.cancel();
_connectionSubscription = null; _connectionSubscription = null;
...@@ -94,14 +95,12 @@ class UserOrderCoinAwaitingController extends GetxController { ...@@ -94,14 +95,12 @@ class UserOrderCoinAwaitingController extends GetxController {
/// 取消订单 /// 取消订单
void cancelPay() async { Future<bool> cancelPay() async {
final result = await MineAPI.cancelPay(ordersnum: orderNum); final result = await MineAPI.cancelPay(ordersnum: orderNum);
if (result) { if (result) {
Get.find<UserOrderController>().onRefresh();
Toast.show('取消成功'); Toast.show('取消成功');
context.pop(true);
// update();
} }
return result;
} }
/// 获取订单信息 /// 获取订单信息
...@@ -231,9 +230,8 @@ class UserOrderCoinAwaitingController extends GetxController { ...@@ -231,9 +230,8 @@ class UserOrderCoinAwaitingController extends GetxController {
final result = await ShopAPI.orderStatus(orderNumber: model.ordersnum??'',receipt:_resultItem != null?_resultItem!.transactionReceipt.toString():''); final result = await ShopAPI.orderStatus(orderNumber: model.ordersnum??'',receipt:_resultItem != null?_resultItem!.transactionReceipt.toString():'');
if (result.paySuccess == 1){ if (result.paySuccess == 1){
Toast.show('订单支付完成'); Toast.show('订单支付完成');
Get.find<UserOrderController>().onRefresh();
if(context.mounted){ if(context.mounted){
context.pop(true); context.pop(true);
} }
if (model.payType == 3){ if (model.payType == 3){
// 清除 // 清除
......
...@@ -23,7 +23,12 @@ class _UserOrderCoinAwaitingState extends State<UserOrderCoinAwaitingPage> { ...@@ -23,7 +23,12 @@ class _UserOrderCoinAwaitingState extends State<UserOrderCoinAwaitingPage> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return FutureBuilder( return WillPopScope(
onWillPop: () async {
context.pop(true);
return false;
},
child: FutureBuilder(
future: myController.getOrderInfo(), future: myController.getOrderInfo(),
builder: (context, snapshot) { builder: (context, snapshot) {
if (snapshot.connectionState == ConnectionState.waiting) { if (snapshot.connectionState == ConnectionState.waiting) {
...@@ -269,10 +274,12 @@ class _UserOrderCoinAwaitingState extends State<UserOrderCoinAwaitingPage> { ...@@ -269,10 +274,12 @@ class _UserOrderCoinAwaitingState extends State<UserOrderCoinAwaitingPage> {
color: Colours.cLine, // 设置分割线的颜色 color: Colours.cLine, // 设置分割线的颜色
), ),
GestureDetector( GestureDetector(
onTap: () { onTap: () async {
myController.cancelPay(); Future<bool> result = myController.cancelPay();
Navigator.of(context).pop(); if(await result){
Navigator.of(context).pop();
context.pop(true);
}
}, },
child:Container( child:Container(
width: 105.w, width: 105.w,
...@@ -315,6 +322,7 @@ class _UserOrderCoinAwaitingState extends State<UserOrderCoinAwaitingPage> { ...@@ -315,6 +322,7 @@ class _UserOrderCoinAwaitingState extends State<UserOrderCoinAwaitingPage> {
); );
} }
}, },
),
); );
} }
} }
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论