Browse Source

门店列表新,优惠券列表,订单列表增骨架屏;

dev
wurong 1 year ago
parent
commit
f3eb8d0776
  1. 122
      lib/mine/coupon_page.dart
  2. 221
      lib/order/order_history_page.dart
  3. 38
      lib/union/union_list.dart

122
lib/mine/coupon_page.dart

@ -20,6 +20,7 @@ import 'package:huixiang/view_widget/selector_store_dialog.dart';
import 'package:pull_to_refresh/pull_to_refresh.dart'; import 'package:pull_to_refresh/pull_to_refresh.dart';
import 'package:shared_preferences/shared_preferences.dart'; import 'package:shared_preferences/shared_preferences.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:shimmer/shimmer.dart';
class CouponPage extends StatefulWidget { class CouponPage extends StatefulWidget {
@override @override
@ -31,6 +32,7 @@ class CouponPage extends StatefulWidget {
class _CouponPage extends State<CouponPage> { class _CouponPage extends State<CouponPage> {
ApiService apiService; ApiService apiService;
RefreshController _refreshController; RefreshController _refreshController;
int networkStatus = 0;
@override @override
void dispose() { void dispose() {
@ -67,6 +69,7 @@ class _CouponPage extends State<CouponPage> {
"searchKey": "", "searchKey": "",
"state": state "state": state
}).catchError((error) { }).catchError((error) {
networkStatus = -1;
_refreshController.loadFailed(); _refreshController.loadFailed();
_refreshController.refreshFailed(); _refreshController.refreshFailed();
}); });
@ -84,6 +87,7 @@ class _CouponPage extends State<CouponPage> {
pageNum += 1; pageNum += 1;
} }
}); });
networkStatus = 1;
} else { } else {
_refreshController.loadFailed(); _refreshController.loadFailed();
_refreshController.refreshFailed(); _refreshController.refreshFailed();
@ -166,7 +170,7 @@ class _CouponPage extends State<CouponPage> {
0xFFFFFFFF), 0xFFFFFFFF),
), ),
child: Text( child: Text(
"已使用", S.of(context).yishiyong,
style: TextStyle( style: TextStyle(
fontWeight: MyFontWeight.medium, fontWeight: MyFontWeight.medium,
fontSize: 15.sp, fontSize: 15.sp,
@ -200,9 +204,7 @@ class _CouponPage extends State<CouponPage> {
0xFFFFFFFF), 0xFFFFFFFF),
), ),
child: Text( child: Text(
S S.of(context).shixiaoquan,
.of(context)
.shixiaoquan,
style: TextStyle( style: TextStyle(
fontWeight: MyFontWeight.medium, fontWeight: MyFontWeight.medium,
fontSize: 15.sp, fontSize: 15.sp,
@ -229,7 +231,17 @@ class _CouponPage extends State<CouponPage> {
), ),
onRefresh: _onRefresh, onRefresh: _onRefresh,
onLoading: queryCard, onLoading: queryCard,
child: (coupons != null && coupons.length > 0) child: networkStatus == 0 ? ListView.builder(
itemCount: 10,
physics: BouncingScrollPhysics(),
shrinkWrap: true,
itemBuilder: (context, position) {
return GestureDetector(
onTap: () {},
child: couponItemSm(),
);
},
):((coupons != null && coupons.length > 0)
? ListView.builder( ? ListView.builder(
itemBuilder: (context, position) { itemBuilder: (context, position) {
return GestureDetector( return GestureDetector(
@ -279,7 +291,7 @@ class _CouponPage extends State<CouponPage> {
text: state == 1 ? "目前暂无优惠券,请到领劵中心领取哦~" :(state == 2 ? "目前暂无已使用的优惠券哦~" :"目前暂无失效的优惠券哦~"), text: state == 1 ? "目前暂无优惠券,请到领劵中心领取哦~" :(state == 2 ? "目前暂无已使用的优惠券哦~" :"目前暂无失效的优惠券哦~"),
fontSize: 16.sp, fontSize: 16.sp,
margin: EdgeInsets.only(top: 120.h, left: 60, right: 60), margin: EdgeInsets.only(top: 120.h, left: 60, right: 60),
), )),
), ),
), ),
], ],
@ -326,4 +338,102 @@ class _CouponPage extends State<CouponPage> {
}); });
} }
Widget couponItemSm(){
return Container(
height:143.h,
width: double.infinity,
margin: EdgeInsets.fromLTRB(14.w, 6.h, 14.w, 6.h),
padding: EdgeInsets.only(right:13.w,top: 12.h,bottom: 13.h,left: 18.w),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(6),
boxShadow: [
BoxShadow(
color: Colors.black.withAlpha(12),
offset: Offset(0, 3),
blurRadius: 14,
spreadRadius: 0,
)
],
),
child:Row(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.start,
children: [
Expanded(child:Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.start,
children: [
Shimmer.fromColors(
baseColor: Color(0XFFD8D8D8),
highlightColor: Color(0XFFD8D8D8),
child: Container(
color: Color(0XFFD8D8D8),
width:143.w,
height: 21.h,
),
),
SizedBox(height: 6.h,),
Shimmer.fromColors(
baseColor: Color(0XFFD8D8D8),
highlightColor: Color(0XFFD8D8D8),
child: Container(
color: Color(0XFFD8D8D8),
width:150.w,
height:17.h,
),
),
Spacer(),
Shimmer.fromColors(
baseColor: Color(0XFFD8D8D8),
highlightColor: Color(0XFFD8D8D8),
child: Container(
color: Color(0XFFD8D8D8),
width:48.w,
height: 17.h,
),
),
],
)),
Column(
children: [
Shimmer.fromColors(
baseColor: Color(0XFFD8D8D8),
highlightColor: Color(0XFFD8D8D8),
child: Container(
color: Color(0XFFD8D8D8),
width:50.w,
height: 50.h,
),
),
SizedBox(height: 10.h,),
Shimmer.fromColors(
baseColor: Color(0XFFD8D8D8),
highlightColor: Color(0XFFD8D8D8),
child: Container(
color: Color(0XFFD8D8D8),
width:59.w,
height:17.h,
),
),
SizedBox(height:15.h,),
Shimmer.fromColors(
baseColor: Color(0XFFD8D8D8),
highlightColor: Color(0XFFD8D8D8),
child: Container(
decoration: BoxDecoration(
color: Color(0XFFD8D8D8),
borderRadius: BorderRadius.circular(10),
),
width:64.w,
height: 19.h,
),
)
],
)
],
),
);
}
} }

221
lib/order/order_history_page.dart

@ -9,7 +9,6 @@ import 'package:huixiang/retrofit/data/base_data.dart';
import 'package:huixiang/retrofit/data/order_info.dart'; import 'package:huixiang/retrofit/data/order_info.dart';
import 'package:huixiang/retrofit/data/order_product_vo.dart'; import 'package:huixiang/retrofit/data/order_product_vo.dart';
import 'package:huixiang/retrofit/data/page.dart'; import 'package:huixiang/retrofit/data/page.dart';
import 'package:huixiang/retrofit/data/product.dart';
import 'package:huixiang/retrofit/min_api.dart'; import 'package:huixiang/retrofit/min_api.dart';
import 'package:huixiang/retrofit/retrofit_api.dart'; import 'package:huixiang/retrofit/retrofit_api.dart';
import 'package:huixiang/store/scan.dart'; import 'package:huixiang/store/scan.dart';
@ -24,6 +23,7 @@ import 'package:huixiang/view_widget/tips_dialog.dart';
import 'package:pull_to_refresh/pull_to_refresh.dart'; import 'package:pull_to_refresh/pull_to_refresh.dart';
import 'package:shared_preferences/shared_preferences.dart'; import 'package:shared_preferences/shared_preferences.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:shimmer/shimmer.dart';
import '../retrofit/data/user_info.dart'; import '../retrofit/data/user_info.dart';
@ -139,12 +139,14 @@ class _OrderHistoryList extends State<OrderHistoryList>
int current = 1; int current = 1;
List<OrderInfo> orderInfos = []; List<OrderInfo> orderInfos = [];
UserInfo userInfo; UserInfo userInfo;
int networkStatus = 0;
@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: true,
context: context, context: context,
token: value.getString("token")), token: value.getString("token")),
queryOrder(), queryOrder(),
@ -157,7 +159,10 @@ class _OrderHistoryList extends State<OrderHistoryList>
queryOrder(); queryOrder();
} }
queryOrder() async { queryOrder({bool isLoading = true}) async {
try{
if(isLoading)
EasyLoading.show(status: S.current.zhengzaijiazai,maskType: EasyLoadingMaskType.black);
BaseData<PageInfo<OrderInfo>> baseData = await apiService.orderList({ BaseData<PageInfo<OrderInfo>> baseData = await apiService.orderList({
"current": current, "current": current,
"model": {"status": widget.orderStatus}, "model": {"status": widget.orderStatus},
@ -165,6 +170,7 @@ class _OrderHistoryList extends State<OrderHistoryList>
"size": 10, "size": 10,
"sort": "id" "sort": "id"
}).catchError((onError) { }).catchError((onError) {
networkStatus = -1;
refreshController.refreshFailed(); refreshController.refreshFailed();
refreshController.loadFailed(); refreshController.loadFailed();
}); });
@ -186,11 +192,14 @@ class _OrderHistoryList extends State<OrderHistoryList>
current += 1; current += 1;
} }
setState(() {}); setState(() {});
networkStatus = 1;
} else { } else {
if((baseData?.msg ?? "") != "") if((baseData?.msg ?? "") != "")
SmartDialog.showToast(baseData.msg,alignment: Alignment.center); SmartDialog.showToast(baseData.msg,alignment: Alignment.center);
refreshController.refreshFailed(); refreshController.refreshFailed();
refreshController.loadFailed(); refreshController.loadFailed();
}}finally{
EasyLoading.dismiss();
} }
} }
@ -333,8 +342,20 @@ class _OrderHistoryList extends State<OrderHistoryList>
}, },
), ),
onRefresh: _onRefresh, onRefresh: _onRefresh,
onLoading: queryOrder, onLoading: (){
child: (orderInfos != null && orderInfos.length > 0) queryOrder(isLoading: false);
},
child: networkStatus == 0 ? ListView.builder(
itemCount: 10,
physics: BouncingScrollPhysics(),
shrinkWrap: true,
itemBuilder: (context, position) {
return GestureDetector(
onTap: () {},
child: orderItemSm(),
);
},
) : ((orderInfos != null && orderInfos.length > 0)
? ListView.builder( ? ListView.builder(
itemCount: orderInfos != null ? orderInfos.length : 0, itemCount: orderInfos != null ? orderInfos.length : 0,
itemBuilder: (context, position) { itemBuilder: (context, position) {
@ -352,7 +373,7 @@ class _OrderHistoryList extends State<OrderHistoryList>
text: "目前暂无订单,快去下一单吧~", text: "目前暂无订单,快去下一单吧~",
fontSize: 16.sp, fontSize: 16.sp,
margin: EdgeInsets.only(top: 120), margin: EdgeInsets.only(top: 120),
), )),
); );
} }
@ -714,6 +735,194 @@ class _OrderHistoryList extends State<OrderHistoryList>
.toList(); .toList();
} }
Widget orderItemSm() {
return Container(
margin: EdgeInsets.fromLTRB(16.w, 8.h, 16.w, 8.h),
padding: EdgeInsets.only(top: 12,bottom: 13.h,left: 13.w),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(4),
boxShadow: [
BoxShadow(
color: Colors.black.withAlpha(25),
offset: Offset(0, 1),
blurRadius: 12,
spreadRadius: 0,
),
],
),
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceAround,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Shimmer.fromColors(
baseColor: Color(0XFFD8D8D8),
highlightColor: Color(0XFFD8D8D8),
child: Container(
color: Color(0XFFD8D8D8),
width:213.w,
height: 20.h,
),
),
Padding(
padding: EdgeInsets.only(right: 12.w),
child: Shimmer.fromColors(
baseColor: Color(0XFFD8D8D8),
highlightColor: Color(0XFFD8D8D8),
child: Container(
color: Color(0XFFD8D8D8),
width:44.w,
height: 20.h,
),
),
),
],
),
Container(
margin: EdgeInsets.only(top:5.h),
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Shimmer.fromColors(
baseColor: Color(0XFFD8D8D8),
highlightColor: Color(0XFFD8D8D8),
child: Container(
color: Color(0XFFD8D8D8),
width:160.w,
height: 16.h,
),
),
SizedBox(
height: 8.h,
),
Row(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Expanded(
child: goodsItemSm(),
flex: 1,
),
Padding(
padding: EdgeInsets.all(22.w),
child: Image.asset(
"assets/image/icon_order_more.webp",
width: 24,
height: 24,
),
)
],
),
],
),
),
SizedBox(
height: 12.h,
),
Container(
alignment: Alignment.centerRight,
margin: EdgeInsets.only(right: 12.w, bottom: 12.h),
child: Directionality(
textDirection: TextDirection.rtl,
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Shimmer.fromColors(
baseColor: Color(0XFFD8D8D8),
highlightColor: Color(0XFFD8D8D8),
child: Container(
color: Color(0XFFD8D8D8),
width:75.w,
height: 20.h,
),
),
SizedBox(
width: 4.w,
),
Shimmer.fromColors(
baseColor: Color(0XFFD8D8D8),
highlightColor: Color(0XFFD8D8D8),
child: Container(
color: Color(0XFFD8D8D8),
width:33.w,
height: 17.h,
),
),
],
),
SizedBox(
height: 8.h,
),
Shimmer.fromColors(
baseColor: Color(0XFFD8D8D8),
highlightColor: Color(0XFFD8D8D8),
child: Container(
decoration: BoxDecoration(
color: Color(0XFFD8D8D8),
borderRadius: BorderRadius.circular(10),
),
width:72.w,
height: 25.h,
),
)
],
),
),
),
],
),
);
}
Widget goodsItemSm(){
return Container(
child: Row(
children: [
Shimmer.fromColors(
baseColor: Color(0XFFD8D8D8),
highlightColor: Color(0XFFD8D8D8),
child: Container(
color: Color(0XFFD8D8D8),
width:75.w,
height: 75.h,
),
),
SizedBox(width: 8.w),
Shimmer.fromColors(
baseColor: Color(0XFFD8D8D8),
highlightColor: Color(0XFFD8D8D8),
child: Container(
color: Color(0XFFD8D8D8),
width:75.w,
height: 75.h,
),
),
SizedBox(width: 8.w),
Shimmer.fromColors(
baseColor: Color(0XFFD8D8D8),
highlightColor: Color(0XFFD8D8D8),
child: Container(
color: Color(0XFFD8D8D8),
width:75.w,
height: 75.h,
),
),
],
)
);
}
@override @override
bool get wantKeepAlive => true; bool get wantKeepAlive => true;
} }

38
lib/union/union_list.dart

@ -2,14 +2,11 @@ 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_baidu_mapapi_base/flutter_baidu_mapapi_base.dart'; import 'package:flutter_baidu_mapapi_base/flutter_baidu_mapapi_base.dart';
import 'package:flutter_baidu_mapapi_utils/flutter_baidu_mapapi_utils.dart';
import 'package:flutter_bmflocation/flutter_bmflocation.dart';
import 'package:flutter_easyloading/flutter_easyloading.dart'; import 'package:flutter_easyloading/flutter_easyloading.dart';
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart'; import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
import 'package:huixiang/generated/l10n.dart'; import 'package:huixiang/generated/l10n.dart';
import 'package:huixiang/retrofit/data/store.dart'; import 'package:huixiang/retrofit/data/store.dart';
import 'package:huixiang/utils/font_weight.dart'; import 'package:huixiang/utils/font_weight.dart';
import 'package:huixiang/utils/location.dart';
import 'package:huixiang/view_widget/custom_image.dart'; import 'package:huixiang/view_widget/custom_image.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:pull_to_refresh/pull_to_refresh.dart'; import 'package:pull_to_refresh/pull_to_refresh.dart';
@ -44,6 +41,7 @@ class _UnionList extends State<UnionList> with AutomaticKeepAliveClientMixin {
List<Store> storeList; List<Store> storeList;
BMFCoordinate latLng; BMFCoordinate latLng;
final RefreshController _refreshController = RefreshController(); final RefreshController _refreshController = RefreshController();
int networkStatus = 0;
@override @override
bool get wantKeepAlive => true; bool get wantKeepAlive => true;
@ -75,11 +73,13 @@ class _UnionList extends State<UnionList> with AutomaticKeepAliveClientMixin {
}).catchError((error) { }).catchError((error) {
SmartDialog.showToast(AppUtils.dioErrorTypeToString(error.type), SmartDialog.showToast(AppUtils.dioErrorTypeToString(error.type),
alignment: Alignment.center); alignment: Alignment.center);
networkStatus = -1;
_refreshController.refreshFailed(); _refreshController.refreshFailed();
}); });
if (baseData != null && baseData.isSuccess) { if (baseData != null && baseData.isSuccess) {
storeList = baseData.data; storeList = baseData.data;
_refreshController.refreshCompleted(); _refreshController.refreshCompleted();
networkStatus = 1;
} else { } else {
_refreshController.refreshFailed(); _refreshController.refreshFailed();
SmartDialog.showToast(baseData.msg, alignment: Alignment.center); SmartDialog.showToast(baseData.msg, alignment: Alignment.center);
@ -99,7 +99,18 @@ class _UnionList extends State<UnionList> with AutomaticKeepAliveClientMixin {
), ),
physics: BouncingScrollPhysics(), physics: BouncingScrollPhysics(),
onRefresh: queryStore, onRefresh: queryStore,
child: (storeList == null || storeList.length == 0) child: networkStatus == 0 ?
ListView.builder(
itemCount: 10,
physics: BouncingScrollPhysics(),
shrinkWrap: true,
itemBuilder: (context, position) {
return GestureDetector(
onTap: () {},
child: buildStoreItemSm(),
);
},
):((storeList == null || storeList.length == 0)
? NoDataView( ? NoDataView(
src: "assets/image/di_zhi.webp", src: "assets/image/di_zhi.webp",
isShowBtn: false, isShowBtn: false,
@ -132,19 +143,26 @@ class _UnionList extends State<UnionList> with AutomaticKeepAliveClientMixin {
child: buildStoreItem(storeList[position], position), child: buildStoreItem(storeList[position], position),
); );
}, },
), )),
); );
} }
Widget sm() { Widget buildStoreItemSm() {
return Container( return Container(
margin: EdgeInsets.symmetric(horizontal: 14.w, vertical: 8.h), margin: EdgeInsets.fromLTRB(16.w, 8.h, 16.w, 12.h),
padding: EdgeInsets.symmetric(horizontal:12.w,vertical: 12.h),
width: double.infinity, width: double.infinity,
decoration: BoxDecoration( decoration: BoxDecoration(
color: Colors.white, color: Colors.white,
borderRadius: BorderRadius.circular(6), borderRadius: BorderRadius.all(Radius.circular(6)),
), boxShadow: [
height: 223.h, BoxShadow(
color: Colors.black.withAlpha(25),
offset: Offset(0, 1),
blurRadius: 12,
spreadRadius: 0,
)
]),
child: Column( child: Column(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [

Loading…
Cancel
Save