Browse Source

Merge branch 'dev' into wr_2023_business

wr_2023_business
wurong 1 year ago
parent
commit
7aa35e1515
  1. 44
      lib/home/welfare_exchange.dart
  2. 11
      lib/integral/integral_detailed_page.dart
  3. 44
      lib/order/exchange_history_page.dart

44
lib/home/welfare_exchange.dart

@ -56,27 +56,26 @@ class _WelfareExchange extends State<WelfareExchange>
super.initState(); super.initState();
SharedPreferences.getInstance().then((value) => { SharedPreferences.getInstance().then((value) => {
apiService = ApiService(Dio(), apiService = ApiService(Dio(),
context: context, token: value.getString("token")), context: context, token: value.getString("token"), showLoading: false),
creditGoods(), creditGoods(),
}); });
} }
queryUser() async { queryUser() async {
EasyLoading.show(status: S.current.zhengzaijiazai,maskType: EasyLoadingMaskType.black); BaseData<UserInfo> baseData =
BaseData<UserInfo> baseData = await apiService.queryInfo().catchError((onError) {});
await apiService.queryInfo().catchError((onError) {}); if (baseData != null && baseData.isSuccess) {
if (baseData != null && baseData.isSuccess) { userInfo = baseData.data;
userInfo = baseData.data; SharedPreferences.getInstance().then((value) => {
EasyLoading.dismiss(); value.setString('user', jsonEncode(baseData.data)),
setState(() {}); });
SharedPreferences.getInstance().then((value) => { }
value.setString('user', jsonEncode(baseData.data)),
});
}
} }
creditGoods() async { creditGoods({isLoading = true}) async {
// EasyLoading.show(status: S.current.zhengzaijiazai); try{
if(isLoading)
EasyLoading.show(status: S.current.zhengzaijiazai,maskType: EasyLoadingMaskType.black);
final SharedPreferences value = await SharedPreferences.getInstance(); final SharedPreferences value = await SharedPreferences.getInstance();
apiService = ApiService(Dio(), apiService = ApiService(Dio(),
@ -99,7 +98,7 @@ class _WelfareExchange extends State<WelfareExchange>
} }
BaseData<PageInfo<GoodsCategory>> dataCategory = BaseData<PageInfo<GoodsCategory>> dataCategory =
await apiService.goodsCategory({ await apiService.goodsCategory({
"current": 1, "current": 1,
"map": {}, "map": {},
"model": {"pageNum": 1, "pageSize": 20, "searchKey": ""}, "model": {"pageNum": 1, "pageSize": 20, "searchKey": ""},
@ -117,7 +116,9 @@ class _WelfareExchange extends State<WelfareExchange>
dataCategory.data.records != null && dataCategory.data.records != null &&
dataCategory.data.records.length > 0) { dataCategory.data.records.length > 0) {
gooodsCategorys.clear(); gooodsCategorys.clear();
gooodsCategorys.add(GoodsCategory(name: S.of(context).quanbu)); gooodsCategorys.add(GoodsCategory(name: S
.of(context)
.quanbu));
gooodsCategorys.addAll(dataCategory.data.records); gooodsCategorys.addAll(dataCategory.data.records);
} }
@ -130,11 +131,10 @@ class _WelfareExchange extends State<WelfareExchange>
"state": 1 "state": 1
}; };
BaseData<PageInfo<Goods>> pageGoods = BaseData<PageInfo<Goods>> pageGoods =
await apiService.creditGoods(param).catchError((onError) { await apiService.creditGoods(param).catchError((onError) {
refreshController.loadFailed(); refreshController.loadFailed();
refreshController.refreshFailed(); refreshController.refreshFailed();
}); });
EasyLoading.dismiss();
if (pageGoods != null && pageGoods.isSuccess) { if (pageGoods != null && pageGoods.isSuccess) {
if (pageNum == 1) { if (pageNum == 1) {
goods.clear(); goods.clear();
@ -151,11 +151,14 @@ class _WelfareExchange extends State<WelfareExchange>
refreshController.loadFailed(); refreshController.loadFailed();
refreshController.refreshFailed(); refreshController.refreshFailed();
} }
setState(() {}); }finally{
EasyLoading.dismiss();
setState(() {});
}
} }
_onRefresh() { _onRefresh() {
creditGoods(); creditGoods(isLoading: false);
} }
@override @override
@ -248,7 +251,6 @@ class _WelfareExchange extends State<WelfareExchange>
categoryId = gooodsCategorys[index].id; categoryId = gooodsCategorys[index].id;
pageNum = 1; pageNum = 1;
creditGoods(); creditGoods();
setState(() {});
}, },
), ),
), ),

11
lib/integral/integral_detailed_page.dart

@ -32,6 +32,11 @@ class _IntegralDetailedPage extends State<IntegralDetailedPage>
with SingleTickerProviderStateMixin, AutomaticKeepAliveClientMixin { with SingleTickerProviderStateMixin, AutomaticKeepAliveClientMixin {
List<Widget> _tabs; List<Widget> _tabs;
TabController tabController; TabController tabController;
ApiService apiService;
UserInfo userInfo;
int current = 1;
List<UserBill> userBill = [];
RefreshController refreshController = RefreshController();
@override @override
void didChangeDependencies() { void didChangeDependencies() {
@ -55,8 +60,6 @@ class _IntegralDetailedPage extends State<IntegralDetailedPage>
}); });
} }
ApiService apiService;
UserInfo userInfo;
@override @override
void dispose() { void dispose() {
@ -75,9 +78,6 @@ class _IntegralDetailedPage extends State<IntegralDetailedPage>
}); });
} }
int current = 1;
List<UserBill> userBill = [];
queryDetail(category,type) async { queryDetail(category,type) async {
BaseData<PageInfo<UserBill>> baseData = await apiService.queryBillInfo({ BaseData<PageInfo<UserBill>> baseData = await apiService.queryBillInfo({
"current": current, "current": current,
@ -106,7 +106,6 @@ class _IntegralDetailedPage extends State<IntegralDetailedPage>
} }
} }
RefreshController refreshController = RefreshController();
_onRefresh() { _onRefresh() {
current = 1; current = 1;

44
lib/order/exchange_history_page.dart

@ -1,6 +1,7 @@
import 'package:dio/dio.dart'; import 'package:dio/dio.dart';
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_easyloading/flutter_easyloading.dart';
import 'package:huixiang/generated/l10n.dart'; import 'package:huixiang/generated/l10n.dart';
import 'package:huixiang/retrofit/data/base_data.dart'; import 'package:huixiang/retrofit/data/base_data.dart';
import 'package:huixiang/retrofit/data/exchange_order.dart'; import 'package:huixiang/retrofit/data/exchange_order.dart';
@ -125,25 +126,25 @@ class ExchangeHistoryList extends StatefulWidget {
class _ExchangeHistoryList extends State<ExchangeHistoryList> class _ExchangeHistoryList extends State<ExchangeHistoryList>
with AutomaticKeepAliveClientMixin{ with AutomaticKeepAliveClientMixin{
ApiService apiService; ApiService apiService;
RefreshController _refreshController = RefreshController(initialRefresh: false);
RefreshController _refreshController = int pageNum = 1;
RefreshController(initialRefresh: false); List<ExchangeOrder> orders = [];
@override @override
void initState() { void initState() {
super.initState(); super.initState();
SharedPreferences.getInstance().then((value) => { SharedPreferences.getInstance().then((value) => {
apiService = ApiService(Dio(), apiService = ApiService(Dio(),
showLoading: true, showLoading: false,
context: context, token: value.getString('token')), context: context, token: value.getString('token')),
queryHistory(), queryHistory(),
}); });
} }
int pageNum = 1; queryHistory({isLoading = true}) async {
List<ExchangeOrder> orders = []; try{
if(isLoading)
queryHistory() async { EasyLoading.show(status: S.current.zhengzaijiazai,maskType: EasyLoadingMaskType.black);
var map = { var map = {
"pageNum": pageNum, "pageNum": pageNum,
"pageSize": 10, "pageSize": 10,
@ -162,7 +163,6 @@ class _ExchangeHistoryList extends State<ExchangeHistoryList>
orders.clear(); orders.clear();
} }
orders.addAll(baseData.data.list); orders.addAll(baseData.data.list);
setState(() {
_refreshController.loadComplete(); _refreshController.loadComplete();
_refreshController.refreshCompleted(); _refreshController.refreshCompleted();
if (baseData.data.pages == baseData.data.pageNum) { if (baseData.data.pages == baseData.data.pageNum) {
@ -170,16 +170,18 @@ class _ExchangeHistoryList extends State<ExchangeHistoryList>
} else { } else {
pageNum += 1; pageNum += 1;
} }
});
} else { } else {
_refreshController.refreshFailed(); _refreshController.refreshFailed();
_refreshController.loadFailed(); _refreshController.loadFailed();
}}finally{
EasyLoading.dismiss();
setState(() {});
} }
} }
_refresh() { _refresh() {
pageNum = 1; pageNum = 1;
queryHistory(); queryHistory(isLoading: false);
} }
@override @override
@ -531,17 +533,15 @@ class _ExchangeHistoryList extends State<ExchangeHistoryList>
GestureDetector( GestureDetector(
behavior: HitTestBehavior.opaque, behavior: HitTestBehavior.opaque,
onTap: () { onTap: () {
setState(() { Navigator.of(context).pushNamed(
Navigator.of(context).pushNamed( '/router/logistics_information_page',
'/router/logistics_information_page', arguments: {
arguments: { "orderId": exchangeOrder.creditOrderDetailList[0].orderId,
"orderId": exchangeOrder.creditOrderDetailList[0].orderId, "logisticsNum": "",
"logisticsNum": "", "logisticsName": "",
"logisticsName": "", "productNum": exchangeOrder.creditOrderDetailList[0].goodsNumber,
"productNum": exchangeOrder.creditOrderDetailList[0].goodsNumber, "skuImg":exchangeOrder.creditOrderDetailList[0].goodsMainImg
"skuImg":exchangeOrder.creditOrderDetailList[0].goodsMainImg });
});
});
}, },
child: buildBtnStatusTow(exchangeOrder.sendStatus), child: buildBtnStatusTow(exchangeOrder.sendStatus),
)) ))

Loading…
Cancel
Save