diff --git a/lib/community/community_course.dart b/lib/community/community_course.dart index 76635efc..8f8f8742 100644 --- a/lib/community/community_course.dart +++ b/lib/community/community_course.dart @@ -87,7 +87,6 @@ class _CommunityCourse extends State refreshController.refreshFailed(); // SmartDialog.showToast(baseData.msg, alignment: Alignment.center); } - SmartDialog.dismiss(); } ///课程分类列表 @@ -101,7 +100,6 @@ class _CommunityCourse extends State }); queryClassList(""); } - SmartDialog.dismiss(); } ///课程列表 @@ -153,7 +151,6 @@ class _CommunityCourse extends State }); }); } - SmartDialog.dismiss(); } ///合集包含的课程列表 diff --git a/lib/community/community_view/course_banner.dart b/lib/community/community_view/course_banner.dart index cf56c9ab..a1236fc0 100644 --- a/lib/community/community_view/course_banner.dart +++ b/lib/community/community_view/course_banner.dart @@ -5,7 +5,9 @@ import 'package:flutter/material.dart'; import 'package:flutter_swiper_view/flutter_swiper_view.dart'; import 'package:huixiang/data/banner.dart'; import 'package:huixiang/retrofit/retrofit_api.dart'; +import 'package:huixiang/utils/shared_preference.dart'; import 'package:huixiang/view_widget/custom_image.dart'; +import 'package:huixiang/view_widget/login_tips_dialog.dart'; import 'package:pull_to_refresh/pull_to_refresh.dart'; class CourseBanner extends StatefulWidget { @@ -73,11 +75,17 @@ class _CourseBanner extends State { /// contentType 跳转类型(0:不跳转,1:积分商品,2:活动,3:文章,4:页面跳转,5:课程,7门店跳转) bannerClick(BannerData bannerData) async { + if (SharedInstance.instance.token.isEmpty) { + LoginTipsDialog.instance.show(context); + return; + } switch (bannerData.contentType) { case 1: Navigator.of(context).pushNamed( '/router/integral_store_page', - arguments: {"goodsId": bannerData.content}, + arguments: { + "goodsId": bannerData.content, + }, ); break; case 2: @@ -125,7 +133,10 @@ class _CourseBanner extends State { } String params = router!.substring(router.indexOf("?")+1); Map map = jsonDecode(params); - Navigator.of(context).pushNamed(router.substring(0, router.indexOf("?")), arguments: map); + Navigator.of(context).pushNamed( + router.substring(0, router.indexOf("?")), + arguments: map, + ); break; } } diff --git a/lib/login/new_login_page.dart b/lib/login/new_login_page.dart index 532a5a25..f5ec1bd9 100644 --- a/lib/login/new_login_page.dart +++ b/lib/login/new_login_page.dart @@ -155,7 +155,7 @@ class _NewLoginPage extends State { Color statusCodeLineColor = Color(0xFFE7E3E3); countdown() { - if (_timer?.isActive ?? true) return; + if (_timer?.isActive ?? false) return; int countdown = 60; _timer = Timer.periodic(Duration(seconds: 1), (timer) { countdown--; @@ -718,9 +718,11 @@ class _NewLoginPage extends State { }, child: Container( width: double.infinity, - height: 57.h, + height: 57, alignment: Alignment.center, - margin: EdgeInsets.only(top: 14.h, bottom: 12.h), + margin: EdgeInsets.only( + top: 14.h, bottom: 12.h, + ), decoration: BoxDecoration( borderRadius: BorderRadius.circular(6), color: Color(0xFF32A060), @@ -740,14 +742,14 @@ class _NewLoginPage extends State { // if (widget.arguments != null) { // Navigator.of(context).pop(); // } else { - ExamineInstance.instance.isExamine = true; + ExamineInstance.instance.isExamine = false; Navigator.of(context) .popAndPushNamed('/router/main_page'); // } }, child: Container( width: double.infinity, - height: 57.h, + height: 57, alignment: Alignment.center, decoration: BoxDecoration( borderRadius: BorderRadius.circular(6), @@ -780,7 +782,7 @@ class _NewLoginPage extends State { "assets/image/login_bott.webp", fit: BoxFit.fill, width: double.infinity, - height: 120.h, + height: 120, ), ) ], @@ -976,8 +978,6 @@ class _NewLoginPage extends State { "mobile": mobile, "verification": v }).catchError((onError) { - SmartDialog.showToast(AppUtils.dioErrorTypeToString(onError.type), - alignment: Alignment.center); return BaseData()..isSuccess = false; }); if (baseData?.isSuccess ?? false) { diff --git a/lib/order/order_history_page.dart b/lib/order/order_history_page.dart index 1d7ea044..dbddd50d 100644 --- a/lib/order/order_history_page.dart +++ b/lib/order/order_history_page.dart @@ -162,51 +162,42 @@ class _OrderHistoryList extends State } queryOrder({bool isLoading = true}) async { - try { - if (isLoading) - SmartDialog.showLoading( - msg: S.current.zhengzaijiazai, - ); - BaseData>? baseData = await apiService?.orderList({ - "current": current, - "model": {"status": widget.orderStatus}, - "order": "descending", - "size": 10, - "sort": "id" - }).catchError((onError) { - networkStatus = -1; - refreshController.refreshFailed(); - refreshController.loadFailed(); - return BaseData>()..isSuccess = false; - }); - if (baseData?.isSuccess ?? false) { - if (baseData!.data != null && - (baseData.data!.records?.isNotEmpty ?? false)) { - if (current == 1) { - orderInfos.clear(); - } - orderInfos.addAll(baseData.data!.records!); + if (isLoading) + SmartDialog.showLoading( + msg: S.current.zhengzaijiazai, + ); + BaseData>? baseData = await apiService?.orderList({ + "current": current, + "model": {"status": widget.orderStatus}, + "order": "descending", + "size": 10, + "sort": "id" + }).catchError((onError) { + networkStatus = -1; + refreshController.refreshFailed(); + refreshController.loadFailed(); + return BaseData>()..isSuccess = false; + }); + if (baseData?.isSuccess ?? false) { + if ((baseData?.data?.records?.isNotEmpty ?? false)) { + if (current == 1) { + orderInfos.clear(); } + orderInfos.addAll(baseData!.data!.records!); + } - refreshController.refreshCompleted(); - refreshController.loadComplete(); - if (current * 10 > (int.tryParse("${baseData.data?.total}") ?? 0)) { - refreshController.loadNoData(); - } else { - current += 1; - } - setState(() {}); - networkStatus = 1; + refreshController.refreshCompleted(); + refreshController.loadComplete(); + if (current * 10 > (int.tryParse("${baseData?.data?.total}") ?? 0)) { + refreshController.loadNoData(); } else { - if (baseData?.msg?.isNotEmpty ?? false) - SmartDialog.showToast( - "${baseData!.msg}", - alignment: Alignment.center, - ); - refreshController.refreshFailed(); - refreshController.loadFailed(); + current += 1; } - } finally { + setState(() {}); + networkStatus = 1; + } else { + refreshController.refreshFailed(); + refreshController.loadFailed(); } } diff --git a/lib/retrofit/min_api.dart b/lib/retrofit/min_api.dart index c7139ccc..e6075137 100644 --- a/lib/retrofit/min_api.dart +++ b/lib/retrofit/min_api.dart @@ -101,9 +101,7 @@ abstract class MinApiService { Map map = response.data; if (map["code"] == 40005 || map["code"] == 40001) { - if (!LoginTipsDialog().isShow) { - LoginTipsDialog().show(context); - } + LoginTipsDialog.instance.show(context); } debugPrint( "======================= Min_响应数据结束 =======================\n"); diff --git a/lib/retrofit/retrofit_api.dart b/lib/retrofit/retrofit_api.dart index 4c902dc9..34f417e9 100644 --- a/lib/retrofit/retrofit_api.dart +++ b/lib/retrofit/retrofit_api.dart @@ -84,8 +84,7 @@ abstract class ApiService { bool pay = true, ParseErrorLogger? errorLogger, }) { - Map headers = - (token == null || token == "") ? {} : {'token': "Bearer $token"}; + Map headers = (token == null || token == "") ? {} : {'token': "Bearer $token"}; if (pay) { headers["Environment"] = "app"; } @@ -107,8 +106,7 @@ abstract class ApiService { RequestInterceptorHandler handler, ) { try { - debugPrint( - "\n======================= 请求数据 ======================="); + debugPrint("\n======================= 请求数据 ======================="); debugPrint("method = ${options.method.toString()}"); debugPrint("url = ${options.uri.toString()}"); debugPrint("headers = ${options.headers}"); @@ -133,11 +131,8 @@ abstract class ApiService { ResponseInterceptorHandler handler, ) { try { - debugPrint( - "\n======================= 响应数据开始 ======================="); - if (showLoading && - SmartDialog.checkExist( - dialogTypes: {SmartAllDialogType.loading})) { + debugPrint("\n======================= 响应数据开始 ======================="); + if (showLoading && SmartDialog.checkExist(dialogTypes: {SmartAllDialogType.loading})) { SmartDialog.dismiss(status: SmartStatus.loading); } debugPrint("code = ${response.statusCode}"); @@ -145,9 +140,8 @@ abstract class ApiService { if (response.data is Map) { Map map = response.data; if (map["code"] == 40005 || map["code"] == 40001) { - if (context != null && !LoginTipsDialog().isShow) { - print("show: ${LoginTipsDialog().isShow}"); - LoginTipsDialog().show(context); + if (context != null) { + LoginTipsDialog.instance.show(context); } } debugPrint("======================= 响应数据结束 =======================\n"); diff --git a/lib/view_widget/login_tips_dialog.dart b/lib/view_widget/login_tips_dialog.dart index 5398306d..436552ac 100644 --- a/lib/view_widget/login_tips_dialog.dart +++ b/lib/view_widget/login_tips_dialog.dart @@ -22,12 +22,14 @@ class LoginTipsDialog { return _instance!; } - bool isShow = false; show(context) { - SmartDialog.dismiss(); - isShow = true; + if (SmartDialog.checkExist(tag: "go-login")) { + return; + } SmartDialog.show( + keepSingle: true, + tag: "go-login", builder: (ctx) { return LoginTips( click: () { @@ -39,9 +41,6 @@ class LoginTipsDialog { }, ); }, - onDismiss: () { - isShow = false; - }, clickMaskDismiss: false, ); }