From 10de196448d75dca7a422f2f0f0d84a49e417752 Mon Sep 17 00:00:00 2001 From: wurong <953969641@qq.com> Date: Wed, 22 Nov 2023 17:06:29 +0800 Subject: [PATCH] =?UTF-8?q?=E5=85=91=E6=8D=A2=E5=88=97=E8=A1=A8=EF=BC=8C?= =?UTF-8?q?=E7=A6=8F=E5=88=A9=E5=85=91=E6=8D=A2=E4=BC=98=E5=8C=96=E6=9B=B4?= =?UTF-8?q?=E6=94=B9=EF=BC=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/home/welfare_exchange.dart | 2 +- lib/order/exchange_history_page.dart | 397 ++++++++++++++------------- 2 files changed, 209 insertions(+), 190 deletions(-) diff --git a/lib/home/welfare_exchange.dart b/lib/home/welfare_exchange.dart index 7e7b0eda..7bf61590 100644 --- a/lib/home/welfare_exchange.dart +++ b/lib/home/welfare_exchange.dart @@ -72,7 +72,7 @@ class _WelfareExchange extends State } } - creditGoods({isLoading = true}) async { + creditGoods({bool isLoading = true}) async { try{ if(isLoading) EasyLoading.show(status: S.current.zhengzaijiazai,maskType: EasyLoadingMaskType.black); diff --git a/lib/order/exchange_history_page.dart b/lib/order/exchange_history_page.dart index adc0f906..4dda3bd1 100644 --- a/lib/order/exchange_history_page.dart +++ b/lib/order/exchange_history_page.dart @@ -85,22 +85,22 @@ class _ExchangeHistoryPage extends State highlightColor: Colors.transparent, // 点击时的背景高亮颜色设置为透明 ), child: TabBar( - controller: tabcontroller, - indicatorWeight: 2, - indicatorColor: Color(0xFF39B54A), - indicatorSize: TabBarIndicatorSize.label, - indicatorPadding: EdgeInsets.only(top: 3), - unselectedLabelStyle: TextStyle( - fontSize: 16.sp, - fontWeight: FontWeight.normal, - ), - labelStyle: TextStyle( - color: Colors.black, - fontSize: 16.sp, - fontWeight: MyFontWeight.semi_bold), - labelColor: Colors.black, - tabs: tabs, - )), + controller: tabcontroller, + indicatorWeight: 2, + indicatorColor: Color(0xFF39B54A), + indicatorSize: TabBarIndicatorSize.label, + indicatorPadding: EdgeInsets.only(top: 3), + unselectedLabelStyle: TextStyle( + fontSize: 16.sp, + fontWeight: FontWeight.normal, + ), + labelStyle: TextStyle( + color: Colors.black, + fontSize: 16.sp, + fontWeight: MyFontWeight.semi_bold), + labelColor: Colors.black, + tabs: tabs, + )), ), ), body: TabBarView( @@ -124,9 +124,10 @@ class ExchangeHistoryList extends StatefulWidget { } class _ExchangeHistoryList extends State - with AutomaticKeepAliveClientMixin{ + with AutomaticKeepAliveClientMixin { ApiService apiService; - RefreshController _refreshController = RefreshController(initialRefresh: false); + RefreshController _refreshController = + RefreshController(initialRefresh: false); int pageNum = 1; List orders = []; @@ -136,33 +137,36 @@ class _ExchangeHistoryList extends State SharedPreferences.getInstance().then((value) => { apiService = ApiService(Dio(), showLoading: false, - context: context, token: value.getString('token')), + context: context, + token: value.getString('token')), queryHistory(), }); } - queryHistory({isLoading = true}) async { - try{ - if(isLoading) - EasyLoading.show(status: S.current.zhengzaijiazai,maskType: EasyLoadingMaskType.black); - var map = { - "pageNum": pageNum, - "pageSize": 10, - // "state": widget.orderStatus - }; - if (widget.orderStatus != 0) { - map["state"] = widget.orderStatus; - } - BaseData> baseData = - await apiService.creditOrderList(map).catchError((error) { - _refreshController.loadFailed(); - _refreshController.refreshFailed(); - }); - if (baseData != null && baseData.isSuccess) { - if (pageNum == 1) { - orders.clear(); + queryHistory({bool isLoading = true}) async { + try { + if (isLoading) + EasyLoading.show( + status: S.current.zhengzaijiazai, + maskType: EasyLoadingMaskType.black); + var map = { + "pageNum": pageNum, + "pageSize": 10, + // "state": widget.orderStatus + }; + if (widget.orderStatus != 0) { + map["state"] = widget.orderStatus; } - orders.addAll(baseData.data.list); + BaseData> baseData = + await apiService.creditOrderList(map).catchError((error) { + _refreshController.loadFailed(); + _refreshController.refreshFailed(); + }); + if (baseData != null && baseData.isSuccess) { + if (pageNum == 1) { + orders.clear(); + } + orders.addAll(baseData.data.list); _refreshController.loadComplete(); _refreshController.refreshCompleted(); if (baseData.data.pages == baseData.data.pageNum) { @@ -170,10 +174,11 @@ class _ExchangeHistoryList extends State } else { pageNum += 1; } - } else { - _refreshController.refreshFailed(); - _refreshController.loadFailed(); - }}finally{ + } else { + _refreshController.refreshFailed(); + _refreshController.loadFailed(); + } + } finally { EasyLoading.dismiss(); setState(() {}); } @@ -197,14 +202,16 @@ class _ExchangeHistoryList extends State ), controller: _refreshController, onRefresh: _refresh, - onLoading: queryHistory, + onLoading: () { + queryHistory(isLoading: false); + }, child: orders == null || orders.length == 0 ? NoDataView( src: "assets/image/ding_dan.webp", isShowBtn: false, text: "目前暂无记录,手上那么多积分要赶紧用掉哦~", fontSize: 16.sp, - margin: EdgeInsets.only(top: 120.h,left: 72,right: 72), + margin: EdgeInsets.only(top: 120.h, left: 72, right: 72), ) : ListView.builder( itemCount: orders == null ? 0 : orders.length, @@ -261,11 +268,16 @@ class _ExchangeHistoryList extends State ), ), Text( - exchangeOrder.payStatus != 1 ? "未支付": - ((exchangeOrder.useTyped ==1)?((exchangeOrder.sendStatus==3 || exchangeOrder.sendStatus == 9)?"已自提":"待提货") - :(exchangeOrder.useTyped == 2 ?((exchangeOrder.sendStatus==1)?"待发货" - :"已发货") - :orderStatus(exchangeOrder.state))), + exchangeOrder.payStatus != 1 + ? "未支付" + : ((exchangeOrder.useTyped == 1) + ? ((exchangeOrder.sendStatus == 3 || + exchangeOrder.sendStatus == 9) + ? "已自提" + : "待提货") + : (exchangeOrder.useTyped == 2 + ? ((exchangeOrder.sendStatus == 1) ? "待发货" : "已发货") + : orderStatus(exchangeOrder.state))), style: TextStyle( color: Color(0xFFFE951E), fontWeight: MyFontWeight.semi_bold, @@ -277,86 +289,117 @@ class _ExchangeHistoryList extends State SizedBox( height: 16.h, ), - exchangeOrder.useTyped == 1 ? - Container( - child: Column( - children: [ - Row( - mainAxisAlignment: MainAxisAlignment.start, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text( - "自提门店" + " :", - style: TextStyle( - color: Color(0xFF353535), - fontWeight: MyFontWeight.regular, - fontSize: 12.sp, + exchangeOrder.useTyped == 1 + ? Container( + child: Column( + children: [ + Row( + mainAxisAlignment: MainAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + "自提门店" + " :", + style: TextStyle( + color: Color(0xFF353535), + fontWeight: MyFontWeight.regular, + fontSize: 12.sp, + ), + ), + SizedBox( + width: 8.w, + ), + Expanded( + child: Text( + exchangeOrder.storeName ?? "", + style: TextStyle( + color: Colors.black, + fontWeight: MyFontWeight.regular, + fontSize: 12.sp, + ), + ), + ) + ], ), - ), - SizedBox( - width: 8.w, - ), - Expanded( - child: Text( - exchangeOrder.storeName ?? "", - style: TextStyle( - color: Colors.black, - fontWeight: MyFontWeight.regular, - fontSize: 12.sp, - ), + SizedBox( + height: 8.h, ), - ) - ], - ), - SizedBox( - height: 8.h, - ), - Row( + Row( + mainAxisAlignment: MainAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + S.of(context).zitidizhi + " :", + style: TextStyle( + color: Color(0xFF353535), + fontWeight: MyFontWeight.regular, + fontSize: 12.sp, + ), + ), + SizedBox( + width: 8.w, + ), + Expanded( + child: Text( + exchangeOrder.address ?? "", + style: TextStyle( + color: Colors.black, + fontWeight: MyFontWeight.regular, + fontSize: 12.sp, + ), + ), + ) + ], + ), + SizedBox( + height: 8.h, + ), + Row( + children: [ + Text( + S.of(context).zitishijian + " :", + style: TextStyle( + color: Color(0xFF353535), + fontWeight: MyFontWeight.regular, + fontSize: 12.sp, + ), + ), + SizedBox( + width: 8.h, + ), + Expanded( + child: Text( + S.of(context).duihuanhouwugegongzuori, + style: TextStyle( + color: Colors.black, + fontWeight: MyFontWeight.regular, + fontSize: 12.sp, + ), + ), + ) + ], + ), + ], + ), + ) + : Row( mainAxisAlignment: MainAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start, children: [ - Text( - S.of(context).zitidizhi + " :", - style: TextStyle( - color: Color(0xFF353535), - fontWeight: MyFontWeight.regular, - fontSize: 12.sp, - ), - ), - SizedBox( - width: 8.w, - ), - Expanded( - child: Text( - exchangeOrder.address ?? "", + if (exchangeOrder.useTyped != 3) + Text( + S.of(context).shouhuodi + " :", style: TextStyle( - color: Colors.black, + color: Color(0xFF353535), fontWeight: MyFontWeight.regular, fontSize: 12.sp, ), ), - ) - ], - ), - SizedBox( - height: 8.h, - ), - Row( - children: [ - Text( - S.of(context).zitishijian + " :", - style: TextStyle( - color: Color(0xFF353535), - fontWeight: MyFontWeight.regular, - fontSize: 12.sp, - ), - ), SizedBox( - width: 8.h, + width: 8.w, ), Expanded( child: Text( - S.of(context).duihuanhouwugegongzuori, + exchangeOrder.recAddress ?? "", style: TextStyle( color: Colors.black, fontWeight: MyFontWeight.regular, @@ -366,37 +409,6 @@ class _ExchangeHistoryList extends State ) ], ), - ], - ), - ): - Row( - mainAxisAlignment: MainAxisAlignment.start, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - if(exchangeOrder.useTyped != 3) - Text( - S.of(context).shouhuodi + " :", - style: TextStyle( - color: Color(0xFF353535), - fontWeight: MyFontWeight.regular, - fontSize: 12.sp, - ), - ), - SizedBox( - width: 8.w, - ), - Expanded( - child: Text( - exchangeOrder.recAddress ?? "", - style: TextStyle( - color: Colors.black, - fontWeight: MyFontWeight.regular, - fontSize: 12.sp, - ), - ), - ) - ], - ), SizedBox( height: 16.h, ), @@ -480,12 +492,16 @@ class _ExchangeHistoryList extends State Text( exchangeOrder?.amount == null || exchangeOrder.amount == "0" ? "" - : exchangeOrder.payType == 2 ? "实付印章 ${exchangeOrder.amount}印章":(S.of(context).shifujifen(exchangeOrder.amount) + - ( exchangeOrder?.creditOrderDetailList[0]?.money == null || - exchangeOrder?.creditOrderDetailList[0]?.money == - "0.00" - ? "" - : " + ${double.parse(exchangeOrder?.creditOrderDetailList[0]?.money.toString()) * exchangeOrder?.creditOrderDetailList[0].goodsNumber}元")), + : exchangeOrder.payType == 2 + ? "实付印章 ${exchangeOrder.amount}印章" + : (S.of(context).shifujifen(exchangeOrder.amount) + + (exchangeOrder?.creditOrderDetailList[0]?.money == + null || + exchangeOrder + ?.creditOrderDetailList[0]?.money == + "0.00" + ? "" + : " + ${double.parse(exchangeOrder?.creditOrderDetailList[0]?.money.toString()) * exchangeOrder?.creditOrderDetailList[0].goodsNumber}元")), style: TextStyle( fontSize: 12.sp, fontWeight: MyFontWeight.semi_bold, @@ -511,40 +527,43 @@ class _ExchangeHistoryList extends State color: Color(0xFF353535), ), ), - if(exchangeOrder.useTyped != 3) - (exchangeOrder.useTyped == 1 ? - GestureDetector( - behavior: HitTestBehavior.opaque, - onTap: () { - // if (exchangeOrder.state == 1) { - // receive2Card(exchangeOrder.id); - // } else { - // Navigator.of(context) - // .pushNamed('/router/write_off_page', arguments: {}); - // } - Navigator.of(context).pushNamed( - '/router/exchange_write_offPage', - arguments: { - "exchangeOrder": exchangeOrder.toJson(), - }); - }, - child: buildBtnStatus(exchangeOrder.state), - ): - GestureDetector( - behavior: HitTestBehavior.opaque, - onTap: () { - Navigator.of(context).pushNamed( - '/router/logistics_information_page', - arguments: { - "orderId": exchangeOrder.creditOrderDetailList[0].orderId, - "logisticsNum": "", - "logisticsName": "", - "productNum": exchangeOrder.creditOrderDetailList[0].goodsNumber, - "skuImg":exchangeOrder.creditOrderDetailList[0].goodsMainImg - }); - }, - child: buildBtnStatusTow(exchangeOrder.sendStatus), - )) + if (exchangeOrder.useTyped != 3) + (exchangeOrder.useTyped == 1 + ? GestureDetector( + behavior: HitTestBehavior.opaque, + onTap: () { + // if (exchangeOrder.state == 1) { + // receive2Card(exchangeOrder.id); + // } else { + // Navigator.of(context) + // .pushNamed('/router/write_off_page', arguments: {}); + // } + Navigator.of(context).pushNamed( + '/router/exchange_write_offPage', + arguments: { + "exchangeOrder": exchangeOrder.toJson(), + }); + }, + child: buildBtnStatus(exchangeOrder.state), + ) + : GestureDetector( + behavior: HitTestBehavior.opaque, + onTap: () { + Navigator.of(context).pushNamed( + '/router/logistics_information_page', + arguments: { + "orderId": exchangeOrder + .creditOrderDetailList[0].orderId, + "logisticsNum": "", + "logisticsName": "", + "productNum": exchangeOrder + .creditOrderDetailList[0].goodsNumber, + "skuImg": exchangeOrder + .creditOrderDetailList[0].goodsMainImg + }); + }, + child: buildBtnStatusTow(exchangeOrder.sendStatus), + )) ], ) ], @@ -560,7 +579,7 @@ class _ExchangeHistoryList extends State } Widget buildBtnStatus(state) { - if (state ==1) { + if (state == 1) { return RoundButton( padding: EdgeInsets.fromLTRB(8, 4, 8, 4), text: S.of(context).chakanhexiaoma,