From b53a6d155a7884a5cd76db4cd462ac6fe1098b24 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E5=8D=8E=E8=BD=A9?= <646903573@qq.com> Date: Mon, 16 Nov 2020 16:42:24 +0800 Subject: [PATCH] =?UTF-8?q?1.=E7=83=AD=E6=A6=9C=20-=20=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E5=8A=A0=E8=BD=BD=E6=97=B6=E7=9A=84loading=E6=98=BE=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../hot_ranking_list/hot_ranking_bloc.dart | 12 +++++++----- .../hot_ranking_list/hot_ranking_list.dart | 5 +++++ 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/lib/widgets/hot_ranking/hot_ranking_list/hot_ranking_bloc.dart b/lib/widgets/hot_ranking/hot_ranking_list/hot_ranking_bloc.dart index fbebe46..709b423 100644 --- a/lib/widgets/hot_ranking/hot_ranking_list/hot_ranking_bloc.dart +++ b/lib/widgets/hot_ranking/hot_ranking_list/hot_ranking_bloc.dart @@ -4,6 +4,7 @@ import 'dart:convert'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:pull_to_refresh/pull_to_refresh.dart'; +import 'package:zhiying_base_widget/dialog/loading/loading.dart'; import 'package:zhiying_base_widget/dialog/loading/loading_dialog.dart'; import 'package:zhiying_base_widget/widgets/hot_ranking/hot_ranking_list/model/hot_ranking_list_data_model.dart'; import 'package:zhiying_comm/util/base_bloc.dart'; @@ -29,7 +30,7 @@ class HotRankingListBloc extends BlocBase { _dataController = null; } - void loadData(String typeId, int page,Function complete) { + void loadData(String typeId, int page, Function complete) { if (isLoading) { complete(); return; @@ -39,17 +40,18 @@ class HotRankingListBloc extends BlocBase { NetUtil.request( '/api/v1/rec/taobao?type_id=' + typeId + '&page=' + page.toString(), method: NetMethod.GET, onSuccess: (data) { - - complete(); + complete(); isLoading = false; _loadData(data); + Loading.dismiss(); }, onError: (e) { - complete(); + Loading.dismiss(); + complete(); isLoading = false; }); } - void loadMoreData(String typeId,Function complete) { + void loadMoreData(String typeId, Function complete) { if (isLoading) { complete(); return; diff --git a/lib/widgets/hot_ranking/hot_ranking_list/hot_ranking_list.dart b/lib/widgets/hot_ranking/hot_ranking_list/hot_ranking_list.dart index f686bfc..3db5fdd 100644 --- a/lib/widgets/hot_ranking/hot_ranking_list/hot_ranking_list.dart +++ b/lib/widgets/hot_ranking/hot_ranking_list/hot_ranking_list.dart @@ -2,6 +2,7 @@ import 'dart:convert'; import 'package:flutter/material.dart'; import 'package:pull_to_refresh/pull_to_refresh.dart'; +import 'package:zhiying_base_widget/dialog/loading/loading.dart'; import 'package:zhiying_base_widget/dialog/loading/loading_dialog.dart'; import 'package:zhiying_base_widget/pages/hot_ranking_page/hot_ranking_page_bloc.dart'; import 'package:zhiying_base_widget/widgets/hot_ranking/hot_ranking_goods/hot_ranking_goods.dart'; @@ -46,6 +47,10 @@ class _HotRankingState extends State if (_pageBloc != null) { _pageBloc.event.listen((event) { if (event.containsKey('type') && event['type'] == "loadData") { + if(!isFirstTime){ + Loading.show(context); + } + isFirstTime=false; _bloc.currentPage = 1; _bloc.loadData(event['type_id'], _bloc.currentPage, () {}); _scrollcontroller.animateTo(0,