From bf7d4dba8e17f5de834e7d7a0954e5414bb730ac Mon Sep 17 00:00:00 2001 From: CYH <13923927013@163.com> Date: Wed, 26 Jul 2023 17:29:12 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=9C=88=E5=AD=90=E5=88=97?= =?UTF-8?q?=E8=A1=A8=E5=8A=A0=E8=BD=BD=E6=9B=B4=E5=A4=9A=E5=9C=88=E5=AD=90?= =?UTF-8?q?=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- circle_app/lib/app/circle/logic.dart | 25 ++++++++++++++++++++----- circle_app/lib/app/my_circle/logic.dart | 2 +- 2 files changed, 21 insertions(+), 6 deletions(-) diff --git a/circle_app/lib/app/circle/logic.dart b/circle_app/lib/app/circle/logic.dart index bc0a96f..2d5c6c6 100644 --- a/circle_app/lib/app/circle/logic.dart +++ b/circle_app/lib/app/circle/logic.dart @@ -17,15 +17,20 @@ class CircleLogic extends GetxController { Map? statistics; int page = 1; + bool isMore = true; + @override void onInit() async { super.onInit(); var data = await DioManager.instance - .get(url: Api.getCircleInterests, params: {"page": page}); + .get(url: Api.getCircleInterests, params: {"page": page,'page_size':20}); var bean = BaseResponse.fromJson( data, (data) => InterestsBean.fromJson(data)); if(bean.data is InterestsBean&&bean.isSuccess()){ circle = bean.data!; + if (circle.lists.length < 20) { + isMore = false; + } update(); } @@ -33,13 +38,23 @@ class CircleLogic extends GetxController { } loadMore() async { - page = page++; + if (!isMore) return; + page = page + 1; var data = await DioManager.instance - .get(url: Api.getCircleInterests, params: {"page": page}); + .get(url: Api.getCircleInterests, params: {"page": page,'page_size':20}); var bean = BaseResponse.fromJson( data, (data) => InterestsBean.fromJson(data)); - circle = bean.data!; - update(); + + InterestsBean newcircle = bean.data!; + if (newcircle.lists.isNotEmpty) { + + if (newcircle.lists.length < 20) { + isMore = false; + } + circle.lists.addAll(newcircle.lists); + update(); + } + } outCircle(String interest_id, bool isStatus) async { diff --git a/circle_app/lib/app/my_circle/logic.dart b/circle_app/lib/app/my_circle/logic.dart index 57fc6e9..7660374 100644 --- a/circle_app/lib/app/my_circle/logic.dart +++ b/circle_app/lib/app/my_circle/logic.dart @@ -33,7 +33,7 @@ class MyCircleLogic extends GetxController { } loadMore() async { - page = page++; + page = page+1; var data = await DioManager.instance .get(url: Api.getMyCircleInterests, params: {"page": page,'page_size':20}); var bean = BaseResponse.fromJson(