From 1faf237205e70916feb7015e6ac4985ce10676c1 Mon Sep 17 00:00:00 2001 From: wurong <953969641@qq.com> Date: Tue, 14 Nov 2023 12:23:28 +0800 Subject: [PATCH] =?UTF-8?q?=E5=85=91=E6=8D=A2=E5=8E=86=E5=8F=B2=E9=A1=B5?= =?UTF-8?q?=E9=9D=A2=E4=BC=98=E5=8C=96=E6=9B=B4=E6=94=B9=EF=BC=9B=20?= =?UTF-8?q?=E6=98=8E=E7=BB=86=E9=A1=B5=E9=9D=A2=E4=BC=98=E5=8C=96=E6=9B=B4?= =?UTF-8?q?=E6=94=B9=EF=BC=9B=20=E7=A6=8F=E5=88=A9=E5=85=91=E6=8D=A2?= =?UTF-8?q?=E9=A1=B5=E9=9D=A2=E4=BC=98=E5=8C=96=E6=9B=B4=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 | 44 +++++++++++++----------- lib/integral/integral_detailed_page.dart | 11 +++--- lib/order/exchange_history_page.dart | 44 ++++++++++++------------ 3 files changed, 50 insertions(+), 49 deletions(-) diff --git a/lib/home/welfare_exchange.dart b/lib/home/welfare_exchange.dart index b4ec8b8e..7e7b0eda 100644 --- a/lib/home/welfare_exchange.dart +++ b/lib/home/welfare_exchange.dart @@ -56,27 +56,26 @@ class _WelfareExchange extends State super.initState(); SharedPreferences.getInstance().then((value) => { apiService = ApiService(Dio(), - context: context, token: value.getString("token")), + context: context, token: value.getString("token"), showLoading: false), creditGoods(), }); } queryUser() async { - EasyLoading.show(status: S.current.zhengzaijiazai,maskType: EasyLoadingMaskType.black); - BaseData baseData = - await apiService.queryInfo().catchError((onError) {}); - if (baseData != null && baseData.isSuccess) { - userInfo = baseData.data; - EasyLoading.dismiss(); - setState(() {}); - SharedPreferences.getInstance().then((value) => { - value.setString('user', jsonEncode(baseData.data)), - }); - } + BaseData baseData = + await apiService.queryInfo().catchError((onError) {}); + if (baseData != null && baseData.isSuccess) { + userInfo = baseData.data; + SharedPreferences.getInstance().then((value) => { + value.setString('user', jsonEncode(baseData.data)), + }); + } } - creditGoods() async { - // EasyLoading.show(status: S.current.zhengzaijiazai); + creditGoods({isLoading = true}) async { + try{ + if(isLoading) + EasyLoading.show(status: S.current.zhengzaijiazai,maskType: EasyLoadingMaskType.black); final SharedPreferences value = await SharedPreferences.getInstance(); apiService = ApiService(Dio(), @@ -99,7 +98,7 @@ class _WelfareExchange extends State } BaseData> dataCategory = - await apiService.goodsCategory({ + await apiService.goodsCategory({ "current": 1, "map": {}, "model": {"pageNum": 1, "pageSize": 20, "searchKey": ""}, @@ -117,7 +116,9 @@ class _WelfareExchange extends State dataCategory.data.records != null && dataCategory.data.records.length > 0) { gooodsCategorys.clear(); - gooodsCategorys.add(GoodsCategory(name: S.of(context).quanbu)); + gooodsCategorys.add(GoodsCategory(name: S + .of(context) + .quanbu)); gooodsCategorys.addAll(dataCategory.data.records); } @@ -130,11 +131,10 @@ class _WelfareExchange extends State "state": 1 }; BaseData> pageGoods = - await apiService.creditGoods(param).catchError((onError) { + await apiService.creditGoods(param).catchError((onError) { refreshController.loadFailed(); refreshController.refreshFailed(); }); - EasyLoading.dismiss(); if (pageGoods != null && pageGoods.isSuccess) { if (pageNum == 1) { goods.clear(); @@ -151,11 +151,14 @@ class _WelfareExchange extends State refreshController.loadFailed(); refreshController.refreshFailed(); } - setState(() {}); + }finally{ + EasyLoading.dismiss(); + setState(() {}); + } } _onRefresh() { - creditGoods(); + creditGoods(isLoading: false); } @override @@ -248,7 +251,6 @@ class _WelfareExchange extends State categoryId = gooodsCategorys[index].id; pageNum = 1; creditGoods(); - setState(() {}); }, ), ), diff --git a/lib/integral/integral_detailed_page.dart b/lib/integral/integral_detailed_page.dart index b0fa7b1b..79f56d29 100644 --- a/lib/integral/integral_detailed_page.dart +++ b/lib/integral/integral_detailed_page.dart @@ -32,6 +32,11 @@ class _IntegralDetailedPage extends State with SingleTickerProviderStateMixin, AutomaticKeepAliveClientMixin { List _tabs; TabController tabController; + ApiService apiService; + UserInfo userInfo; + int current = 1; + List userBill = []; + RefreshController refreshController = RefreshController(); @override void didChangeDependencies() { @@ -55,8 +60,6 @@ class _IntegralDetailedPage extends State }); } - ApiService apiService; - UserInfo userInfo; @override void dispose() { @@ -75,9 +78,6 @@ class _IntegralDetailedPage extends State }); } - int current = 1; - List userBill = []; - queryDetail(category,type) async { BaseData> baseData = await apiService.queryBillInfo({ "current": current, @@ -106,7 +106,6 @@ class _IntegralDetailedPage extends State } } - RefreshController refreshController = RefreshController(); _onRefresh() { current = 1; diff --git a/lib/order/exchange_history_page.dart b/lib/order/exchange_history_page.dart index 7fbb4c3e..adc0f906 100644 --- a/lib/order/exchange_history_page.dart +++ b/lib/order/exchange_history_page.dart @@ -1,6 +1,7 @@ import 'package:dio/dio.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; +import 'package:flutter_easyloading/flutter_easyloading.dart'; import 'package:huixiang/generated/l10n.dart'; import 'package:huixiang/retrofit/data/base_data.dart'; import 'package:huixiang/retrofit/data/exchange_order.dart'; @@ -125,25 +126,25 @@ class ExchangeHistoryList extends StatefulWidget { class _ExchangeHistoryList extends State with AutomaticKeepAliveClientMixin{ ApiService apiService; - - RefreshController _refreshController = - RefreshController(initialRefresh: false); + RefreshController _refreshController = RefreshController(initialRefresh: false); + int pageNum = 1; + List orders = []; @override void initState() { super.initState(); SharedPreferences.getInstance().then((value) => { apiService = ApiService(Dio(), - showLoading: true, + showLoading: false, context: context, token: value.getString('token')), queryHistory(), }); } - int pageNum = 1; - List orders = []; - - queryHistory() async { + queryHistory({isLoading = true}) async { + try{ + if(isLoading) + EasyLoading.show(status: S.current.zhengzaijiazai,maskType: EasyLoadingMaskType.black); var map = { "pageNum": pageNum, "pageSize": 10, @@ -162,7 +163,6 @@ class _ExchangeHistoryList extends State orders.clear(); } orders.addAll(baseData.data.list); - setState(() { _refreshController.loadComplete(); _refreshController.refreshCompleted(); if (baseData.data.pages == baseData.data.pageNum) { @@ -170,16 +170,18 @@ class _ExchangeHistoryList extends State } else { pageNum += 1; } - }); } else { _refreshController.refreshFailed(); _refreshController.loadFailed(); + }}finally{ + EasyLoading.dismiss(); + setState(() {}); } } _refresh() { pageNum = 1; - queryHistory(); + queryHistory(isLoading: false); } @override @@ -531,17 +533,15 @@ class _ExchangeHistoryList extends State GestureDetector( behavior: HitTestBehavior.opaque, onTap: () { - setState(() { - 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 - }); - }); + 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), ))