From f3eb8d0776b5f8d284ff31a2177457032a8093e4 Mon Sep 17 00:00:00 2001 From: wurong <953969641@qq.com> Date: Wed, 22 Nov 2023 16:58:37 +0800 Subject: [PATCH] =?UTF-8?q?=E9=97=A8=E5=BA=97=E5=88=97=E8=A1=A8=E6=96=B0?= =?UTF-8?q?=EF=BC=8C=E4=BC=98=E6=83=A0=E5=88=B8=E5=88=97=E8=A1=A8=EF=BC=8C?= =?UTF-8?q?=E8=AE=A2=E5=8D=95=E5=88=97=E8=A1=A8=E5=A2=9E=E9=AA=A8=E6=9E=B6?= =?UTF-8?q?=E5=B1=8F=EF=BC=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/mine/coupon_page.dart | 122 ++++++++++++++++- lib/order/order_history_page.dart | 221 +++++++++++++++++++++++++++++- lib/union/union_list.dart | 38 +++-- 3 files changed, 359 insertions(+), 22 deletions(-) diff --git a/lib/mine/coupon_page.dart b/lib/mine/coupon_page.dart index 7ea4efef..c7edf812 100644 --- a/lib/mine/coupon_page.dart +++ b/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:shared_preferences/shared_preferences.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; +import 'package:shimmer/shimmer.dart'; class CouponPage extends StatefulWidget { @override @@ -31,6 +32,7 @@ class CouponPage extends StatefulWidget { class _CouponPage extends State { ApiService apiService; RefreshController _refreshController; + int networkStatus = 0; @override void dispose() { @@ -67,6 +69,7 @@ class _CouponPage extends State { "searchKey": "", "state": state }).catchError((error) { + networkStatus = -1; _refreshController.loadFailed(); _refreshController.refreshFailed(); }); @@ -84,6 +87,7 @@ class _CouponPage extends State { pageNum += 1; } }); + networkStatus = 1; } else { _refreshController.loadFailed(); _refreshController.refreshFailed(); @@ -166,7 +170,7 @@ class _CouponPage extends State { 0xFFFFFFFF), ), child: Text( - "已使用", + S.of(context).yishiyong, style: TextStyle( fontWeight: MyFontWeight.medium, fontSize: 15.sp, @@ -200,9 +204,7 @@ class _CouponPage extends State { 0xFFFFFFFF), ), child: Text( - S - .of(context) - .shixiaoquan, + S.of(context).shixiaoquan, style: TextStyle( fontWeight: MyFontWeight.medium, fontSize: 15.sp, @@ -229,7 +231,17 @@ class _CouponPage extends State { ), onRefresh: _onRefresh, 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( itemBuilder: (context, position) { return GestureDetector( @@ -279,7 +291,7 @@ class _CouponPage extends State { text: state == 1 ? "目前暂无优惠券,请到领劵中心领取哦~" :(state == 2 ? "目前暂无已使用的优惠券哦~" :"目前暂无失效的优惠券哦~"), fontSize: 16.sp, margin: EdgeInsets.only(top: 120.h, left: 60, right: 60), - ), + )), ), ), ], @@ -326,4 +338,102 @@ class _CouponPage extends State { }); } + 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, + ), + ) + ], + ) + ], + ), + ); + } + } diff --git a/lib/order/order_history_page.dart b/lib/order/order_history_page.dart index f6011da1..075fcc04 100644 --- a/lib/order/order_history_page.dart +++ b/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_product_vo.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/retrofit_api.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:shared_preferences/shared_preferences.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; +import 'package:shimmer/shimmer.dart'; import '../retrofit/data/user_info.dart'; @@ -139,12 +139,14 @@ class _OrderHistoryList extends State int current = 1; List orderInfos = []; UserInfo userInfo; + int networkStatus = 0; + @override void initState() { super.initState(); SharedPreferences.getInstance().then((value) => { apiService = ApiService(Dio(), - showLoading: true, + // showLoading: true, context: context, token: value.getString("token")), queryOrder(), @@ -157,7 +159,10 @@ class _OrderHistoryList extends State queryOrder(); } - queryOrder() async { + queryOrder({bool isLoading = true}) async { + try{ + if(isLoading) + EasyLoading.show(status: S.current.zhengzaijiazai,maskType: EasyLoadingMaskType.black); BaseData> baseData = await apiService.orderList({ "current": current, "model": {"status": widget.orderStatus}, @@ -165,6 +170,7 @@ class _OrderHistoryList extends State "size": 10, "sort": "id" }).catchError((onError) { + networkStatus = -1; refreshController.refreshFailed(); refreshController.loadFailed(); }); @@ -186,11 +192,14 @@ class _OrderHistoryList extends State current += 1; } setState(() {}); + networkStatus = 1; } else { if((baseData?.msg ?? "") != "") SmartDialog.showToast(baseData.msg,alignment: Alignment.center); refreshController.refreshFailed(); refreshController.loadFailed(); + }}finally{ + EasyLoading.dismiss(); } } @@ -333,8 +342,20 @@ class _OrderHistoryList extends State }, ), onRefresh: _onRefresh, - onLoading: queryOrder, - child: (orderInfos != null && orderInfos.length > 0) + onLoading: (){ + 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( itemCount: orderInfos != null ? orderInfos.length : 0, itemBuilder: (context, position) { @@ -352,7 +373,7 @@ class _OrderHistoryList extends State text: "目前暂无订单,快去下一单吧~", fontSize: 16.sp, margin: EdgeInsets.only(top: 120), - ), + )), ); } @@ -714,6 +735,194 @@ class _OrderHistoryList extends State .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 bool get wantKeepAlive => true; } diff --git a/lib/union/union_list.dart b/lib/union/union_list.dart index 3fef3909..a39b8abc 100644 --- a/lib/union/union_list.dart +++ b/lib/union/union_list.dart @@ -2,14 +2,11 @@ import 'package:dio/dio.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.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_smart_dialog/flutter_smart_dialog.dart'; import 'package:huixiang/generated/l10n.dart'; import 'package:huixiang/retrofit/data/store.dart'; import 'package:huixiang/utils/font_weight.dart'; -import 'package:huixiang/utils/location.dart'; import 'package:huixiang/view_widget/custom_image.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:pull_to_refresh/pull_to_refresh.dart'; @@ -44,6 +41,7 @@ class _UnionList extends State with AutomaticKeepAliveClientMixin { List storeList; BMFCoordinate latLng; final RefreshController _refreshController = RefreshController(); + int networkStatus = 0; @override bool get wantKeepAlive => true; @@ -75,11 +73,13 @@ class _UnionList extends State with AutomaticKeepAliveClientMixin { }).catchError((error) { SmartDialog.showToast(AppUtils.dioErrorTypeToString(error.type), alignment: Alignment.center); + networkStatus = -1; _refreshController.refreshFailed(); }); if (baseData != null && baseData.isSuccess) { storeList = baseData.data; _refreshController.refreshCompleted(); + networkStatus = 1; } else { _refreshController.refreshFailed(); SmartDialog.showToast(baseData.msg, alignment: Alignment.center); @@ -99,7 +99,18 @@ class _UnionList extends State with AutomaticKeepAliveClientMixin { ), physics: BouncingScrollPhysics(), 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( src: "assets/image/di_zhi.webp", isShowBtn: false, @@ -132,19 +143,26 @@ class _UnionList extends State with AutomaticKeepAliveClientMixin { child: buildStoreItem(storeList[position], position), ); }, - ), + )), ); } - Widget sm() { + Widget buildStoreItemSm() { 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, decoration: BoxDecoration( color: Colors.white, - borderRadius: BorderRadius.circular(6), - ), - height: 223.h, + borderRadius: BorderRadius.all(Radius.circular(6)), + boxShadow: [ + BoxShadow( + color: Colors.black.withAlpha(25), + offset: Offset(0, 1), + blurRadius: 12, + spreadRadius: 0, + ) + ]), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [