Browse Source

社群列表优化

remove_uniapp
w-R 3 years ago
parent
commit
362eb452cc
  1. 13
      lib/community/community_child_page.dart
  2. 3
      lib/mine/personal_page.dart
  3. 2
      lib/retrofit/min_api.dart
  4. 2
      lib/retrofit/retrofit_api.dart

13
lib/community/community_child_page.dart

@ -33,6 +33,8 @@ class CommunityChildPageState extends State<CommunityChildPage> with AutomaticKe
int pageNum = 1; int pageNum = 1;
String userId; String userId;
bool isLoadMore = false; bool isLoadMore = false;
bool isRefresh = true;
bool isLoadingData = false;
ScrollController sc = ScrollController(); ScrollController sc = ScrollController();
List<Article> articles = []; List<Article> articles = [];
@ -52,6 +54,14 @@ class CommunityChildPageState extends State<CommunityChildPage> with AutomaticKe
/// ///
queryCommunity() async { queryCommunity() async {
if(!isRefresh){
isRefresh = true;
return;
}
if(isLoadingData){
return;
}
isLoadingData = true;
if (apiService == null) { if (apiService == null) {
SharedPreferences value = await SharedPreferences.getInstance(); SharedPreferences value = await SharedPreferences.getInstance();
userId = value.getString('userId'); userId = value.getString('userId');
@ -107,6 +117,8 @@ class CommunityChildPageState extends State<CommunityChildPage> with AutomaticKe
refreshController.loadNoData(); refreshController.loadNoData();
} }
} }
isLoadingData = false;
} }
@override @override
@ -191,6 +203,7 @@ class CommunityChildPageState extends State<CommunityChildPage> with AutomaticKe
if (baseData != null && baseData.isSuccess) { if (baseData != null && baseData.isSuccess) {
this.articles.forEach((element) { this.articles.forEach((element) {
if(element.id == id){ if(element.id == id){
isRefresh = false;
setState(() { setState(() {
element.likes = baseData.data.likes; element.likes = baseData.data.likes;
element.viewers = baseData.data.viewers; element.viewers = baseData.data.viewers;

3
lib/mine/personal_page.dart

@ -142,6 +142,9 @@ class _PersonalPage extends State<PersonalPage> with WidgetsBindingObserver {
article.likes = element?.likes; article.likes = element?.likes;
article.comments = element?.comments; article.comments = element?.comments;
articles.add(article); articles.add(article);
});
setState(() {
}); });
// print("comments: ${comments.length}"); // print("comments: ${comments.length}");
if (int.tryParse(baseData.data.total) < (pageNum * 10)) { if (int.tryParse(baseData.data.total) < (pageNum * 10)) {

2
lib/retrofit/min_api.dart

@ -32,7 +32,7 @@ part 'min_api.g.dart';
// const base_url = "http://192.168.10.37:8766/app/"; // const base_url = "http://192.168.10.37:8766/app/";
const localBaseUrl = "http://192.168.10.78:8765/app/";/// const localBaseUrl = "https://pos.api.lotus-wallet.com/app/";///
const serviceBaseUrl = "https://pos.api.lotus-wallet.com/app/";///线 const serviceBaseUrl = "https://pos.api.lotus-wallet.com/app/";///线

2
lib/retrofit/retrofit_api.dart

@ -68,7 +68,7 @@ part 'retrofit_api.g.dart';
// const base_url = "http://192.168.10.132:8766/app/";/// // const base_url = "http://192.168.10.132:8766/app/";///
const localBaseUrl = "http://192.168.10.78:8766/app/";/// const localBaseUrl = "https://pos.platform.lotus-wallet.com/app/";///
const serviceBaseUrl = "https://pos.platform.lotus-wallet.com/app/";///线 const serviceBaseUrl = "https://pos.platform.lotus-wallet.com/app/";///线
@RestApi(baseUrl: localBaseUrl) @RestApi(baseUrl: localBaseUrl)

Loading…
Cancel
Save